mirror of
https://github.com/daeken/Zookeeper.git
synced 2024-05-15 03:19:29 -04:00
Made devices not require all methods.
This commit is contained in:
parent
e3134a6424
commit
f19e191cbb
39
Device.cpp
Normal file
39
Device.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "Zookeeper.hpp"
|
||||
|
||||
Device::Device(string name) : name(name) {
|
||||
}
|
||||
|
||||
uint32_t Device::readMmio(uint32_t addr) {
|
||||
switch(addr) {
|
||||
default:
|
||||
cout << format("%s::readMmio(0x%08x)") % name % addr << endl;
|
||||
break_in();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Device::writeMmio(uint32_t addr, uint32_t value) {
|
||||
cout << format("%s::writeMmio(0x%08x, 0x%08x)") % name % addr % value << endl;
|
||||
break_in();
|
||||
}
|
||||
|
||||
void Device::readPci(uint32_t reg, void *buffer, uint32_t length) {
|
||||
cout << format("%s::readPci(0x%08x, %i)") % name % reg % length << endl;
|
||||
break_in();
|
||||
}
|
||||
|
||||
void Device::writePci(uint32_t reg, void *buffer, uint32_t length) {
|
||||
cout << format("%s::writePci(0x%08x, %i)") % name % reg % length << endl;
|
||||
break_in();
|
||||
}
|
||||
|
||||
uint32_t Device::readPort(uint32_t port, uint32_t size) {
|
||||
cout << format("%s::readPort(0x%04x, %i)") % name % port % size << endl;
|
||||
break_in();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Device::writePort(uint32_t port, uint32_t size, uint32_t value) {
|
||||
cout << format("%s::writePort(0x%04x, %i, 0x%x)") % name % port % size % value << endl;
|
||||
break_in();
|
||||
}
|
14
Device.hpp
14
Device.hpp
|
@ -4,14 +4,16 @@
|
|||
|
||||
class Device {
|
||||
public:
|
||||
virtual uint32_t readMmio(uint32_t addr) = 0;
|
||||
virtual void writeMmio(uint32_t addr, uint32_t value) = 0;
|
||||
Device(string name);
|
||||
virtual uint32_t readMmio(uint32_t addr);
|
||||
virtual void writeMmio(uint32_t addr, uint32_t value);
|
||||
|
||||
virtual void readPci(uint32_t reg, void *buffer, uint32_t length) = 0;
|
||||
virtual void writePci(uint32_t reg, void *buffer, uint32_t length) = 0;
|
||||
virtual void readPci(uint32_t reg, void *buffer, uint32_t length);
|
||||
virtual void writePci(uint32_t reg, void *buffer, uint32_t length);
|
||||
|
||||
virtual uint32_t readPort(uint32_t port, uint32_t size) = 0;
|
||||
virtual void writePort(uint32_t port, uint32_t size, uint32_t value) = 0;
|
||||
virtual uint32_t readPort(uint32_t port, uint32_t size);
|
||||
virtual void writePort(uint32_t port, uint32_t size, uint32_t value);
|
||||
|
||||
string name;
|
||||
map<uint32_t, void *> mmioBuffers;
|
||||
};
|
||||
|
|
2
Gpu.cpp
2
Gpu.cpp
|
@ -3,7 +3,7 @@
|
|||
// Comment to enable break_in()s for this file
|
||||
#define break_in() do { } while(0)
|
||||
|
||||
Gpu::Gpu() {
|
||||
Gpu::Gpu() : Device("Gpu") {
|
||||
box->add_mmio(0xFD000000, 4096, this); // 4096 pages * 4KB == 16MB address space
|
||||
box->add_port(0x80c0, this);
|
||||
}
|
||||
|
|
27
Lpc.cpp
27
Lpc.cpp
|
@ -3,24 +3,10 @@
|
|||
// Comment to enable break_in()s for this file
|
||||
#define break_in() do { } while(0)
|
||||
|
||||
Lpc::Lpc() {
|
||||
Lpc::Lpc() : Device("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();
|
||||
|
@ -30,14 +16,3 @@ 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();
|
||||
}
|
||||
|
|
6
Lpc.hpp
6
Lpc.hpp
|
@ -5,12 +5,6 @@ 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);
|
||||
};
|
||||
|
|
27
Smbus.cpp
27
Smbus.cpp
|
@ -3,24 +3,10 @@
|
|||
// Comment to enable break_in()s for this file
|
||||
#define break_in() do { } while(0)
|
||||
|
||||
Smbus::Smbus() {
|
||||
Smbus::Smbus() : Device("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();
|
||||
|
@ -30,14 +16,3 @@ 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();
|
||||
}
|
||||
|
|
|
@ -5,12 +5,6 @@ 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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue