MSVC6 compilation changes
More effort to remove can_pop function calls - almost everything is clean
This commit is contained in:
parent
a5544a693a
commit
8c24dfc01b
Binary file not shown.
Binary file not shown.
@ -413,6 +413,8 @@
|
||||
#if BX_64BIT_CONSTANTS_USE_LL
|
||||
// doesn't work on Microsoft Visual C++, maybe others
|
||||
#define BX_CONST64(x) (x##LL)
|
||||
#elif defined(_MSC_VER)
|
||||
#define BX_CONST64(x) (x##I64)
|
||||
#else
|
||||
#define BX_CONST64(x) (x)
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// $Id: iret.cc,v 1.28 2008-02-15 19:03:53 sshwarts Exp $
|
||||
// $Id: iret.cc,v 1.29 2008-03-26 16:25:05 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005 Stanislav Shwartsman
|
||||
@ -110,10 +110,9 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
/* NT = 0: INTERRUPT RETURN ON STACK -or STACK_RETURN_TO_V86 */
|
||||
unsigned top_nbytes_same, top_nbytes_outer;
|
||||
unsigned top_nbytes_same;
|
||||
Bit32u new_eip = 0, new_esp, temp_ESP, new_eflags = 0;
|
||||
Bit16u new_ip = 0, new_flags = 0;
|
||||
Bit32u ss_offset;
|
||||
|
||||
/* 16bit opsize | 32bit opsize
|
||||
* ==============================
|
||||
@ -126,20 +125,10 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
*/
|
||||
|
||||
if (i->os32L()) {
|
||||
top_nbytes_same = 12;
|
||||
top_nbytes_outer = 20;
|
||||
ss_offset = 16;
|
||||
top_nbytes_same = 12;
|
||||
}
|
||||
else {
|
||||
top_nbytes_same = 6;
|
||||
top_nbytes_outer = 10;
|
||||
ss_offset = 8;
|
||||
}
|
||||
|
||||
/* CS on stack must be within stack limits, else #SS(0) */
|
||||
if (!can_pop(top_nbytes_same)) {
|
||||
BX_ERROR(("iret: CS not within stack limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
top_nbytes_same = 6;
|
||||
}
|
||||
|
||||
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b)
|
||||
@ -148,9 +137,9 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
temp_ESP = SP;
|
||||
|
||||
if (i->os32L()) {
|
||||
raw_cs_selector = read_virtual_word (BX_SEG_REG_SS, temp_ESP + 4);
|
||||
new_eip = read_virtual_dword(BX_SEG_REG_SS, temp_ESP + 0);
|
||||
new_eflags = read_virtual_dword(BX_SEG_REG_SS, temp_ESP + 8);
|
||||
raw_cs_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_ESP + 4);
|
||||
new_eip = read_virtual_dword(BX_SEG_REG_SS, temp_ESP + 0);
|
||||
new_eflags = read_virtual_dword(BX_SEG_REG_SS, temp_ESP + 8);
|
||||
|
||||
// if VM=1 in flags image on stack then STACK_RETURN_TO_V86
|
||||
if (new_eflags & EFlagsVMMask) {
|
||||
@ -237,14 +226,13 @@ BX_CPU_C::iret_protected(bxInstruction_c *i)
|
||||
* IP eSP+0 | EIP eSP+0
|
||||
*/
|
||||
|
||||
/* top 10/20 bytes on stack must be within limits else #SS(0) */
|
||||
if (!can_pop(top_nbytes_outer)) {
|
||||
BX_ERROR(("iret: top 10/20 bytes not within stack limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
/* examine return SS selector and associated descriptor */
|
||||
raw_ss_selector = read_virtual_word(BX_SEG_REG_SS, temp_ESP + ss_offset);
|
||||
if (i->os32L()) {
|
||||
raw_ss_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_ESP + 16);
|
||||
}
|
||||
else {
|
||||
raw_ss_selector = read_virtual_word(BX_SEG_REG_SS, temp_ESP + 8);
|
||||
}
|
||||
|
||||
/* selector must be non-null, else #GP(0) */
|
||||
if ((raw_ss_selector & 0xfffc) == 0) {
|
||||
@ -349,7 +337,6 @@ BX_CPU_C::long_iret(bxInstruction_c *i)
|
||||
bx_descriptor_t cs_descriptor, ss_descriptor;
|
||||
Bit32u new_eflags;
|
||||
Bit64u new_rip, new_rsp, temp_RSP;
|
||||
unsigned top_nbytes_outer, ss_offset;
|
||||
|
||||
BX_DEBUG (("LONG MODE IRET"));
|
||||
|
||||
@ -377,42 +364,22 @@ BX_CPU_C::long_iret(bxInstruction_c *i)
|
||||
unsigned top_nbytes_same = 0; /* stop compiler warnings */
|
||||
|
||||
if (i->os64L()) {
|
||||
raw_cs_selector = read_virtual_word (BX_SEG_REG_SS, temp_RSP + 8);
|
||||
new_rip = read_virtual_qword(BX_SEG_REG_SS, temp_RSP + 0);
|
||||
raw_cs_selector = (Bit16u) read_virtual_qword(BX_SEG_REG_SS, temp_RSP + 8);
|
||||
new_rip = read_virtual_qword(BX_SEG_REG_SS, temp_RSP + 0);
|
||||
new_eflags = (Bit32u) read_virtual_qword(BX_SEG_REG_SS, temp_RSP + 16);
|
||||
|
||||
top_nbytes_outer = 40;
|
||||
ss_offset = 32;
|
||||
top_nbytes_same = 24;
|
||||
}
|
||||
else if (i->os32L()) {
|
||||
/* CS on stack must be within stack limits, else #SS(0) */
|
||||
if (!can_pop(12)) {
|
||||
BX_ERROR(("iret64: CS not within stack limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
raw_cs_selector = read_virtual_word (BX_SEG_REG_SS, temp_RSP + 4);
|
||||
raw_cs_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_RSP + 4);
|
||||
new_rip = (Bit64u) read_virtual_dword(BX_SEG_REG_SS, temp_RSP + 0);
|
||||
new_eflags = read_virtual_dword(BX_SEG_REG_SS, temp_RSP + 8);
|
||||
|
||||
top_nbytes_outer = 20;
|
||||
new_eflags = read_virtual_dword(BX_SEG_REG_SS, temp_RSP + 8);
|
||||
top_nbytes_same = 12;
|
||||
ss_offset = 16;
|
||||
}
|
||||
else {
|
||||
/* CS on stack must be within stack limits, else #SS(0) */
|
||||
if (!can_pop(6)) {
|
||||
BX_ERROR(("iret64: CS not within stack limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
raw_cs_selector = read_virtual_word(BX_SEG_REG_SS, temp_RSP + 2);
|
||||
new_rip = (Bit64u) read_virtual_word(BX_SEG_REG_SS, temp_RSP + 0);
|
||||
new_eflags = read_virtual_word(BX_SEG_REG_SS, temp_RSP + 4);
|
||||
|
||||
top_nbytes_outer = 10;
|
||||
raw_cs_selector = read_virtual_word(BX_SEG_REG_SS, temp_RSP + 2);
|
||||
new_rip = (Bit64u) read_virtual_word(BX_SEG_REG_SS, temp_RSP + 0);
|
||||
new_eflags = read_virtual_word(BX_SEG_REG_SS, temp_RSP + 4);
|
||||
top_nbytes_same = 6;
|
||||
ss_offset = 8;
|
||||
}
|
||||
|
||||
// if VM=1 in flags image on stack then STACK_RETURN_TO_V86
|
||||
@ -482,14 +449,16 @@ BX_CPU_C::long_iret(bxInstruction_c *i)
|
||||
* EIP eSP+0
|
||||
*/
|
||||
|
||||
/* top 10/20 bytes on stack must be within limits else #SS(0) */
|
||||
if (! can_pop(top_nbytes_outer)) {
|
||||
BX_PANIC(("iret64: top bytes not within stack limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
/* examine return SS selector and associated descriptor */
|
||||
raw_ss_selector = read_virtual_word(BX_SEG_REG_SS, temp_RSP + ss_offset);
|
||||
if (i->os64L()) {
|
||||
raw_ss_selector = (Bit16u) read_virtual_qword(BX_SEG_REG_SS, temp_RSP + 32);
|
||||
}
|
||||
else if (i->os32L()) {
|
||||
raw_ss_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_RSP + 16);
|
||||
}
|
||||
else {
|
||||
raw_ss_selector = read_virtual_word(BX_SEG_REG_SS, temp_RSP + 8);
|
||||
}
|
||||
|
||||
if ((raw_ss_selector & 0xfffc) == 0) {
|
||||
if (! IS_LONG64_SEGMENT(cs_descriptor) || (cs_selector.rpl == 3)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// $Id: ret_far.cc,v 1.14 2008-02-02 21:46:53 sshwarts Exp $
|
||||
// $Id: ret_far.cc,v 1.15 2008-03-26 16:25:05 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005 Stanislav Shwartsman
|
||||
@ -62,42 +62,20 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (i->os64L()) {
|
||||
/* operand size=64: in long mode 1st and 2nd quadword on the stack
|
||||
must be in canonical address space */
|
||||
|
||||
raw_cs_selector = read_virtual_word (BX_SEG_REG_SS, temp_RSP + 8);
|
||||
return_RIP = read_virtual_qword(BX_SEG_REG_SS, temp_RSP);
|
||||
|
||||
return_RIP = read_virtual_qword(BX_SEG_REG_SS, temp_RSP);
|
||||
raw_cs_selector = (Bit16u) read_virtual_qword(BX_SEG_REG_SS, temp_RSP + 8);
|
||||
stack_param_offset = 16;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (i->os32L()) {
|
||||
/* operand size=32: 2nd dword on stack must be within stack limits,
|
||||
* else #SS(0); */
|
||||
if (! can_pop(8))
|
||||
{
|
||||
BX_ERROR(("return_protected: 2rd dword not in stack limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
raw_cs_selector = read_virtual_word (BX_SEG_REG_SS, temp_RSP + 4);
|
||||
return_RIP = read_virtual_dword(BX_SEG_REG_SS, temp_RSP);
|
||||
|
||||
return_RIP = read_virtual_dword(BX_SEG_REG_SS, temp_RSP);
|
||||
raw_cs_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_RSP + 4);
|
||||
stack_param_offset = 8;
|
||||
}
|
||||
else {
|
||||
/* operand size=16: second word on stack must be within stack limits,
|
||||
* else #SS(0); */
|
||||
if (! can_pop(4))
|
||||
{
|
||||
BX_ERROR(("return_protected: 2nd word not in stack limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
raw_cs_selector = read_virtual_word(BX_SEG_REG_SS, temp_RSP + 2);
|
||||
return_RIP = read_virtual_word(BX_SEG_REG_SS, temp_RSP);
|
||||
|
||||
raw_cs_selector = read_virtual_word(BX_SEG_REG_SS, temp_RSP + 2);
|
||||
stack_param_offset = 4;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: vm8086.cc,v 1.40 2008-03-24 22:35:37 sshwarts Exp $
|
||||
// $Id: vm8086.cc,v 1.41 2008-03-26 16:25:05 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -72,21 +72,15 @@ void BX_CPU_C::stack_return_to_v86(Bit32u new_eip, Bit32u raw_cs_selector, Bit32
|
||||
else
|
||||
temp_ESP = SP;
|
||||
|
||||
// top 36 bytes of stack must be within stack limits, else #SS(0)
|
||||
if (!can_pop(36)) {
|
||||
BX_ERROR(("stack_return_to_v86: top 36 bytes not within limits"));
|
||||
exception(BX_SS_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
// load SS:ESP from stack
|
||||
new_esp = read_virtual_dword(BX_SEG_REG_SS, temp_ESP+12);
|
||||
raw_ss_selector = read_virtual_word (BX_SEG_REG_SS, temp_ESP+16);
|
||||
new_esp = read_virtual_dword(BX_SEG_REG_SS, temp_ESP+12);
|
||||
raw_ss_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_ESP+16);
|
||||
|
||||
// load ES,DS,FS,GS from stack
|
||||
raw_es_selector = read_virtual_word(BX_SEG_REG_SS, temp_ESP+20);
|
||||
raw_ds_selector = read_virtual_word(BX_SEG_REG_SS, temp_ESP+24);
|
||||
raw_fs_selector = read_virtual_word(BX_SEG_REG_SS, temp_ESP+28);
|
||||
raw_gs_selector = read_virtual_word(BX_SEG_REG_SS, temp_ESP+32);
|
||||
raw_es_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_ESP+20);
|
||||
raw_ds_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_ESP+24);
|
||||
raw_fs_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_ESP+28);
|
||||
raw_gs_selector = (Bit16u) read_virtual_dword(BX_SEG_REG_SS, temp_ESP+32);
|
||||
|
||||
writeEFlags(flags32, EFlagsValidMask);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: acpi.cc,v 1.13 2008-01-26 22:24:00 sshwarts Exp $
|
||||
// $Id: acpi.cc,v 1.14 2008-03-26 16:25:05 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2006 Volker Ruppert
|
||||
@ -390,7 +390,7 @@ void bx_acpi_ctrl_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
||||
if (pmsts & value & TMROF_EN) {
|
||||
// if TMRSTS is reset, then compute the new overflow time
|
||||
Bit64u d = muldiv64(bx_pc_system.time_usec(), PM_FREQ, 1000000);
|
||||
BX_ACPI_THIS s.tmr_overflow_time = (d + 0x800000LL) & ~0x7fffffLL;
|
||||
BX_ACPI_THIS s.tmr_overflow_time = (d + BX_CONST64(0x800000)) & ~BX_CONST64(0x7fffff);
|
||||
}
|
||||
BX_ACPI_THIS s.pmsts &= ~value;
|
||||
BX_ACPI_THIS pm_update_sci();
|
||||
|
Loading…
Reference in New Issue
Block a user