| Previous | 199869 Revisions | Next |
| r18417 Wednesday 10th October, 2012 at 15:33:36 UTC by O. Galibert |
|---|
| memory: Fix dynamic recursive device mapping [O. Galibert] Situation: - you have a device (pc-fdc) with a memory map on it - you map it dynamically into a cpu (maincpu) address space with install_device (isa-fdc does that) - the device pc-fdc has a subdevice (upd765) - the subdevice upd765 has its own memory map - the pc-fdc memory map includes the upd765 memory map through AM_DEVICE("upd765", ...) Before the fix, the code would search for upd765 as a subdevice of maincpu and not of pc-fdc. |
| [src/emu] | addrmap.c addrmap.h memory.c memory.h |
| r18416 | r18417 | |
|---|---|---|
| 1783 | 1783 | m_map = global_alloc(address_map(m_device, m_spacenum)); |
| 1784 | 1784 | |
| 1785 | 1785 | // merge in the submaps |
| 1786 | m_map->uplift_submaps(machine(), m_device, endianness()); | |
| 1786 | m_map->uplift_submaps(machine(), m_device, machine().root_device(), endianness()); | |
| 1787 | 1787 | |
| 1788 | 1788 | // extract global parameters specified by the map |
| 1789 | 1789 | m_unmap = (m_map->m_unmapval == 0) ? 0 : ~0; |
| r18416 | r18417 | |
| 2251 | 2251 | void address_space::install_device_delegate(offs_t addrstart, offs_t addrend, device_t &device, address_map_delegate &delegate, int bits, UINT64 unitmask) |
| 2252 | 2252 | { |
| 2253 | 2253 | address_map map(*this, addrstart, addrend, bits, unitmask, device, delegate); |
| 2254 | map.uplift_submaps(machine(), m_device, endianness()); | |
| 2254 | map.uplift_submaps(machine(), m_device, device, endianness()); | |
| 2255 | 2255 | populate_from_map(&map); |
| 2256 | 2256 | } |
| 2257 | 2257 |
| r18416 | r18417 | |
|---|---|---|
| 716 | 716 | // uplift_submaps - propagate in the device submaps |
| 717 | 717 | //------------------------------------------------- |
| 718 | 718 | |
| 719 | void address_map::uplift_submaps(running_machine &machine, device_t &device, endianness_t endian) | |
| 719 | void address_map::uplift_submaps(running_machine &machine, device_t &device, device_t &owner, endianness_t endian) | |
| 720 | 720 | { |
| 721 | 721 | address_map_entry *prev = 0; |
| 722 | 722 | address_map_entry *entry = m_entrylist.first(); |
| r18416 | r18417 | |
| 724 | 724 | { |
| 725 | 725 | if (entry->m_read.m_type == AMH_DEVICE_SUBMAP) |
| 726 | 726 | { |
| 727 | const char *tag = entry->m_read.m_tag; | |
| 727 | astring tag; | |
| 728 | owner.subtag(tag, entry->m_read.m_tag); | |
| 728 | 729 | device_t *mapdevice = machine.device(tag); |
| 729 | if (mapdevice == NULL) | |
| 730 | throw emu_fatalerror("Attempted to submap a non-existent device '%s' in space %d of device '%s'\n", tag, m_spacenum, device.tag()); | |
| 730 | if (mapdevice == NULL) { | |
| 731 | throw emu_fatalerror("Attempted to submap a non-existent device '%s' in space %d of device '%s'\n", tag.cstr(), m_spacenum, device.basetag()); | |
| 732 | } | |
| 731 | 733 | // Grab the submap |
| 732 | 734 | address_map submap(*mapdevice, entry); |
| 733 | 735 | |
| 734 | 736 | // Recursively uplift it if needed |
| 735 | submap.uplift_submaps(machine, *mapdevice, endian); | |
| 737 | submap.uplift_submaps(machine, device, *mapdevice, endian); | |
| 736 | 738 | |
| 737 | 739 | // Compute the unit repartition characteristics |
| 738 | 740 | int entry_bits = entry->m_submap_bits; |
| r18416 | r18417 | |
|---|---|---|
| 437 | 437 | void *install_ram(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, void *baseptr = NULL) { return install_ram_generic(addrstart, addrend, addrmask, addrmirror, ROW_READWRITE, baseptr); } |
| 438 | 438 | |
| 439 | 439 | // install device memory maps |
| 440 | template <typename T> void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(address_map &map, | |
| 440 | template <typename T> void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(address_map &map, device_t &device), int bits = 0, UINT64 unitmask = 0) { | |
| 441 | 441 | address_map_delegate delegate(map, "dynamic_device_install", &device); |
| 442 | 442 | install_device_delegate(addrstart, addrend, device, delegate, bits, unitmask); |
| 443 | 443 | } |
| r18416 | r18417 | |
|---|---|---|
| 365 | 365 | offs_t m_globalmask; // global mask |
| 366 | 366 | simple_list<address_map_entry> m_entrylist; // list of entries |
| 367 | 367 | |
| 368 | void uplift_submaps(running_machine &machine, device_t &device, endianness_t endian); | |
| 368 | void uplift_submaps(running_machine &machine, device_t &device, device_t &owner, endianness_t endian); | |
| 369 | 369 | }; |
| 370 | 370 | |
| 371 | 371 |
| Previous | 199869 Revisions | Next |