diff options
| author | 2024-04-25 21:24:10 +0100 | |
|---|---|---|
| committer | 2024-04-25 22:32:27 +0000 | |
| commit | 2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch) | |
| tree | 80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/DEV/XMA2EMS/EMSINIT.INC | |
| parent | Merge pull request #430 from jpbaltazar/typoptbr (diff) | |
| download | ms-dos-main.tar.gz ms-dos-main.tar.xz ms-dos-main.zip | |
Diffstat (limited to 'v4.0/src/DEV/XMA2EMS/EMSINIT.INC')
| -rw-r--r-- | v4.0/src/DEV/XMA2EMS/EMSINIT.INC | 886 |
1 files changed, 886 insertions, 0 deletions
diff --git a/v4.0/src/DEV/XMA2EMS/EMSINIT.INC b/v4.0/src/DEV/XMA2EMS/EMSINIT.INC new file mode 100644 index 0000000..4c2213e --- /dev/null +++ b/v4.0/src/DEV/XMA2EMS/EMSINIT.INC | |||
| @@ -0,0 +1,886 @@ | |||
| 1 | |||
| 2 | ;------------------------------------------------------------------------; | ||
| 3 | ; Initialization... ; | ||
| 4 | ;------------------------------------------------------------------------; | ||
| 5 | |||
| 6 | RESR_EXT_PGS DW 0 ;Ext mem reserved here after EMS taken ;an002; dms; | ||
| 7 | |||
| 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 | ||
| 14 | ; 50 and 60, etc. | ||
| 15 | PS2MODEL80 EQU 0F8h ; 386 processor - PS/2 model 80 @RH1 | ||
| 16 | |||
| 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 | ||
| 20 | |||
| 21 | START_BACMEM_SEG DW 0 ;Starting and ending segment addrs | ||
| 22 | END_BACMEM_SEG DW 0 ; of memory backed by the XMA card | ||
| 23 | |||
| 24 | INIT_ERR DW ? ;Initialization error flag @RH4 | ||
| 25 | NO_ERROR EQU 0 ; @RH4 | ||
| 26 | ERROR EQU 1 ; @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 | ||
| 33 | |||
| 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 | ||
| 38 | REQ_PACKET_STRUC ENDS | ||
| 39 | |||
| 40 | REQ_PACKET REQ_PACKET_STRUC <> ; | ||
| 41 | |||
| 42 | |||
| 43 | INIT PROC | ||
| 44 | |||
| 45 | PUSH CS | ||
| 46 | POP DS ;Get this segment into CS | ||
| 47 | |||
| 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 | ||
| 52 | MOV SS,AX ;through ax | ||
| 53 | MOV SP,OFFSET TOP_OF_STACK ;sp to end of code | ||
| 54 | STI ;ints back on | ||
| 55 | PUSH DX ;save old ss on new stack | ||
| 56 | PUSH CX ;save old sp on new stack | ||
| 57 | |||
| 58 | |||
| 59 | MOV DX,OFFSET WELCOME_MSG ;Print title and copy-right | ||
| 60 | MOV AH,9 ; | ||
| 61 | INT 21H | ||
| 62 | |||
| 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; | ||
| 70 | |||
| 71 | CALL GET_PARMS ;Get the user parameters | ||
| 72 | |||
| 73 | pop ds ;restore affected regs ;an000; dms; | ||
| 74 | pop di ; ;an000; dms; | ||
| 75 | pop si ; ;an000; dms; | ||
| 76 | pop dx ; ;an000; dms; | ||
| 77 | pop cx ; ;an000; dms; | ||
| 78 | pop bx ; ;an000; dms; | ||
| 79 | pop ax ; ;an000; dms; | ||
| 80 | |||
| 81 | JE PARMS_OK | ||
| 82 | PUSH CS | ||
| 83 | POP DS | ||
| 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 | ||
| 89 | INT 21H ; | ||
| 90 | JMP GENERAL_FAILURE ;indicate general failure | ||
| 91 | PARMS_OK: | ||
| 92 | |||
| 93 | ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | ||
| 94 | ;³ Does the system use the XMA Emulator? ³ | ||
| 95 | ;³ (PS/2 model 80 with 80386 processor) ³ | ||
| 96 | ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | ||
| 97 | PUSH DS ; @RH1 | ||
| 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 | ||
| 101 | POP DS ; @RH1 | ||
| 102 | |||
| 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 | ||
| 118 | INT 21H ; @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 | ||
| 127 | POP DS ; @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 | ||
| 138 | INT 21H ; @RH7 | ||
| 139 | JMP GENERAL_FAILURE ;indicate general failure @RH7 | ||
| 140 | EMUL_VER_GOOD: | ||
| 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 | ||
| 154 | INT 21h ; @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 | ||
| 165 | INT 15h ; @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 | ||
| 174 | IS_PS2MODEL60: | ||
| 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 | ||
| 194 | POP DS ; @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 | ||
| 205 | INT 21H ; @RH6 | ||
| 206 | JMP GENERAL_FAILURE ;indicate general failure @RH6 | ||
| 207 | XMAA_VER_GOOD: | ||
| 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 | ||
| 220 | INT 21h ; @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 | ||
| 223 | |||
| 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 | ||
| 233 | PS2_5060_ERROR: | ||
| 234 | ;Else error in intialization @RH2 | ||
| 235 | PUSH CS ; | ||
| 236 | POP DS ; | ||
| 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 | ||
| 241 | INT 21H ; @RH2 | ||
| 242 | JMP GENERAL_FAILURE ;indicate general failure @RH2 | ||
| 243 | |||
| 244 | |||
| 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 | ||
| 252 | POP DS ;into ds | ||
| 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 | ||
| 258 | INT 21H ; | ||
| 259 | JMP GENERAL_FAILURE ;indicate general failure | ||
| 260 | XMA1_FOUND: | ||
| 261 | MOV MEMCARD_MODE,XMA1_VIRT ;Indicate an XMA 1 card present @RH2 | ||
| 262 | CALL TRY4MEG ;determine the size of the XMA memory card | ||
| 263 | |||
| 264 | PUSH CS | ||
| 265 | POP DS | ||
| 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 | ||
| 270 | |||
| 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 | ||
| 276 | DO_XMA1DIAG: | ||
| 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 | ||
| 280 | POP DS ;into ds | ||
| 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 | ||
| 286 | INT 21H ; | ||
| 287 | JMP GENERAL_FAILURE ;indicate general failure | ||
| 288 | XMA1_OK: | ||
| 289 | PUSH CS ;get this segment | ||
| 290 | POP DS ;into ds | ||
| 291 | MOV DX,OFFSET DGS_END_MSG ;start of message | ||
| 292 | MOV AH,9 ;dos prt string | ||
| 293 | INT 21H ;write message | ||
| 294 | |||
| 295 | ;Set XMA in virtual mode to look like it was in real mode | ||
| 296 | CALL VIRT2REAL | ||
| 297 | ;Mark pages used on XMA card to back conventional memory | ||
| 298 | CALL BACK_CONV_MEM | ||
| 299 | |||
| 300 | |||
| 301 | ;Set up interrupt 67 vector | ||
| 302 | INT_67_INSTALL: | ||
| 303 | ;------------------------ | ||
| 304 | ; added by GGA | ||
| 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; | ||
| 310 | |||
| 311 | ROM_Scan_Fail: | ||
| 312 | |||
| 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; | ||
| 317 | INT 21H ; | ||
| 318 | |||
| 319 | mov ah,07h ;keyboard input without ECHO ;an000; dms; | ||
| 320 | int 21h ;wait until input ;an000; dms; | ||
| 321 | jmp General_Failure ; | ||
| 322 | ;------------------------------------------------------------------- | ||
| 323 | skip_pars: | ||
| 324 | ;------------------------ | ||
| 325 | ; end of adds by GGA | ||
| 326 | ;------------------------ | ||
| 327 | |||
| 328 | CALL INIT_PAL ;Initialize the Page Allocation @RH8 | ||
| 329 | ; linked List RH8 | ||
| 330 | CALL STEAL_INT67 ; | ||
| 331 | |||
| 332 | |||
| 333 | |||
| 334 | |||
| 335 | ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | ||
| 336 | ;³ Initialize the entries in the Page Allocation List ³ | ||
| 337 | ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | ||
| 338 | MOV CX,TOTAL_SYS_PAGES | ||
| 339 | |||
| 340 | |||
| 341 | ;write variables into message string | ||
| 342 | PUSH CS ;get this segment | ||
| 343 | POP ES ;into es | ||
| 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 | ||
| 347 | MOV CL,10 | ||
| 348 | SHR AX,CL ;convert to number 16k blocks | ||
| 349 | CALL CNVDECAT | ||
| 350 | |||
| 351 | MOV DI,OFFSET RES_PAGES ;ascii string for pinta reserved pages | ||
| 352 | MOV AX,STARTING_BLOCK ;number of 4k pages res for pinta | ||
| 353 | SHR AX,1 | ||
| 354 | SHR AX,1 ;convert to 16k pages | ||
| 355 | CALL CNVDECAT | ||
| 356 | |||
| 357 | MOV DI,OFFSET EMS_PAGES ;ascii string available ems pages | ||
| 358 | MOV AX,FREE_PAGES ;free pages | ||
| 359 | CALL CNVDECAT | ||
| 360 | |||
| 361 | MOV DI,OFFSET PF_START ;ascii string page frame | ||
| 362 | MOV AX,PAGE_FRAME_STA ;page frame | ||
| 363 | CALL CNVHEXAT | ||
| 364 | |||
| 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 | ||
| 368 | |||
| 369 | CMP STARTING_BLOCK,0 | ||
| 370 | ; $IF A | ||
| 371 | JNA $$IF117 | ||
| 372 | MOV DX,OFFSET RESERVE_MSG ;start of message | ||
| 373 | MOV AH,9 ;dos prt string | ||
| 374 | INT 21H ;status msg2 | ||
| 375 | ; $ENDIF | ||
| 376 | $$IF117: | ||
| 377 | |||
| 378 | ;gga MOV DX,OFFSET AVAIL_MSG ;start of message | ||
| 379 | ;gga MOV AH,9 ;dos prt string | ||
| 380 | ;gga INT 21H ;status msg3 | ||
| 381 | |||
| 382 | ;indicate that the card has been tested | ||
| 383 | MOV DX,MODE_REG | ||
| 384 | IN AL,DX ;read mode reg | ||
| 385 | OR AL,WARM_MASK ;turn on warm start bit | ||
| 386 | OUT DX,AL ;write it back | ||
| 387 | |||
| 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; | ||
| 391 | |||
| 392 | JMP COMMON_EXIT_PATH | ||
| 393 | |||
| 394 | |||
| 395 | GENERAL_FAILURE: | ||
| 396 | |||
| 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 | ;------------------------ | ||
| 401 | ; adds by GGA | ||
| 402 | ;------------------------ | ||
| 403 | xor ax,ax ; zero segment and offset | ||
| 404 | mov rh.rh0_endo,ax ; offset of ending addr | ||
| 405 | push cs | ||
| 406 | pop ax | ||
| 407 | mov rh.rh0_ends,ax ; segment of ending addr | ||
| 408 | |||
| 409 | mov rh.rh0_err,0ffh ; error flag for DOS | ||
| 410 | |||
| 411 | mov rh.rh0_nun,al ; = 0 causes installation failure | ||
| 412 | |||
| 413 | jmp skip_size | ||
| 414 | ;------------------------ | ||
| 415 | COMMON_EXIT_PATH: | ||
| 416 | ;move cursor to next line so other messages are clear | ||
| 417 | PUSH CS ;get cs | ||
| 418 | POP DS ;into ds | ||
| 419 | MOV DX,OFFSET NEXT_LINE + 1 ;get offset of string | ||
| 420 | MOV AH,9 ;dos print string | ||
| 421 | INT 21H | ||
| 422 | |||
| 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 | ||
| 426 | PUSH CS | ||
| 427 | POP AX | ||
| 428 | MOV RH.RH0_ENDS,AX ;OFFSET OF ENDING ADDR | ||
| 429 | |||
| 430 | skip_size: ; gga | ||
| 431 | |||
| 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 | ||
| 437 | STI ;ints back on | ||
| 438 | |||
| 439 | |||
| 440 | RET | ||
| 441 | INIT ENDP | ||
| 442 | |||
| 443 | ;-----------------------------------------------------------------------; | ||
| 444 | ; STEAL_INT67 changes the INT 67H vector to point to this ; | ||
| 445 | ; Memory Manager to field subsequent calls. ; | ||
| 446 | ;-----------------------------------------------------------------------; | ||
| 447 | STEAL_INT67 PROC | ||
| 448 | PUSH DS | ||
| 449 | XOR AX,AX | ||
| 450 | MOV DS,AX ;set DS = 0 | ||
| 451 | ASSUME DS:INT_VEC | ||
| 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 | ||
| 457 | POP DS ;restore DS | ||
| 458 | RET | ||
| 459 | STEAL_INT67 ENDP | ||
| 460 | |||
| 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 ; | ||
| 465 | ; for all ID's) ; | ||
| 466 | ; ; | ||
| 467 | ; all registers are preserved ; | ||
| 468 | ; ; | ||
| 469 | ;-----------------------------------------------------------------------; | ||
| 470 | VIRT2REAL PROC | ||
| 471 | PUSH AX | ||
| 472 | PUSH BX | ||
| 473 | PUSH CX | ||
| 474 | PUSH DX | ||
| 475 | PUSH DS ;save these registers | ||
| 476 | |||
| 477 | PUSH CS ;get this segment | ||
| 478 | POP DS ;into ds | ||
| 479 | ;inhibit all of XMA memory before going into virtual mode | ||
| 480 | XOR AX,AX ;start at segment 0 | ||
| 481 | XOR BL,BL ;inhibit | ||
| 482 | MOV CX,1024/4 ;all 4k blocks in pc space | ||
| 483 | CALL INHIBLK | ||
| 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 | ||
| 489 | MOV BL,1 ;enable | ||
| 490 | MOV CX,16 ;do for all 16 task ID's | ||
| 491 | ; $DO | ||
| 492 | $$DO119: | ||
| 493 | PUSH AX ;save these | ||
| 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 | ||
| 501 | POP CX | ||
| 502 | POP AX | ||
| 503 | INC BH ;next ID | ||
| 504 | ; $ENDDO LOOP | ||
| 505 | LOOP $$DO119 | ||
| 506 | |||
| 507 | MOV DX,MODE_REG | ||
| 508 | IN AL,DX ;read mode reg | ||
| 509 | OR AL,VIRT_MODE ;turn on virtual bit | ||
| 510 | OUT DX,AL ;write it back | ||
| 511 | |||
| 512 | POP DS ;restore these registers | ||
| 513 | POP DX | ||
| 514 | POP CX | ||
| 515 | POP BX | ||
| 516 | POP AX | ||
| 517 | RET | ||
| 518 | VIRT2REAL ENDP | ||
| 519 | |||
| 520 | |||
| 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 | ||
| 524 | |||
| 525 | ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | ||
| 526 | ;³ Subprocedure: BACK_CONV_MEM ³ | ||
| 527 | ;³ ³ | ||
| 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. ³ | ||
| 538 | ;³ ³ | ||
| 539 | ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | ||
| 540 | BACK_CONV_MEM PROC | ||
| 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 | ||
| 550 | |||
| 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 | ||
| 559 | BACK_MEM_PAL: | ||
| 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 | ||
| 562 | LOOP BACK_MEM_PAL | ||
| 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. | ||
| 567 | BACK_CONV_MEM ENDP | ||
| 568 | |||
| 569 | ;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | ||
| 570 | ;³ Subprocedure: INIT_PAL ³ | ||
| 571 | ;³ ³ | ||
| 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). ³ | ||
| 580 | ;³ ³ | ||
| 581 | ;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | ||
| 582 | INIT_PAL PROC | ||
| 583 | push cs ;set up addressibility ;an000; dms; | ||
| 584 | pop ds ; ;an000; dms; | ||
| 585 | |||
| 586 | cmp Total_EMS_Pages,0 ;any pages? ;an000; dms; | ||
| 587 | je Init_Pal_End ;no - exit ;an000; dms; | ||
| 588 | |||
| 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; | ||
| 592 | |||
| 593 | |||
| 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; | ||
| 599 | |||
| 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; | ||
| 603 | |||
| 604 | INIT_PAL_LP: | ||
| 605 | |||
| 606 | cmp cx,0 ;at end? ;an000; dms; | ||
| 607 | je Init_Pal_Loop_Exit ;yes - exit ;an000; dms; | ||
| 608 | |||
| 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; | ||
| 615 | INIT_PAL_ENTRY: | ||
| 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; | ||
| 619 | INIT_PAL_BOT: | ||
| 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; | ||
| 623 | |||
| 624 | Init_Pal_Loop_Exit: | ||
| 625 | mov Pal_Free_Ptr,di ;init free ptr ;an007; dms; | ||
| 626 | |||
| 627 | INIT_PAL_END: | ||
| 628 | ret ;return to caller ;an000; dms; | ||
| 629 | INIT_PAL ENDP | ||
| 630 | |||
| 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. ; | ||
| 636 | ; ; | ||
| 637 | ; On entry: (AX) = number to be converted ; | ||
| 638 | ; ES:DI= address where string is to be written ; | ||
| 639 | ; ; | ||
| 640 | ; On exit: all registers are preserved ; | ||
| 641 | ; ; | ||
| 642 | ;-----------------------------------------------------------------------; | ||
| 643 | |||
| 644 | CNVDECAT PROC | ||
| 645 | |||
| 646 | PUSH AX | ||
| 647 | PUSH CX | ||
| 648 | PUSH DX | ||
| 649 | PUSH DI ;save these registers | ||
| 650 | |||
| 651 | MOV CX,4 ;loop counter 4 digits | ||
| 652 | ; $DO | ||
| 653 | $$DO152: | ||
| 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 | ||
| 660 | LOOP $$DO152 | ||
| 661 | |||
| 662 | MOV CX,4 ;recover 4 digits from stack | ||
| 663 | ; $DO | ||
| 664 | $$DO154: | ||
| 665 | POP AX ;recover next most sign digit | ||
| 666 | CMP AL,'0' ;is it a '0' | ||
| 667 | ; $IF NE | ||
| 668 | JE $$IF155 | ||
| 669 | PUSH AX ;back on stack for next loop | ||
| 670 | JMP LEAD_DIGIT ;if not then we found leading non zero | ||
| 671 | ; $ENDIF | ||
| 672 | $$IF155: | ||
| 673 | ; $ENDDO LOOP ;else continiue til non zero found | ||
| 674 | LOOP $$DO154 | ||
| 675 | LEAD_DIGIT: | ||
| 676 | ; $IF NCXZ ;only if cx is non zero | ||
| 677 | JCXZ $$IF158 | ||
| 678 | ; $DO | ||
| 679 | $$DO159: | ||
| 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 | ||
| 684 | LOOP $$DO159 | ||
| 685 | ; $ENDIF | ||
| 686 | $$IF158: | ||
| 687 | |||
| 688 | POP DI ;recover these registers | ||
| 689 | POP DX | ||
| 690 | POP CX | ||
| 691 | POP AX | ||
| 692 | |||
| 693 | RET ;return to caller | ||
| 694 | CNVDECAT ENDP | ||
| 695 | |||
| 696 | |||
| 697 | |||
| 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. ; | ||
| 703 | ; ; | ||
| 704 | ; On entry: (AX) = number to be converted ; | ||
| 705 | ; ES:DI= address where string is to be written ; | ||
| 706 | ; ; | ||
| 707 | ; On exit: all registers are preserved ; | ||
| 708 | ; ; | ||
| 709 | ;-----------------------------------------------------------------------; | ||
| 710 | |||
| 711 | DEC2ASCII DB '0123456789ABCDEF' | ||
| 712 | |||
| 713 | |||
| 714 | CNVHEXAT PROC | ||
| 715 | |||
| 716 | PUSH AX | ||
| 717 | PUSH BX | ||
| 718 | PUSH CX | ||
| 719 | PUSH DX | ||
| 720 | PUSH DI ;save these registers | ||
| 721 | PUSH DS | ||
| 722 | |||
| 723 | PUSH CS | ||
| 724 | POP DS | ||
| 725 | |||
| 726 | MOV BX,OFFSET DEC2ASCII | ||
| 727 | MOV CX,4 ;loop counter 4 digits | ||
| 728 | ; $DO | ||
| 729 | $$DO162: | ||
| 730 | XOR DX,DX ;clear hi word of dividend | ||
| 731 | ;ax is low word of dividend | ||
| 732 | DIV SIXTEEN ;divide by 10 | ||
| 733 | |||
| 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 | ||
| 741 | LOOP $$DO162 | ||
| 742 | |||
| 743 | MOV CX,4 ;recover 4 digits from stack | ||
| 744 | ; $DO | ||
| 745 | $$DO164: | ||
| 746 | ;gga POP AX ;recover next most sign digit | ||
| 747 | ;gga CMP AL,'0' ;is it a '0' | ||
| 748 | ; $IF NE | ||
| 749 | ;gga JE $$IF165 | ||
| 750 | ;gga PUSH AX ;back on stack for next loop | ||
| 751 | ;gga JMP CNVH1 ;if not then we found leading non zero | ||
| 752 | ; $ENDIF | ||
| 753 | $$IF165: | ||
| 754 | ; $ENDDO LOOP ;else continiue til non zero found | ||
| 755 | ;gga LOOP $$DO164 | ||
| 756 | CNVH1: | ||
| 757 | ; $IF NCXZ ;only if cx is non zero | ||
| 758 | JCXZ $$IF168 | ||
| 759 | ; $DO | ||
| 760 | $$DO169: | ||
| 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 | ||
| 765 | LOOP $$DO169 | ||
| 766 | ; $ENDIF | ||
| 767 | $$IF168: | ||
| 768 | |||
| 769 | POP DS | ||
| 770 | POP DI ;recover these registers | ||
| 771 | POP DX | ||
| 772 | POP CX | ||
| 773 | POP BX | ||
| 774 | POP AX | ||
| 775 | |||
| 776 | RET ;return to caller | ||
| 777 | CNVHEXAT ENDP | ||
| 778 | |||
| 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 | ;-----------------------------------------------------------------------; | ||
| 784 | STEAL_INT15 PROC | ||
| 785 | PUSH DS | ||
| 786 | push ax | ||
| 787 | |||
| 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; | ||
| 790 | |||
| 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 | ||
| 793 | |||
| 794 | MOV AH,0C0h ; the XMA/A or XMO card @RH2 | ||
| 795 | INT 15h ; @RH2 | ||
| 796 | CMP INT15_SEC_MOD,SEC_MOD_TB; @RH2 | ||
| 797 | JE Steal_INT15_Hook ; @RH2 | ||
| 798 | |||
| 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 | ||
| 802 | |||
| 803 | Steal_INT15_Hook: | ||
| 804 | |||
| 805 | XOR AX,AX | ||
| 806 | MOV DS,AX ;set DS = 0 | ||
| 807 | ASSUME DS:INT_VEC15 | ||
| 808 | CLI ;disable interrupts | ||
| 809 | LES DI,DS:EM_VEC ;get original vector's content | ||
| 810 | MOV CS:INTV15O,DI ;save original vector | ||
| 811 | MOV CS:INTV15S,ES | ||
| 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 | ||
| 815 | |||
| 816 | Steal_INT15_Exit: | ||
| 817 | |||
| 818 | pop ax | ||
| 819 | POP DS ;restore DS | ||
| 820 | RET | ||
| 821 | STEAL_INT15 ENDP | ||
| 822 | |||
| 823 | |||
| 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; | ||
| 830 | |||
| 831 | push ax ;save regs ;an000; dms; | ||
| 832 | push bx ; ;an000; dms; | ||
| 833 | push cx ; ;an002; dms; | ||
| 834 | push dx ; ;an000; dms; | ||
| 835 | |||
| 836 | mov ah,EM_Size_Get ;get extended mem ;an000; dms; | ||
| 837 | int 15h ; ;an000; dms; | ||
| 838 | |||
| 839 | mov cl,4 ;divide by 16 ;an002; dms; | ||
| 840 | shr ax,cl ; to get page count ;an002; dms; | ||
| 841 | |||
| 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; | ||
| 847 | |||
| 848 | pop dx ;restore regs ;an000; dms; | ||
| 849 | pop cx ; ;an002; dms; | ||
| 850 | pop bx ; ;an000; dms; | ||
| 851 | pop ax ; ;an000; dms; | ||
| 852 | |||
| 853 | ret | ||
| 854 | |||
| 855 | Calc_INT15_Space endp ;an000; dms; | ||
| 856 | |||
| 857 | |||
| 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 ; | ||
| 861 | ; to EMS pages. ; | ||
| 862 | ;-----------------------------------------------------------------------; | ||
| 863 | Steal_Int13 PROC ;an004; dms; | ||
| 864 | PUSH DS ;an004; dms; | ||
| 865 | push ax ;an004; dms; | ||
| 866 | |||
| 867 | CMP MODEL_BYTE,PS2MODEL80 ;If not a PS2/80 don't hook INT 13h ;an004; dms; | ||
| 868 | jne Steal_INT15_Exit ; ;an004; dms; | ||
| 869 | |||
| 870 | XOR AX,AX | ||
| 871 | MOV DS,AX ;set DS = 0 | ||
| 872 | ASSUME DS:INT_VEC13 | ||
| 873 | CLI ;disable interrupts | ||
| 874 | LES DI,DS:DK_VEC ;get original vector's content | ||
| 875 | MOV CS:INTV13O,DI ;save original vector | ||
| 876 | MOV CS:INTV13S,ES | ||
| 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 | ||
| 880 | |||
| 881 | Steal_INT13_Exit: | ||
| 882 | |||
| 883 | pop ax | ||
| 884 | POP DS ;restore DS | ||
| 885 | RET | ||
| 886 | STEAL_INT13 ENDP | ||