]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MEMM/EMM/EMMDEF.INC

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / MEMM / EMM / EMMDEF.INC
1 ;******************************************************************************
2 ;
3 ; (C) Copyright MICROSOFT Corp. 1986
4 ;
5 ; Title: CEMM.EXE - COMPAQ Expanded Memory Manager 386 Driver
6 ; EMMLIB.LIB - Expanded Memory Manager Library
7 ;
8 ; Module: EMMDEF.INC - defines for EMM code.
9 ;
10 ; Version: 0.04
11 ;
12 ; Date: June 21, 1986
13 ;
14 ;******************************************************************************
15 ;
16 ; Change log:
17 ;
18 ; DATE REVISION DESCRIPTION
19 ; -------- -------- -------------------------------------------------------
20 ; 06/21/86 Original
21 ; 06/25/86 0.02 Changed HANDLE_CNT to 255 to match LIM spec (SBP).
22 ; 06/28/86 0.02 Name change from CEMM386 to CEMM (SBP).
23 ; 07/06/86 0.04 Changed save area struct (SBP).
24 ; 05/25/88 Changed to meet LIM 4.0 Spec (PC)
25 ;******************************************************************************
26 ifndef INC_LIST
27 .xlist
28 endif
29
30 ;******************************************************************************
31 ; G E N E R A L D E F I N E S
32 ;******************************************************************************
33 EMM_PAGE_CNT = 2048 ; maximum of 2048 EMM pages (32MB)
34 HANDLE_CNT = 255 ; maximum of 255 EMM handles
35 FRS_COUNT = 16 ; number of 'Fast Register Sets'
36
37 EMM32_PHYS_PAGES = 4 ; page frame contains 4 pages
38 ;
39 ; The 0 to 1M contains 64 physical pages. Of these we are not mapping anything
40 ; between E000 and FFFF, 0000 and 4000. So the Maximum physcial pages we can
41 ; get for mapping is 40.
42
43 TOT_PHYS_PAGES equ 64
44 MAX_PHYS_PAGES equ 40 ; Life, the Universe
45 ; and Everything
46 PAGE_SIZE = 1000h
47 ;
48 ; Of the above mappable pages the regions C000h to Dfffh have to be searched
49 ; for the mappable pages.
50 ;
51 ABOVE_CONV_STRT_SEG equ 0C000h
52 ABOVE_CONV_STRT_PG equ ABOVE_CONV_STRT_SEG SHR 10
53 ;
54 ABOVE_CONV_END_SEG equ 0DC00h
55 ABOVE_CONV_END_PG equ ABOVE_CONV_END_SEG SHR 10
56 ;
57 MAX_ABOVE_CONV_PAGES EQU 8
58 ;
59 ; Also the system memory mappable region starts at 4000h
60 ;
61 CONV_STRT_SEG equ 4000h
62 CONV_STRT_PG equ CONV_STRT_SEG SHR 10
63 ;
64 NUM_CONV_PGS equ (0A000h -4000h) SHR 10
65 ;
66 ; During init we keep track of mappable pages with an array of mappable_segs
67 ;
68
69 PAGE_MAPPABLE equ 0FFh ;
70 PAGE_NOT_MAPPABLE equ 0h ;
71
72
73 NULL_PAGE = 0FFFFh
74 NULL_HANDLE = 00FFFh
75
76
77 ;
78 ; Flags for memory move/xchg
79 ;
80 Source_GT_Dest_Flag = 80h ; Source > Destination for copy / xchg
81 Overlap_Flag = 40h ; Copy overlapping memory
82 Backward_Copy_Flag = 20h ; copy is going to be backward
83 ;
84 ; Flags for PFlag use in Alter Map and Jump
85 ;
86 PFLAG_VM = 0002h ; VM bit in High word of EFLAG
87 PFLAG_VIRTUAL = 0020h ; wheather it's call from virtual or proected mode
88 PFLAG_PATCH_CS_IP = 0008h ; Tell Protected mode dispatch to
89 ; patch new CS:IP onto it's return address
90 ;******************************************************************************
91 ; S T A T U S D E F I N E S
92 ;******************************************************************************
93 OK = 0
94 EMM_SW_MALFUNCTION = 80h
95 EMM_HW_MALFUNCTION = 81h
96 INVALID_HANDLE = 83h
97 INVALID_FUNCTION = 84h
98 NO_MORE_HANDLES = 85h
99 SAVED_PAGE_DEALLOC = 86h
100 NOT_ENOUGH_EXT_MEM = 87h
101 NOT_ENOUGH_FREE_MEM = 88h
102 ZERO_PAGES = 89h
103 LOG_PAGE_RANGE = 8Ah
104 PHYS_PAGE_RANGE = 8Bh
105 SAVE_AREA_FULL = 8Ch
106 MAP_PREV_SAVED = 8Dh
107 NO_MAP_SAVED = 8Eh
108 INVALID_SUBFUNCTION = 8Fh
109
110 ; LIM 4.0 extras
111
112 VALID_OVERLAP = 92h
113 INSUFFICIENT_EMM_PAGES = 93h
114 CONVENTIONAL_EMM_OVERLAP= 94h
115 INVALID_OFFSET = 95h
116 INVALID_REGION_LENGTH = 96h
117 OVERLAPPING_EXCHANGE = 97h
118 INVALID_MEMORY_TYPE = 98h
119 FRSETS_UNSUPPORTED = 99h
120 INVALID_FRSET = 9Ah
121 NO_MORE_FRSETS = 9Bh
122 FRSET_NON_ZERO = 9Ch
123 FRSET_UNDEFINED = 9Dh
124 FRSET_NO_DMA = 9Eh
125 FRSET_INVALID_DMA = 9Fh
126 HANDLE_NAME_NOT_FOUND = 0A0h
127 DUPLICATE_HANDLE_NAME = 0A1h
128 INVALID_WRAPAROUND = 0A2h
129 SOURCE_CORRUPTED = 0A3h
130 ACCESS_DENIED = 0A4h
131
132
133 ;******************************************************************************
134 ; GET/SET PAGE MAP SUBFUNCTION CODES
135 ;******************************************************************************
136 GSPM_GET equ 0
137 GSPM_SET equ 1
138 GSPM_GETSET equ 2
139 GSPM_SIZE equ 3
140
141 ;
142 ; OSEnabled Values
143 ;
144 OS_IDLE equ 0
145 OS_ENABLED equ 1
146 OS_DISABLED equ 2
147
148 ;******************************************************************************
149 ; S T R U C T U R E S
150 ;******************************************************************************
151
152 ;
153 ; stack frame after pushad on real/virtual mode entry
154 ;
155 r67_Frame struc
156 rDI dd ?
157 rSI dd ?
158 rBP dd ?
159 rSP dd ?
160 rBX dd ?
161 rDX dd ?
162 rCX dd ?
163 rAX dd ?
164 retaddr dw ?
165 rCS dw ?
166 PFlag dw ?
167 rDS dw ?
168 rES dw ?
169 rGS dw ?
170 rFS dw ?
171 r67_Frame ends
172
173
174 ;
175 ; for _handle_table
176 ;
177 HandleTable_struc struc
178 ht_index dw NULL_PAGE ; index into emm_page for handle's pgs
179 ht_count dw 0 ; number of emm_pages for this handle
180 HandleTable_struc ends
181
182 ;
183 ; for _save_area
184 ;
185 SaveMap_struc struc
186 s_handle dw NULL_HANDLE ; owning handle
187 s_map dw EMM32_PHYS_PAGES dup (NULL_PAGE) ; EMM page #s
188 SaveMap_struc ends
189
190 ;
191 ; structure linking segment with physical page number
192 ;
193 Mappable_Page struc
194 mappable_seg dw ?
195 mappable_pg dw ?
196 Mappable_Page ends
197
198 ;
199 ; Get Partial Page Map
200 ;
201 gppm_struc struc
202 gppm_count dw ?
203 gppm_segs dw ?
204 gppm_struc ends
205
206 ;
207 ; Structures used as arguments to Map Handle Array function
208 ;
209
210 ; For subfunction 0:
211 mha_array0 struc
212 mha0_log_pg dw ?
213 mha0_phys_pg dw ?
214 mha_array0 ends
215
216 ; For subfunction 1:
217 mha_array1 struc
218 mha1_log_pg dw ?
219 mha1_seg dw ?
220 mha_array1 ends
221
222 ; Used by Map and Jump and Map and Call -- Identical to mha_array0 and 1
223 log_phys_map_struct struc
224 log_page_number dw ?
225 phys_page_number_seg dw ?
226 log_phys_map_struct ends
227
228 ; Map and Jump structure
229 maj_struct struc
230 maj_target_address dd ?
231 maj_log_phys_map_len db ?
232 maj_map_address dd ?
233 maj_struct ends
234
235 ; Map and Call structure
236 mac_struct struc
237 mac_target_address dd ?
238 mac_new_page_map_len db ?
239 mac_new_map_address dd ?
240 mac_old_page_map_len db ?
241 mac_old_map_address dd ?
242 mac_reserved dw 4 dup (?)
243 mac_struct ends
244
245 ; Move / Exchange memory structure
246 mem_memory_descriptor_struct struc
247 mem_memory_type db ?
248 mem_handle dw ?
249 mem_initial_offset dw ?
250 mem_initial_seg_page dw ?
251 mem_memory_descriptor_struct ends
252
253
254 mem_struct struc
255 mem_region_length dd ?
256 mem_source db (SIZE mem_memory_descriptor_struct) dup (?)
257 mem_dest db (SIZE mem_memory_descriptor_struct) dup (?)
258 mem_struct ends
259
260 ;
261 ; Fast Register Set Description
262 ;
263 FRS_struc struc
264 FRS_Window dw MAX_PHYS_PAGES dup (NULL_PAGE) ; emm page numbers
265 FRS_alloc dw 0 ; Is this set allocated
266 FRS_struc ends
267
268 page
269 ;****************************************************************************
270 ;
271 ; Dword_Align -- Aligns code to dword boundry by inserting nops
272 ;
273 ;****************************************************************************
274
275 Dword_Align MACRO Seg_Name
276 IF (($ - OFFSET Seg_Name:0) MOD 4)
277 db 90h ;; Nop in code / else byte of 90h in data
278 Dword_Align Seg_Name
279 ENDIF
280 ENDM
281
282 page
283 ;***********************************************
284 ;
285 ; Validate_Handle - check the handle in DX
286 ;
287 ; ENTRY: Handle as per LIM4.0 spec. in DX
288 ;
289 ; EXIT: If the handle is invalid jump To Death_Label, otherwise,
290 ; EDX points to the _handle_table entry for the handle
291 ;
292 ; USES: EDX
293 ;
294 ;***********************************************
295 Validate_Handle MACRO Death_Label
296
297 cmp dx, [_handle_table_size] ;Q: handle in range ?
298 jae Death_Label ; N: go to error label
299 shl dx, 2 ; Y: convert handle to
300 add dx, offset _handle_table ; pointer
301 xchg bx, dx
302 cmp [bx.ht_index], NULL_PAGE ;Q: is this handle active ?
303 xchg bx, dx
304 je Death_Label ; N: return error
305
306 ENDM
307
308 ;***********************************************
309 ;
310 ; Handle2HandlePtr - convert the handle in DX to
311 ; points into handle_table
312 ;
313 ; ENTRY: Handle as per LIM4.0 spec. in DX
314 ;
315 ; EXIT: EDX points to the _handle_table entry for the handle
316 ;
317 ; USES: EDX
318 ;
319 ;***********************************************
320 Handle2HandlePtr MACRO
321
322 shl dx, 2 ; Y: convert handle to
323 add dx, offset _handle_table ; pointer
324
325 ENDM
326
327 .list ; end of EMMDEF.INC
328
329
330 \1a
331 \1a