Commit Graph

276 Commits

Author SHA1 Message Date
Oliver Stöneberg
c1c74973ee memory: Add another missing 32->64 bits conversion when building the invsubmask (nw) 2013-02-11 19:25:48 +00:00
Olivier Galibert
6852552362 memory: Add missing 32->64 bits conversion when building the invsubmask [Oliver Stöneberg] 2013-02-10 15:07:37 +00:00
Oliver Stöneberg
278ff20c73 replaced bogus memcpy in handler_entry_{read|write} - fixes Visual Studio-only issues/crashes in paso1600, multi16, x68030 and t1000* sets (MT05124,MT05110,MT05112) [Olivier Galibert] 2013-02-03 17:37:57 +00:00
Miodrag Milanovic
0e19f641d3 Cleanups and version bump 2013-01-11 07:32:46 +00:00
Olivier Galibert
23e22e19f0 memory: Map from the cpu's owner, not the root device, otherwise siblings of cpus coming from config fragments aren't happy. [O. Galibert] 2012-10-12 13:01:21 +00:00
Olivier Galibert
5a2289ab25 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.
2012-10-10 15:33:36 +00:00
Aaron Giles
ea8a131e0d Moved device_delegates into their own files. Employed a
non-templatized helper class so that the code can live
co-located, rather than invading device.h.

Changed the read/write delegates to derive from 
device_delegate. Updated the address map macros to create
these properly.

Removed remnants of the old AM_BASE/SIZE macros from the
memory system.
2012-09-26 10:07:49 +00:00
Aaron Giles
81c982ec56 Remove all traces of read/write*_device_func from memory.c.
All legacy device callbacks are now promoted to delegates
and handed off to the modern read/write handler managers.
Fixed ibm5150 and surely many other broken systems. (nw)
2012-09-18 06:10:57 +00:00
Aaron Giles
0dc663e2e9 Memory handler cleanup 3. Add mem_mask parameter
to 8-bit handlers to match the others. To ease
pain, added DECLARE_READ/WRITE_HANDLER macros that
set up a default parameter. Also updated devcb so
that the handlers can be called with or without the
mem_mask. [Aaron Giles]
2012-09-17 09:16:44 +00:00
Aaron Giles
3cce7e019e Memory handler normalization, part 2. Change legacy
read/write handlers to take an address_space & instead
of an address_space *. Also update pretty much all other
functions to take a reference where appropriate.
[Aaron Giles]
2012-09-17 08:22:16 +00:00
Aaron Giles
cc16777cce Memory handler normalization, part 1.
READ/WRITE_DEVICE*_HANDLERs are now passed an
address_space &, and the 8-bit variants get a mem_mask
as well. This means they are now directly compatible
with the member function delegates. Added a generic
address space to the driver_device that can be used
when no specific address space is available. Also
added DECLARE_READ/WRITE_DEVICE*_HANDLER macros to
declare device callbacks with default mem_mask
parameters. [Aaron Giles]
2012-09-17 07:43:37 +00:00
Oliver Stöneberg
512acc5bd6 added missing \n to even more fatalerror() calls (no whatsnew) 2012-09-08 12:52:35 +00:00
Olivier Galibert
40c79602b6 memory: Add support for dynamically mapping devices [O. Galibert]
Just call install_device on the space with as parameters:
- start and end of the mapping zone
- device (not pointer to the device)
- map method

and optionally, if the device data width is not the same than the
space data width:
- device data width (for consistency checking)
- unit mask

For instance, the static mapping:
  AM_RANGE(0x02114100, 0x02114107) AM_DEVICE8("fdc", n82077aa_device, amap, 0xffffffff)

can be converted to a dynamic mapping (where fdc is a pointer to the device):
  machine().device("maincpu")->memory().space(AS_PROGRAM)->
    install_device(0x02114100, 0x02114107, *fdc, &n82077aa_device::amap, 8, 0xffffffff);
2012-08-03 18:55:37 +00:00
Aaron Giles
2a88e54278 ioport.c C++ conversion. Mostly internal changes, with no
intended differences from previous behavior. For drivers,
the main change is that input_port_read() no longer exists.
Instead, the port must be fetched from the appropriate device,
and then read() is called.

For member functions, this is actually simpler/cleaner:

  value = ioport("tag")->read()

For legacy functions which have a driver_data state, it goes:

  value = state->ioport("tag")->read()

For other legacy functions, they need to fetch the root device:

  value = machine.root_device().ioport("tag")->read()

The other big change for drivers is that IPT_VBLANK is gone.
Instead, it has been replaced by a device line callback on the
screen device. There's a new macro PORT_VBLANK("tag") which
automatically points things to the right spot.

Here's a set of imperfect search & replace strings to convert
the input_port_read calls and fix up IPT_VBLANK:

input_port_read( *\( *)(machine\(\)) *, *([^)]+ *\))
ioport\1\3->read\(\)

input_port_read( *\( *)(.*machine[()]*) *, *([^)]+ *\))
\2\.root_device\(\)\.ioport\1\3->read\(\)

(state = .*driver_data[^}]+)space->machine\(\)\.root_device\(\)\.
\1state->

(state = .*driver_data[^}]+)device->machine\(\)\.root_device\(\)\.
\1state->

input_port_read_safe( *\( *)(machine\(\)) *, *([^,]+), *([^)]+\))
ioport\1\3->read_safe\(\4\)

IPT_VBLANK( *\))
IPT_CUSTOM\1 PORT_VBLANK("screen")
2012-05-03 09:00:08 +00:00
Aaron Giles
9afad3fd75 Use a tagged_list for memory_banks. 2012-04-24 04:47:27 +00:00
Angelo Salese
ded30e907e Clean-ups and version bump 2012-04-22 14:10:44 +00:00
Aaron Giles
f3de08a9f8 Created ioport_manager and moved the port list to it.
Removed global port lookups, now all lookups must be
done through device_t::ioport().
2012-04-22 05:07:46 +00:00
Aaron Giles
5594694605 Make memory shares follow the same pattern as memory
regions and memory banks, accessible only via the device.
2012-04-20 19:57:41 +00:00
Aaron Giles
18f33f4eff Changed device->subregion to device->memregion. Moved
memory_region management into the memory manager instead
of directly in the machine. Hid the global region method;
now all regions must be looked up relative to a device.

If you're a member function, you can just use memregion("tag") 
directly. If you're a global function or a device referencing
global regions, use machine().root_device().memregion("tag")
to look up regions relative to the root.

S&R to convert all references:

machine([()]*)\.region
machine\1\.root_device\(\).subregion

Then remove redundant machine().root_device() within src/mame:

([ \t])machine\(\)\.root_device\(\)\.
\1

And use state->memregion() if we have a state variable present:

(state *= *[^;]+driver_data[^}]+)([^ \t]*)machine[()]*\.root_device\(\)\.
\1state->

Finally some cleanup:

screen.state->
state->

device->state->
state->

space->state->
state->

And a few hand-tweaks.
2012-04-20 05:54:39 +00:00
Aaron Giles
b5b7808cb7 Remove global memory banking functions in favor of referencing
subbanks of a device and directly acting on them.

First round S&R:

memory_configure_bank( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->configure_entries\1\(\2

memory_configure_bank_decrypted( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->configure_decrypted_entries\1\(\2

memory_set_bank( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->set_entry\1\(\2

memory_set_bankptr( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->set_base\1\(\2


Then convert single entries to simpler form:

configure_entries( *\( *[^,]+, *)1 *, *([^,]+),[^)]+\)
configure_entry\1\2\)

configure_decrypted_entries( *\( *[^,]+, *)1 *, *([^,]+),[^)]+\)
configure_decrypted_entry\1\2\)


Remove renundant root_device lookup for methods:

([ \t])machine\(\)\.root_device\(\)\.
\1


Use state-> instead of root_device lookup where available (this
one must be done by hand unfortunately):

([^ \t]*)machine[()]*\.root_device\(\)\.
state->
2012-04-19 20:35:01 +00:00
Aaron Giles
523c35daed Now that memory_bank is exposed as an object, removed all the global
bank manipulation APIs from memory_manager, and instead added a
memory_manager::bank("tag") function which will return a pointer to
the representative memory_bank. Operations can then be performed as
expected directly on the memory_bank. Most code did not need an update
yet, as I haven't done the search/replace to move away from global
functions (which still exist for now).

Added device_t::subbank("tag") to return a bank that is owned by the
given device.

Switched YM2151 interfaces over to devcb callbacks.

Created proper sound devices for the Williams NARC, CVSD and ADPCM
sound boards. Updated midyunit, midtunit, williams(joust2), and
mcr68(archrivl/pigskin/trisport) to use the new devices.
2012-04-18 19:40:59 +00:00
Aaron Giles
3c0e321123 Remove AM_BASE in favor of AM_SHARED + required_shared_ptr.
This update passes validity checks but will certainly have
a number of drivers failing at startup because all pointers
are defaulted to required by the automated scripts used. 
Will fix problems once we get a regression run to find out 
which drivers need attention.
2012-04-15 05:44:22 +00:00
Aaron Giles
5352ec77d8 Remove AM_SIZE entirely. AM_BASE_SIZE still exists, though. 2012-04-11 23:14:33 +00:00
Angelo Salese
35e09dd41c Clean-ups and version bump 2012-04-08 14:12:02 +00:00
Aaron Giles
f87e01ed81 Converted memory_private to memory_manager and moved global memory
operations into methods on it. Converted the less-popular cases over
in drivers that used them, leaving the bank management APIs global
for now.
2012-04-05 18:25:39 +00:00
Aaron Giles
194397db29 Moved all drivers to using the paletteram helpers defined in the
driver_device base class. The palette base is now specified via an
AM_SHARE of "paletteram" or "paletteram2". The driver_device base
class now finds these pointers and places them in 
m_generic_paletteram_8/_16/_32 and m_generic_paletteram2_8/_16/_32.

Removed machine.generic.paletteram*, and machine.generic entirely.
Removed AM_BASE_GENERIC/AM_SIZE_GENERIC as they don't apply anymore.

Changed required_/optional_shared_ptr to support set_target with
base and size for manually configuring a shared pointer, and a new
allocate method for dynamically allocating (and registering the
memory for save states).

A few subsequent cleanups are coming related to this, but wanted
to get this in before the next modern push.
2012-04-05 07:44:51 +00:00
Scott Stone
a4098e8a3a Some cleanup of some observed #include redundancy from source files which use emu.h (nw) 2012-02-06 01:30:22 +00:00
Angelo Salese
505442d0a0 Clean-ups and version bump 2012-01-29 16:34:26 +00:00
Aaron Giles
ed0207f126 Move devices into a proper hierarchy and handle naming
and paths consistently for devices, I/O ports, memory
regions, memory banks, and memory shares. [Aaron Giles]

NOTE: there are likely regressions lurking here, mostly
due to devices not being properly found. I have temporarily
added more logging to -verbose to help understand what's
going on. Please let me know ASAP if anything that is being
actively worked on got broken.

As before, the driver device is the root device and all 
other devices are owned by it. Previously all devices
were kept in a single master list, and the hierarchy was
purely logical. With this change, each device owns its
own list of subdevices, and the hierarchy is explicitly
manifest. This means when a device is removed, all of its
subdevices are automatically removed as well.

A side effect of this is that walking the device list is
no longer simple. To address this, a new set of iterator
classes is provided, which walks the device tree in a depth
first manner. There is a general device_iterator class for
walking all devices, plus templates for a device_type_iterator
and a device_interface_iterator which are used to build
iterators for identifying only devices of a given type or
with a given interface. Typedefs for commonly-used cases
(e.g., screen_device_iterator, memory_interface_iterator)
are provided. Iterators can also provide counts, and can
perform indexed lookups.

All device name lookups are now done relative to another 
device. The maching_config and running_machine classes now
have a root_device() method to get the root of the hierarchy. 
The  existing machine->device("name") is now equivalent to
machine->root_device().subdevice("name").

A proper and normalized device path structure is now
supported. Device names that start with a colon are
treated as absolute paths from the root device. Device
names can also use a caret (^) to refer to the owning
device. Querying the device's tag() returns the device's
full path from the root. A new method basetag() returns
just the final tag.

The new pathing system is built on top of the 
device_t::subtag() method, so anyone using that will 
automatically support the new pathing rules. Each device
has its own internal map to cache successful lookups so
that subsequent lookups should be very fast.

Updated every place I could find that referenced devices,
memory regions, I/O ports, memory banks and memory shares
to leverage subtag/subdevice (or siblingtag/siblingdevice
which are built on top).

Removed the device_list class, as it doesn't apply any
more. Moved some of its methods into running_machine
instead.

Simplified the device callback system since the new 
pathing can describe all of the special-case devices that
were previously handled manually.

Changed the core output function callbacks to be delegates.

Completely rewrote the validity checking mechanism. The
validity checker is now a proper C++ class, and temporarily
takes over the error and warning outputs. All errors and 
warnings are collected during a session, and then output in
a consistent manner, with an explicit driver and source file
listed for each one, as well as additional device and/or
I/O port contexts where appropriate. Validity checkers 
should no longer explicitly output this information, just
the error, assuming that the context is provided.

Rewrote the software_list_device as a modern device, getting
rid of the software_list_config abstraction and simplifying
things.

Changed the way FLAC compiles so that it works like other
external libraries, and also compiles successfully for MSVC
builds.
2012-01-24 20:18:55 +00:00
Angelo Salese
5ee0c7d818 clean-ups and version bump 2011-10-10 21:17:54 +00:00
Miodrag Milanovic
4aae041c38 Simplified way of getting octal info (no whatsnew) 2011-10-04 17:16:07 +00:00
Miodrag Milanovic
6730bf8cc7 Added a way to handle output for debug messages and debugger itself into octal too, and made
a few CPU's to give octal output by default.
Note that for now just some functions things return octal, will add more, but since this change required clean compile better to put it sooner then later (no whatsnew)
2011-10-04 09:58:07 +00:00
R. Belmont
1d64e14960 Allow region tags starting with a : to mean "absolute" so devices can access the parent base driver's ROM regions [R. Belmont] 2011-09-17 18:47:02 +00:00
Olivier Galibert
c9fc846c46 memory: Fix an endianness issue when doing a device mapping on a big endian bus [O. Galibert] 2011-08-05 18:52:29 +00:00
Olivier Galibert
abc59bb3f8 addrmap: Allow adding device-sourced memory maps in the main map. [O. Galibert]
Device-side, it only works for modern device.  Declare the map with
DECLARE_ADDRESS_MAP(name, width).  It's a method which can be virtual
but not static.

In the implementation, define ADDRESS_MAP_MODERN, and define the map
starting with DEVICE_ADDRESS_MAP_START(name, width, device_class).
Rest is like a normal modern map.

To include it in the memory map use:
  AM_DEVICE( "device tag", devicea_class, name )

Or for device with differing widths:
  AM_DEVICE8(  "device tag", devicea_class, name, unitmask )
  AM_DEVICE16( "device tag", devicea_class, name, unitmask )
  AM_DEVICE32( "device tag", devicea_class, name, unitmask )
2011-07-05 04:41:06 +00:00
Curt Coder
f58d71ae0b Added device-relative functions for memory banking. [Curt Coder] 2011-06-23 13:27:35 +00:00
Miodrag Milanovic
742a3a92b3 Fix for remaining issues with validation of rom regions (no whatsnew) 2011-06-22 16:23:32 +00:00
Miodrag Milanovic
d0793e644d Fixed AM_REGION to be relative to device (no whatsnew) 2011-06-22 12:13:55 +00:00
Angelo Salese
e6050ace10 Cleanups and version bump 2011-06-19 19:29:25 +00:00
Wilbert Pol
d565bd41e6 memory.c: Fixed display of physical addresses in the debug memory viewer. [Wilbert Pol] 2011-06-14 20:20:48 +00:00
Olivier Galibert
58e656ed66 Duh! (nwn) 2011-06-12 21:14:45 +00:00
Olivier Galibert
e072ccc0f2 memory: Stop being stupid and call the extremely well written
populate_range_mirrored code through map_range when appropriate, which
is most of the time.  [O. Galibert]
2011-06-10 17:50:01 +00:00
Angelo Salese
a449c766a2 Cleanups and version bump 2011-06-05 22:35:20 +00:00
Olivier Galibert
87a6c3f7f8 memory: Change the gc into a refcounter, for speed reasons. [O. Galibert] 2011-06-05 09:03:31 +00:00
Olivier Galibert
b0a4945735 Revert "memory: Change the gc into a refcounter, for speed reasons. [O. Galibert]"
This reverts commit 5deef5b2c6fabdea8cd45ccf71c99f56940e88a2.

Broken, sorry.
2011-06-01 13:00:12 +00:00
Olivier Galibert
f90cbff557 memory: Change the gc into a refcounter, for speed reasons. [O. Galibert] 2011-06-01 12:56:00 +00:00
Olivier Galibert
459102e95f memory: Implement depopulate_unused(). [O. Galibert]
depopulate_unused is essentially the garbage collector for
bottom-level handlers.  The previous code was working around not
having it implemented yet by reusing handlers with the same start
address, end address and address mask.  The problem with that trick is
that it is slightly incorrect.  If you have a memory map with:
  AM_RANGE(0x0000, 0x0fff) AM_READ(up_r)
  AM_RANGE(0x0000, 0x0fff) AM_READ(down_r) AM_MIRROR(0x8000)

then the range 8000..8fff would have called up_r instead of down_r due
to the handler reuse.  The mirror value is not saved, hence not
compared.  New code doesn't use the trick, so doesn't call the wrong
handler, but OTOH eats handlers for breakfast.

It's important to note that such a memory map is so highly improbable
hardware-wise that it wasn't worth worrying about.  But it's a
behaviour change it is interesting to keep in mind.  In particular
since the up_r range can be added through an install_read_handler
instead of a static map.
2011-06-01 07:09:24 +00:00
Scott Stone
50c4a12869 Per OG: Change to allow debug to correctly build. (no whatsnew.txt) 2011-05-31 22:14:59 +00:00
Olivier Galibert
f8c1c71594 memory: Finally allow different handlers on different subunits of the same address. [O. Galibert] 2011-05-31 19:18:48 +00:00
Olivier Galibert
35df369f0f memory: Add a handler copy function which works on subunits-only handlers. [O. Galibert] 2011-05-31 19:18:42 +00:00