Author: hbelusca
Date: Sat Oct 11 15:28:21 2014
New Revision: 64672
URL:
http://svn.reactos.org/svn/reactos?rev=64672&view=rev
Log:
[FAST486]: group Fast486GetIntVector and Fast486InterruptInternal calls into
Fast486PerformInterrupt and use it in the code.
Modified:
trunk/reactos/lib/fast486/common.c
trunk/reactos/lib/fast486/common.h
trunk/reactos/lib/fast486/common.inl
trunk/reactos/lib/fast486/fast486.c
trunk/reactos/lib/fast486/opcodes.c
Modified: trunk/reactos/lib/fast486/common.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.c?rev=6…
==============================================================================
--- trunk/reactos/lib/fast486/common.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.c [iso-8859-1] Sat Oct 11 15:28:21 2014
@@ -160,6 +160,56 @@
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
Fast486InterruptInternal(PFAST486_STATE State,
USHORT SegmentSelector,
@@ -304,14 +354,38 @@
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
FASTCALL
Fast486ExceptionWithErrorCode(PFAST486_STATE State,
FAST486_EXCEPTIONS ExceptionCode,
ULONG ErrorCode)
{
- FAST486_IDT_ENTRY IdtEntry;
-
/* Increment the exception count */
State->ExceptionCount++;
@@ -337,7 +411,8 @@
/* Restore the IP to the saved IP */
State->InstPtr = State->SavedInstPtr;
- if (!Fast486GetIntVector(State, ExceptionCode, &IdtEntry))
+ /* Perform the interrupt */
+ if (!Fast486PerformInterrupt(State, ExceptionCode))
{
/*
* If this function failed, that means Fast486Exception
@@ -346,19 +421,6 @@
return;
}
- /* Perform the interrupt */
- if (!Fast486InterruptInternal(State,
- IdtEntry.Selector,
- MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh),
- IdtEntry.Type))
- {
- /*
- * If this function failed, that means Fast486Exception
- * was called again, so just return in this case.
- */
- return;
- }
-
if (EXCEPTION_HAS_ERROR_CODE(ExceptionCode)
&& (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE))
{
Modified: trunk/reactos/lib/fast486/common.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.h?rev=6…
==============================================================================
--- trunk/reactos/lib/fast486/common.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.h [iso-8859-1] Sat Oct 11 15:28:21 2014
@@ -154,12 +154,10 @@
);
BOOLEAN
-Fast486InterruptInternal
+Fast486PerformInterrupt
(
PFAST486_STATE State,
- USHORT SegmentSelector,
- ULONG Offset,
- ULONG GateType
+ UCHAR Number
);
VOID
Modified: trunk/reactos/lib/fast486/common.inl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.inl?rev…
==============================================================================
--- trunk/reactos/lib/fast486/common.inl [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.inl [iso-8859-1] Sat Oct 11 15:28:21 2014
@@ -693,53 +693,6 @@
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
-BOOLEAN
Fast486CalculateParity(UCHAR Number)
{
// See
http://graphics.stanford.edu/~seander/bithacks.html#ParityLookupTable too...
Modified: trunk/reactos/lib/fast486/fast486.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fast486.c?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/fast486.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fast486.c [iso-8859-1] Sat Oct 11 15:28:21 2014
@@ -93,17 +93,8 @@
*/
if (State->IntStatus == FAST486_INT_EXECUTE)
{
- FAST486_IDT_ENTRY IdtEntry;
-
- /* Get the interrupt vector */
- if (Fast486GetIntVector(State, State->PendingIntNum, &IdtEntry))
- {
- /* Perform the interrupt */
- Fast486InterruptInternal(State,
- IdtEntry.Selector,
- MAKELONG(IdtEntry.Offset, IdtEntry.OffsetHigh),
- IdtEntry.Type);
- }
+ /* Perform the interrupt */
+ Fast486PerformInterrupt(State, State->PendingIntNum);
/* Clear the interrupt status */
State->IntStatus = FAST486_INT_NONE;
Modified: trunk/reactos/lib/fast486/opcodes.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opcodes.c?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] Sat Oct 11 15:28:21 2014
@@ -4615,7 +4615,6 @@
FAST486_OPCODE_HANDLER(Fast486OpcodeInt)
{
UCHAR IntNum;
- FAST486_IDT_ENTRY IdtEntry;
switch (Opcode)
{
@@ -4656,24 +4655,8 @@
}
}
- /* Get the interrupt vector */
- if (!Fast486GetIntVector(State, IntNum, &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;
+ return Fast486PerformInterrupt(State, IntNum);
}
FAST486_OPCODE_HANDLER(Fast486OpcodeIret)