diff --git a/devices/common/pci/bandit.cpp b/devices/common/pci/bandit.cpp
index 64c2b60..2251ca9 100644
--- a/devices/common/pci/bandit.cpp
+++ b/devices/common/pci/bandit.cpp
@@ -1,6 +1,6 @@
/*
DingusPPC - The Experimental PowerPC Macintosh emulator
-Copyright (C) 2018-22 divingkatae and maximum
+Copyright (C) 2018-23 divingkatae and maximum
(theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
@@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-/** Bandit ARBus-to-PCI Bridge emulation. */
+/** Bandit/Chaos ARBus-to-PCI Bridge emulation. */
#include
#include
@@ -60,19 +60,22 @@ Bandit::Bandit(int bridge_num, std::string name, int dev_id, int rev)
// base_addr + 0x1000000 --> pass-through memory space (not included below)
mem_ctrl->add_mmio_region(base_addr, 0x01000000, this);
- std::string banditpcitname = "Bandit1PCI";
- attach_pci_device(banditpcitname, 1);
+ // connnect Bandit PCI device
+ this->my_pci_device = unique_ptr(
+ new BanditPciDevice(bridge_num, name, dev_id, rev)
+ );
+ this->pci_register_device(1, this->my_pci_device.get());
}
-BanditPCI::BanditPCI(int bridge_num, std::string name)
+BanditPciDevice::BanditPciDevice(int bridge_num, std::string name, int dev_id, int rev)
: PCIDevice(name)
{
supports_types(HWCompType::PCI_DEV);
// prepare the PCI config header
this->vendor_id = PCI_VENDOR_APPLE;
- this->device_id = 0x0001;
- this->class_rev = 0x06000003;
+ this->device_id = dev_id;
+ this->class_rev = 0x06000000 | (rev & 0xFFU);
this->cache_ln_sz = 8;
this->command = 0x16;
@@ -91,7 +94,7 @@ BanditPCI::BanditPCI(int bridge_num, std::string name)
this->rd_hold_off_cnt = 8;
}
-uint32_t BanditPCI::pci_cfg_read(uint32_t reg_offs, AccessDetails &details)
+uint32_t BanditPciDevice::pci_cfg_read(uint32_t reg_offs, AccessDetails &details)
{
if (reg_offs < 64) {
return PCIDevice::pci_cfg_read(reg_offs, details);
@@ -109,7 +112,7 @@ uint32_t BanditPCI::pci_cfg_read(uint32_t reg_offs, AccessDetails &details)
return 0;
}
-void BanditPCI::pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details)
+void BanditPciDevice::pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details)
{
if (reg_offs < 64) {
PCIDevice::pci_cfg_write(reg_offs, value, details);
@@ -233,7 +236,7 @@ void BanditHost::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
}
}
-void BanditPCI::verbose_address_space()
+void BanditPciDevice::verbose_address_space()
{
uint32_t mask;
int bit_pos;
@@ -289,11 +292,6 @@ static const DeviceDescription Chaos_Descriptor = {
Chaos::create, {}, {}
};
-static const DeviceDescription Bandit1PCI_Descriptor = {
- BanditPCI::create_first, {}, {}
-};
-
REGISTER_DEVICE(Bandit1 , Bandit1_Descriptor);
-REGISTER_DEVICE(Bandit1PCI, Bandit1PCI_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 4880014..9272bed 100644
--- a/devices/common/pci/bandit.h
+++ b/devices/common/pci/bandit.h
@@ -1,6 +1,6 @@
/*
DingusPPC - The Experimental PowerPC Macintosh emulator
-Copyright (C) 2018-22 divingkatae and maximum
+Copyright (C) 2018-23 divingkatae and maximum
(theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
@@ -19,10 +19,19 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-/** Bandit ARBus-to-PCI bridge definitions.
+/** Bandit/Chaos ARBus-to-PCI bridge definitions.
- The Bandit ASIC is a custom ARBus-to-PCI bridge used in the second
- generation of the Power Macintosh computer equipped with the PCI bus.
+ Bandit is a custom ARBus-to-PCI bridge used in the second generation
+ of the Power Macintosh computer equipped with the PCI bus.
+
+ Chaos is a custom ARBus-to-PCI bridge that provides a specialized
+ PCI-like bus for video called VCI. This 64-bit bus runs at the same
+ frequency as the CPU bus (40-50 MHz) and connects video input/output
+ devices with the CPU bus.
+
+ Chaos seems to be a Bandit variant without PCI configuration space.
+ It's assumed to be present in some PCI Power Macintosh models of the
+ first generation.
*/
#ifndef BANDIT_PCI_H
@@ -36,7 +45,6 @@ along with this program. If not, see .
#include
#include
#include
-#include
#define BANDIT_DEV (11) // Bandit's own device number
#define BANDIT_CAR_TYPE (1 << 0) // Bandit config address type bit
@@ -52,6 +60,9 @@ enum {
/** checks if one bit is set at time, return 0 if not */
#define SINGLE_BIT_SET(val) ((val) && !((val) & ((val)-1)))
+/*
+ Common functionality for Bandit/Chaos PCI host bridge.
+ */
class BanditHost : public PCIHost, public MMIODevice {
public:
void cfg_setup(uint32_t offset, int size, int &bus_num, int &dev_num, int &fun_num, uint8_t ®_offs, AccessDetails &details, PCIDevice *&device);
@@ -64,6 +75,30 @@ protected:
uint32_t config_addr;
};
+/*
+ PCI device for Bandit (but not for Chaos).
+ */
+class BanditPciDevice : public PCIDevice {
+public:
+ BanditPciDevice(int bridge_num, std::string name, int dev_id, int rev);
+ ~BanditPciDevice() = default;
+
+ // PCIDevice methods
+ uint32_t pci_cfg_read(uint32_t reg_offs, AccessDetails &details);
+ void pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details);
+
+protected:
+ void verbose_address_space();
+
+private:
+ uint32_t addr_mask;
+ uint32_t mode_ctrl; // controls various chip modes/features
+ uint32_t rd_hold_off_cnt;
+};
+
+/*
+ Bandit HLE emulation class.
+ */
class Bandit : public BanditHost {
public:
Bandit(int bridge_num, std::string name, int dev_id=1, int rev=3);
@@ -78,35 +113,12 @@ public:
};
private:
- uint32_t base_addr;
+ uint32_t base_addr;
+ unique_ptr my_pci_device;
};
-class BanditPCI : public PCIDevice {
-public:
- BanditPCI(int bridge_num, std::string name);
- ~BanditPCI() = default;
-
- static std::unique_ptr create_first() {
- return std::unique_ptr(new BanditPCI(1, "BanditPCI"));
- };
-
- // PCIDevice methods
- uint32_t pci_cfg_read(uint32_t reg_offs, AccessDetails &details);
- void pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details);
-
-protected:
- void verbose_address_space();
-
-private:
- uint32_t addr_mask;
- uint32_t mode_ctrl; // controls various chip modes/features
- uint32_t rd_hold_off_cnt;
-};
-
-/** Chaos is a custom ARBus-to-PCI bridge that provides a specialized
- PCI-like bus for video called VCI. This 64-bit bus runs at the same
- frequency as the CPU bus (40-50 MHz) and provides an interface
- between video input/output devices and the CPU bus.
+/**
+ Chaos HLE emulation class.
*/
class Chaos : public BanditHost {
public: