bandit: attach devices from the CLI.

This commit is contained in:
Maxim Poliakovski 2023-04-01 16:59:42 +02:00
parent 888d919ae7
commit 49f47c5f3f
2 changed files with 29 additions and 1 deletions

View File

@ -225,6 +225,23 @@ inline void BanditHost::cfg_setup(uint32_t offset, int size, int &bus_num,
} }
} }
int BanditHost::device_postinit()
{
std::string pci_dev_name;
static const std::map<std::string, int> pci_slots = {
{"pci_A1", DEV_FUN(0xD,0)}, {"pci_B1", DEV_FUN(0xE,0)}, {"pci_C1", DEV_FUN(0xF,0)}
};
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;
}
Bandit::Bandit(int bridge_num, std::string name, int dev_id, int rev) Bandit::Bandit(int bridge_num, std::string name, int dev_id, int rev)
: BanditHost() : BanditHost()
{ {
@ -268,8 +285,17 @@ Chaos::Chaos(std::string name) : BanditHost()
mem_ctrl->add_mmio_region(0xF0000000UL, 0x01000000, this); mem_ctrl->add_mmio_region(0xF0000000UL, 0x01000000, this);
} }
static const PropMap Bandit_Properties = {
{"pci_A1",
new StrProperty("")},
{"pci_B1",
new StrProperty("")},
{"pci_C1",
new StrProperty("")},
};
static const DeviceDescription Bandit1_Descriptor = { static const DeviceDescription Bandit1_Descriptor = {
Bandit::create_first, {}, {} Bandit::create_first, {}, Bandit_Properties
}; };
static const DeviceDescription PsxPci1_Descriptor = { static const DeviceDescription PsxPci1_Descriptor = {

View File

@ -74,6 +74,8 @@ public:
uint32_t read(uint32_t rgn_start, uint32_t offset, int size); uint32_t read(uint32_t rgn_start, uint32_t offset, int size);
void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size); void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size);
int device_postinit();
protected: protected:
uint32_t config_addr; uint32_t config_addr;