1 ; disk.S - inquire of BIOS and display disk parameters
3 ; Copyright 1999-2004 John Coffman
4 ; Copyright 2009-2011 Joachim Wiedorn
7 ; Licensed under the terms contained in the file 'COPYING'
8 ; in the source directory.
12 #define DELL_DIRTY_HACK
15 SYSSEG = 0x1000 ; DEF_SYSSEG
16 SETUPSEG = 0x9020 ; DEF_SETUPSEG
27 ; we want this to look like a bootable kernel image
28 ; so we include the following header
31 .ascii "HdrS" ; Signature for Setup header
32 .word 0x0201 ; header format version number
33 .word 0,0 ; realmode switch, SETUPSEG
34 .word SYSSEG ; SYSSEG -- load at 1000:0000
36 .byte 0 ; type of loader
37 .byte 0 ; flags 0=load low
38 .word 0x200 ; move size
39 dd 0x1000 ; load us here
41 .word bs_helper,SETUPSEG ; kludge???
42 .word modelist+1024 ; heap end pointer
43 ;----------end of header------------
47 cli ;make purists happy
51 call start ;do not separate from the instruction below
52 start: pop bx ;this MUST immediately follow the 'call'
55 sub bx,bp ;BX=100h under DOS, BX=0h under BIOS
60 mov dx_save,dx ;save DX we received
62 #ifdef DELL_DIRTY_HACK
63 mov ah,#15 ; get video mode
66 int 0x10 ; set video mode
69 .ascii "\n>>>> Disk Detection and Parameter Display <<<<\n"
70 .ascii "Version 1.6, Copyright (C) 1999-2005 John Coffman.\n"
71 .ascii "Re-use and redistribution rights set forth"
72 .ascii " in the file \"COPYING\".\n\n"
76 je sane ;check that we got the DS set right
78 .ascii "\n\nCS/DS sanity check failed.\n"
101 .ascii "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
102 .ascii "!!! *** Warning: DOS is not running in REAL mode *** !!!\n"
103 .ascii "!!! *** Reported results may not be accurate *** !!!\n"
104 .ascii "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
113 int 0x11 ; get equipment configuration
134 .ascii " floppy drive"
142 .ascii " with BIOS support.\n"
145 ; now probe for floppy drives
164 .ascii "But probing has found "
177 mov dl,#0 ;start with drive 0x00
192 int 0x12 ;get amount of low memory
193 ;;; mov ax,#640 ;debug
197 .ascii "K of low memory"
203 .ascii " with no EBDA."
211 .ascii ". EBDA size = "
215 .ascii "K EBDA starts at 0x"
266 .ascii " with BIOS support.\n"
269 ; probe for hard drives
289 .ascii "But probing has found "
306 mov dl,#0x80 ;start with drive 0x80
314 test byte ptr bigflag,#0xFF
317 hdd2: test byte ptr bigcyl,#0xFF
322 .ascii "\nEither your BIOS does not support EDD"
323 .ascii " packet calls, or you have no large\n"
324 .ascii "disks. You do not need to use LILO with"
325 .ascii " the 'lba32' global option (or '-L'\n"
345 .ascii " bigger than 8.4Gb"
348 .ascii " with Enhanced BIOS support.\n"
349 .ascii "Using LILO with the 'lba32' global option"
350 .ascii " (or '-L' switch) is recommended.\n"
368 .ascii " with more than 1023 cylinders"
378 nlimit: dd 1024*255*63, 0
381 ; inquire whether EDD drive BIOS calls are valid
382 ; Carry clear says NO, Carry set says YES, CX=device bits &
383 ; SI = pointer to dparam table
403 mov dh,ah ;save version number
404 mov ah,#0x48 ;get drive parameters
408 pop ax ;discard saved SI
409 mov (si+1),dh ;save version info
410 jmp edd9 ;return SI, too
413 edd7: xor cx,cx ;carry is clear
421 ; pause for the user to look at the screen
424 .ascii "Hit any key to continue..."
433 ; print out the IBM BIOS drive parameters for the drive in DL
450 .ascii " Cyl:Head:Sec = "
457 mov dh,#0xFF ; 0xFE is the max.
498 ;; avoid Davide bug: Sectors == 0
501 inc ax ; now sectors = [1..64]
524 .ascii " sectors) --> "
555 .ascii " geometry = "
565 xdd1a: inc byte (bigcyl)
586 .ascii " sectors) --> "
603 xdd2a: inc byte bigflag
626 chars: .ascii " KMGTxyz"
644 jz dpr5 ;handle small disks
663 cmp byte ptr (si),#'K
698 ; print the decimal double word number in DX:AX
717 ; print the decimal quad-word number in [DS:SI]
761 ; multiply the number in the ac pointed at by [DS:SI] by the AX, putting
762 ; the result in the ac pointed to by [ES:SI]. Return overflow in AX.
763 ; SI and DI may be the same
794 ; divide the ac pointed at by [DS:SI] by the AX, producing a result
795 ; in [ES:DI], and a remainder in DX; the Z flag reflects the quotient
796 ; DI may equal SI for in-place division
816 or bp,ax ;sets the Z flag
829 ; write the number < 1000 in AX as 3 decimal digits
830 ; BH flags whether leading zeroes are printed (0x80=yes, 0=no)
856 ; write the <nul> terminated string which follows the call
857 ; no registers altered
879 ; write the word in AX in hex
886 ; write the byte in AL in hex
907 ; write the character in AL in teletype mode
908 ; all registers are preserved
914 cmp al,#10 ;test for new-line
929 #include "biosdata.S"
935 exit_dos: mov ax,#0x4c00
941 .ascii "BIOS data collection test.\n"
942 .ascii "Failure of this test will require booting all Linux\n"
943 .ascii "kernels with the 'nobd' command-line option.\n"
944 .ascii "Hit <ESC> to bypass, any other key to continue..."
974 mov dx,dx_save ; DX passed in on boot
978 .ascii "\nALL OKAY\n\n"
983 .ascii "Remove the floppy disk from the drive.\n"
984 .ascii "Hit any key to reboot..."
990 bs_helper: int 0x19 ;label here for kludge
993 id_string: .ascii "Disk.Com"