2 ;------------------------------------------------------------------------;
4 ;------------------------------------------------------------------------;
6 RESR_EXT_PGS DW 0 ;Ext mem reserved here after EMS taken ;an002; dms;
8 MACH_MODEL_PTR DD 0F000FFFEh ;Byte in upper BIOS that indicates @RH1
9 MODEL_BYTE DB (?) ; which system you are on. @RH1
10 PC1 EQU 0FFh ;Values returned for: PC 1 @RH1
11 PC_XT EQU 0FEh ; PC XT @RH1
12 XT_AQUARIUS EQU 0FBH ; PC Aquarius @RH1
13 PC_AT EQU 0FCh ; PC AT type - AT, PS/2 models @RH1
15 PS2MODEL80 EQU 0F8h ; 386 processor - PS/2 model 80 @RH1
17 INT15_SEC_MOD EQU ES:BYTE PTR [BX+3] ;Secondary model byte @RH2
18 SEC_MOD_TB EQU 4 ; PS/2 Model 50 @RH2
19 SEC_MOD_RR EQU 5 ; PS/2 Model 60 @RH2
21 START_BACMEM_SEG DW 0 ;Starting and ending segment addrs
22 END_BACMEM_SEG DW 0 ; of memory backed by the XMA card
24 INIT_ERR DW ? ;Initialization error flag @RH4
27 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
28 ;³ Device driver IOCTL call declares ³
29 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
30 EMULATOR_DD_NAME DB '386XMAEM',0 ;Device driver names for the Emulator
31 XMAAVIRT_DD_NAME DB 'INDXMAII',0 ; and WSP's XMA/A init code
32 DD_FILE_HANDLE DW ? ;File handle from opening either DD
34 REQ_PACKET_STRUC STRUC ;Generic IOCTL parameter packet
35 PACKET_LEN DW 4 ;Packet length (in bytes)
36 PACKET_FCN DW 0 ;DD defined function number
37 PACKET_WORD DW 0 ;Data area
40 REQ_PACKET REQ_PACKET_STRUC <> ;
46 POP DS ;Get this segment into CS
48 MOV DX,SS ;save stack segment
49 MOV CX,SP ;save stack pointer
50 CLI ;ints off during swap
51 MOV AX,CS ;move cs to ss
53 MOV SP,OFFSET TOP_OF_STACK ;sp to end of code
55 PUSH DX ;save old ss on new stack
56 PUSH CX ;save old sp on new stack
59 MOV DX,OFFSET WELCOME_MSG ;Print title and copy-right
63 push ax ;save affected regs ;an000; dms;
64 push bx ; ;an000; dms;
65 push cx ; ;an000; dms;
66 push dx ; ;an000; dms;
67 push si ; ;an000; dms;
68 push di ; ;an000; dms;
69 push ds ; ;an000; dms;
71 CALL GET_PARMS ;Get the user parameters
73 pop ds ;restore affected regs ;an000; dms;
84 MOV DX,OFFSET PARM_ERR_MSG ;Print message indicating
85 MOV AH,9 ; parameter error using
86 INT 21H ; DOS function call
87 MOV DX,OFFSET NOT_INSTL_MSG ;Print that the EMS driver
88 MOV AH,9 ; has not been installed
90 JMP GENERAL_FAILURE ;indicate general failure
93 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
94 ;³ Does the system use the XMA Emulator? ³
95 ;³ (PS/2 model 80 with 80386 processor) ³
96 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
98 LDS SI,MACH_MODEL_PTR ; DS:SI points to model descriptor @RH1
99 MOV AL,DS:BYTE PTR [SI] ; byte (F000:FEEE) @RH1
100 MOV MODEL_BYTE,AL ; @RH1
103 CMP MODEL_BYTE,PS2MODEL80 ;If the model byte is for a @RH7
104 JE FIND_EMULATOR ; PS/2 model 80 @RH7
105 JMP NOT_PS2MODEL80 ; then attempt to open the 80386 @RH7
106 FIND_EMULATOR: ; XMA Emulator device driver @RH7
107 MOV AX,3D00h ; (INDXMAEM.SYS) @RH7
108 LEA DX,EMULATOR_DD_NAME ; @RH7
109 INT 21h ;No carry means open successful @RH7
110 JNC EMUL_INSTALLED ; and the DD is present @RH7
111 PUSH CS ;Else open failed @RH7
112 POP DS ;Print message indicating @RH7
113 MOV DX,OFFSET NO_EMUL_MSG ; emulator not present @RH7
114 MOV AH,9 ;dos prt string @RH7
115 INT 21H ;write message @RH7
116 MOV DX,OFFSET NOT_INSTL_MSG ;Print that the EMS driver @RH7
117 MOV AH,9 ; has not been installed @RH7
119 JMP GENERAL_FAILURE ;indicate general failure @RH7
120 EMUL_INSTALLED: ;Emulator is present @RH7
121 MOV DD_FILE_HANDLE,AX ;Do IOCTL to find # of XMA blocks @RH7
122 MOV BX,AX ;Emulator DD handle in BX @RH7
123 MOV AX,440Ch ;Handle generic IOCTL fcn code @RH7
124 XOR CH,CH ;CH = 0 means "unknown" @RH7
125 MOV CL,60h ;CL = 40h means set device info @RH7
126 PUSH CS ; = 60h means get device info @RH7
128 LEA DX,REQ_PACKET ;DS:DX -> generic IOCTL packet @RH7
129 INT 21h ;Issue the generic IOCTL @RH7
130 JNC EMUL_VER_GOOD ;No carry means the right @RH7
131 PUSH CS ; version of the Emulator was @RH7
132 POP DS ; installed (can handle IOCTL) @RH7
133 MOV DX,OFFSET WRONG_EMUL_MSG ;Otherwise print message @RH7
134 MOV AH,9 ; indicating incorrect version @RH7
135 INT 21H ; of the Emulator detected @RH7
136 MOV DX,OFFSET NOT_INSTL_MSG ;Print that the EMS driver @RH7
137 MOV AH,9 ; has not been installed @RH7
139 JMP GENERAL_FAILURE ;indicate general failure @RH7
141 MOV AX,REQ_PACKET.PACKET_WORD ;Get the last available XMA block@RH7
142 INC AX ; number from the emulator...add 1 @RH7
143 XOR DX,DX ; to calc total XMA blocks and @RH7
144 DIV BLOCKS_PER_PAGE ; convert it to EMS pages @RH7
145 MOV TOTAL_SYS_PAGES,AX ;Set the number of total 16K pages @RH7
146 MOV TOTAL_EMS_PAGES,AX ; (before and after mem backing) @RH7
147 MOV FREE_PAGES,AX ; and the pages free for useage @RH7
148 MOV START_BACMEM_SEG,0 ;Mark from 0-640K as taken to @RH7
149 MOV END_BACMEM_SEG,0A000h ; back conventional memory and @RH7
150 CALL BACK_CONV_MEM ; adjust TOTAL_EMS_PAGES @RH7
151 MOV AX,3E00h ;Close the XMA Emulator device @RH7
152 MOV BX,DD_FILE_HANDLE ; driver @RH7
153 MOV MEMCARD_MODE,EMUL_VIRT ;Set flag for hardware used @RH7
155 JMP INT_67_INSTALL ;Install int 67 vector, end init @RH7
156 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
157 NOT_PS2MODEL80: ;³ Does the system use the XMA\A or XMO card? ³
158 ;³ (PS/2 models 50 and 60) ³
159 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
160 CMP MODEL_BYTE,PC_AT ;If the model byte is for an 'AT' @RH2
161 JE MODEL_AT ; type (80286 processor), check @RH2
162 JMP FAMILY_1_MACH ; the secondary model byte to @RH2
163 MODEL_AT: ; see if it's a model that uses @RH2
164 MOV AH,0C0h ; the XMA/A or XMO card @RH2
166 CMP INT15_SEC_MOD,SEC_MOD_TB; @RH2
167 JNE NOT_PS2MODEL50 ; @RH2
168 MOV NUM_OF_SLOTS,4 ; PS2/50 has 4 adapter slots @RH2
169 JMP PS2_5060 ; Init for XMA/A and XMO @RH2
170 NOT_PS2MODEL50: ; @RH2
171 CMP INT15_SEC_MOD,SEC_MOD_RR;If 'AT' but not PS/2 50 or 60, @RH2
172 JE IS_PS2MODEL60 ; then family 1 (uses XMA 1 card) @RH2
173 JMP FAMILY_1_MACH ; @RH2
175 MOV NUM_OF_SLOTS,8 ;PS2/60 has 8 adapter slots @RH2
176 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
177 PS2_5060: ;³ Machine is a PS/2 Model 50 (TB) or 60 (RR). ³
178 ;³ Check for the Workstation Program's XMA/A ³
179 ;³ virtual mode device driver (INDXMAA.SYS). If ³
180 ;³ present, use only that card in virtual mode. ³
181 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
182 MOV AX,3D00h ;Attempt to open WSP's XMA/A @RH6
183 LEA DX,XMAAVIRT_DD_NAME ; virtual mode device driver @RH6
184 INT 21h ;Carry means open failed and the @RH6
185 JC PS2_5060_REAL ; DD is not present. Use XMA/A @RH6
186 ; in real mode and XMO card. @RH6
187 INDXMAA_INSTALLED: ;Else driver found. XMA/A virtual @RH6
188 MOV DD_FILE_HANDLE,AX ;Do IOCTL to find # of XMA/A blks @RH6
189 MOV BX,AX ;INDXMAA.SYS DD handle in BX @RH6
190 MOV AX,440Ch ;Handle generic IOCTL fcn code @RH6
191 XOR CH,CH ;CH = 0 means "unknown" @RH6
192 MOV CL,60h ;CL = 40h means set device info @RH6
193 PUSH CS ; = 60h means get device info @RH6
195 LEA DX,REQ_PACKET ;DS:DX -> generic IOCTL packet @RH6
196 INT 21h ;Issue the generic IOCTL @RH6
197 JNC XMAA_VER_GOOD ;No carry means the right @RH6
198 PUSH CS ; version of the XMAA DD was @RH6
199 POP DS ; installed (can handle IOCTL) @RH6
200 MOV DX,OFFSET WRONG_XMAA_MSG ;Otherwise print message @RH6
201 MOV AH,9 ; indicating incorrect version @RH6
202 INT 21H ; of the XMAA DD detected @RH6
203 MOV DX,OFFSET NOT_INSTL_MSG ;Print that the EMS driver @RH6
204 MOV AH,9 ; has not been installed @RH6
206 JMP GENERAL_FAILURE ;indicate general failure @RH6
208 MOV AX,REQ_PACKET.PACKET_WORD ;Get the last available XMA/A blk@RH6
209 INC AX ; number from the XMA/A DD...add 1 @RH6
210 XOR DX,DX ; to calc total XMA/A blocks and @RH6
211 DIV BLOCKS_PER_PAGE ; convert it to EMS pages @RH6
212 MOV TOTAL_SYS_PAGES,AX ;Set the number of total 16K pages @RH6
213 MOV TOTAL_EMS_PAGES,AX ; (before and after mem backing) @RH6
214 MOV FREE_PAGES,AX ; and the pages free for useage @RH6
215 MOV START_BACMEM_SEG,0 ;Mark from 0-640K as taken to @RH6
216 MOV END_BACMEM_SEG,0A000h ; back conventional memory and @RH6
217 CALL BACK_CONV_MEM ; adjust TOTAL_EMS_PAGES @RH6
218 MOV AX,3E00h ;Close the XMA/A virtual mode @RH6
219 MOV BX,DD_FILE_HANDLE ; device driver @RH6
221 MOV MEMCARD_MODE,XMAA_VIRT ;Set hardware flag to XMAA virtual @RH6
222 JMP INT_67_INSTALL ;Install int 67 vector,end init @RH6
224 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
225 PS2_5060_REAL: ;³ PS/2 Model 50 or 60 without XMA/A virtual DD. ³
226 ;³ Use XMA/A card in real mode (Bank ID reg ³
227 ;³ not used) or XMO card. ³
228 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
229 CALL INIT_MOD_50_60 ;Init for XMA/A and XMO @RH2
230 CMP INIT_ERR,ERROR ;If no error then install the @RH2
231 JE PS2_5060_ERROR ; int 67 vector, print msgs @RH2
232 JMP INT_67_INSTALL ; @RH2
234 ;Else error in intialization @RH2
237 MOV AH,9 ; Barf out 1st part of msg @RH2
238 INT 21H ; set by subproc (DX = ptr) @RH2
239 MOV DX,OFFSET NOT_INSTL_MSG ;Print that the EMS driver @RH2
240 MOV AH,9 ; has not been installed @RH2
242 JMP GENERAL_FAILURE ;indicate general failure @RH2
245 FAMILY_1_MACH: ;Family 1 machine (pre-PS/2)
246 mov rom_scan_type,family1 ; set flag for rom scan code - gga
247 MOV START_BACMEM_SEG,04000h ;Memory is backed from 256K to
248 MOV END_BACMEM_SEG,0A000h ; 640K on XMA 1 card
249 CALL PRESTST ;Insure XMA 1 card is present
250 JE XMA1_FOUND ;Zero flag = 1 means XMA 1 found
251 PUSH CS ;Else error..get this segment
253 MOV DX,OFFSET NOT_FOUND_MSG ;Print message for cannot
254 MOV AH,9 ; find adapter
255 INT 21H ;write message
256 MOV DX,OFFSET NOT_INSTL_MSG ;Print that the EMS driver
257 MOV AH,9 ; has not been installed
259 JMP GENERAL_FAILURE ;indicate general failure
261 MOV MEMCARD_MODE,XMA1_VIRT ;Indicate an XMA 1 card present @RH2
262 CALL TRY4MEG ;determine the size of the XMA memory card
266 MOV DX,OFFSET DGS_START_MSG ;start of diagnostics message
267 MOV AH,9 ;dos prt string
268 INT 21H ;starting diagnostics message
269 CALL CUR_POS ;save cursor position for KB OK msg
271 MOV DX,MODE_REG ;determine if this is a warm start
272 IN AL,DX ;read mode reg
273 AND AL,WARM_MASK ;isolate warm start bit
274 JZ DO_XMA1DIAG ;If off perform full XMA 1 diags
275 MOV CS:WARM_START,'Y' ;Else warm start..limited diags
277 CALL XMA1DIAGS ;Perform XMA 1 diagnostics
278 JE XMA1_OK ;Zero flag set means all OK
279 PUSH CS ;Else error..get this segment
281 MOV DX,OFFSET XMA1_ERR_MSG ;'XMA001 Adapter error'
282 MOV AH,9 ;dos prt string
283 INT 21H ;write message
284 MOV DX,OFFSET NOT_INSTL_MSG ;Print that the EMS driver
285 MOV AH,9 ; has not been installed
287 JMP GENERAL_FAILURE ;indicate general failure
289 PUSH CS ;get this segment
291 MOV DX,OFFSET DGS_END_MSG ;start of message
292 MOV AH,9 ;dos prt string
293 INT 21H ;write message
295 ;Set XMA in virtual mode to look like it was in real mode
297 ;Mark pages used on XMA card to back conventional memory
301 ;Set up interrupt 67 vector
303 ;------------------------
305 ;------------------------
306 ;-------------------------------------------------------------------
307 call romscan ; just for grins
308 jc ROM_Scan_Fail ; error - prompt user to hit any key ;an000; dms;
309 jmp Skip_Pars ; continue load of XMA2EMS ;an000; dms;
313 PUSH CS ;set up addressibility ;an000; dms;
314 POP DS ; ;an000; dms;
315 MOV DX,OFFSET Prompt_Msg ;Press any key to continue... ;an000; dms;
316 MOV AH,9 ;dos prt string ;an000; dms;
319 mov ah,07h ;keyboard input without ECHO ;an000; dms;
320 int 21h ;wait until input ;an000; dms;
321 jmp General_Failure ;
322 ;-------------------------------------------------------------------
324 ;------------------------
326 ;------------------------
328 CALL INIT_PAL ;Initialize the Page Allocation @RH8
335 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
336 ;³ Initialize the entries in the Page Allocation List ³
337 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
338 MOV CX,TOTAL_SYS_PAGES
341 ;write variables into message string
342 PUSH CS ;get this segment
344 MOV DI,OFFSET CONV_PAGES ;ascii string for numb fill pgs
345 MOV AX,END_BACMEM_SEG ;upper limit of fill
346 SUB AX,START_BACMEM_SEG ;minus lower start of fill
348 SHR AX,CL ;convert to number 16k blocks
351 MOV DI,OFFSET RES_PAGES ;ascii string for pinta reserved pages
352 MOV AX,STARTING_BLOCK ;number of 4k pages res for pinta
354 SHR AX,1 ;convert to 16k pages
357 MOV DI,OFFSET EMS_PAGES ;ascii string available ems pages
358 MOV AX,FREE_PAGES ;free pages
361 MOV DI,OFFSET PF_START ;ascii string page frame
362 MOV AX,PAGE_FRAME_STA ;page frame
365 ;gga MOV DX,OFFSET PAGE_FRAME_MSG ;start of message
366 ;gga MOV AH,9 ;dos prt string
367 ;gga INT 21H ;status msg1
372 MOV DX,OFFSET RESERVE_MSG ;start of message
373 MOV AH,9 ;dos prt string
378 ;gga MOV DX,OFFSET AVAIL_MSG ;start of message
379 ;gga MOV AH,9 ;dos prt string
380 ;gga INT 21H ;status msg3
382 ;indicate that the card has been tested
384 IN AL,DX ;read mode reg
385 OR AL,WARM_MASK ;turn on warm start bit
386 OUT DX,AL ;write it back
388 call Calc_INT15_Space ;calculate remaining INT 15h space ;an000; dms;
389 call Steal_INT15 ;hook INT 15h ;an000; dms;
390 call Steal_Int13 ;hook INT 13h ;an004; dms;
397 LDS BX,CS:RH_PTRA ;ELSE ...
398 MOV AX,STAT_GENFAIL ;INDICATE A GENERAL FAILURE
399 MOV RH.RHC_STA,AX ;WRITE IT TO RH STATUS
400 ;------------------------
402 ;------------------------
403 xor ax,ax ; zero segment and offset
404 mov rh.rh0_endo,ax ; offset of ending addr
407 mov rh.rh0_ends,ax ; segment of ending addr
409 mov rh.rh0_err,0ffh ; error flag for DOS
411 mov rh.rh0_nun,al ; = 0 causes installation failure
414 ;------------------------
416 ;move cursor to next line so other messages are clear
419 MOV DX,OFFSET NEXT_LINE + 1 ;get offset of string
420 MOV AH,9 ;dos print string
423 LDS BX,CS:RH_PTRA ;ADDRESSABILITY INTO RH
424 MOV AX,OFFSET RESIDENT + STACK_SIZE + 100H
425 MOV RH.RH0_ENDO,AX ;OFFSET OF ENDING ADDR
428 MOV RH.RH0_ENDS,AX ;OFFSET OF ENDING ADDR
432 POP CX ;recover old ss
433 POP DX ;recover old sp
434 CLI ;ints off during swap
435 MOV SP,CX ;restore old sp
436 MOV SS,DX ;restore old ss
443 ;-----------------------------------------------------------------------;
444 ; STEAL_INT67 changes the INT 67H vector to point to this ;
445 ; Memory Manager to field subsequent calls. ;
446 ;-----------------------------------------------------------------------;
450 MOV DS,AX ;set DS = 0
452 CLI ;disable interrupts
453 LES DI,DS:EMS_VEC ;get addressing into vector
454 MOV DS:EMS_VECO,OFFSET EMS_INT67 ;offset of new INT routine
455 MOV DS:EMS_VECS,CS ;segment of new INT routine
456 STI ;enable interrupts again
461 ;-----------------------------------------------------------------------;
462 ; VIRT2REAL puts the XMA into 'virtual' mode with the translate ;
463 ; table written such that memory is mapped just as it was ;
464 ; in 'real' mode. (Either 256-640k or 512-640k reamains fixed ;
467 ; all registers are preserved ;
469 ;-----------------------------------------------------------------------;
475 PUSH DS ;save these registers
477 PUSH CS ;get this segment
479 ;inhibit all of XMA memory before going into virtual mode
480 XOR AX,AX ;start at segment 0
482 MOV CX,1024/4 ;all 4k blocks in pc space
484 ;now map virtual mode to look like real mode
485 MOV AX,START_BACMEM_SEG ;starting 'fill' segment
486 MOV DX,AX ;get it into dx
487 XCHG DH,DL ;and shr 8 to convert it to 4k block #
488 XOR BH,BH ;start at task ID=0
490 MOV CX,16 ;do for all 16 task ID's
494 PUSH CX ;because they are
495 PUSH DX ;destroyed by call
496 MOV CX,160 ;640K = 160*4K blocks
497 SUB CX,DX ;minus starting 4K block
498 ;is # 4K blocks to map for this ID
499 CALL SETXLAT ;write trans table accordingly
500 POP DX ;recover these registers
508 IN AL,DX ;read mode reg
509 OR AL,VIRT_MODE ;turn on virtual bit
510 OUT DX,AL ;write it back
512 POP DS ;restore these registers
521 include romscan.inc ; code to do romscan for hole location/verification
522 INCLUDE PARMPARS.INC ;Routines to parse the parameters
523 ; on the CONFIG.SYS line
525 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
526 ;³ Subprocedure: BACK_CONV_MEM ³
528 ;³ Purpose: Called when a portion of the XMA card is used to back ³
529 ;³ conventional memory. This is the case on an XMA 1 ³
530 ;³ card (256K - 640K disabled on planar) and on the ³
531 ;³ XMA/A card when WSP's XMA/A initialization device ³
532 ;³ driver has disabled the planar. ³
533 ;³ This procedure will mark the Page Allocation List for ³
534 ;³ these entries with an ASCII value (for debugging) that ³
535 ;³ is above the range of eligible pointer values. ³
536 ;³ At the time this proc is called the PAL has not been ³
537 ;³ initialized. Initialization will skip these entries. ³
539 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
541 MOV AX,END_BACMEM_SEG ;upper segment of backed memory
542 SUB AX,START_BACMEM_SEG ;subtract seg of backed memory start
543 MOV CL,10 ;conver # of segments to # of 16 K
544 SHR AX,CL ; pages used for fill (div by 1024)
545 SUB TOTAL_EMS_PAGES,AX ;subtract from total EMS pages
546 ; (but not from TOTAL_SYStem_PAGES)
547 SUB FREE_PAGES,AX ;subtract from free EMS pages
548 MOV CX,AX ;Put # of backing pages into CX
549 PUSH CX ; and save it on stack
551 MOV AX,START_BACMEM_SEG ;Convert the segment value for the
552 MOV CL,10 ; start of backed memory to its
553 SHR AX,CL ; corresponding page number
554 MOV DX,TYPE PAGE_ALLOC_LIST ; then convert to the correct @RH8
555 MUL DX ; entry in the page alloc list @RH8
556 MOV SI,AX ; store PAL offset into SI
557 POP CX ;recover loop counter for # backed
558 ;mark these pages used in page list but do not assign a handle
560 MOV PAGE_LIST_ENTRY,BACMEM_ALLOC ;Mark the PAL with ascii @RH8
561 ADD SI,TYPE PAGE_ALLOC_LIST ;Next entry in PAL @RH8
563 ;Remove code here that used to reserve pages for
564 ; WSP by reading a value on the CONFIG.SYS line.
565 ; Instead, WSP will make an IOCTL call for the
566 ; number of pages it needs.
569 ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
570 ;³ Subprocedure: INIT_PAL ³
572 ;³ Purpose: This subprocedure will link the Page Allocation List. ³
573 ;³ The head pointer to the list of available pages ³
574 ;³ (PAL_FREE_PTR) is initialized to the top EMS page, ³
575 ;³ and all available pages are linked from top to bottom. ³
576 ;³ All free pages will initially be contiguous, except on ³
577 ;³ an XMA 1 system. With XMA 1, 256-640K on the card is ³
578 ;³ used to back conventional memory. The free list will ³
579 ;³ skip around these pages (pages 16 to 40). ³
581 ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
583 push cs ;set up addressibility ;an000; dms;
584 pop ds ; ;an000; dms;
586 cmp Total_EMS_Pages,0 ;any pages? ;an000; dms;
587 je Init_Pal_End ;no - exit ;an000; dms;
589 mov ax,Total_Sys_Pages ;top of EMS pages = ;an000; dms;
590 add ax,Resr_Ext_Pgs ; total EMS pages + ;an000; dms;
591 dec ax ; rsv ext. pages - 1 ;an000; dms;
594 mov si,ax ;ptr to free page ;an000; dms;
595 shl si,1 ;make an index ;an000; dms;
596 mov Page_List_Entry,Pal_Null ;set last entry to null ;ac007; dms;
597 shr si,1 ;convert to ptr value ;an007; dms;
598 mov di,si ;place in di ;an007; dms;
600 dec ax ;next page ;an000; dms;
601 mov cx,Total_EMS_Pages ;loop for all entries ;an000; dms;
602 dec cx ; but the last ;an000; dms;
606 cmp cx,0 ;at end? ;an000; dms;
607 je Init_Pal_Loop_Exit ;yes - exit ;an000; dms;
609 mov si,ax ;ptr to next page ;ac007; dms;
610 shl si,1 ;make an index ;ac007; dms;
611 cmp Page_Alloc_List[si],BacMem_Alloc ;backfilled memory? ;ac007; dms;
612 jne Init_Pal_Entry ;no - set up ptr's ;an000; dms;
613 dec ax ;yes - next ptr value ;an000; dms;
614 jmp Init_Pal_LP ;keep on looping ;an000; dms;
616 mov Page_List_Entry,di ;set up ptr value ;ac007; dms;
617 mov di,si ;next ptr value ;ac007; dms;
618 shr di,1 ;make a ptr value ;an007; dms;
620 dec ax ;get next ptr value ;an000; dms;
621 dec cx ;dec loop counter ;an000; dms;
622 jmp INIT_PAL_LP ;continue looping ;an000; dms;
625 mov Pal_Free_Ptr,di ;init free ptr ;an007; dms;
628 ret ;return to caller ;an000; dms;
631 ;-----------------------------------------------------------------------;
632 ; This routine will convert a number in (AX) to a ;
633 ; 4 byte ascii string equivalent to a 4 digit decimal ;
634 ; number and write it at the address pointed to ;
635 ; by ES:DI. Leading zeroes are suppressed. ;
637 ; On entry: (AX) = number to be converted ;
638 ; ES:DI= address where string is to be written ;
640 ; On exit: all registers are preserved ;
642 ;-----------------------------------------------------------------------;
649 PUSH DI ;save these registers
651 MOV CX,4 ;loop counter 4 digits
654 XOR DX,DX ;clear hi word of dividend
655 ;ax is low word of dividend
656 DIV CS:TEN ;divide by 10
657 OR DL,30H ;make modulo into ascii digit
658 PUSH DX ;put it on stack
659 ; $ENDDO LOOP ;repeat for all 4 digits
662 MOV CX,4 ;recover 4 digits from stack
665 POP AX ;recover next most sign digit
666 CMP AL,'0' ;is it a '0'
669 PUSH AX ;back on stack for next loop
670 JMP LEAD_DIGIT ;if not then we found leading non zero
673 ; $ENDDO LOOP ;else continiue til non zero found
676 ; $IF NCXZ ;only if cx is non zero
680 POP AX ;recover next digit
681 MOV ES:BYTE PTR [DI],AL ;write it to string
682 INC DI ;point to next byte
683 ; $ENDDO LOOP ;repeat for all digits
688 POP DI ;recover these registers
693 RET ;return to caller
698 ;-----------------------------------------------------------------------;
699 ; This routine will convert a number in (AX) to a ;
700 ; 4 byte ascii string equivalent to a 4 digit hexadecimal ;
701 ; number and write it at the address pointed to ;
702 ; by ES:DI. Leading zeroes are suppressed. ;
704 ; On entry: (AX) = number to be converted ;
705 ; ES:DI= address where string is to be written ;
707 ; On exit: all registers are preserved ;
709 ;-----------------------------------------------------------------------;
711 DEC2ASCII DB '0123456789ABCDEF'
720 PUSH DI ;save these registers
726 MOV BX,OFFSET DEC2ASCII
727 MOV CX,4 ;loop counter 4 digits
730 XOR DX,DX ;clear hi word of dividend
731 ;ax is low word of dividend
732 DIV SIXTEEN ;divide by 10
734 PUSH AX ;save quotient
735 MOV AX,DX ;get modulo into ax
736 XLAT DEC2ASCII ;convert al to ascii
737 MOV DX,AX ;get it into dx
738 POP AX ;recover quotient
739 PUSH DX ;put ascii modulo on stack
740 ; $ENDDO LOOP ;repeat for all 4 digits
743 MOV CX,4 ;recover 4 digits from stack
746 ;gga POP AX ;recover next most sign digit
747 ;gga CMP AL,'0' ;is it a '0'
750 ;gga PUSH AX ;back on stack for next loop
751 ;gga JMP CNVH1 ;if not then we found leading non zero
754 ; $ENDDO LOOP ;else continiue til non zero found
757 ; $IF NCXZ ;only if cx is non zero
761 POP AX ;recover next digit
762 MOV ES:BYTE PTR [DI],AL ;write it to string
763 INC DI ;point to next byte
764 ; $ENDDO LOOP ;repeat for all digits
770 POP DI ;recover these registers
776 RET ;return to caller
779 ;-----------------------------------------------------------------------;
780 ; STEAL_INT15 changes the INT 15H vector to point to this EMS' ;
781 ; so that subsequent calls to INT15H may determine the actual ;
782 ; size of EM after EMS' allocation of it ;
783 ;-----------------------------------------------------------------------;
788 CMP MODEL_BYTE,PS2MODEL80 ;If a PS2/80 treat as XMA memory ;an000; dms;
789 je Steal_INT15_Exit ;do not hook INT15h ;an000; dms;
791 CMP MODEL_BYTE,PC_AT ;If the model byte is for an 'AT' @RH2
792 jne Steal_INT15_Hook ; type (80286 processor), check @RH2
794 MOV AH,0C0h ; the XMA/A or XMO card @RH2
796 CMP INT15_SEC_MOD,SEC_MOD_TB; @RH2
797 JE Steal_INT15_Hook ; @RH2
799 CMP INT15_SEC_MOD,SEC_MOD_RR;If 'AT' but not PS/2 50 or 60, @RH2
800 JE Steal_INT15_Hook ; then family 1 (uses XMA 1 card) @RH2
801 JMP Steal_INT15_Exit ; @RH2
806 MOV DS,AX ;set DS = 0
808 CLI ;disable interrupts
809 LES DI,DS:EM_VEC ;get original vector's content
810 MOV CS:INTV15O,DI ;save original vector
812 MOV DS:EM_VECO,OFFSET XMA_INT15 ;offset of new INT routine
813 MOV DS:EM_VECS,CS ;segment of new INT routine
814 STI ;enable interrupts again
824 ;-----------------------------------------------------------------------;
825 ; Calc_INT15_Space calculates the remaining extended memory for ;
826 ; the system. This value will be used by all subsequent calls ;
827 ; to function 88h, INT 15h. ;
828 ;-----------------------------------------------------------------------;
829 Calc_INT15_Space proc near ;an000; dms;
831 push ax ;save regs ;an000; dms;
832 push bx ; ;an000; dms;
833 push cx ; ;an002; dms;
834 push dx ; ;an000; dms;
836 mov ah,EM_Size_Get ;get extended mem ;an000; dms;
837 int 15h ; ;an000; dms;
839 mov cl,4 ;divide by 16 ;an002; dms;
840 shr ax,cl ; to get page count ;an002; dms;
842 sub ax,cs:Total_Sys_Pages ;new extended mem size ;an002; dms;
843 xor dx,dx ;get K count ;an002; dms;
844 mov bx,cs:Sixteen ; ;an002; dms;
845 mul bx ; ;an002; dms;
846 mov word ptr cs:EM_Ksize,ax ;save new size ;an000; dms;
848 pop dx ;restore regs ;an000; dms;
849 pop cx ; ;an002; dms;
850 pop bx ; ;an000; dms;
851 pop ax ; ;an000; dms;
855 Calc_INT15_Space endp ;an000; dms;
858 ;-----------------------------------------------------------------------;
859 ; STEAL_INT13 changes the INT 13H vector to point to this EMS' ;
860 ; so that subsequent calls to INT13H may properly handle DMA ;
862 ;-----------------------------------------------------------------------;
863 Steal_Int13 PROC ;an004; dms;
867 CMP MODEL_BYTE,PS2MODEL80 ;If not a PS2/80 don't hook INT 13h ;an004; dms;
868 jne Steal_INT15_Exit ; ;an004; dms;
871 MOV DS,AX ;set DS = 0
873 CLI ;disable interrupts
874 LES DI,DS:DK_VEC ;get original vector's content
875 MOV CS:INTV13O,DI ;save original vector
877 MOV DS:DK_VECO,OFFSET I13_Handler ;offset of new INT routine
878 MOV DS:DK_VECS,CS ;segment of new INT routine
879 STI ;enable interrupts again