bandit: add PSX style PCI bridge.

This commit is contained in:
Maxim Poliakovski 2022-12-18 23:40:56 +01:00
parent 78528a1a16
commit 24ccdabedc
2 changed files with 13 additions and 5 deletions

View File

@ -40,7 +40,8 @@ const int MultiplyDeBruijnBitPosition2[] =
/** finds the position of the bit that is set */
#define WHAT_BIT_SET(val) (MultiplyDeBruijnBitPosition2[(uint32_t)(val * 0x077CB531U) >> 27])
Bandit::Bandit(int bridge_num, std::string name) : PCIHost(), PCIDevice(name)
Bandit::Bandit(int bridge_num, std::string name, int dev_id, int rev)
: PCIHost(), PCIDevice(name)
{
supports_types(HWCompType::PCI_HOST | HWCompType::PCI_DEV);
@ -72,8 +73,6 @@ Bandit::Bandit(int bridge_num, std::string name) : PCIHost(), PCIDevice(name)
// that correspond to the 32MB assigned PCI address space of this Bandit.
// This initialization is implied by the device functionality.
this->addr_mask = 3 << ((bridge_num & 3) * 2);
this->name = name;
}
uint32_t Bandit::pci_cfg_read(uint32_t reg_offs, uint32_t size)
@ -403,9 +402,14 @@ static const DeviceDescription Bandit1_Descriptor = {
Bandit::create_first, {}, {}
};
static const DeviceDescription PsxPci1_Descriptor = {
Bandit::create_psx_first, {}, {}
};
static const DeviceDescription Chaos_Descriptor = {
Chaos::create, {}, {}
};
REGISTER_DEVICE(Bandit1, Bandit1_Descriptor);
REGISTER_DEVICE(Chaos, Chaos_Descriptor);
REGISTER_DEVICE(PsxPci1, PsxPci1_Descriptor);
REGISTER_DEVICE(Chaos, Chaos_Descriptor);

View File

@ -52,13 +52,17 @@ enum {
class Bandit : public PCIHost, public PCIDevice {
public:
Bandit(int bridge_num, std::string name);
Bandit(int bridge_num, std::string name, int dev_id=1, int rev=3);
~Bandit() = default;
static std::unique_ptr<HWComponent> create_first() {
return std::unique_ptr<Bandit>(new Bandit(1, "Bandit-PCI1"));
};
static std::unique_ptr<HWComponent> create_psx_first() {
return std::unique_ptr<Bandit>(new Bandit(1, "PSX-PCI1", 8, 0));
};
uint32_t pci_cfg_read(uint32_t reg_offs, uint32_t size);
void pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size);