2001-10-03 17:10:38 +04:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 00:54:04 +03:00
|
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2011-07-07 00:01:18 +04:00
|
|
|
|
// Copyright (C) 2001-2011 The Bochs Project
|
2001-04-10 05:04:59 +04:00
|
|
|
|
//
|
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-01-10 14:30:20 +03:00
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-10-14 23:04:51 +04:00
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2001-05-24 22:46:34 +04:00
|
|
|
|
#define NEED_CPU_REG_SHORTCUTS 1
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#include "bochs.h"
|
2006-03-07 01:03:16 +03:00
|
|
|
|
#include "cpu.h"
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
|
#define LOG_THIS BX_CPU_THIS_PTR
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2010-02-26 17:18:19 +03:00
|
|
|
|
#include "param_names.h"
|
|
|
|
|
|
2011-07-29 19:24:32 +04:00
|
|
|
|
BX_CPU_C::BX_CPU_C(unsigned id): bx_cpuid(id)
|
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
|
|
|
|
, cpuid(NULL)
|
|
|
|
|
#endif
|
2001-06-12 17:07:43 +04:00
|
|
|
|
#if BX_SUPPORT_APIC
|
2009-02-20 20:26:01 +03:00
|
|
|
|
,lapic (this, id)
|
2001-05-23 12:16:07 +04:00
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
{
|
2001-05-23 12:16:07 +04:00
|
|
|
|
// in case of SMF, you cannot reference any member data
|
|
|
|
|
// in the constructor because the only access to it is via
|
|
|
|
|
// global variables which aren't initialized quite yet.
|
2009-02-20 20:26:01 +03:00
|
|
|
|
char buffer[16];
|
|
|
|
|
sprintf(buffer, "CPU%x", bx_cpuid);
|
|
|
|
|
put(buffer);
|
2011-07-28 20:17:42 +04:00
|
|
|
|
|
2011-09-25 21:36:20 +04:00
|
|
|
|
isa_extensions_bitmask = BX_SUPPORT_FPU ? BX_ISA_X87 : 0;
|
2011-07-28 20:17:42 +04:00
|
|
|
|
cpu_extensions_bitmask = 0;
|
2011-09-26 16:31:40 +04:00
|
|
|
|
#if BX_SUPPORT_VMX
|
|
|
|
|
vmx_extensions_bitmask = 0;
|
|
|
|
|
#endif
|
2001-05-23 12:16:07 +04:00
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
- 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 20:43:26 +04:00
|
|
|
|
#if BX_WITH_WX
|
- 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 07:55:22 +04:00
|
|
|
|
|
2006-03-07 23:32:07 +03:00
|
|
|
|
#define IF_SEG_REG_GET(x) \
|
|
|
|
|
if (!strcmp(param->get_name(), #x)) { \
|
2006-03-09 23:16:17 +03:00
|
|
|
|
return BX_CPU(cpu)->sregs[BX_SEG_REG_##x].selector.value; \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
|
|
|
|
#define IF_SEG_REG_SET(reg, val) \
|
|
|
|
|
if (!strcmp(param->get_name(), #reg)) { \
|
2006-03-09 23:16:17 +03:00
|
|
|
|
BX_CPU(cpu)->load_seg_reg(&BX_CPU(cpu)->sregs[BX_SEG_REG_##reg],val); \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
|
|
|
|
#define IF_LAZY_EFLAG_GET(flag) \
|
|
|
|
|
if (!strcmp(param->get_name(), #flag)) { \
|
2006-03-09 23:16:17 +03:00
|
|
|
|
return BX_CPU(cpu)->get_##flag(); \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
|
|
|
|
#define IF_LAZY_EFLAG_SET(flag, val) \
|
|
|
|
|
if (!strcmp(param->get_name(), #flag)) { \
|
2006-03-09 23:16:17 +03:00
|
|
|
|
BX_CPU(cpu)->set_##flag(val); \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
|
|
|
|
#define IF_EFLAG_GET(flag) \
|
|
|
|
|
if (!strcmp(param->get_name(), #flag)) { \
|
2006-03-09 23:16:17 +03:00
|
|
|
|
return BX_CPU(cpu)->get_##flag(); \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
|
|
|
|
#define IF_EFLAG_SET(flag, val) \
|
|
|
|
|
if (!strcmp(param->get_name(), #flag)) { \
|
2006-03-09 23:16:17 +03:00
|
|
|
|
BX_CPU(cpu)->set_##flag(val); \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
- 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 07:55:22 +04:00
|
|
|
|
|
|
|
|
|
|
- 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 20:43:26 +04:00
|
|
|
|
// implement get/set handler for parameters that need unusual set/get
|
2006-03-07 23:32:07 +03:00
|
|
|
|
static Bit64s cpu_param_handler(bx_param_c *param, int set, Bit64s val)
|
- 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 20:43:26 +04:00
|
|
|
|
{
|
2006-04-16 14:12:32 +04:00
|
|
|
|
#if BX_SUPPORT_SMP
|
2006-03-09 23:16:17 +03:00
|
|
|
|
int cpu = atoi(param->get_parent()->get_name());
|
2006-04-16 14:12:32 +04:00
|
|
|
|
#endif
|
- 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 07:55:22 +04:00
|
|
|
|
if (set) {
|
2006-03-07 23:32:07 +03:00
|
|
|
|
if (!strcmp(param->get_name(), "LDTR")) {
|
2006-03-09 23:16:17 +03:00
|
|
|
|
BX_CPU(cpu)->panic("setting LDTR not implemented");
|
- 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 20:43:26 +04:00
|
|
|
|
}
|
2006-03-07 23:32:07 +03:00
|
|
|
|
if (!strcmp(param->get_name(), "TR")) {
|
2006-03-09 23:16:17 +03:00
|
|
|
|
BX_CPU(cpu)->panic("setting LDTR not implemented");
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
|
|
|
|
IF_SEG_REG_SET(CS, val);
|
|
|
|
|
IF_SEG_REG_SET(DS, val);
|
|
|
|
|
IF_SEG_REG_SET(SS, val);
|
|
|
|
|
IF_SEG_REG_SET(ES, val);
|
|
|
|
|
IF_SEG_REG_SET(FS, val);
|
|
|
|
|
IF_SEG_REG_SET(GS, val);
|
|
|
|
|
IF_LAZY_EFLAG_SET(OF, val);
|
|
|
|
|
IF_LAZY_EFLAG_SET(SF, val);
|
|
|
|
|
IF_LAZY_EFLAG_SET(ZF, val);
|
|
|
|
|
IF_LAZY_EFLAG_SET(AF, val);
|
|
|
|
|
IF_LAZY_EFLAG_SET(PF, val);
|
|
|
|
|
IF_LAZY_EFLAG_SET(CF, val);
|
|
|
|
|
IF_EFLAG_SET(ID, val);
|
|
|
|
|
IF_EFLAG_SET(VIP, val);
|
|
|
|
|
IF_EFLAG_SET(VIF, val);
|
|
|
|
|
IF_EFLAG_SET(AC, val);
|
|
|
|
|
IF_EFLAG_SET(VM, val);
|
|
|
|
|
IF_EFLAG_SET(RF, val);
|
|
|
|
|
IF_EFLAG_SET(NT, val);
|
|
|
|
|
IF_EFLAG_SET(IOPL, val);
|
|
|
|
|
IF_EFLAG_SET(DF, val);
|
|
|
|
|
IF_EFLAG_SET(IF, val);
|
|
|
|
|
IF_EFLAG_SET(TF, val);
|
- 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 20:43:26 +04:00
|
|
|
|
} else {
|
2006-03-07 23:32:07 +03:00
|
|
|
|
if (!strcmp(param->get_name(), "LDTR")) {
|
2006-03-09 23:16:17 +03:00
|
|
|
|
return BX_CPU(cpu)->ldtr.selector.value;
|
2006-03-07 23:32:07 +03:00
|
|
|
|
}
|
|
|
|
|
if (!strcmp(param->get_name(), "TR")) {
|
2006-03-09 23:16:17 +03:00
|
|
|
|
return BX_CPU(cpu)->tr.selector.value;
|
- 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 20:43:26 +04:00
|
|
|
|
}
|
2006-03-07 23:32:07 +03:00
|
|
|
|
IF_SEG_REG_GET (CS);
|
|
|
|
|
IF_SEG_REG_GET (DS);
|
|
|
|
|
IF_SEG_REG_GET (SS);
|
|
|
|
|
IF_SEG_REG_GET (ES);
|
|
|
|
|
IF_SEG_REG_GET (FS);
|
|
|
|
|
IF_SEG_REG_GET (GS);
|
|
|
|
|
IF_LAZY_EFLAG_GET(OF);
|
|
|
|
|
IF_LAZY_EFLAG_GET(SF);
|
|
|
|
|
IF_LAZY_EFLAG_GET(ZF);
|
|
|
|
|
IF_LAZY_EFLAG_GET(AF);
|
|
|
|
|
IF_LAZY_EFLAG_GET(PF);
|
|
|
|
|
IF_LAZY_EFLAG_GET(CF);
|
|
|
|
|
IF_EFLAG_GET(ID);
|
|
|
|
|
IF_EFLAG_GET(VIP);
|
|
|
|
|
IF_EFLAG_GET(VIF);
|
|
|
|
|
IF_EFLAG_GET(AC);
|
|
|
|
|
IF_EFLAG_GET(VM);
|
|
|
|
|
IF_EFLAG_GET(RF);
|
|
|
|
|
IF_EFLAG_GET(NT);
|
|
|
|
|
IF_EFLAG_GET(IOPL);
|
|
|
|
|
IF_EFLAG_GET(DF);
|
|
|
|
|
IF_EFLAG_GET(IF);
|
|
|
|
|
IF_EFLAG_GET(TF);
|
- 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 20:43:26 +04:00
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
}
|
2006-03-07 23:32:07 +03:00
|
|
|
|
#undef IF_SEG_REG_GET
|
|
|
|
|
#undef IF_SEG_REG_SET
|
- 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 07:55:22 +04:00
|
|
|
|
|
- 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 20:43:26 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-07-29 19:24:32 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
|
|
|
|
|
2011-07-28 20:17:42 +04:00
|
|
|
|
#include "generic_cpuid.h"
|
|
|
|
|
|
2011-07-31 22:43:46 +04:00
|
|
|
|
#define bx_define_cpudb(model) \
|
|
|
|
|
extern bx_cpuid_t *create_ ##model##_cpuid(BX_CPU_C *cpu);
|
|
|
|
|
|
|
|
|
|
#include "cpudb.h"
|
|
|
|
|
|
|
|
|
|
#undef bx_define_cpudb
|
2011-07-29 19:03:54 +04:00
|
|
|
|
|
|
|
|
|
static bx_cpuid_t *cpuid_factory(BX_CPU_C *cpu)
|
|
|
|
|
{
|
|
|
|
|
unsigned cpu_model = SIM->get_param_enum(BXPN_CPU_MODEL)->get();
|
2011-07-31 22:43:46 +04:00
|
|
|
|
|
|
|
|
|
#define bx_define_cpudb(model) \
|
|
|
|
|
case bx_cpudb_##model: \
|
|
|
|
|
return create_ ##model##_cpuid(cpu);
|
|
|
|
|
|
2011-07-29 19:03:54 +04:00
|
|
|
|
switch(cpu_model) {
|
2011-07-31 22:43:46 +04:00
|
|
|
|
#include "cpudb.h"
|
2011-07-29 19:03:54 +04:00
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2011-07-31 22:43:46 +04:00
|
|
|
|
#undef bx_define_cpudb
|
2011-07-29 19:03:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-29 19:24:32 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2009-02-20 20:26:01 +03:00
|
|
|
|
// BX_CPU_C constructor
|
2008-04-27 23:49:02 +04:00
|
|
|
|
void BX_CPU_C::initialize(void)
|
2001-05-23 12:16:07 +04:00
|
|
|
|
{
|
2010-02-26 01:04:31 +03:00
|
|
|
|
BX_CPU_THIS_PTR set_INTR(0);
|
|
|
|
|
|
2011-07-29 19:24:32 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
2011-07-29 19:03:54 +04:00
|
|
|
|
BX_CPU_THIS_PTR cpuid = cpuid_factory(this);
|
|
|
|
|
if (! BX_CPU_THIS_PTR cpuid)
|
|
|
|
|
BX_PANIC(("Failed to create CPUID module !"));
|
2011-07-28 20:17:42 +04:00
|
|
|
|
|
|
|
|
|
BX_CPU_THIS_PTR isa_extensions_bitmask = cpuid->get_isa_extensions_bitmask();
|
|
|
|
|
BX_CPU_THIS_PTR cpu_extensions_bitmask = cpuid->get_cpu_extensions_bitmask();
|
2011-09-26 16:31:40 +04:00
|
|
|
|
#if BX_SUPPORT_VMX
|
|
|
|
|
BX_CPU_THIS_PTR vmx_extensions_bitmask = cpuid->get_vmx_extensions_bitmask();
|
|
|
|
|
#endif
|
2011-07-29 19:24:32 +04:00
|
|
|
|
#endif
|
2011-04-21 17:27:42 +04:00
|
|
|
|
|
2010-04-03 09:59:07 +04:00
|
|
|
|
init_FetchDecodeTables(); // must be called after init_isa_features_bitmask()
|
2006-01-11 21:22:12 +03:00
|
|
|
|
|
2008-12-28 23:30:48 +03:00
|
|
|
|
#if BX_CONFIGURE_MSRS
|
2009-01-08 21:07:44 +03:00
|
|
|
|
for (unsigned n=0; n < BX_MSR_MAX_INDEX; n++) {
|
2008-12-28 23:30:48 +03:00
|
|
|
|
BX_CPU_THIS_PTR msrs[n] = 0;
|
|
|
|
|
}
|
|
|
|
|
const char *msrs_filename = SIM->get_param_string(BXPN_CONFIGURABLE_MSRS_PATH)->getptr();
|
|
|
|
|
load_MSRs(msrs_filename);
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-03-05 21:54:23 +03:00
|
|
|
|
// ignore bad MSRS if user asked for it
|
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
|
|
|
|
BX_CPU_THIS_PTR ignore_bad_msrs = SIM->get_param_bool(BXPN_IGNORE_BAD_MSRS)->get();
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-01-18 01:35:45 +03:00
|
|
|
|
init_SMRAM();
|
|
|
|
|
|
2009-01-31 13:43:24 +03:00
|
|
|
|
#if BX_SUPPORT_VMX
|
|
|
|
|
init_VMCS();
|
|
|
|
|
#endif
|
|
|
|
|
|
- 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 07:55:22 +04:00
|
|
|
|
#if BX_WITH_WX
|
2007-10-14 23:04:51 +04:00
|
|
|
|
register_wx_state();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if BX_WITH_WX
|
|
|
|
|
void BX_CPU_C::register_wx_state(void)
|
|
|
|
|
{
|
2006-06-06 22:36:50 +04:00
|
|
|
|
if (SIM->get_param(BXPN_WX_CPU_STATE) != NULL) {
|
2002-10-01 02:18:53 +04:00
|
|
|
|
// Register some of the CPUs variables as shadow parameters so that
|
|
|
|
|
// they can be visible in the config interface.
|
|
|
|
|
// (Experimental, obviously not a complete list)
|
|
|
|
|
bx_param_num_c *param;
|
2006-09-07 22:50:51 +04:00
|
|
|
|
char cpu_name[10], cpu_title[10], cpu_pname[16];
|
2002-10-01 02:18:53 +04:00
|
|
|
|
const char *fmt16 = "%04X";
|
|
|
|
|
const char *fmt32 = "%08X";
|
2006-03-07 23:32:07 +03:00
|
|
|
|
Bit32u oldbase = bx_param_num_c::set_default_base(16);
|
|
|
|
|
const char *oldfmt = bx_param_num_c::set_default_format(fmt32);
|
2006-03-09 23:16:17 +03:00
|
|
|
|
sprintf(cpu_name, "%d", BX_CPU_ID);
|
|
|
|
|
sprintf(cpu_title, "CPU %d", BX_CPU_ID);
|
2006-09-07 22:50:51 +04:00
|
|
|
|
sprintf(cpu_pname, "%s.%d", BXPN_WX_CPU_STATE, BX_CPU_ID);
|
|
|
|
|
if (SIM->get_param(cpu_pname) == NULL) {
|
2008-02-03 00:46:54 +03:00
|
|
|
|
bx_list_c *list = new bx_list_c(SIM->get_param(BXPN_WX_CPU_STATE),
|
2006-09-07 22:50:51 +04:00
|
|
|
|
cpu_name, cpu_title, 60);
|
2006-05-30 02:33:38 +04:00
|
|
|
|
|
- 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 07:55:22 +04:00
|
|
|
|
#define DEFPARAM_NORMAL(name,field) \
|
2006-05-27 19:54:49 +04:00
|
|
|
|
new bx_shadow_num_c(list, #name, &(field))
|
2006-03-07 23:32:07 +03:00
|
|
|
|
|
|
|
|
|
DEFPARAM_NORMAL(EAX, EAX);
|
|
|
|
|
DEFPARAM_NORMAL(EBX, EBX);
|
|
|
|
|
DEFPARAM_NORMAL(ECX, ECX);
|
|
|
|
|
DEFPARAM_NORMAL(EDX, EDX);
|
|
|
|
|
DEFPARAM_NORMAL(ESP, ESP);
|
|
|
|
|
DEFPARAM_NORMAL(EBP, EBP);
|
|
|
|
|
DEFPARAM_NORMAL(ESI, ESI);
|
|
|
|
|
DEFPARAM_NORMAL(EDI, EDI);
|
|
|
|
|
DEFPARAM_NORMAL(EIP, EIP);
|
2008-05-23 21:49:46 +04:00
|
|
|
|
DEFPARAM_NORMAL(DR0, dr[0]);
|
|
|
|
|
DEFPARAM_NORMAL(DR1, dr[1]);
|
|
|
|
|
DEFPARAM_NORMAL(DR2, dr[2]);
|
|
|
|
|
DEFPARAM_NORMAL(DR3, dr[3]);
|
2011-03-15 23:20:15 +03:00
|
|
|
|
DEFPARAM_NORMAL(DR6, dr6.val32);
|
|
|
|
|
DEFPARAM_NORMAL(DR7, dr7.val32);
|
2006-03-07 23:32:07 +03:00
|
|
|
|
DEFPARAM_NORMAL(CR0, cr0.val32);
|
|
|
|
|
DEFPARAM_NORMAL(CR2, cr2);
|
|
|
|
|
DEFPARAM_NORMAL(CR3, cr3);
|
2011-08-16 20:49:04 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
2007-07-09 19:16:14 +04:00
|
|
|
|
DEFPARAM_NORMAL(CR4, cr4.val32);
|
- 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 23:39:38 +04:00
|
|
|
|
#endif
|
- 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 07:55:22 +04:00
|
|
|
|
|
2006-09-07 22:50:51 +04:00
|
|
|
|
// segment registers require a handler function because they have
|
|
|
|
|
// special get/set requirements.
|
- 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 07:55:22 +04:00
|
|
|
|
#define DEFPARAM_SEG_REG(x) \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
param = new bx_param_num_c(list, \
|
|
|
|
|
#x, #x, "", 0, 0xffff, 0); \
|
|
|
|
|
param->set_handler(cpu_param_handler); \
|
|
|
|
|
param->set_format(fmt16);
|
- 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 07:55:22 +04:00
|
|
|
|
#define DEFPARAM_GLOBAL_SEG_REG(name,field) \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
param = new bx_shadow_num_c(list, \
|
2008-02-01 00:44:28 +03:00
|
|
|
|
#name"_base", &(field.base)); \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
param = new bx_shadow_num_c(list, \
|
2008-02-01 00:44:28 +03:00
|
|
|
|
#name"_limit", &(field.limit));
|
2002-10-01 02:18:53 +04:00
|
|
|
|
|
2006-09-07 22:50:51 +04:00
|
|
|
|
DEFPARAM_SEG_REG(CS);
|
|
|
|
|
DEFPARAM_SEG_REG(DS);
|
|
|
|
|
DEFPARAM_SEG_REG(SS);
|
|
|
|
|
DEFPARAM_SEG_REG(ES);
|
|
|
|
|
DEFPARAM_SEG_REG(FS);
|
|
|
|
|
DEFPARAM_SEG_REG(GS);
|
|
|
|
|
DEFPARAM_SEG_REG(LDTR);
|
|
|
|
|
DEFPARAM_SEG_REG(TR);
|
2008-01-30 01:29:48 +03:00
|
|
|
|
DEFPARAM_GLOBAL_SEG_REG(GDTR, BX_CPU_THIS_PTR gdtr);
|
|
|
|
|
DEFPARAM_GLOBAL_SEG_REG(IDTR, BX_CPU_THIS_PTR idtr);
|
2006-05-01 22:24:47 +04:00
|
|
|
|
#undef DEFPARAM_NORMAL
|
2006-04-22 22:14:55 +04:00
|
|
|
|
#undef DEFPARAM_SEG_REG
|
|
|
|
|
#undef DEFPARAM_GLOBAL_SEG_REG
|
- 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 07:55:22 +04:00
|
|
|
|
|
2006-09-07 22:50:51 +04:00
|
|
|
|
param = new bx_shadow_num_c(list, "EFLAGS",
|
2008-01-30 01:26:29 +03:00
|
|
|
|
&BX_CPU_THIS_PTR eflags);
|
- 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 23:39:38 +04:00
|
|
|
|
|
2006-09-07 22:50:51 +04:00
|
|
|
|
// flags implemented in lazy_flags.cc must be done with a handler
|
|
|
|
|
// that calls their get function, to force them to be computed.
|
- 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 07:55:22 +04:00
|
|
|
|
#define DEFPARAM_EFLAG(name) \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
param = new bx_param_bool_c(list, \
|
|
|
|
|
#name, #name, "", get_##name()); \
|
|
|
|
|
param->set_handler(cpu_param_handler);
|
- 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 07:55:22 +04:00
|
|
|
|
#define DEFPARAM_LAZY_EFLAG(name) \
|
2006-03-07 23:32:07 +03:00
|
|
|
|
param = new bx_param_bool_c(list, \
|
|
|
|
|
#name, #name, "", get_##name()); \
|
|
|
|
|
param->set_handler(cpu_param_handler);
|
- 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 07:55:22 +04:00
|
|
|
|
|
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
2006-09-07 22:50:51 +04:00
|
|
|
|
DEFPARAM_EFLAG(ID);
|
|
|
|
|
DEFPARAM_EFLAG(VIP);
|
|
|
|
|
DEFPARAM_EFLAG(VIF);
|
|
|
|
|
DEFPARAM_EFLAG(AC);
|
- 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 07:55:22 +04:00
|
|
|
|
#endif
|
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
2006-09-07 22:50:51 +04:00
|
|
|
|
DEFPARAM_EFLAG(VM);
|
|
|
|
|
DEFPARAM_EFLAG(RF);
|
- 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 07:55:22 +04:00
|
|
|
|
#endif
|
|
|
|
|
#if BX_CPU_LEVEL >= 2
|
2006-09-07 22:50:51 +04:00
|
|
|
|
DEFPARAM_EFLAG(NT);
|
|
|
|
|
// IOPL is a special case because it is 2 bits wide.
|
|
|
|
|
param = new bx_shadow_num_c(
|
|
|
|
|
list,
|
|
|
|
|
"IOPL",
|
2008-01-30 01:29:48 +03:00
|
|
|
|
&BX_CPU_THIS_PTR eflags, 10,
|
2006-09-07 22:50:51 +04:00
|
|
|
|
12, 13);
|
|
|
|
|
param->set_range(0, 3);
|
|
|
|
|
param->set_format("%d");
|
- 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 07:55:22 +04:00
|
|
|
|
#endif
|
2006-09-07 22:50:51 +04:00
|
|
|
|
DEFPARAM_LAZY_EFLAG(OF);
|
|
|
|
|
DEFPARAM_EFLAG(DF);
|
|
|
|
|
DEFPARAM_EFLAG(IF);
|
|
|
|
|
DEFPARAM_EFLAG(TF);
|
|
|
|
|
DEFPARAM_LAZY_EFLAG(SF);
|
|
|
|
|
DEFPARAM_LAZY_EFLAG(ZF);
|
|
|
|
|
DEFPARAM_LAZY_EFLAG(AF);
|
|
|
|
|
DEFPARAM_LAZY_EFLAG(PF);
|
|
|
|
|
DEFPARAM_LAZY_EFLAG(CF);
|
2002-10-01 02:18:53 +04:00
|
|
|
|
|
2006-09-07 22:50:51 +04:00
|
|
|
|
// restore defaults
|
|
|
|
|
bx_param_num_c::set_default_base(oldbase);
|
|
|
|
|
bx_param_num_c::set_default_format(oldfmt);
|
|
|
|
|
}
|
2002-10-01 02:18:53 +04:00
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
}
|
2007-10-14 23:04:51 +04:00
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2007-09-28 23:52:08 +04:00
|
|
|
|
// save/restore functionality
|
2006-05-28 21:07:57 +04:00
|
|
|
|
void BX_CPU_C::register_state(void)
|
2006-05-27 19:54:49 +04:00
|
|
|
|
{
|
2008-06-14 20:55:45 +04:00
|
|
|
|
unsigned n;
|
2007-10-14 23:04:51 +04:00
|
|
|
|
char name[10];
|
2006-05-27 19:54:49 +04:00
|
|
|
|
|
2007-10-14 23:36:23 +04:00
|
|
|
|
sprintf(name, "cpu%d", BX_CPU_ID);
|
2008-02-03 00:46:54 +03:00
|
|
|
|
|
2011-08-18 00:00:51 +04:00
|
|
|
|
bx_list_c *cpu = new bx_list_c(SIM->get_bochs_root(), name, name, 55 + BX_GENERAL_REGISTERS);
|
2006-05-30 02:33:38 +04:00
|
|
|
|
|
2010-04-03 09:59:07 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, isa_extensions_bitmask);
|
2011-07-27 18:16:51 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, cpu_extensions_bitmask);
|
2011-09-26 16:31:40 +04:00
|
|
|
|
#if BX_SUPPORT_VMX
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, vmx_extensions_bitmask);
|
|
|
|
|
#endif
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_DEC_PARAM_SIMPLE(cpu, cpu_mode);
|
2009-01-29 23:27:57 +03:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, activity_state);
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, inhibit_mask);
|
2011-12-21 10:17:45 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, inhibit_icount);
|
2007-10-14 23:04:51 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, debug_trap);
|
2011-08-17 23:51:32 +04:00
|
|
|
|
BXRS_DEC_PARAM_SIMPLE(cpu, icount);
|
2011-09-22 23:38:52 +04:00
|
|
|
|
BXRS_DEC_PARAM_SIMPLE(cpu, icount_last_sync);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#if BX_SUPPORT_X86_64
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RAX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RBX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RCX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RDX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RSP);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RBP);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RSI);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RDI);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R8);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R9);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R10);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R11);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R12);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R13);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R14);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, R15);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, RIP);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#else
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, EAX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, EBX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, ECX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, EDX);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, ESP);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, EBP);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, ESI);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, EDI);
|
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, EIP);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
#endif
|
2008-02-03 00:46:54 +03:00
|
|
|
|
BXRS_PARAM_SPECIAL32(cpu, EFLAGS,
|
2006-06-02 00:05:15 +04:00
|
|
|
|
param_save_handler, param_restore_handler);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
2008-05-23 21:49:46 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, DR0, dr[0]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, DR1, dr[1]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, DR2, dr[2]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, DR3, dr[3]);
|
2011-03-15 23:20:15 +03:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, DR6, dr6.val32);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, DR7, dr7.val32);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
#endif
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, CR0, cr0.val32);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, CR2, cr2);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, CR3, cr3);
|
2011-08-16 20:49:04 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, CR4, cr4.val32);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#endif
|
2010-02-27 01:53:43 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2011-09-25 21:36:20 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_XSAVE)) {
|
2010-02-27 01:53:43 +03:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, XCR0, xcr0.val32);
|
|
|
|
|
}
|
2008-02-13 19:45:21 +03:00
|
|
|
|
#endif
|
2011-12-25 23:53:23 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, tsc_last_reset, tsc_last_reset);
|
|
|
|
|
#if BX_SUPPORT_VMX || BX_SUPPORT_SVM
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(cpu, tsc_offset, tsc_offset);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
2008-06-14 20:55:45 +04:00
|
|
|
|
for(n=0; n<6; n++) {
|
|
|
|
|
bx_segment_reg_t *segment = &BX_CPU_THIS_PTR sregs[n];
|
2011-03-12 12:56:43 +03:00
|
|
|
|
bx_list_c *sreg = new bx_list_c(cpu, strseg(segment), 12);
|
2008-02-03 00:46:54 +03:00
|
|
|
|
BXRS_PARAM_SPECIAL16(sreg, selector,
|
2006-05-28 23:18:29 +04:00
|
|
|
|
param_save_handler, param_restore_handler);
|
2011-03-12 12:56:43 +03:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(sreg, valid, segment->cache.valid);
|
|
|
|
|
BXRS_PARAM_BOOL(sreg, p, segment->cache.p);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(sreg, dpl, segment->cache.dpl);
|
|
|
|
|
BXRS_PARAM_BOOL(sreg, segment, segment->cache.segment);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(sreg, type, segment->cache.type);
|
2006-05-28 23:18:29 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(sreg, base, segment->cache.u.segment.base);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(sreg, limit_scaled, segment->cache.u.segment.limit_scaled);
|
|
|
|
|
BXRS_PARAM_BOOL(sreg, granularity, segment->cache.u.segment.g);
|
|
|
|
|
BXRS_PARAM_BOOL(sreg, d_b, segment->cache.u.segment.d_b);
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
|
BXRS_PARAM_BOOL(sreg, l, segment->cache.u.segment.l);
|
|
|
|
|
#endif
|
|
|
|
|
BXRS_PARAM_BOOL(sreg, avl, segment->cache.u.segment.avl);
|
|
|
|
|
}
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2008-03-23 23:18:24 +03:00
|
|
|
|
bx_list_c *GDTR = new bx_list_c(cpu, "GDTR", 2);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(GDTR, base, gdtr.base);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(GDTR, limit, gdtr.limit);
|
|
|
|
|
|
|
|
|
|
bx_list_c *IDTR = new bx_list_c(cpu, "IDTR", 2);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(IDTR, base, idtr.base);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(IDTR, limit, idtr.limit);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
|
2011-03-12 12:56:43 +03:00
|
|
|
|
bx_list_c *LDTR = new bx_list_c(cpu, "LDTR", 12);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BXRS_PARAM_SPECIAL16(LDTR, selector, param_save_handler, param_restore_handler);
|
2011-03-12 12:56:43 +03:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(LDTR, valid, ldtr.cache.valid);
|
|
|
|
|
BXRS_PARAM_BOOL(LDTR, p, ldtr.cache.p);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(LDTR, dpl, ldtr.cache.dpl);
|
|
|
|
|
BXRS_PARAM_BOOL(LDTR, segment, ldtr.cache.segment);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(LDTR, type, ldtr.cache.type);
|
2009-04-05 23:09:44 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(LDTR, base, ldtr.cache.u.segment.base);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(LDTR, limit_scaled, ldtr.cache.u.segment.limit_scaled);
|
|
|
|
|
BXRS_PARAM_BOOL(LDTR, granularity, ldtr.cache.u.segment.g);
|
|
|
|
|
BXRS_PARAM_BOOL(LDTR, d_b, ldtr.cache.u.segment.d_b);
|
|
|
|
|
BXRS_PARAM_BOOL(LDTR, avl, ldtr.cache.u.segment.avl);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2011-03-12 12:56:43 +03:00
|
|
|
|
bx_list_c *TR = new bx_list_c(cpu, "TR", 12);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BXRS_PARAM_SPECIAL16(TR, selector, param_save_handler, param_restore_handler);
|
2011-03-12 12:56:43 +03:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(TR, valid, tr.cache.valid);
|
|
|
|
|
BXRS_PARAM_BOOL(TR, p, tr.cache.p);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(TR, dpl, tr.cache.dpl);
|
|
|
|
|
BXRS_PARAM_BOOL(TR, segment, tr.cache.segment);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(TR, type, tr.cache.type);
|
2009-04-05 23:09:44 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(TR, base, tr.cache.u.segment.base);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(TR, limit_scaled, tr.cache.u.segment.limit_scaled);
|
|
|
|
|
BXRS_PARAM_BOOL(TR, granularity, tr.cache.u.segment.g);
|
|
|
|
|
BXRS_PARAM_BOOL(TR, d_b, tr.cache.u.segment.d_b);
|
|
|
|
|
BXRS_PARAM_BOOL(TR, avl, tr.cache.u.segment.avl);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE(cpu, smbase);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2010-03-26 01:04:31 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
|
|
|
|
bx_list_c *PDPTRS = new bx_list_c(cpu, "PDPTR_CACHE", 5);
|
|
|
|
|
BXRS_PARAM_BOOL(PDPTRS, valid, PDPTR_CACHE.valid);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(PDPTRS, entry0, PDPTR_CACHE.entry[0]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(PDPTRS, entry1, PDPTR_CACHE.entry[1]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(PDPTRS, entry2, PDPTR_CACHE.entry[2]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(PDPTRS, entry3, PDPTR_CACHE.entry[3]);
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
2007-10-14 04:22:07 +04:00
|
|
|
|
bx_list_c *MSR = new bx_list_c(cpu, "MSR", 45);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#if BX_SUPPORT_APIC
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, apicbase, msr.apicbase);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#endif
|
2008-04-01 00:56:27 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, EFER, efer.val32);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, star, msr.star);
|
2011-09-25 21:36:20 +04:00
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
|
if (BX_CPUID_SUPPORT_CPU_EXTENSION(BX_CPU_LONG_MODE)) {
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, lstar, msr.lstar);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, cstar, msr.cstar);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, fmask, msr.fmask);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, kernelgsbase, msr.kernelgsbase);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, tsc_aux, msr.tsc_aux);
|
|
|
|
|
}
|
2006-05-28 21:07:57 +04:00
|
|
|
|
#endif
|
2010-02-26 14:44:50 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, sysenter_cs_msr, msr.sysenter_cs_msr);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, sysenter_esp_msr, msr.sysenter_esp_msr);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, sysenter_eip_msr, msr.sysenter_eip_msr);
|
2007-09-20 21:33:35 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase0, msr.mtrrphys[0]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask0, msr.mtrrphys[1]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase1, msr.mtrrphys[2]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask1, msr.mtrrphys[3]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase2, msr.mtrrphys[4]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask2, msr.mtrrphys[5]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase3, msr.mtrrphys[6]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask3, msr.mtrrphys[7]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase4, msr.mtrrphys[8]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask4, msr.mtrrphys[9]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase5, msr.mtrrphys[10]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask5, msr.mtrrphys[11]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase6, msr.mtrrphys[12]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask6, msr.mtrrphys[13]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysbase7, msr.mtrrphys[14]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrphysmask7, msr.mtrrphys[15]);
|
|
|
|
|
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix64k_00000, msr.mtrrfix64k_00000);
|
2009-05-21 17:25:30 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix16k_80000, msr.mtrrfix16k[0]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix16k_a0000, msr.mtrrfix16k[1]);
|
2007-09-20 21:33:35 +04:00
|
|
|
|
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_c0000, msr.mtrrfix4k[0]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_c8000, msr.mtrrfix4k[1]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_d0000, msr.mtrrfix4k[2]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_d8000, msr.mtrrfix4k[3]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_e0000, msr.mtrrfix4k[4]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_e8000, msr.mtrrfix4k[5]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_f0000, msr.mtrrfix4k[6]);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrrfix4k_f8000, msr.mtrrfix4k[7]);
|
|
|
|
|
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, pat, msr.pat);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(MSR, mtrr_deftype, msr.mtrr_deftype);
|
|
|
|
|
#endif
|
2008-12-28 23:30:48 +03:00
|
|
|
|
#if BX_CONFIGURE_MSRS
|
2010-03-26 01:04:31 +03:00
|
|
|
|
bx_list_c *MSRS = new bx_list_c(cpu, "USER_MSR", BX_MSR_MAX_INDEX);
|
2008-12-28 23:30:48 +03:00
|
|
|
|
for(n=0; n < BX_MSR_MAX_INDEX; n++) {
|
|
|
|
|
if (! msrs[n]) continue;
|
|
|
|
|
sprintf(name, "msr_0x%03x", n);
|
|
|
|
|
bx_list_c *m = new bx_list_c(MSRS, name, 6);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(m, index, msrs[n]->index);
|
|
|
|
|
BXRS_DEC_PARAM_FIELD(m, type, msrs[n]->type);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(m, val64, msrs[n]->val64);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(m, reset, msrs[n]->reset_value);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(m, reserved, msrs[n]->reserved);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(m, ignored, msrs[n]->ignored);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#endif
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2010-03-01 21:53:53 +03:00
|
|
|
|
#if BX_SUPPORT_FPU
|
2007-10-14 23:04:51 +04:00
|
|
|
|
bx_list_c *fpu = new bx_list_c(cpu, "FPU", 17);
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, cwd, the_i387.cwd);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, swd, the_i387.swd);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, twd, the_i387.twd);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, foo, the_i387.foo);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, fcs, the_i387.fcs);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, fip, the_i387.fip);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, fds, the_i387.fds);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(fpu, fdp, the_i387.fdp);
|
2008-06-14 20:55:45 +04:00
|
|
|
|
for (n=0; n<8; n++) {
|
|
|
|
|
sprintf(name, "st%d", n);
|
2006-05-30 02:33:38 +04:00
|
|
|
|
bx_list_c *STx = new bx_list_c(fpu, name, 8);
|
2008-06-14 20:55:45 +04:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(STx, exp, the_i387.st_space[n].exp);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(STx, fraction, the_i387.st_space[n].fraction);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
}
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BXRS_DEC_PARAM_FIELD(fpu, tos, the_i387.tos);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#endif
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2010-02-26 14:44:50 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2011-09-25 21:36:20 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_SSE)) {
|
2011-03-19 23:09:34 +03:00
|
|
|
|
bx_list_c *sse = new bx_list_c(cpu, "SSE", BX_VLMAX*2*BX_XMM_REGISTERS+1);
|
2010-02-26 01:04:31 +03:00
|
|
|
|
BXRS_HEX_PARAM_FIELD(sse, mxcsr, mxcsr.mxcsr);
|
|
|
|
|
for (n=0; n<BX_XMM_REGISTERS; n++) {
|
2011-03-19 23:09:34 +03:00
|
|
|
|
for(unsigned j=0;j < BX_VLMAX*2;j++) {
|
|
|
|
|
sprintf(name, "xmm%02d_%d", n, j);
|
|
|
|
|
#if BX_SUPPORT_AVX
|
|
|
|
|
new bx_shadow_num_c(sse, name, &vmm[n].avx64u(j), BASE_HEX);
|
|
|
|
|
#else
|
|
|
|
|
new bx_shadow_num_c(sse, name, &vmm[n].xmm64u(j), BASE_HEX);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2010-02-26 01:04:31 +03:00
|
|
|
|
}
|
2006-05-27 19:54:49 +04:00
|
|
|
|
}
|
2010-02-26 14:44:50 +03:00
|
|
|
|
#endif
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2007-11-01 21:03:48 +03:00
|
|
|
|
#if BX_SUPPORT_MONITOR_MWAIT
|
2011-07-19 01:44:22 +04:00
|
|
|
|
bx_list_c *monitor_list = new bx_list_c(cpu, "MONITOR", 2);
|
|
|
|
|
BXRS_HEX_PARAM_FIELD(monitor_list, monitor_addr, monitor.monitor_addr);
|
2009-04-05 23:38:44 +04:00
|
|
|
|
BXRS_PARAM_BOOL(monitor_list, armed, monitor.armed);
|
2007-11-01 21:03:48 +03:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#if BX_SUPPORT_APIC
|
2009-02-17 22:20:47 +03:00
|
|
|
|
lapic.register_state(cpu);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
#endif
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2009-01-31 13:43:24 +03:00
|
|
|
|
#if BX_SUPPORT_VMX
|
|
|
|
|
register_vmx_state(cpu);
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-12-25 23:58:21 +04:00
|
|
|
|
#if BX_SUPPORT_SVM
|
2011-12-25 23:35:29 +04:00
|
|
|
|
register_svm_state(cpu);
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-04-18 22:32:40 +04:00
|
|
|
|
BXRS_HEX_PARAM_SIMPLE32(cpu, async_event);
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_PARAM_BOOL(cpu, INTR, INTR);
|
2009-10-30 12:13:19 +03:00
|
|
|
|
|
|
|
|
|
#if BX_X86_DEBUGGER
|
|
|
|
|
BXRS_PARAM_BOOL(cpu, in_repeat, in_repeat);
|
2011-06-24 17:38:34 +04:00
|
|
|
|
// for debug only (no need for save/restore), calculated in prefetch()
|
|
|
|
|
BXRS_PARAM_BOOL(cpu, codebp, codebp);
|
2009-10-30 12:13:19 +03:00
|
|
|
|
#endif
|
|
|
|
|
|
2007-09-28 23:52:08 +04:00
|
|
|
|
BXRS_PARAM_BOOL(cpu, in_smm, in_smm);
|
2008-12-01 22:06:14 +03:00
|
|
|
|
BXRS_PARAM_BOOL(cpu, disable_SMI, disable_SMI);
|
|
|
|
|
BXRS_PARAM_BOOL(cpu, pending_SMI, pending_SMI);
|
|
|
|
|
BXRS_PARAM_BOOL(cpu, disable_NMI, disable_NMI);
|
|
|
|
|
BXRS_PARAM_BOOL(cpu, pending_NMI, pending_NMI);
|
|
|
|
|
BXRS_PARAM_BOOL(cpu, disable_INIT, disable_INIT);
|
|
|
|
|
BXRS_PARAM_BOOL(cpu, pending_INIT, pending_INIT);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 22:29:45 +04:00
|
|
|
|
Bit64s BX_CPU_C::param_save_handler(void *devptr, bx_param_c *param)
|
2006-05-27 19:54:49 +04:00
|
|
|
|
{
|
|
|
|
|
#if !BX_USE_CPU_SMF
|
|
|
|
|
BX_CPU_C *class_ptr = (BX_CPU_C *) devptr;
|
2009-10-16 22:29:45 +04:00
|
|
|
|
return class_ptr->param_save(param);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 22:29:45 +04:00
|
|
|
|
Bit64s BX_CPU_C::param_save(bx_param_c *param)
|
2006-05-27 19:54:49 +04:00
|
|
|
|
{
|
|
|
|
|
#else
|
|
|
|
|
UNUSED(devptr);
|
|
|
|
|
#endif // !BX_USE_CPU_SMF
|
2006-05-30 02:33:38 +04:00
|
|
|
|
const char *pname, *segname;
|
2006-05-27 19:54:49 +04:00
|
|
|
|
bx_segment_reg_t *segment = NULL;
|
2009-10-16 22:29:45 +04:00
|
|
|
|
Bit64s val = 0;
|
2006-05-27 19:54:49 +04:00
|
|
|
|
|
|
|
|
|
pname = param->get_name();
|
2011-07-27 18:16:51 +04:00
|
|
|
|
if (!strcmp(pname, "EFLAGS")) {
|
2006-06-02 00:05:15 +04:00
|
|
|
|
val = BX_CPU_THIS_PTR read_eflags();
|
2011-03-12 12:56:43 +03:00
|
|
|
|
} else if (!strcmp(pname, "selector")) {
|
2006-05-27 19:54:49 +04:00
|
|
|
|
segname = param->get_parent()->get_name();
|
|
|
|
|
if (!strcmp(segname, "CS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS];
|
|
|
|
|
} else if (!strcmp(segname, "DS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS];
|
|
|
|
|
} else if (!strcmp(segname, "SS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS];
|
|
|
|
|
} else if (!strcmp(segname, "ES")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES];
|
|
|
|
|
} else if (!strcmp(segname, "FS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS];
|
|
|
|
|
} else if (!strcmp(segname, "GS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS];
|
|
|
|
|
} else if (!strcmp(segname, "LDTR")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR ldtr;
|
|
|
|
|
} else if (!strcmp(segname, "TR")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR tr;
|
|
|
|
|
}
|
|
|
|
|
if (segment != NULL) {
|
2011-03-12 12:56:43 +03:00
|
|
|
|
val = segment->selector.value;
|
2006-05-27 19:54:49 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BX_PANIC(("Unknown param %s in param_save handler !", pname));
|
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 22:29:45 +04:00
|
|
|
|
void BX_CPU_C::param_restore_handler(void *devptr, bx_param_c *param, Bit64s val)
|
2006-05-27 19:54:49 +04:00
|
|
|
|
{
|
|
|
|
|
#if !BX_USE_CPU_SMF
|
|
|
|
|
BX_CPU_C *class_ptr = (BX_CPU_C *) devptr;
|
2009-10-16 22:29:45 +04:00
|
|
|
|
class_ptr->param_restore(param, val);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 22:29:45 +04:00
|
|
|
|
void BX_CPU_C::param_restore(bx_param_c *param, Bit64s val)
|
2006-05-27 19:54:49 +04:00
|
|
|
|
{
|
|
|
|
|
#else
|
|
|
|
|
UNUSED(devptr);
|
|
|
|
|
#endif // !BX_USE_CPU_SMF
|
2006-05-30 02:33:38 +04:00
|
|
|
|
const char *pname, *segname;
|
2006-05-27 19:54:49 +04:00
|
|
|
|
bx_segment_reg_t *segment = NULL;
|
|
|
|
|
|
|
|
|
|
pname = param->get_name();
|
2011-07-27 18:16:51 +04:00
|
|
|
|
if (!strcmp(pname, "EFLAGS")) {
|
2007-04-06 19:22:17 +04:00
|
|
|
|
BX_CPU_THIS_PTR setEFlags((Bit32u)val);
|
2011-03-12 12:56:43 +03:00
|
|
|
|
} else if (!strcmp(pname, "selector")) {
|
2006-05-27 19:54:49 +04:00
|
|
|
|
segname = param->get_parent()->get_name();
|
|
|
|
|
if (!strcmp(segname, "CS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS];
|
|
|
|
|
} else if (!strcmp(segname, "DS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS];
|
|
|
|
|
} else if (!strcmp(segname, "SS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS];
|
|
|
|
|
} else if (!strcmp(segname, "ES")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES];
|
|
|
|
|
} else if (!strcmp(segname, "FS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS];
|
|
|
|
|
} else if (!strcmp(segname, "GS")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS];
|
|
|
|
|
} else if (!strcmp(segname, "LDTR")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR ldtr;
|
|
|
|
|
} else if (!strcmp(segname, "TR")) {
|
|
|
|
|
segment = &BX_CPU_THIS_PTR tr;
|
|
|
|
|
}
|
|
|
|
|
if (segment != NULL) {
|
|
|
|
|
bx_selector_t *selector = &(segment->selector);
|
2011-03-12 12:56:43 +03:00
|
|
|
|
parse_selector((Bit16u)val, selector);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BX_PANIC(("Unknown param %s in param_restore handler !", pname));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-28 21:07:57 +04:00
|
|
|
|
void BX_CPU_C::after_restore_state(void)
|
2006-05-27 19:54:49 +04:00
|
|
|
|
{
|
2008-08-14 01:51:54 +04:00
|
|
|
|
TLB_flush();
|
2010-04-06 23:26:03 +04:00
|
|
|
|
|
|
|
|
|
#if BX_CPU_LEVEL >= 4 && BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
|
handleAlignmentCheck();
|
|
|
|
|
#endif
|
|
|
|
|
handleCpuModeChange();
|
2010-12-19 10:06:40 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
|
|
|
|
handleSseModeChange();
|
2011-03-19 23:09:34 +03:00
|
|
|
|
#if BX_SUPPORT_AVX
|
|
|
|
|
handleAvxModeChange();
|
|
|
|
|
#endif
|
2010-12-19 10:06:40 +03:00
|
|
|
|
#endif
|
2010-04-06 23:26:03 +04:00
|
|
|
|
|
2010-06-05 00:31:04 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_IA32_REAL) CPL = 0;
|
|
|
|
|
else {
|
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_IA32_V8086) CPL = 3;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-03 17:02:14 +04:00
|
|
|
|
#if BX_SUPPORT_VMX
|
|
|
|
|
set_VMCSPTR(BX_CPU_THIS_PTR vmcsptr);
|
|
|
|
|
#endif
|
2010-04-06 23:26:03 +04:00
|
|
|
|
|
2006-05-27 19:54:49 +04:00
|
|
|
|
assert_checks();
|
|
|
|
|
invalidate_prefetch_q();
|
|
|
|
|
debug(RIP);
|
|
|
|
|
}
|
2007-09-28 23:52:08 +04:00
|
|
|
|
// end of save/restore functionality
|
2006-05-27 19:54:49 +04:00
|
|
|
|
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BX_CPU_C::~BX_CPU_C()
|
2001-04-10 05:04:59 +04:00
|
|
|
|
{
|
2011-07-28 20:17:42 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
|
|
|
|
delete cpuid;
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-04-16 01:27:57 +04:00
|
|
|
|
BX_INSTR_EXIT(BX_CPU_ID);
|
2006-05-27 19:54:49 +04:00
|
|
|
|
BX_DEBUG(("Exit."));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
}
|
|
|
|
|
|
2004-10-16 14:18:01 +04:00
|
|
|
|
void BX_CPU_C::reset(unsigned source)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
{
|
2008-06-14 20:55:45 +04:00
|
|
|
|
unsigned n;
|
2007-09-20 21:33:35 +04:00
|
|
|
|
|
2007-10-15 01:42:50 +04:00
|
|
|
|
if (source == BX_RESET_HARDWARE)
|
|
|
|
|
BX_INFO(("cpu hardware reset"));
|
|
|
|
|
else if (source == BX_RESET_SOFTWARE)
|
|
|
|
|
BX_INFO(("cpu software reset"));
|
|
|
|
|
else
|
|
|
|
|
BX_INFO(("cpu reset"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2010-12-20 00:41:15 +03:00
|
|
|
|
for (n=0;n<BX_GENERAL_REGISTERS;n++)
|
|
|
|
|
BX_WRITE_32BIT_REGZ(n, 0);
|
|
|
|
|
|
2011-07-28 20:17:42 +04:00
|
|
|
|
//BX_WRITE_32BIT_REGZ(BX_32BIT_REG_EDX, get_cpu_version_information());
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2008-03-29 12:34:35 +03:00
|
|
|
|
// initialize NIL register
|
2008-04-03 21:56:59 +04:00
|
|
|
|
BX_WRITE_32BIT_REGZ(BX_NIL_REGISTER, 0);
|
2008-03-29 12:34:35 +03:00
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
// status and control flags register set
|
2010-03-05 11:54:07 +03:00
|
|
|
|
setEFlags(0x2); // Bit1 is always set
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2011-09-06 19:35:39 +04:00
|
|
|
|
if (source == BX_RESET_HARDWARE)
|
|
|
|
|
BX_CPU_THIS_PTR icount = 0;
|
|
|
|
|
BX_CPU_THIS_PTR icount_last_sync = BX_CPU_THIS_PTR icount;
|
2011-08-17 23:51:32 +04:00
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
BX_CPU_THIS_PTR inhibit_mask = 0;
|
2011-12-21 10:17:45 +04:00
|
|
|
|
BX_CPU_THIS_PTR inhibit_icount = 0;
|
|
|
|
|
|
2009-01-29 23:27:57 +03:00
|
|
|
|
BX_CPU_THIS_PTR activity_state = BX_ACTIVITY_STATE_ACTIVE;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
BX_CPU_THIS_PTR debug_trap = 0;
|
|
|
|
|
|
|
|
|
|
/* instruction pointer */
|
|
|
|
|
#if BX_CPU_LEVEL < 2
|
2007-11-24 17:22:34 +03:00
|
|
|
|
BX_CPU_THIS_PTR prev_rip = EIP = 0x00000000;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#else /* from 286 up */
|
2007-11-24 17:22:34 +03:00
|
|
|
|
BX_CPU_THIS_PTR prev_rip = RIP = 0x0000FFF0;
|
2002-09-14 04:51:46 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
/* CS (Code Segment) and descriptor cache */
|
|
|
|
|
/* Note: on a real cpu, CS initially points to upper memory. After
|
|
|
|
|
* the 1st jump, the descriptor base is zero'd out. Since I'm just
|
|
|
|
|
* going to jump to my BIOS, I don't need to do this.
|
|
|
|
|
* For future reference:
|
|
|
|
|
* processor cs.selector cs.base cs.limit EIP
|
|
|
|
|
* 8086 FFFF FFFF0 FFFF 0000
|
|
|
|
|
* 286 F000 FF0000 FFFF FFF0
|
|
|
|
|
* 386+ F000 FFFF0000 FFFF FFF0
|
|
|
|
|
*/
|
2008-02-03 00:46:54 +03:00
|
|
|
|
parse_selector(0xf000,
|
2006-06-12 01:37:22 +04:00
|
|
|
|
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector);
|
|
|
|
|
|
2008-09-08 19:45:57 +04:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.valid = SegValidCache | SegAccessROK | SegAccessWOK;
|
2004-11-15 00:25:42 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.p = 1;
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.dpl = 0;
|
2005-11-19 22:38:45 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.segment = 1; /* data/code segment */
|
2008-05-27 01:46:39 +04:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.type = BX_DATA_READ_WRITE_ACCESSED;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2004-11-19 12:39:30 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.base = 0xFFFF0000;
|
2006-02-28 22:50:08 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled = 0xFFFF;
|
2008-08-17 01:06:56 +04:00
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.g = 0; /* byte granular */
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b = 0; /* 16bit default size */
|
2005-11-08 01:45:25 +03:00
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.l = 0; /* 16bit default size */
|
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.avl = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-02-01 16:25:23 +03:00
|
|
|
|
flushICaches();
|
2006-01-16 22:22:28 +03:00
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
/* DS (Data Segment) and descriptor cache */
|
2008-02-03 00:46:54 +03:00
|
|
|
|
parse_selector(0x0000,
|
2006-06-12 01:37:22 +04:00
|
|
|
|
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector);
|
|
|
|
|
|
2008-09-08 19:45:57 +04:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.valid = SegValidCache | SegAccessROK | SegAccessWOK;
|
2004-11-15 00:25:42 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.p = 1;
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.dpl = 0;
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.segment = 1; /* data/code segment */
|
2006-06-12 20:58:27 +04:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.type = BX_DATA_READ_WRITE_ACCESSED;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.u.segment.base = 0x00000000;
|
2006-02-28 22:50:08 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.u.segment.limit_scaled = 0xFFFF;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
2006-02-28 22:50:08 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.u.segment.avl = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.u.segment.g = 0; /* byte granular */
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.u.segment.d_b = 0; /* 16bit default size */
|
2005-11-08 01:45:25 +03:00
|
|
|
|
#if BX_SUPPORT_X86_64
|
2005-11-19 22:38:45 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].cache.u.segment.l = 0; /* 16bit default size */
|
2005-11-08 01:45:25 +03:00
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-02-28 22:50:08 +03:00
|
|
|
|
// use DS segment as template for the others
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS] = BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS];
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES] = BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS];
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
2006-02-28 22:50:08 +03:00
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS] = BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS];
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS] = BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS];
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2004-10-16 14:18:01 +04:00
|
|
|
|
/* GDTR (Global Descriptor Table Register) */
|
2005-11-19 22:38:45 +03:00
|
|
|
|
BX_CPU_THIS_PTR gdtr.base = 0x00000000;
|
|
|
|
|
BX_CPU_THIS_PTR gdtr.limit = 0xFFFF;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
/* IDTR (Interrupt Descriptor Table Register) */
|
2005-11-19 22:38:45 +03:00
|
|
|
|
BX_CPU_THIS_PTR idtr.base = 0x00000000;
|
|
|
|
|
BX_CPU_THIS_PTR idtr.limit = 0xFFFF; /* always byte granular */
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
/* LDTR (Local Descriptor Table Register) */
|
2004-10-16 14:18:01 +04:00
|
|
|
|
BX_CPU_THIS_PTR ldtr.selector.value = 0x0000;
|
|
|
|
|
BX_CPU_THIS_PTR ldtr.selector.index = 0x0000;
|
2004-11-15 00:25:42 +03:00
|
|
|
|
BX_CPU_THIS_PTR ldtr.selector.ti = 0;
|
|
|
|
|
BX_CPU_THIS_PTR ldtr.selector.rpl = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2005-11-19 21:27:15 +03:00
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.valid = 1; /* valid */
|
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.p = 1; /* present */
|
2004-11-15 00:25:42 +03:00
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.dpl = 0; /* field not used */
|
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.segment = 0; /* system segment */
|
2006-05-21 23:31:23 +04:00
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.type = BX_SYS_SEGMENT_LDT;
|
2009-04-05 23:09:44 +04:00
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.u.segment.base = 0x00000000;
|
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.u.segment.limit_scaled = 0xFFFF;
|
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.u.segment.avl = 0;
|
|
|
|
|
BX_CPU_THIS_PTR ldtr.cache.u.segment.g = 0; /* byte granular */
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2004-11-15 00:25:42 +03:00
|
|
|
|
/* TR (Task Register) */
|
|
|
|
|
BX_CPU_THIS_PTR tr.selector.value = 0x0000;
|
|
|
|
|
BX_CPU_THIS_PTR tr.selector.index = 0x0000; /* undefined */
|
|
|
|
|
BX_CPU_THIS_PTR tr.selector.ti = 0;
|
|
|
|
|
BX_CPU_THIS_PTR tr.selector.rpl = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2005-11-19 21:27:15 +03:00
|
|
|
|
BX_CPU_THIS_PTR tr.cache.valid = 1; /* valid */
|
|
|
|
|
BX_CPU_THIS_PTR tr.cache.p = 1; /* present */
|
2001-04-10 05:04:59 +04:00
|
|
|
|
BX_CPU_THIS_PTR tr.cache.dpl = 0; /* field not used */
|
2005-11-19 21:27:15 +03:00
|
|
|
|
BX_CPU_THIS_PTR tr.cache.segment = 0; /* system segment */
|
2008-03-25 01:13:04 +03:00
|
|
|
|
BX_CPU_THIS_PTR tr.cache.type = BX_SYS_SEGMENT_BUSY_386_TSS;
|
2009-04-05 23:09:44 +04:00
|
|
|
|
BX_CPU_THIS_PTR tr.cache.u.segment.base = 0x00000000;
|
|
|
|
|
BX_CPU_THIS_PTR tr.cache.u.segment.limit_scaled = 0xFFFF;
|
|
|
|
|
BX_CPU_THIS_PTR tr.cache.u.segment.avl = 0;
|
|
|
|
|
BX_CPU_THIS_PTR tr.cache.u.segment.g = 0; /* byte granular */
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
// DR0 - DR7 (Debug Registers)
|
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
2008-12-28 23:30:48 +03:00
|
|
|
|
for (n=0; n<4; n++)
|
2009-08-19 13:59:30 +04:00
|
|
|
|
BX_CPU_THIS_PTR dr[n] = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#endif
|
2006-02-28 22:50:08 +03:00
|
|
|
|
|
2011-03-15 23:20:15 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
|
|
|
|
BX_CPU_THIS_PTR dr6.val32 = 0xFFFF0FF0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#else
|
2011-03-15 23:20:15 +03:00
|
|
|
|
BX_CPU_THIS_PTR dr6.val32 = 0xFFFF1FF0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#endif
|
2011-03-15 23:20:15 +03:00
|
|
|
|
BX_CPU_THIS_PTR dr7.val32 = 0x00000400;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2009-10-30 12:13:19 +03:00
|
|
|
|
#if BX_X86_DEBUGGER
|
|
|
|
|
BX_CPU_THIS_PTR in_repeat = 0;
|
2011-06-24 17:38:34 +04:00
|
|
|
|
BX_CPU_THIS_PTR codebp = 0;
|
2009-10-30 12:13:19 +03:00
|
|
|
|
#endif
|
2006-02-14 23:03:14 +03:00
|
|
|
|
BX_CPU_THIS_PTR in_smm = 0;
|
2008-12-01 22:06:14 +03:00
|
|
|
|
BX_CPU_THIS_PTR disable_SMI = 0;
|
|
|
|
|
BX_CPU_THIS_PTR pending_SMI = 0;
|
|
|
|
|
BX_CPU_THIS_PTR disable_NMI = 0;
|
|
|
|
|
BX_CPU_THIS_PTR pending_NMI = 0;
|
|
|
|
|
BX_CPU_THIS_PTR disable_INIT = 0;
|
|
|
|
|
BX_CPU_THIS_PTR pending_INIT = 0;
|
2007-08-01 00:25:52 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 4 && BX_SUPPORT_ALIGNMENT_CHECK
|
2008-09-08 19:45:57 +04:00
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
2007-08-01 00:25:52 +04:00
|
|
|
|
#endif
|
2006-02-14 22:00:08 +03:00
|
|
|
|
|
2008-11-18 23:55:59 +03:00
|
|
|
|
if (source == BX_RESET_HARDWARE) {
|
|
|
|
|
BX_CPU_THIS_PTR smbase = 0x30000; // do not change SMBASE on INIT
|
|
|
|
|
}
|
2006-04-05 21:31:35 +04:00
|
|
|
|
|
2008-12-06 13:21:55 +03:00
|
|
|
|
BX_CPU_THIS_PTR cr0.set32(0x60000010);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
// handle reserved bits
|
|
|
|
|
#if BX_CPU_LEVEL == 3
|
|
|
|
|
// reserved bits all set to 1 on 386
|
|
|
|
|
BX_CPU_THIS_PTR cr0.val32 |= 0x7ffffff0;
|
|
|
|
|
#endif
|
2006-03-04 19:58:10 +03:00
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
|
|
|
|
BX_CPU_THIS_PTR cr2 = 0;
|
|
|
|
|
BX_CPU_THIS_PTR cr3 = 0;
|
|
|
|
|
#endif
|
2007-07-09 19:16:14 +04:00
|
|
|
|
|
2011-08-16 20:49:04 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
2008-12-06 13:21:55 +03:00
|
|
|
|
BX_CPU_THIS_PTR cr4.set32(0);
|
2011-08-11 00:31:29 +04:00
|
|
|
|
BX_CPU_THIS_PTR cr4_suppmask = get_cr4_allow_mask();
|
2002-09-14 04:51:46 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2010-02-27 01:53:43 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2008-12-06 13:21:55 +03:00
|
|
|
|
BX_CPU_THIS_PTR xcr0.set32(0x1);
|
2011-03-19 23:09:34 +03:00
|
|
|
|
BX_CPU_THIS_PTR xcr0_suppmask = 0x3;
|
|
|
|
|
#if BX_SUPPORT_AVX
|
2011-09-25 21:36:20 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_AVX))
|
2011-03-19 23:09:34 +03:00
|
|
|
|
BX_CPU_THIS_PTR xcr0_suppmask |= BX_XCR0_AVX_MASK;
|
|
|
|
|
#endif
|
2008-02-13 19:45:21 +03:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-03-27 19:04:05 +03:00
|
|
|
|
/* initialise MSR registers to defaults */
|
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
2006-03-15 20:57:11 +03:00
|
|
|
|
#if BX_SUPPORT_APIC
|
2002-03-27 19:04:05 +03:00
|
|
|
|
/* APIC Address, APIC enabled and BSP is default, we'll fill in the rest later */
|
2006-03-07 01:03:16 +03:00
|
|
|
|
BX_CPU_THIS_PTR msr.apicbase = BX_LAPIC_BASE_ADDR;
|
2009-02-20 20:26:01 +03:00
|
|
|
|
BX_CPU_THIS_PTR lapic.reset(source);
|
2004-02-12 03:56:21 +03:00
|
|
|
|
BX_CPU_THIS_PTR msr.apicbase |= 0x900;
|
2009-02-19 01:38:58 +03:00
|
|
|
|
BX_CPU_THIS_PTR lapic.set_base(BX_CPU_THIS_PTR msr.apicbase);
|
2004-12-14 23:41:55 +03:00
|
|
|
|
#endif
|
2011-08-11 02:04:33 +04:00
|
|
|
|
|
2008-12-06 13:21:55 +03:00
|
|
|
|
BX_CPU_THIS_PTR efer.set32(0);
|
2011-08-11 02:04:33 +04:00
|
|
|
|
BX_CPU_THIS_PTR efer_suppmask = 0;
|
|
|
|
|
if (BX_CPUID_SUPPORT_CPU_EXTENSION(BX_CPU_NX))
|
|
|
|
|
BX_CPU_THIS_PTR efer_suppmask |= BX_EFER_NXE_MASK;
|
2011-09-26 16:31:40 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_SYSCALL_SYSRET_LEGACY))
|
2011-08-31 01:32:40 +04:00
|
|
|
|
BX_CPU_THIS_PTR efer_suppmask |= BX_EFER_SCE_MASK;
|
2011-08-11 02:04:33 +04:00
|
|
|
|
#if BX_SUPPORT_X86_64
|
2011-09-25 21:36:20 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_CPU_EXTENSION(BX_CPU_LONG_MODE)) {
|
2011-08-11 02:04:33 +04:00
|
|
|
|
BX_CPU_THIS_PTR efer_suppmask |= (BX_EFER_SCE_MASK | BX_EFER_LME_MASK | BX_EFER_LMA_MASK);
|
2011-09-25 21:36:20 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_CPU_EXTENSION(BX_CPU_FFXSR))
|
|
|
|
|
BX_CPU_THIS_PTR efer_suppmask |= BX_EFER_FFXSR_MASK;
|
2011-12-25 23:35:29 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_CPU_EXTENSION(BX_ISA_SVM))
|
|
|
|
|
BX_CPU_THIS_PTR efer_suppmask |= BX_EFER_SVME_MASK;
|
2011-09-25 21:36:20 +04:00
|
|
|
|
}
|
2011-08-11 02:04:33 +04:00
|
|
|
|
#endif
|
2007-09-11 00:47:08 +04:00
|
|
|
|
|
2011-09-25 21:36:20 +04:00
|
|
|
|
BX_CPU_THIS_PTR msr.star = 0;
|
2011-08-11 02:04:33 +04:00
|
|
|
|
#if BX_SUPPORT_X86_64
|
2011-09-25 21:36:20 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_CPU_EXTENSION(BX_CPU_LONG_MODE)) {
|
|
|
|
|
BX_CPU_THIS_PTR msr.lstar = 0;
|
|
|
|
|
BX_CPU_THIS_PTR msr.cstar = 0;
|
|
|
|
|
BX_CPU_THIS_PTR msr.fmask = 0x00020200;
|
|
|
|
|
BX_CPU_THIS_PTR msr.kernelgsbase = 0;
|
|
|
|
|
BX_CPU_THIS_PTR msr.tsc_aux = 0;
|
|
|
|
|
}
|
2002-09-14 04:51:46 +04:00
|
|
|
|
#endif
|
2011-09-25 21:36:20 +04:00
|
|
|
|
|
2011-12-26 02:09:31 +04:00
|
|
|
|
#if BX_SUPPORT_VMX || BX_SUPPORT_SVM
|
|
|
|
|
BX_CPU_THIS_PTR tsc_offset = 0;
|
|
|
|
|
#endif
|
2008-11-18 23:55:59 +03:00
|
|
|
|
if (source == BX_RESET_HARDWARE) {
|
|
|
|
|
BX_CPU_THIS_PTR set_TSC(0); // do not change TSC on INIT
|
|
|
|
|
}
|
2011-09-25 21:36:20 +04:00
|
|
|
|
#endif // BX_CPU_LEVEL >= 5
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2010-02-26 14:44:50 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2006-05-28 21:07:57 +04:00
|
|
|
|
BX_CPU_THIS_PTR msr.sysenter_cs_msr = 0;
|
|
|
|
|
BX_CPU_THIS_PTR msr.sysenter_esp_msr = 0;
|
|
|
|
|
BX_CPU_THIS_PTR msr.sysenter_eip_msr = 0;
|
2006-06-03 16:59:14 +04:00
|
|
|
|
#endif
|
2006-05-28 21:07:57 +04:00
|
|
|
|
|
2008-11-18 23:55:59 +03:00
|
|
|
|
// Do not change MTRR on INIT
|
2009-06-15 19:10:05 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2008-11-18 23:55:59 +03:00
|
|
|
|
if (source == BX_RESET_HARDWARE) {
|
|
|
|
|
for (n=0; n<16; n++)
|
|
|
|
|
BX_CPU_THIS_PTR msr.mtrrphys[n] = 0;
|
2007-09-20 21:33:35 +04:00
|
|
|
|
|
2008-11-18 23:55:59 +03:00
|
|
|
|
BX_CPU_THIS_PTR msr.mtrrfix64k_00000 = 0; // all fix range MTRRs undefined according to manual
|
2009-05-21 17:25:30 +04:00
|
|
|
|
BX_CPU_THIS_PTR msr.mtrrfix16k[0] = 0;
|
|
|
|
|
BX_CPU_THIS_PTR msr.mtrrfix16k[1] = 0;
|
2007-09-20 21:33:35 +04:00
|
|
|
|
|
2008-11-18 23:55:59 +03:00
|
|
|
|
for (n=0; n<8; n++)
|
|
|
|
|
BX_CPU_THIS_PTR msr.mtrrfix4k[n] = 0;
|
2007-09-20 21:33:35 +04:00
|
|
|
|
|
2008-11-18 23:55:59 +03:00
|
|
|
|
BX_CPU_THIS_PTR msr.pat = BX_CONST64(0x0007040600070406);
|
2010-04-10 11:32:48 +04:00
|
|
|
|
BX_CPU_THIS_PTR msr.mtrr_deftype = BX_CONST64(0x806);
|
2008-11-18 23:55:59 +03:00
|
|
|
|
}
|
2007-09-20 21:33:35 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2008-12-28 23:30:48 +03:00
|
|
|
|
// All configurable MSRs do not change on INIT
|
|
|
|
|
#if BX_CONFIGURE_MSRS
|
|
|
|
|
if (source == BX_RESET_HARDWARE) {
|
2009-01-08 21:07:44 +03:00
|
|
|
|
for (n=0; n < BX_MSR_MAX_INDEX; n++) {
|
2008-12-28 23:30:48 +03:00
|
|
|
|
if (BX_CPU_THIS_PTR msrs[n])
|
|
|
|
|
BX_CPU_THIS_PTR msrs[n]->reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
BX_CPU_THIS_PTR EXT = 0;
|
2010-04-19 15:09:35 +04:00
|
|
|
|
BX_CPU_THIS_PTR errorno = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2010-04-08 19:50:39 +04:00
|
|
|
|
TLB_flush();
|
2010-04-09 11:15:54 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2010-04-08 19:50:39 +04:00
|
|
|
|
BX_CPU_THIS_PTR PDPTR_CACHE.valid = 0;
|
2010-04-09 11:15:54 +04:00
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2006-03-15 20:57:11 +03:00
|
|
|
|
// invalidate the prefetch queue
|
2002-09-02 22:44:35 +04:00
|
|
|
|
BX_CPU_THIS_PTR eipPageBias = 0;
|
|
|
|
|
BX_CPU_THIS_PTR eipPageWindowSize = 0;
|
|
|
|
|
BX_CPU_THIS_PTR eipFetchPtr = NULL;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2008-04-07 22:39:17 +04:00
|
|
|
|
handleCpuModeChange();
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
|
BX_CPU_THIS_PTR stop_reason = STOP_NO_REASON;
|
2008-01-22 00:36:58 +03:00
|
|
|
|
BX_CPU_THIS_PTR magic_break = 0;
|
2011-08-21 21:04:21 +04:00
|
|
|
|
BX_CPU_THIS_PTR trace = 0;
|
2002-11-19 08:52:52 +03:00
|
|
|
|
BX_CPU_THIS_PTR trace_reg = 0;
|
2008-04-19 17:21:23 +04:00
|
|
|
|
BX_CPU_THIS_PTR trace_mem = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-18 18:11:11 +04:00
|
|
|
|
// Reset the Floating Point Unit
|
2003-04-23 00:21:34 +04:00
|
|
|
|
#if BX_SUPPORT_FPU
|
2008-11-18 23:55:59 +03:00
|
|
|
|
if (source == BX_RESET_HARDWARE) {
|
|
|
|
|
BX_CPU_THIS_PTR the_i387.reset();
|
|
|
|
|
}
|
2004-11-15 00:25:42 +03:00
|
|
|
|
#endif
|
|
|
|
|
|
2010-02-26 14:44:50 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 6
|
2010-12-19 10:06:40 +03:00
|
|
|
|
BX_CPU_THIS_PTR sse_ok = 0;
|
2011-03-19 23:09:34 +03:00
|
|
|
|
#if BX_SUPPORT_AVX
|
|
|
|
|
BX_CPU_THIS_PTR avx_ok = 0;
|
|
|
|
|
#endif
|
2010-12-23 00:16:02 +03:00
|
|
|
|
|
|
|
|
|
// Reset XMM state - unchanged on #INIT
|
2008-11-18 23:55:59 +03:00
|
|
|
|
if (source == BX_RESET_HARDWARE) {
|
2011-03-19 23:09:34 +03:00
|
|
|
|
static BxPackedXmmRegister xmmnil; /* compiler will clear the variable */
|
2008-11-18 23:55:59 +03:00
|
|
|
|
for(n=0; n<BX_XMM_REGISTERS; n++)
|
2011-03-19 23:09:34 +03:00
|
|
|
|
BX_WRITE_XMM_REG_CLEAR_HIGH(n, xmmnil);
|
2004-11-15 00:25:42 +03:00
|
|
|
|
|
2008-11-18 23:55:59 +03:00
|
|
|
|
BX_CPU_THIS_PTR mxcsr.mxcsr = MXCSR_RESET;
|
2011-03-19 23:09:34 +03:00
|
|
|
|
BX_CPU_THIS_PTR mxcsr_mask = 0x0000ffbf;
|
2011-09-25 21:36:20 +04:00
|
|
|
|
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_SSE2))
|
2010-02-26 01:04:31 +03:00
|
|
|
|
BX_CPU_THIS_PTR mxcsr_mask |= MXCSR_DAZ;
|
|
|
|
|
if (BX_SUPPORT_MISALIGNED_SSE)
|
|
|
|
|
BX_CPU_THIS_PTR mxcsr_mask |= MXCSR_MISALIGNED_EXCEPTION_MASK;
|
2008-11-18 23:55:59 +03:00
|
|
|
|
}
|
2010-02-26 14:44:50 +03:00
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2009-01-31 13:43:24 +03:00
|
|
|
|
#if BX_SUPPORT_VMX
|
|
|
|
|
BX_CPU_THIS_PTR in_vmx = BX_CPU_THIS_PTR in_vmx_guest = 0;
|
2010-03-16 17:51:20 +03:00
|
|
|
|
BX_CPU_THIS_PTR in_smm_vmx = BX_CPU_THIS_PTR in_smm_vmx_guest = 0;
|
2009-02-03 22:17:15 +03:00
|
|
|
|
BX_CPU_THIS_PTR vmx_interrupt_window = 0;
|
2011-07-03 19:59:48 +04:00
|
|
|
|
#if BX_SUPPORT_VMX >= 2
|
|
|
|
|
BX_CPU_THIS_PTR pending_vmx_timer_expired = 0;
|
|
|
|
|
#endif
|
2009-05-28 12:26:17 +04:00
|
|
|
|
BX_CPU_THIS_PTR vmcsptr = BX_CPU_THIS_PTR vmxonptr = BX_INVALID_VMCSPTR;
|
2009-05-03 17:02:14 +04:00
|
|
|
|
BX_CPU_THIS_PTR vmcshostptr = 0;
|
2010-05-22 14:21:31 +04:00
|
|
|
|
/* enable VMX, should be done in BIOS instead */
|
|
|
|
|
BX_CPU_THIS_PTR msr.ia32_feature_ctrl =
|
2010-05-23 09:32:00 +04:00
|
|
|
|
/*BX_IA32_FEATURE_CONTROL_LOCK_BIT | */BX_IA32_FEATURE_CONTROL_VMX_ENABLE_BIT;
|
2009-01-31 13:43:24 +03:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-12-25 23:35:29 +04:00
|
|
|
|
#if BX_SUPPORT_SVM
|
2011-12-26 23:57:39 +04:00
|
|
|
|
BX_CPU_THIS_PTR in_svm_guest = 0;
|
2011-12-25 23:35:29 +04:00
|
|
|
|
BX_CPU_THIS_PTR svm_gif = 1;
|
2011-12-27 23:42:11 +04:00
|
|
|
|
BX_CPU_THIS_PTR vmcbptr = 0;
|
|
|
|
|
BX_CPU_THIS_PTR vmcbhostptr = 0;
|
2011-12-25 23:35:29 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-12-26 20:33:13 +04:00
|
|
|
|
#if BX_SUPPORT_VMX || BX_SUPPORT_SVM
|
|
|
|
|
BX_CPU_THIS_PTR in_event = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-01-18 21:35:38 +03:00
|
|
|
|
#if BX_SUPPORT_SMP
|
2009-02-03 22:28:22 +03:00
|
|
|
|
// notice if I'm the bootstrap processor. If not, do the equivalent of
|
|
|
|
|
// a HALT instruction.
|
2009-02-17 22:20:47 +03:00
|
|
|
|
int apic_id = lapic.get_id();
|
2009-02-03 22:28:22 +03:00
|
|
|
|
if (BX_BOOTSTRAP_PROCESSOR == apic_id) {
|
|
|
|
|
// boot normally
|
|
|
|
|
BX_CPU_THIS_PTR msr.apicbase |= 0x0100; /* set bit 8 BSP */
|
|
|
|
|
BX_INFO(("CPU[%d] is the bootstrap processor", apic_id));
|
|
|
|
|
} else {
|
|
|
|
|
// it's an application processor, halt until IPI is heard.
|
|
|
|
|
BX_CPU_THIS_PTR msr.apicbase &= ~0x0100; /* clear bit 8 BSP */
|
|
|
|
|
BX_INFO(("CPU[%d] is an application processor. Halting until IPI.", apic_id));
|
|
|
|
|
activity_state = BX_ACTIVITY_STATE_WAIT_FOR_SIPI;
|
|
|
|
|
disable_INIT = 1; // INIT is disabled when CPU is waiting for SIPI
|
|
|
|
|
async_event = 1;
|
2001-05-23 12:16:07 +04:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2002-09-28 04:54:05 +04:00
|
|
|
|
|
2011-07-28 20:17:42 +04:00
|
|
|
|
updateFetchModeMask();
|
|
|
|
|
|
2011-02-25 19:27:01 +03:00
|
|
|
|
#if BX_CPU_LEVEL >= 4
|
2011-07-28 20:17:42 +04:00
|
|
|
|
BX_CPU_THIS_PTR cpuid->dump_cpuid();
|
2011-02-25 19:27:01 +03:00
|
|
|
|
#endif
|
2007-11-11 23:44:07 +03:00
|
|
|
|
|
2008-11-18 23:58:09 +03:00
|
|
|
|
BX_INSTR_RESET(BX_CPU_ID, source);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
}
|
|
|
|
|
|
2004-10-16 14:18:01 +04:00
|
|
|
|
void BX_CPU_C::sanity_checks(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
{
|
2011-04-21 17:27:42 +04:00
|
|
|
|
Bit32u eax = EAX, ecx = ECX, edx = EDX, ebx = EBX, esp = ESP, ebp = EBP, esi = ESI, edi = EDI;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
EAX = 0xFFEEDDCC;
|
|
|
|
|
ECX = 0xBBAA9988;
|
|
|
|
|
EDX = 0x77665544;
|
|
|
|
|
EBX = 0x332211FF;
|
|
|
|
|
ESP = 0xEEDDCCBB;
|
|
|
|
|
EBP = 0xAA998877;
|
|
|
|
|
ESI = 0x66554433;
|
|
|
|
|
EDI = 0x2211FFEE;
|
|
|
|
|
|
2011-04-21 17:27:42 +04:00
|
|
|
|
Bit8u al, cl, dl, bl, ah, ch, dh, bh;
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
al = AL;
|
|
|
|
|
cl = CL;
|
|
|
|
|
dl = DL;
|
|
|
|
|
bl = BL;
|
|
|
|
|
ah = AH;
|
|
|
|
|
ch = CH;
|
|
|
|
|
dh = DH;
|
|
|
|
|
bh = BH;
|
|
|
|
|
|
|
|
|
|
if ( al != (EAX & 0xFF) ||
|
|
|
|
|
cl != (ECX & 0xFF) ||
|
|
|
|
|
dl != (EDX & 0xFF) ||
|
|
|
|
|
bl != (EBX & 0xFF) ||
|
|
|
|
|
ah != ((EAX >> 8) & 0xFF) ||
|
|
|
|
|
ch != ((ECX >> 8) & 0xFF) ||
|
|
|
|
|
dh != ((EDX >> 8) & 0xFF) ||
|
2006-02-28 22:50:08 +03:00
|
|
|
|
bh != ((EBX >> 8) & 0xFF) )
|
|
|
|
|
{
|
2002-09-14 04:51:46 +04:00
|
|
|
|
BX_PANIC(("problems using BX_READ_8BIT_REGx()!"));
|
2006-02-28 22:50:08 +03:00
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2011-04-21 17:27:42 +04:00
|
|
|
|
Bit16u ax, cx, dx, bx, sp, bp, si, di;
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
ax = AX;
|
|
|
|
|
cx = CX;
|
|
|
|
|
dx = DX;
|
|
|
|
|
bx = BX;
|
|
|
|
|
sp = SP;
|
|
|
|
|
bp = BP;
|
|
|
|
|
si = SI;
|
|
|
|
|
di = DI;
|
|
|
|
|
|
|
|
|
|
if ( ax != (EAX & 0xFFFF) ||
|
|
|
|
|
cx != (ECX & 0xFFFF) ||
|
|
|
|
|
dx != (EDX & 0xFFFF) ||
|
|
|
|
|
bx != (EBX & 0xFFFF) ||
|
|
|
|
|
sp != (ESP & 0xFFFF) ||
|
|
|
|
|
bp != (EBP & 0xFFFF) ||
|
|
|
|
|
si != (ESI & 0xFFFF) ||
|
2006-02-28 22:50:08 +03:00
|
|
|
|
di != (EDI & 0xFFFF) )
|
|
|
|
|
{
|
2001-05-30 22:56:02 +04:00
|
|
|
|
BX_PANIC(("problems using BX_READ_16BIT_REG()!"));
|
2006-02-28 22:50:08 +03:00
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2011-04-21 17:27:42 +04:00
|
|
|
|
EAX = eax; /* restore registers */
|
|
|
|
|
ECX = ecx;
|
|
|
|
|
EDX = edx;
|
|
|
|
|
EBX = ebx;
|
|
|
|
|
ESP = esp;
|
|
|
|
|
EBP = ebp;
|
|
|
|
|
ESI = esi;
|
|
|
|
|
EDI = edi;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
if (sizeof(Bit8u) != 1 || sizeof(Bit8s) != 1)
|
2001-05-30 22:56:02 +04:00
|
|
|
|
BX_PANIC(("data type Bit8u or Bit8s is not of length 1 byte!"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
if (sizeof(Bit16u) != 2 || sizeof(Bit16s) != 2)
|
2001-05-30 22:56:02 +04:00
|
|
|
|
BX_PANIC(("data type Bit16u or Bit16s is not of length 2 bytes!"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
if (sizeof(Bit32u) != 4 || sizeof(Bit32s) != 4)
|
2001-05-30 22:56:02 +04:00
|
|
|
|
BX_PANIC(("data type Bit32u or Bit32s is not of length 4 bytes!"));
|
2003-08-07 23:22:37 +04:00
|
|
|
|
if (sizeof(Bit64u) != 8 || sizeof(Bit64s) != 8)
|
|
|
|
|
BX_PANIC(("data type Bit64u or Bit64u is not of length 8 bytes!"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
2006-01-26 01:20:00 +03:00
|
|
|
|
BX_DEBUG(("#(%u)all sanity checks passed!", BX_CPU_ID));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-25 18:42:57 +04:00
|
|
|
|
void BX_CPU_C::assert_checks(void)
|
|
|
|
|
{
|
|
|
|
|
// check CPU mode consistency
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-04-01 00:56:27 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR efer.get_LMA()) {
|
2007-07-09 19:16:14 +04:00
|
|
|
|
if (! BX_CPU_THIS_PTR cr0.get_PE()) {
|
2006-04-25 18:42:57 +04:00
|
|
|
|
BX_PANIC(("assert_checks: EFER.LMA is set when CR0.PE=0 !"));
|
|
|
|
|
}
|
|
|
|
|
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.l) {
|
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64)
|
|
|
|
|
BX_PANIC(("assert_checks: unconsistent cpu_mode BX_MODE_LONG_64 !"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_COMPAT)
|
|
|
|
|
BX_PANIC(("assert_checks: unconsistent cpu_mode BX_MODE_LONG_COMPAT !"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-03 00:46:54 +03:00
|
|
|
|
else
|
2006-04-25 18:42:57 +04:00
|
|
|
|
#endif
|
|
|
|
|
{
|
2007-07-09 19:16:14 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR cr0.get_PE()) {
|
2006-04-25 18:42:57 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR get_VM()) {
|
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode != BX_MODE_IA32_V8086)
|
|
|
|
|
BX_PANIC(("assert_checks: unconsistent cpu_mode BX_MODE_IA32_V8086 !"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode != BX_MODE_IA32_PROTECTED)
|
|
|
|
|
BX_PANIC(("assert_checks: unconsistent cpu_mode BX_MODE_IA32_PROTECTED !"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (BX_CPU_THIS_PTR cpu_mode != BX_MODE_IA32_REAL)
|
|
|
|
|
BX_PANIC(("assert_checks: unconsistent cpu_mode BX_MODE_IA32_REAL !"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
|
// check CR0 consistency
|
2010-03-26 00:33:07 +03:00
|
|
|
|
if (! check_CR0(BX_CPU_THIS_PTR cr0.val32))
|
|
|
|
|
BX_PANIC(("assert_checks: CR0 consistency checks failed !"));
|
2007-07-09 19:16:14 +04:00
|
|
|
|
|
2011-08-16 20:49:04 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 5
|
2010-03-26 00:33:07 +03:00
|
|
|
|
// check CR4 consistency
|
|
|
|
|
if (! check_CR4(BX_CPU_THIS_PTR cr4.val32))
|
|
|
|
|
BX_PANIC(("assert_checks: CR4 consistency checks failed !"));
|
2010-03-26 14:09:12 +03:00
|
|
|
|
#endif
|
2007-07-09 19:16:14 +04:00
|
|
|
|
|
2006-04-25 18:42:57 +04:00
|
|
|
|
#if BX_SUPPORT_X86_64
|
2006-05-20 00:04:33 +04:00
|
|
|
|
// VM should be OFF in long mode
|
2006-10-04 23:08:40 +04:00
|
|
|
|
if (long_mode()) {
|
2006-04-25 18:42:57 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR get_VM()) BX_PANIC(("assert_checks: VM is set in long mode !"));
|
|
|
|
|
}
|
2006-05-20 00:04:33 +04:00
|
|
|
|
|
|
|
|
|
// CS.L and CS.D_B are mutualy exclusive
|
|
|
|
|
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.l &&
|
|
|
|
|
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b)
|
|
|
|
|
{
|
|
|
|
|
BX_PANIC(("assert_checks: CS.l and CS.d_b set together !"));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-05-21 23:31:23 +04:00
|
|
|
|
// check LDTR type
|
2006-06-05 20:36:56 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR ldtr.cache.valid)
|
2006-05-21 23:31:23 +04:00
|
|
|
|
{
|
2006-06-05 20:36:56 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR ldtr.cache.type != BX_SYS_SEGMENT_LDT)
|
|
|
|
|
{
|
|
|
|
|
BX_PANIC(("assert_checks: LDTR is not LDT type !"));
|
|
|
|
|
}
|
2006-05-21 23:31:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check Task Register type
|
2006-06-05 20:36:56 +04:00
|
|
|
|
if(BX_CPU_THIS_PTR tr.cache.valid)
|
2006-05-21 23:31:23 +04:00
|
|
|
|
{
|
2006-06-05 20:36:56 +04:00
|
|
|
|
switch(BX_CPU_THIS_PTR tr.cache.type)
|
|
|
|
|
{
|
|
|
|
|
case BX_SYS_SEGMENT_BUSY_286_TSS:
|
|
|
|
|
case BX_SYS_SEGMENT_AVAIL_286_TSS:
|
2006-05-22 00:41:48 +04:00
|
|
|
|
#if BX_CPU_LEVEL >= 3
|
2009-04-05 23:09:44 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR tr.cache.u.segment.g != 0)
|
2006-06-05 20:36:56 +04:00
|
|
|
|
BX_PANIC(("assert_checks: tss286.g != 0 !"));
|
2009-04-05 23:09:44 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR tr.cache.u.segment.avl != 0)
|
2006-06-05 20:36:56 +04:00
|
|
|
|
BX_PANIC(("assert_checks: tss286.avl != 0 !"));
|
2006-05-22 00:41:48 +04:00
|
|
|
|
#endif
|
2006-06-05 20:36:56 +04:00
|
|
|
|
break;
|
|
|
|
|
case BX_SYS_SEGMENT_BUSY_386_TSS:
|
|
|
|
|
case BX_SYS_SEGMENT_AVAIL_386_TSS:
|
|
|
|
|
break;
|
2008-02-03 00:46:54 +03:00
|
|
|
|
default:
|
2006-06-05 20:36:56 +04:00
|
|
|
|
BX_PANIC(("assert_checks: TR is not TSS type !"));
|
|
|
|
|
}
|
2006-05-21 23:31:23 +04:00
|
|
|
|
}
|
2011-08-11 02:04:33 +04:00
|
|
|
|
|
2011-08-31 01:32:40 +04:00
|
|
|
|
#if BX_SUPPORT_X86_64 == 0 && BX_CPU_LEVEL >= 5
|
2011-08-11 02:04:33 +04:00
|
|
|
|
if (BX_CPU_THIS_PTR efer_suppmask & (BX_EFER_SCE_MASK |
|
|
|
|
|
BX_EFER_LME_MASK | BX_EFER_LMA_MASK | BX_EFER_FFXSR_MASK))
|
|
|
|
|
{
|
|
|
|
|
BX_PANIC(("assert_checks: EFER supports x86-64 specific bits !"));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-04-25 18:42:57 +04:00
|
|
|
|
}
|