mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-12 11:31:16 +00:00
bandit: clean up PCI device connection.
This commit is contained in:
parent
699b62373a
commit
289ddf10b7
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||||
Copyright (C) 2018-22 divingkatae and maximum
|
Copyright (C) 2018-23 divingkatae and maximum
|
||||||
(theweirdo) spatium
|
(theweirdo) spatium
|
||||||
|
|
||||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
(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 <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Bandit ARBus-to-PCI Bridge emulation. */
|
/** Bandit/Chaos ARBus-to-PCI Bridge emulation. */
|
||||||
|
|
||||||
#include <devices/common/pci/bandit.h>
|
#include <devices/common/pci/bandit.h>
|
||||||
#include <devices/deviceregistry.h>
|
#include <devices/deviceregistry.h>
|
||||||
@ -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)
|
// base_addr + 0x1000000 --> pass-through memory space (not included below)
|
||||||
mem_ctrl->add_mmio_region(base_addr, 0x01000000, this);
|
mem_ctrl->add_mmio_region(base_addr, 0x01000000, this);
|
||||||
|
|
||||||
std::string banditpcitname = "Bandit1PCI";
|
// connnect Bandit PCI device
|
||||||
attach_pci_device(banditpcitname, 1);
|
this->my_pci_device = unique_ptr<BanditPciDevice>(
|
||||||
|
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)
|
: PCIDevice(name)
|
||||||
{
|
{
|
||||||
supports_types(HWCompType::PCI_DEV);
|
supports_types(HWCompType::PCI_DEV);
|
||||||
|
|
||||||
// prepare the PCI config header
|
// prepare the PCI config header
|
||||||
this->vendor_id = PCI_VENDOR_APPLE;
|
this->vendor_id = PCI_VENDOR_APPLE;
|
||||||
this->device_id = 0x0001;
|
this->device_id = dev_id;
|
||||||
this->class_rev = 0x06000003;
|
this->class_rev = 0x06000000 | (rev & 0xFFU);
|
||||||
this->cache_ln_sz = 8;
|
this->cache_ln_sz = 8;
|
||||||
this->command = 0x16;
|
this->command = 0x16;
|
||||||
|
|
||||||
@ -91,7 +94,7 @@ BanditPCI::BanditPCI(int bridge_num, std::string name)
|
|||||||
this->rd_hold_off_cnt = 8;
|
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) {
|
if (reg_offs < 64) {
|
||||||
return PCIDevice::pci_cfg_read(reg_offs, details);
|
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;
|
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) {
|
if (reg_offs < 64) {
|
||||||
PCIDevice::pci_cfg_write(reg_offs, value, details);
|
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;
|
uint32_t mask;
|
||||||
int bit_pos;
|
int bit_pos;
|
||||||
@ -289,11 +292,6 @@ static const DeviceDescription Chaos_Descriptor = {
|
|||||||
Chaos::create, {}, {}
|
Chaos::create, {}, {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const DeviceDescription Bandit1PCI_Descriptor = {
|
|
||||||
BanditPCI::create_first, {}, {}
|
|
||||||
};
|
|
||||||
|
|
||||||
REGISTER_DEVICE(Bandit1 , Bandit1_Descriptor);
|
REGISTER_DEVICE(Bandit1 , Bandit1_Descriptor);
|
||||||
REGISTER_DEVICE(Bandit1PCI, Bandit1PCI_Descriptor);
|
|
||||||
REGISTER_DEVICE(PsxPci1 , PsxPci1_Descriptor);
|
REGISTER_DEVICE(PsxPci1 , PsxPci1_Descriptor);
|
||||||
REGISTER_DEVICE(Chaos , Chaos_Descriptor);
|
REGISTER_DEVICE(Chaos , Chaos_Descriptor);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||||
Copyright (C) 2018-22 divingkatae and maximum
|
Copyright (C) 2018-23 divingkatae and maximum
|
||||||
(theweirdo) spatium
|
(theweirdo) spatium
|
||||||
|
|
||||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
(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 <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** 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
|
Bandit is a custom ARBus-to-PCI bridge used in the second generation
|
||||||
generation of the Power Macintosh computer equipped with the PCI bus.
|
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
|
#ifndef BANDIT_PCI_H
|
||||||
@ -36,7 +45,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#define BANDIT_DEV (11) // Bandit's own device number
|
#define BANDIT_DEV (11) // Bandit's own device number
|
||||||
#define BANDIT_CAR_TYPE (1 << 0) // Bandit config address type bit
|
#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 */
|
/** checks if one bit is set at time, return 0 if not */
|
||||||
#define SINGLE_BIT_SET(val) ((val) && !((val) & ((val)-1)))
|
#define SINGLE_BIT_SET(val) ((val) && !((val) & ((val)-1)))
|
||||||
|
|
||||||
|
/*
|
||||||
|
Common functionality for Bandit/Chaos PCI host bridge.
|
||||||
|
*/
|
||||||
class BanditHost : public PCIHost, public MMIODevice {
|
class BanditHost : public PCIHost, public MMIODevice {
|
||||||
public:
|
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);
|
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;
|
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 {
|
class Bandit : public BanditHost {
|
||||||
public:
|
public:
|
||||||
Bandit(int bridge_num, std::string name, int dev_id=1, int rev=3);
|
Bandit(int bridge_num, std::string name, int dev_id=1, int rev=3);
|
||||||
@ -78,35 +113,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t base_addr;
|
uint32_t base_addr;
|
||||||
|
unique_ptr<BanditPciDevice> my_pci_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BanditPCI : public PCIDevice {
|
/**
|
||||||
public:
|
Chaos HLE emulation class.
|
||||||
BanditPCI(int bridge_num, std::string name);
|
|
||||||
~BanditPCI() = default;
|
|
||||||
|
|
||||||
static std::unique_ptr<HWComponent> create_first() {
|
|
||||||
return std::unique_ptr<BanditPCI>(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.
|
|
||||||
*/
|
*/
|
||||||
class Chaos : public BanditHost {
|
class Chaos : public BanditHost {
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user