Clearify the code. x86-64 code always running in pmode so it is not needed to check if we are in protected mode everytime
This commit is contained in:
parent
bff2c04c5b
commit
169fa0c574
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: cpu.h,v 1.223 2005-07-04 17:44:08 sshwarts Exp $
|
||||
// $Id: cpu.h,v 1.224 2005-07-10 20:32:22 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -2712,6 +2712,9 @@ public: // for now...
|
||||
BX_SMF void call_protected(bxInstruction_c *, Bit16u cs, bx_address disp) BX_CPP_AttrRegparmN(3);
|
||||
BX_SMF void return_protected(bxInstruction_c *, Bit16u pop_bytes) BX_CPP_AttrRegparmN(2);
|
||||
BX_SMF void iret_protected(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
#if BX_SUPPORT_X86_64
|
||||
BX_SMF void long_return(bxInstruction_c *, Bit16u pop_bytes) BX_CPP_AttrRegparmN(2);
|
||||
#endif
|
||||
BX_SMF void validate_seg_regs(void);
|
||||
BX_SMF void stack_return_to_v86(Bit32u new_eip, Bit32u raw_cs_selector,
|
||||
Bit32u flags32);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: ctrl_xfer64.cc,v 1.34 2005-05-19 18:13:07 sshwarts Exp $
|
||||
// $Id: ctrl_xfer64.cc,v 1.35 2005-07-10 20:32:30 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -98,21 +98,10 @@ void BX_CPU_C::RETfar64_Iw(bxInstruction_c *i)
|
||||
BX_CPU_THIS_PTR show_flag |= Flag_ret;
|
||||
#endif
|
||||
|
||||
Bit16u imm16 = i->Iw();
|
||||
BX_ASSERT(protected_mode());
|
||||
|
||||
if (protected_mode()) {
|
||||
BX_PANIC(("Return protected is not implemented in x86-64 mode !"));
|
||||
BX_CPU_THIS_PTR return_protected(i, imm16);
|
||||
goto done;
|
||||
}
|
||||
long_return(i, i->Iw());
|
||||
|
||||
pop_64(&rip);
|
||||
pop_64(&rcs_raw);
|
||||
RIP = rip;
|
||||
load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], (Bit16u) rcs_raw);
|
||||
RSP += imm16;
|
||||
|
||||
done:
|
||||
BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET,
|
||||
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, BX_CPU_THIS_PTR rip);
|
||||
}
|
||||
@ -127,18 +116,10 @@ void BX_CPU_C::RETfar64(bxInstruction_c *i)
|
||||
BX_CPU_THIS_PTR show_flag |= Flag_ret;
|
||||
#endif
|
||||
|
||||
if ( protected_mode() ) {
|
||||
BX_PANIC(("Return protected is not implemented in x86-64 mode !"));
|
||||
BX_CPU_THIS_PTR return_protected(i, 0);
|
||||
goto done;
|
||||
}
|
||||
BX_ASSERT(protected_mode());
|
||||
|
||||
pop_64(&rip);
|
||||
pop_64(&rcs_raw); /* 64bit pop, upper 48 bits discarded */
|
||||
RIP = rip;
|
||||
load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], (Bit16u) rcs_raw);
|
||||
long_return(i, 0);
|
||||
|
||||
done:
|
||||
BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET,
|
||||
BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, BX_CPU_THIS_PTR rip);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: ctrl_xfer_pro.cc,v 1.41 2005-05-20 17:04:42 sshwarts Exp $
|
||||
// $Id: ctrl_xfer_pro.cc,v 1.42 2005-07-10 20:32:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -91,8 +91,8 @@ BX_CPU_C::jump_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
}
|
||||
}
|
||||
|
||||
/* segment must be PRESENT else #NP(selector) */
|
||||
if (descriptor.p == 0) {
|
||||
/* segment must be present else #NP(selector) */
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("jump_protected: p == 0"));
|
||||
exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
|
||||
return;
|
||||
@ -177,7 +177,7 @@ BX_CPU_C::jump_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
BX_DEBUG(("jump_protected: JUMP TO 286 CALL GATE"));
|
||||
|
||||
// gate must be present else #NP(gate selector)
|
||||
if (descriptor.p==0) {
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("jump_protected: task gate.p == 0"));
|
||||
exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
|
||||
return;
|
||||
@ -221,7 +221,7 @@ BX_CPU_C::jump_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
}
|
||||
|
||||
// code segment must be present else #NP(CS selector)
|
||||
if (gate_cs_descriptor.p==0) {
|
||||
if (! IS_PRESENT(gate_cs_descriptor)) {
|
||||
BX_ERROR(("jump_protected: code seg not present"));
|
||||
exception(BX_NP_EXCEPTION, gate_cs_raw & 0xfffc, 0);
|
||||
}
|
||||
@ -243,7 +243,7 @@ BX_CPU_C::jump_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
|
||||
case BX_TASK_GATE:
|
||||
// task gate must be present else #NP(gate selector)
|
||||
if (descriptor.p==0) {
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("jump_protected: task gate.p == 0"));
|
||||
exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
|
||||
return;
|
||||
@ -276,7 +276,7 @@ BX_CPU_C::jump_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
}
|
||||
|
||||
// task state segment must be present, else #NP(tss selector)
|
||||
if (tss_descriptor.p==0) {
|
||||
if (! IS_PRESENT(tss_descriptor)) {
|
||||
BX_ERROR(("jump_protected: task descriptor.p == 0"));
|
||||
exception(BX_NP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
}
|
||||
@ -307,7 +307,7 @@ BX_CPU_C::jump_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
#endif
|
||||
|
||||
// gate must be present else #NP(gate selector)
|
||||
if (descriptor.p==0) {
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("jump_protected: task gate.p == 0"));
|
||||
exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
|
||||
return;
|
||||
@ -350,7 +350,7 @@ BX_CPU_C::jump_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
}
|
||||
|
||||
// code segment must be present else #NP(CS selector)
|
||||
if (gate_cs_descriptor.p==0) {
|
||||
if (! IS_PRESENT(gate_cs_descriptor)) {
|
||||
BX_ERROR(("jump_protected: code seg not present"));
|
||||
exception(BX_NP_EXCEPTION, gate_cs_raw & 0xfffc, 0);
|
||||
}
|
||||
@ -440,7 +440,7 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
}
|
||||
|
||||
// segment must be present, else #NP(code seg selector)
|
||||
if (cs_descriptor.p == 0) {
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_ERROR(("call_protected: cs.p = 0"));
|
||||
exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
|
||||
}
|
||||
@ -556,7 +556,7 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
|
||||
case BX_TASK_GATE:
|
||||
// task gate must be present else #NP(gate selector)
|
||||
if (gate_descriptor.p==0) {
|
||||
if (! IS_PRESENT(gate_descriptor)) {
|
||||
BX_ERROR(("call_protected: task gate.p == 0"));
|
||||
exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
|
||||
return;
|
||||
@ -589,7 +589,7 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
}
|
||||
|
||||
// task state segment must be present, else #NP(tss selector)
|
||||
if (tss_descriptor.p==0) {
|
||||
if (! IS_PRESENT(tss_descriptor)) {
|
||||
BX_ERROR(("call_protected: task descriptor.p == 0"));
|
||||
exception(BX_NP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
|
||||
}
|
||||
@ -620,7 +620,7 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
// BX_INFO(("CALL: 32bit call gate"));
|
||||
|
||||
// call gate must be present, else #NP(call gate selector)
|
||||
if (gate_descriptor.p==0) {
|
||||
if (! IS_PRESENT(gate_descriptor)) {
|
||||
BX_ERROR(("call_protected: not present"));
|
||||
exception(BX_NP_EXCEPTION, gate_selector.value & 0xfffc, 0);
|
||||
}
|
||||
@ -738,7 +738,7 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
}
|
||||
|
||||
// segment must be present, else #SS(SS selector)
|
||||
if (ss_descriptor.p==0) {
|
||||
if (! IS_PRESENT(ss_descriptor)) {
|
||||
BX_ERROR(("call_protected: ss descriptor not present."));
|
||||
exception(BX_SS_EXCEPTION, SS_for_cpl_x & 0xfffc, 0);
|
||||
return;
|
||||
@ -932,6 +932,16 @@ BX_CPU_C::call_protected(bxInstruction_c *i, Bit16u cs_raw, bx_address dispBig)
|
||||
BX_PANIC(("call_protected: shouldn't get here!"));
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
|
||||
void BX_CPP_AttrRegparmN(2)
|
||||
BX_CPU_C::long_return(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
{
|
||||
BX_PANIC(("Return protected is not implemented in x86-64 mode !"));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void BX_CPP_AttrRegparmN(2)
|
||||
BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
{
|
||||
@ -991,7 +1001,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
}
|
||||
|
||||
// if return selector RPL == CPL then
|
||||
// RETURN TO SAME LEVEL
|
||||
// RETURN TO SAME PRIVILEGE LEVEL
|
||||
if ( cs_selector.rpl == CPL ) {
|
||||
//BX_INFO(("return: to same level %04x:%08x",
|
||||
// BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
|
||||
@ -1040,7 +1050,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
}
|
||||
|
||||
// code segment must be present, else #NP(selector)
|
||||
if (cs_descriptor.p==0) {
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_ERROR(("return_protected: not present"));
|
||||
exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
|
||||
return;
|
||||
@ -1093,9 +1103,9 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
/* + 2: CS | + 4: CS */
|
||||
/* + 0: IP | + 0: EIP */
|
||||
|
||||
//BX_INFO(("return: to outer level %04x:%08x",
|
||||
// BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
|
||||
// BX_CPU_THIS_PTR prev_eip));
|
||||
//BX_INFO(("return: to outer level %04x:%08x",
|
||||
// BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
|
||||
// BX_CPU_THIS_PTR prev_eip));
|
||||
|
||||
if (i->os32L()) {
|
||||
/* top 16+immediate bytes on stack must be within stack limits, else #SS(0) */
|
||||
@ -1158,8 +1168,8 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
}
|
||||
|
||||
/* segment must be present else #NP(selector) */
|
||||
if (cs_descriptor.p==0) {
|
||||
BX_INFO(("return_protected: segment not present"));
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_ERROR(("return_protected: segment not present"));
|
||||
exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
|
||||
return;
|
||||
}
|
||||
@ -1228,8 +1238,8 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
}
|
||||
|
||||
/* segment must be present else #SS(selector) */
|
||||
if (ss_descriptor.p==0) {
|
||||
BX_ERROR(("ss.p == 0"));
|
||||
if (! IS_PRESENT(ss_descriptor)) {
|
||||
BX_ERROR(("ss.present == 0"));
|
||||
exception(BX_SS_EXCEPTION, raw_ss_selector & 0xfffc, 0);
|
||||
return;
|
||||
}
|
||||
@ -1319,8 +1329,8 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
// TSS must be present, else #NP(new TSS selector)
|
||||
if (tss_descriptor.p==0) {
|
||||
BX_INFO(("iret: task descriptor.p == 0"));
|
||||
if (! IS_PRESENT(tss_descriptor)) {
|
||||
BX_ERROR(("iret: task descriptor.p == 0"));
|
||||
exception(BX_NP_EXCEPTION, raw_link_selector & 0xfffc, 0);
|
||||
}
|
||||
|
||||
@ -1442,8 +1452,8 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
// segment must be present else #NP(return selector)
|
||||
if ( cs_descriptor.p==0 ) {
|
||||
BX_PANIC(("iret: not present"));
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_ERROR(("iret: not present"));
|
||||
exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
|
||||
return;
|
||||
}
|
||||
@ -1524,8 +1534,8 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
/* SS must be present, else #NP(SS selector) */
|
||||
if ( ss_descriptor.p==0 ) {
|
||||
BX_PANIC(("iret: SS not present!"));
|
||||
if (! IS_PRESENT(ss_descriptor)) {
|
||||
BX_ERROR(("iret: SS not present!"));
|
||||
exception(BX_NP_EXCEPTION, raw_ss_selector & 0xfffc, 0);
|
||||
return;
|
||||
}
|
||||
@ -1699,8 +1709,8 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
// segment must be present else #NP(return selector)
|
||||
if ( cs_descriptor.p==0 ) {
|
||||
BX_PANIC(("iret: not present"));
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_ERROR(("iret: segment not present"));
|
||||
exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
|
||||
return;
|
||||
}
|
||||
@ -1812,7 +1822,7 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
/* SS must be present, else #NP(SS selector) */
|
||||
if ( ss_descriptor.p==0 ) {
|
||||
if (! IS_PRESENT(ss_descriptor)) {
|
||||
BX_ERROR(("iret: SS not present!"));
|
||||
exception(BX_NP_EXCEPTION, raw_ss_selector & 0xfffc, 0);
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: descriptor.h,v 1.7 2005-05-19 19:46:20 sshwarts Exp $
|
||||
// $Id: descriptor.h,v 1.8 2005-07-10 20:32:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -148,6 +148,7 @@ union {
|
||||
|
||||
} bx_descriptor_t;
|
||||
|
||||
#define IS_PRESENT(descriptor) (descriptor.p)
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define IS_LONG64_SEGMENT(descriptor) (descriptor.u.segment.l)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: exception.cc,v 1.57 2005-07-07 18:40:26 sshwarts Exp $
|
||||
// $Id: exception.cc,v 1.58 2005-07-10 20:32:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -111,7 +111,7 @@ void BX_CPU_C::long_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error_code
|
||||
}
|
||||
|
||||
// Gate must be present, else #NP(vector * 8 + 2 + EXT)
|
||||
if (gate_descriptor.p == 0) {
|
||||
if (! IS_PRESENT(gate_descriptor)) {
|
||||
BX_ERROR(("interrupt(long mode): p == 0"));
|
||||
exception(BX_NP_EXCEPTION, vector*8 + 2, 0);
|
||||
}
|
||||
@ -157,7 +157,7 @@ void BX_CPU_C::long_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error_code
|
||||
}
|
||||
|
||||
// segment must be present, else #NP(selector + EXT)
|
||||
if ( cs_descriptor.p==0 ) {
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_ERROR(("interrupt(long mode): segment not present"));
|
||||
exception(BX_NP_EXCEPTION, cs_selector.value & 0xfffc, 0);
|
||||
}
|
||||
@ -351,7 +351,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
|
||||
}
|
||||
|
||||
// Gate must be present, else #NP(vector * 8 + 2 + EXT)
|
||||
if (gate_descriptor.p == 0) {
|
||||
if (! IS_PRESENT(gate_descriptor)) {
|
||||
BX_DEBUG(("interrupt(): gate not present"));
|
||||
exception(BX_NP_EXCEPTION, vector*8 + 2, 0);
|
||||
}
|
||||
@ -458,8 +458,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
|
||||
}
|
||||
|
||||
// segment must be present, else #NP(selector + EXT)
|
||||
if ( cs_descriptor.p==0 )
|
||||
{
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_DEBUG(("interrupt(): segment not present"));
|
||||
exception(BX_NP_EXCEPTION, cs_selector.value & 0xfffc, 0);
|
||||
}
|
||||
@ -525,8 +524,8 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
|
||||
}
|
||||
|
||||
// seg must be present, else #SS(SS selector + ext)
|
||||
if (ss_descriptor.p==0) {
|
||||
BX_PANIC(("interrupt(): SS not present"));
|
||||
if (! IS_PRESENT(ss_descriptor)) {
|
||||
BX_ERROR(("interrupt(): SS not present"));
|
||||
exception(BX_SS_EXCEPTION, SS_for_cpl_x & 0xfffc, 0);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: protect_ctrl.cc,v 1.39 2005-06-22 18:13:45 sshwarts Exp $
|
||||
// $Id: protect_ctrl.cc,v 1.40 2005-07-10 20:32:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -390,7 +390,7 @@ BX_CPU_C::LLDT_Ew(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
/* #NP(selector) if LDT descriptor is not present */
|
||||
if (descriptor.p==0) {
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("LLDT: LDT descriptor not present!"));
|
||||
exception(BX_NP_EXCEPTION, raw_selector & 0xfffc, 0);
|
||||
}
|
||||
@ -486,7 +486,7 @@ void BX_CPU_C::LTR_Ew(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
/* #NP(selector) if TSS descriptor is not present */
|
||||
if (descriptor.p==0) {
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("LTR: LDT descriptor not present!"));
|
||||
exception(BX_NP_EXCEPTION, raw_selector & 0xfffc, 0);
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: segment_ctrl_pro.cc,v 1.38 2005-05-19 18:13:08 sshwarts Exp $
|
||||
// $Id: segment_ctrl_pro.cc,v 1.39 2005-07-10 20:32:32 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -159,7 +159,7 @@ BX_CPU_C::load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value)
|
||||
}
|
||||
|
||||
/* segment must be marked PRESENT else #SS(selector) */
|
||||
if (descriptor.p == 0) {
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("load_seg_reg(): not present"));
|
||||
exception(BX_SS_EXCEPTION, new_value & 0xfffc, 0);
|
||||
}
|
||||
@ -274,7 +274,7 @@ BX_CPU_C::load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value)
|
||||
}
|
||||
|
||||
/* segment must be marked PRESENT else #NP(selector) */
|
||||
if (descriptor.p == 0) {
|
||||
if (! IS_PRESENT(descriptor)) {
|
||||
BX_ERROR(("load_seg_reg: segment not present"));
|
||||
exception(BX_NP_EXCEPTION, new_value & 0xfffc, 0);
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: tasking.cc,v 1.21 2005-06-22 18:13:45 sshwarts Exp $
|
||||
// $Id: tasking.cc,v 1.22 2005-07-10 20:32:32 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -557,11 +557,12 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
// LDT of new task is present in memory, else #TS(new tasks's LDT)
|
||||
else if (ldt_descriptor.p==0) {
|
||||
if (! IS_PRESENT(ldt_descriptor)) {
|
||||
exception_no = BX_TS_EXCEPTION;
|
||||
error_code = raw_ldt_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
|
||||
// All checks pass, fill in LDTR shadow cache
|
||||
BX_CPU_THIS_PTR ldtr.cache = ldt_descriptor;
|
||||
}
|
||||
@ -603,7 +604,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
// if non-conforming then DPL must equal selector RPL else #TS(CS)
|
||||
else if (cs_descriptor.u.segment.c_ed==0 &&
|
||||
if (cs_descriptor.u.segment.c_ed==0 &&
|
||||
cs_descriptor.dpl!=cs_selector.rpl)
|
||||
{
|
||||
BX_INFO(("task_switch: non-conforming: CS.dpl!=CS.RPL"));
|
||||
@ -613,7 +614,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
// if conforming then DPL must be <= selector RPL else #TS(CS)
|
||||
else if (cs_descriptor.u.segment.c_ed &&
|
||||
if (cs_descriptor.u.segment.c_ed &&
|
||||
cs_descriptor.dpl>cs_selector.rpl)
|
||||
{
|
||||
BX_INFO(("task_switch: conforming: CS.dpl>RPL"));
|
||||
@ -623,8 +624,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
// Code segment is present in memory, else #NP(new code segment)
|
||||
else if (cs_descriptor.p==0)
|
||||
{
|
||||
if (! IS_PRESENT(cs_descriptor)) {
|
||||
BX_PANIC(("task_switch: CS.p==0"));
|
||||
exception_no = BX_NP_EXCEPTION;
|
||||
error_code = raw_cs_selector & 0xfffc;
|
||||
@ -671,7 +671,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
//
|
||||
// Stack segment is present in memory, else #SF(new stack segment)
|
||||
//
|
||||
else if (ss_descriptor.p==0) {
|
||||
if (! IS_PRESENT(ss_descriptor)) {
|
||||
BX_PANIC(("task_switch: SS not present"));
|
||||
exception_no = BX_SS_EXCEPTION;
|
||||
error_code = raw_ss_selector & 0xfffc;
|
||||
@ -679,7 +679,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
// Stack segment DPL matches CS.RPL, else #TS(new stack segment)
|
||||
else if (ss_descriptor.dpl != cs_selector.rpl) {
|
||||
if (ss_descriptor.dpl != cs_selector.rpl) {
|
||||
BX_PANIC(("task_switch: SS.rpl != CS.RPL"));
|
||||
exception_no = BX_TS_EXCEPTION;
|
||||
error_code = raw_ss_selector & 0xfffc;
|
||||
@ -687,7 +687,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
// Stack segment DPL matches selector RPL, else #TS(new stack segment)
|
||||
else if (ss_descriptor.dpl != ss_selector.rpl) {
|
||||
if (ss_descriptor.dpl != ss_selector.rpl) {
|
||||
BX_PANIC(("task_switch: SS.dpl != SS.rpl"));
|
||||
exception_no = BX_TS_EXCEPTION;
|
||||
error_code = raw_ss_selector & 0xfffc;
|
||||
@ -695,8 +695,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
#if 0
|
||||
// +++
|
||||
else if (ss_descriptor.u.segment.d_b && (tss_descriptor->type<9)) {
|
||||
if (ss_descriptor.u.segment.d_b && (tss_descriptor->type<9)) {
|
||||
BX_DEBUG(( "++++++++++++++++++++++++++" ));
|
||||
exception_no = BX_TS_EXCEPTION;
|
||||
error_code = raw_ss_selector & 0xfffc;
|
||||
@ -735,6 +734,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
parse_descriptor(dword1, dword2, &ds_descriptor);
|
||||
|
||||
if (ds_descriptor.valid==0 || ds_descriptor.segment==0 ||
|
||||
(ds_descriptor.u.segment.executable &&
|
||||
ds_descriptor.u.segment.r_w==0))
|
||||
@ -744,17 +744,19 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
error_code = raw_ds_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
|
||||
// if data or non-conforming code
|
||||
else if (ds_descriptor.type<12 &&
|
||||
(ds_descriptor.dpl<cs_selector.rpl ||
|
||||
ds_descriptor.dpl<ds_selector.rpl))
|
||||
if (ds_descriptor.type<12 &&
|
||||
(ds_descriptor.dpl<cs_selector.rpl ||
|
||||
ds_descriptor.dpl<ds_selector.rpl))
|
||||
{
|
||||
BX_PANIC(("task_switch: DS.dpl not valid"));
|
||||
exception_no = BX_TS_EXCEPTION;
|
||||
error_code = raw_ds_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
else if (ds_descriptor.p==0) {
|
||||
|
||||
if (! IS_PRESENT(ds_descriptor)) {
|
||||
BX_PANIC(("task_switch: DS.p==0"));
|
||||
exception_no = BX_NP_EXCEPTION;
|
||||
error_code = raw_ds_selector & 0xfffc;
|
||||
@ -779,6 +781,7 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
}
|
||||
|
||||
parse_descriptor(dword1, dword2, &es_descriptor);
|
||||
|
||||
if (es_descriptor.valid==0 || es_descriptor.segment==0 ||
|
||||
(es_descriptor.u.segment.executable &&
|
||||
es_descriptor.u.segment.r_w==0))
|
||||
@ -788,17 +791,19 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
error_code = raw_es_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
|
||||
// if data or non-conforming code
|
||||
else if (es_descriptor.type<12 &&
|
||||
(es_descriptor.dpl<cs_selector.rpl ||
|
||||
es_descriptor.dpl<es_selector.rpl))
|
||||
if (es_descriptor.type<12 &&
|
||||
(es_descriptor.dpl<cs_selector.rpl ||
|
||||
es_descriptor.dpl<es_selector.rpl))
|
||||
{
|
||||
BX_PANIC(("task_switch: ES.dpl not valid"));
|
||||
exception_no = BX_TS_EXCEPTION;
|
||||
error_code = raw_es_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
else if (es_descriptor.p==0) {
|
||||
|
||||
if (! IS_PRESENT(es_descriptor)) {
|
||||
BX_PANIC(("task_switch: ES.p==0"));
|
||||
exception_no = BX_NP_EXCEPTION;
|
||||
error_code = raw_es_selector & 0xfffc;
|
||||
@ -832,8 +837,9 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
error_code = raw_fs_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
|
||||
// if data or non-conforming code
|
||||
else if (fs_descriptor.type<12 &&
|
||||
if (fs_descriptor.type<12 &&
|
||||
(fs_descriptor.dpl<cs_selector.rpl ||
|
||||
fs_descriptor.dpl<fs_selector.rpl))
|
||||
{
|
||||
@ -842,7 +848,8 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
error_code = raw_fs_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
else if (fs_descriptor.p==0) {
|
||||
|
||||
if (! IS_PRESENT(fs_descriptor)) {
|
||||
BX_PANIC(("task_switch: FS.p==0"));
|
||||
exception_no = BX_NP_EXCEPTION;
|
||||
error_code = raw_fs_selector & 0xfffc;
|
||||
@ -876,17 +883,19 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector,
|
||||
error_code = raw_gs_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
|
||||
// if data or non-conforming code
|
||||
else if (gs_descriptor.type<12 &&
|
||||
(gs_descriptor.dpl<cs_selector.rpl ||
|
||||
gs_descriptor.dpl<gs_selector.rpl))
|
||||
if (gs_descriptor.type<12 &&
|
||||
(gs_descriptor.dpl<cs_selector.rpl ||
|
||||
gs_descriptor.dpl<gs_selector.rpl))
|
||||
{
|
||||
BX_PANIC(("task_switch: GS.dpl not valid"));
|
||||
exception_no = BX_TS_EXCEPTION;
|
||||
error_code = raw_gs_selector & 0xfffc;
|
||||
goto post_exception;
|
||||
}
|
||||
else if (gs_descriptor.p==0) {
|
||||
|
||||
if (! IS_PRESENT(gs_descriptor)) {
|
||||
BX_PANIC(("task_switch: GS.p==0"));
|
||||
exception_no = BX_NP_EXCEPTION;
|
||||
error_code = raw_gs_selector & 0xfffc;
|
||||
|
Loading…
Reference in New Issue
Block a user