diff --git a/src/devices/bus/isa/isa.h b/src/devices/bus/isa/isa.h index cd389f4b365..d4f67b55f74 100644 --- a/src/devices/bus/isa/isa.h +++ b/src/devices/bus/isa/isa.h @@ -216,7 +216,7 @@ public: } void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler); - template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(class address_map &map, device_t &device), int bits = 8, uint64_t unitmask = U64(0xffffffffffffffff)) + template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(class address_map &map), int bits = 8, uint64_t unitmask = U64(0xffffffffffffffff)) { m_iospace->install_device(addrstart, addrend, device, map, bits, unitmask); } diff --git a/src/devices/machine/gt64xxx.cpp b/src/devices/machine/gt64xxx.cpp index 763f27be1e2..8f692abd3a1 100644 --- a/src/devices/machine/gt64xxx.cpp +++ b/src/devices/machine/gt64xxx.cpp @@ -183,7 +183,7 @@ void gt64xxx_device::map_cpu_space() // CS[0:3] //m_cpu_space->install_device_delegate(0x16000000, 0x17ffffff, machine().root_device(), m_cs_map[3].map); - typedef void (gt64xxx_device::*tramp_t)(::address_map &, device_t &); + typedef void (gt64xxx_device::*tramp_t)(::address_map &); static const tramp_t trampolines[4] = { >64xxx_device::map_trampoline<0>, >64xxx_device::map_trampoline<1>, diff --git a/src/devices/machine/gt64xxx.h b/src/devices/machine/gt64xxx.h index 15720d36897..ec537cf3ebe 100644 --- a/src/devices/machine/gt64xxx.h +++ b/src/devices/machine/gt64xxx.h @@ -292,10 +292,10 @@ private: // Chip Select galileo_device_map m_cs_map[4]; - template void map_trampoline(::address_map &map, device_t &device) { - m_cs_map[id].map(map, *m_cs_map[id].device); + template void map_trampoline(::address_map &map) { + m_cs_map[id].map(map); } - template void install_cs_map(offs_t addrstart, offs_t addrend, void (T::*map)(::address_map &map, device_t &device), const char *name) { + template void install_cs_map(offs_t addrstart, offs_t addrend, void (T::*map)(::address_map &map), const char *name) { //address_map_delegate delegate(map, name, static_cast(this)); address_map_delegate delegate(map, name, static_cast(this)); m_cpu_space->install_device_delegate(addrstart, addrend, *this, delegate); diff --git a/src/devices/machine/pci.h b/src/devices/machine/pci.h index 245ca503009..6b94f4abd82 100644 --- a/src/devices/machine/pci.h +++ b/src/devices/machine/pci.h @@ -124,7 +124,7 @@ protected: void skip_map_regs(int count); void add_map(uint64_t size, int flags, address_map_delegate &map); - template void add_map(uint64_t size, int flags, void (T::*map)(address_map &map, device_t &device), const char *name) { + template void add_map(uint64_t size, int flags, void (T::*map)(address_map &map), const char *name) { address_map_delegate delegate(map, name, static_cast(this)); add_map(size, flags, delegate); } diff --git a/src/devices/machine/pci9050.cpp b/src/devices/machine/pci9050.cpp index a7ccb5eff62..8f5e36b3550 100644 --- a/src/devices/machine/pci9050.cpp +++ b/src/devices/machine/pci9050.cpp @@ -59,7 +59,7 @@ void pci9050_device::set_map(int id, address_map_constructor map, const char *na void pci9050_device::device_start() { - typedef void (pci9050_device::*tramp_t)(address_map &, device_t &); + typedef void (pci9050_device::*tramp_t)(address_map &); static const tramp_t trampolines[4] = { &pci9050_device::map_trampoline<0>, &pci9050_device::map_trampoline<1>, diff --git a/src/devices/machine/pci9050.h b/src/devices/machine/pci9050.h index 64778d02bfa..f8ba2880d58 100644 --- a/src/devices/machine/pci9050.h +++ b/src/devices/machine/pci9050.h @@ -75,8 +75,8 @@ private: void remap_local(int id); void remap_rom(); - template void map_trampoline(address_map &map, device_t &device) { - m_maps[id](map, *m_devices[id]); + template void map_trampoline(address_map &map) { + m_maps[id](map); } devcb_read32 m_user_input_handler; diff --git a/src/emu/addrmap.cpp b/src/emu/addrmap.cpp index 4cba3760c27..eab1fd4d2ba 100644 --- a/src/emu/addrmap.cpp +++ b/src/emu/addrmap.cpp @@ -342,36 +342,41 @@ address_map_entry64::address_map_entry64(device_t &device, address_map &map, off address_map::address_map(device_t &device, address_spacenum spacenum) : m_spacenum(spacenum), + m_device(&device), m_databits(0xff), m_unmapval(0), m_globalmask(0) { // get our memory interface const device_memory_interface *memintf; - if (!device.interface(memintf)) - throw emu_fatalerror("No memory interface defined for device '%s'\n", device.tag()); + if (!m_device->interface(memintf)) + throw emu_fatalerror("No memory interface defined for device '%s'\n", m_device->tag()); // and then the configuration for the current address space const address_space_config *spaceconfig = memintf->space_config(spacenum); if (spaceconfig == nullptr) - throw emu_fatalerror("No memory address space configuration found for device '%s', space %d\n", device.tag(), spacenum); + throw emu_fatalerror("No memory address space configuration found for device '%s', space %d\n", m_device->tag(), spacenum); // construct the internal device map (first so it takes priority) if (spaceconfig->m_internal_map != nullptr) - (*spaceconfig->m_internal_map)(*this, device); + (*spaceconfig->m_internal_map)(*this); if (!spaceconfig->m_internal_map_delegate.isnull()) - spaceconfig->m_internal_map_delegate(*this, device); + spaceconfig->m_internal_map_delegate(*this); // append the map provided by the owner if (memintf->address_map(spacenum) != nullptr) - (*memintf->address_map(spacenum))(*this, *device.owner()); + { + m_device = device.owner(); + (*memintf->address_map(spacenum))(*this); + m_device = &device; + } else { // if the owner didn't provide a map, use the default device map if (spaceconfig->m_default_map != nullptr) - (*spaceconfig->m_default_map)(*this, device); + (*spaceconfig->m_default_map)(*this); if (!spaceconfig->m_default_map_delegate.isnull()) - spaceconfig->m_default_map_delegate(*this, device); + spaceconfig->m_default_map_delegate(*this); } } @@ -383,13 +388,14 @@ address_map::address_map(device_t &device, address_spacenum spacenum) address_map::address_map(device_t &device, address_map_entry *entry) : m_spacenum(AS_PROGRAM), + m_device(&device), m_databits(0xff), m_unmapval(0), m_globalmask(0) { // Retrieve the submap - entry->m_submap_delegate.late_bind(device); - entry->m_submap_delegate(*this, device); + entry->m_submap_delegate.late_bind(*m_device); + entry->m_submap_delegate(*this); } @@ -400,6 +406,7 @@ address_map::address_map(device_t &device, address_map_entry *entry) address_map::address_map(const address_space &space, offs_t start, offs_t end, int bits, uint64_t unitmask, device_t &device, address_map_delegate submap_delegate) : m_spacenum(space.spacenum()), + m_device(&device), m_databits(space.data_width()), m_unmapval(space.unmap()), m_globalmask(space.bytemask()) @@ -407,16 +414,16 @@ address_map::address_map(const address_space &space, offs_t start, offs_t end, i address_map_entry *e; switch(m_databits) { case 8: - e = add(device, start, end, (address_map_entry8 *)nullptr); + e = add(start, end, (address_map_entry8 *)nullptr); break; case 16: - e = add(device, start, end, (address_map_entry16 *)nullptr); + e = add(start, end, (address_map_entry16 *)nullptr); break; case 32: - e = add(device, start, end, (address_map_entry32 *)nullptr); + e = add(start, end, (address_map_entry32 *)nullptr); break; case 64: - e = add(device, start, end, (address_map_entry64 *)nullptr); + e = add(start, end, (address_map_entry64 *)nullptr); break; default: throw emu_fatalerror("Trying to dynamically map a device on a space with a corrupt databits width"); @@ -468,33 +475,33 @@ void address_map::set_global_mask(offs_t mask) // add - add a new entry of the appropriate type //------------------------------------------------- -address_map_entry8 *address_map::add(device_t &device, offs_t start, offs_t end, address_map_entry8 *ptr) +address_map_entry8 *address_map::add(offs_t start, offs_t end, address_map_entry8 *ptr) { - ptr = global_alloc(address_map_entry8(device, *this, start, end)); + ptr = global_alloc(address_map_entry8(*m_device, *this, start, end)); m_entrylist.append(*ptr); return ptr; } -address_map_entry16 *address_map::add(device_t &device, offs_t start, offs_t end, address_map_entry16 *ptr) +address_map_entry16 *address_map::add(offs_t start, offs_t end, address_map_entry16 *ptr) { - ptr = global_alloc(address_map_entry16(device, *this, start, end)); + ptr = global_alloc(address_map_entry16(*m_device, *this, start, end)); m_entrylist.append(*ptr); return ptr; } -address_map_entry32 *address_map::add(device_t &device, offs_t start, offs_t end, address_map_entry32 *ptr) +address_map_entry32 *address_map::add(offs_t start, offs_t end, address_map_entry32 *ptr) { - ptr = global_alloc(address_map_entry32(device, *this, start, end)); + ptr = global_alloc(address_map_entry32(*m_device, *this, start, end)); m_entrylist.append(*ptr); return ptr; } -address_map_entry64 *address_map::add(device_t &device, offs_t start, offs_t end, address_map_entry64 *ptr) +address_map_entry64 *address_map::add(offs_t start, offs_t end, address_map_entry64 *ptr) { - ptr = global_alloc(address_map_entry64(device, *this, start, end)); + ptr = global_alloc(address_map_entry64(*m_device, *this, start, end)); m_entrylist.append(*ptr); return ptr; } @@ -504,7 +511,7 @@ address_map_entry64 *address_map::add(device_t &device, offs_t start, offs_t end // uplift_submaps - propagate in the device submaps //------------------------------------------------- -void address_map::uplift_submaps(running_machine &machine, device_t &device, device_t &owner, endianness_t endian) +void address_map::uplift_submaps(running_machine &machine, device_t &owner, endianness_t endian) { address_map_entry *prev = nullptr; address_map_entry *entry = m_entrylist.first(); @@ -515,13 +522,13 @@ void address_map::uplift_submaps(running_machine &machine, device_t &device, dev std::string tag = owner.subtag(entry->m_read.m_tag); device_t *mapdevice = machine.device(tag.c_str()); if (mapdevice == nullptr) { - throw emu_fatalerror("Attempted to submap a non-existent device '%s' in space %d of device '%s'\n", tag.c_str(), m_spacenum, device.basetag()); + throw emu_fatalerror("Attempted to submap a non-existent device '%s' in space %d of device '%s'\n", tag.c_str(), m_spacenum, m_device->basetag()); } // Grab the submap address_map submap(*mapdevice, entry); // Recursively uplift it if needed - submap.uplift_submaps(machine, device, *mapdevice, endian); + submap.uplift_submaps(machine, *mapdevice, endian); // Compute the unit repartition characteristics int entry_bits = entry->m_submap_bits; @@ -645,10 +652,10 @@ void address_map::uplift_submaps(running_machine &machine, device_t &device, dev // one of the device's address maps //------------------------------------------------- -void address_map::map_validity_check(validity_checker &valid, const device_t &device, address_spacenum spacenum) const +void address_map::map_validity_check(validity_checker &valid, address_spacenum spacenum) const { // it's safe to assume here that the device has a memory interface and a config for this space - const address_space_config &spaceconfig = *device.memory().space_config(spacenum); + const address_space_config &spaceconfig = *m_device->memory().space_config(spacenum); int datawidth = spaceconfig.m_databus_width; int alignunit = datawidth / 8; @@ -721,7 +728,7 @@ void address_map::map_validity_check(validity_checker &valid, const device_t &de // if this is a program space, auto-assign implicit ROM entries if (entry.m_read.m_type == AMH_ROM && entry.m_region == nullptr) { - entry.m_region = device.tag(); + entry.m_region = m_device->tag(); entry.m_rgnoffs = entry.m_addrstart; } @@ -733,7 +740,7 @@ void address_map::map_validity_check(validity_checker &valid, const device_t &de std::string entry_region = entry.m_devbase.subtag(entry.m_region); // look for the region - for (device_t &dev : device_iterator(device.mconfig().root_device())) + for (device_t &dev : device_iterator(m_device->mconfig().root_device())) for (const rom_entry *romp = rom_first_region(dev); romp != nullptr && !found; romp = rom_next_region(romp)) { if (rom_region_name(dev, romp) == entry_region) diff --git a/src/emu/addrmap.h b/src/emu/addrmap.h index e440d0cd8b5..d08fe63a12d 100644 --- a/src/emu/addrmap.h +++ b/src/emu/addrmap.h @@ -282,20 +282,21 @@ public: void set_unmap_value(uint8_t value) { m_unmapval = value; } // add a new entry of the given type - address_map_entry8 *add(device_t &device, offs_t start, offs_t end, address_map_entry8 *ptr); - address_map_entry16 *add(device_t &device, offs_t start, offs_t end, address_map_entry16 *ptr); - address_map_entry32 *add(device_t &device, offs_t start, offs_t end, address_map_entry32 *ptr); - address_map_entry64 *add(device_t &device, offs_t start, offs_t end, address_map_entry64 *ptr); + address_map_entry8 *add(offs_t start, offs_t end, address_map_entry8 *ptr); + address_map_entry16 *add(offs_t start, offs_t end, address_map_entry16 *ptr); + address_map_entry32 *add(offs_t start, offs_t end, address_map_entry32 *ptr); + address_map_entry64 *add(offs_t start, offs_t end, address_map_entry64 *ptr); // public data address_spacenum m_spacenum; // space number of the map + device_t * m_device; // associated device uint8_t m_databits; // data bits represented by the map uint8_t m_unmapval; // unmapped memory value offs_t m_globalmask; // global mask simple_list m_entrylist; // list of entries - void uplift_submaps(running_machine &machine, device_t &device, device_t &owner, endianness_t endian); - void map_validity_check(validity_checker &valid, const device_t &device, address_spacenum spacenum) const; + void uplift_submaps(running_machine &machine, device_t &owner, endianness_t endian); + void map_validity_check(validity_checker &valid, address_spacenum spacenum) const; }; @@ -310,7 +311,7 @@ public: #define ADDRESS_MAP_NAME(_name) construct_address_map_##_name #define ADDRESS_MAP_START(_name, _space, _bits, _class) \ -void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device) \ +void ADDRESS_MAP_NAME(_name)(address_map &map) \ { \ typedef read##_bits##_delegate read_delegate ATTR_UNUSED; \ typedef write##_bits##_delegate write_delegate ATTR_UNUSED; \ @@ -319,7 +320,7 @@ void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device) \ map.configure(_space, _bits); \ typedef _class drivdata_class ATTR_UNUSED; #define DEVICE_ADDRESS_MAP_START(_name, _bits, _class) \ -void _class :: _name(::address_map &map, device_t &device) \ +void _class :: _name(::address_map &map) \ { \ typedef read##_bits##_delegate read_delegate ATTR_UNUSED; \ typedef write##_bits##_delegate write_delegate ATTR_UNUSED; \ @@ -332,12 +333,12 @@ void _class :: _name(::address_map &map, device_t &device) \ // use this to declare external references to an address map #define ADDRESS_MAP_EXTERN(_name, _bits) \ - extern void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device) + extern void ADDRESS_MAP_NAME(_name)(address_map &map) // use this to declare an address map as a member of a modern device class // need to qualify with :: to avoid a collision with descendants of device_memory_interface #define DECLARE_ADDRESS_MAP(_name, _bits) \ - void _name(::address_map &map, device_t &device) + void _name(::address_map &map) // global controls @@ -350,14 +351,14 @@ void _class :: _name(::address_map &map, device_t &device) \ // importing data from other address maps #define AM_IMPORT_FROM(_name) \ - ADDRESS_MAP_NAME(_name)(map, device); + ADDRESS_MAP_NAME(_name)(map); // importing data from inherited address maps #define AM_INHERIT_FROM(_name) \ - _name(map, device); + _name(map); // address ranges #define AM_RANGE(_start, _end) \ - curentry = map.add(device, _start, _end, curentry); + curentry = map.add(_start, _end, curentry); #define AM_MASK(_mask) \ curentry->set_mask(_mask); #define AM_MIRROR(_mirror) \ diff --git a/src/emu/dimemory.cpp b/src/emu/dimemory.cpp index 6071f5c2405..9d038af72d9 100644 --- a/src/emu/dimemory.cpp +++ b/src/emu/dimemory.cpp @@ -243,7 +243,7 @@ void device_memory_interface::interface_validity_check(validity_checker &valid) ::address_map addrmap(const_cast(device()), spacenum); // let the map check itself - addrmap.map_validity_check(valid, device(), spacenum); + addrmap.map_validity_check(valid, spacenum); } } } diff --git a/src/emu/emumem.cpp b/src/emu/emumem.cpp index 27dc67a9385..0deab9d74a4 100644 --- a/src/emu/emumem.cpp +++ b/src/emu/emumem.cpp @@ -2011,7 +2011,7 @@ void address_space::prepare_map() m_map = std::make_unique(m_device, m_spacenum); // merge in the submaps - m_map->uplift_submaps(machine(), m_device, m_device.owner() ? *m_device.owner() : m_device, endianness()); + m_map->uplift_submaps(machine(), m_device.owner() ? *m_device.owner() : m_device, endianness()); // extract global parameters specified by the map m_unmap = (m_map->m_unmapval == 0) ? 0 : ~0; @@ -2434,8 +2434,8 @@ void address_space::unmap_generic(offs_t addrstart, offs_t addrend, offs_t addrm void address_space::install_device_delegate(offs_t addrstart, offs_t addrend, device_t &device, address_map_delegate &delegate, int bits, uint64_t unitmask) { check_address("install_device_delegate", addrstart, addrend); - address_map map(*this, addrstart, addrend, bits, unitmask, device, delegate); - map.uplift_submaps(machine(), m_device, device, endianness()); + address_map map(*this, addrstart, addrend, bits, unitmask, m_device, delegate); + map.uplift_submaps(machine(), device, endianness()); populate_from_map(&map); } diff --git a/src/emu/emumem.h b/src/emu/emumem.h index 80f8e050660..ccdc6c28335 100644 --- a/src/emu/emumem.h +++ b/src/emu/emumem.h @@ -80,10 +80,10 @@ class address_table_setoffset; typedef uint32_t offs_t; // address map constructors are functions that build up an address_map -typedef void (*address_map_constructor)(address_map &map, device_t &devconfig); +typedef void (*address_map_constructor)(address_map &map); // submap retriever delegate -typedef named_delegate address_map_delegate; +typedef named_delegate address_map_delegate; // struct with function pointers for accessors; use is generally discouraged unless necessary struct data_accessors @@ -384,7 +384,7 @@ public: void install_ram(offs_t addrstart, offs_t addrend, offs_t addrmirror, void *baseptr = nullptr) { install_ram_generic(addrstart, addrend, addrmirror, ROW_READWRITE, baseptr); } // install device memory maps - template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(address_map &map, device_t &device), int bits = 0, uint64_t unitmask = 0) { + template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(address_map &map), int bits = 0, uint64_t unitmask = 0) { address_map_delegate delegate(map, "dynamic_device_install", &device); install_device_delegate(addrstart, addrend, device, delegate, bits, unitmask); } diff --git a/src/mame/drivers/tranz330.cpp b/src/mame/drivers/tranz330.cpp index e2fc9a5eb8a..cf151b0c3f4 100644 --- a/src/mame/drivers/tranz330.cpp +++ b/src/mame/drivers/tranz330.cpp @@ -23,38 +23,38 @@ #include "includes/tranz330.h" #include "tranz330.lh" -static void construct_address_map_tranz330_mem(address_map &map, device_t &device) +static void construct_address_map_tranz330_mem(address_map &map) { map.configure(AS_PROGRAM, 8); address_map_entry8 *curentry = nullptr; - curentry = map.add(device, 0x0000, 0x7fff, curentry); + curentry = map.add(0x0000, 0x7fff, curentry); curentry->set_read_type(AMH_ROM); - curentry = map.add(device, 0x8000, 0xffff, curentry); + curentry = map.add(0x8000, 0xffff, curentry); curentry->set_read_type(AMH_RAM); curentry->set_write_type(AMH_RAM); } -static void construct_address_map_tranz330_io(address_map &map, device_t &device) +static void construct_address_map_tranz330_io(address_map &map) { map.configure(AS_IO, 8); map.set_global_mask(0xff); address_map_entry8 *curentry = nullptr; - curentry = map.add(device, 0x00, 0x03, curentry); + curentry = map.add(0x00, 0x03, curentry); curentry->set_handler(read8_delegate(&z80pio_device::read_alt, "z80pio_device::read_alt", PIO_TAG, (z80pio_device *)nullptr), write8_delegate(&z80pio_device::write_alt, "z80pio_device::write_alt", PIO_TAG, (z80pio_device *)nullptr)); - curentry = map.add(device, 0x10, 0x13, curentry); + curentry = map.add(0x10, 0x13, curentry); curentry->set_handler(read8_delegate(&z80ctc_device::read, "z80ctc_device::read", CTC_TAG, (z80ctc_device *)nullptr), write8_delegate(&z80ctc_device::write, "z80ctc_device::write", CTC_TAG, (z80ctc_device *)nullptr)); - curentry = map.add(device, 0x20, 0x23, curentry); + curentry = map.add(0x20, 0x23, curentry); curentry->set_handler(read8_delegate(&z80dart_device::ba_cd_r, "z80dart_device::ba_cd_r", DART_TAG, (z80dart_device *)nullptr), write8_delegate(&z80dart_device::ba_cd_w, "z80dart_device::ba_cd_w", DART_TAG, (z80dart_device *)nullptr)); - curentry = map.add(device, 0x30, 0x3f, curentry); + curentry = map.add(0x30, 0x3f, curentry); curentry->set_handler(read8_delegate(&msm6242_device::read, "msm6242_device::read", RTC_TAG, (msm6242_device *)nullptr), write8_delegate(&msm6242_device::write, "msm6242_device::write", RTC_TAG, (msm6242_device *)nullptr)); }