Changed cpu core names
Changed the exception handling of far jmp/calls interrupts and some others Added x86 dynamic core startup code Some new defines to enable/disable the dynamic core Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1513
This commit is contained in:
parent
5cc3d9d24b
commit
23a4d8fe3d
11 changed files with 82 additions and 93 deletions
|
@ -33,6 +33,11 @@ extern Bits CPU_CycleMax;
|
|||
typedef Bits (CPU_Decoder)(void);
|
||||
extern CPU_Decoder * cpudecoder;
|
||||
|
||||
Bits CPU_Core_Normal_Run(void);
|
||||
Bits CPU_Core_Normal_Trap_Run(void);
|
||||
Bits CPU_Core_Full_Run(void);
|
||||
Bits CPU_Core_Dyn_X86_Run(void);
|
||||
|
||||
//CPU Stuff
|
||||
|
||||
extern Bit16u parity_lookup[256];
|
||||
|
@ -70,26 +75,23 @@ void CPU_RET(bool use32,Bitu bytes,Bitu opLen=0);
|
|||
#define CPU_INT_HAS_ERROR 0x4
|
||||
|
||||
|
||||
bool CPU_Interrupt(Bitu num,Bitu type);
|
||||
void CPU_Interrupt(Bitu num,Bitu type,Bitu opLen=0);
|
||||
INLINE void CPU_HW_Interrupt(Bitu num) {
|
||||
CPU_Interrupt(num,0);
|
||||
}
|
||||
INLINE bool CPU_SW_Interrupt(Bitu num) {
|
||||
return CPU_Interrupt(num,CPU_INT_SOFTWARE);
|
||||
INLINE void CPU_SW_Interrupt(Bitu num,Bitu OpLen) {
|
||||
CPU_Interrupt(num,CPU_INT_SOFTWARE,OpLen);
|
||||
}
|
||||
|
||||
void CPU_Exception(Bitu which,Bitu error=0);
|
||||
void CPU_StartException(void);
|
||||
void CPU_SetupException(Bitu which,Bitu error=0);
|
||||
|
||||
|
||||
|
||||
void CPU_IRET(bool use32);
|
||||
bool CPU_SetSegGeneral(SegNames seg,Bitu value);
|
||||
void CPU_HLT(Bitu opLen);
|
||||
|
||||
void CPU_CPUID(void);
|
||||
bool CPU_HLT(void);
|
||||
|
||||
Bitu CPU_Pop16(void);
|
||||
Bitu CPU_Pop32(void);
|
||||
void CPU_Push16(Bitu value);
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef PhysPt EAPoint;
|
|||
goto nextopcode; \
|
||||
}
|
||||
|
||||
Bits Full_DeCode(void) {
|
||||
Bits CPU_Core_Full_Run(void) {
|
||||
FullData inst;
|
||||
restart_core:
|
||||
if (CPU_Cycles<=0) return CBRET_NONE;
|
||||
|
@ -82,7 +82,7 @@ restart_core:
|
|||
EAPoint IPPoint;
|
||||
LoadIP();
|
||||
lflags.type=t_UNKNOWN;
|
||||
while (CPU_Cycles--) {
|
||||
while (CPU_Cycles-->0) {
|
||||
#if C_DEBUG
|
||||
cycle_count++;
|
||||
#if C_HEAVY_DEBUG
|
||||
|
@ -110,6 +110,6 @@ exit_core:
|
|||
}
|
||||
|
||||
|
||||
void CPU_Core_Full_Start(bool big) {
|
||||
cpudecoder=&Full_DeCode;
|
||||
void CPU_Core_Full_Init(void) {
|
||||
|
||||
}
|
||||
|
|
|
@ -502,10 +502,7 @@ l_M_Ed:
|
|||
goto nextopcode;
|
||||
case D_HLT:
|
||||
LEAVECORE;
|
||||
if (CPU_HLT()) {
|
||||
reg_eip-=IPPoint-inst.start;
|
||||
CPU_StartException();
|
||||
}
|
||||
CPU_HLT(IPPoint-inst.start);
|
||||
return CBRET_NONE;
|
||||
default:
|
||||
LOG(LOG_CPU,LOG_ERROR)("LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry);
|
||||
|
|
|
@ -345,10 +345,7 @@ switch (inst.code.op) {
|
|||
else if (DEBUG_IntBreakpoint(inst.op1.b))
|
||||
return debugCallback;
|
||||
#endif
|
||||
if (CPU_SW_Interrupt(inst.op1.b)) {
|
||||
reg_eip-=IPPoint-inst.start;
|
||||
CPU_StartException();
|
||||
}
|
||||
CPU_SW_Interrupt(inst.op1.b,IPPoint-inst.start);
|
||||
goto restart_core;
|
||||
case O_INb:
|
||||
reg_al=IO_Read(inst.op1.d);
|
||||
|
|
|
@ -151,10 +151,7 @@ static GetEATable * EAPrefixTable[8] = {
|
|||
|
||||
#define EALookupTable (*(core.ea_table))
|
||||
|
||||
|
||||
Bits CPU_Core_Normal_Decode_Trap(void);
|
||||
|
||||
Bits CPU_Core_Normal_Decode(void) {
|
||||
Bits CPU_Core_Normal_Run(void) {
|
||||
decode_start:
|
||||
if (cpu.code.big) {
|
||||
core.index_default=0x200;
|
||||
|
@ -202,26 +199,23 @@ restart_opcode:
|
|||
return CBRET_NONE;
|
||||
}
|
||||
|
||||
Bits CPU_Core_Normal_Decode_Trap(void) {
|
||||
Bits CPU_Core_Normal_Trap_Run(void) {
|
||||
|
||||
Bits oldCycles = CPU_Cycles;
|
||||
CPU_Cycles = 1;
|
||||
core.trap.skip=false;
|
||||
|
||||
Bits ret=CPU_Core_Normal_Decode();
|
||||
if (!core.trap.skip) if (CPU_SW_Interrupt(1)) {
|
||||
E_Exit("Exception in trap flag cpu core, noooooooo");
|
||||
}
|
||||
Bits ret=CPU_Core_Normal_Run();
|
||||
if (!core.trap.skip) CPU_SW_Interrupt(1,0);
|
||||
CPU_Cycles = oldCycles-1;
|
||||
cpudecoder = &CPU_Core_Normal_Decode;
|
||||
cpudecoder = &CPU_Core_Normal_Run;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CPU_Core_Normal_Start(bool big) {
|
||||
if (GETFLAG(TF)) cpudecoder=CPU_Core_Normal_Decode_Trap;
|
||||
else cpudecoder=CPU_Core_Normal_Decode;
|
||||
void CPU_Core_Normal_Init(void) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -358,7 +358,7 @@
|
|||
SETFLAGSd(Pop_32())
|
||||
#if CPU_TRAP_CHECK
|
||||
if (GETFLAG(TF)) {
|
||||
cpudecoder=CPU_Core_Normal_Decode_Trap;
|
||||
cpudecoder=CPU_Core_Normal_Trap_Run;
|
||||
goto decode_end;
|
||||
}
|
||||
#endif
|
||||
|
@ -495,7 +495,7 @@
|
|||
CPU_IRET(true);
|
||||
#if CPU_TRAP_CHECK
|
||||
if (GETFLAG(TF)) {
|
||||
cpudecoder=CPU_Core_Normal_Decode_Trap;
|
||||
cpudecoder=CPU_Core_Normal_Trap_Run;
|
||||
return CBRET_NONE;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -561,7 +561,7 @@
|
|||
SETFLAGSw(Pop_16());
|
||||
#if CPU_TRAP_CHECK
|
||||
if (GETFLAG(TF)) {
|
||||
cpudecoder=CPU_Core_Normal_Decode_Trap;
|
||||
cpudecoder=CPU_Core_Normal_Trap_Run;
|
||||
goto decode_end;
|
||||
}
|
||||
#endif
|
||||
|
@ -752,10 +752,7 @@
|
|||
return debugCallback;
|
||||
}
|
||||
#endif
|
||||
if (CPU_SW_Interrupt(3)) {
|
||||
reg_eip-=(core.ip_lookup-core.op_start);
|
||||
CPU_StartException();
|
||||
};
|
||||
CPU_SW_Interrupt(3,(core.ip_lookup-core.op_start));
|
||||
#if CPU_TRAP_CHECK
|
||||
core.trap.skip=true;
|
||||
#endif
|
||||
|
@ -769,10 +766,7 @@
|
|||
return debugCallback;
|
||||
}
|
||||
#endif
|
||||
if (CPU_SW_Interrupt(num)) {
|
||||
reg_eip-=core.ip_lookup-core.op_start;
|
||||
CPU_StartException();
|
||||
}
|
||||
CPU_SW_Interrupt(num,core.ip_lookup-core.op_start);
|
||||
#if CPU_TRAP_CHECK
|
||||
core.trap.skip=true;
|
||||
#endif
|
||||
|
@ -782,10 +776,7 @@
|
|||
CASE_B(0xce) /* INTO */
|
||||
if (get_OF()) {
|
||||
LEAVECORE;
|
||||
if (CPU_SW_Interrupt(4)) {
|
||||
reg_eip-=core.ip_lookup-core.op_start;
|
||||
CPU_StartException();
|
||||
}
|
||||
CPU_SW_Interrupt(4,core.ip_lookup-core.op_start);
|
||||
#if CPU_TRAP_CHECK
|
||||
core.trap.skip=true;
|
||||
#endif
|
||||
|
@ -802,7 +793,7 @@
|
|||
#endif
|
||||
#if CPU_TRAP_CHECK
|
||||
if (GETFLAG(TF)) {
|
||||
cpudecoder=CPU_Core_Normal_Decode_Trap;
|
||||
cpudecoder=CPU_Core_Normal_Trap_Run;
|
||||
return CBRET_NONE;
|
||||
}
|
||||
#endif
|
||||
|
@ -960,11 +951,7 @@
|
|||
break;
|
||||
CASE_B(0xf4) /* HLT */
|
||||
LEAVECORE;
|
||||
if (CPU_HLT()) {
|
||||
reg_eip-=core.ip_lookup-core.op_start;
|
||||
CPU_Exception(13,0);
|
||||
goto decode_start;
|
||||
}
|
||||
CPU_HLT(core.ip_lookup-core.op_start);
|
||||
return CBRET_NONE; //Needs to return for hlt cpu core
|
||||
CASE_B(0xf5) /* CMC */
|
||||
FillFlags();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: cpu.cpp,v 1.45 2003-12-17 23:10:00 finsterr Exp $ */
|
||||
/* $Id: cpu.cpp,v 1.46 2004-01-01 12:26:08 harekiet Exp $ */
|
||||
|
||||
#include <assert.h>
|
||||
#include "dosbox.h"
|
||||
|
@ -49,24 +49,22 @@ static struct {
|
|||
Bitu which,errorcode;
|
||||
} exception;
|
||||
|
||||
void CPU_Core_Full_Start(bool big);
|
||||
void CPU_Core_Normal_Start(bool big);
|
||||
void CPU_Dynamic_Start(bool big);
|
||||
void CPU_Core_Full_Init(void);
|
||||
void CPU_Core_Normal_Init(void);
|
||||
void CPU_Core_Dyn_X86_Init(void);
|
||||
|
||||
static Bits CPU_Core_Normal_Decode(void);
|
||||
static Bits CPU_Core_Full_Decode(void);
|
||||
#if (C_DYNAMIC_X86)
|
||||
|
||||
|
||||
#if 1
|
||||
|
||||
#define realcore_start CPU_Core_Normal_Start
|
||||
#define startcpu_core CPU_Core_Dyn_X86_Run
|
||||
|
||||
#else
|
||||
|
||||
#define realcore_start CPU_Core_Full_Start
|
||||
#define startcpu_core CPU_Core_Normal_Run
|
||||
//#define startcpu_core CPU_Core_Full_Run
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void CPU_Push16(Bitu value) {
|
||||
reg_esp-=2;
|
||||
mem_writew(SegPhys(ss) + (reg_esp & cpu.stack.mask) ,value);
|
||||
|
@ -296,7 +294,7 @@ void CPU_Exception(Bitu which,Bitu error ) {
|
|||
}
|
||||
|
||||
Bit8u lastint;
|
||||
bool CPU_Interrupt(Bitu num,Bitu type) {
|
||||
void CPU_Interrupt(Bitu num,Bitu type,Bitu opLen) {
|
||||
lastint=num;
|
||||
#if C_DEBUG
|
||||
switch (num) {
|
||||
|
@ -309,7 +307,7 @@ bool CPU_Interrupt(Bitu num,Bitu type) {
|
|||
case 0x03:
|
||||
if (DEBUG_Breakpoint()) {
|
||||
CPU_Cycles=0;
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
@ -326,7 +324,7 @@ bool CPU_Interrupt(Bitu num,Bitu type) {
|
|||
Segs.val[cs]=mem_readw(base+(num << 2)+2);
|
||||
Segs.phys[cs]=Segs.val[cs]<<4;
|
||||
cpu.code.big=false;
|
||||
return false;
|
||||
return;
|
||||
} else {
|
||||
/* Protected Mode Interrupt */
|
||||
// if (type&CPU_INT_SOFTWARE && cpu.v86) goto realmode_interrupt;
|
||||
|
@ -335,16 +333,18 @@ bool CPU_Interrupt(Bitu num,Bitu type) {
|
|||
if ((reg_flags & FLAG_VM) && (type&CPU_INT_SOFTWARE)) {
|
||||
// LOG_MSG("Software int in v86, AH %X IOPL %x",reg_ah,(reg_flags & FLAG_IOPL) >>12);
|
||||
if ((reg_flags & FLAG_IOPL)!=FLAG_IOPL) {
|
||||
CPU_SetupException(13,0);
|
||||
return true;
|
||||
reg_eip-=opLen;
|
||||
CPU_Exception(13,0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Descriptor gate;
|
||||
//TODO Check for software interrupt and check gate's dpl<cpl
|
||||
cpu.idt.GetDescriptor(num<<3,gate);
|
||||
if (type&CPU_INT_SOFTWARE && gate.DPL()<cpu.cpl) {
|
||||
CPU_SetupException(13,num*8+2);
|
||||
return true;
|
||||
reg_eip-=opLen;
|
||||
CPU_Exception(13,num*8+2);
|
||||
return;
|
||||
}
|
||||
switch (gate.Type()) {
|
||||
case DESC_286_INT_GATE: case DESC_386_INT_GATE:
|
||||
|
@ -429,7 +429,7 @@ do_interrupt:
|
|||
cpu.code.big=cs_desc.Big()>0;
|
||||
LOG(LOG_CPU,LOG_NORMAL)("INT:Gate to %X:%X big %d %s",gate_sel,gate_off,cs_desc.Big(),gate.Type() & 0x8 ? "386" : "286");
|
||||
reg_eip=gate_off;
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
case DESC_TASK_GATE:
|
||||
CPU_SwitchTask(gate.GetSelector(),TSwitch_CALL_INT);
|
||||
|
@ -438,13 +438,13 @@ do_interrupt:
|
|||
if (cpu_tss.is386) CPU_Push32(cpu.exception.error);
|
||||
else CPU_Push16(cpu.exception.error);
|
||||
}
|
||||
return false;
|
||||
return;
|
||||
default:
|
||||
E_Exit("Illegal descriptor type %X for int %X",gate.Type(),num);
|
||||
}
|
||||
}
|
||||
assert(1);
|
||||
return false; // make compiler happy
|
||||
return ; // make compiler happy
|
||||
}
|
||||
|
||||
void CPU_IRET(bool use32) {
|
||||
|
@ -801,12 +801,6 @@ void CPU_RET(bool use32,Bitu bytes,Bitu opLen) {
|
|||
offset=CPU_Pop32();
|
||||
selector=CPU_Pop32() & 0xffff;
|
||||
}
|
||||
if (cpu.stack.big) {
|
||||
reg_esp+=bytes;
|
||||
} else {
|
||||
reg_sp+=bytes;
|
||||
}
|
||||
|
||||
if (cpu.cpl==rpl) {
|
||||
/* Return to same level */
|
||||
switch (desc.Type()) {
|
||||
|
@ -827,11 +821,16 @@ RET_same_level:
|
|||
cpu.code.big=desc.Big()>0;
|
||||
Segs.val[cs]=selector;
|
||||
reg_eip=offset;
|
||||
if (cpu.stack.big) {
|
||||
reg_esp+=bytes;
|
||||
} else {
|
||||
reg_sp+=bytes;
|
||||
}
|
||||
LOG(LOG_CPU,LOG_NORMAL)("RET - Same level to %X:%X RPL %X DPL %X",selector,offset,rpl,desc.DPL());
|
||||
return;
|
||||
} else {
|
||||
/* Return to higher level */
|
||||
if (bytes) E_Exit("RETF with immediate value");
|
||||
/* Return to outer level */
|
||||
if (bytes) E_Exit("RETF outeer level with immediate value");
|
||||
Bitu n_esp,n_ss;
|
||||
if (use32) {
|
||||
n_esp = CPU_Pop32();
|
||||
|
@ -1179,17 +1178,18 @@ static Bits HLT_Decode(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool CPU_HLT(void) {
|
||||
void CPU_HLT(Bitu opLen) {
|
||||
if (cpu.cpl) {
|
||||
CPU_SetupException(13,0);
|
||||
return true;
|
||||
reg_eip-=opLen;
|
||||
CPU_Exception(13,0);
|
||||
return;
|
||||
}
|
||||
CPU_Cycles=0;
|
||||
cpu.hlt.cs=SegValue(cs);
|
||||
cpu.hlt.eip=reg_eip;
|
||||
cpu.hlt.old_decoder=cpudecoder;
|
||||
cpudecoder=&HLT_Decode;
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1248,7 +1248,14 @@ void CPU_Init(Section* sec) {
|
|||
cpu.stack.big=false;
|
||||
cpu.idt.SetBase(0);
|
||||
cpu.idt.SetLimit(1023);
|
||||
realcore_start(false);
|
||||
|
||||
/* Init the cpu cores */
|
||||
CPU_Core_Normal_Init();
|
||||
CPU_Core_Full_Init();
|
||||
#if (C_DYNAMIC_X86)
|
||||
CPU_Core_Dyn_X86_Init();
|
||||
#endif
|
||||
cpudecoder=&startcpu_core;
|
||||
|
||||
CPU_JMP(false,0,0); //Setup the first cpu core
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ HostPt PageHandler::GetHostPt(Bitu phys_page) {
|
|||
}
|
||||
|
||||
|
||||
Bits Full_DeCode(void);
|
||||
struct PF_Entry {
|
||||
Bitu cs;
|
||||
Bitu eip;
|
||||
|
@ -86,7 +85,7 @@ struct {
|
|||
static Bits PageFaultCore(void) {
|
||||
CPU_CycleLeft+=CPU_Cycles;
|
||||
CPU_Cycles=1;
|
||||
Bitu ret=Full_DeCode();
|
||||
Bitu ret=CPU_Core_Full_Run();
|
||||
CPU_CycleLeft+=CPU_Cycles;
|
||||
if (ret<0) E_Exit("Got a dosbox close machine in pagefault core?");
|
||||
if (ret)
|
||||
|
|
|
@ -981,7 +981,7 @@ Bitu DPMI::SimulateInt(void)
|
|||
// Push flags from structure on stack
|
||||
DPMI_LOG("DPMI: SimInt1: StackInfo %04X:%04X (%02X %02X)",SegValue(ss),reg_esp,mem_readb(0xD0100+0x01FA),mem_readb(0xD0100+0x01FB));
|
||||
reg_flags = mem_readw(data+0x20);
|
||||
CPU_SW_Interrupt(num);
|
||||
CPU_SW_Interrupt(num,0);
|
||||
DPMI_LOG("DPMI: SimInt2: StackInfo %04X:%04X (%02X %02X)",SegValue(ss),reg_esp,mem_readb(0xD0100+0x01FA),mem_readb(0xD0100+0x01FB));
|
||||
return 0;
|
||||
};
|
||||
|
@ -1043,7 +1043,7 @@ Bitu DPMI::ptorHandler(void)
|
|||
DPMI_LOG("DPMI: INT %02X %04X called.",num,reg_ax);
|
||||
// Prepare flags for real int
|
||||
// CPU_SetFlagsw(reg_flags & 0x3ED5); // 0011111011010101b
|
||||
CPU_SW_Interrupt(num);
|
||||
CPU_SW_Interrupt(num,0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1106,7 +1106,7 @@ Bitu DPMI::Int21Handler(void)
|
|||
reg_esp = rm_sp;
|
||||
// Call realmode interrupt
|
||||
DPMI_LOG("DPMI: INT 21 %04X called.",reg_ax);
|
||||
CPU_SW_Interrupt(0x21);
|
||||
CPU_SW_Interrupt(0x21,0);
|
||||
if (reg_ah==0x4C) {
|
||||
// Shut doen dpmi and restore previous one
|
||||
delete this;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#define VERSION "0.60"
|
||||
|
||||
/* Define to 1 to enable internal debugger, requires libcurses */
|
||||
#define C_DEBUG 0
|
||||
#define C_DEBUG 1
|
||||
|
||||
/* Define to 1 to enable screenshots, requires libpng */
|
||||
#define C_SSHOT 1
|
||||
|
@ -14,6 +14,12 @@
|
|||
/* Enable some heavy debugging options */
|
||||
#define C_HEAVY_DEBUG 0
|
||||
|
||||
/* The type of cpu this host has */
|
||||
#define C_HOSTCPU X86
|
||||
|
||||
/* Define to 1 to use x86 dynamic cpu core */
|
||||
#define C_DYNAMIC_X86 1
|
||||
|
||||
/* Enable memory function inlining in */
|
||||
#define C_CORE_INLINE 0
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue