3 ; Copyright 2002-2004 John Coffman.
6 ; Licensed under the terms contained in the file 'COPYING' in the
12 io_sig: .long 0 ; space for CRC
13 .ascii PROBE_SIGNATURE ; "LiLo"
14 .word PROBE_VERSION ; sanity check
15 io_lth: .word 0 ; byte count overall
17 .byte 0 ; last good drive (in low byte)
25 #if PROBE_VERSION >= 5
32 ; read partition table of device in DL
42 mov bx,#BOOTSEG*16+SECTOR_SIZE
45 mov ax,#0x201 ; read 1 sector
49 .ascii "Read partition table\n"
53 call dsk_do_rw ; make 5 tries
58 #if PROBE_VERSION == 3
59 lea si,(bx+PART_TABLE_OFFSET)
61 #elif PROBE_VERSION >= 4
62 lea si,(bx+PART_TABLE_OFFSET-8)
80 ; check a hard drive for EDD support
82 ; device code is in DL
92 .ascii "Check EDD present\n"
108 jc io_do_edd_check_ret
110 jne io_do_edd_check_ret
111 #if PROBE_VERSION < 6
112 test al,#EDD_SUBSET ; test for EDD call supported
113 jz io_do_edd_check_ret
116 ; get the EDD parameters
118 push dx ; paranoia, protect DL
119 push es ; more paranoia
124 mov si,di ; DS:SI points at return area
127 mov word (si),#EDD_LTH ; set max count to return
131 .ascii "Get EDD parameters\n"
142 stosw ; save the return flags
154 ; io_biosdata: examine hard disk BIOS devices
159 ; direction flag clear
163 ; All registers preserved
165 ; Side effect is to write the low memory disk data area
171 pusha ;save all registers
174 push #PROBESEG ;save area is at 0060:0000 (0x000600)
176 mov di,#io_l_sig ;skip over header area
178 ; get the equipment configuration flags
180 #if PROBE_VERSION >= 5
181 mov io_eqp,di ;save equipment pointer
182 push dx ; protect this register
187 .ascii "Get equipment configuration\n"
194 ; get the conventional memory size
199 .ascii "Get conventional memory size\n"
204 stosw ; save the number
206 #if PROBE_VERSION >= 5
210 .ascii "Save boot device code\n"
214 pop ax ; get saved DX register
218 ; collect the video information
220 #if PROBE_VERSION >= 5
221 mov io_vid,di ; set the pointer
223 #if BD_GET_VIDEO >= 1
224 mov ah,#0x0F ; get video mode
228 .ascii "Get video mode\n"
237 mov bl,[0x84] ; get rows, too
243 cmp bl,#7 ; is it MDA
244 beq io_floppies ; yup, skip it all
245 cmp bh,#80 ; number of columns on screen
246 jb io_floppies1 ; probably CGA
249 #if BD_GET_VIDEO >= 2
252 mov bx,#0xFF10 ; get configuration information
256 .ascii "Get video configuration\n"
269 mov ax,#0x1A00 ; get display combination code
273 .ascii "Get display combination\n"
282 cmp bl,#0x1A ; is function supported?
292 #if PROBE_VERSION >= 5
294 ; test to see if registers get trashed (some geforce video bios trashes dx)
308 .ascii "Enable Screen Refresh\n"
312 int 0x10 ; enable screen refresh
326 #endif /* BD_GET_VIDEO >= 2 */
328 #if BD_GET_VIDEO >= 3
329 mov ax,#0x4F00 ; check VESA present
330 ; ES:DI is already set
334 .ascii "Check VESA present\n"
341 mov bx,(di) ; possible "VE"
343 mov cx,(di+2) ; possible "SA"
346 stosw ; possible "VE"
347 xchg ax,cx ; possible "SA"
349 cmp bx,#0x004F ; good return
351 cmp cx,#0x4556 ; "VE"
353 cmp ax,#0x4153 ; "SA"
357 mov cx,#0x0101 ; get mode information
361 .ascii "Get VESA mode information 1\n"
368 mov bx,(di) ; get bits
374 mov cx,#0x0103 ; get mode information
378 .ascii "Get VESA mode information 3\n"
385 mov bx,(di) ; get bits
390 mov ax,#-1 ; flag for VESA not present
394 ; jmp io_floppies ; exit to this point
397 ; now go after the disk drive information
403 mov cx,#BD_MAX_FLOPPY ;test 4 floppies
405 mov io_flp,di ;set pointer to floppy info
416 test dl,#3 ; pause every 4th drive
421 .ascii "Get drive type "
431 xchg al,ah ;code to AL
436 stosw ; save DX (low order)
438 stosw ; save CX (high order)
439 xchg ax,dx ; restore code to AL
442 jc io_no_disk ; error means no disk present
443 dec al ; AL==0 means no disk present
444 jns io_get_param ; if S=0, some disk type is present
448 jns io_get_param ;do it all on floppies
450 pop cx ;premature loop termination
451 jmp io_loop_end ;skip the rest on fixed disks
455 ; get drive parameters
458 push es ; supposedly clobbered for floppies only
459 push di ; do not trust anyone
465 .ascii "Get drive parameters\n"
473 mov bp,di ; save floppy param pointer
479 stosw ; save return code & flags
486 jc io_fh_check ; bad return above
487 ;;; mov [io_good_disk],dl ; save DL
489 cmp dl,#0x80 ; check for first HD
491 cbw ; former DL has disk count
492 pop cx ; get HD count
493 push ax ; set new HD count
496 or dl,dl ; check floppy/hard disk
504 ; check EDD extensions present
512 mov [io_good_disk],dl ;save last disk checked
522 or dl,dl ; set the S flag
524 mov cx,#BD_MAX_HARD ; do not touch flags ***
525 mov dl,#0x80 ; do not touch flags ***
527 jns io_next_drive ; do the hard drives if not done
531 pop word [io_pt] ; save pt pointer
532 pop word [io_hrd] ; save hd pointer
534 ; now save the partition tables
546 ; now must record and checksum the results
548 mov io_lth,di ; address of end is overall count
551 xor di,di ;move to here
552 mov si,#io_sig ;move from here
553 mov cx,#io_l_sig ;this number of bytes
557 mov si,#4 ; skip long at beginning
560 push dword #CRC_POLY1
564 mov [0],eax ; save that crc
567 ; restore the registers and return