From: Stanislav S. <ssh...@us...> - 2005-03-30 20:53:35
|
Update of /cvsroot/bochs/bochs/cpu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3541 Modified Files: cpu.h exception.cc proc_ctrl.cc segment_ctrl_pro.cc Log Message: Added debug messages for interrupt function in long mode Added mode switch debug prints Index: cpu.h =================================================================== RCS file: /cvsroot/bochs/bochs/cpu/cpu.h,v retrieving revision 1.211 retrieving revision 1.212 diff -u -d -r1.211 -r1.212 --- cpu.h 29 Mar 2005 21:37:06 -0000 1.211 +++ cpu.h 30 Mar 2005 20:52:42 -0000 1.212 @@ -2743,7 +2743,7 @@ BX_SMF void decrementESPForPush(unsigned nBytes, Bit32u *eSP); BX_SMF void sanity_checks(void); - BX_SMF void debug(Bit32u offset); + BX_SMF void debug(bx_address offset); #if BX_EXTERNAL_DEBUGGER BX_SMF void trap_debugger(bx_bool callnow); Index: exception.cc =================================================================== RCS file: /cvsroot/bochs/bochs/cpu/exception.cc,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- exception.cc 22 Mar 2005 18:19:54 -0000 1.50 +++ exception.cc 30 Mar 2005 20:52:49 -0000 1.51 @@ -63,7 +63,8 @@ #endif #endif -//BX_DEBUG(( "::interrupt(%u)", vector )); + BX_DEBUG(("interrupt(): vector = %u, INT = %u, EXT = %u", + (unsigned) vector, (unsigned) is_INT, (unsigned) BX_CPU_THIS_PTR EXT)); BX_INSTR_INTERRUPT(BX_CPU_ID, vector); invalidate_prefetch_q(); @@ -74,23 +75,16 @@ BX_CPU_THIS_PTR inhibit_mask = 0; #if BX_CPU_LEVEL >= 2 -// unsigned prev_errno; - - BX_DEBUG(("interrupt(): vector = %u, INT = %u, EXT = %u", - (unsigned) vector, (unsigned) is_INT, (unsigned) BX_CPU_THIS_PTR EXT)); BX_CPU_THIS_PTR save_cs = BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS]; BX_CPU_THIS_PTR save_ss = BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS]; BX_CPU_THIS_PTR save_eip = EIP; BX_CPU_THIS_PTR save_esp = ESP; -// prev_errno = BX_CPU_THIS_PTR errorno; - #if BX_SUPPORT_X86_64 if (BX_CPU_THIS_PTR msr.lma) { // long mode interrupt - Bit64u idtindex; Bit32u dword1, dword2, dword3; @@ -105,12 +99,10 @@ // else #GP(vector number*16 + 2 + EXT) idtindex = vector*16; if ( (idtindex + 15) > BX_CPU_THIS_PTR idtr.limit) { - BX_DEBUG(("IDT.limit = %04x", (unsigned) BX_CPU_THIS_PTR idtr.limit)); - BX_DEBUG(("IDT.base = %06x", (unsigned) BX_CPU_THIS_PTR idtr.base)); - BX_DEBUG(("interrupt vector must be within IDT table limits")); - BX_DEBUG(("bailing")); - BX_DEBUG(("interrupt(): vector > idtr.limit")); - + BX_ERROR(("IDT.limit = %04x", (unsigned) BX_CPU_THIS_PTR idtr.limit)); + BX_ERROR(("IDT.base = %06x", (unsigned) BX_CPU_THIS_PTR idtr.base)); + BX_ERROR(("interrupt vector must be within IDT table limits")); + BX_ERROR(("long mode interrupt(): vector > idtr.limit")); exception(BX_GP_EXCEPTION, vector*16 + 2, 0); } @@ -126,7 +118,7 @@ if ((gate_descriptor.valid==0) || gate_descriptor.segment) { - BX_DEBUG(("interrupt(): gate descriptor is not valid sys seg")); + BX_ERROR(("long mode interrupt(): gate descriptor is not valid sys seg")); exception(BX_GP_EXCEPTION, vector*8 + 2, 0); } @@ -138,7 +130,7 @@ case BX_386_TRAP_GATE: break; default: - BX_DEBUG(("interrupt(): gate.type(%u) != {5,6,7,14,15}", + BX_ERROR(("long mode interrupt(): gate.type(%u) != {5,6,7,14,15}", (unsigned) gate_descriptor.type)); exception(BX_GP_EXCEPTION, vector*8 + 2, 0); return; @@ -148,14 +140,14 @@ // else #GP(vector * 8 + 2 + EXT) if (is_INT && (gate_descriptor.dpl < CPL)) { - BX_DEBUG(("interrupt(): is_INT && (dpl < CPL)")); + BX_ERROR(("long mode interrupt(): is_INT && (dpl < CPL)")); exception(BX_GP_EXCEPTION, vector*8 + 2, 0); return; } // Gate must be present, else #NP(vector * 8 + 2 + EXT) if (gate_descriptor.p == 0) { - BX_DEBUG(("interrupt(): p == 0")); + BX_ERROR(("long mode interrupt(): p == 0")); exception(BX_NP_EXCEPTION, vector*8 + 2, 0); } @@ -187,7 +179,7 @@ cs_descriptor.u.segment.executable==0 || cs_descriptor.dpl>CPL) { - BX_DEBUG(("interrupt(): not code segment")); + BX_ERROR(("long mode interrupt(): not code segment")); exception(BX_GP_EXCEPTION, cs_selector.value & 0xfffc, 0); } @@ -195,13 +187,13 @@ if ( cs_descriptor.u.segment.l == 0 || cs_descriptor.u.segment.d_b == 1) { - BX_DEBUG(("interrupt(): must be 64 bit segment")); + BX_ERROR(("long mode interrupt(): must be 64 bit segment")); exception(BX_GP_EXCEPTION, vector, 0); } // segment must be present, else #NP(selector + EXT) if ( cs_descriptor.p==0 ) { - BX_DEBUG(("interrupt(): segment not present")); + BX_ERROR(("long mode interrupt(): segment not present")); exception(BX_NP_EXCEPTION, cs_selector.value & 0xfffc, 0); } @@ -213,13 +205,12 @@ Bit64u RSP_for_cpl_x, old_RSP; bx_descriptor_t ss_descriptor; bx_selector_t ss_selector; - int savemode; - BX_DEBUG(("interrupt(): INTERRUPT TO INNER PRIVILEGE")); + BX_ERROR(("long mode interrupt(): INTERRUPT TO INNER PRIVILEGE")); // check selector and descriptor for new stack in current TSS if (ist > 0) { - BX_DEBUG(("trap to IST, vector = %d\n",ist)); + BX_ERROR(("long mode interrupt(): trap to IST, vector = %d\n",ist)); get_RSP_from_TSS(ist+3,&RSP_for_cpl_x); } else { @@ -241,7 +232,7 @@ // load new RSP values from TSS - savemode = BX_CPU_THIS_PTR cpu_mode; + int savemode = BX_CPU_THIS_PTR cpu_mode; BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_64; // need to switch to 64 bit mode temporarily here. @@ -294,12 +285,15 @@ // INTERRUPT TO SAME PRIVILEGE LEVEL: if (cs_descriptor.u.segment.c_ed==1 || cs_descriptor.dpl==CPL) { - BX_DEBUG(("int_trap_gate286(): INTERRUPT TO SAME PRIVILEGE")); + BX_ERROR(("long mode interrupt(): INTERRUPT TO SAME PRIVILEGE")); Bit64u old_RSP = RSP; // align stack RSP = RSP & BX_CONST64(0xfffffffffffffff0); + int savemode = BX_CPU_THIS_PTR cpu_mode; + BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_64; + // push flags onto stack // push current CS selector onto stack // push return offset onto stack @@ -311,6 +305,8 @@ if ( is_error_code ) push_64(error_code); + BX_CPU_THIS_PTR cpu_mode = savemode; + // load CS:IP from gate // load CS descriptor // set the RPL field of CS to CPL @@ -328,12 +324,12 @@ } // else #GP(CS selector + ext) - BX_DEBUG(("interrupt: bad descriptor")); - BX_DEBUG(("c_ed=%u, descriptor.dpl=%u, CPL=%u", + BX_ERROR(("long mode interrupt(): bad descriptor")); + BX_ERROR(("c_ed=%u, descriptor.dpl=%u, CPL=%u", (unsigned) cs_descriptor.u.segment.c_ed, (unsigned) cs_descriptor.dpl, (unsigned) CPL)); - BX_DEBUG(("cs.segment = %u", (unsigned) cs_descriptor.segment)); + BX_ERROR(("cs.segment = %u", (unsigned) cs_descriptor.segment)); exception(BX_GP_EXCEPTION, cs_selector.value & 0xfffc, 0); } else @@ -356,7 +352,6 @@ BX_DEBUG(("IDT.limit = %04x", (unsigned) BX_CPU_THIS_PTR idtr.limit)); BX_DEBUG(("IDT.base = %06x", (unsigned) BX_CPU_THIS_PTR idtr.base)); BX_DEBUG(("interrupt vector must be within IDT table limits")); - BX_DEBUG(("bailing")); BX_DEBUG(("interrupt(): vector > idtr.limit")); exception(BX_GP_EXCEPTION, vector*8 + 2, 0); } Index: proc_ctrl.cc =================================================================== RCS file: /cvsroot/bochs/bochs/cpu/proc_ctrl.cc,v retrieving revision 1.100 retrieving revision 1.101 diff -u -d -r1.100 -r1.101 --- proc_ctrl.cc 17 Mar 2005 20:50:39 -0000 1.100 +++ proc_ctrl.cc 30 Mar 2005 20:53:00 -0000 1.101 @@ -1337,10 +1337,12 @@ if (prev_pe==0 && BX_CPU_THIS_PTR cr0.pe) { enter_protected_mode(); + BX_DEBUG(("Enter Protected Mode")); BX_CPU_THIS_PTR cpu_mode = BX_MODE_IA32_PROTECTED; } else if (prev_pe==1 && BX_CPU_THIS_PTR cr0.pe==0) { enter_real_mode(); + BX_DEBUG(("Enter Real Mode")); BX_CPU_THIS_PTR cpu_mode = BX_MODE_IA32_REAL; } @@ -1352,6 +1354,7 @@ exception(BX_GP_EXCEPTION, 0, 0); } BX_CPU_THIS_PTR msr.lma = 1; + BX_DEBUG(("Enter Compatibility Mode")); BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_COMPAT; #if BX_EXTERNAL_DEBUGGER //trap_debugger(0); @@ -1365,9 +1368,11 @@ } BX_CPU_THIS_PTR msr.lma = 0; if (BX_CPU_THIS_PTR cr0.pe) { + BX_DEBUG(("Enter Protected Mode")); BX_CPU_THIS_PTR cpu_mode = BX_MODE_IA32_PROTECTED; } else { + BX_DEBUG(("Enter Real Mode")); BX_CPU_THIS_PTR cpu_mode = BX_MODE_IA32_REAL; } #if BX_EXTERNAL_DEBUGGER Index: segment_ctrl_pro.cc =================================================================== RCS file: /cvsroot/bochs/bochs/cpu/segment_ctrl_pro.cc,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- segment_ctrl_pro.cc 29 Mar 2005 21:37:06 -0000 1.33 +++ segment_ctrl_pro.cc 30 Mar 2005 20:53:04 -0000 1.34 @@ -564,6 +564,7 @@ loadSRegLMNominal(BX_SEG_REG_CS, selector->value, 0, cpl); } else { + BX_INFO(("Compatibility Mode Activated")); BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_COMPAT; } } |