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
|
COMMENT #
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* MODULE NAME : INDEDES *
* *
* *
* 5669-196 (C) COPYRIGHT 1988 Microsoft *
* *
* DESCRIPTIVE NAME: Macros for setting up 80386 descriptors *
* *
* STATUS (LEVEL) : Version (0) Level (1.0) *
* *
* FUNCTION : DESCR_DEF - Define storage for a descriptor *
* DESCR_INIT - Initialize a descriptor that has already *
* been defined *
* *
* MODULE TYPE : MAC *
* *
* REGISTER USAGE : 80286 Standard *
* *
* CHANGE ACTIVITY : *
* *
* $MAC(INDEDES) COMP(LOAD) PROD(3270PC) : *
* *
* $D0=D0004700 410 870604 D : NEW FOR RELEASE 1.1 *
* $P1=P0000311 410 870804 D : RENAME MODULE'S LIBRARY FILE TYPE TO "MAC" *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#
; DESCR_DEF: Define a descriptor in-line using DWs and DBs.
;
; Input: For Segment descriptors, TYPE = SEG.
; For Gate descriptors, TYPE = GATE.
; Other parameters are as described by comments below.
;
; Output: DWs (define words) and DBs (define bytes) using the passed
; values. Useful for copying descriptors directly out of the code
; space, as when their values are forever static.
;
; Example: DESCR_DEF SEG, TSS0_LEN, TSS0_LOC, 0, CPL0_DATA_ACCESS
;
; This defines a segment format (limit/base/access) descriptor
; based on the parameters, which are usually equated values. Note
; that the low word of the address is TSS0_LOC and the high byte
; is 0.
DESCR_DEF MACRO TYPE,PARM1,PARM2,PARM3,ARB
IFIDN <&TYPE>,<SEG>
;
; Segment descriptor definition
;
DW &PARM1 ; Segment limit
DW &PARM2 ; Segment base address - low word
DB &PARM3 ; Segment base address - high byte
DB &ARB ; Access rights byte
DW 0 ; Intel reserved
ENDIF
IFIDN <&TYPE>,<GATE>
;
; Gate descriptor definition
;
DW &PARM1 ; Destination offset
DW &PARM2 ; Destination segment selector
DB &PARM3 ; Word count for stack-to-stack copy
; (only for call gates when PL changes)
DB &ARB ; Access rights byte
DW 0 ; Intel reserved
ENDIF
ENDM
PAGE
; DESCR_INIT: Initialize a descriptor dynamically.
;
; NOTE: ES must already point to the BASE of table
; where you want the descriptor to go.
;
;
; Input: For Segment descriptors, TYPE = SEG.
; For 4K granularity Segment descriptors, TYPE = BSEG.
; For Gate descriptors, TYPE = GATE.
; If the FIELD parameter is supplied, a MOV DI,FIELD is generated.
; Otherwise, its current value is used. Other parameters are as
; described by comments below.
;
;
; Output: DI ends up as DI + 8 (i.e. pointing at next descriptor. This
; is useful if you are initializing several consecutive
; descriptors).
;
; The passed data is stored at ES:DI using string store. This
; macro would be used when creating descriptors dynamically, as
; when allocating virtual machines.
;
; Example: DESCR_INIT GATE,INT13_PTR,INT13_IP,INT13_CS,0,TRAP_GATE_ACCESS
;
; This stores the parameters in gate format (offset/ selector/word
; count/access) through ES:DI, where DI is first loaded with
; INT13_PTR.
DESCR_INIT MACRO TYPE,FIELD,PARM1,PARM2,PARM3,ARB
PUSH AX ; Save the utility register
IFNB <&FIELD>
MOV DI,&FIELD ; Set up index value to proper descriptor
ADD DI,GDT_LOC
ENDIF
IFIDN <&TYPE>,<SEG>
;
; Segment descriptor initialization
;
MOV AX,&PARM1 ; PARM1 = Segment Limit; load into AX
STOSW ; and store
MOV AX,&PARM2 ; PARM2 = BASE_LO_W; load into AX
STOSW ; and store
MOV AL,&PARM3 ; PARM3 = BASE_HI_B; load into AL, and
MOV AH,&ARB ; ARB = Access Rights Byte; load into AH
STOSW ; and store both
MOV AX,0 ; Make sure the Intel
STOSW ; reserved word is zero
ENDIF
IFIDN <&TYPE>,<BSEG>
;
; Big (4k granularity) segment descriptor initialization
;
MOV AX,&PARM1 ; PARM1 = Segment Limit; load into AX
STOSW ; and store
MOV AX,&PARM2 ; PARM2 = BASE_LO_W; load into AX
STOSW ; and store
MOV AL,&PARM3 ; PARM3 = BASE_HI_B; load into AL, and
MOV AH,&ARB ; ARB = Access Rights Byte; load into AH
STOSW ; and store both
MOV AX,0080H ; 4k granularity bit
STOSW
ENDIF
IFIDN <&TYPE>,<GATE>
;
; Gate descriptor initialization
;
MOV AX,&PARM1 ; PARM1 = Destination offset; load into AX
STOSW ; and store
MOV AX,&PARM2 ; PARM2 = Destination Selector;load into AX
STOSW ; and store
MOV AL,&PARM3 ; PARM3 = Word Count; load into AL, and
MOV AH,&ARB ; ARB = Access Rights Byte; load into AH
STOSW ; and store both
MOV AX,0 ; Make sure the Intel
STOSW ; reserved word is zero
ENDIF
POP AX ; Restore AX
ENDM
|