pci.cpp: add new config read/write functions to support bridges that allow software to issue both Type 0 and Type 1 config addresses. [R. Belmont]

bandit.cpp: use the new functionality in pci.cpp. [R. Belmont]

macpci.cpp: Fix Grand Central PCI address now that we're interpreting the config address correctly. [R. Belmont]
This commit is contained in:
arbee 2023-03-22 22:57:49 -04:00
parent 2ea68c9c44
commit 160a221990
5 changed files with 59 additions and 8 deletions

View File

@ -938,6 +938,38 @@ void pci_host_device::config_data_w(offs_t offset, uint32_t data, uint32_t mem_m
root_config_write((config_address >> 16) & 0xff, (config_address >> 8) & 0xff, config_address & 0xfc, data, mem_mask);
}
uint32_t pci_host_device::config_data_ex_r(offs_t offset, uint32_t mem_mask)
{
// is this a Type 0 or Type 1 configuration address? (page 31, PCI 2.2 Specification)
if ((config_address & 3) == 0)
{
const int devnum = 31 - count_leading_zeros_32(config_address & 0xfffff800);
return root_config_read(0, devnum << 3, config_address & 0xfc, mem_mask);
}
else if ((config_address & 3) == 1)
return config_address & 0x80000000 ? root_config_read((config_address >> 16) & 0xff, (config_address >> 8) & 0xff, config_address & 0xfc, mem_mask) : 0xffffffff;
logerror("pci: configuration address format %d unsupported", config_address & 3);
return 0xffffffff;
}
void pci_host_device::config_data_ex_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
// is this a Type 0 or Type 1 configuration address? (page 31, PCI 2.2 Specification)
if ((config_address & 3) == 0)
{
const int devnum = 31 - count_leading_zeros_32(config_address & 0xfffff800);
root_config_write(0, devnum << 3, config_address & 0xfc, data, mem_mask);
}
else if ((config_address & 3) == 1)
{
if (config_address & 0x80000000)
root_config_write((config_address >> 16) & 0xff, (config_address >> 8) & 0xff, config_address & 0xfc, data, mem_mask);
}
else
logerror("pci: configuration address format %d unsupported", config_address & 3);
}
uint32_t pci_host_device::root_config_read(uint8_t bus, uint8_t device, uint16_t reg, uint32_t mem_mask)
{
if(bus == 0x00)

View File

@ -249,6 +249,8 @@ protected:
void config_address_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint32_t config_data_r(offs_t offset, uint32_t mem_mask = ~0);
void config_data_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint32_t config_data_ex_r(offs_t offset, uint32_t mem_mask = ~0);
void config_data_ex_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
virtual void device_start() override;
virtual void device_reset() override;

View File

@ -29,6 +29,7 @@ void bandit_host_device::config_map(address_map &map)
bandit_host_device::bandit_host_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: pci_host_device(mconfig, type, tag, owner, clock)
, m_last_config_address(0xffffffff)
, m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32)
, m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32)
, m_cpu(*this, finder_base::DUMMY_TAG)
@ -123,19 +124,26 @@ void bandit_host_device::cpu_map(address_map &map)
u32 bandit_host_device::be_config_address_r()
{
u32 temp = pci_host_device::config_address_r();
return (temp >> 24) | (temp << 24) | ((temp & 0xff00) << 8) | ((temp & 0xff0000) >> 8);
return m_last_config_address;
}
void bandit_host_device::be_config_address_w(offs_t offset, u32 data, u32 mem_mask)
{
u32 tempdata = (data >> 24) | (data << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8);
pci_host_device::config_address_w(offset, tempdata|0x80000000, mem_mask);
m_last_config_address = tempdata;
if ((tempdata & 3) == 1)
{
tempdata |= 0x80000000;
}
pci_host_device::config_address_w(offset, tempdata, mem_mask);
}
u32 bandit_host_device::be_config_data_r(offs_t offset, u32 mem_mask)
{
u32 temp = pci_host_device::config_data_r(offset, mem_mask);
u32 temp = pci_host_device::config_data_ex_r(offset, mem_mask);
return (temp >> 24) | (temp << 24) | ((temp & 0xff00) << 8) | ((temp & 0xff0000) >> 8);
}
@ -146,7 +154,7 @@ void bandit_host_device::be_config_data_w(offs_t offset, u32 data, u32 mem_mask)
// printf("config_data_w: %08x @ %08x mask %08x\n", data, offset, mem_mask);
tempdata = (data >> 24) | (data << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8);
pci_host_device::config_data_w(offset, tempdata, mem_mask);
pci_host_device::config_data_ex_w(offset, tempdata, mem_mask);
}
template <u32 Base>
@ -194,10 +202,17 @@ void bandit_host_device::map_extra(u64 memory_window_start, u64 memory_window_en
u32 aspen_host_device::be_config_address_r()
{
return pci_host_device::config_address_r();
return m_last_config_address;
}
void aspen_host_device::be_config_address_w(offs_t offset, u32 data, u32 mem_mask)
{
pci_host_device::config_address_w(offset, data | 0x80000000, mem_mask);
m_last_config_address = data;
if ((data & 3) == 1)
{
data |= 0x80000000;
}
pci_host_device::config_address_w(offset, data, mem_mask);
}

View File

@ -42,6 +42,8 @@ protected:
virtual space_config_vector memory_space_config() const override;
u32 m_last_config_address;
private:
void cpu_map(address_map &map);
virtual u32 be_config_address_r();

View File

@ -171,7 +171,7 @@ void macpci_state::pippin(machine_config &config)
RAM(config, m_ram);
m_ram->set_default_size("32M");
grandcentral_device &grandcentral(GRAND_CENTRAL(config, "pci:05.0", 0));
grandcentral_device &grandcentral(GRAND_CENTRAL(config, "pci:0d.0", 0));
grandcentral.set_maincpu_tag("maincpu");
MACADB(config, m_macadb, 15.6672_MHz_XTAL);