Commit Graph

50 Commits

Author SHA1 Message Date
Miodrag Milanovic
ed9afac60c Clean-ups and version bump 2012-07-15 09:28:52 +00:00
Miodrag Milanovic
4f44afd034 Sync with MESS (no whatsnew) 2012-07-14 19:05:18 +00:00
Angelo Salese
58a33d8b36 Various changes to i386 CPU core and Chihiro emulation, allowing it to show a basic logo and text [Samuele Zannoli] 2012-07-05 08:34:53 +00:00
mahlemiut
372e7ee034 i386: another small vm86 fix [Carl] 2012-05-20 00:03:14 +00:00
mahlemiut
39fb790b3f i386: IRET/Virtual 8086 mode fixes [Carl] 2012-05-17 23:14:49 +00:00
mahlemiut
605a48921b i386: Big pmode update. [Carl] 2012-05-03 05:58:32 +00:00
Aaron Giles
53aca4fb0c Renamed device_irq_callback to device_irq_acknowledge_callback to
make its purpose clearer.

Added delegate support for interrupt callbacks, and made driver_device
variants of the generic interrupt helper callbacks. Did not convert
existing callers yet due to logistical issues.
2012-04-10 20:13:30 +00:00
mahlemiut
168f4a8920 i386: remove one too many ampersands. (no whatsnew) 2012-03-10 10:49:43 +00:00
mahlemiut
ff2e20a96b i386: Trap flag support [Carl] 2012-02-08 21:26:25 +00:00
Miodrag Milanovic
fdca6f887c Fix for protection mode faults, makes 586 based things to work again by Carl (no whatsnew) 2012-02-02 14:58:18 +00:00
Angelo Salese
505442d0a0 Clean-ups and version bump 2012-01-29 16:34:26 +00:00
mahlemiut
436a0164ac i386: Major update to segment limit and protection checking. [Carl] 2012-01-29 09:40:48 +00:00
Phil Bennett
ab2640c4f7 Rewrote i386 x87 emulation: [Phil Bennett]
* Use SoftFloat arithmetic functions
 * Implemented tag word updates
 * Implemented status word/exception flag updates
 * Implemented stack underflow/overflow behaviour
2012-01-26 23:20:52 +00:00
mahlemiut
f0553bafb5 i386: More page fault work. [Carl] 2012-01-22 22:49:12 +00:00
mahlemiut
d458480a07 i386: BTR and page fault fixes from Carl, and basic implementation of FIST and FBLD FPU instructions. 2012-01-18 22:54:36 +00:00
Angelo Salese
7b631e4c5b Clean-ups and version bump 2012-01-15 21:40:54 +00:00
mahlemiut
61cb12528c i386: Added I/O permissions. [Carl] 2012-01-14 22:35:57 +00:00
mahlemiut
ec72bf4995 Beginning to implement page faults [Carl] 2012-01-14 06:36:45 +00:00
mahlemiut
814eebb930 i386: various fixes to 486 and Pentium eflags from MESS, and Carl's small
IRQ fix. (no whatsnew)
2012-01-13 06:37:18 +00:00
mahlemiut
5f6f7b8267 i386: Bit more progress towards getting 386 enhanced mode Windows running. [Carl] 2012-01-12 06:20:33 +00:00
mahlemiut
9f1c1efe74 i386: Fixed high bits in eflags register from being changed by POPF, and
VM and IF flags from changing depending on privilege level.
      Fixed exception error codes in protected mode.
      Further work on virtual 8086 mode.  EMM386 will now load, but will 
      still die a few seconds later.
2012-01-11 08:50:03 +00:00
mahlemiut
44ee92ea77 i386: Made a start at Virtual 8086 Mode. Not fully working yet, though.
Fixed an issue where two address or operand size prefixes would cancel
      each other out.
2012-01-09 08:10:14 +00:00
Angelo Salese
e869f846ad Implemented generic functions for RDMSR and WRMSR opcodes in Pentium CPU core (i.e. no MSR is actually hooked up so far) [Angelo Salese] 2011-12-31 16:19:04 +00:00
Miodrag Milanovic
9babf1fcf4 i386: Various fixes. [Barry Rodewald]
- Load LDT before segment registers when switching tasks,
  - Set IF after the instruction following STI,
  - Reset IF after MOV SS or POP SS for one instruction,
  - Fixed LSL instruction when modrm < 0xc0.
2011-07-06 07:08:37 +00:00
Miodrag Milanovic
941c72c85a i386: Implemented task gates, call gates, and task state segments (both
286 and 386).  Also inplmented triple fault CPU resets (used by OS/2).
x87: Basic implementation of FSTENV (used by OS/2).  [Barry Rodewald]
2011-06-17 07:01:45 +00:00
Miodrag Milanovic
a1d618b9da Fixed issues with latest change by adding safety 16bit handling (no whatsnew) 2011-04-26 13:01:09 +00:00
Miodrag Milanovic
fbbbaa20ae Fixed i86/i386 POP SP and POP ESP thanks to bug report for Xenix boot by bs666 [Miodrag Milanovic] 2011-04-26 12:38:11 +00:00
Aaron Giles
9ef0bcf8f2 Cleanups and version bump. 2011-02-28 09:27:05 +00:00
Dirk Best
8c07036b0f i386: Changed READ/WRITEPORT macros to inline functions to properly support aligned vs. unaligned writes. Fixes regressions in MESS for all drivers using the PCI bus and possibly others. [Dirk Best] 2011-02-13 16:28:43 +00:00
Aaron Giles
3b41606ca0 running_device -> device_t
They both already existed. No sense in having two names for the
same object type.
2010-12-31 21:42:55 +00:00
Angelo Salese
e1a32f54d8 Fixed unaligned 16 and 32-bit i/o accesses in i386 CPU core [Barry Rodewald] 2010-09-29 11:42:38 +00:00
Aaron Giles
621a2faa2a Remove final set of legacy inlines from memory.h. Mostly affects CPU
cores, which all now cache a copy of space->direct() and use it for
direct accesses.
2010-08-19 16:10:19 +00:00
Aaron Giles
0edda6dda2 Remove memory_read/write_byte/word/dword/qword* variants. Again, this is mostly
bulk search & replace:

S: memory_read_([bytewordq]+)_[0-9lbe_maskd]+( *)\(( *)([^,]+)( *),( *)
R: \4->read_\1\2\(\3

S: memory_read_([bytewordq]+)( *)\(( *)([^,]+)( *),( *)
R: \4->read_\1\2\(\3

S: memory_write_([bytewordq]+)_[0-9lbe_maskd]+( *)\(( *)([^,]+)( *),( *)
R: \4->write_\1\2\(\3

S: memory_write_([bytewordq]+)( *)\(( *)([^,]+)( *),( *)
R: \4->write_\1\2\(\3

Gets 99% of the cases.
2010-08-19 08:27:05 +00:00
Aaron Giles
3598b772bc Replace "const address_space" with "address_space" throughout the system.
The purpose of making it const before was to discourage direct tampering,
but private/protected does a better job of that now anyhow, and it is
annoying now.

    s/const[ \t]+address_space\b/address_space/g;

Is basically what I did.
2010-08-19 07:26:14 +00:00
Aaron Giles
c70c5fee5a Created CPU-specific device types for all CPUs, using new macros
DECLARE_LEGACY_CPU_DEVICE and DEFINE_LEGACY_CPU_DEVICE. Changed CPUs
to be their own device types, rather than all of type CPU with a
special internal subtype. Note that as part of this process I removed
the CPU_ prefix from the ALL-CAPS device name, so CPU_Z80 is just
plain old Z80 now. This required changing a couple of names like
8080 to I8080 so that there was an alphabetic first character.

Added memory interfaces to the list of fast-access interfaces. To do
this properly I had to add a separate method to devices which is
called immediately after construction, when it is possible to perform
dynamic_casts on fully-constructed objects. (This is just internal,
no changes necessary to the devices themselves.)

Some additional notes:
 * SH2 and SH4 had typedefs that conflicted with their CPU_-less names
    so I bulk renamed to structures to sh2_state and sh4_state; RB, feel
    free to choose alternate names if you don't like 'em
 * SCSP was caught doing something to the 3rd indexed CPU. Since several
    systems that use SCSP don't even have 3 CPUs, I had no idea what
    this was supposed to do, so I changed to it reference "audiocpu"
    assuming that stv was the assumed target. This is really gross and
    should be a configuration parameter, not a hard-coded assumption.
2010-07-03 00:12:44 +00:00
Aaron Giles
b8f916e17e Change cpu_device into a base class. Rename old cpu_device to legacy_cpu_device.
Update interfaces as appropriate.
2010-06-17 03:33:24 +00:00
Aaron Giles
5e04468569 Changed CPU callbacks to use cpu_device, eliminating a bunch of casting. 2010-06-08 17:35:49 +00:00
Aaron Giles
100564d412 WARNING: There are likely to be regressions in both functionality and
performance as a result of this change. Do not panic; report issues to the
list in the short term and I will look into them. There are probably also
some details I forgot to mention. Please ask questions if anything is not
clear.

NOTE: This is a major internal change to the way devices are handled in
MAME. There is a small impact on drivers, but the bulk of the changes are
to the devices themselves. Full documentation on the new device handling
is in progress at http://mamedev.org/devwiki/index.php/MAME_Device_Basics

Defined two new casting helpers: [Aaron Giles]

  downcast<type>(value) should be used for safe and efficient downcasting
  from a base class to a derived class. It wraps static_cast<> by adding
  an assert that a matching dynamic_cast<> returns the same result in 
  debug builds.
  
  crosscast<type>(value) should be used for safe casting from one type to
  another in multiple inheritance scenarios. It compiles to a 
  dynamic_cast<> plus an assert on the result. Since it does not optimize
  down to static_cast<>, you should prefer downcast<> over crosscast<>
  when you can.
  
Redefined running_device to be a proper C++ class (now called device_t).
Same for device_config (still called device_config). All devices and
device_configs must now be derived from these base classes. This means
each device type now has a pair of its own unique classes that describe
the device. Drivers are encouraged to use the specific device types
instead of the generic running_device or device_t classes. Drivers that
have a state class defined in their header file are encouraged to use
initializers off the constructor to locate devices. [Aaron Giles]

Removed the following fields from the device and device configuration
classes as they never were necessary or provided any use: device class,
device family, source file, version, credits. [Aaron Giles]

Added templatized variant of machine->device() which performs a downcast
as part of the device fetch. Thus machine->device<timer_device>("timer")
will locate a device named "timer", downcast it to a timer_device, and
assert if the downcast fails. [Aaron Giles]

Removed most publically accessible members of running_device/device_t in
favor of inline accessor functions. The only remaining public member is
machine. Thus all references to device->type are now device->type(), etc.
[Aaron Giles]

Created a number of device interface classes which are designed to be mix-
ins for the device classes, providing specific extended functionality and
information. There are standard interface classes for sound, execution,
state, nvram, memory, and disassembly. Devices can opt into 0 or more of
these classes. [Aaron Giles]

Converted the classic CPU device to a standard device that uses the
execution, state, memory, and disassembly interfaces. Used this new class
(cpu_device) to implement the existing CPU device interface. In the future
it will be possible to convert each CPU core to its own device type, but 
for now they are still all CPU devices with a cpu_type() that specifies
exactly which kind of CPU. [Aaron Giles] 

Created a new header devlegcy.h which wraps the old device interface using
some special template classes. To use these with an existing device,
simply remove from the device header the DEVICE_GET_INFO() declaration and
the #define mapping the ALL_CAPS name to the DEVICE_GET_INFO. In their
place #include "devlegcy.h" and use the DECLARE_LEGACY_DEVICE() macro.
In addition, there is a DECLARE_LEGACY_SOUND_DEVICE() macro for wrapping
existing sound devices into new-style devices, and a 
DECLARE_LEGACY_NVRAM_DEVICE() for wrapping NVRAM devices. Also moved the
token and inline_config members to the legacy device class, as these are
not used in modern devices. [Aaron Giles]

Converted the standard base devices (VIDEO_SCREEN, SPEAKER, and TIMER) 
from legacy devices to the new C++ style. Also renamed VIDEO_SCREEN to
simply SCREEN. The various global functions that were previously used to
access information or modify the state of these devices are now replaced
by methods on the device classes. Specifically:

  video_screen_configure()             == screen->configure()
  video_screen_set_visarea()           == screen->set_visible_area()
  video_screen_update_partial()        == screen->update_partial()
  video_screen_update_now()            == screen->update_now()
  video_screen_get_vpos()              == screen->vpos()
  video_screen_get_hpos()              == screen->hpos()
  video_screen_get_vblank()            == screen->vblank()
  video_screen_get_hblank()            == screen->hblank()
  video_screen_get_width()             == screen->width()
  video_screen_get_height()            == screen->height()
  video_screen_get_visible_area()      == screen->visible_area()
  video_screen_get_time_until_pos()    == screen->time_until_pos()
  video_screen_get_time_until_vblank_start() == 
                                 screen->time_until_vblank_start()
  video_screen_get_time_until_vblank_end() == 
                                 screen->time_until_vblank_end()
  video_screen_get_time_until_update() == screen->time_until_update()
  video_screen_get_scan_period()       == screen->scan_period()
  video_screen_get_frame_period()      == screen->frame_period()
  video_screen_get_frame_number()      == screen->frame_number()

  timer_device_adjust_oneshot()        == timer->adjust()
  timer_device_adjust_periodic()       == timer->adjust()
  timer_device_reset()                 == timer->reset()
  timer_device_enable()                == timer->enable()
  timer_device_enabled()               == timer->enabled()
  timer_device_get_param()             == timer->param()
  timer_device_set_param()             == timer->set_param()
  timer_device_get_ptr()               == timer->get_ptr()
  timer_device_set_ptr()               == timer->set_ptr()
  timer_device_timeelapsed()           == timer->time_elapsed()
  timer_device_timeleft()              == timer->time_left()
  timer_device_starttime()             == timer->start_time()
  timer_device_firetime()              == timer->fire_time()

Updated all drivers that use the above functions to fetch the specific
device type (timer_device or screen_device) and call the appropriate
method. [Aaron Giles]

Changed machine->primary_screen and the 'screen' parameter to VIDEO_UPDATE
to specifically pass in a screen_device object. [Aaron Giles]

Defined a new custom interface for the Z80 daisy chain. This interface
behaves like the standard interfaces, and can be added to any device that
implements the Z80 daisy chain behavior. Converted all existing Z80 daisy
chain devices to new-style devices that inherit this interface.
[Aaron Giles]

Changed the way CPU state tables are built up. Previously, these were data
structures defined by a CPU core which described all the registers and how
to output them. This functionality is now part of the state interface and
is implemented via the device_state_entry class. Updated all CPU cores
which were using the old data structure to use the new form. The syntax is
currently awkward, but will be cleaner for CPUs that are native new 
devices. [Aaron Giles]

Converted the okim6295 and eeprom devices to the new model. These were
necessary because they both require multiple interfaces to operate and it
didn't make sense to create legacy device templates for these single cases.
(okim6295 needs the sound interface and the memory interface, while eeprom
requires both the nvram and memory interfaces). [Aaron Giles]

Changed parameters in a few callback functions from pointers to references
in situations where they are guaranteed to never be NULL. [Aaron Giles]

Removed MDRV_CPU_FLAGS() which was only used for disabling a CPU. Changed
it to MDRV_DEVICE_DISABLE() instead. Updated drivers. [Aaron Giles]

Reorganized the token parsing for machine configurations. The core parsing
code knows how to create/replace/remove devices, but all device token
parsing is now handled in the device_config class, which in turn will make
use of any interface classes or device-specific token handling for custom
token processing. [Aaron Giles]

Moved many validity checks out of validity.c and into the device interface
classes. For example, address space validation is now part of the memory
interface class. [Aaron Giles]

Consolidated address space parameters (bus width, endianness, etc.) into
a single address_space_config class. Updated all code that queried for
address space parameters to use the new mechanism. [Aaron Giles]
2010-06-08 06:09:57 +00:00
Phil Bennett
3354dc342b i386+ core updates: [Samuele Zannoli]
* Added CR4 register
 * Added bswap instruction
 * Added support for 4MB pages
2010-03-31 21:25:15 +00:00
Aaron Giles
a91446eaca Cleanups and version bump. 2010-03-25 13:18:38 +00:00
Fabio Priuli
585c85dbae i386: fixed unaligned memory accesses and opcode fetches
when they cross a page boundary. Previously, if pages
were not ordered in contiguous RAM, then a cross-boundary 
read or write would read partially incorrect data or write 
some of the data in the wrong page. [Barry Rodewald]
2010-03-17 09:56:42 +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
Dirk Best
3997330a94 i386: Improved accuracy of the various emulated models, makes CPU detection programs detect the correct CPU (in MESS).
- eflags mask added
- Initial values for the EAX and EDX registers fixed
- cpuid values improved
- feature flags improved
- initial value for the cr0 register improved
- changed 486 to not support the cpuid instruction by default
- take a trap on invalid instructions instead of throwing a fatalerror
- emulated the undefined flag behavior for the DIV/IDIV instructions on Intel CPUs
2010-01-15 18:54:23 +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
Phil Bennett
448de6a3e9 i386 core fixes: [Barry Rodewald]
* Added Nested Task flag, and I/O Privilege flags.  They aren't
  implemented in any way, but can now be set or reset.  Can be used to
  detect a 80386 or later CPU.
* Implemented ENTER instruction.
* Made IRQ vectors treated as 8 bytes when in protected mode, and made
  the addresses pushed onto the stack 32-bit if the gate descriptor used
  is a 386 interrupt or trap gate (also when in protected mode, will
  always be 16-bit if in real mode).


---------- Forwarded message ----------
From: Barry Rodewald <bsr@xnet.co.nz>
Date: Tue, Nov 3, 2009 at 10:12 PM
Subject: i386 update
To: submit@mamedev.org


Hi,

Here's a few small fixes for the i386 core, based from the work I've
been doing on emulating the FM Towns in MESS.  Mostly based from the
i386 Programmer's Reference Manual.

The fixes are as follows:

* Added Nested Task flag, and I/O Privilege flags.  They aren't
implemented in any way, but can now be set or reset.  Can be used to
detect a 80386 or later CPU.

* Implemented ENTER instruction, this is used by the FM Towns version of MS-DOS.

* Made IRQ vectors treated as 8 bytes when in protected mode, and made
the addresses pushed onto the stack 32-bit if the gate descriptor used
is a 386 interrupt or trap gate (also when in protected mode, will
always be 16-bit if in real mode).

I've tested a few i386 games (Seibu SPI, PC-AT, and Wolf System) in
MAME 0.135, with no obvious regressions.

Diff is based on MAME 0.135.

Thanks,
Barry Rodewald
mailto:bsr@xnet.co.nz
2009-11-05 13:17:33 +00:00
Aaron Giles
d8aa6627f5 > -----Original Message-----
> From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Sunday, September 20, 2009 9:54 AM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] Eliminate more #ifdef LSB_FIRST
> 
> Hi mamedev,
> 
> This patch recodes more cases where LSB_FIRST is used to conditionally
> compile separate code for LSB and MSB targets.  The atari.h chunk was
> dead code (both in MAME and MESS) so I simply removed it.
> 
> ~aa
2009-09-24 07:14:58 +00:00
Michaël Banaan Ananas
4bb09d5632 fixed i386 carry/borrow flag in ADC/SBB [Gabriele Gorla]
> -----Original Message-----
> From: Gabriele Gorla [mailto:gorlik@penguintown.net]
> Sent: Saturday, August 29, 2009 5:39 AM
> To: submit@mamedev.org
> Cc: Gabriele Gorla
> Subject: Re: i386: fix carry/borrow flag in ADC/SBB
>
> > the original code implements ADC and SBB as 2 consecutive ADDs.
> > This will not produce the correct result when the carry is generated
> by
> > the first addition as it is overwritten by the second operation.
>
> updated patch, fixes a typo.
2009-08-30 11:19:07 +00:00
Aaron Giles
46494694d1 CPU cores now compile cleanly. 2009-03-15 17:12:40 +00:00
Aaron Giles
aa7e2482e2 CPU header cleanups....
i86/i286/i386/nec/v30mz:
 * renamed i86.h -> i86priv.h
 * renamed i86intrf.h -> i86.h
 * consolidated i88intrf.h, i186intf.h, i188intf.h, etc into i86.h

m6805:
 * moved memory read/write macros out of public header

m37710:
 * moved memory read/write macros out of public header

spc700:
 * moved many structs/functions/macros out of public header

tms32010:
 * moved memory read/write macros out of public header

sm8500:
 * pointer-ified the core (apparently never had get/set context!)

g65816:
 * moved memory read/write macros out of public header

pic16c5x:
 * moved memory read/write macros out of public header

t11:
 * moved memory read/write macros out of public header
2008-12-18 09:38:12 +00:00