2 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4 * MODULE NAME : INDEACC *
7 * 5669-196 (C) COPYRIGHT 1988 Microsoft Corporation *
9 * DESCRIPTIVE NAME: Access rights byte definitions for 80386 XMA emulator *
11 * STATUS (LEVEL) : Version (0) Level (1.0) *
13 * FUNCTION : This file defines the access rights bytes used in *
14 * descriptors that define the code and data segments. *
18 * REGISTER USAGE : 80386 Standard *
20 * RESTRICTIONS : None *
22 * DEPENDENCIES : None *
29 * $MAC(INDEACC) COMP(LOAD) PROD(3270PC) : *
31 * $D0=D0004700 410 870530 D : NEW FOR WSP RELEASE 1.1 *
32 * $P1=P0000311 410 870804 D : RENAME MODULE'S LIBRARY FILE TYPE TO "INC" *
34 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
38 ; RECORD DEFINITIONS FOR ACCESS RIGHTS BYTES
39 ; ====== =========== === ====== ====== =====
41 ; Data Segments - Interpretation of access rights for DS/ES/SS
44 ; Define the bit fields for the access rights byte
46 DATA_ACC RECORD PRESENT:1,DPL:2,SEG_TYPE:1,XQTBLE:1,EXPDIR:1,WRTBLE:1,ACCESSED:1
48 ; PRESENT (1 bit) 0 = segment not present in memory
49 ; 1 = segment present in memory
51 ; DPL (2 bits) Descriptor privilege level -- 0 to 3
53 ; SEG_TYPE (1 bit) 0 = system segment
54 ; 1 = application segment
56 ; XQTBL (1 bit) 0 = segment is not executable (i.e., data)
57 ; 1 = segment is executable (i.e., code)
59 ; EXPDIR (1 bit) 0 = expand up, i.e., normal data segment
60 ; 1 = expand down, i.e., stack segment
62 ; WRTBLE (1 bit) 0 = data segment is read only
63 ; 1 = data segment is read/write
65 ; ACCESSED (1 bit) 0 = segment has not been accessed
66 ; 1 = segment has been accessed
69 ; Privilege level 3 read/write data segment access rights byte
71 CPL3_DATA_ACCESS EQU 11110011B ; Present
74 ; Not executable (i.e. data)
79 ; Privilege level 0 read/write data segment access rights byte
81 CPL0_DATA_ACCESS EQU 10010011B ; Present
84 ; Not executable (i.e. data)
90 NULL_ACCESS EQU 00000000B ; Null (Not present)
93 ; Descriptor privilege levels. These can be ANDed or ORed with the access
94 ; rights byte to get the desired DPL for the descriptor.
102 ; Code Segments - Interpretation of access rights for CS.
103 ; Identical to data segments except for two fields.
106 CODE_ACC RECORD DATA_HI:5,CONFORM:1,READABLE:1,DATA_LO:1
108 ; DATA_HI (5 bits) Same five bits as described for data segments
109 ; PPRESENT (1), DPL (2), SEG_TYPE (1) and
112 ; CONFORM (1 bit) 0 = Non-conforming - cannot be called by
113 ; someone with a different CPL
114 ; 1 = Conforming - can be called by anyone
115 ; regardless of CPL. CPL remains the same
117 ; READABLE (1 bit) 0 = code segment is execute only
118 ; 1 = data segment is executable and readable
120 ; DATA_LO (1 bit) Same bit as described for data segments
124 ; Privilege level 3 conforming readable code segment access rights byte
126 ; We switched the DPL to 0. Why? Because the DPL of the current code segment
127 ; determines the current privilege level (CPL). Whatever is running at the
128 ; time can only access data with a DPL >= CPL. So if the DPL for the code
129 ; segment were 3 and we tried to access data with a DPL of 0 we would get a
130 ; fault. By setting the DPL of the code segment to 0 we can access all data
131 ; and will never be bothered by faults.
133 CPL3_CODE_ACCESS EQU 10011111B ; Present
135 ; Application segment
136 ; Executable (i.e. code)
141 ; Access rights to be able to read and write to a code segment. Code segments
142 ; may not be written to. So this access byte will define the segment as a
143 ; read/write data segment. It is the same as CPL3_DATA_ACCESS.
145 COMP_CODE_ACCESS EQU CPL3_DATA_ACCESS
147 ; Privilege level 0 non-conforming readable code segment access rights byte
149 CPL0_CODE_ACCESS EQU 10011011B ; Present
151 ; Application segment
152 ; Executable (i.e. code)
158 ; System Segments - Interpretation of access rights for TR/LDTR as well as
159 ; the four gate types. The access rights byte for the
160 ; GDTR and IDTR is undefined, meaning anyone can access
161 ; the table (although not necessarily the segments
162 ; defined in the table). The uppermost 4 bits are
163 ; identical to those for data segments; the type field
164 ; occupies the lowermost 4 bits.
167 SYSTEM_ACC RECORD DATA_H:4,DESC_TYPE:4
169 ; DATA_H (4 bits) Same four bits as described for data segments
170 ; PPRESENT (1), DPL (2) and SEG_TYPE (1)
172 ; DESC_TYPE(4 bits) 0000 Intel Reserved
173 ; 0001 Available 286 TSS
178 ; 0110 286 Interrupt Gate
180 ; 1000 Intel Reserved
181 ; 1001 Available 386 TSS
182 ; 1010 Intel Reserved
185 ; 1101 Intel Reserved
186 ; 1110 386 Interrupt Gate
191 ; These equates cover the topmost 4 bits for system segment access
192 ; rights bytes. They define the privilege level.
194 LDT_ACCESS EQU 11100000B ; Present, DPL = 3 for LDTs
196 TSS_ACCESS EQU 10000000B ; Present, DPL = 0 for TSSs
198 GATE_ACCESS EQU 10000000B ; Present, DPL = 0 for Gates
201 ; These are for the type field. When "OR"ed with one of the above,
202 ; you have a complete access rights byte.
204 LDT_DESC EQU 00000010B OR LDT_ACCESS
206 FREE_TSS EQU 00000001B OR TSS_ACCESS
207 FREE_TSS_386 EQU 00001001B OR TSS_ACCESS
209 BUSY_TSS EQU 00000011B OR TSS_ACCESS
211 CALL_GATE EQU 00000100B OR GATE_ACCESS
213 TASK_GATE EQU 00000101B OR GATE_ACCESS
215 INT_GATE EQU 00000110B OR GATE_ACCESS
217 TRAP_GATE EQU 00000111B OR GATE_ACCESS