mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 05:29:43 +00:00
Initial DEC 21154 P2P bridge emulation.
This commit is contained in:
parent
299f0d3a9f
commit
ad2fc290ec
94
devices/common/pci/dec21154.cpp
Normal file
94
devices/common/pci/dec21154.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-23 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** DEC 21154 PCI-to-PCI bridge emulation. */
|
||||
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/pci/dec21154.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <endianswap.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
DecPciBridge::DecPciBridge(std::string name) : PCIBridge(name)
|
||||
{
|
||||
supports_types(HWCompType::PCI_HOST | HWCompType::PCI_DEV);
|
||||
|
||||
// initialize PCI config header
|
||||
this->vendor_id = PCI_VENDOR_DEC;
|
||||
this->device_id = 0x0026;
|
||||
this->class_rev = 0x06040002;
|
||||
this->cache_ln_sz = 0;
|
||||
this->command = 0;
|
||||
this->status = 0x2B0;
|
||||
}
|
||||
|
||||
uint32_t DecPciBridge::pci_cfg_read(uint32_t reg_offs, AccessDetails &details)
|
||||
{
|
||||
if (reg_offs < 64) {
|
||||
return PCIBridge::pci_cfg_read(reg_offs, details);
|
||||
}
|
||||
|
||||
switch (reg_offs) {
|
||||
case CHIP_CTRL:
|
||||
return (this->arb_ctrl << 16) | (this-> diag_ctrl << 8) | this->chip_ctrl;
|
||||
case PSERR_EVENT_DIS:
|
||||
return (this->gpio_out_en << 16) | this->pserr_event_dis;
|
||||
case SEC_CLK_CTRL:
|
||||
return this->sec_clock_ctrl;
|
||||
default:
|
||||
LOG_READ_UNIMPLEMENTED_CONFIG_REGISTER();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DecPciBridge::pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details)
|
||||
{
|
||||
if (reg_offs < 64) {
|
||||
PCIBridge::pci_cfg_write(reg_offs, value, details);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (reg_offs) {
|
||||
case CHIP_CTRL:
|
||||
this->chip_ctrl = value & 0xFFU;
|
||||
this->diag_ctrl = (value >> 8) & 0xFFU;
|
||||
this->arb_ctrl = value >> 16;
|
||||
break;
|
||||
case PSERR_EVENT_DIS:
|
||||
this->pserr_event_dis = value & 0xFFU;
|
||||
this->gpio_out_en = (value >> 16) & 0xFFU;
|
||||
break;
|
||||
case SEC_CLK_CTRL:
|
||||
this->sec_clock_ctrl = value & 0xFFFFU;
|
||||
break;
|
||||
default:
|
||||
LOG_WRITE_UNIMPLEMENTED_CONFIG_REGISTER();
|
||||
}
|
||||
}
|
||||
|
||||
static const DeviceDescription Dec21154_Descriptor = {
|
||||
DecPciBridge::create, {}, {}
|
||||
};
|
||||
|
||||
REGISTER_DEVICE(Dec21154, Dec21154_Descriptor);
|
62
devices/common/pci/dec21154.h
Normal file
62
devices/common/pci/dec21154.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-23 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** DEC 21154 PCI-to-PCI bridge definitions. */
|
||||
|
||||
#ifndef DEC_P2P_H
|
||||
#define DEC_P2P_H
|
||||
|
||||
#include <devices/common/pci/pcibridge.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
enum {
|
||||
CHIP_CTRL = 0x40,
|
||||
PSERR_EVENT_DIS = 0x64,
|
||||
SEC_CLK_CTRL = 0x68,
|
||||
};
|
||||
|
||||
class DecPciBridge : public PCIBridge {
|
||||
public:
|
||||
DecPciBridge(std::string name);
|
||||
~DecPciBridge() = default;
|
||||
|
||||
static std::unique_ptr<HWComponent> create() {
|
||||
return std::unique_ptr<DecPciBridge>(new DecPciBridge("DEC21154"));
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
private:
|
||||
uint8_t chip_ctrl = 0;
|
||||
uint8_t diag_ctrl = 0;
|
||||
uint16_t arb_ctrl = 0x0200;
|
||||
uint8_t pserr_event_dis = 0;
|
||||
uint8_t gpio_out_data = 0;
|
||||
uint8_t gpio_out_en = 0;
|
||||
uint8_t gpio_in_data = 0;
|
||||
uint16_t sec_clock_ctrl = 0;
|
||||
};
|
||||
|
||||
#endif // DEC_P2P_H
|
@ -54,6 +54,7 @@ enum {
|
||||
/** PCI Vendor IDs for devices used in Power Macintosh computers. */
|
||||
enum {
|
||||
PCI_VENDOR_ATI = 0x1002,
|
||||
PCI_VENDOR_DEC = 0x1011,
|
||||
PCI_VENDOR_MOTOROLA = 0x1057,
|
||||
PCI_VENDOR_APPLE = 0x106B,
|
||||
PCI_VENDOR_NVIDIA = 0x10DE,
|
||||
|
@ -26,6 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <endianswap.h>
|
||||
|
||||
#include <array>
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@ -78,6 +79,13 @@ public:
|
||||
|
||||
virtual PCIDevice *pci_find_device(uint8_t bus_num, uint8_t dev_num, uint8_t fun_num);
|
||||
|
||||
virtual uint32_t pci_t1_read(uint8_t dev, uint32_t fun, uint32_t reg, AccessDetails &details) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual void pci_t1_write(uint8_t dev, uint32_t fun, uint32_t reg, uint32_t value,
|
||||
AccessDetails &details) {};
|
||||
|
||||
protected:
|
||||
std::unordered_map<int, PCIDevice*> dev_map;
|
||||
std::vector<PCIDevice*> io_space_devs;
|
||||
|
Loading…
x
Reference in New Issue
Block a user