is now separate from runtime device state. I have larger plans
for devices, so there is some temporary scaffolding to hold
everything together, but this first step does separate things
out.
There is a new class 'running_device' which represents the
state of a live device. A list of these running_devices sits
in machine->devicelist and is created when a running_machine
is instantiated.
To access the configuration state, use device->baseconfig()
which returns a reference to the configuration.
The list of running_devices in machine->devicelist has a 1:1
correspondance with the list of device configurations in
machine->config->devicelist, and most navigation options work
equally on either (scanning by class, type, etc.)
For the most part, drivers will now deal with running_device
objects instead of const device_config objects. In fact, in
order to do this patch, I did the following global search &
replace:
const device_config -> running_device
device->static_config -> device->baseconfig().static_config
device->inline_config -> device->baseconfig().inline_config
and then fixed up the compiler errors that fell out.
Some specifics:
Removed device_get_info_* functions and replaced them with
methods called get_config_*.
Added methods for get_runtime_* to access runtime state from
the running_device.
DEVICE_GET_INFO callbacks are only passed a device_config *.
This means they have no access to the token or runtime state
at all. For most cases this is fine.
Added new DEVICE_GET_RUNTIME_INFO callback that is passed
the running_device for accessing data that is live at runtime.
In the future this will go away to make room for a cleaner
mechanism.
Cleaned up the handoff of memory regions from the memory
subsystem to the devices.
- Created new central header "emu.h"; this should be included
by pretty much any driver or device as the first include. This
file in turn includes pretty much everything a driver or device
will need, minus any other devices it references. Note that
emu.h should *never* be included by another header file.
- Updated all files in the core (src/emu) to use emu.h.
- Removed a ton of redundant and poorly-tracked header includes
from within other header files.
- Temporarily changed driver.h to map to emu.h until we update
files outside of the core.
Added class wrapper around tagmap so it can be directly included
and accessed within objects that need it. Updated all users to
embed tagmap objects and changed them to call through the class.
Added nicer functions for finding devices, ports, and regions in
a machine:
machine->device("tag") -- return the named device, or NULL
machine->port("tag") -- return the named port, or NULL
machine->region("tag"[, &length[, &flags]]) -- return the
named region and optionally its length and flags
Made the device tag an astring. This required touching a lot of
code that printed the device to explicitly fetch the C-string
from it. (Thank you gcc for flagging that issue!)
- simplified RSP's misaligned memory accesses
- removed now-unnecessary shifts from direct memory accesses in
mips3/powerpc drcs
- optimized AND with 0xff/0xffff/0xffffffff cases for x86/x64
- added rudimentary memory/register tracking in x86 backend to
remove redundant loads
memory_install_ram() to assign a un-named bank to a region and specify
a pointer to where the RAM lives. If this is called in the DRIVER_INIT
function or MACHINE/SOUND/VIDEO_START functions, then it is permissible
to specify NULL, in which case the memory system will allocate memory
and register it for save states.
memory_install_rom() is like the above except that it only installs a
read handler.
memory_install_writeonly() is like the above except that it only installs
a write handler.
Updated several instances in the code that were assigning banks to these
sorts of static RAM regions and simplified the code.
Also fixed several regressions reported by Tafoid.
their place are a series of expanded macros and new memory
installation helpers. Some mappings below (not all are new):
AM_READ(SMH_RAM) -> AM_READONLY
AM_WRITE(SMH_RAM) -> AM_WRITEONLY
AM_READWRITE(SMH_RAM, SMH_RAM) -> AM_RAM
AM_READ(rhandler) AM_WRITE(SMH_RAM) -> AM_RAM_READ(rhandler)
AM_READ(SMH_RAM) AM_WRITE(whandler) -> AM_RAM_WRITE(whandler)
AM_DEVREAD(tag, rhandler) AM_WRITE(SMH_RAM)
-> AM_RAM_DEVREAD(tag, rhandler)
AM_READ(SMH_RAM) AM_DEVWRITE(tag, whandler)
-> AM_RAM_DEVWRITE(tag, whandler)
AM_READ(SMH_ROM) -> AM_ROM
AM_WRITE(SMH_ROM) -> (was a no-op)
AM_READ(SMH_NOP) -> AM_READNOP
AM_WRITE(SMH_NOP) -> AM_WRITENOP
AM_READWRITE(SMH_NOP, SMH_NOP) -> AM_NOP
For dynamic memory handler installation of the various types,
use the new functions:
memory_unmap_read()
memory_unmap_write()
memory_unmap_readwrite() -- unmaps a section of address space
memory_nop_read()
memory_nop_write()
memory_nop_readwrite() -- nops a section of address space
Cleaned up the internals of the address_map_entry structure, and
also normalized the way the address map macros work to remove a
lot of redundancy.
Changed all memory_bank_* functions to specify a tag.
Bulk-converted existing banks to be tagged "bank##" in
order to ensure consistency. However, going forward, the
tags don't matter, so please name them something useful.
Added AM_BANK_READ/AM_BANK_WRITE macros to let you specify
bank tags. Also changed AM_ROMBANK and AM_RAMBANK macros to
accept tags as well.
Added new functions memory_install_read_bank_handler and
memory_install_write_bank_handler to install banks by tag
name, similar to input ports.
Changed internals of memory system to dynamically allocate
all banks. The first time a bank with an unknown tag is
installed, a new bank object is created and tracked
internally. Removed all SMH_BANK(n) references outside of
the main code; these should never, ever be useful anymore.
- fixed bug in vtlb code that caused us to lose track of previously
registered fixed page ranges
- fixed MIPS3 behavior that would not clear out invalid page ranges
from the VTLB under certain circumstances
- added support for TLB sizes less than 48 entries
- now properly generating TLB fill exceptions under correct circumstances
- TLB exceptions no longer trash low 4 bits of Context
- exceptions with the EXL bit set always go to vector 0x180
Types are pretty much unified now.
Multiply operations are handled by eminline.h.
Divide operations were just silly in macros.
64/32-bit combination/extraction macros moved to osdcomm.h and renamed.
Also fixed compile errors in recent 68k changes.
> Sent: Monday, September 07, 2009 8:08 PM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] const/static/include fixes
>
> Hi mamedev,
>
> A result of some code auditing, this patch adds missing static and
> const qualifiers, and fixes up some header files.
>
> ~aa
Fixed a register naming issue in the MIPS core [Harmony]
Numerous SuperFX updates: [Harmony]
- Hooked up RAM and ROM buffering
- Inlined several more functions
- Removed debug spew
- Added the ability to define an external IRQ line callback, and hooked it up to the 65C816
- Fixed flag calculation for HIB opcode
- Hooked SuperFX chip up to the SNES machine driver
- added unidasm to the tools build
- split the disassemblers out of libcpu and into new libdasm
- ensured the disassembly entry points for all disassemblers are
in the source file for the disassembler (sometimes new generic
versions were created)
Still needs command line options and file loading, but the
fundamentals are present, and it links.
to devintrf (including endianness). Removed space array from the
CPU class header. Made the memory system much more device-neutral.
Various other cleanups along the way.
This update changes the way we handle memory allocation. Rather
than allocating in terms of bytes, allocations are now done in
terms of objects. This is done via new set of macros that replace
the malloc_or_die() macro:
alloc_or_die(t) - allocate memory for an object of type 't'
alloc_array_or_die(t,c) - allocate memory for an array of 'c' objects of type 't'
alloc_clear_or_die(t) - same as alloc_or_die but memset's the memory to 0
alloc_array_clear_or_die(t,c) - same as alloc_array_or_die but memset's the memory to 0
All original callers of malloc_or_die have been updated to call these
new macros. If you just need an array of bytes, you can use
alloc_array_or_die(UINT8, numbytes).
Made a similar change to the auto_* allocation macros. In addition,
added 'machine' as a required parameter to the auto-allocation macros,
as the resource pools will eventually be owned by the machine object.
The new macros are:
auto_alloc(m,t) - allocate memory for an object of type 't'
auto_alloc_array(m,t,c) - allocate memory for an array of 'c' objects of type 't'
auto_alloc_clear(m,t) - allocate and memset
auto_alloc_array_clear(m,t,c) - allocate and memset
All original calls or auto_malloc have been updated to use the new
macros. In addition, auto_realloc(), auto_strdup(), auto_astring_alloc(),
and auto_bitmap_alloc() have been updated to take a machine parameter.
Changed validity check allocations to not rely on auto_alloc* anymore
because they are not done in the context of a machine.
One final change that is included is the removal of SMH_BANKn macros.
Just use SMH_BANK(n) instead, which is what the previous macros mapped
to anyhow.
or ENDIANNESS_BIG based on the LSB_FIRST definition. Unlink LSB_FIRST,
ENDIANNESS_NATIVE always exists and can be used in expressions without
invoking the preprocessor.
Added macro ENDIAN_VALUE_LE_BE() which selects one of two values based
on the endianness passed in. Also added NATIVE_ENDIAN_VALUE_LE_BE()
which calls ENDIAN_VALUE_LE_BE with ENDIANNESS_NATIVE.
Updated a number of drivers and call sites to use these macros in favor
of #ifdef LSB_FIRST.
describes the interface, but does not contain any implementation.
All remaining bits of implementation have been migrated either to
cpuexec.c or to debugcpu.c. Specifically, cpu_dasm() is now
debug_cpu_disassemble(), and cpu_set_dasm_override() is now
debug_cpu_set_dasm_override(). Also moved memory_address_physical()
to debug_cpu_translate(), since it was only ever used for
debugging.
Changed all CPU and sound cores to use memory_find_address_space()
instead of cpu_get_address_space(). The former is reliable even
during early initialization when the CPU cores generally need it.
Removed the dummy CPU core and cpuintrf.c.
Changed the core execution loop to directly call the execute
function instead of using the inline helper (which has been removed).
bus width and shift CPU interface constants. Changed all the cores
to use them.
Minor spacing cleanup in Z80, Z180, TMS34010, ADSP21xx cores.
Changed ADSP21xx cores to accept a configuration struct instead of
using set_info to specify serial port callbacks. Simplified the
ADSP21xx get/set info significantly. Removed support for only
including certain variants of the chips; they are now either all
supported or all unsupported.
specified when the device is added, and the clock is available in
the device_config directly via device->clock. Updated all devices
that have a clock to specify it when adding the device, rather than
as part of their configuration. As part of this work, also created
device-specific _ADD and _REMOVE macros to simplify configuration.
Dfined a generic device execute function callback, though it
is not used yet. The long term plan is that any device with an
execute callback will be scheduled along with the CPUs. Now that
CPUs are devices, their scheduling will be moved over to this
logic eventually.
Changed various NVRAM devices to fetch their default memory region
from the device->region rather than specifying it in the
configuration.
Moved a number of CPUINFO_PTR_* constants to CPUINFO_FCT_*.
Fixed several drivers that manually created their own gfx_elements
to fill in the machine object, so they no longer crash.
Fixed incorrect CPU display on info screen (recently broken).
Moved device startup to *before* the DRIVER_INIT is called. This
is to allow the DRIVER_INIT to configure devices that have been
properly allocated. So far I don't see any negative effects, but
be on the lookout if something weird shows up.
Rewrote the device iteration logic to make use of the typenext
field and the newly-introduced classnext field for iterating more
efficiently through devices of a given type or class.
Fixed behavior of MDRV_CPU_REPLACE so it does not delete and then
re-add a CPU (causing the order to change).
Sent: Tuesday, December 16, 2008 12:20 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Migrate CPU defines to cpu header files
Hi mamedev,
This patch migrates all the CPU definitions into the cpu header files.
The #defines and CPU_GET_INFO declarations were added by hand to the
cpu cores in the first patch, plus a few partly related fixes to the
non-DRC cores. The second patch was produced by the attached script
which inserts all needed #includes, except for two that were added by
hand in the first patch. The first patch also removed an extra define
of N2A03_DEFAULTCLOCK that would have caused problems with the second
patch.
~aa
Sent: Thursday, December 11, 2008 6:52 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] deprecat.h cpu cleanup
Hi mamedev,
This patch purges the last few uses of deprecat.h from the cpu cores,
plus a handful of other Machine cases elsewhere that were found by
script inspection.
~aa
--
Hi mamedev,
This patch eliminates most uses of deprecat.h in the sound cores by
attaching the device to the state object and using it where
appropriate. Given that all the cpu objects use this convention, and
three sound cores already do this, this seemed an appropriate
approach.
~aa
from the CPU cores.
Disabled the use of PULSE_LINE for any input lines except NMI and RESET.
Added a helper function generic_pulse_irq_line() for doing a single-cycle
assert/deassert for those few drivers remaining that were trying to use
PULSE_LINE directly.
Sent: Saturday, December 06, 2008 4:52 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Deprecat.h cleanup
Hi mamedev,
This patch changes some global Machine references to use machine,
device->machine, ... instead, and removes any unneeded #include
"deprecat.h" lines as well (about 10% of them in fact). It was
generated using the attached script, and then reverting some cases
where it was overzealous.
~aa