diff --git a/devices/machineid.h b/devices/machineid.h new file mode 100644 index 0000000..2f2cf8c --- /dev/null +++ b/devices/machineid.h @@ -0,0 +1,37 @@ +#ifndef MACHINE_ID_H +#define MACHINE_ID_H + +#include +#include "mmiodevice.h" + +/** + @file Contains definitions for PowerMacintosh machine ID registers. + + The machine ID register is a memory-based register containing hardcoded + values the system software can read to identify machine/board it's running on. + + Register location and value meaning are board-dependent. + */ + +/** + The machine ID for the Gossamer board is accesible at 0xFF000004 (phys). + It contains a 16-bit value revealing machine's capabilities like bus speed, + ROM speed, I/O configuration etc. + Because the meaning of these bits is poorly documented, the code below + simply return raw values obtained from real hardware. + */ +class GossamerID : public MMIODevice { +public: + GossamerID(const uint16_t id) { this->id = id, this->name = "Machine-id"; }; + ~GossamerID() = default; + + uint32_t read(uint32_t offset, int size) { + return ((!offset && size == 2) ? this->id : 0); }; + + void write(uint32_t offset, uint32_t value, int size) {}; /* not writable */ + +private: + uint16_t id; +}; + +#endif /* MACHINE_ID_H */ diff --git a/main.cpp b/main.cpp index 6f3af38..df342a1 100644 --- a/main.cpp +++ b/main.cpp @@ -25,6 +25,7 @@ #include "devices/mpc106.h" #include "openpic.h" #include "debugger.h" +#include "devices/machineid.h" #include "devices/macio.h" #include "devices/mpc106.h" @@ -84,6 +85,7 @@ uint32_t return_value; MemCtrlBase *mem_ctrl_instance = 0; HeathrowIC *heathrow = 0; +GossamerID *machine_id; //A pointer to a pointer, used for quick movement to one of the following //memory areas. These are listed right below. @@ -557,6 +559,10 @@ int main(int argc, char **argv) romFile.close(); return 1; } + machine_id = new GossamerID(0x3d8c); + assert(machine_id != 0); + mpc106->add_mmio_region(0xFF000004, 4096, machine_id); + heathrow = new HeathrowIC(); assert(heathrow != 0); mpc106->pci_register_device(16, heathrow); @@ -791,6 +797,7 @@ int main(int argc, char **argv) } delete(heathrow); + delete(machine_id); delete(mem_ctrl_instance); //Free memory after the emulation is completed.