Sync with trunk r63502.
[reactos.git] / lib / fast486 / common.h
index 39c629d..677bd19 100644 (file)
 #define SIGN_FLAG_BYTE  0x80
 #define SIGN_FLAG_WORD  0x8000
 #define SIGN_FLAG_LONG  0x80000000
-#define REAL_MODE_FLAGS_MASK 0x17FD5
-#define PROT_MODE_FLAGS_MASK 0x10DD5
+#define REAL_MODE_FLAGS_MASK 0x57FD5
+#define PROT_MODE_FLAGS_MASK 0x50DD5
 
 /* Block size for string operations */
 #define STRING_BLOCK_SIZE 4096
 
 #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)\
+#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)\
+
+#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 ALIGNMENT_CHECK(x, a) if (State->Flags.Ac \
+                                  && (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_AM)\
+                                  && (State->Cpl == 3)\
+                                  && (((x) % (a)) != 0))\
 {\
-    x = !x;\
+    Fast486Exception(State, FAST486_EXCEPTION_AC);\
+    return FALSE;\
 }
-#define SWAP(x, y) { (x) ^= (y); (y) ^= (x); (x) ^= (y); }
 
 #define PAGE_ALIGN(x)   ((x) & 0xFFFFF000)
 #define PAGE_OFFSET(x)  ((x) & 0x00000FFF)
@@ -149,7 +159,7 @@ Fast486InterruptInternal
     PFAST486_STATE State,
     USHORT SegmentSelector,
     ULONG Offset,
-    BOOLEAN InterruptGate
+    ULONG GateType
 );
 
 VOID
@@ -163,13 +173,6 @@ Fast486ExceptionWithErrorCode
 
 /* INLINED FUNCTIONS **********************************************************/
 
-/* static */ FORCEINLINE
-INT
-Fast486GetCurrentPrivLevel(PFAST486_STATE State)
-{
-    return GET_SEGMENT_RPL(State->SegmentRegs[FAST486_REG_CS].Selector);
-}
-
 #include "common.inl"
 
 #endif // _COMMON_H_