summaryrefslogtreecommitdiff
path: root/v4.0/src/DEV/XMAEM/INDEACC.INC
blob: 01a28b28811ef48a9a7b988e3c7b18e372081327 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
COMMENT #
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                             *
* MODULE NAME     : INDEACC                                                   *
*                                                                             *
*                                                                             *
*                    5669-196 (C) COPYRIGHT 1988 Microsoft Corporation 	      *
*                                                                             *
* DESCRIPTIVE NAME: Access rights byte definitions for 80386 XMA emulator     *
*                                                                             *
* STATUS (LEVEL)  : Version (0) Level (1.0)                                   *
*                                                                             *
* FUNCTION        : This file defines the access rights bytes used in         *
*                   descriptors that define the code and data segments.       *
*                                                                             *
* MODULE TYPE     : INC                                                       *
*                                                                             *
* REGISTER USAGE  : 80386 Standard                                            *
*                                                                             *
* RESTRICTIONS    : None                                                      *
*                                                                             *
* DEPENDENCIES    : None                                                      *
*                                                                             *
* EXTERNAL                                                                    *
* REFERENCES      : None                                                      *
*                                                                             *
* CHANGE ACTIVITY :                                                           *
*                                                                             *
* $MAC(INDEACC) COMP(LOAD) PROD(3270PC) :                                     *
*                                                                             *
* $D0=D0004700 410 870530 D : NEW FOR WSP RELEASE 1.1                         *
* $P1=P0000311 410 870804 D : RENAME MODULE'S LIBRARY FILE TYPE TO "INC"      *
*                                                                             *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#

PAGE
;       RECORD DEFINITIONS FOR ACCESS RIGHTS BYTES
;       ====== =========== === ====== ====== =====
;
;       Data Segments - Interpretation of access rights for DS/ES/SS


;       Define the bit fields for the access rights byte

DATA_ACC RECORD PRESENT:1,DPL:2,SEG_TYPE:1,XQTBLE:1,EXPDIR:1,WRTBLE:1,ACCESSED:1

              ; PRESENT  (1 bit)   0 = segment not present in memory
              ;                    1 = segment present in memory
              ;
              ; DPL      (2 bits)  Descriptor privilege level -- 0 to 3
              ;
              ; SEG_TYPE (1 bit)   0 = system segment
              ;                    1 = application segment
              ;
              ; XQTBL    (1 bit)   0 = segment is not executable (i.e., data)
              ;                    1 = segment is executable     (i.e., code)
              ;
              ; EXPDIR   (1 bit)   0 = expand up, i.e., normal data segment
              ;                    1 = expand down, i.e., stack segment
              ;
              ; WRTBLE   (1 bit)   0 = data segment is read only
              ;                    1 = data segment is read/write
              ;
              ; ACCESSED (1 bit)   0 = segment has not been accessed
              ;                    1 = segment has been accessed


; Privilege level 3 read/write data segment access rights byte

CPL3_DATA_ACCESS        EQU     11110011B     ; Present
                                              ; DPL = 3
                                              ; Application segment
                                              ; Not executable (i.e. data)
                                              ; Expand up
                                              ; Readable/Writable
                                              ; Accessed

; Privilege level 0 read/write data segment access rights byte

CPL0_DATA_ACCESS        EQU     10010011B     ; Present
                                              ; DPL = 0
                                              ; Application segment
                                              ; Not executable (i.e. data)
                                              ; Expand up
                                              ; Readable/Writable
                                              ; Accessed


NULL_ACCESS             EQU     00000000B     ; Null (Not present)


; Descriptor privilege levels.  These can be ANDed or ORed with the access
; rights byte to get the desired DPL for the descriptor.

DPL3                    EQU     01100000B
DPL2                    EQU     01000000B
DPL1                    EQU     00100000B
DPL0                    EQU     00000000B

PAGE
;       Code Segments - Interpretation of access rights for CS.
;                       Identical to data segments except for two fields.


CODE_ACC        RECORD  DATA_HI:5,CONFORM:1,READABLE:1,DATA_LO:1

              ; DATA_HI  (5 bits)  Same five bits as described for data segments
              ;                    PPRESENT (1), DPL (2), SEG_TYPE (1) and
              ;                    XQTBL (1)
              ;
              ; CONFORM  (1 bit)   0 = Non-conforming - cannot be called by
              ;                        someone with a different CPL
              ;                    1 = Conforming - can be called by anyone
              ;                        regardless of CPL.  CPL remains the same
              ;
              ; READABLE (1 bit)   0 = code segment is execute only
              ;                    1 = data segment is executable and readable
              ;
              ; DATA_LO  (1 bit)   Same bit as described for data segments
              ;                    ACCESSED (1)


; Privilege level 3 conforming readable code segment access rights byte
; BUT...
; We switched the DPL to 0.  Why?  Because the DPL of the current code segment
; determines the current privilege level (CPL).  Whatever is running at the
; time can only access data with a DPL >= CPL.  So if the DPL for the code
; segment were 3 and we tried to access data with a DPL of 0 we would get a
; fault. By setting the DPL of the code segment to 0 we can access all data
; and will never be bothered by faults.

CPL3_CODE_ACCESS        EQU     10011111B     ; Present
                                              ; DPL = 0
                                              ; Application segment
                                              ; Executable (i.e. code)
                                              ; Conforming
                                              ; Readable
                                              ; Accessed

; Access rights to be able to read and write to a code segment.  Code segments
; may not be written to.  So this access byte will define the segment as a
; read/write data segment.  It is the same as CPL3_DATA_ACCESS.

COMP_CODE_ACCESS        EQU     CPL3_DATA_ACCESS

; Privilege level 0 non-conforming readable code segment access rights byte

CPL0_CODE_ACCESS        EQU     10011011B     ; Present
                                              ; DPL = 0
                                              ; Application segment
                                              ; Executable (i.e. code)
                                              ; Non-conforming
                                              ; Readable
                                              ; Accessed

PAGE
;       System Segments - Interpretation of access rights for TR/LDTR as well as
;                         the four gate types.  The access rights byte for the
;                         GDTR and IDTR is undefined, meaning anyone can access
;                         the table (although not necessarily the segments
;                         defined in the table). The uppermost 4 bits are
;                         identical to those for data segments; the type field
;                         occupies the lowermost 4 bits.


SYSTEM_ACC      RECORD  DATA_H:4,DESC_TYPE:4

              ; DATA_H   (4 bits)  Same four bits as described for data segments
              ;                    PPRESENT (1), DPL (2) and SEG_TYPE (1)
              ;
              ; DESC_TYPE(4 bits)  0000  Intel Reserved
              ;                    0001  Available 286 TSS
              ;                    0010  LDT
              ;                    0011  Busy 286 TSS
              ;                    0100  Call Gate
              ;                    0101  Task Gate
              ;                    0110  286 Interrupt Gate
              ;                    0111  286 Trap Gate
              ;                    1000  Intel Reserved
              ;                    1001  Available 386 TSS
              ;                    1010  Intel Reserved
              ;                    1011  Busy 386 TSS
              ;                    1100  386 Call Gate
              ;                    1101  Intel Reserved
              ;                    1110  386 Interrupt Gate
              ;                    1111  386 Trap Gate
              ;


;       These equates cover the topmost 4 bits for system segment access
;       rights bytes.  They define the privilege level.

LDT_ACCESS      EQU     11100000B     ; Present, DPL = 3 for LDTs

TSS_ACCESS      EQU     10000000B     ; Present, DPL = 0 for TSSs

GATE_ACCESS     EQU     10000000B     ; Present, DPL = 0 for Gates


;       These are for the type field.  When "OR"ed with one of the above,
;       you have a complete access rights byte.

LDT_DESC        EQU     00000010B OR LDT_ACCESS

FREE_TSS        EQU     00000001B OR TSS_ACCESS
FREE_TSS_386    EQU     00001001B OR TSS_ACCESS

BUSY_TSS        EQU     00000011B OR TSS_ACCESS

CALL_GATE       EQU     00000100B OR GATE_ACCESS

TASK_GATE       EQU     00000101B OR GATE_ACCESS

INT_GATE        EQU     00000110B OR GATE_ACCESS

TRAP_GATE       EQU     00000111B OR GATE_ACCESS