1
0
Fork 0

cpu updates (privileged instructions, trapflag handling)

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2275
This commit is contained in:
Sebastian Strohhäcker 2005-08-15 13:43:44 +00:00
parent 85850ccc22
commit b48eceebe7
12 changed files with 1352 additions and 109 deletions

View file

@ -49,8 +49,8 @@ Bits CPU_Core_Dyn_X86_Run(void);
extern Bit16u parity_lookup[256];
void CPU_LLDT(Bitu selector);
void CPU_LTR(Bitu selector);
bool CPU_LLDT(Bitu selector);
bool CPU_LTR(Bitu selector);
void CPU_LIDT(Bitu limit,Bitu base);
void CPU_LGDT(Bitu limit,Bitu base);
@ -68,6 +68,9 @@ bool CPU_WRITE_CRX(Bitu cr,Bitu value);
Bitu CPU_GET_CRX(Bitu cr);
bool CPU_READ_CRX(Bitu cr,Bit32u & retvalue);
bool CPU_WRITE_DRX(Bitu dr,Bitu value);
bool CPU_READ_DRX(Bitu dr,Bit32u & retvalue);
void CPU_SMSW(Bitu & word);
Bitu CPU_LMSW(Bitu word);
@ -93,6 +96,7 @@ void CPU_ENTER(bool use32,Bitu bytes,Bitu level);
#define CPU_INT_SOFTWARE 0x1
#define CPU_INT_EXCEPTION 0x2
#define CPU_INT_HAS_ERROR 0x4
#define CPU_INT_NOIOPLCHECK 0x8
void CPU_Interrupt(Bitu num,Bitu type,Bitu oldeip);
INLINE void CPU_HW_Interrupt(Bitu num) {
@ -101,6 +105,9 @@ INLINE void CPU_HW_Interrupt(Bitu num) {
INLINE void CPU_SW_Interrupt(Bitu num,Bitu oldeip) {
CPU_Interrupt(num,CPU_INT_SOFTWARE,oldeip);
}
INLINE void CPU_SW_Interrupt_NoIOPLCheck(Bitu num,Bitu oldeip) {
CPU_Interrupt(num,CPU_INT_SOFTWARE|CPU_INT_NOIOPLCHECK,oldeip);
}
bool CPU_PrepareException(Bitu which,Bitu error);
void CPU_Exception(Bitu which,Bitu error=0);
@ -116,18 +123,25 @@ void CPU_Push32(Bitu value);
void CPU_SetFlags(Bitu word,Bitu mask);
#define EXCEPTION_UD 6
#define EXCEPTION_TS 10
#define EXCEPTION_NP 11
#define EXCEPTION_SS 12
#define EXCEPTION_GP 13
#define CR0_PROTECTION 0x00000001
#define CR0_MONITORPROCESSOR 0x00000002
#define CR0_FPUEMULATION 0x00000004
#define CR0_TASKSWITCH 0x00000008
#define CR0_FPUPRESENT 0x00000010
#define CR0_PAGING 0x80000000
// *********************************************************************
// Descriptor
// *********************************************************************
#define CR0_PROTECTION 0x00000001
#define CR0_FPUENABLED 0x00000002
#define CR0_FPUMONITOR 0x00000004
#define CR0_TASKSWITCH 0x00000008
#define CR0_FPUPRESENT 0x00000010
#define CR0_PAGING 0x80000000
#define DESC_INVALID 0x00
#define DESC_286_TSS_A 0x01
#define DESC_LDT 0x02
@ -360,9 +374,16 @@ public:
return ldt_value;
}
bool LLDT(Bitu value) {
//TODO checking
if ((value&0xfffc)==0) {
ldt_value=0;
ldt_base=0;
ldt_limit=0;
return true;
}
Descriptor desc;
GetDescriptor(value,desc);
if (!GetDescriptor(value,desc)) return !CPU_PrepareException(EXCEPTION_GP,value);
if (desc.Type()!=DESC_LDT) return !CPU_PrepareException(EXCEPTION_GP,value);
if (!desc.saved.seg.p) return !CPU_PrepareException(EXCEPTION_NP,value);
ldt_base=desc.GetBase();
ldt_limit=desc.GetLimit();
ldt_value=value;
@ -410,6 +431,7 @@ struct CPUBlock {
Bitu which,error;
} exception;
Bits direction;
Bit32u drx[8];
};
extern CPUBlock cpu;