diff options
Diffstat (limited to 'v4.0/src/DEV/XMA2EMS/ROMSCAN.INC')
| -rw-r--r-- | v4.0/src/DEV/XMA2EMS/ROMSCAN.INC | 420 |
1 files changed, 420 insertions, 0 deletions
diff --git a/v4.0/src/DEV/XMA2EMS/ROMSCAN.INC b/v4.0/src/DEV/XMA2EMS/ROMSCAN.INC new file mode 100644 index 0000000..8eeb1b8 --- /dev/null +++ b/v4.0/src/DEV/XMA2EMS/ROMSCAN.INC | |||
| @@ -0,0 +1,420 @@ | |||
| 1 | |||
| 2 | page | ||
| 3 | ;------------------------------------------------------------------- | ||
| 4 | ; | ||
| 5 | ; This file contains the code to do a pseudo-rom scan looking | ||
| 6 | ; for possible EMS holes | ||
| 7 | ; | ||
| 8 | ;------------------------------------------------------------------- | ||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 | romscan proc near | ||
| 13 | |||
| 14 | push ax | ||
| 15 | push dx | ||
| 16 | push cx | ||
| 17 | push di | ||
| 18 | |||
| 19 | push cs ; make es and ds point to segment where messages are | ||
| 20 | pop es | ||
| 21 | |||
| 22 | push cs | ||
| 23 | pop ds | ||
| 24 | |||
| 25 | ; must do rom scan with interrupts disabled | ||
| 26 | |||
| 27 | cli | ||
| 28 | |||
| 29 | ;------------------------ | ||
| 30 | |||
| 31 | cmp map_count,0 ; no segments specified, do rom scan | ||
| 32 | je no_pages_spec | ||
| 33 | |||
| 34 | mov cx,map_count ; number of segments to check | ||
| 35 | xor di,di ; use di as pointer into table | ||
| 36 | |||
| 37 | check_segs: | ||
| 38 | mov ax,map_table.phys_page_segment[di] | ||
| 39 | |||
| 40 | call CHK_FREE_SEGMENT ; check a 16K block | ||
| 41 | jnc segment_ok | ||
| 42 | |||
| 43 | ; display the error | ||
| 44 | |||
| 45 | mov segment_error,1 ; set segment error flag | ||
| 46 | |||
| 47 | |||
| 48 | ; display conflict message | ||
| 49 | |||
| 50 | push ax ; save some regs | ||
| 51 | push dx | ||
| 52 | push di | ||
| 53 | |||
| 54 | MOV DI,OFFSET confl_address ; ascii string page frame | ||
| 55 | CALL CNVHEXAT | ||
| 56 | |||
| 57 | MOV DX,OFFSET conflict_msg ; start of message | ||
| 58 | MOV AH,9 ; dos prt string | ||
| 59 | INT 21H ; | ||
| 60 | |||
| 61 | pop di ; restore some regs | ||
| 62 | pop dx | ||
| 63 | pop ax | ||
| 64 | |||
| 65 | segment_ok: | ||
| 66 | add di,type mappable_phys_page_struct | ||
| 67 | loop check_segs | ||
| 68 | |||
| 69 | ;------------------------ | ||
| 70 | ; if there were no conflicts, then exit with no error | ||
| 71 | |||
| 72 | cmp segment_error,0 | ||
| 73 | je rom_scan_no_error ; exit with no error (carry = 0) | ||
| 74 | |||
| 75 | ;------------------------ | ||
| 76 | |||
| 77 | MOV DX,OFFSET CRLF ; skip a blank line | ||
| 78 | MOV AH,9 ; dos prt string | ||
| 79 | INT 21H ; | ||
| 80 | |||
| 81 | jmp rom_scan_code | ||
| 82 | |||
| 83 | ; display no pages message | ||
| 84 | |||
| 85 | no_pages_spec: | ||
| 86 | MOV DX,OFFSET NO_PAGES_MSG ; skip a blank line | ||
| 87 | MOV AH,9 ; dos prt string | ||
| 88 | INT 21H | ||
| 89 | |||
| 90 | MOV DX,OFFSET CRLF ; skip a blank line | ||
| 91 | MOV AH,9 ; dos prt string | ||
| 92 | INT 21H ; | ||
| 93 | |||
| 94 | ;------------------------------------------------------------------- | ||
| 95 | ; | ||
| 96 | ; This routine scans the address range from c000 - FFFF looking | ||
| 97 | ; for 16 K gaps. | ||
| 98 | ; | ||
| 99 | ;------------------------------------------------------------------- | ||
| 100 | |||
| 101 | rom_scan_code: | ||
| 102 | |||
| 103 | mov ax,0c000h ; start at c000 | ||
| 104 | xor bx,bx ; bx holds count of contiguous pages | ||
| 105 | mov cx,15 ; loop counter | ||
| 106 | mov dx,ax ; dx holds start of frame | ||
| 107 | |||
| 108 | fam2_loop: | ||
| 109 | call CHK_FREE_SEGMENT ; check a 16K block | ||
| 110 | jc bad_seg | ||
| 111 | |||
| 112 | ; good 16 segment | ||
| 113 | |||
| 114 | call FoundBlock | ||
| 115 | |||
| 116 | add bx,1 ; add another page to frame counter | ||
| 117 | cmp bx,4 ; 4 means frame is found | ||
| 118 | jne no_frame_yet | ||
| 119 | |||
| 120 | ; a frame has been found | ||
| 121 | |||
| 122 | mov bx,100 ; make sure we don't look for more frames | ||
| 123 | |||
| 124 | no_frame_yet: | ||
| 125 | add ax,0400h ; point to next segment | ||
| 126 | jmp continue_loop | ||
| 127 | |||
| 128 | ; bad 16 segment | ||
| 129 | |||
| 130 | bad_seg: | ||
| 131 | add ax,0400h ; point to next segment | ||
| 132 | cmp bx,100 | ||
| 133 | jae continue_loop ; don't reset frame info if one has been found | ||
| 134 | |||
| 135 | xor bx,bx ; clear contiguous page counter | ||
| 136 | mov dx,ax ; make frame pointer point to next page | ||
| 137 | |||
| 138 | continue_loop: | ||
| 139 | |||
| 140 | loop fam2_loop | ||
| 141 | jmp rom_scan_exit | ||
| 142 | |||
| 143 | |||
| 144 | rom_scan_no_error: | ||
| 145 | clc | ||
| 146 | jmp clean_exit | ||
| 147 | |||
| 148 | |||
| 149 | ;------------------------------------------------------------------- | ||
| 150 | |||
| 151 | rom_scan_exit: | ||
| 152 | |||
| 153 | ; display frame if found | ||
| 154 | |||
| 155 | cmp bx,100 ; >= 100 means frame was found | ||
| 156 | jb no_frame_exit | ||
| 157 | |||
| 158 | mov ax,dx ; get frame address in ax | ||
| 159 | call FoundFrame ; display frame address | ||
| 160 | |||
| 161 | |||
| 162 | no_frame_exit: | ||
| 163 | STC ; carry = 1 means error | ||
| 164 | |||
| 165 | clean_exit: | ||
| 166 | sti | ||
| 167 | |||
| 168 | |||
| 169 | pop di | ||
| 170 | pop dx | ||
| 171 | pop cx | ||
| 172 | pop ax | ||
| 173 | |||
| 174 | ret | ||
| 175 | |||
| 176 | romscan endp | ||
| 177 | |||
| 178 | |||
| 179 | |||
| 180 | ;------------------------------------------------------------------- | ||
| 181 | ; | ||
| 182 | ; FoundBlock assumes AX = segment address of good 16 K block | ||
| 183 | ; | ||
| 184 | ;------------------------------------------------------------------- | ||
| 185 | |||
| 186 | FoundBlock proc near | ||
| 187 | |||
| 188 | push ax | ||
| 189 | push dx | ||
| 190 | push es | ||
| 191 | push di | ||
| 192 | |||
| 193 | push cs | ||
| 194 | pop es | ||
| 195 | |||
| 196 | push cs | ||
| 197 | pop ds | ||
| 198 | |||
| 199 | MOV DI,OFFSET hole_address ; ascii string page frame | ||
| 200 | CALL CNVHEXAT | ||
| 201 | |||
| 202 | MOV DX,OFFSET hole_msg ; start of message | ||
| 203 | MOV AH,9 ; dos prt string | ||
| 204 | INT 21H ; | ||
| 205 | |||
| 206 | |||
| 207 | pop di | ||
| 208 | pop es | ||
| 209 | pop dx | ||
| 210 | pop ax | ||
| 211 | |||
| 212 | ret | ||
| 213 | |||
| 214 | FoundBlock endp | ||
| 215 | |||
| 216 | ;------------------------------------------------------------------- | ||
| 217 | ; | ||
| 218 | ; FoundFrame assumes AX = segment address of good 64 K block | ||
| 219 | ; | ||
| 220 | ;------------------------------------------------------------------- | ||
| 221 | |||
| 222 | FoundFrame proc near | ||
| 223 | |||
| 224 | push ax | ||
| 225 | push dx | ||
| 226 | push es | ||
| 227 | push di | ||
| 228 | |||
| 229 | push cs | ||
| 230 | pop es | ||
| 231 | |||
| 232 | push cs | ||
| 233 | pop ds | ||
| 234 | |||
| 235 | MOV DI,OFFSET frame_address ; ascii string page frame | ||
| 236 | CALL CNVHEXAT | ||
| 237 | |||
| 238 | MOV DX,OFFSET frame_msg ; start of message | ||
| 239 | MOV AH,9 ; dos prt string | ||
| 240 | INT 21H ; | ||
| 241 | |||
| 242 | |||
| 243 | pop di | ||
| 244 | pop es | ||
| 245 | pop dx | ||
| 246 | pop ax | ||
| 247 | |||
| 248 | ret | ||
| 249 | |||
| 250 | FoundFrame endp | ||
| 251 | |||
| 252 | |||
| 253 | |||
| 254 | |||
| 255 | |||
| 256 | |||
| 257 | ;------------------------------------------------------------------- | ||
| 258 | ;------------------------------------------------------------------- | ||
| 259 | ;------------------------------------------------------------------- | ||
| 260 | ;------------------------------------------------------------------- | ||
| 261 | ;------------------------------------------------------------------- | ||
| 262 | ;------------------------------------------------------------------- | ||
| 263 | ;------------------------------------------------------------------- | ||
| 264 | ;------------------------------------------------------------------- | ||
| 265 | ;------------------------------------------------------------------- | ||
| 266 | ;------------------------------------------------------------------- | ||
| 267 | ;------------------------------------------------------------------- | ||
| 268 | ;------------------------------------------------------------------- | ||
| 269 | ;------------------------------------------------------------------------ | ||
| 270 | ; 03/04/88 jwg: | ||
| 271 | ; PROCEDURE NAME: CHK_FREE_SEGMENT : | ||
| 272 | ; : | ||
| 273 | ; THIS PROCEDURE CHECKS EACH OF THE 2K BOUNDARIES IN THE 16K SEGMENT : | ||
| 274 | ; TO DETERMINE IF A ROM SEGMENT IS EMPTY. IT VERIFIES THAT NO ROM : | ||
| 275 | ; FROM A PRECEEDING ADDRESS EXTENDS INTO THIS 16K SEGMENT. ALSO THE : | ||
| 276 | ; 16K BLOCK IS CHECKED FOR THE PRESENCE OF ANY RESPONDING CARD. : | ||
| 277 | ; : | ||
| 278 | ; ENTRY: AX - CONTAINS 16K SEGMENT ADDRESS : | ||
| 279 | ; EXIT: CARRY FLAG = 0 - SEGMENT FREE : | ||
| 280 | ; CARRY FLAG = 1 - SEGMENT IN USE : | ||
| 281 | ; : | ||
| 282 | ;------------------------------------------------------------------------ | ||
| 283 | |||
| 284 | ROM_SCAN EQU 0AA55H | ||
| 285 | CARD_SEL_PORT EQU 091h ; CARD SELECTED LATCH PORT | ||
| 286 | |||
| 287 | |||
| 288 | CHK_FREE_SEGMENT PROC NEAR | ||
| 289 | |||
| 290 | PUSH AX ; Save work registers | ||
| 291 | PUSH BX | ||
| 292 | PUSH CX | ||
| 293 | PUSH DX | ||
| 294 | PUSH DI | ||
| 295 | PUSH ES ; Save data segment register | ||
| 296 | MOV BX,AX ; Save segment start address | ||
| 297 | MOV CX,AX ; Save in work register | ||
| 298 | ADD CX,0400h ; Determine End segment address of FIFE | ||
| 299 | ; MOV DX,0C000h-00100h ; Get address of start of ROM area | ||
| 300 | mov dx,ax ; gga | ||
| 301 | sub dx,0100h ; gga | ||
| 302 | CHK_FREE_NEXT: | ||
| 303 | ADD DX,00100h ; Add offset to get next 2K segment | ||
| 304 | CMP DX,CX ; Check for past end of 16K ROM area | ||
| 305 | JAE CHK_FREE_OK ; IF (NC) then Exit, segment was free | ||
| 306 | |||
| 307 | ; CHECK FOR ROM BLOCK SIGNATURE | ||
| 308 | MOV ES,DX ; Change to new ROM segment | ||
| 309 | CMP ES:WORD PTR [0],ROM_SCAN; Check if a ROM module is present | ||
| 310 | JE CHK_FREE_SIZE ; Go check length if ROM SCAN signature | ||
| 311 | |||
| 312 | CMP BX,DX ; Check if into the target segment yet | ||
| 313 | JA CHK_FREE_NEXT ; Loop and check next 2K block in not | ||
| 314 | |||
| 315 | ; CHECK FOR CARD RESPONDING IN 2K | ||
| 316 | NOP ; Following sequence can not be traced.. | ||
| 317 | ;;;;; CALL CARD_SEL_NOW ; Reset CARD SELECTED FEED BACK latch . | ||
| 318 | XOR DI,DI ; Clear source pointer . | ||
| 319 | MOV AX,0FFFFh ; Get expected floating bus pattern . | ||
| 320 | PUSH CX ; Save CX . | ||
| 321 | MOV CX,00400h ; Get count of 1 K words (2K bytes) . | ||
| 322 | REPE SCASW ; Check for all bits on in block ES:DI . | ||
| 323 | POP CX ; Recover end segment address . | ||
| 324 | JNE CHK_FREE_ERROR ; Exit if anything there . | ||
| 325 | |||
| 326 | ;;;;;; cmp rom_scan_type,family1 ; gga only do the card select check on PS2's | ||
| 327 | ;;;;;; je skip_ps2_check | ||
| 328 | |||
| 329 | ;;;;;; CALL CARD_SEL_NOW ; Check for a CARD SELECTED by scan . | ||
| 330 | ;;;;;; JC CHK_FREE_ERROR ; Exit (CY) if a card responded ........ | ||
| 331 | |||
| 332 | ;;;;;;skip_ps2_check: | ||
| 333 | JMP CHK_FREE_NEXT ; ELSE check next 2K address | ||
| 334 | |||
| 335 | CHK_FREE_SIZE: ; CHECK LENGTH INTO 16K SEGMENT | ||
| 336 | push cx ; gga | ||
| 337 | MOV AL,ES:BYTE PTR [2] ; Get ROM module length in 512 bytes | ||
| 338 | MOV AH,0 ; Clear high byte | ||
| 339 | mov cl,5 ; gga | ||
| 340 | SHL AX,cl ; gga convert to segment length (16 byte) | ||
| 341 | pop cx ; gga | ||
| 342 | ADD AX,DX ; Determine ending segment size | ||
| 343 | CMP BX,AX ; Does ROM extend into this 16K segment | ||
| 344 | JNB CHK_FREE_NEXT ; IF not then continue search | ||
| 345 | |||
| 346 | CHK_FREE_ERROR: | ||
| 347 | STC ; ELSE (CY), Exit with segment not free | ||
| 348 | CHK_FREE_OK: | ||
| 349 | POP ES ; restore segment register | ||
| 350 | POP DI | ||
| 351 | POP DX | ||
| 352 | POP CX ; restore all registers | ||
| 353 | POP BX | ||
| 354 | POP AX | ||
| 355 | RET ; EXIT (NC) if segment free to test | ||
| 356 | |||
| 357 | CHK_FREE_SEGMENT ENDP | ||
| 358 | |||
| 359 | |||
| 360 | ;------------------------------------------------------------------------ | ||
| 361 | ; 03/04/88 jwg: | ||
| 362 | ; PROCEDURE NAME: CARD_SEL_FBK : | ||
| 363 | ; : | ||
| 364 | ; THIS PROCEDURE CHECKS THE CARD SELECTED FEEDBACK LINE AND LATCH : | ||
| 365 | ; TO VERIFY THAT THIS LINE WAS ACTIVATED. METHOD IS TO CLEAR THE : | ||
| 366 | ; LATCH AND READ A LOCATION USING THE PASSED SEGMENT ADDRESS. IF : | ||
| 367 | ; ANY CARD RESPONDS THE LATCH WILL BE SET ON. : | ||
| 368 | ; : | ||
| 369 | ; NOTE: These routines can not be traced with a debug-er : | ||
| 370 | ; as VIDEO updates also set the card selected latch. : | ||
| 371 | ; : | ||
| 372 | ; ENTRY: AX - ADDRESS OF SELECTED SEGMENT : | ||
| 373 | ; : | ||
| 374 | ; EXIT: CARRY FLAG = 0 - CARD SELECTED LATCH WAS NOT SET (OFF) : | ||
| 375 | ; CARRY FLAG = 1 - CARD SELECTED LATCH WAS SET BY TEST : | ||
| 376 | ; : | ||
| 377 | ;------------------------------------------------------------------------ | ||
| 378 | |||
| 379 | ;;;;;CARD_SEL_FBK PROC NEAR ; TEST CARD SELECTED FEED BACK | ||
| 380 | |||
| 381 | ;;;;; CLI ; Block interrupts during operation | ||
| 382 | ;;;;; CALL CARD_SEL_NOW ; Read current port value to clear | ||
| 383 | ;;;;; PUSH DS ; Save segment register | ||
| 384 | ;;;;; MOV DS,AX ; Set segment | ||
| 385 | ;;;;; CMP DS:BYTE PTR [0],AL ; Read first byte with dummy compare | ||
| 386 | ;;;;; POP DS ; Restore segment selector | ||
| 387 | ;;;;; CALL CARD_SEL_NOW ; Read current port value and clear | ||
| 388 | ;;;;; STI ; Enable interrupts | ||
| 389 | ;;;;; RET ; RETurn (CY)= 1 if latch set by read | ||
| 390 | |||
| 391 | ;;;;;CARD_SEL_FBK ENDP | ||
| 392 | |||
| 393 | ;------------------------------------------------------------------------ | ||
| 394 | ; 03/04/88 jwg: | ||
| 395 | ; PROCEDURE NAME: CARD_SEL_NOW (CURRENT VALUE) : | ||
| 396 | ; : | ||
| 397 | ; THIS PROCEDURE READS AND RESETS THE CURRENT CARD SELECTED FEEDBACK : | ||
| 398 | ; LATCH AND RETURNS THE STATUS. : | ||
| 399 | ; : | ||
| 400 | ; NOTE: This routine can not be traced with a debug-er : | ||
| 401 | ; as VIDEO updates also set the card selected latch. : | ||
| 402 | ; : | ||
| 403 | ; ENTRY: NONE : | ||
| 404 | ; : | ||
| 405 | ; EXIT: CARRY FLAG = 0 - CARD SELECTED LATCH WAS NOT SET (OFF) : | ||
| 406 | ; CARRY FLAG = 1 - CARD SELECTED LATCH WAS SET ON WHEN READ : | ||
| 407 | ; : | ||
| 408 | ;------------------------------------------------------------------------ | ||
| 409 | |||
| 410 | ;;;;;CARD_SEL_NOW PROC NEAR ; READ CARD SELECTED FEED BACK | ||
| 411 | |||
| 412 | ;;;;; PUSH AX ; Save segment address | ||
| 413 | ;;;;; IN AL,CARD_SEL_PORT ; Read current port value and clear | ||
| 414 | ;;;;; RCR AL,1 ; Move bit 0 into CY flag | ||
| 415 | ;;;;; POP AX ; Recover segment address | ||
| 416 | ;;;;; RET ; RETurn (CY)= 0 if latch set | ||
| 417 | |||
| 418 | ;;;;;CARD_SEL_NOW ENDP | ||
| 419 | |||
| 420 | \ No newline at end of file | ||