/
GXT_HDR.INC
144 lines (111 loc) · 4.82 KB
/
GXT_HDR.INC
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
;' $Header$
;
; (C) Copyright 1995-2002 Qualitas, Inc. All rights reserved.
;
; GXT_HDR.INC
;
; Header structure for MMEXT loaded modules
;
COMMENT|
The file to be loaded has the following format:
* Code segment(s) the first bytes of which are GXTHDR_STR
* Initialized data segment(s)
* Uninitialized data segment
Each module is processed as follows:
* The module is loaded into memory
* The module's INIT_REAL entry point is called
* The module is copied to XMS memory
After all modules are processed as above, each module is again
processed as follows:
* The module's selectors are allocated
* The module's INIT_PROT entry point is called
At INIT_PROT time, the selectors have been allocated. The first
selector maps the code as per GXTHDR_COFF/CLEN and the second selector
maps the data as per GXTHDR_DOFF/DLEN. The remaining selectors are
uninitialized, but may be initialized at INIT_PROT (or later) time by
writing into the GDT directly. Also at INIT_PROT and REST_PROT time,
the selector in ES maps all of memory. Note that the INIT_PROT and
REST_PROT routines are called on a 32-bit stack.
During execution in PM, all interrupts and exceptions must be on the
host's PL0 stack.
|
GXTHDR_STR struc
; Legend: R = filled in by module during INIT_REAL
; P = ... INIT_PROT
; L = ... loader before INIT_REAL
; ? = ... loader before INIT_PROT *FIXME*
; M = ... module before INIT_REAL
GXTHDR_CNT dw size GXTHDR_STR ; 00: R: # bytes in header
GXTHDR_NXT dw -1 ; 02: L: Segment of next header (-1=last)
GXTHDR_HVER dw ? ; 04: R: Header version #
GXTHDR_LVER dw 0100h ; 06: L: Loader version #
GXTHDR_COFF dd ? ; 08: R: Offset to PM code (typically zero)
GXTHDR_CLEN dd ? ; 0C: R: Length of ...
GXTHDR_DOFF dd ? ; 10: R: Offset to PM data
GXTHDR_DLEN dd ? ; 14: R: Length of ... (may include
; uninitialized data)
GXTHDR_IREAL dd ? ; 18: M: Seg:Off of INIT_REAL code
GXTHDR_IPROT df ? ; 1C: R: Sel:Off of INIT_PROT code
GXTHDR_RPROT df ? ; 22: R: Sel:Off of REST_PROT code
GXTHDR_RREAL dd ? ; 28: R: REST_REAL code/data offset
dd ? ; 2C: R: ... length
GXTHDR_NSELS dw ? ; 30: R: # consecutive selectors needed
; including initial code/data
GXTHDR_SELCR3 dw ? ; 32: ?: Selector which maps CR3
GXTHDR_ATTR dd ? ; 34: L/R: Attributes (see GXTHDR_REC below)
GXTHDR_CBFVEC df ? ; 38: : Sel|Off of Callback address
GXTHDR_PRGSEG_CUR dw ? ; 3E: L/R: Current program segment of TSR
GXTHDR_PRGSEG_NXT dw ? ; 40: R: Upper limit segment of TSR
GXTHDR_HDRSEG dw ? ; 42: L: Header ...
GXTHDR_NLOWPARA dw ? ; 44: R: # paras needed in low DOS memory
dw ? ; 46: ?: (for alignment)
GXTHDR_PM2RM_FVEC df ? ; 48: P: Sel:Off of entry from PM to RM transfer
dw ? ; 4E: ?: (for alignment)
GXTHDR_RM2PM_VEC dd ? ; 50: L: Seg:Off of RM to PM transfer function
GXTHDR_RM2PM_FVEC df ? ; 54: P: Sel:Off of entry from RM to PM transfer
GXTHDR_IBV0 db ? ; 5A: ?: Master PIC base
GXTHDR_IBV1 db ? ; 5B: ?: Slave ...
GXTHDR_PHYSIZE dd ? ; 5C: L: Top of physical memory in 1KB
GXTHDR_STR ends
; The callback function checks for one of the following function codes in EAX
@GXCB_CHGIDT equ 0000h ; The client is about to change the IDT
@GXCB_CHGIDTZ equ 0001h ; ... is finished changing ...
@GXCB_SETCR3 equ 0002h ; ... is setting CR3
@GXCB_LIN2PHYS equ 0003h ; ... requests a linear to physical
; address conversion
@GXCB_RELRMSTK equ 0004h ; ... is releasing a RM stack
GXTHDR_REC record \
$GXTHDR_VDS:1, \
$GXTHDR_FCR3:1, \
$GXTHDR_USE32:1, \
$GXTHDR_RMIE:1, \
$GXTHDR_PSWAT:1
@GXTHDR_VDS equ (mask $GXTHDR_VDS) ; XMS lock addresses need VDS translation
@GXTHDR_FCR3 equ (mask $GXTHDR_FCR3) ; The MM has a full CR3
@GXTHDR_USE32 equ (mask $GXTHDR_USE32) ; Initial code selector for
; module is USE32
@GXTHDR_RMIE equ (mask $GXTHDR_RMIE) ; Real mode initialization error
@GXTHDR_PSWAT equ (mask $GXTHDR_PSWAT) ; SWAT present: do not call @VCPI_DPRES
; To fail a load module and abort the loader itself, set RMIE.
; To fail a load module but continue with other load modules,
; return CLEN=DLEN=0.
; Structure for entering PM from RM
EPRM_STR struc
EPRM_EIP dd ? ; Caller's EIP
EPRM_CS dw ?,? ; ... CS w/filler
EPRM_EFL dd ? ; ... EFL
EPRM_ESP dd ? ; ... ESP
EPRM_SS dw ?,? ; ... SS w/filler
EPRM_ES dw ?,? ; ... ES w/filler
EPRM_DS dw ?,? ; ... DS w/filler
EPRM_FS dw ?,? ; ... FS w/filler
EPRM_GS dw ?,? ; ... GS w/filler
EPRM_STR ends
RM2PM_STR struc
RM2PM_EGP db (size PUSHAD_STR) dup (?) ; ... EGPs
RM2PM_EPRM db (size EPRM_STR) dup (?) ; ... EPRM
RM2PM_NEXT dd ? ; RM_NEXT
RM2PM_DEV_FLAG dw ? ; DEV_FLAG
RM2PM_GDTR df ? ; RM_GDTR
RM2PM_STR ends