3 ;-------------------------------------------------------------------
5 ; This file contains the code to do a pseudo-rom scan looking
6 ; for possible EMS holes
8 ;-------------------------------------------------------------------
19 push cs ; make es and ds point to segment where messages are
25 ; must do rom scan with interrupts disabled
29 ;------------------------
31 cmp map_count,0 ; no segments specified, do rom scan
34 mov cx,map_count ; number of segments to check
35 xor di,di ; use di as pointer into table
38 mov ax,map_table.phys_page_segment[di]
40 call CHK_FREE_SEGMENT ; check a 16K block
45 mov segment_error,1 ; set segment error flag
48 ; display conflict message
50 push ax ; save some regs
54 MOV DI,OFFSET confl_address ; ascii string page frame
57 MOV DX,OFFSET conflict_msg ; start of message
58 MOV AH,9 ; dos prt string
61 pop di ; restore some regs
66 add di,type mappable_phys_page_struct
69 ;------------------------
70 ; if there were no conflicts, then exit with no error
73 je rom_scan_no_error ; exit with no error (carry = 0)
75 ;------------------------
77 MOV DX,OFFSET CRLF ; skip a blank line
78 MOV AH,9 ; dos prt string
83 ; display no pages message
86 MOV DX,OFFSET NO_PAGES_MSG ; skip a blank line
87 MOV AH,9 ; dos prt string
90 MOV DX,OFFSET CRLF ; skip a blank line
91 MOV AH,9 ; dos prt string
94 ;-------------------------------------------------------------------
96 ; This routine scans the address range from c000 - FFFF looking
99 ;-------------------------------------------------------------------
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
109 call CHK_FREE_SEGMENT ; check a 16K block
116 add bx,1 ; add another page to frame counter
117 cmp bx,4 ; 4 means frame is found
120 ; a frame has been found
122 mov bx,100 ; make sure we don't look for more frames
125 add ax,0400h ; point to next segment
131 add ax,0400h ; point to next segment
133 jae continue_loop ; don't reset frame info if one has been found
135 xor bx,bx ; clear contiguous page counter
136 mov dx,ax ; make frame pointer point to next page
149 ;-------------------------------------------------------------------
153 ; display frame if found
155 cmp bx,100 ; >= 100 means frame was found
158 mov ax,dx ; get frame address in ax
159 call FoundFrame ; display frame address
163 STC ; carry = 1 means error
180 ;-------------------------------------------------------------------
182 ; FoundBlock assumes AX = segment address of good 16 K block
184 ;-------------------------------------------------------------------
199 MOV DI,OFFSET hole_address ; ascii string page frame
202 MOV DX,OFFSET hole_msg ; start of message
203 MOV AH,9 ; dos prt string
216 ;-------------------------------------------------------------------
218 ; FoundFrame assumes AX = segment address of good 64 K block
220 ;-------------------------------------------------------------------
235 MOV DI,OFFSET frame_address ; ascii string page frame
238 MOV DX,OFFSET frame_msg ; start of message
239 MOV AH,9 ; dos prt string
257 ;-------------------------------------------------------------------
258 ;-------------------------------------------------------------------
259 ;-------------------------------------------------------------------
260 ;-------------------------------------------------------------------
261 ;-------------------------------------------------------------------
262 ;-------------------------------------------------------------------
263 ;-------------------------------------------------------------------
264 ;-------------------------------------------------------------------
265 ;-------------------------------------------------------------------
266 ;-------------------------------------------------------------------
267 ;-------------------------------------------------------------------
268 ;-------------------------------------------------------------------
269 ;------------------------------------------------------------------------
271 ; PROCEDURE NAME: CHK_FREE_SEGMENT :
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. :
278 ; ENTRY: AX - CONTAINS 16K SEGMENT ADDRESS :
279 ; EXIT: CARRY FLAG = 0 - SEGMENT FREE :
280 ; CARRY FLAG = 1 - SEGMENT IN USE :
282 ;------------------------------------------------------------------------
285 CARD_SEL_PORT EQU 091h ; CARD SELECTED LATCH PORT
288 CHK_FREE_SEGMENT PROC NEAR
290 PUSH AX ; Save work registers
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
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
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
312 CMP BX,DX ; Check if into the target segment yet
313 JA CHK_FREE_NEXT ; Loop and check next 2K block in not
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 .
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 .
326 ;;;;;; cmp rom_scan_type,family1 ; gga only do the card select check on PS2's
327 ;;;;;; je skip_ps2_check
329 ;;;;;; CALL CARD_SEL_NOW ; Check for a CARD SELECTED by scan .
330 ;;;;;; JC CHK_FREE_ERROR ; Exit (CY) if a card responded ........
332 ;;;;;;skip_ps2_check:
333 JMP CHK_FREE_NEXT ; ELSE check next 2K address
335 CHK_FREE_SIZE: ; CHECK LENGTH INTO 16K SEGMENT
337 MOV AL,ES:BYTE PTR [2] ; Get ROM module length in 512 bytes
338 MOV AH,0 ; Clear high byte
340 SHL AX,cl ; gga convert to segment length (16 byte)
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
347 STC ; ELSE (CY), Exit with segment not free
349 POP ES ; restore segment register
352 POP CX ; restore all registers
355 RET ; EXIT (NC) if segment free to test
357 CHK_FREE_SEGMENT ENDP
360 ;------------------------------------------------------------------------
362 ; PROCEDURE NAME: CARD_SEL_FBK :
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. :
369 ; NOTE: These routines can not be traced with a debug-er :
370 ; as VIDEO updates also set the card selected latch. :
372 ; ENTRY: AX - ADDRESS OF SELECTED SEGMENT :
374 ; EXIT: CARRY FLAG = 0 - CARD SELECTED LATCH WAS NOT SET (OFF) :
375 ; CARRY FLAG = 1 - CARD SELECTED LATCH WAS SET BY TEST :
377 ;------------------------------------------------------------------------
379 ;;;;;CARD_SEL_FBK PROC NEAR ; TEST CARD SELECTED FEED BACK
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
391 ;;;;;CARD_SEL_FBK ENDP
393 ;------------------------------------------------------------------------
395 ; PROCEDURE NAME: CARD_SEL_NOW (CURRENT VALUE) :
397 ; THIS PROCEDURE READS AND RESETS THE CURRENT CARD SELECTED FEEDBACK :
398 ; LATCH AND RETURNS THE STATUS. :
400 ; NOTE: This routine can not be traced with a debug-er :
401 ; as VIDEO updates also set the card selected latch. :
405 ; EXIT: CARRY FLAG = 0 - CARD SELECTED LATCH WAS NOT SET (OFF) :
406 ; CARRY FLAG = 1 - CARD SELECTED LATCH WAS SET ON WHEN READ :
408 ;------------------------------------------------------------------------
410 ;;;;;CARD_SEL_NOW PROC NEAR ; READ CARD SELECTED FEED BACK
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
418 ;;;;;CARD_SEL_NOW ENDP