Added LPC and SMBus stub devices. Moved boost headers out of Zookeeper to speed up compiles.

This commit is contained in:
Cody Brocious 2016-05-21 11:45:28 -06:00
parent d53e5cb51b
commit e3134a6424
10 changed files with 138 additions and 6 deletions

View file

@ -20,6 +20,8 @@ Box::Box() {
debugger = new Debugger();
gpu = new Gpu();
lpc = new Lpc();
smbus = new Smbus();
}
void Box::add_mmio(uint32_t base, uint32_t pages, Device *dev) {

View file

@ -10,7 +10,6 @@ public:
void add_pci(uint16_t bus, uint16_t slot, Device *dev);
Cpu *cpu;
Gpu *gpu;
Hypercall *hypercall;
HandleManager *hm;
PageManager *pm;
@ -18,6 +17,10 @@ public:
IOManager *io;
Debugger *debugger;
Gpu *gpu;
Lpc *lpc;
Smbus *smbus;
map<uint32_t, Device *> mmio;
map<uint32_t, Device *> ports;
map<uint32_t, Device *> pci;

View file

@ -1,4 +1,7 @@
#include "Zookeeper.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
using namespace boost::algorithm;
void break_in(bool fatal) {
if(fatal)

View file

@ -1,7 +1,9 @@
#include "Zookeeper.hpp"
// Comment to enable break_in()s for this file
#define break_in() do { } while(0)
Gpu::Gpu() {
box->add_pci(1, 0, this);
box->add_mmio(0xFD000000, 4096, this); // 4096 pages * 4KB == 16MB address space
box->add_port(0x80c0, this);
}
@ -12,6 +14,7 @@ uint32_t Gpu::readMmio(uint32_t addr) {
return 3;
default:
cout << format("Gpu::readMmio(0x%08x)") % addr << endl;
break_in();
return 0;
}
}

View file

@ -1,4 +1,6 @@
#include "Zookeeper.hpp"
#include <boost/algorithm/string.hpp>
using namespace boost::algorithm;
list<string> parse_path(string path) {
list<string> vec;

43
Lpc.cpp Normal file
View file

@ -0,0 +1,43 @@
#include "Zookeeper.hpp"
// Comment to enable break_in()s for this file
#define break_in() do { } while(0)
Lpc::Lpc() {
box->add_pci(1, 0, this);
}
uint32_t Lpc::readMmio(uint32_t addr) {
switch(addr) {
default:
cout << format("Lpc::readMmio(0x%08x)") % addr << endl;
break_in();
return 0;
}
}
void Lpc::writeMmio(uint32_t addr, uint32_t value) {
cout << format("Lpc::writeMmio(0x%08x, 0x%08x)") % addr % value << endl;
break_in();
}
void Lpc::readPci(uint32_t reg, void *buffer, uint32_t length) {
cout << format("Lpc::readPci(0x%08x, %i)") % reg % length << endl;
break_in();
}
void Lpc::writePci(uint32_t reg, void *buffer, uint32_t length) {
cout << format("Lpc::writePci(0x%08x, %i)") % reg % length << endl;
break_in();
}
uint32_t Lpc::readPort(uint32_t port, uint32_t size) {
cout << format("Lpc::readPort(0x%04x, %i)") % port % size << endl;
break_in();
return 0;
}
void Lpc::writePort(uint32_t port, uint32_t size, uint32_t value) {
cout << format("Lpc::writePort(0x%04x, %i, 0x%x)") % port % size % value << endl;
break_in();
}

16
Lpc.hpp Normal file
View file

@ -0,0 +1,16 @@
#pragma once
#include "Zookeeper.hpp"
class Lpc : public Device {
public:
Lpc();
uint32_t readMmio(uint32_t addr);
void writeMmio(uint32_t addr, uint32_t value);
void readPci(uint32_t reg, void *buffer, uint32_t length);
void writePci(uint32_t reg, void *buffer, uint32_t length);
uint32_t readPort(uint32_t port, uint32_t size);
void writePort(uint32_t port, uint32_t size, uint32_t value);
};

43
Smbus.cpp Normal file
View file

@ -0,0 +1,43 @@
#include "Zookeeper.hpp"
// Comment to enable break_in()s for this file
#define break_in() do { } while(0)
Smbus::Smbus() {
box->add_pci(1, 1, this);
}
uint32_t Smbus::readMmio(uint32_t addr) {
switch(addr) {
default:
cout << format("Smbus::readMmio(0x%08x)") % addr << endl;
break_in();
return 0;
}
}
void Smbus::writeMmio(uint32_t addr, uint32_t value) {
cout << format("Smbus::writeMmio(0x%08x, 0x%08x)") % addr % value << endl;
break_in();
}
void Smbus::readPci(uint32_t reg, void *buffer, uint32_t length) {
cout << format("Smbus::readPci(0x%08x, %i)") % reg % length << endl;
break_in();
}
void Smbus::writePci(uint32_t reg, void *buffer, uint32_t length) {
cout << format("Smbus::writePci(0x%08x, %i)") % reg % length << endl;
break_in();
}
uint32_t Smbus::readPort(uint32_t port, uint32_t size) {
cout << format("Smbus::readPort(0x%04x, %i)") % port % size << endl;
break_in();
return 0;
}
void Smbus::writePort(uint32_t port, uint32_t size, uint32_t value) {
cout << format("Smbus::writePort(0x%04x, %i, 0x%x)") % port % size % value << endl;
break_in();
}

16
Smbus.hpp Normal file
View file

@ -0,0 +1,16 @@
#pragma once
#include "Zookeeper.hpp"
class Smbus : public Device {
public:
Smbus();
uint32_t readMmio(uint32_t addr);
void writeMmio(uint32_t addr, uint32_t value);
void readPci(uint32_t reg, void *buffer, uint32_t length);
void writePci(uint32_t reg, void *buffer, uint32_t length);
uint32_t readPort(uint32_t port, uint32_t size);
void writePort(uint32_t port, uint32_t size, uint32_t value);
};

View file

@ -1,9 +1,6 @@
#pragma once
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
#include <iomanip>
#include <cassert>
@ -11,9 +8,9 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <list>
#include <map>
using namespace std;
using boost::format;
using namespace boost::algorithm;
#define bailout(expr) do { if(expr) { cout << "Bailout: " << #expr << " @ " << __FILE__ << " (" << dec << __LINE__ << ")" << endl; exit(1); } } while(0)
@ -34,9 +31,13 @@ using namespace boost::algorithm;
#include "Hypercall.hpp"
#include "xbetypes.hpp"
#include "Xbe.hpp"
#include "Device.hpp"
#include "Cpu.hpp"
#include "Gpu.hpp"
#include "Lpc.hpp"
#include "Smbus.hpp"
#include "HandleManager.hpp"
#include "PageManager.hpp"
#include "ThreadManager.hpp"