[FAST486]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 12 May 2015 19:10:52 +0000 (19:10 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 12 May 2015 19:10:52 +0000 (19:10 +0000)
- Only flush the TLB when needed.
- Flush the TLB after a reset.

svn path=/trunk/; revision=67698

reactos/lib/fast486/common.c
reactos/lib/fast486/common.inl
reactos/lib/fast486/extraops.c
reactos/lib/fast486/fast486.c

index 363324e..af7edc3 100644 (file)
@@ -834,7 +834,7 @@ Fast486TaskSwitch(PFAST486_STATE State, FAST486_TASK_SWITCH_TYPE Type, USHORT Se
     }
 
     /* Flush the TLB */
-    if (State->Tlb) RtlFillMemory(State->Tlb, NUM_TLB_ENTRIES * sizeof(ULONG), 0xFF);
+    Fast486FlushTlb(State);
 
     /* Update the CPL */
     if (NewTssLimit >= (sizeof(FAST486_TSS) - 1)) State->Cpl = GET_SEGMENT_RPL(NewTss.Cs);
index 8491451..864c634 100644 (file)
@@ -138,12 +138,23 @@ Fast486GetPageTableEntry(PFAST486_STATE State,
     {
         /* Set the TLB entry */
         State->Tlb[VirtualAddress >> 12] = TableEntry.Value;
+        State->TlbEmpty = FALSE;
     }
 
     /* Return the table entry */
     return TableEntry.Value;
 }
 
+FORCEINLINE
+VOID
+FASTCALL
+Fast486FlushTlb(PFAST486_STATE State)
+{
+    if (!State->Tlb || State->TlbEmpty) return;
+    RtlFillMemory(State->Tlb, NUM_TLB_ENTRIES * sizeof(ULONG), 0xFF);
+    State->TlbEmpty = TRUE;
+}
+
 FORCEINLINE
 BOOLEAN
 FASTCALL
index 6f053ff..2a4c6ba 100644 (file)
@@ -640,10 +640,10 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeLoadControlReg)
     State->PrefetchValid = FALSE;
 #endif
 
-    if (State->Tlb && (ModRegRm.Register == (INT)FAST486_REG_CR3))
+    if (ModRegRm.Register == (INT)FAST486_REG_CR3)
     {
         /* Flush the TLB */
-        RtlFillMemory(State->Tlb, NUM_TLB_ENTRIES * sizeof(ULONG), 0xFF);
+        Fast486FlushTlb(State);
     }
 
     /* Load a value to the control register */
index 89669e4..0ad6988 100644 (file)
@@ -284,6 +284,9 @@ Fast486Reset(PFAST486_STATE State)
     State->IntAckCallback   = IntAckCallback;
     State->FpuCallback      = FpuCallback;
     State->Tlb              = Tlb;
+
+    /* Flush the TLB */
+    Fast486FlushTlb(State);
 }
 
 VOID