[FAST486]

Reading/writing to memory should #SS(0) when the segment is the stack segment,
and #GP(0) otherwise. It should never generate #NP.


svn path=/trunk/; revision=69427
This commit is contained in:
Aleksandar Andrejevic 2015-10-02 15:11:24 +00:00
parent a1ae94ce52
commit 7fe13943a9

View file

@ -42,6 +42,8 @@ Fast486ReadMemory(PFAST486_STATE State,
{ {
ULONG LinearAddress; ULONG LinearAddress;
PFAST486_SEG_REG CachedDescriptor; PFAST486_SEG_REG CachedDescriptor;
FAST486_EXCEPTIONS Exception = SegmentReg != FAST486_REG_SS
? FAST486_EXCEPTION_GP : FAST486_EXCEPTION_SS;
ASSERT(SegmentReg < FAST486_NUM_SEG_REGS); ASSERT(SegmentReg < FAST486_NUM_SEG_REGS);
@ -53,7 +55,7 @@ Fast486ReadMemory(PFAST486_STATE State,
if ((Offset + Size - 1) > CachedDescriptor->Limit) if ((Offset + Size - 1) > CachedDescriptor->Limit)
{ {
/* Read beyond limit */ /* Read beyond limit */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
} }
@ -62,7 +64,7 @@ Fast486ReadMemory(PFAST486_STATE State,
if (Offset < CachedDescriptor->Limit) if (Offset < CachedDescriptor->Limit)
{ {
/* Read beyond limit */ /* Read beyond limit */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
} }
@ -74,14 +76,14 @@ Fast486ReadMemory(PFAST486_STATE State,
if (!CachedDescriptor->Present) if (!CachedDescriptor->Present)
{ {
Fast486Exception(State, FAST486_EXCEPTION_NP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
if ((!InstFetch && (CachedDescriptor->Rpl > CachedDescriptor->Dpl)) if ((!InstFetch && (CachedDescriptor->Rpl > CachedDescriptor->Dpl))
|| (Fast486GetCurrentPrivLevel(State) > CachedDescriptor->Dpl)) || (Fast486GetCurrentPrivLevel(State) > CachedDescriptor->Dpl))
{ {
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
@ -90,7 +92,7 @@ Fast486ReadMemory(PFAST486_STATE State,
if (!CachedDescriptor->Executable) if (!CachedDescriptor->Executable)
{ {
/* Data segment not executable */ /* Data segment not executable */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
} }
@ -99,7 +101,7 @@ Fast486ReadMemory(PFAST486_STATE State,
if (CachedDescriptor->Executable && (!CachedDescriptor->ReadWrite)) if (CachedDescriptor->Executable && (!CachedDescriptor->ReadWrite))
{ {
/* Code segment not readable */ /* Code segment not readable */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
} }
@ -166,6 +168,8 @@ Fast486WriteMemory(PFAST486_STATE State,
{ {
ULONG LinearAddress; ULONG LinearAddress;
PFAST486_SEG_REG CachedDescriptor; PFAST486_SEG_REG CachedDescriptor;
FAST486_EXCEPTIONS Exception = SegmentReg != FAST486_REG_SS
? FAST486_EXCEPTION_GP : FAST486_EXCEPTION_SS;
ASSERT(SegmentReg < FAST486_NUM_SEG_REGS); ASSERT(SegmentReg < FAST486_NUM_SEG_REGS);
@ -177,7 +181,7 @@ Fast486WriteMemory(PFAST486_STATE State,
if ((Offset + Size - 1) > CachedDescriptor->Limit) if ((Offset + Size - 1) > CachedDescriptor->Limit)
{ {
/* Write beyond limit */ /* Write beyond limit */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
} }
@ -185,8 +189,8 @@ Fast486WriteMemory(PFAST486_STATE State,
{ {
if (Offset < CachedDescriptor->Limit) if (Offset < CachedDescriptor->Limit)
{ {
/* Read beyond limit */ /* Write beyond limit */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
} }
@ -198,27 +202,27 @@ Fast486WriteMemory(PFAST486_STATE State,
if (!CachedDescriptor->Present) if (!CachedDescriptor->Present)
{ {
Fast486Exception(State, FAST486_EXCEPTION_NP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
if ((CachedDescriptor->Rpl > CachedDescriptor->Dpl) if ((CachedDescriptor->Rpl > CachedDescriptor->Dpl)
|| (Fast486GetCurrentPrivLevel(State) > CachedDescriptor->Dpl)) || (Fast486GetCurrentPrivLevel(State) > CachedDescriptor->Dpl))
{ {
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
if (CachedDescriptor->Executable) if (CachedDescriptor->Executable)
{ {
/* Code segment not writable */ /* Code segment not writable */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
else if (!CachedDescriptor->ReadWrite) else if (!CachedDescriptor->ReadWrite)
{ {
/* Data segment not writeable */ /* Data segment not writeable */
Fast486Exception(State, FAST486_EXCEPTION_GP); Fast486Exception(State, Exception);
return FALSE; return FALSE;
} }
} }