From 85d10e4f727bf89c5fe66cddb46480d9629a36c2 Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Thu, 13 Dec 2007 21:41:32 +0000 Subject: [PATCH] Added MWAIT callback --- bochs/cpu/proc_ctrl.cc | 4 +++- bochs/instrument/example0/instrument.h | 4 +++- bochs/instrument/example1/instrument.h | 5 ++++- bochs/instrument/instrumentation.txt | 7 +++++++ bochs/instrument/stubs/instrument.cc | 3 ++- bochs/instrument/stubs/instrument.h | 8 +++++++- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/bochs/cpu/proc_ctrl.cc b/bochs/cpu/proc_ctrl.cc index b8499893a..90be91e01 100644 --- a/bochs/cpu/proc_ctrl.cc +++ b/bochs/cpu/proc_ctrl.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: proc_ctrl.cc,v 1.185 2007-12-03 21:43:14 sshwarts Exp $ +// $Id: proc_ctrl.cc,v 1.186 2007-12-13 21:41:32 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -2000,6 +2000,8 @@ void BX_CPU_C::MWAIT(bxInstruction_c *i) // will remain in a optimized state until one of the above // conditions is met. + BX_INSTR_MWAIT(BX_CPU_ID, BX_CPU_THIS_PTR monitor.monitor_begin, CACHE_LINE_SIZE, ECX); + #if BX_USE_IDLE_HACK bx_gui->sim_is_idle(); #endif diff --git a/bochs/instrument/example0/instrument.h b/bochs/instrument/example0/instrument.h index 6315aa32f..208a89f56 100644 --- a/bochs/instrument/example0/instrument.h +++ b/bochs/instrument/example0/instrument.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: instrument.h,v 1.18 2007-12-13 21:30:05 sshwarts Exp $ +// $Id: instrument.h,v 1.19 2007-12-13 21:41:32 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -78,6 +78,7 @@ void bx_instr_mem_data(unsigned cpu, bx_address lin, unsigned size, unsigned rw) # define BX_INSTR_SHUTDOWN(cpu_id) # define BX_INSTR_RESET(cpu_id) bx_instr_reset(cpu_id) # 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) /* called from command line debugger */ @@ -143,6 +144,7 @@ void bx_instr_mem_data(unsigned cpu, bx_address lin, unsigned size, unsigned rw) # define BX_INSTR_SHUTDOWN(cpu_id) # define BX_INSTR_RESET(cpu_id) # define BX_INSTR_HLT(cpu_id) +# define BX_INSTR_MWAIT(cpu_id, addr, len, flags) # define BX_INSTR_NEW_INSTRUCTION(cpu_id) /* called from command line debugger */ diff --git a/bochs/instrument/example1/instrument.h b/bochs/instrument/example1/instrument.h index e37fa20a0..e268f65cc 100644 --- a/bochs/instrument/example1/instrument.h +++ b/bochs/instrument/example1/instrument.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: instrument.h,v 1.16 2007-12-13 21:30:05 sshwarts Exp $ +// $Id: instrument.h,v 1.17 2007-12-13 21:41:32 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -126,6 +126,8 @@ extern bxInstrumentation *icpu; # define BX_INSTR_SHUTDOWN(cpu_id) # define BX_INSTR_RESET(cpu_id) icpu[cpu_id].bx_instr_reset() # define BX_INSTR_HLT(cpu_id) +# define BX_INSTR_MWAIT(cpu_id, addr, len, flags) + # define BX_INSTR_NEW_INSTRUCTION(cpu_id) icpu[cpu_id].bx_instr_new_instruction() /* called from command line debugger */ @@ -190,6 +192,7 @@ extern bxInstrumentation *icpu; # define BX_INSTR_SHUTDOWN(cpu_id) # define BX_INSTR_RESET(cpu_id) # define BX_INSTR_HLT(cpu_id) +# define BX_INSTR_MWAIT(cpu_id, addr, len, flags) # define BX_INSTR_NEW_INSTRUCTION(cpu_id) /* called from command line debugger */ diff --git a/bochs/instrument/instrumentation.txt b/bochs/instrument/instrumentation.txt index 3ec31890f..486a01036 100755 --- a/bochs/instrument/instrumentation.txt +++ b/bochs/instrument/instrumentation.txt @@ -42,6 +42,13 @@ RESET BUTTON on the simulator's control panel. The callback is called each time, when Bochs' emulated CPU enters to the HALT state. + void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flags); + +The callback is called each time, when Bochs' emulated CPU enters to the MWAIT +state. The callback receives monitored memory range and MWAIT flags as a +parameters. + + void bx_instr_new_instruction(unsigned cpu); The callback is called each time, when Bochs completes (commits) already diff --git a/bochs/instrument/stubs/instrument.cc b/bochs/instrument/stubs/instrument.cc index ba5a52986..fab6efe3a 100644 --- a/bochs/instrument/stubs/instrument.cc +++ b/bochs/instrument/stubs/instrument.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: instrument.cc,v 1.18 2007-12-13 21:30:05 sshwarts Exp $ +// $Id: instrument.cc,v 1.19 2007-12-13 21:41:32 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -33,6 +33,7 @@ void bx_instr_init(unsigned cpu) {} void bx_instr_shutdown(unsigned cpu) {} void bx_instr_reset(unsigned cpu) {} 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) {} void bx_instr_debug_promt() {} diff --git a/bochs/instrument/stubs/instrument.h b/bochs/instrument/stubs/instrument.h index 11851f425..3cf1e9eca 100644 --- a/bochs/instrument/stubs/instrument.h +++ b/bochs/instrument/stubs/instrument.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: instrument.h,v 1.22 2007-12-13 21:30:05 sshwarts Exp $ +// $Id: instrument.h,v 1.23 2007-12-13 21:41:32 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -56,6 +56,7 @@ void bx_instr_init(unsigned cpu); void bx_instr_shutdown(unsigned cpu); void bx_instr_reset(unsigned cpu); 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); void bx_instr_debug_promt(); @@ -105,6 +106,10 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value); # define BX_INSTR_SHUTDOWN(cpu_id) bx_instr_shutdown(cpu_id) # define BX_INSTR_RESET(cpu_id) bx_instr_reset(cpu_id) # define BX_INSTR_HLT(cpu_id) bx_instr_hlt(cpu_id) + +# define BX_INSTR_MWAIT(cpu_id, addr, len, flags) \ + bx_instr_hlt(cpu_id, addr, len, flags) + # define BX_INSTR_NEW_INSTRUCTION(cpu_id) bx_instr_new_instruction(cpu_id) /* called from command line debugger */ @@ -171,6 +176,7 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value); # define BX_INSTR_SHUTDOWN(cpu_id) # define BX_INSTR_RESET(cpu_id) # define BX_INSTR_HLT(cpu_id) +# define BX_INSTR_MWAIT(cpu_id, addr, len, flags) # define BX_INSTR_NEW_INSTRUCTION(cpu_id) /* called from command line debugger */