diff options
author | 2010-01-18 09:34:43 +0000 | |
---|---|---|
committer | 2010-01-18 09:34:43 +0000 | |
commit | e738b79785852050ce8b83e369a7fc4dd46a071b (patch) | |
tree | 1ac39e9f40790b375c57fea4e5d56ca8d132babc /src/emu/cpu/sharc/sharc.c | |
parent | 3f87f47a2ecdccb9d9627d0d52b76f262becb949 (diff) |
Correct a long-standing design flaw: device configuration state
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.
Diffstat (limited to 'src/emu/cpu/sharc/sharc.c')
-rw-r--r-- | src/emu/cpu/sharc/sharc.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/emu/cpu/sharc/sharc.c b/src/emu/cpu/sharc/sharc.c index e4a7790cb9a..b1610471bcb 100644 --- a/src/emu/cpu/sharc/sharc.c +++ b/src/emu/cpu/sharc/sharc.c @@ -125,7 +125,7 @@ struct _SHARC_REGS UINT16 *internal_ram_block0, *internal_ram_block1; cpu_irq_callback irq_callback; - const device_config *device; + running_device *device; const address_space *program; const address_space *data; void (*opcode_handler)(SHARC_REGS *cpustate); @@ -184,7 +184,7 @@ static void (* sharc_op[512])(SHARC_REGS *cpustate); ((UINT64)(cpustate->internal_ram[((pc-0x20000) * 3) + 1]) << 16) | \ ((UINT64)(cpustate->internal_ram[((pc-0x20000) * 3) + 2]) << 0) -INLINE SHARC_REGS *get_safe_token(const device_config *device) +INLINE SHARC_REGS *get_safe_token(running_device *device) { assert(device != NULL); assert(device->token != NULL); @@ -371,7 +371,7 @@ static void build_opcode_table(void) /*****************************************************************************/ -void sharc_external_iop_write(const device_config *device, UINT32 address, UINT32 data) +void sharc_external_iop_write(running_device *device, UINT32 address, UINT32 data) { SHARC_REGS *cpustate = get_safe_token(device); if (address == 0x1c) @@ -388,7 +388,7 @@ void sharc_external_iop_write(const device_config *device, UINT32 address, UINT3 } } -void sharc_external_dma_write(const device_config *device, UINT32 address, UINT64 data) +void sharc_external_dma_write(running_device *device, UINT32 address, UINT64 data) { SHARC_REGS *cpustate = get_safe_token(device); switch ((cpustate->dma[6].control >> 6) & 0x3) @@ -420,7 +420,7 @@ void sharc_external_dma_write(const device_config *device, UINT32 address, UINT6 static CPU_INIT( sharc ) { SHARC_REGS *cpustate = get_safe_token(device); - const sharc_config *cfg = (const sharc_config *)device->static_config; + const sharc_config *cfg = (const sharc_config *)device->baseconfig().static_config; int saveindex; cpustate->boot_mode = cfg->boot_mode; @@ -608,7 +608,7 @@ static void sharc_set_irq_line(SHARC_REGS *cpustate, int irqline, int state) } } -void sharc_set_flag_input(const device_config *device, int flag_num, int state) +void sharc_set_flag_input(running_device *device, int flag_num, int state) { SHARC_REGS *cpustate = get_safe_token(device); if (flag_num >= 0 && flag_num < 4) |