Fixed bug prevented to boot Win98

This commit is contained in:
Stanislav Shwartsman 2007-11-30 08:49:12 +00:00
parent 943cc3e974
commit a0147fe055
5 changed files with 16 additions and 101 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.378 2007-11-29 21:45:10 sshwarts Exp $
// $Id: cpu.h,v 1.379 2007-11-30 08:49:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -3243,7 +3243,6 @@ public: // for now...
BX_SMF void pop_64(Bit64u *value64_ptr);
BX_SMF bx_bool can_push(bx_descriptor_t *descriptor, Bit32u esp, Bit32u bytes) BX_CPP_AttrRegparmN(3);
BX_SMF bx_bool can_pop(Bit32u bytes);
BX_SMF void decrementESPForPush(unsigned nBytes, Bit32u *eSP);
BX_SMF void sanity_checks(void);
BX_SMF void assert_checks(void);
BX_SMF void enter_system_management_mode(void);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: exception.cc,v 1.96 2007-11-24 14:22:33 sshwarts Exp $
// $Id: exception.cc,v 1.97 2007-11-30 08:49:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -428,7 +428,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
IS_DATA_SEGMENT(cs_descriptor.type) ||
cs_descriptor.dpl>CPL)
{
BX_ERROR(("interrupt(): not accessable or not code segment"));
BX_ERROR(("interrupt(): not accessable or not code segment cs=0x%04x", cs_selector.value));
exception(BX_GP_EXCEPTION, cs_selector.value & 0xfffc, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: segment_ctrl_pro.cc,v 1.76 2007-11-24 14:22:34 sshwarts Exp $
// $Id: segment_ctrl_pro.cc,v 1.77 2007-11-30 08:49:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -139,7 +139,7 @@ BX_CPU_C::load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value)
parse_descriptor(dword1, dword2, &descriptor);
if (descriptor.valid==0) {
BX_ERROR(("load_seg_reg(%s): valid bit cleared", strseg(seg)));
BX_ERROR(("load_seg_reg(%s, 0x%04x): invalid segment", strseg(seg), new_value));
exception(BX_GP_EXCEPTION, new_value & 0xfffc, 0);
}
@ -147,7 +147,7 @@ BX_CPU_C::load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value)
if (descriptor.segment==0 || (IS_CODE_SEGMENT(descriptor.type) &&
IS_CODE_SEGMENT_READABLE(descriptor.type) == 0))
{
BX_ERROR(("load_seg_reg(%s): not data or readable code", strseg(seg)));
BX_ERROR(("load_seg_reg(%s, 0x%04x): not data or readable code", strseg(seg), new_value));
exception(BX_GP_EXCEPTION, new_value & 0xfffc, 0);
}
@ -157,14 +157,14 @@ BX_CPU_C::load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value)
IS_CODE_SEGMENT_NON_CONFORMING(descriptor.type))
{
if ((selector.rpl > descriptor.dpl) || (CPL > descriptor.dpl)) {
BX_ERROR(("load_seg_reg(%s): RPL & CPL must be <= DPL", strseg(seg)));
BX_ERROR(("load_seg_reg(%s, 0x%04x): RPL & CPL must be <= DPL", strseg(seg), new_value));
exception(BX_GP_EXCEPTION, new_value & 0xfffc, 0);
}
}
/* segment must be marked PRESENT else #NP(selector) */
if (! IS_PRESENT(descriptor)) {
BX_ERROR(("load_seg_reg(%s): segment not present", strseg(seg)));
BX_ERROR(("load_seg_reg(%s, 0x%04x): segment not present", strseg(seg), new_value));
exception(BX_NP_EXCEPTION, new_value & 0xfffc, 0);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: stack32.cc,v 1.41 2007-11-24 14:22:34 sshwarts Exp $
// $Id: stack32.cc,v 1.42 2007-11-30 08:49:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -77,85 +77,32 @@ void BX_CPU_C::POP_ERX(bxInstruction_c *i)
void BX_CPU_C::PUSH32_CS(bxInstruction_c *i)
{
Bit32u eSP;
decrementESPForPush(4, &eSP);
write_virtual_word(BX_SEG_REG_SS, eSP,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value);
push_32(BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value);
}
void BX_CPU_C::PUSH32_DS(bxInstruction_c *i)
{
Bit32u eSP;
decrementESPForPush(4, &eSP);
write_virtual_word(BX_SEG_REG_SS, eSP,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value);
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
ESP = eSP;
}
else {
SP = (Bit16u) eSP;
}
push_32(BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value);
}
void BX_CPU_C::PUSH32_ES(bxInstruction_c *i)
{
Bit32u eSP;
decrementESPForPush(4, &eSP);
write_virtual_word(BX_SEG_REG_SS, eSP,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value);
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
ESP = eSP;
}
else {
SP = (Bit16u) eSP;
}
push_32(BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value);
}
void BX_CPU_C::PUSH32_FS(bxInstruction_c *i)
{
Bit32u eSP;
decrementESPForPush(4, &eSP);
write_virtual_word(BX_SEG_REG_SS, eSP,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value);
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
ESP = eSP;
}
else {
SP = (Bit16u) eSP;
}
push_32(BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value);
}
void BX_CPU_C::PUSH32_GS(bxInstruction_c *i)
{
Bit32u eSP;
decrementESPForPush(4, &eSP);
write_virtual_word(BX_SEG_REG_SS, eSP,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value);
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
ESP = eSP;
}
else {
SP = (Bit16u) eSP;
}
push_32(BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value);
}
void BX_CPU_C::PUSH32_SS(bxInstruction_c *i)
{
Bit32u eSP;
decrementESPForPush(4, &eSP);
write_virtual_word(BX_SEG_REG_SS, eSP,
&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value);
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
ESP = eSP;
}
else {
SP = (Bit16u) eSP;
}
push_32(BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value);
}
void BX_CPU_C::POP32_DS(bxInstruction_c *i)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: stack_pro.cc,v 1.32 2007-11-24 14:22:34 sshwarts Exp $
// $Id: stack_pro.cc,v 1.33 2007-11-30 08:49:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -328,34 +328,3 @@ bx_bool BX_CPU_C::can_pop(Bit32u bytes)
return(0);
}
}
void BX_CPU_C::decrementESPForPush(unsigned nBytes, Bit32u *eSP_ptr)
{
Bit32u eSP;
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b)
eSP = ESP;
else
eSP = SP;
if (protected_mode()) {
if (!can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, eSP, nBytes)) {
BX_INFO(("decrementESPForPush: push outside stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}
}
else { // Real Mode.
if ( (eSP>=1) && (eSP<nBytes) ) {
BX_PANIC(("decrementESPForPush: eSP=%08x", (unsigned) eSP));
}
}
// And finally, decrement eSP and return the new eSP value.
eSP -= nBytes;
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
*eSP_ptr = eSP;
}
else {
*eSP_ptr = SP;
}
}