[FAST486]

- Call Fast486GetCurrentPrivLevel only when needed.
- Fix a type.

svn path=/branches/ntvdm/; revision=61211
This commit is contained in:
Hermès Bélusca-Maïto 2013-12-03 23:51:51 +00:00
parent aad49cc77c
commit a2bd742ecd
4 changed files with 20 additions and 23 deletions

View file

@ -118,7 +118,6 @@ Fast486WriteMemory(PFAST486_STATE State,
{
/* Write beyond limit */
Fast486Exception(State, FAST486_EXCEPTION_GP);
return FALSE;
}

View file

@ -40,19 +40,19 @@
#define SEGMENT_TABLE_INDICATOR (1 << 2)
#define EXCEPTION_HAS_ERROR_CODE(x) (((x) == 8) || ((x) >= 10 && (x) <= 14))
#define NO_LOCK_PREFIX() if (State->PrefixFlags & FAST486_PREFIX_LOCK)\
#define NO_LOCK_PREFIX()\
if (State->PrefixFlags & FAST486_PREFIX_LOCK)\
{\
Fast486Exception(State, FAST486_EXCEPTION_UD);\
return FALSE;\
}
#define TOGGLE_OPSIZE(x) if (State->PrefixFlags & FAST486_PREFIX_OPSIZE)\
{\
x = !x;\
}
#define TOGGLE_ADSIZE(x) if (State->PrefixFlags & FAST486_PREFIX_ADSIZE)\
{\
x = !x;\
}
#define TOGGLE_OPSIZE(x)\
if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) x = !x;
#define TOGGLE_ADSIZE(x)\
if (State->PrefixFlags & FAST486_PREFIX_ADSIZE) x = !x;
#define SWAP(x, y) { (x) ^= (y); (y) ^= (x); (x) ^= (y); }
#define PAGE_ALIGN(x) ((x) & 0xFFFFF000)

View file

@ -122,13 +122,12 @@ Fast486ReadLinearMemory(PFAST486_STATE State,
PVOID Buffer,
ULONG Size)
{
INT Cpl = Fast486GetCurrentPrivLevel(State);
/* Check if paging is enabled */
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PG)
{
ULONG Page;
FAST486_PAGE_TABLE TableEntry;
INT Cpl = Fast486GetCurrentPrivLevel(State);
for (Page = PAGE_ALIGN(LinearAddress);
Page <= PAGE_ALIGN(LinearAddress + Size - 1);
@ -151,14 +150,14 @@ Fast486ReadLinearMemory(PFAST486_STATE State,
/* Check if this is the first page */
if (Page == PAGE_ALIGN(LinearAddress))
{
/* Start copying from the offset from the beginning of the page */
/* Start reading from the offset from the beginning of the page */
PageOffset = PAGE_OFFSET(LinearAddress);
}
/* Check if this is the last page */
if (Page == PAGE_ALIGN(LinearAddress + Size - 1))
{
/* Copy only a part of the page */
/* Read only a part of the page */
PageLength = PAGE_OFFSET(LinearAddress) + Size - PageOffset;
}
@ -185,13 +184,12 @@ Fast486WriteLinearMemory(PFAST486_STATE State,
PVOID Buffer,
ULONG Size)
{
INT Cpl = Fast486GetCurrentPrivLevel(State);
/* Check if paging is enabled */
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PG)
{
ULONG Page;
FAST486_PAGE_TABLE TableEntry;
INT Cpl = Fast486GetCurrentPrivLevel(State);
for (Page = PAGE_ALIGN(LinearAddress);
Page <= PAGE_ALIGN(LinearAddress + Size - 1);
@ -216,14 +214,14 @@ Fast486WriteLinearMemory(PFAST486_STATE State,
/* Check if this is the first page */
if (Page == PAGE_ALIGN(LinearAddress))
{
/* Start copying from the offset from the beginning of the page */
/* Start writing from the offset from the beginning of the page */
PageOffset = PAGE_OFFSET(LinearAddress);
}
/* Check if this is the last page */
if (Page == PAGE_ALIGN(LinearAddress + Size - 1))
{
/* Copy only a part of the page */
/* Write only a part of the page */
PageLength = PAGE_OFFSET(LinearAddress) + Size - PageOffset;
}
@ -385,7 +383,7 @@ Fast486StackPop(PFAST486_STATE State,
FORCEINLINE
BOOLEAN
Fast486LoadSegment(PFAST486_STATE State,
INT Segment,
FAST486_SEG_REGS Segment,
USHORT Selector)
{
PFAST486_SEG_REG CachedDescriptor;

View file

@ -1434,7 +1434,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeGroupFF)
else if (ModRegRm.Register == 3)
{
USHORT Selector;
INT Segment = FAST486_REG_DS;
FAST486_SEG_REGS Segment = FAST486_REG_DS;
/* Check for the segment override */
if (State->PrefixFlags & FAST486_PREFIX_SEG)
@ -1487,7 +1487,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeGroupFF)
else if (ModRegRm.Register == 5)
{
USHORT Selector;
INT Segment = FAST486_REG_DS;
FAST486_SEG_REGS Segment = FAST486_REG_DS;
/* Check for the segment override */
if (State->PrefixFlags & FAST486_PREFIX_SEG)
@ -1580,7 +1580,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeGroupFF)
else if (ModRegRm.Register == 3)
{
USHORT Selector;
INT Segment = FAST486_REG_DS;
FAST486_SEG_REGS Segment = FAST486_REG_DS;
/* Check for the segment override */
if (State->PrefixFlags & FAST486_PREFIX_SEG)
@ -1636,7 +1636,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeGroupFF)
else if (ModRegRm.Register == 5)
{
USHORT Selector;
INT Segment = FAST486_REG_DS;
FAST486_SEG_REGS Segment = FAST486_REG_DS;
/* Check for the segment override */
if (State->PrefixFlags & FAST486_PREFIX_SEG)