pci: Add remapping notifiers [O. Galibert]

This commit is contained in:
Olivier Galibert 2014-11-10 19:46:48 +01:00
parent 0a3d96d6f0
commit 31eda228fe
3 changed files with 40 additions and 1 deletions

View File

@ -71,7 +71,7 @@ void i6300esb_lpc_device::reset_all_mappings()
lpc_if_sound_range = 0x00;
fwh_dec_en1 = 0xff;
gen1_dec = 0x0000;
lpc_en = 0x2000;
lpc_en = 0x0000;
fwh_sel1 = 0x00112233;
}
@ -85,6 +85,7 @@ WRITE32_MEMBER(i6300esb_lpc_device::gpio_base_w)
COMBINE_DATA(&gpio_base);
gpio_base &= 0x0000ffc0;
logerror("%s: gpio_base = %08x\n", tag(), gpio_base);
remap_cb();
}
READ8_MEMBER (i6300esb_lpc_device::gpio_cntl_r)
@ -96,6 +97,7 @@ WRITE8_MEMBER (i6300esb_lpc_device::gpio_cntl_w)
{
COMBINE_DATA(&gpio_cntl);
logerror("%s: gpio_cntl = %02x\n", tag(), gpio_cntl);
remap_cb();
}
READ8_MEMBER (i6300esb_lpc_device::lpc_if_com_range_r)
@ -107,6 +109,7 @@ WRITE8_MEMBER (i6300esb_lpc_device::lpc_if_com_range_w)
{
COMBINE_DATA(&lpc_if_com_range);
logerror("%s: lpc_if_com_range = %02x\n", tag(), lpc_if_com_range);
remap_cb();
}
READ8_MEMBER (i6300esb_lpc_device::lpc_if_fdd_lpt_range_r)
@ -118,6 +121,7 @@ WRITE8_MEMBER (i6300esb_lpc_device::lpc_if_fdd_lpt_range_w)
{
COMBINE_DATA(&lpc_if_fdd_lpt_range);
logerror("%s: lpc_if_fdd_lpt_range = %02x\n", tag(), lpc_if_fdd_lpt_range);
remap_cb();
}
READ8_MEMBER (i6300esb_lpc_device::lpc_if_sound_range_r)
@ -129,6 +133,7 @@ WRITE8_MEMBER (i6300esb_lpc_device::lpc_if_sound_range_w)
{
COMBINE_DATA(&lpc_if_sound_range);
logerror("%s: lpc_if_sound_range = %02x\n", tag(), lpc_if_sound_range);
remap_cb();
}
READ8_MEMBER (i6300esb_lpc_device::fwh_dec_en1_r)
@ -140,6 +145,7 @@ WRITE8_MEMBER (i6300esb_lpc_device::fwh_dec_en1_w)
{
fwh_dec_en1 = data | 0x80;
logerror("%s: fwh_dec_en1 = %02x\n", tag(), fwh_dec_en1);
remap_cb();
}
READ16_MEMBER (i6300esb_lpc_device::gen1_dec_r)
@ -151,6 +157,7 @@ WRITE16_MEMBER(i6300esb_lpc_device::gen1_dec_w)
{
COMBINE_DATA(&gen1_dec);
logerror("%s: gen1_dec = %04x\n", tag(), gen1_dec);
remap_cb();
}
READ16_MEMBER (i6300esb_lpc_device::lpc_en_r)
@ -162,6 +169,7 @@ WRITE16_MEMBER(i6300esb_lpc_device::lpc_en_w)
{
COMBINE_DATA(&lpc_en);
logerror("%s: lpc_en = %04x\n", tag(), lpc_en);
remap_cb();
}
READ32_MEMBER (i6300esb_lpc_device::fwh_sel1_r)
@ -173,6 +181,7 @@ WRITE32_MEMBER(i6300esb_lpc_device::fwh_sel1_w)
{
COMBINE_DATA(&fwh_sel1);
logerror("%s: fwh_sel1 = %08x\n", tag(), fwh_sel1);
remap_cb();
}
READ32_MEMBER (i6300esb_lpc_device::unk_fc_r)

View File

@ -91,6 +91,11 @@ void pci_device::scan_sub_devices(pci_device **devices, dynamic_array<pci_device
{
}
void pci_device::set_remap_cb(mapper_cb _remap_cb)
{
remap_cb = _remap_cb;
}
void pci_device::reset_all_mappings()
{
}
@ -163,6 +168,14 @@ device_t *pci_bridge_device::bus_root()
return this;
}
void pci_bridge_device::set_remap_cb(mapper_cb _remap_cb)
{
remap_cb = _remap_cb;
for(int i=0; i != all_devices.count(); i++)
if(all_devices[i] != this)
all_devices[i]->set_remap_cb(_remap_cb);
}
void pci_bridge_device::device_start()
{
pci_device::device_start();
@ -179,10 +192,15 @@ void pci_bridge_device::device_start()
int fct = t[l-1] - '0';
sub_devices[(id << 3) | fct] = downcast<pci_device *>(d);
}
mapper_cb cf_cb(FUNC(pci_bridge_device::regenerate_config_mapping), this);
for(int i=0; i<32*8; i++)
if(sub_devices[i]) {
all_devices.append(sub_devices[i]);
if(sub_devices[i] != this) {
sub_devices[i]->remap_config_cb = cf_cb;
sub_devices[i]->set_remap_cb(remap_cb);
pci_bridge_device *bridge = dynamic_cast<pci_bridge_device *>(sub_devices[i]);
if(bridge)
all_bridges.append(bridge);
@ -262,10 +280,16 @@ device_t *pci_host_device::bus_root()
void pci_host_device::device_start()
{
remap_cb = mapper_cb(FUNC(pci_host_device::regenerate_mapping), this);
pci_bridge_device::device_start();
memory_window_start = memory_window_end = memory_offset = 0;
io_window_start = io_window_end = io_offset = 0;
for(int i=0; i != all_devices.count(); i++)
if(all_devices[i] != this)
all_devices[i]->reset_all_mappings();
}
void pci_host_device::device_reset()

View File

@ -24,10 +24,15 @@
class pci_device : public device_t {
public:
typedef delegate<void ()> mapper_cb;
mapper_cb remap_cb, remap_config_cb;
pci_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
void set_ids(UINT32 main_id, UINT8 revision, UINT32 pclass, UINT32 subsystem_id);
virtual void set_remap_cb(mapper_cb _remap_cb);
virtual void reset_all_mappings();
virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
@ -87,6 +92,7 @@ public:
pci_bridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
pci_bridge_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
virtual void set_remap_cb(mapper_cb _remap_cb);
virtual void map_device(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space,
UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space);
virtual void reset_all_mappings();