Author: aandrejevic
Date: Wed Nov 20 10:48:26 2013
New Revision: 61057

URL: http://svn.reactos.org/svn/reactos?rev=61057&view=rev
Log:
[FAST486]
Read the LDT instead of the GDT when the table indicator is set.


Modified:
    branches/ntvdm/lib/fast486/common.h
    branches/ntvdm/lib/fast486/common.inl

Modified: branches/ntvdm/lib/fast486/common.h
URL: 
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.h?rev=61057&r1=61056&r2=61057&view=diff
==============================================================================
--- branches/ntvdm/lib/fast486/common.h [iso-8859-1] (original)
+++ branches/ntvdm/lib/fast486/common.h [iso-8859-1] Wed Nov 20 10:48:26 2013
@@ -37,6 +37,7 @@
 
 #define GET_SEGMENT_RPL(s)          ((s) & 3)
 #define GET_SEGMENT_INDEX(s)        ((s) & 0xFFF8)
+#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)\

Modified: branches/ntvdm/lib/fast486/common.inl
URL: 
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.inl?rev=61057&r1=61056&r2=61057&view=diff
==============================================================================
--- branches/ntvdm/lib/fast486/common.inl       [iso-8859-1] (original)
+++ branches/ntvdm/lib/fast486/common.inl       [iso-8859-1] Wed Nov 20 
10:48:26 2013
@@ -399,22 +399,45 @@
     /* Check for protected mode */
     if ((State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE) && 
!State->Flags.Vm)
     {
-        /* Make sure the GDT contains the entry */
-        if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1))
-        {
-            Fast486Exception(State, FAST486_EXCEPTION_GP);
-            return FALSE;
-        }
-
-        /* Read the GDT */
-        if (!Fast486ReadLinearMemory(State,
-                                     State->Gdtr.Address
-                                     + GET_SEGMENT_INDEX(Selector),
-                                     &GdtEntry,
-                                     sizeof(GdtEntry)))
-        {
-            /* Exception occurred */
-            return FALSE;
+        if (!(Selector & SEGMENT_TABLE_INDICATOR))
+        {
+            /* Make sure the GDT contains the entry */
+            if (GET_SEGMENT_INDEX(Selector) >= (State->Gdtr.Size + 1))
+            {
+                Fast486ExceptionWithErrorCode(State, FAST486_EXCEPTION_GP, 
Selector);
+                return FALSE;
+            }
+
+            /* Read the GDT */
+            if (!Fast486ReadLinearMemory(State,
+                                         State->Gdtr.Address
+                                         + GET_SEGMENT_INDEX(Selector),
+                                         &GdtEntry,
+                                         sizeof(GdtEntry)))
+            {
+                /* Exception occurred */
+                return FALSE;
+            }
+        }
+        else
+        {
+            /* Make sure the LDT contains the entry */
+            if (GET_SEGMENT_INDEX(Selector) >= (State->Ldtr.Size + 1))
+            {
+                Fast486ExceptionWithErrorCode(State, FAST486_EXCEPTION_GP, 
Selector);
+                return FALSE;
+            }
+
+            /* Read the LDT */
+            if (!Fast486ReadLinearMemory(State,
+                                         State->Ldtr.Address
+                                         + GET_SEGMENT_INDEX(Selector),
+                                         &GdtEntry,
+                                         sizeof(GdtEntry)))
+            {
+                /* Exception occurred */
+                return FALSE;
+            }
         }
 
         if (Segment == FAST486_REG_SS)
@@ -503,7 +526,6 @@
                         Fast486ExceptionWithErrorCode(State, 
FAST486_EXCEPTION_GP, Selector);
                         return FALSE;
                     }
-
                 }
 
                 /* Update CPL */


Reply via email to