Commit Graph

172 Commits

Author SHA1 Message Date
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