Commit Graph

185 Commits

Author SHA1 Message Date
Aaron Giles
1a2c20441f Remove some aliases between CPUINFO_ and DEVINFO_ to help clarify
usage.

Also converted a few more places to use the new accessors.
2010-01-21 06:05:57 +00:00
Aaron Giles
e738b79785 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.
2010-01-18 09:34:43 +00:00
Aaron Giles
470f843262 Within src/emu, basic conversions:
devtag_get_device ... machine->device()
  memory_find_address_space ... device->space()
2010-01-12 06:54:57 +00:00
Aaron Giles
4498faacd9 First round of an attempted cleanup of header files in the system.
- 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!)
2010-01-10 00:29:26 +00:00
Aaron Giles
bd24fb23c1 Results of running the latest srcclean. 2009-12-28 09:04:00 +00:00
Aaron Giles
30d57e3f48 Minor drc improvments:
- 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
2009-12-20 15:21:26 +00:00
Aaron Giles
c3fb047204 Added new profiler bucket for DRC recompilation.
Removed a number of extraneous sign extensions from the RSP DRC.
2009-12-19 08:50:34 +00:00
Aaron Giles
fd34a32091 Added new functions:
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.
2009-12-07 08:32:02 +00:00
Aaron Giles
ee315fe99d Renamed functions:
memory_install_read/write_port_handler -> 
        memory_install_read/write_port

   memory_install_read/write_bank_handler -> 
        memory_install_read/write_bank
2009-12-05 07:59:31 +00:00
Aaron Giles
9eda9e163e More memory system cleanup. Removed SMH_* macros entirely. In
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.
2009-12-05 07:54:11 +00:00
Aaron Giles
0069237f20 Memory banks are now referenced by tag rather than index.
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.
2009-12-03 08:16:38 +00:00
Aaron Giles
f0cdba5b11 Cleanups and version bump. 2009-11-20 06:50:40 +00:00
Aaron Giles
ad062c9e43 Fix TLBMOD exceptions so they also properly set BadVAddr. 2009-11-18 15:46:52 +00:00
Aaron Giles
693024974e Fix assertion in DRC. 2009-11-18 06:12:50 +00:00
Aaron Giles
ccefa6749d MIPS3 TLB fixes:
- 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
2009-11-17 06:09:38 +00:00
Aaron Giles
19bf1b46ea MIPS3 TLB fixes:
- 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
2009-11-16 06:45:54 +00:00
Ryan Holtz
2a9387c49d Reverting bad fix 2009-11-16 02:45:46 +00:00
Ryan Holtz
4cef27ecc9 - Fixed Context usage and TLB exception vectors in the MIPS core [Harmony] 2009-11-16 00:04:37 +00:00
Aaron Giles
357e36fc84 Eliminated osd_cpu.h.
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.
2009-10-12 08:37:04 +00:00
Aaron Giles
fa68c11272 > From: Atari Ace [mailto:atari_ace@verizon.net]
> 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
2009-09-10 08:35:37 +00:00
Ryan Holtz
f09c9059f9 Added a compile-time flag to select between ABI and Manual register names in the MIPS core. [Harmony]
Fixed a MESS-side compile warning in the SNES S-DD1 code. [Harmony]
2009-09-04 11:40:49 +00:00
Ryan Holtz
b54790792a Fixed numerous opcodes in the AVR8 core [Harmony]
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
2009-09-03 23:53:43 +00:00
Aaron Giles
f474114e1d Added infrastructure to compile universal standalone disassembler:
- 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.
2009-08-22 06:25:07 +00:00
Aaron Giles
2577a0b22d Another step. Moved the address-space related get_info constants
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.
2009-07-08 16:20:01 +00:00
Aaron Giles
ad4910a8a8 Bulk change alert.
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.
2009-04-26 23:54:37 +00:00
Aaron Giles
c0e9a1a10c Fix MT 3065/3069 2009-04-11 16:36:21 +00:00
Wilbert Pol
a35ef58b54 CPU cores are now enabled on a per cpu core family basis instead of per cpu core variant. As a result CPUDEFS is no longer needed in the makefile. 2009-03-25 19:39:41 +00:00
Aaron Giles
3b302a8bae Cleanups and version bump. 2009-03-19 07:28:58 +00:00
R. Belmont
5c8f9fb570 MIPS III: Update RA before executing the delay slot. 2009-03-19 02:34:15 +00:00
Aaron Giles
46494694d1 CPU cores now compile cleanly. 2009-03-15 17:12:40 +00:00
R. Belmont
e2df23829c Add specific support for NEC VR4300/4310 CPUs
The 4300 was used on the N64 and Aleck64, and the 4310 on the IT Eagle boards.  COP0 is slightly non-standard on these chips.
2009-03-14 14:44:22 +00:00
Aaron Giles
eb539cce9d Many casts added to the core files, and various other tweaks
to make them compile as either C or C++.
2009-03-12 07:43:03 +00:00
smf-
8e2173e06e fixed disassembly of -$8000, it was showing up as -$0 2009-03-08 09:19:49 +00:00
Aaron Giles
75f0ff10d1 Added function calls to replace the MIPS3 DRC's various CPU_SET_INFO
bits.

Fixed DCS2 speedup handler so it doesn't get lost during a memory
remap.
2009-03-07 08:54:03 +00:00
R. Belmont
1c5a8cb1bf Improve disassembly of R3000 code that uses the TLB or FPU 2009-02-02 00:48:36 +00:00
Aaron Giles
aad099ad00 DRC frontends must do their own opcode fetching unfortunately. Updated all
DRC cores to do this. Also tweaked a few oddities in the SH2 DRC.
2009-01-18 00:39:40 +00:00
Aaron Giles
eb8366c740 Added new #define ENDIANNESS_NATIVE, which maps to either ENDIANNESS_LITTLE
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.
2009-01-17 23:03:17 +00:00
smf-
e819aa7556 changed divide to throw out negative numerators. 2008-12-28 22:37:26 +00:00
smf-
d0a5273861 Implemented GTE divider using reciprocal table derived by pSXAuthor, this should allow the results to be calculated as inaccurately as the real hardware. 2008-12-28 14:56:15 +00:00
Aaron Giles
a70fdf00a1 CPU interface organization shuffle. The file cpuintrf.h now merely
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).
2008-12-22 17:35:27 +00:00
Aaron Giles
9be5d30f20 More cleanup. Added address-space-specific constants for the various
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.
2008-12-20 02:57:13 +00:00
Aaron Giles
320097d9fe Renamed CPUINFO_PTR_* to CPUINFO_FCT_* for function get infos.
Changed Z80 over to the new cpu_state_table mechanism.
2008-12-19 22:26:25 +00:00
Aaron Giles
72b283a0d1 Removed index and clock parameters from CPU_INIT function. 2008-12-18 10:11:10 +00:00
Aaron Giles
cf9fc58618 Made the concept of a "clock" native to devices. The clock is now
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).
2008-12-18 08:28:50 +00:00
Aaron Giles
e2ae5c7fa3 From: Atari Ace [atari_ace@verizon.net]
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
2008-12-17 05:52:10 +00:00
Aaron Giles
b400e7978b From: Atari Ace [mailto:atari_ace@verizon.net]
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
2008-12-12 06:11:15 +00:00
Aaron Giles
04ae2d8bc7 Removed get context/set context calls from the CPU interface entirely.
Pointer-ified the TMS99xx core (missed that one!)
2008-12-11 10:21:52 +00:00
Aaron Giles
eb43d34725 Re-routed empty get/set context calls to the dummy CPU's, and removed them
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.
2008-12-09 06:21:15 +00:00
Aaron Giles
872ec20658 From: Atari Ace [mailto:atari_ace@verizon.net]
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
2008-12-07 14:51:36 +00:00
Aaron Giles
554f86eb65 Pointer-ified the mips3drc. 2008-12-06 19:55:22 +00:00