Add externs to avoid multiple definitions, and then add missing definitions.
[rrq/maintain_lilo.git] / src / disk.S
1 ;  disk.S  -  inquire of BIOS and display disk parameters
2 ;
3 ;  Copyright 1999-2004 John Coffman
4 ;  Copyright 2009-2011 Joachim Wiedorn
5 ;  All rights reserved.
6 ;
7 ;  Licensed under the terms contained in the file 'COPYING'
8 ;  in the source directory.
9 ;
10
11 #define DEBUG 0
12 #define DELL_DIRTY_HACK
13
14
15 SYSSEG  =  0x1000       ; DEF_SYSSEG
16 SETUPSEG = 0x9020       ; DEF_SETUPSEG
17
18
19                 .text
20 #if 1
21 .globl  _main
22 _main:
23 #endif
24                 .globl  zero
25 zero:
26
27 ; we want this to look like a bootable kernel image
28 ; so we include the following header
29 ;
30                 jmp     begin
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
35                 .word   id_string
36                 .byte   0               ; type of loader
37                 .byte   0               ; flags 0=load low
38                 .word   0x200           ; move size
39                 dd      0x1000          ; load us here
40                 dd      0               ; ramdisk image
41                 .word   bs_helper,SETUPSEG      ; kludge???
42                 .word   modelist+1024   ; heap end pointer
43 ;----------end of header------------
44                 
45 begin:
46                 mov     ax,cs
47                 cli                     ;make purists happy
48                 mov     ss,ax
49                 mov     sp,#0x7FFE
50                 sti                     ; ***
51                 call    start           ;do not separate from the instruction below
52 start:          pop     bx              ;this MUST immediately follow the 'call'
53                 sub     bx,#start-zero
54                 lea     bp,zero
55                 sub     bx,bp           ;BX=100h under DOS, BX=0h under BIOS
56                 mov     cl,#4
57                 sar     bx,cl
58                 add     ax,bx
59                 mov     ds,ax
60                 mov     dx_save,dx      ;save DX we received
61                 cld
62 #ifdef DELL_DIRTY_HACK
63                 mov     ah,#15          ; get video mode
64                 int     0x10
65                 cbw
66                 int     0x10            ; set video mode
67 #endif
68                 call    say
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"
73                 .byte   0
74
75                 cmp     magic,#0xAA55
76                 je      sane            ;check that we got the DS set right
77                 call    say
78                 .ascii  "\n\nCS/DS sanity check failed.\n"
79                 .byte   0
80 hlti:           hlt
81                 jmp      hlti
82 ;;;     nop     ;spacer
83
84 magic:          .word      0xAA55
85 dx_save:        .word   0
86
87 sane:
88 #if 0
89                 xor     ax,ax
90                 mov     dl,al
91                 int     0x13
92                 mov     ah,#8
93                 int     0x13
94 #endif              
95                 smsw    ax
96                 test    al,#1
97                 jnz     v86mode
98                 br      realmode
99 v86mode:
100                 call    say
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"
105                 .byte   0
106
107                 call    pause
108
109 realmode:
110                 call    say
111                 .ascii  "There "
112                 .byte   0
113                 int     0x11            ; get equipment configuration
114                 test    al,#1
115                 mov     ah,#-1
116                 jz      noflop
117                 shl     ax,1
118                 shl     ax,1
119                 and     ah,#3
120                 jz      flop1
121 noflop:         call    say
122                 .ascii  "are "
123                 .byte   0
124                 jmp     flop2
125 flop1:          call    say
126                 .ascii  "is "
127                 .byte   0
128 flop2:          inc     ah
129                 mov     nflop,ah
130                 mov     al,ah
131                 add     al,#0x30
132                 call    putc
133                 call    say
134                 .ascii  " floppy drive"
135                 .byte   0
136                 mov     al,#'s
137                 dec     ah
138                 jz      flop3
139                 call    putc
140 flop3:          inc     ah
141                 call    say
142                 .ascii  " with BIOS support.\n"
143                 .byte   0
144
145 ; now probe for floppy drives
146
147                 mov     dl,#-1
148
149 fprobe:         mov     ah,#8
150                 inc     dl
151                 push    dx
152                 xor     cx,cx
153                 int     0x13
154                 pop     dx
155                 jc      fstop
156                 or      cx,cx
157                 jnz     fprobe
158
159 fstop:
160                 mov     ah,nflop
161                 cmp     ah,dl
162                 je      fdisplay
163                 call    say
164                 .ascii  "But probing has found "
165                 .byte   0
166                 mov     al,dl
167                 add     al,#'0
168                 call    putc
169                 call    say
170                 .ascii  "!!!\n"
171                 .byte   0
172                 cmp     ah,dl
173                 jae     fdisplay
174                 xchg    ah,dl
175
176 fdisplay:
177                 mov     dl,#0            ;start with drive 0x00
178                 xor     cx,cx
179                 mov     cl,ah
180                 jcxz    floppy1
181
182 floppy:         call    drive
183                 inc     dl
184                 loop    floppy
185 floppy1:
186                 mov     al,#10
187                 call    putc
188
189                 call    say
190                 .ascii  "There is "
191                 .byte   0
192                 int     0x12            ;get amount of low memory
193 ;;;       mov ax,#640 ;debug
194                 xor     dx,dx
195                 call    print
196                 call    say
197                 .ascii  "K of low memory"
198                 .byte   0
199                 mov     bx,#640
200                 sub     bx,ax
201                 jnz     ebda1
202                 call    say
203                 .ascii  " with no EBDA."
204                 .byte   0
205                 br      ebda2
206
207 ebda1:          push    ax
208                 mov     ax,bx
209                 xor     bx,bx
210                 call    say
211                 .ascii  ".    EBDA size = "
212                 .byte   0
213                 call    dec3
214                 call    say
215                 .ascii  "K   EBDA starts at 0x"
216                 .byte   0
217                 pop     ax
218                 mov     cl,#6
219                 shl     ax,cl
220                 call    wout
221                 call    say
222                 .ascii  "0"
223                 .byte   0
224 ebda2:
225                 call    say
226                 .ascii  "\n"
227                 .byte   0
228
229 ; post-floppy pause
230                 call    pause
231
232                 mov     ah,#0
233                 mov     dl,#0x80
234                 int     0x13
235                 mov     ah,#8
236                 int     0x13
237                 mov     ah,#0
238                 jc      nohard
239                 mov     ah,dl
240 nohard:         mov     nhard,ah
241                 call    say
242                 .ascii  "There "
243                 .byte   0
244                 dec     ah
245                 jz      hard1
246                 call    say
247                 .ascii  "are "
248                 .byte   0
249                 jmp     hard2
250 hard1:          call    say
251                 .ascii  "is "
252                 .byte   0
253 hard2:          inc     ah
254                 mov     al,ah
255                 add     al,#'0
256                 call    putc
257                 call    say
258                 .ascii  " hard drive"
259                 .byte   0
260                 mov     al,#'s
261                 dec     ah
262                 jz      hard3
263                 call    putc
264 hard3:          inc     ah
265                 call    say
266                 .ascii  " with BIOS support.\n"
267                 .byte   0
268
269 ; probe for hard drives
270
271                 mov     dl,#0x80-1
272
273 hprobe:         mov     ah,#8
274                 inc     dl
275                 push    dx
276                 xor     cx,cx
277                 int     0x13
278                 pop     dx
279                 jc      hstop
280                 or      cx,cx
281                 jnz     hprobe
282
283 hstop:
284                 and     dl,#0x7f
285                 mov     ah,nhard
286                 cmp     ah,dl
287                 je      hdisplay
288                 call    say
289                 .ascii  "But probing has found "
290                 .byte   0
291                 mov     al,dl
292                 add     al,#'0
293                 call    putc
294                 call    say
295                 .ascii  "!!!\n"
296                 .byte   0
297                 cmp     ah,dl
298                 jae     hdisplay
299                 xchg    ah,dl
300
301 hdisplay:
302
303
304
305
306                 mov     dl,#0x80         ;start with drive 0x80
307                 xor     cx,cx
308                 mov     cl,ah
309                 jcxz    hdd1
310 hard:           call    drive
311                 inc     dl
312                 loop    hard
313 hdd1:
314                 test    byte ptr bigflag,#0xFF
315                 jz      hdd2
316                 br      big
317 hdd2:           test    byte ptr bigcyl,#0xFF
318                 jz      hdd3
319                 br      big2
320 hdd3:                
321                 call    say
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"
326                 .ascii  "switch).\n"
327                 .byte   0
328                 br      exit
329
330
331 big:
332                 call    say
333                 .ascii  "\nYou have "
334                 .byte   0
335                 cmp     byte bigflag,#1
336                 je      noS
337                 call    say
338                 .ascii  "disks"
339                 .byte   0
340                 jmp     goOn
341 noS:            call    say
342                 .ascii  "a disk"
343                 .byte   0
344 goOn:           call    say
345                 .ascii  " bigger than 8.4Gb"
346                 .byte   0
347 big1c:          call    say
348                 .ascii  " with Enhanced BIOS support.\n"
349                 .ascii  "Using LILO with the 'lba32' global option"
350                 .ascii  " (or '-L' switch) is recommended.\n"
351                 .byte   0
352                 br      exit
353
354 big2:
355                 call    say
356                 .ascii  "\nYou have "
357                 .byte   0
358                 cmp     byte bigcyl,#1
359                 je      big2a
360                 call    say
361                 .ascii  "disks"
362                 .byte   0
363                 jmp     big2b
364 big2a:          call    say
365                 .ascii  "a disk"
366                 .byte   0
367 big2b:          call    say
368                 .ascii  " with more than 1023 cylinders"
369                 .byte   0
370                 br      big1c
371
372
373
374 nflop:          .byte      0
375 nhard:          .byte      0
376 bigflag:        .byte      0
377 bigcyl:         db      0
378 nlimit:         dd      1024*255*63, 0
379
380
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
384
385 inqedd:         push    ax
386                 push    bx
387                 push    dx
388                 push    si
389
390                 mov     ah,#0x41
391                 mov     bx,#0x55aa
392                 int     0x13
393                 jc      edd7
394                 cmp     bx,#0xaa55
395                 jne     edd7
396                 test    cl,#7
397                 stc
398                 jz      edd8
399                 lea     si,dparam
400                 mov     word (si),#dlth
401 ;;;     nop     ;spacer
402 ;;;     nop     ;spacer
403                 mov     dh,ah           ;save version number
404                 mov     ah,#0x48         ;get drive parameters
405                 int     0x13
406                 jc      edd7
407                 stc
408                 pop     ax              ;discard saved SI
409                 mov     (si+1),dh       ;save version info
410                 jmp     edd9            ;return SI, too
411              
412
413 edd7:           xor     cx,cx           ;carry is clear
414 edd8:           pop     si
415 edd9:           pop     dx
416                 pop     bx
417                 pop     ax
418                 ret
419
420
421 ; pause for the user to look at the screen
422
423 pause:          call    say
424                 .ascii  "Hit any key to continue..."
425                 .byte   0
426                 mov     ah,#0
427                 int     0x16
428                 call    say
429                 .ascii  "\r                           \n"
430                 .byte   0
431                 ret
432
433 ; print out the IBM BIOS drive parameters for the drive in DL
434
435 drive:          push    bp
436                 push    ax
437                 push    bx
438                 push    cx
439                 push    es
440                 push    di
441                 push    si
442                 push    dx
443
444                 call    say
445                 .ascii  "Drive 0x"
446                 .byte   0
447                 mov     al,dl
448                 call    bout
449                 call    say
450                 .ascii  "   Cyl:Head:Sec = "
451                 .byte   0
452
453                 mov     ah,#8
454                 int     0x13
455 #if DEBUG
456                 mov     cx,#0xFAFF
457                 mov     dh,#0xFF                ; 0xFE is the max.
458 #endif
459                 push    cx
460                 push    dx
461                 rol     cl,1
462                 mov     di,#1000
463                 rol     cl,1
464                 xor     bh,bh
465                 and     cl,#3
466                 xchg    ch,cl
467                 inc     cx
468                 mov     ax,cx
469                 xor     dx,dx
470                 div     di
471                 mov     bp,cx
472                 or      ax,ax
473                 jz      cyl2
474                 call    say
475                 .ascii  "1"
476                 .byte   0
477                 mov     bh,#0x80
478 cyl2:           xchg    ax,dx
479                 call    dec3
480                 call    punct
481                 pop     dx
482                 xor     ax,ax
483                 mov     al,dh
484                 xor     bh,bh
485                 inc     ax
486                 call    dec3
487                 mov     dx,ax
488                 call    punct
489 ;;;             pop     cx
490 ;;;             and     cl,#0x3F
491 ;;;             mov     al,cl
492                 pop     ax
493 #if 0
494 ; sectors = [1..63]
495                 and     ax,#0x3F
496 #else
497 ;; version 1.6
498 ;; avoid Davide bug:  Sectors == 0
499                 dec     ax
500                 and     ax,#0x3F
501                 inc     ax      ; now sectors = [1..64]
502 ;; version 1.6 end
503 #endif
504                 call    dec3
505                 call    say
506                 .ascii  " ("
507                 .byte   0
508 ;;;             mul     dl
509                 mul     dx
510                 mul     bp
511                 push    ds
512                 pop     es
513                 lea     di,ac0
514                 push    di
515                 stosw
516                 mov     ax,dx
517                 stosw
518                 xor     ax,ax
519                 stosw
520                 stosw
521                 pop     si
522                 call    dprint
523                 call    say
524                 .ascii  " sectors)  -->  "
525                 .byte   0
526
527                 call    sizeit
528
529                 call    say
530                 .byte   10,0
531
532                 pop     dx
533                 push    dx
534                 call    inqedd
535                 jc      xdd1
536                 br      xdd4
537 xdd1:
538                 call    say
539                 .ascii  "   EDD rev "
540                 .byte   0
541                 mov     al,(si+1)
542                 mov     cl,#4
543                 mov     ah,al
544                 shr     al,cl
545                 add     al,#'0
546                 call    putc
547                 mov     al,#'.
548                 call    putc
549                 mov     al,ah
550                 and     al,#0x0F
551                 add     al,#'0
552                 call    putc
553
554                 call    say
555                 .ascii  " geometry = "
556                 .byte   0
557                 test    byte (si+2),#2
558                 jz      xdd2
559                 mov     ax,(si+4)
560                 mov     dx,(si+6)
561                 or      dx,dx
562                 jnz     xdd1a
563                 cmp     ax,#1024
564                 jb      xdd1b
565 xdd1a:          inc     byte (bigcyl)
566 xdd1b:
567                 call    print
568                 call    punct
569                 mov     ax,(si+8)
570                 mov     dx,(si+10)
571                 call    print
572                 call    punct
573                 mov     ax,(si+12)
574                 mov     dx,(si+14)
575                 call    print
576                 call    say
577                 .ascii  " "
578                 .byte   0
579 xdd2:
580                 call    say
581                 .ascii  "("
582                 .byte   0
583                 lea     si,(si+16)
584                 call    dprint
585                 call    say
586                 .ascii  " sectors)  -->  "
587                 .byte   0
588                 mov     ax,(si+6)
589                 cmp     ax,nlimit+6
590                 jb      xdd3
591                 ja      xdd2a
592                 mov     ax,(si+4)
593                 cmp     ax,nlimit+4
594                 jb      xdd3
595                 ja      xdd2a
596                 mov     ax,(si+2)
597                 cmp     ax,nlimit+2
598                 jb      xdd3
599                 ja      xdd2a
600                 mov     ax,(si)
601                 cmp     ax,nlimit
602                 jb      xdd3
603 xdd2a:          inc     byte bigflag
604 xdd3:
605                 mov     dl,#1
606                 call    sizeit
607                 call    say
608                 .byte   10,0
609
610 xdd4:
611
612                 pop     dx
613                 pop     si
614                 pop     di
615                 pop     es
616                 pop     cx
617                 pop     bx
618                 pop     ax
619                 pop     bp
620                 ret
621
622 punct:          mov     al,#':
623                 call    putc
624                 ret
625
626 chars:          .ascii  " KMGTxyz"
627
628 sizeit:
629                 push    ax
630                 push    bx
631                 push    cx
632                 push    dx
633                 push    si      
634                 push    es
635                 push    di
636                 
637
638                 lea     bx,chars-1
639                 mov     di,si
640                 push    ds
641                 pop     es
642                 mov     ax,#512
643                 or      dx,dx
644                 jz      dpr5            ;handle small disks
645                 call    intmul
646                 jmp     dpr6
647 dpr5:           mov     ax,#2
648                 call    intdiv
649                 inc     bx
650
651 dpr6:           mov     ax,#1000
652                 lea     di,ac1
653 dpr7:           lea     bx,(bx+1)
654                 mov     cx,dx
655                 call    intdiv
656                 xchg    si,di
657                 jnz     dpr7
658
659                 mov     si,bx
660                 mov     ax,dx
661                 xor     bx,bx
662                 call    dec3
663                 cmp     byte ptr (si),#'K
664                 je      dpr8
665                 mov     al,#'.
666                 call    putc
667                 mov     ax,cx
668 #if 1
669                 mov     bx,#0x800a
670                 cmp     ax,#995
671                 jae     no_add
672                 add     ax,#5
673 no_add:
674                 div     bl
675                 xor     ah,ah
676                 div     bl
677                 add     al,#'0
678                 call    putc
679                 xchg    al,ah
680 #else
681                 mov     bx,#0x8000+100
682                 add     ax,#50
683                 div     bl
684 #endif
685                 add     al,#'0
686                 call    putc
687 dpr8:           mov     al,(si)
688                 call    putc
689
690                 pop     di
691                 pop     es
692                 pop     si
693                 pop     dx
694                 pop     cx
695                 pop     bx
696                 pop     ax
697                 ret
698 ; print the decimal double word number in DX:AX
699 ;
700 print:          push    ds
701                 push    si
702                 xor     si,si
703                 push    si
704                 push    si
705                 push    dx
706                 push    ax
707                 push    ss
708                 pop     ds
709                 mov     si,sp
710                 call    dprint
711                 lea     sp,(si+8)
712                 pop     si
713                 pop     ds
714                 ret
715
716
717 ; print the decimal quad-word number in [DS:SI]
718 ;
719 dprint:         push    ax
720                 push    bx
721                 push    dx
722                 push    es
723                 push    di
724                 push    ds
725                 push    si
726                 sub     sp,#8
727                 mov     di,sp
728                 push    ss
729                 pop     es
730                 xor     bx,bx
731                 mov     ax,#1000
732
733 dpr1:           inc     bx
734                 call    intdiv
735                 mov     si,di
736                 push    es
737                 pop     ds
738                 push    dx
739                 jnz     dpr1
740                 jmp     dpr3
741
742 dpr2:           mov     al,#',
743                 call    putc
744 dpr3:           pop     ax
745                 call    dec3
746                 mov     bh,#0x80
747                 dec     bl
748                 jnz     dpr2
749                 
750                 lea     sp,(di+8)
751                 pop     si
752                 pop     ds
753                 pop     di
754                 pop     es
755                 pop     dx
756                 pop     bx
757                 pop     ax
758                 ret
759
760
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
764
765 intmul:
766                 push    bp
767                 push    si
768                 push    di
769                 push    bx
770                 push    cx
771                 push    dx
772
773                 mov     cx,#4
774                 mov     bp,ax
775                 xor     dx,dx
776 im4:            mov     bx,dx
777                 lodsw
778                 mul     bp
779                 add     ax,bx
780                 adc     dx,#0
781 ;;;     nop     ;spacer
782                 stosw
783                 loop    im4
784
785                 mov     ax,dx
786                 pop     dx
787                 pop     cx
788                 pop     bx
789                 pop     di
790                 pop     si
791                 pop     bp
792                 ret
793                 
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
797
798 intdiv:         push    bx
799                 push    cx
800                 push    bp
801                 push    di
802                 push    si
803                 
804                 mov     cx,#4
805                 mov     bx,cx
806                 dec     bx
807                 add     bx,bx
808                 lea     si,(si+bx)
809                 lea     di,(di+bx)
810                 xor     dx,dx
811                 xor     bp,bp
812                 std
813                 mov     bx,ax
814 id2:            lodsw
815                 div     bx
816                 or      bp,ax           ;sets the Z flag
817                 stosw
818                 loop    id2
819                 cld
820                 mov     ax,bx
821
822                 pop     si
823                 pop     di
824                 pop     bp
825                 pop     cx
826                 pop     bx
827                 ret
828
829 ; write the number < 1000 in AX as 3 decimal digits
830 ; BH flags whether leading zeroes are printed (0x80=yes, 0=no)
831
832 dec3:           push    bx
833                 push    ax
834                 push    cx
835                 mov     cx,#2
836                 mov     bl,#100
837 dec32:          div     bl
838                 xor     al,bh
839                 jz      dec36
840                 xor     al,bh
841                 mov     bh,#0x80
842 dec34:          add     al,#'0
843                 call    putc
844                 mov     bh,#0x80
845 dec36:          mov     al,ah
846                 mov     ah,#0
847                 mov     bl,#10
848                 dec     cx
849                 jg      dec32
850                 jz      dec34
851                 pop     cx
852                 pop     ax
853                 pop     bx          
854                 ret
855
856 ; write the <nul> terminated string which follows the call
857 ; no registers altered
858
859 say:            push    bp
860                 mov     bp,sp
861                 push    ds
862                 push    si
863                 push    ax
864                 mov     si,(bp+2)
865                 push    cs
866                 pop     ds
867 say1:           lodsb
868                 or      al,al
869                 jz      say2
870                 call    putc
871                 jmp     say1
872 say2:           mov     (bp+2),si
873                 pop     ax
874                 pop     si
875                 pop     ds
876                 pop     bp
877                 ret
878
879 ; write the word in AX in hex
880 wout:           xchg    ah,al
881                 call    bout
882                 xchg    ah,al
883                 call    bout
884                 ret
885
886 ; write the byte in AL in hex
887 bout:           push    ax
888                 push    cx
889                 push    ax
890                 mov     cx,#0x204
891                 shr     al,cl
892 bout1:          add     al,#'0
893                 cmp     al,#'9
894                 jbe     bout2
895                 add     al,#'A-'0-10
896 bout2:          call    putc
897                 dec     ch
898                 jz      bout4
899                 pop     ax
900                 and     al,#0xF
901                 jmp     bout1
902 bout4:          pop     cx
903                 pop     ax
904                 ret
905
906
907 ; write the character in AL in teletype mode
908 ; all registers are preserved
909
910 putc:           push    bx
911                 push    ax
912                 mov     ah,#14
913                 xor     bh,bh
914                 cmp     al,#10           ;test for new-line
915                 jne     putc2
916                 mov     al,#13           ;get <cr>
917                 int     0x10
918                 mov     al,#10
919 putc2:          int     0x10
920                 pop     ax
921                 pop     bx
922                 ret
923
924 #define LILO_ASM
925 #include "lilo.h"
926 #include "read.S"
927 #include "bdata.h"
928 #define BD_VERBOSE
929 #include "biosdata.S"
930
931 exit:           mov     ax,cs
932                 mov     dx,ds
933                 cmp     ax,dx
934                 jae     bd_test
935 exit_dos:       mov     ax,#0x4c00
936                 int     0x21
937
938 bd_test:
939                 call    pause
940                 call    say
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..."
945                 .byte   0
946                 mov     ah,#0
947                 int     0x16
948                 call    say
949                 .byte   10,10,0
950                 cmp     al,#0x1b        ; <ESC>
951                 je      bd_test_skip
952
953 #if 1
954                 mov     ax,cs
955                 mov     bx,#SYSSEG
956                 cmp     ax,bx
957                 jae     collect
958                 mov     es,bx
959                 mov     di,#theend-1
960                 std
961                 lea     cx,(di+1)
962                 mov     si,di
963                 rep
964                   movsb
965                 mov     ss,bx
966                 mov     ds,bx
967                 cld
968                 push    es
969                 push    #collect
970                 retf
971 collect:
972 #endif
973
974                 mov     dx,dx_save              ; DX passed in on boot
975                 call    io_biosdata
976
977                 call    say
978                 .ascii  "\nALL OKAY\n\n"
979                 .byte   0
980
981 bd_test_skip:
982                 call    say
983                 .ascii  "Remove the floppy disk from the drive.\n"
984                 .ascii  "Hit any key to reboot..."
985                 .byte   0
986                 mov     ah,#0
987                 int     0x16
988                 call    say
989                 .byte      10,10,10,0
990 bs_helper:      int     0x19                    ;label here for kludge
991
992
993 id_string:      .ascii  "Disk.Com"
994                 .byte   0
995
996
997 ac0:            .word      0,0,0,0
998 ac1:            .word      0,0,0,0
999
1000 dparam:         .word      dlth
1001 dflags:         .word      0
1002 dcyl:           dd      0
1003 dhead:          dd      0
1004 dsec:           dd      0
1005 dsecs:          dd      0,0
1006 ssize:          .word   0
1007 dptp:           dd      0
1008 dlthe:
1009 dlth            =     dlthe-dparam
1010 modelist:
1011
1012 theend: