]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MEMM/EMM/EMMDATA.ASM
2 ;******************************************************************************
3 title EMMDATA
- EMM
data structures definitions
4 ;******************************************************************************
6 ; (C) Copyright MICROSOFT Corp. 1986
8 ; Title: CEMM.EXE - COMPAQ Expanded Memory Manager 386 Driver
9 ; EMMLIB.LIB - Expanded Memory Manager Functions Library
17 ;******************************************************************************
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.
32 ;******************************************************************************
34 ; Functional Description:
35 ; data definitions for emm/lim
38 ;******************************************************************************
39 .lfcond
; list false conditionals
55 PUBLIC _page_frame_base
56 PUBLIC _mappable_pages
57 PUBLIC _mappable_page_count
58 PUBLIC _physical_page_count
59 PUBLIC _page_frame_pages
64 PUBLIC _Handle_Name_Table
65 PUBLIC _handle_table_size
74 PUBLIC EMM_dynamic_data_area
94 ;******************************************************************************
95 ; DATA STRUCTURES FOR MEMM
97 ; The data structures are documented below. Only a description of how
98 ; emm interfaces with the page table memory mananger is appropriate here
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.
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.
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.
115 ; given map_handle_page(phys_page, log_page, handle)
117 ; a. determine pte offset in system page table corresponding to phys_page
118 ; from the _page_frame_base table.
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.
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.
127 ; d. use this index into _pft386 to access the pte for the log page under
130 ; e. store this pte in the pte offset corresponding to the phys_page as
132 ;******************************************************************************
139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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.
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
155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
156 _EMMstatus
LABEL WORD
160 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
161 ;01. Register Block Pointer
162 ; points to the the vm86 regs on the
164 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
169 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
171 ; total # of EMM pages in system
172 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
173 _total_pages
LABEL WORD
176 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
177 ;03. LIM 3.2 PAGE FRAME
178 ; A suitable lim 3.2 page frame found
179 ; by scanning for free area
180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
183 dw 0FFFFh ; Undefined initially
186 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
195 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
196 _page_frame_base
LABEL DWORD
197 DW MAX_PHYS_PAGES
dup (0, PAGET_GSEL
) ; PTE offsets of physical pages
200 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
201 ;05. MAPPABLE PAGE ARRAY
202 ; this is the segment, physical page
203 ; correspondence array
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
206 _mappable_pages
LABEL WORD
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
218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
219 EMM_MPindex
LABEL byte ; table of indexes into above
220 _EMM_MPindex
LABEL byte
221 db 48 dup (-1) ; 4000h to 10000h
223 _mappable_page_count dw MAX_PHYS_PAGES
; number of entries in above
224 _physical_page_count dw 0 ; number of physical pages
227 _page_frame_pages dw 4 ; pages in the page frame
229 _VM1_EMM_Pages dw 30 ; 4000h to B800h for now
231 _VM1_EMM_Pages dw 24 ; 4000h to A000h for now
234 ; don't need it (used only in _set_40windows)
236 ;_VM1_EMM_Offset dw 0 ; Offset of these in context
238 ; combined into _cntxt_pages and _cntxt_bytes
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
245 _cntxt_pages db 0 ; Pages in context
246 _cntxt_bytes db 0 ; Bytes in context
248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
249 ;07. HARDWARE INFORMATION
250 ; Hardware information returned by Get
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
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
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
281 ; initialized to 0:0 for initial buffer inquiry
283 EMM_savES dw 0 ; store for buffer address provided
284 EMM_savDI dw 0 ; by user on frs function
286 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
287 ;10. Variable to support OS access functions
288 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
289 _OSEnabled dd 0 ; Security feature
290 _OSKey dd ?
; Key for security functions
293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
294 ;11. Mysterious variable right now
295 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
296 VEMMD_SSbase dd 0 ; Linear base of Stack Segment
298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
300 ; This is an array of structures that save
301 ; the current mapping state.
302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
304 REPT HANDLE_CNT
; one save area per handle
305 SaveMap_struc
<> ; save area
308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
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
330 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
331 ;15. book-keeping variables for handle table
332 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
333 _handle_table_size
LABEL WORD
336 _handle_count
LABEL WORD
339 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
341 ; emmpt_start is the index of the next
342 ; free entry in emm_page
343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
344 _emmpt_start
LABEL WORD
347 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
355 DW EMM_PAGE_CNT
; none free initially
357 _free_count
LABEL WORD
358 DW 0 ; none free initially
360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
361 ;18. POINTERS to the variable sized data structures
362 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
363 _emm_page dw offset dgroup
:EMM_dynamic_data_area
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
377 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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)
389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
395 ; it is initialized to FFFF entries. this is
397 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
398 _def_emm_free
LABEL WORD
399 DW EMM_PAGE_CNT
DUP(NULL_PAGE
)
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)
412 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
413 EMM_data_end
label byte
414 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
424 vdata_begin
label byte
425 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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)
437 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
443 ; it is initialized to FFFF entries. this is
445 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
446 _def_emm_freev
LABEL WORD
447 DW EMM_PAGE_CNT
DUP(NULL_PAGE
)
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)