2 * Fast486 386/486 CPU Emulation Library
5 * Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 /* DEFINES ********************************************************************/
28 #define FASTCALL __fastcall
31 #define SIGN_FLAG_BYTE 0x80
32 #define SIGN_FLAG_WORD 0x8000
33 #define SIGN_FLAG_LONG 0x80000000
34 #define REAL_MODE_FLAGS_MASK 0x17FD5
35 #define PROT_MODE_FLAGS_MASK 0x10DD5
37 /* Block size for string operations */
38 #define STRING_BLOCK_SIZE 4096
40 #define GET_SEGMENT_RPL(s) ((s) & 3)
41 #define GET_SEGMENT_INDEX(s) ((s) & 0xFFF8)
42 #define EXCEPTION_HAS_ERROR_CODE(x) (((x) == 8) || ((x) >= 10 && (x) <= 14))
44 #define PAGE_ALIGN(x) ((x) & 0xFFFFF000)
45 #define PAGE_OFFSET(x) ((x) & 0x00000FFF)
48 #define PAGE_SIZE 4096
51 typedef struct _FAST486_MOD_REG_RM
53 FAST486_GEN_REGS Register
;
57 FAST486_GEN_REGS SecondRegister
;
60 } FAST486_MOD_REG_RM
, *PFAST486_MOD_REG_RM
;
64 typedef union _FAST486_PAGE_DIR
71 ULONG WriteThrough
: 1;
77 ULONG TableAddress
: 20;
80 } FAST486_PAGE_DIR
, *PFAST486_PAGE_DIR
;
82 typedef union _FAST486_PAGE_TABLE
89 ULONG WriteThrough
: 1;
99 } FAST486_PAGE_TABLE
, *PFAST486_PAGE_TABLE
;
103 /* FUNCTIONS ******************************************************************/
108 PFAST486_STATE State
,
109 FAST486_SEG_REGS SegmentReg
,
119 PFAST486_STATE State
,
120 FAST486_SEG_REGS SegmentReg
,
127 Fast486InterruptInternal
129 PFAST486_STATE State
,
130 USHORT SegmentSelector
,
132 BOOLEAN InterruptGate
137 Fast486ExceptionWithErrorCode
139 PFAST486_STATE State
,
140 FAST486_EXCEPTIONS ExceptionCode
,
144 /* INLINED FUNCTIONS **********************************************************/
146 /* static */ FORCEINLINE
148 Fast486GetCurrentPrivLevel(PFAST486_STATE State
)
150 return GET_SEGMENT_RPL(State
->SegmentRegs
[FAST486_REG_CS
].Selector
);
153 #include "common.inl"