diff --git a/devices/memctrl/mpc106.cpp b/devices/memctrl/mpc106.cpp index 14e8e91..05e7f0d 100644 --- a/devices/memctrl/mpc106.cpp +++ b/devices/memctrl/mpc106.cpp @@ -32,7 +32,8 @@ along with this program. If not, see . #include #include #include - +#include +#include MPC106::MPC106() : MemCtrlBase(), PCIDevice("Grackle"), PCIHost() { @@ -56,6 +57,23 @@ MPC106::MPC106() : MemCtrlBase(), PCIDevice("Grackle"), PCIHost() add_mmio_region(0xFEC00000, 0x300000, this); } +int MPC106::device_postinit() +{ + std::string pci_dev_name; + + static const std::map pci_slots = { + {"pci_A1", 0xD}, {"pci_B1", 0xE}, {"pci_C1", 0xF} + }; + + for (auto& slot : pci_slots) { + pci_dev_name = GET_STR_PROP(slot.first); + if (!pci_dev_name.empty()) { + this->attach_pci_device(pci_dev_name, slot.second); + } + } + return 0; +} + uint32_t MPC106::read(uint32_t reg_start, uint32_t offset, int size) { uint32_t result; @@ -235,8 +253,17 @@ void MPC106::setup_ram() { } } +static const PropMap Grackle_Properties = { + {"pci_A1", + new StrProperty("")}, + {"pci_B1", + new StrProperty("")}, + {"pci_C1", + new StrProperty("")}, +}; + static const DeviceDescription Grackle_Descriptor = { - MPC106::create, {}, {} + MPC106::create, {}, Grackle_Properties }; REGISTER_DEVICE(Grackle, Grackle_Descriptor); diff --git a/devices/memctrl/mpc106.h b/devices/memctrl/mpc106.h index b55e3c5..0b818d1 100644 --- a/devices/memctrl/mpc106.h +++ b/devices/memctrl/mpc106.h @@ -55,6 +55,8 @@ public: uint32_t read(uint32_t reg_start, uint32_t offset, int size); void write(uint32_t reg_start, uint32_t offset, uint32_t value, int size); + int device_postinit(); + protected: /* PCI access */ uint32_t pci_read(uint32_t size);