Commit Graph

549 Commits

Author SHA1 Message Date
Bryce Denney
9b14101a05 - rewrite typecast of temp to Bit64u to keep VC++ happy. I don't really
know what it thought was wrong.
2002-11-19 05:53:47 +00:00
Bryce Denney
dcc6d6038a - we forgot to initialize trace_reg and kill_bochs_request to 0. 2002-11-19 05:52:52 +00:00
Bryce Denney
97f911d1fe - when VC++ sees local variables in a for statement, it doesn't think
that they go out of scope at the end, so it complains about duplicate
  definitions.
2002-11-19 05:51:52 +00:00
Bryce Denney
0a7cb3a43c - apply patch.ifdef-disabled-options. Comments from that patch are below:
For a whole lot of configure options, I put #if...#endif around code that
  is specific to the option, even in files which are normally only compiled
  when the option is on.  This allows me to create a MS Visual C++ 6.0
  workspace that supports many of these options.  The workspace will basically
  compile every file all the time, but the code for disabled options will
  be commented out by the #if...#endif.

  This may one day lead to simplification of the Makefiles and configure
  scripts, but for the moment I'm leaving Makefiles and configure scripts
  alone.

  Affected options:
    BX_SUPPORT_APIC (cpu/apic.cc)
    BX_SUPPORT_X86_64 (cpu/*64.cc)
    BX_DEBUGGER (debug/*)
    BX_DISASM (disasm/*)
    BX_WITH_nameofgui (gui/*)
    BX_SUPPORT_CDROM (iodev/cdrom.cc)
    BX_NE2K_SUPPORT (iodev/eth*.cc, iodev/ne2k.cc)
    BX_SUPPORT_APIC (iodev/ioapic.cc)
    BX_IODEBUG_SUPPORT (iodev/iodebug.cc)
    BX_PCI_SUPPORT (iodev/pci*.cc)
    BX_SUPPORT_SB16 (iodev/sb*.cc)

Modified Files:
  cpu/apic.cc cpu/arith64.cc cpu/ctrl_xfer64.cc
  cpu/data_xfer64.cc cpu/fetchdecode64.cc cpu/logical64.cc
  cpu/mult64.cc cpu/resolve64.cc cpu/shift64.cc cpu/stack64.cc
  debug/Makefile.in debug/crc.cc debug/dbg_main.cc debug/lexer.l
  debug/linux.cc debug/parser.c debug/parser.y
  disasm/dis_decode.cc disasm/dis_groups.cc gui/amigaos.cc
  gui/beos.cc gui/carbon.cc gui/macintosh.cc gui/rfb.cc
  gui/sdl.cc gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc
  gui/wxmain.cc gui/x.cc iodev/cdrom.cc iodev/eth.cc
  iodev/eth_arpback.cc iodev/eth_fbsd.cc iodev/eth_linux.cc
  iodev/eth_null.cc iodev/eth_packetmaker.cc iodev/eth_tap.cc
  iodev/eth_tuntap.cc iodev/eth_win32.cc iodev/ioapic.cc
  iodev/iodebug.cc iodev/ne2k.cc iodev/pci.cc iodev/pci2isa.cc
  iodev/sb16.cc iodev/soundlnx.cc iodev/soundwin.cc
2002-11-19 05:47:45 +00:00
Bryce Denney
add9107dae - add BOCHSAPI to bxICache_c 2002-11-15 18:12:04 +00:00
Stanislav Shwartsman
3217759a75 Implemented
PSHUFLW_VqWqIb, PSHUFHW_VqWqIb instructions
2002-11-15 17:34:47 +00:00
Stanislav Shwartsman
da8a2a71b1 Fixed bug PSHUFW instruction 2002-11-15 17:02:06 +00:00
Stanislav Shwartsman
62e362afc2 just typo 2002-11-15 15:55:36 +00:00
Stanislav Shwartsman
34dd74fe6c Fixed BUG in PMADDWD instruction 2002-11-15 15:51:12 +00:00
Stanislav Shwartsman
189f64b533 SSE2 shifts uses as count only low 64 bits of XMM register/mem128 2002-11-15 14:48:24 +00:00
Stanislav Shwartsman
d4426dc60b More bugfix in SSE 2002-11-15 14:33:44 +00:00
Stanislav Shwartsman
88ce9917e6 Replace BX_PANIC to BX_INFO for FXSAVE/FXRSTOR instruction
because their is required for booting Windows with SSE enabled.
2002-11-15 13:10:06 +00:00
Stanislav Shwartsman
121de7d960 Fixed bug with decoding of Group15 2002-11-15 13:05:19 +00:00
Stanislav Shwartsman
ccbc8e0ef7 MOVAPS/MOVAPD have a different exceptions 2002-11-15 12:44:39 +00:00
Stanislav Shwartsman
65b8712d04 More tuning of SSE 2002-11-14 19:59:29 +00:00
Stanislav Shwartsman
7ccf1de78f According to the Intel (and AMD) manuals a lot different SSE/SSE2 opcodes has EXACTLY the same operation.
Deleted first three redundant opcodes (move integer data):
   MOVLPS_VpsMq   (0f 12) = MOVLPD_VsdMq   (66 0f 12)
   MOVLPS_MqVps   (0f 13) = MOVLPD_MqVsd   (66 0f 13)
   MOVHPS_VpsMq   (0f 16) = MOVHPD_VpdMq   (66 0f 16)
   MOVHPS_MqVps   (0f 17) = MOVHPD_MqVpd   (66 0f 17)

Until under examination:
XORPS,XORPD
ORPS,ORPD
ANDPS,ANDPD
ANDNPS,ANDNPD
MOVUPS,MOVUPD
2002-11-13 22:24:03 +00:00
Stanislav Shwartsman
968b2744f4 According to the Intel (and AMD) manuals a lot different SSE/SSE2 opcodes
has EXACTLY the same operation.

Deleted first three redundant opcodes:
   MOVAPS_VpsWps  (0f 28) = MOVAPD_VpdWpd  (66 0f 28)
   MOVAPS_WpsVps  (0f 29) = MOVAPD_WpdVpd  (66 0f 29)
   MOVNTPS_MdqVps (0f 2b) = MOVNTPD_MdqVpd (66 0f 2b)

Until checking:
XORPS,XORPD
ORPS,ORPD
ANDPS,ANDPD
ANDNPS,ANDNPD
MOVUPS,MOVUPD
MOVLPS,MOVLPD
MOVHPS,MOVHPD
2002-11-13 21:35:17 +00:00
Stanislav Shwartsman
5803e20240 Changed policy of SSE/SSE2 checking 2002-11-13 21:00:05 +00:00
Stanislav Shwartsman
6c6519a73d Implemented SSE2 integer instructions:
PMULHW_VdqWdq
PMULHUW_VdqWdq
PMULLW_VdqWdq
MOVNTI_MdGd

Somedoby that is the difference between MOVNTPD, MOVNTPS, MPVNTDQ instructions ?
2002-11-09 19:22:00 +00:00
Stanislav Shwartsman
bc0463f08a Implemented
PSRLDQ_WdqIb
PSLLDQ_WdqIb
instructions
2002-11-08 21:09:17 +00:00
Stanislav Shwartsman
790430bf22 #UD exception condition for SSE instructions fixed 2002-11-08 20:27:42 +00:00
Stanislav Shwartsman
3cd6f7282d Alloc setting OFXCSR (bit9) of CR4 in SSE/SSE2 enabled 2002-11-08 20:26:12 +00:00
Stanislav Shwartsman
a814c00278 MOVD_EdVd: bugfix 2002-11-08 17:50:20 +00:00
Stanislav Shwartsman
0df9c9af85 Implemented integer SSE2 instructions:
PSRLW_PdqIb
PSRLD_PdqIb
PSRLQ_PdqIb
PSLLW_PdqIb
PSLLD_PdqIb
PSLLQ_PdqIb
PSRAW_PdqIb
PSRAD_PdqIb
PSRLW_VdqWdq
PSRLD_VdqWdq
PSRLQ_VdqWdq
PSRAW_PdqWdq
PSRAD_PdqWdq
PSLLW_VdqWdq
PSLLD_VdqWdq
PSLLQ_VdqWdq
PMOVMSKB_GdVRdq
PMULUDQ_VdqWdq
PMINUB_VdqWdq
PMINSW_VdqWdq
PMAXUB_VdqWdq
PMAXSW_VdqWdq

Fixed bug in the PMINUB_PqQq and PMAXUB_PqQq SSE instructions
2002-11-08 17:47:46 +00:00
Stanislav Shwartsman
c98b30af0c Changed BX_INFO to BX_PANIC for still not implemented SSE2 instruction
I just forgot to change the BX_INFO before ...
2002-11-08 14:35:03 +00:00
Stanislav Shwartsman
2f214c34ed Fixed compilation problem ... 2002-11-08 14:26:04 +00:00
Stanislav Shwartsman
1ec420be74 Implemented SSE2 integer instructions:
PADDUSB_VdqWdq
PADDUSW_VdqWdq
PSUBSB_VdqWdq
PSUBSW_VdqWdq
PADDSB_VdqWdq
PADDSW_VdqWdq
PSADBW_VdqWdq
PUNPCKLBW_VdqWq
PUNPCKLWD_VdqWq
PUNPCKLDQ_VdqWq
PUNPCKLQDQ_VdqWq
MOVDQA_VdqWdq
2002-11-08 14:23:34 +00:00
Stanislav Shwartsman
4363745725 Implemented SSE2 integer instructions:
PACKSSDW_VdqWdq
PUNPCKHDQ_VdqWq
PUNPCKHWD_VdqWq
PUNPCKHBW_VdqWq
PUNPCKHQDQ_VdqWq
MOVD_EdVd
MOVD_VdqEd
2002-11-08 12:47:24 +00:00
Stanislav Shwartsman
b200ff2058 Implemented several integer SSE2 instructions (similar to the MMX):
PACKSSWB_VdqWq
PCMPGTB_VdqWq
PCMPGTW_VdqWq
PCMPGTD_VdqWdq
PACKUSWB_VdqWdq
PCMPEQB_VdqWdq
PCMPEQW_VdqWdq
PCMPEQD_VdqWdq
PADDQ_VdqWdq
PSUBUSB_VdqWdq
PSUBUSW_VdqWdq
PAND_VdqWdq
PANDN_VdqWdq
PAVGB_VdqWdq
PAVGW_VdqWdq
POR_VdqWdq
PXOR_VdqWdq
PSUBB_VdqWdq
PSUBW_VdqWdq
PSUBD_VdqWdq
PSUBQ_VdqWdq
PADDB_VdqWdq
PADDW_VdqWdq
PADDD_VdqWdq
PADDQ_VdqWdq
2002-11-07 22:41:34 +00:00
Jonathan S. Shapiro
eb21a1ef5c Kevin looked at the push_64() change and thinks its reasonable, so I'm
switching the BX_PANIC to a BX_INFO.
2002-11-07 15:42:14 +00:00
Jonathan S. Shapiro
0aac231adb Changed push_32() and push_64() to issue SS(0) for a push outside of
stack limits. This is needed for EROS, and probably for L4, as both
rely on this SS fault (and the corresponding GP fault) to trigger the
switch from small address spaces to large address spaces. The
push_16() code was already correct, and I find the inconsistency a bit
odd.

I'm not 100% sure about the push_64() change, so I made the change
with a comment but left it a BX_PANIC() rather than switching it to
BX_INFO. I'll ask Peter momentarily to have a look and let me know.

While I was added, changed the push_16() BX_INFO message to be
consistent with the others -- all now say 'push outside stack limits'.
2002-11-07 14:02:47 +00:00
Peter Tattam
4addb73d99 External debugger patches.
Formatting problem in printf()
2002-11-04 05:38:12 +00:00
Peter Tattam
1bb5040031 Miscellaneous patches for Tattam's External Debugger.
- Now compiles for plain ia-32
- Fixed some printf formatting for ia32 only.
- Update to latest Win32 DLL
- Added an ICEBP (Undoc 0xF8, INT 01) facility.
- updated to use latest VGA refresh routine
2002-11-04 05:27:26 +00:00
Stanislav Shwartsman
0e60aa8232 We will need integer saturation functions also in SSE2 instructions 2002-11-02 12:35:33 +00:00
Stanislav Shwartsman
22d292d83f Detalized XMM register definition for BIG/LITTLE endian systems 2002-11-02 12:09:27 +00:00
Bryce Denney
a6aa9afd67 - rename "control" to "textconfig". It was named when we called it
a control panel, but now we're calling it a text configuration interface.

Modified:
    .bochsrc Makefile.in bochs.h main.cc cpu/Makefile.in
    debug/Makefile.in disasm/Makefile.in fpu/Makefile.in
    gui/Makefile.in iodev/Makefile.in memory/Makefile.in
2002-10-29 20:18:32 +00:00
Gregory Alexander
0e390b33f6 Double semicolons are confusing VisualAge. 2002-10-28 18:36:53 +00:00
Bryce Denney
4f53ba4e39 - bx_gui is now a pointer, so it needs to be 'bx_gui->' not 'bx_gui.' 2002-10-27 22:26:34 +00:00
Bryce Denney
8ff15654e8 - add #ifs around use of cr0-4, which didn't all exist on earlier cpus 2002-10-27 15:15:12 +00:00
Stanislav Shwartsman
b84f0bd0f2 This was not a cleanup. Those macros were intentionally
there to offer a way to substitute more efficient code
to do the RMW cases.  At the moment, they just map to
the normal functions.

Sorry, restored the previous version ...
2002-10-25 18:26:29 +00:00
Stanislav Shwartsman
a0c1fd60e6 Just little cleanup of macro duplicating an existing code 2002-10-25 17:23:34 +00:00
Bryce Denney
48acd53db4 - all #warnings are now inside #ifdef __GNUC__ ... #endif
Modified Files:
    ltdl.c main.cc plugin.cc cpu/cpu.cc cpu/debugstuff.cc
    cpu/exception.cc cpu/fetchdecode64.cc cpu/init.cc
    cpu/paging.cc gui/siminterface.cc gui/wxmain.cc
    iodev/harddrv.cc
2002-10-25 12:36:44 +00:00
Bryce Denney
357cf9845f - in rev 1.24 I broke the compile, because I was missing BX_CPU_THIS_PTR
before "mem".  This is fixed now.
2002-10-25 11:54:42 +00:00
Bryce Denney
cec9135e9f - Apply patch.replace-Boolean rev 1.3. Every "Boolean" is now changed to a
"bx_bool" which is always defined as Bit32u on all platforms.  In Carbon
  specific code, Boolean is still used because the Carbon header files
  define it to unsigned char.
- this fixes bug [ 623152 ] MacOSX: Triple Exception Booting win95.
  The bug was that some code in Bochs depends on Boolean to be a
  32 bit value.  (This should be fixed, but I don't know all the places
  where it needs to be fixed yet.)  Because Carbon defined Boolean as
  an unsigned char, Bochs just followed along and used the unsigned char
  definition to avoid compile problems.  This exposed the dependency
  on 32 bit Boolean on MacOS X only and led to major simulation problems,
  that could only be reproduced and debugged on that platform.
- On the mailing list we debated whether to make all Booleans into "bool" or
  our own type.  I chose bx_bool for several reasons.
  1. Unlike C++'s bool, we can guarantee that bx_bool is the same size on all
     platforms, which makes it much less likely to have more platform-specific
     simulation differences in the future.  (I spent hours on a borrowed
     MacOSX machine chasing bug 618388 before discovering that different sized
     Booleans were the problem, and I don't want to repeat that.)
  2. We still have at least one dependency on 32 bit Booleans which must be
     fixed some time, but I don't want to risk introducing new bugs into the
     simulation just before the 2.0 release.

Modified Files:
    bochs.h config.h.in gdbstub.cc logio.cc main.cc pc_system.cc
    pc_system.h plugin.cc plugin.h bios/rombios.c cpu/apic.cc
    cpu/arith16.cc cpu/arith32.cc cpu/arith64.cc cpu/arith8.cc
    cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer16.cc cpu/ctrl_xfer32.cc
    cpu/ctrl_xfer64.cc cpu/data_xfer16.cc cpu/data_xfer32.cc
    cpu/data_xfer64.cc cpu/debugstuff.cc cpu/exception.cc
    cpu/fetchdecode.cc cpu/flag_ctrl_pro.cc cpu/init.cc
    cpu/io_pro.cc cpu/lazy_flags.cc cpu/lazy_flags.h cpu/mult16.cc
    cpu/mult32.cc cpu/mult64.cc cpu/mult8.cc cpu/paging.cc
    cpu/proc_ctrl.cc cpu/segment_ctrl_pro.cc cpu/stack_pro.cc
    cpu/tasking.cc debug/dbg_main.cc debug/debug.h debug/sim2.cc
    disasm/dis_decode.cc disasm/disasm.h doc/docbook/Makefile
    docs-html/cosimulation.html fpu/wmFPUemu_glue.cc
    gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/gui.cc gui/gui.h
    gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc
    gui/rfb.cc gui/sdl.cc gui/siminterface.cc gui/siminterface.h
    gui/term.cc gui/win32.cc gui/wx.cc gui/wxmain.cc gui/wxmain.h
    gui/x.cc instrument/example0/instrument.cc
    instrument/example0/instrument.h
    instrument/example1/instrument.cc
    instrument/example1/instrument.h
    instrument/stubs/instrument.cc instrument/stubs/instrument.h
    iodev/cdrom.cc iodev/cdrom.h iodev/cdrom_osx.cc iodev/cmos.cc
    iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_arpback.cc
    iodev/eth_packetmaker.cc iodev/eth_packetmaker.h
    iodev/floppy.cc iodev/floppy.h iodev/guest2host.h
    iodev/harddrv.cc iodev/harddrv.h iodev/ioapic.cc
    iodev/ioapic.h iodev/iodebug.cc iodev/iodev.h
    iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.h
    iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pic.h
    iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h
    iodev/sb16.cc iodev/sb16.h iodev/serial.cc iodev/serial.h
    iodev/vga.cc iodev/vga.h memory/memory.h memory/misc_mem.cc
2002-10-25 11:44:41 +00:00
Bryce Denney
5e520261db Add plugin support to Bochs by merging all the changes from the
BRANCH_PLUGINS branch!

Authors:
  Bryce Denney
  Christophe Bothamy
  Kevin Lawton (we grabbed a lot of plugin code from plex86)
Testing help from:
  Volker Ruppert
  Don Becker (Psyon)
  Jeremy Parsons (Br'fin)

The change log is too long to paste in here.  To read the change log, do
  cvs log patches/patch.final-from-BRANCH_PLUGINS.gz

All the changes and a detailed description are contained in a patch
called patch.final-from-BRANCH_PLUGINS.gz.  To look at the complete
patch, do
  cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz

Then you will have a local copy of the patch, which you can gunzip and
play with however you want.

Modified Files:
    .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure
    configure.in gdbstub.cc logio.cc main.cc pc_system.cc
    pc_system.h state_file.h bios/Makefile.in bios/rombios.c
    cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc
    cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h
    cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc
    cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc
    cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc
    cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc
    cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc
    cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc
    debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in
    doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in
    gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc
    gui/control.cc gui/control.h gui/gui.cc gui/gui.h
    gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc
    gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc
    gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc
    gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h
    gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map
    gui/keymaps/x11-pc-de.map instrument/example0/instrument.h
    instrument/example1/instrument.h
    instrument/stubs/instrument.cc instrument/stubs/instrument.h
    iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h
    iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc
    iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc
    iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc
    iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h
    iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc
    iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc
    iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc
    iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc
    iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc
    iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc
    iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h
    iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc
    iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h
    iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc
    memory/memory.h memory/misc_mem.cc misc/bximage.c
    misc/niclist.c
Added Files:
    README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in
    ltmain.sh plugin.cc plugin.h
2002-10-24 21:07:56 +00:00
Bryce Denney
6f49d51996 - avoid crash if BX_CPU_C::debug() called while mem is NULL 2002-10-24 06:26:37 +00:00
Stanislav Shwartsman
466a3226f5 FXSAVE/FXRSTOR stubs defined in sse.cc 2002-10-19 21:47:28 +00:00
Stanislav Shwartsman
277f14dd76 Implemented PMOVMSKB_GdPRq instruction (SSE) 2002-10-19 21:46:07 +00:00
Stanislav Shwartsman
63ac78d496 Implemented MOVNTQ instruction 2002-10-19 21:28:50 +00:00
Stanislav Shwartsman
82c879717c add prepareSSE for SSE2 only. SSE2 only not allowed by configure script but for debug issues it may be useful to enable SSE2 only ... 2002-10-19 21:01:24 +00:00
Stanislav Shwartsman
6cd078b777 Add opcode name to the information message in case of MMX/SSE/SSE2 instruction is not supported 2002-10-19 20:58:18 +00:00
Stanislav Shwartsman
21201bc237 Add opcode name to the information message in case of MMX/SSE/SSE2 instruction is not supported 2002-10-19 20:16:42 +00:00
Stanislav Shwartsman
c5f0ef8c76 Removed duplicated definition of BX_SEG_REGS 2002-10-16 22:10:07 +00:00
Bryce Denney
f6c637aa8a - upgrade bx_param_num to use 64 bit values, so that I could make
bx_shadow_num_c able to handle pointers to 64 bit values.  This
  allows x86-64 and wxWindows to coexist.
- I had a number of duplicate constructors for bx_shadow_num_c,
  with an without the description arg.  I eliminated the ones
  that had no description, and also removed the min/max arg from
  all.  I still need a bunch of constructors though, for
  Bit64u*, Bit64s*, Bit32u*, Bit32s*, Bit16u*, Bit16s*, Bit8u*, Bit8s*.
  Having all these constructors allows us to write
    new bx_shadow_num (bxid, name, description, &value)
  for basically any integer variable.  They are all handled by the same class.
- these changes led to minor touchups in cpu/init.cc and iodev/keyboard.cc
- modified:
    configure main.cc cpu/init.cc iodev/keyboard.cc
    gui/siminterface.cc gui/siminterface.h
2002-10-16 19:39:27 +00:00
Stanislav Shwartsman
194952a53d Merged BOCHS-SSE branch 2002-10-16 17:37:35 +00:00
Bryce Denney
c07f5836f3 - move definition of bx_address earlier, just after the Bit32u and Bit64u
types are defined.  This should ensure that bx_address is defined by
  the time it's needed.
2002-10-13 22:38:17 +00:00
Volker Ruppert
ae0bb040d9 - in VERR / VERW function: changed BX_ERROR to BX_DEBUG. According to the i386
opcode description there is no error present.
2002-10-13 15:34:49 +00:00
Stanislav Shwartsman
b4f1a57924 Merged BOCHS-SSE branch with latest main trunk sources 2002-10-11 17:56:56 +00:00
Kevin Lawton
491ca837f9 Fixed double quadword routines to work for little or big endian hosts. 2002-10-11 16:18:00 +00:00
Kevin Lawton
cffded3829 Simple implementations of the new double quadword functions in
access.cc for SSE[2] implementation by Stanislav.
2002-10-11 13:55:26 +00:00
Bryce Denney
14f9f230a8 - in OR_ALIb the local variable "sum" was changed to "result" but the
non-host-asm line at the end still said "sum".  Fixed.
2002-10-11 13:50:14 +00:00
Kevin Lawton
3183ab7102 Added some preliminary configure and config.h stuff for
SSE/SSE2 for Stanislav.  Also, some method prototypes and
  skeletal functions in access.cc for read/write double quadword
  features.

Also cleaned up one warning in protect_ctrl.cc for non-64 bit compiles.
  There was an unused variable, only used for 64-bit.
2002-10-11 01:11:11 +00:00
Stanislav Shwartsman
30060682c1 Removed duplicate depencies list for mmx.cc 2002-10-08 21:31:56 +00:00
Peter Tattam
b968c4e5c8 Latest round of patches/fixups to get 64 bit emulation further.
This is an interim update to allow others to test.

We have userland code running!!! (up to a point)

Able to start executing "sash" as /sbin/init in userland from linux 64 bit
kernel until it crashes trying to access a null pointer.  No kernel panics
though, just a segfault loop.
2002-10-08 14:43:18 +00:00
Kevin Lawton
b8d7f5c88e Moved the asm() statements from the arithmetic instruction emulation
into inline functions with asm() statements in cpu.h.  This cleans
  up the *.cc code (which now doesn't have any asm()s in it), and
  centralizes the asm() code so constraints can be modified in one
  place.  This also makes it easier to cover more instructions
  with asm()s for more efficient eflags handling.
2002-10-07 22:51:58 +00:00
Kevin Lawton
d7a16521c4 Replaced "return;" statements associated with bx_guard.special_unwind_stack
hack with longjmp() back to cpu.cc main decode loop, and added a
  check in there to return control when bx_guard.special_unwind_stack
  is set (compiling with debugger enabled only).

If in the debugger you try to execute further instructions
  (which you shouldn't), other fields need to be reset I would
  think, such as EXT and errorno, and have to make sure ESP/EIP
  are corrected properly.  Basically, this hack is only good
  for examining the current situation of a nasty fault.
2002-10-06 22:08:18 +00:00
Kevin Lawton
c6350caa48 Removed several "#if BX_CPU_LEVEL < 2" clauses, since stack64.cc
is only compiled for x86-64.
2002-10-06 21:38:02 +00:00
Kevin Lawton
2baf4372d1 Got rid of Ctrl-M's in exception.cc, introduced with the
implementation of SYSCALL.
2002-10-06 18:05:21 +00:00
Kevin Lawton
261badee5a Added a couple macros which expand on GCC to __attribute__ directives
to give the compiler some hints:

    BX_CPP_AttrPrintf(formatArg, firstArg)
    BX_CPP_AttrNoReturn()

The first is to tell the compiler that a function receives printf-like
  arguments so it can do some smart argument checking w.r.t. the
  format string.  The 2nd tells the compiler that the function does
  not ever return; it's not used yet, but I'd like to use it on
  exception() after we fix the situation of it returning for debugging.

I fixed one parameter mismatch in cpu/ by deleting a deprecated
  debug print statement.  There are several other mismatches in
  other code modules.
2002-10-06 14:16:23 +00:00
Kevin Lawton
b1d2f7ae48 Added a return value to handleAsyncEvent() so that requests to
exit out of cpu_loop() and back to the caller can be honored.
  Previously, code in this function was a part of cpu_loop so
  a "return;" would already do that.  Now, a value is passed
  back to cpu_loop() to denote such a request, and then a return
  is executed from cpu_loop().

  I haven't tested this yet, but previously I must have broke
  certain debugging requests by moving the code to a separate
  function and not fixing the "return;" statements.
2002-10-05 14:51:25 +00:00
Peter Tattam
db0a37824c Fixed elusive APIC interrupt problems when bochs compiled for P6 or later.
Symptom:  Linux kernel 2.4.19 would hang in random places.  CPU still
running, but in dle loop.

Cause: if APIC interrupt occurred while a PIC interrupt was pending, the
PIC interrupt would be lost.  This is because either an APIC or PIC
interrupt would trash any pending interrupt event because INTR is only a state,
not an event queue.

Temporary fix: reworked apic.cc to have it's own copy of INTR state. cpu.cc now
checks for both cpu.INTR and local_apic.INTR.

Need to do further research to see if local_apic and pic can be integrated in such
a way as properly manage the combined effects of both devices accessing INTR state.
2002-10-05 10:25:31 +00:00
Kevin Lawton
0d22bbafc2 Added a new function writeEFlags() which takes a 32-bit eflags
value and a change-mask, rather than passing all the boolean
  change flags as arguments.

Recoded the POPF instruction in flag_ctrl.cc to use the
  new writeEFlags() function, and to make it more sane.

Also, the old write_flags() and write_eflags() functions
  redirect to writeEFlags() for now.  Later, when we get
  back in a development mode, it would be better to make
  all calls use the new function and get rid of the old ones.
2002-10-05 06:33:10 +00:00
Bryce Denney
d754550d47 - a boolean variable is represented by just 1 bit, 0=false or 1=true. We have
been using the Boolean type for a number of multi-bit fields on the
  assumption that it is actually many bits wide.  However, this assumption is
  unsafe and has caused some bugs that are hard to track down.
- in the Carbon library on MacOS X, Boolean is defined to be an unsigned char.
  This has been causing some of the EFLAGS accessors to fail (bits 8-31)
  because they depended on Boolean being 32 bits wide.  I changed these
  accessors to return Bit32u instead.  I believe that this will finally fix
  [ 618388 ] Unable to boot under MacOS X.
- It would be possible to create a bochs specific type for booleans (bx_bool),
  but it's cleaner to simply use "Boolean" when we actually mean a 1-bit true
  or false field, and Bit8u/Bit32u when it is a multibit field.
2002-10-04 22:25:22 +00:00
Kevin Lawton
66452e9898 Replaced tabs in cpu/*.{cc,h} files with spaces. 2002-10-04 17:04:33 +00:00
Kevin Lawton
f64eb0e16a Changed the hot countdown timer in pc_system.* files to be
32-bits rather than 64.  This is possible, because there is
  always an active null (heartbeat) timer, with periodicity
  of less than or equal to the maximum 32-bit int value.

  This generates a little less code in the hot part of cpu_loop,
  and saved about 3% execution time on a Win95 boot.

Moved the asynchronous handling code from cpu_loop() to its
  own function since it's a long path.  This neatened up the
  code a little (less gotos and all), and made it more clear
  to use a "while (1)" around the iterative code in cpu_loop().
2002-10-04 16:26:10 +00:00
Bryce Denney
f54551717e - include <windows.h> in bochs.h whenever WIN32 is defined. This is required
so that windows types can be used in fields, for example in cdrom.h:
    #ifdef WIN32
      HANDLE cdrom_interface::hFile;
    #endif
- since every file includes bochs.h, I removed includes of <windows.h>
  everywhere else
- modified: bochs.h cpu/extdb.cc gui/win32.cc gui/wx.cc iodev/cdrom.cc
  iodev/eth_win32.cc iodev/floppy.cc
2002-10-03 21:07:04 +00:00
Kevin Lawton
8e33d2eda1 Integrated patches/patch.extra_eflags_asms from Jas, for more asm()
coverage of the high-frequency eflags instructions.  That should
  complete the asm() eflags updates for now, as we should be stabilizing
  moving towards bochs 2.0.
2002-10-03 18:12:40 +00:00
Kevin Lawton
ee47fabac0 Committed new bochs internal timers (in pc_system.{cc,h}.
These seem to be working better, are a more simple design,
  easier to understand, and AFAIK don't have race conditions
  in them like the old ones do.

Re-coded the apic timer, to return cycle accurate values
  which vary with each iteration of a read from a guest OS.
  The previous implementation had very poor resolution.  It
  also didn't check the mask bit to see if an apic timer
  interrupt should occur on countdown to 0.  The apic timer
  now calls its own bochs timer, rather than tag on the
  one in iodev/devices.cc.

I needed to use one new function which is an inline in
  pc_sytem.h.  That would have to be added to the old pc_system.h if
  we have to back-out to it.

Linux/x86-64 now boots until it hits two undefined opcodes:

  FXRSTOR (0f ae).  This restores FPU, MMX, XMM and MXCSR registers
    from a 512-byte region of memory.  We don't implement this yet.

  MOVNTDQ (66 0f e7).  This is a move involving an XMM register.
    The 0x66 prefix is used so it's a double quadword, rather than
    MOVNTQ (0f e7) which operates on a single quadword.

  The Linux kernel panic is on the MOVNTQD opcodes.  Perhaps that's
  because that opcode is used in exception handling of the 1st?

  Looks like we need to implement some new instructions.
2002-10-03 15:47:13 +00:00
Bryce Denney
75ce3842d2 - add GDB stub patch by Johan Rydberg 2002-10-03 05:14:50 +00:00
Bryce Denney
aeffd3e212 - improve panic slightly to show limits on LDT, if the limit is exceeded 2002-10-03 05:10:24 +00:00
Bryce Denney
0d28420aa2 - provide dbg_xlate_linear2phy when running as GDB stub 2002-10-03 04:53:53 +00:00
Bryce Denney
534c4985d9 - specify the exception type on triple exceptions 2002-10-03 04:52:39 +00:00
Bryce Denney
6c5b223752 - improve panic msg slightly 2002-10-03 04:49:47 +00:00
Bryce Denney
de68ca74d9 - call BX_CPU_C::set_INTR(0) instead of just setting the INTR value.
The result is the async_event gets set, though as far as I can tell
  it makes no difference.
2002-10-03 04:45:17 +00:00
Bryce Denney
7a5b4377fb - replace new preprocessor directive "#panic" with call to BX_INFO and
UndefinedOpcode().
2002-10-02 04:01:45 +00:00
Bryce Denney
4c9776fb96 - add -lwinmm to the link lines anytime you use --enable-sb16=win. Now
instead of winmm being a part of GUI_LINK_OPTS_WIN32 only, it is
  placed in @DEVICE_LINE_OPTS@ so that it will be used for sdl, rfb, wx,
  etc.
- solve compile problems when building bximage, niclist, and any other
  console based program.  The compile flags returned by wx-config and
  sdl-config did strange things to these console programs, for example
  redefining main to SDL_main.  Because I wanted to use the
  configure-generated CFLAGS to compile the programs, but I wanted to
  avoid including GUI specific compile options, I split up the configure's
  @CFLAGS@ variable into @CFLAGS@ and @GUI_CFLAGS@, and split
  @CXXFLAGS@ into @CXXFLAGS@ and @GUI_CXXFLAGS@.  All programs in the
  Bochs binary will use both, but the console programs will just use
  @CFLAGS@ or @CXXFLAGS@.
- gui/Makefile.in, I no longer use the gui specific CFLAGS variables,
  SDL_CFLAGS and WX_CXXFLAGS.  These values are included in CFLAGS and
  CXXFLAGS now.
- modified: configure.in, configure, all Makefile.in's
2002-10-01 23:37:50 +00:00
Peter Tattam
562d6b55dd fixed a formatting problem for debug output for external debugger. 2002-10-01 07:13:00 +00:00
Peter Tattam
9078c5fc06 fixed extdb.cc to work in default IA32 bochs 2002-10-01 06:47:06 +00:00
Peter Tattam
94b2dd2bc8 Cleanup of extdb.* files. included in right places now. 2002-10-01 04:13:12 +00:00
Bryce Denney
be4005269b - many parameters in cpu were being redefined if you stop simulation and
restart another one in wxWindows.  Fixed that.  Also, on restart, the
  apic id's left over from the first run were causing panics.  Fixed that.
- modified: main.cc cpu/apic.cc cpu/cpu.h cpu/init.cc
2002-09-30 22:18:53 +00:00
Kevin Lawton
1e5343b421 As a 1st effort to understand/debug the timer code, I cleanup
up pc_system.h.  Moved all variables under the private: section,
  as well as a few member functions.  The string instructions
  were accessing a field directly (only reads), so I indirected
  that via an inline member function for better abstraction.
2002-09-30 16:43:59 +00:00
Kevin Lawton
af31c4583b More merging of modRM==11b if () clauses in logical*.cc functions,
and code cleanup.
2002-09-30 03:37:42 +00:00
Kevin Lawton
00c14e4efe Added ./configure option --enable-all-optimizations which turns on
all available optimizations in one shot.

Finished one last case of an instruction which could but didn't use
  the Read-Modify-Write variants of access.cc functions.

Started going through the integer instructions, merging obvious cases
  where there are two "if (modrm==11b) {" clauses and very little
  action in between, and cleaning up the aweful indentation leftover
  from many years ago when those instructions were implemented using
  cut-and-paste.  We may get a little extra performance out of these
  mods, but they'll also be easier after I'm finished to enhance
  with asm() statements to knock out the lazy flags processing on x86.
2002-09-30 02:02:06 +00:00
Kevin Lawton
67721c48f4 The convience functions protected_mode(), v8086_mode() and real_mode()
now simply return a cached value which is set upon mode changes.
  The biggest problem was protected_mode() which did something like:

    return CR0.PM && ! EFLAGS.VM

  This adds up when it was being executed many times in branch functions
  etc.  Now, cached values are set and sampled instead.
2002-09-29 22:38:18 +00:00
Kevin Lawton
a5537449cd Split out reg-reg and reg-memory cases for a few other high-profile
instructions, mainly variants of MOV.  Had to update fetchdecode64
  to keep it inline with the 32-bit mods.
2002-09-29 19:21:38 +00:00
Stanislav Shwartsman
b8f1d5c031 Fixed the bug caused failures of instrumentation on SMP configuration ... 2002-09-29 16:59:28 +00:00
Kevin Lawton
f99f17bca4 Integrated CPUID CMPXCHG8B bit setting patch from John_Bäckstrand.
Moved it slightly, but it is correct.
2002-09-29 16:23:03 +00:00
Kevin Lawton
895693b3b5 Fixed fetchdecode64() to work with the few MOV instructions which
were split into mod=11b, and mod!=11b cases for performance.
2002-09-29 15:07:11 +00:00
Stanislav Shwartsman
abb1530faf Fixed number of problems with instrumentation merge cause to instrumentation fail the compilation 2002-09-29 15:06:58 +00:00
Stanislav Shwartsman
8d99157993 Another additional for instrumentation 2002-09-29 14:16:30 +00:00
Stanislav Shwartsman
d495bd75a6 fter integration of SplitMod11b changes Bochs failed to compile in SMP mode.
I fixed the compilation errors in CVS, smbd please check if the fix is property;
2002-09-28 09:38:58 +00:00
Peter Tattam
3ed1d61cd4 Initial work on updating bochs disassembler
Used patch.disasm to do

1) clean up the disasm output to make the dispaly of extra stuff optional.
2) included the part of the patch which displays displacements as
   proper addresses.
2002-09-28 06:29:55 +00:00
Kevin Lawton
08a89fe7b6 Performance mod: I implemented a suggestion from Peter Tattam
and Jas Sandys-Lumsdaine to split out common instructions into
  variants which deal with the mod=11b case (Reg-Reg) and the
  other cases (which do memory ops).  Actually, I only split
  MOV_GwEw and MOV_GdEd for now.  According to some instrumentation
  of a Win95 boot, they were the most frequently used opcode by far.
2002-09-28 05:38:11 +00:00
Kevin Lawton
6843c3dfe8 Integrated patches/patch.logicalxx_asm from Jas Sandys-Lumsdaine.
Essentially, when I coded a few of the instructions to use
  asm()s for acceleration of the eflags, I got lazy and only
  used the asm() to compute eflags and let the normal C operation
  do the actual operation.  Jas's patch, moved the asm()s such
  that they now do the work of the operation as well.

  The patches look great.  The code reads a lot better as well.

  Further work can be done to give the compiler more options with
  register scheduling.
2002-09-28 01:48:18 +00:00
Kevin Lawton
c49309de14 Committed [english] patches from Jas Sandys-Lumsdaine. These
were simply replacements of the eflags mask constants with
  the macro names already in cpu.h for asm() statements.  I forgot
  to use the macros for some instructions.
  0x000008d5 -> EFlagsOSZAPCMask
  0x000008d4 -> EFlagsOSZAPMask
2002-09-28 01:16:09 +00:00
Kevin Lawton
13a1e55f20 Committed patches/patch-bochs-instrumentation from Stanislav.
Some things changed in the ctrl_xfer*.cc, fetchdecode*.cc,
and cpu.cc since the original patches, so I did some patch
integration by hand.  Check the placement of the
macros BX_INSTR_FETCH_DECODE_COMPLETED() and BX_INSTR_OPCODE()
in cpu.cc to make sure I go them right.  Also, I changed the
parameters to BX_INSTR_OPCODE() to update them to the new code.
I put some comments before each of these to help determine if
the placement is right.

These macros are only compiled in if you are gathering instrumentation
data from bochs, so they shouldn't effect others.
2002-09-28 00:54:05 +00:00
Stanislav Shwartsman
e6adebfe2d Added MMX opcodes to x86-64 mode
Fixed problem with fetching extra byte in ESCx opcodes if FPU is disabled
2002-09-27 09:56:40 +00:00
Kevin Lawton
47f2e7c404 Got rid of the KPL64Hacks macro. The fixes below eliminated it.
Created 64-bit versions of some branch instructions and
  changed fetchdecode64.cc to use them instead.  This keeps the
  #ifdef pollution down for 32-bit code and made fixing them
  easier.  They needed to clear the upper bits of RIP for
  16-bit operand sizes.  They also should not have had a protection
  limit check in them, especially since that field is still
  32-bit in cpu.h, so there's no way to set nominal 64-bit values.
  The 32-bit versions were also not honoring the upper 32-bits
  of RIP.

  LOOPNE64_Jb
  LOOPE64_Jb
  LOOP64_Jb
  JCXZ64_Jb

Changed all occurances of JCC_Jw/JCC_Jd in fetchdecode64.cc to
  use JCC_Jq, which was coded already.  Both JMP_Jq and JCC_Jq are
  now fixed w.r.t. 16-bit opsizes and upper RIP bit clearing.
2002-09-27 07:01:02 +00:00
Peter Tattam
5bfd2c669e SYSRET patch. need to do invalidate_prefetch() for correctness 2002-09-27 03:33:13 +00:00
Kevin Lawton
109111202c Modified my fix to JMP_Jq to clear all the upper bits,
63..16 when a 16-bit operand size JMP is executed.  Previous
  fix cleared only 63..32.  I since realized, this is the case
  which does parallel the 32-bit semantics.
2002-09-26 22:34:06 +00:00
Kevin Lawton
6d74a334d6 64-bit bug#1: Instructions such as MOV_ALOq were always
fetching 64-bit address opcode info, which was incorrect.

  Fixed.  Got rid of BxImmediate_Oq.  fetchdecode64.cc now
  uses BxImmediateO, like the fetch routine does.  Addresses which
  are embedded in the opcode, have a size which depends on
  the current addressing size.  For long-mode, this is
  either 64 (default) or 32 (AddrSize over-ride).  BxImmediate_O
  now conditionally fetches based on AddrSize.

64-bit bug#2: In JMP_Jq(), when the current operand size is
  16-bits, the upper dword of RIP was not being cleared.  The
  semantics with this case are weird - one would think the
  top 48 bits would be cleared, but apparently only the top
  32 bits are.  Anyways, I fixed this.

Replaced some of the messy immediate fetching (byte-by-byte) in
  fetchdecode64.cc with ReadHost{Q,D}WordFromLittleEndian() calls
  for cleanliness.  Should do this for all the cases, plus
  the 32-bit stuff.
2002-09-26 21:32:26 +00:00
Stanislav Shwartsman
f987ad036e Changed BxError to UndefinedOpcode function for UD2 opcode (oF 0B) 2002-09-26 18:58:50 +00:00
Peter Tattam
67082a5b50 Implemented SWAPGS instruction.
Note that it is unusual to decode (see SGDT instruction)
2002-09-25 14:09:08 +00:00
Bryce Denney
8f9bec3919 - remove unused, and incorrect MSR fields 2002-09-25 13:26:04 +00:00
Peter Tattam
a0d90e9b39 Implemented SYSCALL and SYSRET as part of x86-64 emulation.
Since the SYSCALL replaces the LOADALL instruction, it is incompatible with
earlier CPU types.

At moment, the SYSCALL is only enabled by x86-64 emulation, but the code
can be incorporated in IA32 only emulations.

Instructions added:

0F 05		SYSCALL		(replaces LOADALL)
0F 07		SYSRET		(new)

TODO:  restructure #if ... so that it can be used by non x86-64 emulations.
2002-09-25 12:54:41 +00:00
Peter Tattam
0de63e8492 Fix to stop external debugger trapping for all exceptions. 2002-09-25 06:36:42 +00:00
Bryce Denney
e3539d7a4a - from Peter Tattam: add missing instruction MOVNTI to decode table 2002-09-25 03:32:12 +00:00
Bryce Denney
8e103b3ffb - fix compile warning about checking that an unsigned int was >= 0 2002-09-25 01:50:14 +00:00
Kevin Lawton
3c09fdb363 I updated code that was using !!get_CF() (or other arithmetic flag) to
use getB_CF() etc.  getB_CF() and friends are only for a relatively
  small number of cases where a true boolean/binary number (0 or 1) is required
  rather than 0 or non-0 as is returned by get_CF().
2002-09-24 18:33:38 +00:00
Kevin Lawton
aeca26fc04 Declaration of loadSRegLMNominal() is now only defined for 64-bit. 2002-09-24 16:39:33 +00:00
Kevin Lawton
26ebda0775 Got rid of INIT_64_DESCRIPTOR in all places. Added/replaced it with
loadSRegLMNominal() which should be used to load a segment register
  in long-mode with nominal values which are compatible with existing
  checks and expectations for descriptor cache values.

Fixed 64-bit iret to not do a descriptor fetch if SS selector is null.
  Also load SS with loadSRegLMNorminal() in the same case.
2002-09-24 16:35:44 +00:00
Kevin Lawton
6e7e4c2431 Fixed ctrl_xfer_pro.cc for 64-bit iret. Check for null selector
was not correct (used == 0, rather than s&0xffc == 0).  Also,
  with a null SS selector, it was fetching the descriptor anyways.
  Put more code inside the if (selector != NULL) clause.
  For a temporary measure I added the local INIT_64_DESCRIPTOR
  from segment_ctrl_pro.cc, and used it in the case that the
  SS selector is null.  We need to make a real function which
  sets a descriptor in long-mode to nominal values.  I'm going
  to do that next... I can't stand seeing the current hacks.  :^)
2002-09-24 15:41:03 +00:00
Bryce Denney
2684886624 - fix my merging error from previous rev. Instead of putting the 32bit code
inside the else clause of an if statement, I added a return in the 64bit
  code so that it would not continue.
2002-09-24 14:00:10 +00:00
Bryce Denney
6e473648bd - remove extra #endifs that came from merging Peter's and Kevin's code 2002-09-24 13:57:37 +00:00
Bryce Denney
de0e58c2c5 These changes are from Peter Tattam
- fix load_ss, remove load_ss_null
- change the "#if KPL64Hacks" around msr stuff into "#if BX_IGNORE_BAD_MSR"
- remove "#if KPL64Hacks" from BX_CPU_C::can_push
- segment_ctrl_pro.cc: bug fix to ss == null handling in 64 bit mode

Modified: cpu/cpu.h cpu/ctrl_xfer_pro.cc cpu/exception.cc
cpu/proc_ctrl.cc cpu/segment_ctrl_pro.cc cpu/stack_pro.cc
2002-09-24 08:29:06 +00:00
Kevin Lawton
82fd79c546 Fixed/updated/cleaned repeat IO & memcpy speedups for Long mode.
Fixed/updated/cleaned guest2host TLB speedups for Long mode.

I now can boot the Linux x86-64 kernel to the VFS mount message,
using all the accelerations.
2002-09-24 04:43:59 +00:00
Kevin Lawton
281e62d8b1 I integrated my hacks to get Linux/x86-64 booting. To keep
these from interfering from a normal compile here's what I did.
In config.h.in (which will generate config.h after a configure),
I added a #define called KPL64Hacks:

  #define KPL64Hacks

*After* running configure, you must set this by hand.  It will
default to off, so you won't get my hacks in a normal compile.
This will go away soon.  There is also a macro just after that
called BailBigRSP().  You don't need to enabled that, but you
can.  In many of the instructions which seemed like they could
be hit by the fetchdecode64() process, but which also touched
EIP/ESP, I inserted a macro.  Usually this macro expands to nothing.
If you like, you can enabled it, and it will panic if it finds
the upper bits of RIP/RSP set.   This helped me find bugs.

Also, I cleaned up the emulation in ctrl_xfer{8,16,32}.cc.
There were some really old legacy code snippets which directly
accessed operands on the stack with access_linear.  Lots of
ugly code instead of just pop_32() etc.  Cleaning those up,
minimized the number of instructions which directly manipulate
the stack pointer, which should help in refining 64-bit support.
2002-09-24 00:44:56 +00:00
Bryce Denney
caa82a19a0 - print CR* registers on exit
[ 501694 ] cr2 value shown when bochs panics
  http://sourceforge.net/tracker/index.php?func=detail&aid=501694&group_id=12580&atid=362580
2002-09-23 22:10:00 +00:00
Kevin Lawton
91fd4b3745 Added new configure option --enable-host-specific-asms, so the
user can turn on/off use of native host specific inline asm
  statements.  By default, this option is enabled, so you only
  need it to disable inline asms in your compile for now.

Currently only on x86+GCC environments, will inline asm()
  statements be used.  Eventually, other platforms could specify
  some asm()s; probably for endian issues such as byte-swapping
  and unaligned memory accesses.  On x86, there are some inline
  asm()s which do the arithmetic EFLAGS processing so that the
  lazy flags handling is somewhat bypassed.  Eventually, I'll
  add more, at least for the more common instructions.  This
  adds a little extra performance.
2002-09-23 17:59:18 +00:00
Bryce Denney
c6133d926a - uncomment pieces of Peter Tattam's external debugger, but leave them in
an #if BX_EXTERNAL_DEBUGGER block
2002-09-23 15:26:05 +00:00
Bryce Denney
00b2607e6a - added bit definitions of CR4 in comments 2002-09-23 14:45:44 +00:00
Bryce Denney
c9b05afa6d - add "Reserved" bitfields to comments, to make it more complete 2002-09-23 14:38:14 +00:00
Bryce Denney
8b1a27fc7e - I forgot to mention that the previous rev was a patch from Peter Tattam 2002-09-23 14:33:49 +00:00
Bryce Denney
185254e367 - for x86-64, claim that we are an "AuthenticAMD" processor
- return model=2 so that Linux recognizes the processor as having an APIC.
  We don't really know what Hammer returns.
- in SetCR4, allow bits 9 and 10 to be written
2002-09-23 14:31:21 +00:00
Bryce Denney
35d9ad97b9 - from Peter Tattam: change prefetch instructions to nops instead of undefined 2002-09-23 14:25:29 +00:00
Bryce Denney
9810e6ab8d - in CMP_EqId, fix bug in sign extension 2002-09-23 14:25:08 +00:00
Kevin Lawton
30de048055 Enhanced my previous updates, by making sure that both operands
to byte operations in asm() statements use either a byte-accessible
  register (eax,ebx,ecx,edx) or a memory operand with "q" and "mq"
  constraints.
2002-09-23 00:40:58 +00:00
Kevin Lawton
9100d1ab1e Changed "r" constraints to "q", so gcc will emit a byte addressable
register for the x86 asm() tricks.
2002-09-23 00:27:18 +00:00
Kevin Lawton
41929b75bd Moved the "i = &iStorage" line inside the #ifdef bracketing
for iCache support.  It wouldn't hurt anything, but it
  makes the compiler complain of longjmp/fork issues.
2002-09-22 23:42:01 +00:00
Kevin Lawton
6e7a2e91f2 Added more x86 specific asm() code to directly handle eflags return
values for some common instructions (like test/and/cmp).  Only
  compiles in on x86 of course.
2002-09-22 22:22:16 +00:00
Kevin Lawton
4150ae197e Hopefully this fixes "Bugs item #612880", which was due to
the icache pageStamp check too early, before it was known
  that the TLB entry would produce a physical address in
  range of the normal part of physical memory.  PCI accesses
  were causing seg faults because of this.  I haven't tested
  this for PCI.
2002-09-22 21:47:57 +00:00
Bryce Denney
a785453194 - fixed another case of get_##flag##(void) 2002-09-22 19:06:46 +00:00
Bryce Denney
fda29cd55b - in definition of ArithmeticalFlag, we had "getB_##flag##(void)",
which says to paste getB_ with flag and then paste with (.  It should
  be "getB_##flag(void)".  Some preprocessors are complaining about pasting
  the symbol with the paren.
2002-09-22 19:03:24 +00:00
Kevin Lawton
b742ccec7e Changed eflags accessors for get_?F() to use (val32 & (1<<N)) instead
of (1 & (val32>>N)), and added a getB_?F() accessor for special
  cases which need a strict binary value (exactly 0 or 1).  Most
  code only needed a value for logical comparison.  I modified the
  special cases which do need a binary number for shifting and
  comparison between flags, to use the special getB_?F() accessor.

Cleaned up memory.cc functions a little, now that all accesses
  are within a single page.

Fixed a (not very likely encountered) bug in fetchdecode.cc (and
  fetchdecode64.cc) where a 2-byte opcode starting with a prefix
  starts at the last offset on a page.  There were no checks
  on the segment overrides for a boundary condition.  I added them.

The eflags enhancements added just a tiny bit of performance.
2002-09-22 18:22:24 +00:00
Bryce Denney
ac4e5bb6cf - add sanity checks
- don't allow MMX on cpu level < 5.
  - require FPU support on cpu level >= 55
  - don't allow MMX support without FPU support (moved this check from
    cpu/i387.h to config.h)
2002-09-22 16:11:12 +00:00
Bryce Denney
e3e16682df from Peter Tattam: in MOVSX_GqEd, typecast op2 to Bit32s instead of Bit16s 2002-09-22 15:42:09 +00:00
Bryce Denney
6b5192d98a - from Peter Tattam: fixed invalid instructions for 64 bit mode 2002-09-22 15:29:51 +00:00
Bryce Denney
2b7654a37d - fixed "macro expands to nothing" by renaming the macro 2002-09-22 07:23:26 +00:00
Bryce Denney
5933d94c91 - add typecast to Bit32u to avoid lots of useless -Wall warnings. The constant
expression on the right side of the comparison was turning out signed, while
  the expression on the left was unsigned.
2002-09-22 02:53:09 +00:00
Kevin Lawton
7fd744b4ef Oops, I had #ifdef 0'd the code in here to do a test compile,
and forgot to put it back.
2002-09-22 02:07:46 +00:00
Kevin Lawton
3bfeab23c9 Split out JZ/JNZ instructions from JCC because they were called
so frequently.
Coded asm() statements for INC/DEC_ERX() instructions.
Cleaned up the iCache a litle including a bug fix.  The
  generation ID was decrementing the whole field including
  some high meta bits.  That could roll over after 1 Billion
  cycles.  I know only decrement if the field is valid, to
  save the write.
I implemented inline functions which can serve the value of
  the arithmetic flags if they are cached, and redirect to
  the lazy_flags.cc routines if not.
Most of this was just prep work for adding more asm() statements
  for native eflags processing when on x86.
2002-09-22 01:52:21 +00:00
Stanislav Shwartsman
a08834b7f7 MMX cannot be compiled without FPU 2002-09-21 17:24:24 +00:00
Kevin Lawton
e2e219eda0 Modified the way that the register field (low 3 bits of a few opcodes
also extended by the REX.B field on Hammer) is passed to instructions.
I rearranged the bxInstruction_c to free up a field to be used
to pass this info when mod-rm bytes are not used.  This got rid
of the ugly ((i->b1 & 7) + i->rex_b) code.

Probably shaved just a very little run time off Hammer emulation,
and even less on x86-32.  The resultant is a little cleaner anyways.
2002-09-20 23:17:51 +00:00
Bryce Denney
dc18466f15 - fix "fatal error U1083: target macro '' expands to nothing" that
Psyon reported
- clean up remnants of cpu64 merge in configure script, Makefile.in,
  and cpu/Makefile.in
2002-09-20 23:16:23 +00:00
Kevin Lawton
402d02974d Moved the EFLAGS.RF check and clearing of inhibit_mask code
in cpu.cc out of the main loop, and into the asynchronous
events handling.  I went through all the code paths, and
there doesn't seem to be any reason for that code to be
in the hot loop.

Added another accessor for getting instruction data, called
modC0().  A lot of instructions test whether the mod field
of mod-nnn-rm is 0xc0 or not, ie., it's a register operation
and not memory.  So I flag this in fetchdecode{,64}.cc.
This added on the order of 1% performance improvement for
a Win95 boot.

Macroized a few leftover calls to Write_RMV_virtual_xyz()
that didn't get modified in the x86-64 merge.  Really, they
just call the real function for now, but I want to have them
available to do direct writes with the guest2host TLB pointers.
2002-09-20 03:52:59 +00:00
Gregory Alexander
88e64f9521 Fix big endian compile problem. 2002-09-20 03:06:39 +00:00
Kevin Lawton
0cd7346b9c - Added an instruction cache. Size is fixed for the moment,
but if you hand edit cpu/cpu.h, and change BxICacheEntries,
  you can try different sizes.  I'll make this more flexible
  with configure.  For now, use "--enable-icache" with no parameters.

- Modified fetchdecode.cc/fetchdecode64.cc just enough so that
  instructions which encode a direct address now use a memory
  resolution function which just sticks the immediate address
  into rm_addr.  With cached instructions we need this.
2002-09-19 19:17:20 +00:00
Kevin Lawton
4e51dcae40 Converted all the remaining available separate fields in bxInstruction_c
to bitfields.  bxInstruction_c is now 24 bytes, including 4 for
the memory addr resolution function pointer, and 4 for the
execution function pointer (16 + 4 + 4).

Coded more accessors, to abstract access from most code.
2002-09-18 08:00:43 +00:00
Kevin Lawton
6723ca9bf4 Moved more separate fields in the bxInstruction_c into bitfields
with accessors.  Had to touch a number of files to update the
access using the new accessors.

Moved rm_addr to the CPU structure, to slim down bxInstruction_c
and to prevent future instruction caching from getting sprayed
with writes to individual rm_addr fields.  There only needs to
be one.  Though need to deal with instructions which have
static non-modrm addresses, but which are using rm_addr since
that will change.

bxInstruction_c is down to about 40 bytes now.  Trying to
get down to 24 bytes.
2002-09-18 05:36:48 +00:00
Bryce Denney
15a3cbc35f - make cpu_param_handler compile with SMP enabled. Unfortunately it will
read all param values from CPU #0.  The only solution I can come up with
  is to change the siminterface handler function interface to pass a void*
  to the callback function.  I'll take care of it eventually.
2002-09-18 04:32:16 +00:00
Kevin Lawton
07b0df2a8a Updated accessing of modrm/sib addressing information to
use accessors.  This lets me work on compressing the
size of fetch-decode structure (now called bxInstruction_c).

I've reduced it down to about 76 bytes.  We should be able
to do much better soon.  I needed the abstraction of the
accessors, so I have a lot of freedom to re-arrange things
without making massive future changes.

Lost a few percent of performance in these mods, but my
main focus was to get the abstraction.
2002-09-17 22:50:53 +00:00
Bryce Denney
f1a3e0307a - add #if BX_CPU_LEVEL>=4 around cr0.wp and cr4 so that i386 will compile 2002-09-17 22:14:33 +00:00
Stanislav Shwartsman
a43bd93b98 just little clean of the code 2002-09-17 14:36:39 +00:00
Kevin Lawton
3d4210fd3f Got rid of a couple fields in BxInstruction_t that were
no longer used.  Also rearranged that struct a little
to be more compressed.  Over time, I'm going to reduce
it further, for use with future accelerations.
2002-09-17 04:20:42 +00:00
Kevin Lawton
2eb34d13a6 Added a configure option, "--enable-pae". The x86-64 enhancements
already had Physical Address Extensions support - we can now
compile for PAE support for x86-32 mode as well.
2002-09-16 21:55:57 +00:00
Kevin Lawton
cc6d44f9c6 Fixed cpu/paging.cc for non-global-pages support compile. 2002-09-16 21:10:31 +00:00
Kevin Lawton
a851db3e36 Ooops, cpu/paging.cc was hosed on that last commit. Fixed that. 2002-09-16 21:01:55 +00:00
Kevin Lawton
5eb4e247bc Merged the final filed ("paging.cc") from Peter Tattam's x86-64
enhancement to bochs.  You can now configure with
--enable-guest2host-tlb.

Force the support of big pages (PSE) when x86-64 is configured.

Reverted back to only one kind of TLB entry style, since everything
is ported.

Fixed one bug in io.cc with as_64 and the index registers.
There are others, as noticed by Peter.
2002-09-16 20:23:38 +00:00
Bryce Denney
6a50742b20 - clean up ^M pollution from working in cygwin 2002-09-16 17:00:16 +00:00
Bryce Denney
42f412c43b - MS VC++ did not accept initialization of static const fields in the
class declaration, for example:
     static const unsigned os_64=0, as_64=0;
  After reading some suggestions on usenet, I changed these into
  enums instead, like this:
     enum { os_64=0, as_64=0 };
2002-09-16 15:21:51 +00:00
Bryce Denney
9eb006ee66 - cr4 has turned into a struct. fix two cases where it was used as if it
was still a number by calling the accessor.
2002-09-16 13:14:06 +00:00
Kevin Lawton
80dd7a07ec Removed references to building libextdb.a. It doesn't seem to
be used at all, and Peter didn't want it.  "extdb.o" is compiled
into libcpu.a, if configured for it.

Removed a few #warnings for x86-64 compile, based on Peter's
line-item comments regarding the warnings I inserted during
the port/merge.
2002-09-15 15:10:21 +00:00
Kevin Lawton
7a11ed547d Fixed CR4 reference in extdb.cc to use the new accessor model.
Also, deleted the old 32-bit path in there as Peter said it's
no longer useful to him.
2002-09-15 14:01:16 +00:00
Bryce Denney
03bb4c1c92 - update wxwindows param for cr4, since it's changed into a structure 2002-09-15 11:01:36 +00:00
Kevin Lawton
798fc08585 (cpu64) Merged string.cc. 2002-09-15 05:09:18 +00:00
Kevin Lawton
a6ea6659ab (cpu64) Merged bit.cc. 2002-09-15 03:38:52 +00:00
Kevin Lawton
918442ae4a (cpu64) Merged io.cc. 2002-09-15 02:55:34 +00:00
Kevin Lawton
b68c2b929a (cpu64) Merged a couple more files. 2002-09-15 02:23:12 +00:00
Kevin Lawton
72f37c0fc5 (cpu64) Merged 2 more. For extdb.cc, essentially I just wrapped
the contents of both files with an #ifdef.  It's a small file,
but I don't use it.  Someone else should clean it up.
2002-09-15 01:36:13 +00:00
Kevin Lawton
a372b32c79 (cpu64) Merged another wad of files. 2002-09-15 01:00:20 +00:00
Kevin Lawton
425a8cda81 (cpu64) Merged lazy_flags.cc. 2002-09-15 00:18:41 +00:00
Kevin Lawton
278e27d5fe Merged proc_ctrl.cc. Also fixed a bug in CR4 reloading; we were
printing a message when a reserved bit was set, but not causing
a #GP(0).  As well, I force a new PAE support option to 1 when
Hammer support is enabled.
2002-09-14 23:17:55 +00:00
Kevin Lawton
93d05990cc Updated CR4 to use the patented Bryce bitfields accessor method for
both cpu32 and cpu64, to make upcoming merging easier, and the
code cleaner.  Compiled for debug as well, and fixed CR4 for that
also.
2002-09-14 19:21:41 +00:00
Kevin Lawton
6d4b3e0e4d (cpu64) Merged 4 more files. 2002-09-14 17:29:47 +00:00
Kevin Lawton
aaeeab5850 Reverted back to using "ar" for making libraries. I had to
declare libs from cpu and cpu64 twice to make the linker
pick up all the symbols.
2002-09-14 05:46:57 +00:00
Kevin Lawton
03691c8fca (cpu64) Merged segment_ctrl.cc. 2002-09-14 03:31:50 +00:00
Kevin Lawton
0305a6a2fa (cpu64) Merged {cpu,cpu64}/cpu.h 2002-09-14 03:01:05 +00:00
Kevin Lawton
c24ef050e1 (cpu64) Merged init.cc. 2002-09-14 00:51:46 +00:00
Kevin Lawton
d16fcfce91 (cpu64) Merged fetchdecode.cc. Also, I had some problems with
circular dependencies between 3 cpu related libs that I need
as part of this transition.  I changed the "ar rv" to "ld -i -o"
to do an incremental load instead of an archive.  Hope this
doesn't break any platforms.  We can reset this later.
2002-09-13 23:59:24 +00:00
Kevin Lawton
1154c81816 (cpu64) Merged arith16.cc 2002-09-13 22:31:02 +00:00
Kevin Lawton
a49391ba30 (cpu64) Merged logical8.cc logical32.cc 2002-09-13 22:20:45 +00:00
Kevin Lawton
b1e787cdc6 (cpu64) Merged vm8086.cc. 2002-09-13 22:02:11 +00:00
Kevin Lawton
b9212fdafb (cpu64) Merged data_xfer8.cc 2002-09-13 21:47:21 +00:00
Kevin Lawton
9393b0046c (cpu64) Merged mult8.cc 2002-09-13 21:34:00 +00:00
Kevin Lawton
5e93ae3cd9 These files were removed since they have not been used for
a long time.  They are artifacts of an older fetch/decode
architecture in bochs.
2002-09-13 21:22:35 +00:00
Kevin Lawton
5c54cf5e3a (cpu64) merged protect_ctrl_pro.cc 2002-09-13 21:15:29 +00:00
Kevin Lawton
e5dc75091b (cpu64) Merged protect_ctrl.cc. For cpu64 there is a cpu field
called cpu_mode.  Now there is one for cpu32, but it is declared:

  static const unsigned cpu_mode=BX_MODE_IA32;

This way the compiler can compile-out if-then-else clauses based
on it, allowing for easier code sharing.
2002-09-13 21:08:54 +00:00
Bryce Denney
565b3846c9 - add infrastructure for sending commands from the wxWindows interface to the
Bochs debugger.  The Bochs debugger calls SIM->debug_get_next_command() which
  does not return until a debugger command is found.  The siminterface sends an
  synchronous event to the wxWindows thread with a blank to be filled in with a
  debugger command.  wxWindows fills in the blank and sends the synchronous
  event back, and the Bochs debugger interprets it as if it was typed on
  the command line.  For the long term I haven't decided whether to stick with
  sending text strings vs. some other method.
- so far the wxWindows debugger consists of one big dialog box that shows
  all the standard registers, and a working Continue, Stop, and Step button.
- modify ParamDialog so that it is more useful as a base class, by moving
  some things to protected members&fields, separating out functionality
  that is most likely to be replaced into virtual functions, and making it
  generally more flexible.  The new CpuRegistersDialog is based on
  ParamDialog.
- in wxdialog.cc, continue the convention of using wxID_HELP, wxID_OK,
  wxID_CANCEL, etc. for the id's of buttons, instead of wxHELP, wxOK, etc.
  which are intended to be ORred together in a bit field.
- cpu/init.cc: put ifdefs around DEFPARAMs for flags in configurations
  where they don't exist.  Add an eflags shadow parameter that represents all
  of the bits of eflags at once.  There are also boolean shadow params for
  each bit.
- modified files: cpu/init.cc debug/dbg_main.cc debug/debug.h
  gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
  gui/wxmain.cc gui/wxmain.h
2002-09-13 19:39:38 +00:00
Bryce Denney
7ff21b5f30 - the implementation of accessors should not use BX_CPU_C_PREFIX. When static
member functions are turned on, BX_CPU_C_PREFIX expands to nothing, and any
  method that uses BX_CPU_C_PREFIX instead of explictly writing "BX_CPU_C::"
  will not be a member function at all.  This makes it impossible for code
  outside the BX_CPU_C object to call the accessor because sometimes the method
  is at ptr_to_cpu->get_EIP() and other times you'd have to do just get_EIP().
  The only way I've found to solve this is to remove the BX_CPU_C_PREFIX
  and write BX_CPU_C:: instead.
- in debug/dbg_main.cc I removed the EBP, EIP, ESP, SP shortcuts. Now
  the accessors are used everywhere.  Also I replaced a reference to
  the short-lived get_erx() accessor with ones that work: get_EAX(), etc.
- with these changes the current cvs compiles with any combination of
  debugger enabled/disabled, SMP enabled/disabled, and x86-64 enabled/disabled.
2002-09-13 18:15:20 +00:00
Kevin Lawton
bb7a9e5341 Merged arith8.cc, stack16.cc. 2002-09-13 17:28:14 +00:00
Kevin Lawton
ac7ca2b035 Changed cpu64 calls to macros:
BX_READ_8BIT_REG()  --> BX_READ_8BIT_REGx()
  BX_WRITE_8BIT_REG() --> BX_WRITE_8BIT_REGx()
They use an extra parameter "extended".  I coded this
as the macro without the "x" for cpu32 compiles.  This
allows for ease of merging and code sharing.
2002-09-13 17:04:14 +00:00
Kevin Lawton
6889c3846f resolve32.cc was redundant, tasking.cc was merged. 2002-09-13 16:23:02 +00:00
Kevin Lawton
f05d453b6c Moved 64-bit only files from cpu64 to cpu and modified the Makefiles
accordingly.  These files cause no conflicts at all, since they
are not used in 32-bit compiles.
2002-09-13 15:53:22 +00:00
Kevin Lawton
bbb20f5d49 Got rid of get_bit{1,3,5,15} accessors to EFLAGS. They were
only used by the debug functions, and those can get the
entire eflags value in one shot now.
2002-09-13 05:03:37 +00:00
Kevin Lawton
8f9c3c582d More migration/synchronization of cpu/cpu64. 2002-09-13 04:33:42 +00:00
Kevin Lawton
c520824de5 Changed configure and the cpu + cpu64 dir Makefiles so it's easy
to incrementally merge files.  For a test, shift16.cc is always
compiled in the cpu/ directory regardless of 32/64-bit configure.
Ultimately, all files will migrate from cpu64 to cpu.
2002-09-13 02:56:14 +00:00
Kevin Lawton
b9d3791aa5 Integrated Stanislav's general register accessors, which model
Bryce's eflags accessors.
2002-09-13 01:09:10 +00:00
Kevin Lawton
6655634179 I merged the cpu/cpu.h and cpu64/cpu.h files as well as the
other header files.  There no longer are any *.h files in cpu64/.
Had to make some changes to the *.cc files for dealing with
accesses to eip.
2002-09-13 00:15:23 +00:00
Christophe Bothamy
ea76dbe210 - fixed compile problem with gcc 2.95 2002-09-12 20:51:48 +00:00
Stanislav Shwartsman
647c1676e9 Added general registers accessors (like for EFLAGS) 2002-09-12 20:00:24 +00:00
Bryce Denney
5d9fa0844e - rename "_long" to "dword" in eip structure in cpu64.
- add get_erx() method to bx_gen_reg_t which returns the erx field of the
  structure (which is has a different name in cpu and cpu64).  Providing
  an accessor is one strategy for avoiding igly "#ifdef BX_SUPPORT_X86_64"
  statements in the rest of the code.
- cpu64/init.cc: the "eflags" before get_flag and set_flag is no longer
  correct. removed.
- modified files: load32bitOShack.cc logio.cc cpu/cpu.h cpu64/apic.cc
  cpu64/cpu.h cpu64/init.cc cpu64/proc_ctrl.cc debug/dbg_main.cc
2002-09-12 18:52:14 +00:00
Bryce Denney
5fc31bcfda - this revision changes the way eflags are accessed throughout the cpu and
cpu64 directories.  Instead of using the macros introduced in cpu.h rev 1.37
  such as GetEFlagsDFLogical and SetEFlagsDF and ClearEFlagsDF, I made inline
  methods on the BX_CPU_C object that access the eflags fields.  The problem
  with the macros is that they cannot be used outside the BX_CPU_C object.  The
  macros have now been removed, and all references to eflags now use these new
  accessors.
- I debated whether to put the accessors as members of the BX_CPU_C object
  or members of the bx_flags_reg_t struct.  I chose to make them members
  of BX_CPU_C for two reasons: 1. the lazy flags are implemented as
  members of BX_CPU_C, and 2. the eflags are referenced in many many places
  and it is more compact without having to put eflags in front of each.  (The
  real problem with compactness is having to write BX_CPU_THIS_PTR in front of
  everything, but that's another story.)
- Kevin pointed out a major bug in my set accessor code.  What a difference a
  little tilde can make!  That is fixed now.
- modified: load32bitOShack.cc debug/dbg_main.cc
  and in both cpu and cpu64 directories:
    cpu.cc cpu.h ctrl_xfer_pro.cc debugstuff.cc exception.cc flag_ctrl.cc
    flag_ctrl_pro.cc init.cc io.cc io_pro.cc proc_ctrl.cc soft_int.cc
    string.cc vm8086.cc
2002-09-12 18:10:46 +00:00
Bryce Denney
22eb32934a - declare class BX_CPU_C early before it's first used 2002-09-12 17:06:40 +00:00
Bryce Denney
0fdbbae45b - integrate Peter Tattam's x86-64 emulation code into the main branch!
This adds a whole new directory cpu64 with the new emulation code.
  Very few changes were necessary outside cpu64.  To try it, configure
  with --enable-x86-64 and make.
- also this adds Peter Tattam's external debugger interface.
- modified files: Makefile.in bochs.h config.h.in configure.in
  load32bitOShack.cc logio.cc cpu/Makefile.in cpu/cpu.cc debug/dbg_main.cc
- added files: cpu/extdb.cc cpu/extdb.h and cpu64/*
2002-09-12 07:16:37 +00:00
Bryce Denney
f4818e6fa3 - bug fix from Peter Tattam that he describes as follows:
> This is the bug fix to make the reset button work properly when the cpu
  > is in the halt state.  There is another patch in init.cc as well to clear
  > async_event.  If you don't do this, if a cpu goes into HLT, the only thing
  > which will fix it is another interrupt.  The reset button won't work.
2002-09-12 06:29:13 +00:00
Bryce Denney
450070850b - the debugger was broken by recent changes in the cpu flags. To provide
a consistent way of accessing these flags that works both inside and
  outside the BX_CPU class, I added inline accessor methods for each
  flag: assert_FLAG(), clear_FLAG(), set_FLAG(value), and get_FLAG ()
  that returns its value.  I use assert to mean "set the value to one"
  to avoid confusion, since there's also a set method that takes a value.
- the eflags access macros (e.g. GetEFlagsDFLogical, ClearEFlagsTF) are
  now defined in terms of the inline accessors.  In most cases it will
  result in the same code anyway.  The major advantage of the accesors
  is that they can be used from inside or outside the BX_CPU object, while
  the macros can only be used from inside.
- since almost all eflags were stored in val32 now, I went ahead and
  removed the if_, rf, and vm fields.  Now the val32 bit is the
  "official" value for these flags, and they have accessors just like
  everything else.
- init.cc: move the registration of registers until after they have been
  initialized so that the initial value of each parameter is correct.

Modified files:
  debug/dbg_main.cc cpu/cpu.h cpu/debugstuff.cc cpu/flag_ctrl.cc
  cpu/flag_ctrl_pro.cc cpu/init.cc
2002-09-11 03:55:22 +00:00
Bryce Denney
41c3bb736d - remove extraneous newline 2002-09-10 18:56:36 +00:00
Kevin Lawton
08576b24be I implemented Global pages. Though, I haven't tested them. :^)
You need to use '--enable-global-pages' to configure in support.
If you have something to boot that uses them, give them a
spin.  Really the were introduced for PPro and above, but
I haven't put in any limits.  CPUID and CR4 report the proper
bits when configured, regardless of --enable-cpu-level at the
moment.
2002-09-10 03:52:32 +00:00
Kevin Lawton
112bf27f29 Fixed bug in tasking.cc found by Scott Duplichan. When paging
if off, we were still reading CR3 from the TSS and reloading
it!  This was causing problems with a DOS extender.  When
paging is turned back on, CR3 would be incorrect.
2002-09-10 01:39:40 +00:00
Kevin Lawton
425ad824c0 I changed the TLB entry from 3 dwords to 4, and (when you compile
with GCC) align them with the GCC special alignment attribute.
Since there was then one available field, I split the protection
attributes and native host pointers into their own fields.

Before, with 3 dwords per TLB entry, some entries (about 3/8)
were spanning two processor cache lines (assuming a 32-byte
cache line).  Now, they all fit within one cache line.

Knocked about 1.4% off Win95 boot time, probably more off normal
software runs.
2002-09-10 00:01:01 +00:00
Kevin Lawton
59d00a46a3 Fixed two calls to dtranslate_linear in paging.cc to use
BX_READ not 0.  BX_READ was 10.  While I was at it, I did
change BX_{READ,WRITE,RW} to {0,1,2} rather than {10,11,12}
in case that helps optimize code.

There may be more paging checks we should do before changing
any state, to avoid receiving a page fault in the middle.
I put some extra comments in there.
2002-09-09 21:59:10 +00:00
uid94540
293cbc01ea Got rid of very old BX_SUPPORT_TASKING define. That originated
way back when I first added paging support.
2002-09-09 19:48:58 +00:00
Kevin Lawton
1e22357b06 Very small #ifdef mods so that all the static functions would
be compiled out, when MMX is not enabled for a compile.  Eliminates
the unused warnings from the compiler.
2002-09-09 17:13:13 +00:00
Kevin Lawton
414e97bc32 Enhanced the repeat IO accelerations (enabled by --enable-repeat-speedups)
to request bulk IO operations to IO devices which are bulk IO aware.
Currently, I modified only harddrv.cc to be aware.  I added some
fields to the bx_devices_c class for the IO instructions to
place requests and receive responses from the IO device emulation.
Devices except the hard drive, don't monitor these fields so they
respond as normal.  The hard drive now monitors these fields for
bulk requests, and if enabled, it memcpy()'s data straight from
the disk buffer to memory.  This eliminates numerous inp/outp calling
sequences per disk sector.

I used the fields in bx_devices_c so that I would not have to
disrupt most IO device modules.  Enhancements can be made to
other devices if they use high-bandwidth IO via in/out instructions.
2002-09-09 16:56:56 +00:00
Bryce Denney
be659a09b3 - check in Stanislav Shwartsman's patch "bochs-mmx.patch-endian-support".
He writes: Detailed description: MMX instruction set support.
  Also supports BIG_ENDIAN systems. Tested on Solaris and HP1100.
- modified files:
    configure.in cpu/Makefile.in cpu/cpu.h cpu/fetchdecode.cc
    cpu/proc_ctrl.cc fpu/fpu_system.h fpu/wmFPUemu_glue.cc
- added files: cpu/i387.h cpu/mmx.cc
2002-09-09 16:11:25 +00:00
Kevin Lawton
0d7a5fdf3c I rehashed the way the EFLAGS register was stored internally.
All the EFLAGS bits used to be cached in separate fields.  I left
a few of them in separate fields for now - might remove them
at some point also.  When the arithmetic fields are known
(ie they're not in lazy mode), they are all cached in a
32-bit EFLAGS image, just like the x86 EFLAGS register expects.
All other eflags are store in the 32-bit register also, with
a few also mirrored in separate fields for now.

The reason I did this, was so that on x86 hosts, asm() statements
can be #ifdef'd in to do the calculation and get the native
eflags results very cheaply.  Just to test that it works, I
coded ADD_EdId() and ADD_EwIw() with some conditionally compiled
asm()s for accelerated eflags processing and it works.

-Kevin
2002-09-08 04:08:14 +00:00
Kevin Lawton
51c93e12a1 The paging unit gets notified of all CR0/CR3/CR4 updates so
it can decide how to proceed.  Some of those bits are necessary
to make TLB invalidation decisions.  INVLPG doesn't cause
a whole TLB flush anymore, just one page.  Some of the
current CPU behaviours model the P6, especially on CR0
reloads.  Earlier processors kept some pre-change pre-fetched
instructions until a branch.  We could probably model that
by setting a flag, and letting the revalidate_prefetch_q
function cause serialization.

The TLB flush code only invalidates entries which are not
already invalidated for the case where the TLB invalidation
ID trick is not in use.
2002-09-07 05:21:28 +00:00
Kevin Lawton
491035fcb2 I extended the guest-to-host TLB acceleration across the
Read-Modify-Write instructions.  The first read phase stores
the host pointer in the "pages" field if a direct use pointer
is available.  The Write phase first checks if a pointer was
issued and uses it for a direct write if available.

I chose the "pages" field since it needs to be checked by the
write_RMW_virtual variants anyways and thus needs to be
cached anyways.

Mostly the mods where to access.cc, but I did also macro-ize
the calls to write_RMW_virtual...() in files which use it
and cpu.h.  Right now, the macro is just a straight pass-through.
I tried expanding it to a quick initial check for the pointer
availability to do the write in-place, with a function call
as a fall-back.  That didn't seemed to matter at all.

Booting is not helped by this really.  The upper bound of
the gain is 5 or 6%, and that's only if you have a loop that
looks like:

label:
  add [eax], ebx   ;; mega read-modify-write instruction
  jmp label        ;; intensive loop.
2002-09-06 21:54:58 +00:00
Gregory Alexander
4f6039f533 Macroize BX_TLB_QUICK_INVALIDATE code.
Kevin Lawton says he doesn't get a performance benefit.

I'm not sure if I do.  Either way, the difference isn't
very large.

This code may get removed if it turns out to be useless.
2002-09-06 19:21:55 +00:00
Bryce Denney
80a3900b8b - apply a patch I've been working on
- modified files: config.h.in cpu/init.cc debug/dbg_main.cc gui/control.cc
  gui/siminterface.cc gui/siminterface.h gui/wxdialog.cc gui/wxdialog.h
  gui/wxmain.cc gui/wxmain.h iodev/keyboard.cc

----------------------------------------------------------------------
Patch name: patch.wx-show-cpu2
Author: Bryce Denney
Date: Fri Sep  6 12:13:28 EDT 2002

Description:

Second try at implementing the "Debug:Show Cpu" and "Debug:Show
Keyboard" dialog with values that change as the simulation proceeds.
(Nobody gets to see the first try.)  This is the first step toward
making something resembling a wxWindows debugger.

First, variables which are going to be visible in the CI must be
registered as parameters.  For some variables, it might be acceptable
to change them from Bit32u into bx_param_num_c and access them only
with set/get methods, but for most variables it would be a horrible
pain and wreck performance.

To deal with this, I introduced the concept of a shadow parameter.  A
normal parameter has its value stored inside the struct, but a shadow
parameter has only a pointer to the value.  Shadow params allow you to
treat any variable as if it was a parameter, without having to change
its type and access it using get/set methods.  Of course, a shadow
param's value is controlled by someone else, so it can change at any
time.

To demonstrate and test the registration of shadow parameters, I
added code in cpu/init.cc to register a few CPU registers and
code in iodev/keyboard.cc to register a few keyboard state values.
Now these parameters are visible in the Debug:Show CPU and
Debug:Show Keyboard dialog boxes.

The Debug:Show* dialog boxes are created by the ParamDialog class,
which already understands how to display each type of parameter,
including the new shadow parameters (because they are just a subclass
of a normal parameter class).  I have added a ParamDialog::Refresh()
method, which rereads the value from every parameter that it is
displaying and changes the displayed value.  At the moment, in the
Debug:Show CPU dialog, changing the values has no effect.  However
this is trivial to add when it's time (just call CommitChanges!).  It
wouldn't really make sense to change the values unless you have paused
the simulation, for example when single stepping with the debugger.

The Refresh() method must be called periodically or else the dialog
will show the initial values forever.  At the moment, Refresh() is
called when the simulator sends an async event called
BX_ASYNC_EVT_REFRESH, created by a call to SIM->refresh_ci ().

Details:
- implement shadow parameter class for Bit32s, called bx_shadow_num_c.
  implement shadow parameter class for Boolean, called bx_shadow_bool_c.
  more to follow (I need one for every type!)
- now the simulator thread can request that the config interface refresh
  its display.  For now, the refresh event causes the CI to check every
  parameter it is watching and change the display value.  Later, it may
  be worth the trouble to keep track of which parameters have actually
  changed.  Code in the simulator thread calls SIM->refresh_ci(), which
  creates an async event called BX_ASYNC_EVT_REFRESH and sends it to
  the config interface.  When it arrives in the wxWindows gui thread,
  it calls RefreshDialogs(), which calls the Refresh() method on any
  dialogs that might need it.
- in the debugger, SIM->refresh_ci() is called before every prompt
  is printed.  Otherwise, the refresh would wait until the next
  SIM->periodic(), which might be thousands of cycles.  This way,
  when you're single stepping, the dialogs update with every step.
- To improve performance, the CI has a flag (MyFrame::WantRefresh())
  which tells whether it has any need for refresh events.  If no
  dialogs are showing that need refresh events, then no event is sent
  between threads.
- add a few defaults to the param classes that affect the settings of
  newly created parameters.  When declaring a lot of params with
  similar settings it's more compact to set the default for new params
  rather than to change each one separately.  default_text_format is
  the printf format string for displaying numbers.  default_base is
  the default base for displaying numbers (0, 16, 2, etc.)
- I added to ParamDialog to make it able to display modeless dialog
  boxes such as "Debug:Show CPU".  The new Refresh() method queries
  all the parameters for their current value and changes the value in
  the wxWindows control.  The ParamDialog class still needs a little
  work; for example, if it's modal it should have Cancel/Ok buttons,
  but if it's going to be modeless it should maybe have Apply (commit
  any changes) and Close.
2002-09-06 16:43:26 +00:00
Gregory Alexander
afdccad36c Oops, had to fix a bunch of parentheses.
Why | has precedence under == (or is it =)
I still don't understand.
2002-09-06 16:29:49 +00:00
Gregory Alexander
1c3ae99300 Speed-up for TLB invalidates as proposed by Peter Tattam.
I had been planning on this same thing in a similar form
for the I$, so this made a lot of sense, and was easy to
implement.
2002-09-06 14:58:56 +00:00
Bryce Denney
85b3dfe60f - fix minor problems with static member function declarations:
- bx_gen_reg cannot be declared with BX_SMF or it can't read gen_reg
    when static member functions are turned on.
  - use "BX_CPU_C_PREFIX" instead of "BX_CPU_C::" for get_segment_base.
- the SMF (static member function) tricks are just plain wierd. The only way to
  really be sure that you're not breaking something is to try compiling it with
  SMF on and with SMF off.  e.g. "configure && make" and
  "configure --enable-processors=2 && make".
2002-09-05 20:16:40 +00:00
Stanislav Shwartsman
2d2651a0f3 Added some useful debug/information methods for BX_CPU class 2002-09-05 19:46:20 +00:00
Stanislav Shwartsman
611d983900 Added get_REGISTER functions for all registers 2002-09-05 19:12:02 +00:00
Kevin Lawton
f29f9ef021 Fixed Big-endian case of --enable-guest2host-tlb. I macro'ized the
direct reads/writes from native variables to the x86 (guest)
memory image.  Look at the end of bochs.h.  Don't know if that's
the right place to put them, but here you can extend these
macros to platform-specific asm() code if you like, or just
use the generic C code I supplied.  Some platforms have special
instructions for byte-order swapping etc.  Also, you can't
make any assumptions about the alignment of the pointers
passed.
2002-09-05 04:56:11 +00:00
Kevin Lawton
83eb7d4199 Updated comments with info on the new TLB permissions storage
and strategy, so that others can understand it.
2002-09-05 03:09:59 +00:00
Kevin Lawton
f0c9896964 Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB.  This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.

Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on.  Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.

I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 02:31:24 +00:00
Kevin Lawton
8a1baa6bb8 Added ::{read,write}_virtual_qword() functions as per Stanislav's request.
I have not tested these functions, but they model the format and
acceleration principals of the byte/word/dword functions.  Give them
a try on both little/big endian machines.
2002-09-04 20:23:54 +00:00
Kevin Lawton
d07c1c0bb0 I rehashed the way the paging code stores protection bits,
so that a compare of the current access could be done more
efficiently against the cached values, both in the normal
paging routines, and in the accelerated code in access.cc.

This cut down the amount of code path needed to get to
direct use of a host address nicely, and speed definitely
got a boost as a result, especially if you use the
--enable-guest2host-tlb option.

The CR0.WP flag was a real pain, because it imparts
a complication on the way protections work.  Fortunately
it's not a high-change flag, so I just base the new
cached info on the current CR0.WP value, and dump
the TLB cache when it changes.
2002-09-04 08:59:13 +00:00
Kevin Lawton
54bc40971c Fixed repeated IO/string instruction acceleration bug. Not all the
checks were honoring the EFLAGS.DF bit, but assuming it was always
equal to 0 (increment upward).  Plus some general cleanup of the
acceleration code.

I left the default of '--enable-repeat-speedups' to disabled, but
it seems pretty solid.  Definitely adds performance for disk
heavy workloads.
2002-09-03 19:38:27 +00:00
Bryce Denney
765f21fbc3 - disable #warning on MSVC++ because it doesn't understand it 2002-09-03 15:56:24 +00:00
Kevin Lawton
3f2d28f86c Added guest2host TLB tricks to read-modify-write variants of
access routines in access.cc, completing the upgrade of
those routines.  You do need '--enable-guest2host-tlb', before
you get the speedups for now.  The guest2host mods seem pretty
solid, though I do need to see what effects the A20 line has
on this cache and the paging TLB in general.
2002-09-03 04:54:28 +00:00
Kevin Lawton
746f09b427 There's a bug in the repeated IO & mem copy speedups. I
added --enable-repeat-speedups with default to disabled.
Reconfigure/recompile and the speedup code will be #ifdef'd
out for now.  It manifested as junk written to the VGA screen
while booting/running Windows.

Also made some more mods to the main cpu loop.  Moved the
handling of EXT/errorno outside the main loop, much like
the extra EIP/ESP commits were moved, for a little better
performance.

I changed the fetch_ptr/bytesleft method of fetching to
a slightly different model, which calculates a window
for which EIP will be valid (land on the current page),
and a bias which when applied to EIP will be from
0..upper_page_limit.  Speed is about the same for either
method, but a pseudo-op/threaded-interpreter will plug
in better with this and be faster.
2002-09-02 18:44:35 +00:00
Kevin Lawton
3d8e5f8b61 Removed the BX_FETCHDECODE_CACHE mods, and the patch that
Bryce created for use of ensuring all mods were removed
cleanly.
2002-09-01 23:02:36 +00:00
Kevin Lawton
3a5f338419 Integrated patches for:
- Paging code rehash.  You must now use --enable-4meg-pages to
    use 4Meg pages, with the default of disabled, since we don't well
    support 4Meg pages yet.  Paging table walks model a real CPU
    more closely now, and I fixed some bugs in the old logic.
  - Segment check redundancy elimination.  After a segment is loaded,
    reads and writes are marked when a segment type check succeeds, and
    they are skipped thereafter, when possible.
  - Repeated IO and memory string copy acceleration.  Only some variants
    of instructions are available on all platforms, word and dword
    variants only on x86 for the moment due to alignment and endian issues.
    This is compiled in currently with no option - I should add a configure
    option.
  - Added a guest linear address to host TLB.  Actually, I just stick
    the host address (mem.vector[addr] address) in the upper 29 bits
    of the field 'combined_access' since they are unused.  Convenient
    for now.  I'm only storing page frame addresses.  This was the
    simplest for of such a TLB.  We can likely enhance this.  Also,
    I only accelerated the normal read/write routines in access.cc.
    Could also modify the read-modify-write versions too.  You must
    use --enable-guest2host-tlb, to try this out.  Currently speeds
    up Win95 boot time by about 3.5% for me.  More ground to cover...
  - Minor mods to CPUI/MOV_CdRd for CMOV.
  - Integrated enhancements from Volker to getHostMemAddr() for PCI
    being enabled.
2002-09-01 20:12:09 +00:00
Kevin Lawton
d52b23daf1 Made some very minor mods, to make CPUID aware of CMOV instructions
for BX_CPU_LEVEL >= 6, and to have the CMOV instructions generate
an undefined opcode exception after printing info that they were
called, if BX_CPU_LEVEL <= 5.  I suppose we could have a separate
configure option, but mirroring Intel, CMOV is available as of
Pentium Pro.

For now, you have to compile with --enable-cpu-level=6 for CMOV
support to be compiled in.
2002-09-01 04:01:14 +00:00
Volker Ruppert
38666a2cfb - PCI memory handling moved to bx_mem_c
* shadow RAM array and fetch function are now a part of the memory code
  * removed unnecessary PCI macros and functions load_ROM() and mem_read()
2002-08-31 12:24:41 +00:00
Bryce Denney
44ec9a0fc8 - update Makefile dependencies on nearly everything 2002-08-27 22:43:57 +00:00
Bryce Denney
10f56f60d1 - I thought I would add mmx.o ONLY when --enable-mmx was present. Stanislav
has been assuming we would compile mmx.o all the time, so I took out the
  conditional compile stuff.
2002-08-26 19:07:00 +00:00