1
0
Fork 0

Changed some cpu functions to get opcode length as parameter

Added cli and sti functions


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1747
This commit is contained in:
Sjoerd van der Berg 2004-03-31 17:27:31 +00:00
parent 988633017d
commit cd5f7c9666
3 changed files with 38 additions and 25 deletions

View file

@ -380,7 +380,7 @@
{
Bit32u newip=Fetchd();Bit16u newcs=Fetchw();
LEAVECORE;
CPU_CALL(true,newcs,newip);
CPU_CALL(true,newcs,newip,core.ip_lookup-core.op_start);
goto decode_start;
}
CASE_D(0x9c) /* PUSHFD */
@ -530,7 +530,7 @@
CASE_D(0xcf) /* IRET */
{
LEAVECORE;
CPU_IRET(true);
CPU_IRET(true,core.ip_lookup-core.op_start);
#if CPU_TRAP_CHECK
if (GETFLAG(TF)) {
cpudecoder=CPU_Core_Normal_Trap_Run;
@ -540,7 +540,6 @@
#if CPU_PIC_CHECK
if (GETFLAG(IF) && PIC_IRQCheck) return CBRET_NONE;
#endif
//TODO TF check
goto decode_start;
}
CASE_D(0xd1) /* GRP2 Ed,1 */
@ -641,7 +640,7 @@
Bit32u newip=LoadMd(eaa);
Bit16u newcs=LoadMw(eaa+4);
LEAVECORE;
CPU_CALL(true,newcs,newip);
CPU_CALL(true,newcs,newip,core.ip_lookup-core.op_start);
goto decode_start;
}
break;

View file

@ -237,7 +237,7 @@
break;
CASE_W(0x63) /* ARPL Ew,Rw */
{
if (((cpu.pmode) && (reg_flags & FLAG_VM)) || (!cpu.pmode)) goto illegal_opcode;
if ((reg_flags & FLAG_VM) || (!cpu.pmode)) goto illegal_opcode;
FillFlags();
GetRMrw;
if (rm >= 0xc0 ) {
@ -792,7 +792,7 @@
CASE_W(0xcf) /* IRET */
{
LEAVECORE;
CPU_IRET(false);
CPU_IRET(false,core.ip_lookup-core.op_start);
#if CPU_PIC_CHECK
if (GETFLAG(IF) && PIC_IRQCheck) return CBRET_NONE;
#endif
@ -1059,20 +1059,14 @@
SETFLAGBIT(CF,true);
break;
CASE_B(0xfa) /* CLI */
if (cpu.pmode && (GETFLAG_IOPL<cpu.cpl)) {
LEAVECORE;reg_eip-=core.ip_lookup-core.op_start;
CPU_Exception(13,0);
LEAVECORE;
if (CPU_CLI(core.ip_lookup-core.op_start))
goto decode_start;
}
SETFLAGBIT(IF,false);
break;
CASE_B(0xfb) /* STI */
if (cpu.pmode && !GETFLAG(VM) && (GETFLAG_IOPL<cpu.cpl)) {
LEAVECORE;reg_eip-=core.ip_lookup-core.op_start;
CPU_Exception(13,0);
LEAVECORE;
if (CPU_STI(core.ip_lookup-core.op_start))
goto decode_start;
}
SETFLAGBIT(IF,true);
#if CPU_PIC_CHECK
if (GETFLAG(IF) && PIC_IRQCheck) goto decode_end;
#endif

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: cpu.cpp,v 1.54 2004-02-26 07:42:53 harekiet Exp $ */
/* $Id: cpu.cpp,v 1.55 2004-03-31 17:24:30 harekiet Exp $ */
#include <assert.h>
#include "dosbox.h"
@ -91,6 +91,28 @@ void CPU_SetFlags(Bitu word,Bitu mask) {
cpu.direction=1-((reg_flags & FLAG_DF) >> 9);
}
bool CPU_CLI(Bitu opLen) {
if (cpu.pmode && ((!GETFLAG(VM) && (GETFLAG_IOPL<cpu.cpl)) || (GETFLAG(VM) && (GETFLAG_IOPL<3)))) {
reg_eip-=opLen;
CPU_Exception(13,0);
return true;
} else {
SETFLAGBIT(IF,false);
return false;
}
}
bool CPU_STI(Bitu opLen) {
if (cpu.pmode && ((!GETFLAG(VM) && (GETFLAG_IOPL<cpu.cpl)) || (GETFLAG(VM) && (GETFLAG_IOPL<3)))) {
reg_eip-=opLen;
CPU_Exception(13,0);
return true;
} else {
SETFLAGBIT(IF,true);
return false;
}
}
class TaskStateSegment {
public:
TaskStateSegment() {
@ -437,7 +459,7 @@ do_interrupt:
return ; // make compiler happy
}
void CPU_IRET(bool use32) {
void CPU_IRET(bool use32,Bitu opLen) {
if (!cpu.pmode) { /* RealMode IRET */
realmode_iret:
if (use32) {
@ -454,7 +476,7 @@ realmode_iret:
} else { /* Protected mode IRET */
if (reg_flags & FLAG_VM) {
if ((reg_flags & FLAG_IOPL)!=FLAG_IOPL) {
reg_eip--;
reg_eip-=opLen;
CPU_Exception(13,0);
return;
} else goto realmode_iret;
@ -712,7 +734,7 @@ call_code:
if (call.Type()==DESC_386_CALL_GATE) {
CPU_Push32(o_ss); //save old stack
CPU_Push32(o_esp);
if (call.saved.gate.paramcount&31>0)
if (call.saved.gate.paramcount&31)
for (Bits i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
CPU_Push32(mem_readd(o_stack+i*4));
CPU_Push32(SegValue(cs));
@ -720,7 +742,7 @@ call_code:
} else {
CPU_Push16(o_ss); //save old stack
CPU_Push16(o_esp);
if (call.saved.gate.paramcount&31>0)
if (call.saved.gate.paramcount&31)
for (Bits i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
CPU_Push16(mem_readw(o_stack+i*2));
CPU_Push16(SegValue(cs));
@ -982,7 +1004,6 @@ void CPU_LAR(Bitu selector,Bitu & ar) {
return;
}
Descriptor desc;Bitu rpl=selector & 3;
ar=0;
if (!cpu.gdt.GetDescriptor(selector,desc)){
SETFLAGBIT(ZF,false);
return;
@ -991,7 +1012,7 @@ void CPU_LAR(Bitu selector,Bitu & ar) {
case DESC_CODE_N_C_A: case DESC_CODE_N_C_NA:
case DESC_CODE_R_C_A: case DESC_CODE_R_C_NA:
break;
case DESC_286_INT_GATE: case DESC_286_TRAP_GATE: {
case DESC_386_INT_GATE: case DESC_386_TRAP_GATE:
SETFLAGBIT(ZF,false);
@ -1034,7 +1055,6 @@ void CPU_LSL(Bitu selector,Bitu & limit) {
return;
}
Descriptor desc;Bitu rpl=selector & 3;
limit=0;
if (!cpu.gdt.GetDescriptor(selector,desc)){
SETFLAGBIT(ZF,false);
return;
@ -1300,7 +1320,7 @@ void CPU_Init(Section* sec) {
else {
LOG_MSG("CPU:Unknown core type %s, switcing back to normal.",core);
}
CPU_JMP(false,0,0); //Setup the first cpu core
CPU_JMP(false,0,0,0); //Setup the first cpu core
if (!CPU_CycleMax) CPU_CycleMax = 2500;
if(!CPU_CycleUp) CPU_CycleUp = 500;