From 24ccdabedc003132082554b07d152b762589ecd2 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Sun, 18 Dec 2022 23:40:56 +0100 Subject: [PATCH] bandit: add PSX style PCI bridge. --- devices/common/pci/bandit.cpp | 12 ++++++++---- devices/common/pci/bandit.h | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/devices/common/pci/bandit.cpp b/devices/common/pci/bandit.cpp index 3c2c0e9..1ec1c7d 100644 --- a/devices/common/pci/bandit.cpp +++ b/devices/common/pci/bandit.cpp @@ -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); diff --git a/devices/common/pci/bandit.h b/devices/common/pci/bandit.h index 83d9fce..6905e0b 100644 --- a/devices/common/pci/bandit.h +++ b/devices/common/pci/bandit.h @@ -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 create_first() { return std::unique_ptr(new Bandit(1, "Bandit-PCI1")); }; + static std::unique_ptr create_psx_first() { + return std::unique_ptr(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);