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

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / MEMM / EMM / EMMDATA.ASM
1 page 58,132
2 ;******************************************************************************
3 title EMMDATA - EMM data structures definitions
4 ;******************************************************************************
5 ;
6 ; (C) Copyright MICROSOFT Corp. 1986
7 ;
8 ; Title: CEMM.EXE - COMPAQ Expanded Memory Manager 386 Driver
9 ; EMMLIB.LIB - Expanded Memory Manager Functions Library
10 ;
11 ; Module: EMMDAT
12 ;
13 ; Version: 0.04
14 ;
15 ; Date: June 14,1986
16 ;
17 ;******************************************************************************
18 ;
19 ; Change log:
20 ;
21 ; DATE REVISION DESCRIPTION
22 ; -------- -------- -------------------------------------------------------
23 ; 06/14/86 Added MapSize (SBP)
24 ; 06/27/86 0.02 Reordered tables to place size dependent ones at end.
25 ; 06/28/86 0.02 Name change from CEMM386 to CEMM (SBP).
26 ; 07/06/86 0.04 Made _emm_page,_emm_free, and _pft386 pointers instead
27 ; of labels to allow sizing of these arrays based on the
28 ; number of pages in the system. Also added _emm_brk.
29 ; ? 0.05 Modified for WIN386
30 ; 05/06/88 0.06 Modified back for MEMM.
31 ;
32 ;******************************************************************************
33 ;
34 ; Functional Description:
35 ; data definitions for emm/lim
36 ;
37 ;
38 ;******************************************************************************
39 .lfcond ; list false conditionals
40 .386p
41 ; include protseg.inc
42 include vdmseg.inc
43 include vdmsel.inc
44 include page.inc
45 include emmdef.inc
46
47 _DATA SEGMENT
48
49 public EMM_PAGE_CNT
50 public HANDLE_CNT
51
52 PUBLIC _total_pages
53 PUBLIC _EMMstatus
54 PUBLIC _emm40_info
55 PUBLIC _page_frame_base
56 PUBLIC _mappable_pages
57 PUBLIC _mappable_page_count
58 PUBLIC _physical_page_count
59 PUBLIC _page_frame_pages
60 PUBLIC EMM_MPindex
61 PUBLIC _EMM_MPindex
62 PUBLIC _save_map
63 PUBLIC _handle_table
64 PUBLIC _Handle_Name_Table
65 PUBLIC _handle_table_size
66 PUBLIC _handle_count
67 PUBLIC _emmpt_start
68 PUBLIC _free_top
69 PUBLIC _free_count
70 PUBLIC _emm_page
71 PUBLIC _emm_free
72 PUBLIC _pft386
73 PUBLIC _emm_brk
74 PUBLIC EMM_dynamic_data_area
75 PUBLIC EMM_data_end
76 PUBLIC _regp
77 PUBLIC EMM_savES
78 PUBLIC EMM_savDI
79 PUBLIC CurRegSet
80 PUBLIC _CurRegSet
81 PUBLIC CurRegSetn
82 PUBLIC FRS_array
83 PUBLIC FRS_free
84 PUBLIC PF_Base
85 PUBLIC _PF_Base
86 PUBLIC _OSEnabled
87 PUBLIC _OSKey
88 PUBLIC _VM1_EMM_Pages
89 PUBLIC _cntxt_pages
90 PUBLIC _cntxt_bytes
91
92
93
94 ;******************************************************************************
95 ; DATA STRUCTURES FOR MEMM
96 ;
97 ; The data structures are documented below. Only a description of how
98 ; emm interfaces with the page table memory mananger is appropriate here
99 ;
100 ; During initialisation the pages in the physical address space to be devoted
101 ; to emm are indicated in the _pft386 array. This array translates the emm
102 ; page number to a pte in the system page table.
103 ;
104 ; The emm pages currently free are copied to the emm_free stack and the
105 ; free_stack pointer points to the top of this stack.
106 ;
107 ; When pages are allocated to a handle the pages are allocated from the stack
108 ; and copied to the emm_page array. The place where a handles pages are
109 ; copied to in this array is recorded in the handle table. The emm_page array
110 ; should be kept compacted all the time. Thus if a handle is deallocated, the
111 ; pages allocated to the handle are copied to the emm_free stack and the hole
112 ; left behind in the emm_page array is compacted by shifting all the entries
113 ; below upwards updating the indexes stored in the handle table if needed.
114 ;
115 ; given map_handle_page(phys_page, log_page, handle)
116 ;
117 ; a. determine pte offset in system page table corresponding to phys_page
118 ; from the _page_frame_base table.
119 ;
120 ; b. access handle table for the handle and determine the start of the
121 ; emm pages allocated to the handle in the emm_page array.
122 ;
123 ; c. add log_page to this start offset in the emm_page array and access
124 ; the entry in this array. This entry is an offset into the _pft386
125 ; array for the emm page under consideration.
126 ;
127 ; d. use this index into _pft386 to access the pte for the log page under
128 ; consideration.
129 ;
130 ; e. store this pte in the pte offset corresponding to the phys_page as
131 ; determined in a.
132 ;******************************************************************************
133
134
135
136
137
138
139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
140 ;00. EMM Status
141 ; Current status of `HW'. The way this is handled is that
142 ; when returning status to caller, normal status is reported
143 ; via EMMstatus being moved into AX. Persistant errors
144 ; (such as internal datastructure inconsistancies, etc) are
145 ; placed in `EMMstatus' as HW failures. All other errors are
146 ; transient in nature (out of memory, handles, ...) and are
147 ; thus reported by directly setting AX. The EMMstatus variable
148 ; is provided for expansion and is not currently being
149 ; set to any other value.
150 ;
151 ; set to OK for now. when integrated, the value should be
152 ; set to EMM_HW_MALFUNCTION (81H) initially, then set to
153 ; OK (00H) when the `EMM ON' function is invoke
154 ;
155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
156 _EMMstatus LABEL WORD
157 DW 00H
158
159
160 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
161 ;01. Register Block Pointer
162 ; points to the the vm86 regs on the
163 ; stack
164 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
165 _regp LABEL WORD
166 DW 0
167 DW 0
168
169 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
170 ;02. TOTAL_PAGES
171 ; total # of EMM pages in system
172 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
173 _total_pages LABEL WORD
174 DW 0
175
176 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
177 ;03. LIM 3.2 PAGE FRAME
178 ; A suitable lim 3.2 page frame found
179 ; by scanning for free area
180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
181 PF_Base label word
182 _PF_Base label word
183 dw 0FFFFh ; Undefined initially
184
185
186 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
187 ;04. PAGE FRAME BASE
188 ; this is the map of linear addr.
189 ; of the n 16kb physical pages used to
190 ; access the EMM pages. The contents
191 ; far pointers into the system page
192 ; table. If a lim 3.2 page frame is
193 ; available it gets the entries at the
194 ; beginning
195 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
196 _page_frame_base LABEL DWORD
197 DW MAX_PHYS_PAGES dup (0, PAGET_GSEL) ; PTE offsets of physical pages
198
199 ;
200 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
201 ;05. MAPPABLE PAGE ARRAY
202 ; this is the segment, physical page
203 ; correspondence array
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
205 ;
206 _mappable_pages LABEL WORD
207 REPT MAX_PHYS_PAGES
208 Mappable_Page <0, 0>
209 ENDM
210
211 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
212 ;06. MAPPABLE PAGE INDEX ARRAY
213 ; the pages in system memory are numbered
214 ; 4000h onwards whereas the physical page
215 ; numbers are arbitrarily numbered. this
216 ; array indexes into the mappable page
217 ; array.
218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
219 EMM_MPindex LABEL byte ; table of indexes into above
220 _EMM_MPindex LABEL byte
221 db 48 dup (-1) ; 4000h to 10000h
222
223 _mappable_page_count dw MAX_PHYS_PAGES ; number of entries in above
224 _physical_page_count dw 0 ; number of physical pages
225
226
227 _page_frame_pages dw 4 ; pages in the page frame
228 ifdef CGA
229 _VM1_EMM_Pages dw 30 ; 4000h to B800h for now
230 else
231 _VM1_EMM_Pages dw 24 ; 4000h to A000h for now
232 endif
233
234 ; don't need it (used only in _set_40windows)
235 ;
236 ;_VM1_EMM_Offset dw 0 ; Offset of these in context
237 ;
238 ; combined into _cntxt_pages and _cntxt_bytes
239 ;
240 ;_VM1_cntxt_pages db 0 ; Pages in context
241 ;_VM1_cntxt_bytes db 0 ; Bytes in context
242 ;_VMn_cntxt_pages db 0
243 ;_VMn_cntxt_bytes db 0
244
245 _cntxt_pages db 0 ; Pages in context
246 _cntxt_bytes db 0 ; Bytes in context
247
248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
249 ;07. HARDWARE INFORMATION
250 ; Hardware information returned by Get
251 ; Information call
252 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
253 _emm40_info LABEL WORD
254 dw 0400h ; raw page size in paragraphs (16k)
255 dw FRS_COUNT-1 ; number of fast register sets
256 dw size FRS_window+2 ; max. number of bytes to save a context
257 ; ( FRS_window size + 2 )
258 dw 0 ; settable DMA channels
259 dw 0 ; DMA_channel_operation
260
261 ;
262 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
263 ;08. FRS MAPPING STATE ARRAY
264 ; Used to emulate FRS. FRS 0..FRS_COUNT-1. FRS 0
265 ; is the normal mapping set.
266 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
267 FRS_array LABEL WORD ; Array of Fast Register Set structures
268 REPT FRS_COUNT
269 FRS_struc <>
270 ENDM
271
272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
273 ;09. Variables to support FRS Implementation
274 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
275 FRS_free db 0 ; How many of the above are free
276 CurRegSetn db 0 ; Number of Current Register Set
277 _CurRegSet LABEL WORD
278 CurRegSet dw 0 ; Pointer to Current Register Set Area
279 ; in FRS_array
280
281 ; initialized to 0:0 for initial buffer inquiry
282 ;
283 EMM_savES dw 0 ; store for buffer address provided
284 EMM_savDI dw 0 ; by user on frs function
285
286 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
287 ;10. Variable to support OS access functions
288 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
289 _OSEnabled dd 0 ; Security feature
290 _OSKey dd ? ; Key for security functions
291
292
293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
294 ;11. Mysterious variable right now
295 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
296 VEMMD_SSbase dd 0 ; Linear base of Stack Segment
297
298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
299 ;12. save_map
300 ; This is an array of structures that save
301 ; the current mapping state.
302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
303 _save_map LABEL BYTE
304 REPT HANDLE_CNT ; one save area per handle
305 SaveMap_struc <> ; save area
306 ENDM
307
308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
309 ;13. handle_table
310 ; This is an array of handle pointers.
311 ; In addition to the handle number a ptr
312 ; to the start of the ems pages allocated
313 ; to the handle in emm_page array is given
314 ; emm_page index of NULL_PAGE means free
315 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
316 _handle_table LABEL WORD
317 REPT HANDLE_CNT ; one table per handle
318 HandleTable_struc <> ; initialized handle table
319 ENDM
320
321 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
322 ;14. handle name table
323 ; Under LIM 4.0 each allocated handle can
324 ; be given a 8 byte name. this array keeps
325 ; track of the handle names
326 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
327 _Handle_Name_Table LABEL QWORD
328 DQ HANDLE_CNT dup (0) ; 8 0 bytes for every handle name
329
330 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
331 ;15. book-keeping variables for handle table
332 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
333 _handle_table_size LABEL WORD
334 DW HANDLE_CNT
335
336 _handle_count LABEL WORD
337 DW 0
338
339 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
340 ;16. EMMPT_START
341 ; emmpt_start is the index of the next
342 ; free entry in emm_page
343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
344 _emmpt_start LABEL WORD
345 DW 0
346
347 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
348 ;17. FREE pointers
349 ; free_top is the index for the top free
350 ; page in the emm_free stack.
351 ; free_count is the number of free
352 ; pages in the emm_free stack
353 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
354 _free_top LABEL WORD
355 DW EMM_PAGE_CNT ; none free initially
356
357 _free_count LABEL WORD
358 DW 0 ; none free initially
359
360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
361 ;18. POINTERS to the variable sized data structures
362 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
363 _emm_page dw offset dgroup:EMM_dynamic_data_area
364 _emm_free dw 0
365 _pft386 dw 0
366 _emm_brk dw offset dgroup:EMM_data_end
367 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
368 ; Espensive data structures are going to be
369 ; to be assigned storage dynamically so that we
370 ; don't end up wasting space. These data areas
371 ; are referred to by pointers above.
372 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
373 EMM_dynamic_data_area LABEL BYTE
374 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
375
376 ifndef NOHIMEM
377 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
378 ;19. EMM Page table
379 ; this array contains lists of indexes into the pseudo
380 ; Page Table. Each list is pointed to
381 ; by a handle table entry and is sequential/contiguous.
382 ; This is so that maphandlepage doesn't have to scan
383 ; a list for the specified entry.
384 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
385 _def_emm_page LABEL WORD
386 DW EMM_PAGE_CNT DUP(0)
387
388
389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
390 ;20. EMM free table
391 ; this array is a stack of available page table entries.
392 ; each entry is an index into pft386[].
393 ; it is initialized to FFFF entries. this is
394 ; a null page entry/
395 ; it is initialized to FFFF entries. this is
396 ; a null page entry.
397 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
398 _def_emm_free LABEL WORD
399 DW EMM_PAGE_CNT DUP(NULL_PAGE)
400
401 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
402 ;21. PAGE FRAME TABLE
403 ; This array contains addresses of physical
404 ; page frames for 386 pages. A page is
405 ; referred to by an index into this array.
406 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
407 _def_pft386 LABEL DWORD
408 DD EMM_PAGE_CNT DUP(NULL_HANDLE AND 0fffh)
409
410 endif
411
412 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
413 EMM_data_end label byte
414 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
415
416 _DATA ENDS
417
418 ifndef NOHIMEM
419
420 else
421
422 VDATA SEGMENT
423 public vdata_begin
424 vdata_begin label byte
425 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
426 ;19. EMM Page table
427 ; this array contains lists of indexes into the pseudo
428 ; Page Table. Each list is pointed to
429 ; by a handle table entry and is sequential/contiguous.
430 ; This is so that maphandlepage doesn't have to scan
431 ; a list for the specified entry.
432 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
433 _def_emm_pagev LABEL WORD
434 DW EMM_PAGE_CNT DUP(0)
435
436
437 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
438 ;20. EMM free table
439 ; this array is a stack of available page table entries.
440 ; each entry is an index into pft386[].
441 ; it is initialized to FFFF entries. this is
442 ; a null page entry/
443 ; it is initialized to FFFF entries. this is
444 ; a null page entry.
445 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
446 _def_emm_freev LABEL WORD
447 DW EMM_PAGE_CNT DUP(NULL_PAGE)
448
449 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
450 ;21. PAGE FRAME TABLE
451 ; This array contains addresses of physical
452 ; page frames for 386 pages. A page is
453 ; referred to by an index into this array.
454 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
455 _def_pft386v LABEL DWORD
456 DD EMM_PAGE_CNT DUP(NULL_HANDLE AND 0fffh)
457
458 VDATA ENDS
459
460
461
462 endif
463
464
465 END
466 \1a
467 \1a