Fixed CPU state after software reset (INIT).

Update instrumentation.
Clean extra space from plugin.h biosdev device name
This commit is contained in:
Stanislav Shwartsman 2008-11-18 20:55:59 +00:00
parent 1a28deb3aa
commit 3d60e1e20d
9 changed files with 67 additions and 52 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: init.cc,v 1.179 2008-09-08 15:45:56 sshwarts Exp $
// $Id: init.cc,v 1.180 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -858,7 +858,9 @@ void BX_CPU_C::reset(unsigned source)
BX_CPU_THIS_PTR alignment_check_mask = 0;
#endif
BX_CPU_THIS_PTR smbase = 0x30000;
if (source == BX_RESET_HARDWARE) {
BX_CPU_THIS_PTR smbase = 0x30000; // do not change SMBASE on INIT
}
BX_CPU_THIS_PTR cr0.setRegister(0x60000010);
// handle reserved bits
@ -900,7 +902,9 @@ void BX_CPU_C::reset(unsigned source)
BX_CPU_THIS_PTR msr.kernelgsbase = 0;
BX_CPU_THIS_PTR msr.tsc_aux = 0;
#endif
BX_CPU_THIS_PTR set_TSC(0);
if (source == BX_RESET_HARDWARE) {
BX_CPU_THIS_PTR set_TSC(0); // do not change TSC on INIT
}
#endif
#if BX_SUPPORT_SEP
@ -909,19 +913,22 @@ void BX_CPU_C::reset(unsigned source)
BX_CPU_THIS_PTR msr.sysenter_eip_msr = 0;
#endif
// Do not change MTRR on INIT
#if BX_SUPPORT_MTRR
for (n=0; n<16; n++)
BX_CPU_THIS_PTR msr.mtrrphys[n] = 0;
if (source == BX_RESET_HARDWARE) {
for (n=0; n<16; n++)
BX_CPU_THIS_PTR msr.mtrrphys[n] = 0;
BX_CPU_THIS_PTR msr.mtrrfix64k_00000 = 0; // all fix range MTRRs undefined according to manual
BX_CPU_THIS_PTR msr.mtrrfix16k_80000 = 0;
BX_CPU_THIS_PTR msr.mtrrfix16k_a0000 = 0;
BX_CPU_THIS_PTR msr.mtrrfix64k_00000 = 0; // all fix range MTRRs undefined according to manual
BX_CPU_THIS_PTR msr.mtrrfix16k_80000 = 0;
BX_CPU_THIS_PTR msr.mtrrfix16k_a0000 = 0;
for (n=0; n<8; n++)
BX_CPU_THIS_PTR msr.mtrrfix4k[n] = 0;
for (n=0; n<8; n++)
BX_CPU_THIS_PTR msr.mtrrfix4k[n] = 0;
BX_CPU_THIS_PTR msr.pat = BX_CONST64(0x0007040600070406);
BX_CPU_THIS_PTR msr.mtrr_deftype = 0;
BX_CPU_THIS_PTR msr.pat = BX_CONST64(0x0007040600070406);
BX_CPU_THIS_PTR msr.mtrr_deftype = 0;
}
#endif
BX_CPU_THIS_PTR EXT = 0;
@ -946,18 +953,22 @@ void BX_CPU_C::reset(unsigned source)
// Reset the Floating Point Unit
#if BX_SUPPORT_FPU
BX_CPU_THIS_PTR the_i387.reset(); // unchanged on #INIT
if (source == BX_RESET_HARDWARE) {
BX_CPU_THIS_PTR the_i387.reset();
}
#endif
// Reset XMM state
#if BX_SUPPORT_SSE >= 1 // unchanged on #INIT
for(n=0; n<BX_XMM_REGISTERS; n++)
{
BX_CPU_THIS_PTR xmm[n].xmm64u(0) = 0;
BX_CPU_THIS_PTR xmm[n].xmm64u(1) = 0;
}
if (source == BX_RESET_HARDWARE) {
for(n=0; n<BX_XMM_REGISTERS; n++)
{
BX_CPU_THIS_PTR xmm[n].xmm64u(0) = 0;
BX_CPU_THIS_PTR xmm[n].xmm64u(1) = 0;
}
BX_CPU_THIS_PTR mxcsr.mxcsr = MXCSR_RESET;
BX_CPU_THIS_PTR mxcsr.mxcsr = MXCSR_RESET;
}
#endif
#if BX_SUPPORT_SMP

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.cc,v 1.25 2008-10-01 11:36:04 akrisak Exp $
// $Id: instrument.cc,v 1.26 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -66,7 +66,7 @@ static logfunctions *instrument_log = new logfunctions ();
void bx_instr_init_env(void) {}
void bx_instr_exit_env(void) {}
void bx_instr_init(unsigned cpu)
void bx_instr_initialize(unsigned cpu)
{
assert(cpu < BX_SMP_PROCESSORS);
@ -76,7 +76,7 @@ void bx_instr_init(unsigned cpu)
fprintf(stderr, "Initialize cpu %d\n", cpu);
}
void bx_instr_reset(unsigned cpu)
void bx_instr_reset(unsigned cpu, unsigned type)
{
instruction[cpu].valid = 0;
instruction[cpu].num_data_accesses = 0;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.h,v 1.30 2008-10-01 11:36:04 akrisak Exp $
// $Id: instrument.h,v 1.31 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -61,8 +61,8 @@ void bx_instr_exit_env(void);
// called from the CPU core
void bx_instr_init(unsigned cpu);
void bx_instr_reset(unsigned cpu);
void bx_instr_initialize(unsigned cpu);
void bx_instr_reset(unsigned cpu, unsigned type);
void bx_instr_new_instruction(unsigned cpu);
void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip);
@ -83,9 +83,9 @@ void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, uns
# define BX_INSTR_EXIT_ENV() bx_instr_exit_env()
/* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id)
# define BX_INSTR_INITIALIZE(cpu_id) bx_instr_initialize(cpu_id)
# define BX_INSTR_EXIT(cpu_id)
# define BX_INSTR_RESET(cpu_id) bx_instr_reset(cpu_id)
# define BX_INSTR_RESET(cpu_id, type) bx_instr_reset(cpu_id, type)
# define BX_INSTR_HLT(cpu_id)
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags)
# define BX_INSTR_NEW_INSTRUCTION(cpu_id) bx_instr_new_instruction(cpu_id)
@ -149,9 +149,9 @@ void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, uns
# define BX_INSTR_EXIT_ENV()
/* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id)
# define BX_INSTR_INITIALIZE(cpu_id)
# define BX_INSTR_EXIT(cpu_id)
# define BX_INSTR_RESET(cpu_id)
# define BX_INSTR_RESET(cpu_id, type)
# define BX_INSTR_HLT(cpu_id)
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags)
# define BX_INSTR_NEW_INSTRUCTION(cpu_id)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.cc,v 1.20 2008-10-01 11:36:04 akrisak Exp $
// $Id: instrument.cc,v 1.21 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -37,7 +37,7 @@ static disassembler bx_disassembler;
void bx_instr_init_env(void) {}
void bx_instr_exit_env(void) {}
void bx_instr_init(unsigned cpu)
void bx_instr_initialize(unsigned cpu)
{
assert(cpu < BX_SMP_PROCESSORS);
@ -49,7 +49,7 @@ void bx_instr_init(unsigned cpu)
fprintf(stderr, "Initialize cpu %d\n", cpu);
}
void bxInstrumentation::bx_instr_reset()
void bxInstrumentation::bx_instr_reset(unsigned type)
{
valid = is_branch = 0;
num_data_accesses = 0;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.h,v 1.28 2008-10-01 11:36:04 akrisak Exp $
// $Id: instrument.h,v 1.29 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -99,7 +99,7 @@ public:
void toggle_active() { active = !active; }
bx_bool is_active() const { return active; }
void bx_instr_reset();
void bx_instr_reset(unsigned type);
void bx_instr_new_instruction();
void bx_instr_cnear_branch_taken(bx_address new_eip);
@ -128,9 +128,9 @@ extern bxInstrumentation *icpu;
# define BX_INSTR_EXIT_ENV() bx_instr_exit_env()
/* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id);
# define BX_INSTR_INITIALIZE(cpu_id) bx_instr_initialize(cpu_id);
# define BX_INSTR_EXIT(cpu_id)
# define BX_INSTR_RESET(cpu_id) icpu[cpu_id].bx_instr_reset()
# define BX_INSTR_RESET(cpu_id, type) icpu[cpu_id].bx_instr_reset(type)
# define BX_INSTR_HLT(cpu_id)
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags)
@ -194,9 +194,9 @@ extern bxInstrumentation *icpu;
# define BX_INSTR_EXIT_ENV()
/* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id)
# define BX_INSTR_INITIALIZE(cpu_id)
# define BX_INSTR_EXIT(cpu_id)
# define BX_INSTR_RESET(cpu_id)
# define BX_INSTR_RESET(cpu_id, type)
# define BX_INSTR_HLT(cpu_id)
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags)
# define BX_INSTR_NEW_INSTRUCTION(cpu_id)

View File

@ -17,6 +17,7 @@ directory to it, then customize it. Use:
-----------------------------------------------------------------------------
BOCHS instrumentation callbacks
void bx_instr_init_env();
@ -27,23 +28,26 @@ when bx_instr_init() is called it can access configuration parameters defined
by bx_instr_init_env(), so instrumentalization module can use additional
options in .bochsrc.
void bx_instr_exit_env();
The callback is called each time Bochs exits.
void bx_instr_init(unsigned cpu);
void bx_instr_initialize(unsigned cpu);
The callback is called each time, when Bochs initializes the CPU object. It
can be used for initialization of user's data, dynamic memory allocation and
etc.
void bx_instr_exit(unsigned cpu);
The callback is called each time, when Bochs destructs the CPU object. It can
be used for destruction of user's data, allocated by bx_instr_init callback.
void bx_instr_reset(unsigned cpu);
void bx_instr_reset(unsigned cpu, unsigned type);
The callback is called each time, when Bochs resets the CPU object. It would
be executed once at the start of simulation and each time that user presses

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.cc,v 1.28 2008-10-01 11:36:04 akrisak Exp $
// $Id: instrument.cc,v 1.29 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -32,9 +32,9 @@
void bx_instr_init_env(void) {}
void bx_instr_exit_env(void) {}
void bx_instr_init(unsigned cpu) {}
void bx_instr_initialize(unsigned cpu) {}
void bx_instr_exit(unsigned cpu) {}
void bx_instr_reset(unsigned cpu) {}
void bx_instr_reset(unsigned cpu, unsigned type) {}
void bx_instr_hlt(unsigned cpu) {}
void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flags) {}
void bx_instr_new_instruction(unsigned cpu) {}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.h,v 1.36 2008-10-01 11:36:04 akrisak Exp $
// $Id: instrument.h,v 1.37 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -61,9 +61,9 @@ void bx_instr_exit_env(void);
// called from the CPU core
void bx_instr_init(unsigned cpu);
void bx_instr_initialize(unsigned cpu);
void bx_instr_exit(unsigned cpu);
void bx_instr_reset(unsigned cpu);
void bx_instr_reset(unsigned cpu, unsigned type);
void bx_instr_hlt(unsigned cpu);
void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flags);
void bx_instr_new_instruction(unsigned cpu);
@ -110,9 +110,9 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value);
# define BX_INSTR_EXIT_ENV() bx_instr_exit_env()
/* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id)
# define BX_INSTR_INITIALIZE(cpu_id) bx_instr_initialize(cpu_id)
# define BX_INSTR_EXIT(cpu_id) bx_instr_exit(cpu_id)
# define BX_INSTR_RESET(cpu_id) bx_instr_reset(cpu_id)
# define BX_INSTR_RESET(cpu_id, type) bx_instr_reset(cpu_id, type)
# define BX_INSTR_HLT(cpu_id) bx_instr_hlt(cpu_id)
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags) \
@ -179,9 +179,9 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value);
# define BX_INSTR_EXIT_ENV()
/* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id)
# define BX_INSTR_INITIALIZE(cpu_id)
# define BX_INSTR_EXIT(cpu_id)
# define BX_INSTR_RESET(cpu_id)
# define BX_INSTR_RESET(cpu_id, type)
# define BX_INSTR_HLT(cpu_id)
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags)
# define BX_INSTR_NEW_INSTRUCTION(cpu_id)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: plugin.h,v 1.62 2008-02-15 22:05:38 sshwarts Exp $
// $Id: plugin.h,v 1.63 2008-11-18 20:55:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// This file provides macros and types needed for plugins. It is based on
@ -22,7 +22,7 @@ extern "C" {
#endif
#define BX_PLUGIN_UNMAPPED "unmapped"
#define BX_PLUGIN_BIOSDEV " biosdev"
#define BX_PLUGIN_BIOSDEV "biosdev"
#define BX_PLUGIN_CMOS "cmos"
#define BX_PLUGIN_VGA "vga"
#define BX_PLUGIN_FLOPPY "floppy"