MPC106: insert PCI devices using the CLI.

This commit is contained in:
Maxim Poliakovski 2022-08-19 20:07:22 +02:00
parent 336ea14422
commit 5220b03f0f
2 changed files with 31 additions and 2 deletions

View File

@ -32,7 +32,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstring>
#include <iostream>
#include <loguru.hpp>
#include <string>
#include <vector>
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<std::string, int> 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);

View File

@ -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);