2 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4 * MODULE NAME : INDEDES *
7 * 5669-196 (C) COPYRIGHT 1988 Microsoft *
9 * DESCRIPTIVE NAME: Macros for setting up 80386 descriptors *
11 * STATUS (LEVEL) : Version (0) Level (1.0) *
13 * FUNCTION : DESCR_DEF - Define storage for a descriptor *
14 * DESCR_INIT - Initialize a descriptor that has already *
19 * REGISTER USAGE : 80286 Standard *
23 * $MAC(INDEDES) COMP(LOAD) PROD(3270PC) : *
25 * $D0=D0004700 410 870604 D : NEW FOR RELEASE 1.1 *
26 * $P1=P0000311 410 870804 D : RENAME MODULE'S LIBRARY FILE TYPE TO "MAC" *
28 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
31 ; DESCR_DEF: Define a descriptor in-line using DWs and DBs.
33 ; Input: For Segment descriptors, TYPE = SEG.
34 ; For Gate descriptors, TYPE = GATE.
35 ; Other parameters are as described by comments below.
37 ; Output: DWs (define words) and DBs (define bytes) using the passed
38 ; values. Useful for copying descriptors directly out of the code
39 ; space, as when their values are forever static.
41 ; Example: DESCR_DEF SEG, TSS0_LEN, TSS0_LOC, 0, CPL0_DATA_ACCESS
43 ; This defines a segment format (limit/base/access) descriptor
44 ; based on the parameters, which are usually equated values. Note
45 ; that the low word of the address is TSS0_LOC and the high byte
49 DESCR_DEF MACRO TYPE,PARM1,PARM2,PARM3,ARB
53 ; Segment descriptor definition
55 DW &PARM1 ; Segment limit
56 DW &PARM2 ; Segment base address - low word
57 DB &PARM3 ; Segment base address - high byte
58 DB &ARB ; Access rights byte
65 ; Gate descriptor definition
67 DW &PARM1 ; Destination offset
68 DW &PARM2 ; Destination segment selector
69 DB &PARM3 ; Word count for stack-to-stack copy
70 ; (only for call gates when PL changes)
71 DB &ARB ; Access rights byte
80 ; DESCR_INIT: Initialize a descriptor dynamically.
82 ; NOTE: ES must already point to the BASE of table
83 ; where you want the descriptor to go.
86 ; Input: For Segment descriptors, TYPE = SEG.
87 ; For 4K granularity Segment descriptors, TYPE = BSEG.
88 ; For Gate descriptors, TYPE = GATE.
89 ; If the FIELD parameter is supplied, a MOV DI,FIELD is generated.
90 ; Otherwise, its current value is used. Other parameters are as
91 ; described by comments below.
94 ; Output: DI ends up as DI + 8 (i.e. pointing at next descriptor. This
95 ; is useful if you are initializing several consecutive
98 ; The passed data is stored at ES:DI using string store. This
99 ; macro would be used when creating descriptors dynamically, as
100 ; when allocating virtual machines.
102 ; Example: DESCR_INIT GATE,INT13_PTR,INT13_IP,INT13_CS,0,TRAP_GATE_ACCESS
104 ; This stores the parameters in gate format (offset/ selector/word
105 ; count/access) through ES:DI, where DI is first loaded with
109 DESCR_INIT MACRO TYPE,FIELD,PARM1,PARM2,PARM3,ARB
111 PUSH AX ; Save the utility register
115 MOV DI,&FIELD ; Set up index value to proper descriptor
123 ; Segment descriptor initialization
125 MOV AX,&PARM1 ; PARM1 = Segment Limit; load into AX
127 MOV AX,&PARM2 ; PARM2 = BASE_LO_W; load into AX
129 MOV AL,&PARM3 ; PARM3 = BASE_HI_B; load into AL, and
130 MOV AH,&ARB ; ARB = Access Rights Byte; load into AH
131 STOSW ; and store both
132 MOV AX,0 ; Make sure the Intel
133 STOSW ; reserved word is zero
140 ; Big (4k granularity) segment descriptor initialization
142 MOV AX,&PARM1 ; PARM1 = Segment Limit; load into AX
144 MOV AX,&PARM2 ; PARM2 = BASE_LO_W; load into AX
146 MOV AL,&PARM3 ; PARM3 = BASE_HI_B; load into AL, and
147 MOV AH,&ARB ; ARB = Access Rights Byte; load into AH
148 STOSW ; and store both
149 MOV AX,0080H ; 4k granularity bit
157 ; Gate descriptor initialization
159 MOV AX,&PARM1 ; PARM1 = Destination offset; load into AX
161 MOV AX,&PARM2 ; PARM2 = Destination Selector;load into AX
163 MOV AL,&PARM3 ; PARM3 = Word Count; load into AL, and
164 MOV AH,&ARB ; ARB = Access Rights Byte; load into AH
165 STOSW ; and store both
166 MOV AX,0 ; Make sure the Intel
167 STOSW ; reserved word is zero