mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 07:52:56 +00:00
[FAST486]: group Fast486GetIntVector and Fast486InterruptInternal calls into Fast486PerformInterrupt and use it in the code.
svn path=/trunk/; revision=64672
This commit is contained in:
parent
beb08f639d
commit
1e5192c2b4
5 changed files with 82 additions and 95 deletions
|
@ -160,6 +160,56 @@ Fast486WriteMemory(PFAST486_STATE State,
|
||||||
return Fast486WriteLinearMemory(State, LinearAddress, Buffer, Size);
|
return Fast486WriteLinearMemory(State, LinearAddress, Buffer, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
inline
|
||||||
|
BOOLEAN
|
||||||
|
Fast486GetIntVector(PFAST486_STATE State,
|
||||||
|
UCHAR Number,
|
||||||
|
PFAST486_IDT_ENTRY IdtEntry)
|
||||||
|
{
|
||||||
|
ULONG FarPointer;
|
||||||
|
|
||||||
|
/* Check for protected mode */
|
||||||
|
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE)
|
||||||
|
{
|
||||||
|
/* Read from the IDT */
|
||||||
|
if (!Fast486ReadLinearMemory(State,
|
||||||
|
State->Idtr.Address
|
||||||
|
+ Number * sizeof(*IdtEntry),
|
||||||
|
IdtEntry,
|
||||||
|
sizeof(*IdtEntry)))
|
||||||
|
{
|
||||||
|
/* Exception occurred */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Read from the real-mode IVT */
|
||||||
|
|
||||||
|
/* Paging is always disabled in real mode */
|
||||||
|
State->MemReadCallback(State,
|
||||||
|
State->Idtr.Address
|
||||||
|
+ Number * sizeof(FarPointer),
|
||||||
|
&FarPointer,
|
||||||
|
sizeof(FarPointer));
|
||||||
|
|
||||||
|
/* Fill a fake IDT entry */
|
||||||
|
IdtEntry->Offset = LOWORD(FarPointer);
|
||||||
|
IdtEntry->Selector = HIWORD(FarPointer);
|
||||||
|
IdtEntry->Zero = 0;
|
||||||
|
IdtEntry->Type = FAST486_IDT_INT_GATE;
|
||||||
|
IdtEntry->Storage = FALSE;
|
||||||
|
IdtEntry->Dpl = 0;
|
||||||
|
IdtEntry->Present = TRUE;
|
||||||
|
IdtEntry->OffsetHigh = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
inline
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
Fast486InterruptInternal(PFAST486_STATE State,
|
Fast486InterruptInternal(PFAST486_STATE State,
|
||||||
USHORT SegmentSelector,
|
USHORT SegmentSelector,
|
||||||
|
@ -304,14 +354,38 @@ Cleanup:
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
Fast486PerformInterrupt(PFAST486_STATE State,
|
||||||
|
UCHAR Number)
|
||||||
|
{
|
||||||
|
FAST486_IDT_ENTRY IdtEntry;
|
||||||
|
|
||||||
|
/* Get the interrupt vector */
|
||||||
|
if (!Fast486GetIntVector(State, Number, &IdtEntry))
|
||||||
|
{
|
||||||
|
/* Exception occurred */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform the interrupt */
|
||||||
|
if (!Fast486InterruptInternal(State,
|
||||||
|
IdtEntry.Selector,
|
||||||
|
MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh),
|
||||||
|
IdtEntry.Type))
|
||||||
|
{
|
||||||
|
/* Exception occurred */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
FASTCALL
|
FASTCALL
|
||||||
Fast486ExceptionWithErrorCode(PFAST486_STATE State,
|
Fast486ExceptionWithErrorCode(PFAST486_STATE State,
|
||||||
FAST486_EXCEPTIONS ExceptionCode,
|
FAST486_EXCEPTIONS ExceptionCode,
|
||||||
ULONG ErrorCode)
|
ULONG ErrorCode)
|
||||||
{
|
{
|
||||||
FAST486_IDT_ENTRY IdtEntry;
|
|
||||||
|
|
||||||
/* Increment the exception count */
|
/* Increment the exception count */
|
||||||
State->ExceptionCount++;
|
State->ExceptionCount++;
|
||||||
|
|
||||||
|
@ -337,20 +411,8 @@ Fast486ExceptionWithErrorCode(PFAST486_STATE State,
|
||||||
/* Restore the IP to the saved IP */
|
/* Restore the IP to the saved IP */
|
||||||
State->InstPtr = State->SavedInstPtr;
|
State->InstPtr = State->SavedInstPtr;
|
||||||
|
|
||||||
if (!Fast486GetIntVector(State, ExceptionCode, &IdtEntry))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* If this function failed, that means Fast486Exception
|
|
||||||
* was called again, so just return in this case.
|
|
||||||
*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Perform the interrupt */
|
/* Perform the interrupt */
|
||||||
if (!Fast486InterruptInternal(State,
|
if (!Fast486PerformInterrupt(State, ExceptionCode))
|
||||||
IdtEntry.Selector,
|
|
||||||
MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh),
|
|
||||||
IdtEntry.Type))
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If this function failed, that means Fast486Exception
|
* If this function failed, that means Fast486Exception
|
||||||
|
|
|
@ -154,12 +154,10 @@ Fast486WriteMemory
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
Fast486InterruptInternal
|
Fast486PerformInterrupt
|
||||||
(
|
(
|
||||||
PFAST486_STATE State,
|
PFAST486_STATE State,
|
||||||
USHORT SegmentSelector,
|
UCHAR Number
|
||||||
ULONG Offset,
|
|
||||||
ULONG GateType
|
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -691,53 +691,6 @@ Fast486FetchDword(PFAST486_STATE State,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
|
||||||
BOOLEAN
|
|
||||||
Fast486GetIntVector(PFAST486_STATE State,
|
|
||||||
UCHAR Number,
|
|
||||||
PFAST486_IDT_ENTRY IdtEntry)
|
|
||||||
{
|
|
||||||
ULONG FarPointer;
|
|
||||||
|
|
||||||
/* Check for protected mode */
|
|
||||||
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE)
|
|
||||||
{
|
|
||||||
/* Read from the IDT */
|
|
||||||
if (!Fast486ReadLinearMemory(State,
|
|
||||||
State->Idtr.Address
|
|
||||||
+ Number * sizeof(*IdtEntry),
|
|
||||||
IdtEntry,
|
|
||||||
sizeof(*IdtEntry)))
|
|
||||||
{
|
|
||||||
/* Exception occurred */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Read from the real-mode IVT */
|
|
||||||
|
|
||||||
/* Paging is always disabled in real mode */
|
|
||||||
State->MemReadCallback(State,
|
|
||||||
State->Idtr.Address
|
|
||||||
+ Number * sizeof(FarPointer),
|
|
||||||
&FarPointer,
|
|
||||||
sizeof(FarPointer));
|
|
||||||
|
|
||||||
/* Fill a fake IDT entry */
|
|
||||||
IdtEntry->Offset = LOWORD(FarPointer);
|
|
||||||
IdtEntry->Selector = HIWORD(FarPointer);
|
|
||||||
IdtEntry->Zero = 0;
|
|
||||||
IdtEntry->Type = FAST486_IDT_INT_GATE;
|
|
||||||
IdtEntry->Storage = FALSE;
|
|
||||||
IdtEntry->Dpl = 0;
|
|
||||||
IdtEntry->Present = TRUE;
|
|
||||||
IdtEntry->OffsetHigh = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
Fast486CalculateParity(UCHAR Number)
|
Fast486CalculateParity(UCHAR Number)
|
||||||
|
|
|
@ -93,17 +93,8 @@ Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command)
|
||||||
*/
|
*/
|
||||||
if (State->IntStatus == FAST486_INT_EXECUTE)
|
if (State->IntStatus == FAST486_INT_EXECUTE)
|
||||||
{
|
{
|
||||||
FAST486_IDT_ENTRY IdtEntry;
|
/* Perform the interrupt */
|
||||||
|
Fast486PerformInterrupt(State, State->PendingIntNum);
|
||||||
/* Get the interrupt vector */
|
|
||||||
if (Fast486GetIntVector(State, State->PendingIntNum, &IdtEntry))
|
|
||||||
{
|
|
||||||
/* Perform the interrupt */
|
|
||||||
Fast486InterruptInternal(State,
|
|
||||||
IdtEntry.Selector,
|
|
||||||
MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh),
|
|
||||||
IdtEntry.Type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear the interrupt status */
|
/* Clear the interrupt status */
|
||||||
State->IntStatus = FAST486_INT_NONE;
|
State->IntStatus = FAST486_INT_NONE;
|
||||||
|
|
|
@ -4615,7 +4615,6 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeRetFar)
|
||||||
FAST486_OPCODE_HANDLER(Fast486OpcodeInt)
|
FAST486_OPCODE_HANDLER(Fast486OpcodeInt)
|
||||||
{
|
{
|
||||||
UCHAR IntNum;
|
UCHAR IntNum;
|
||||||
FAST486_IDT_ENTRY IdtEntry;
|
|
||||||
|
|
||||||
switch (Opcode)
|
switch (Opcode)
|
||||||
{
|
{
|
||||||
|
@ -4656,24 +4655,8 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeInt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the interrupt vector */
|
|
||||||
if (!Fast486GetIntVector(State, IntNum, &IdtEntry))
|
|
||||||
{
|
|
||||||
/* Exception occurred */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Perform the interrupt */
|
/* Perform the interrupt */
|
||||||
if (!Fast486InterruptInternal(State,
|
return Fast486PerformInterrupt(State, IntNum);
|
||||||
IdtEntry.Selector,
|
|
||||||
MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh),
|
|
||||||
IdtEntry.Type))
|
|
||||||
{
|
|
||||||
/* Exception occurred */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FAST486_OPCODE_HANDLER(Fast486OpcodeIret)
|
FAST486_OPCODE_HANDLER(Fast486OpcodeIret)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue