bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "grub" command works, but GRUB boot loader hangs


From: Ben Liblit
Subject: Re: "grub" command works, but GRUB boot loader hangs
Date: Tue, 28 Aug 2001 23:06:04 -0700

>From earlier discussions in this thread we have concluded that
get_diskinfo_floppy() should go away.  Attached below is a proposed
patch to remove it.

I've also reorganized the tail end of get_diskinfo() to unify the floppy
and non-floppy calls to get_diskinfo_standard(), which previously were
in distinct branches of a conditional.  Someone should give that a
second look before checking it in to make sure that I haven't done
something boneheaded to the control flow.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/grub/grub/ChangeLog,v
retrieving revision 1.429
diff -u -u -r1.429 ChangeLog
--- ChangeLog   2001/08/08 08:00:01     1.429
+++ ChangeLog   2001/08/29 05:58:15
@@ -1,3 +1,12 @@
+2001-08-28  OKUJI Yoshinori  <address@hidden>
+
+       From Ben Liblit  <address@hidden>
+       * stage2/bios.c (get_diskinfo): Do not call get_diskinfo_floppy to
+       get information on floppy drives.  It confuses some BIOSes, and we
+       seem to be able to get everything we need by simply calling
+       get_diskinfo_standard instead.
+       * stage2/asm.S (get_diskinfo_floppy): Removed.
+
 2001-08-08  OKUJI Yoshinori  <address@hidden>
 
        From Derrik Pates <address@hidden>:
Index: stage2/asm.S
===================================================================
RCS file: /cvsroot/grub/grub/stage2/asm.S,v
retrieving revision 1.57
diff -u -u -r1.57 asm.S
--- stage2/asm.S        2001/08/08 08:00:01     1.57
+++ stage2/asm.S        2001/08/29 05:58:18
@@ -1221,91 +1221,6 @@
        ret
 
                
-/*
- *   int get_diskinfo_floppy (int drive, unsigned long *cylinders, 
- *                            unsigned long *heads, unsigned long *sectors)
- *
- *   Return the geometry of DRIVE in CYLINDERS, HEADS and SECTORS. If an
- *   error occurs, then return non-zero, otherwise zero.
- */
-
-ENTRY(get_diskinfo_floppy)
-       pushl   %ebp
-       movl    %esp, %ebp
-
-       pushl   %ebx
-       pushl   %esi
-
-       /* drive */
-       movb    0x8(%ebp), %dl
-       /* enter real mode */
-       call    EXT_C(prot_to_real)
-
-       .code16
-       /* init probe value */
-       movl    $probe_values-1, %esi
-1:
-       xorw    %ax, %ax
-       int     $0x13           /* reset floppy controller */
-
-       incw    %si
-       movb    (%si), %cl
-       cmpb    $0, %cl         /* probe failed if zero */
-       je      2f
-
-       /* perform read */
-       movw    $SCRATCHSEG, %ax
-       movw    %ax, %es
-       xorw    %bx, %bx
-       movw    $0x0201, %ax
-       movb    $0, %ch
-       movb    $0, %dh
-       int     $0x13
-
-       /* FIXME: Read from floppy may fail even if the geometry is correct.
-          So should retry at least three times.  */
-       jc      1b              /* next value */
-       
-       /* succeed */
-       jmp     2f
-       
-probe_values:
-       .byte   36, 18, 15, 9, 0
-       
-2:
-       /* back to protected mode */
-       DATA32  call    EXT_C(real_to_prot)
-       .code32
-
-       /* restore %ebp */
-       leal    0x8(%esp), %ebp
-       
-       /* cylinders */
-       movl    0xc(%ebp), %eax
-       movl    $80, %ebx
-       movl    %ebx, (%eax)
-       /* heads */
-       movl    0x10(%ebp), %eax
-       movl    $2, %ebx
-       movl    %ebx, (%eax)
-       /* sectors */
-       movl    0x14(%ebp), %eax
-       movzbl  %cl, %ebx
-       movl    %ebx, (%eax)
-
-       /* return value in %eax */
-       xorl    %eax, %eax
-       cmpb    $0, %cl
-       jne     3f
-       incl    %eax            /* %eax = 1 (non-zero) */
-3:
-       popl    %esi
-       popl    %ebx
-       popl    %ebp
-
-       ret
-
-
 /* Source files are splitted, as they have different copyrights.  */
 #ifndef STAGE1_5
 # include "setjmp.S"
Index: stage2/bios.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/bios.c,v
retrieving revision 1.12
diff -u -u -r1.12 bios.c
--- stage2/bios.c       2000/12/13 17:11:19     1.12
+++ stage2/bios.c       2001/08/29 05:58:19
@@ -33,10 +33,6 @@
                                  unsigned long *cylinders,
                                  unsigned long *heads,
                                  unsigned long *sectors);
-extern int get_diskinfo_floppy (int drive,
-                               unsigned long *cylinders,
-                               unsigned long *heads,
-                               unsigned long *sectors);
 
 
 /* Read/write NSEC sectors starting from SECTOR in DRIVE disk with GEOMETRY
@@ -123,6 +119,7 @@
 get_diskinfo (int drive, struct geometry *geometry)
 {
   int err;
+  unsigned long total_sectors = 0;
 
   /* Clear the flags.  */
   geometry->flags = 0;
@@ -131,7 +128,6 @@
     {
       /* hard disk */
       int version;
-      unsigned long total_sectors = 0;
       
       version = check_int13_extensions (drive);
       if (version)
@@ -187,47 +183,24 @@
                total_sectors = drp.cylinders * drp.heads * drp.sectors;
            }
        }
+    }
 
-      /* Don't pass GEOMETRY directly, but pass each element instead,
+  /* Don't pass GEOMETRY directly, but pass each element instead,
         so that we can change the structure easily.  */
-      err = get_diskinfo_standard (drive,
-                                  &geometry->cylinders,
-                                  &geometry->heads,
-                                  &geometry->sectors);
-      if (err)
-       return err;
+  err = get_diskinfo_standard (drive,
+                              &geometry->cylinders,
+                              &geometry->heads,
+                              &geometry->sectors);
+  if (err)
+    return err;
 
-      if (! total_sectors)
-       {
-         total_sectors = (geometry->cylinders
-                          * geometry->heads
-                          * geometry->sectors);
-       }
-      geometry->total_sectors = total_sectors;
-    }
-  else
+  if (! total_sectors)
     {
-      /* floppy disk */
-
-      /* First, try INT 13 AH=8h call.  */
-      err = get_diskinfo_standard (drive,
-                                  &geometry->cylinders,
-                                  &geometry->heads,
-                                  &geometry->sectors);
-
-      /* If fails, then try floppy-specific probe routine.  */
-      if (err)
-       err = get_diskinfo_floppy (drive,
-                                  &geometry->cylinders,
-                                  &geometry->heads,
-                                  &geometry->sectors);
-      if (err)
-       return err;
-
-      geometry->total_sectors = (geometry->cylinders
-                                * geometry->heads
-                                * geometry->sectors);
+      total_sectors = (geometry->cylinders
+                      * geometry->heads
+                      * geometry->sectors);
     }
+  geometry->total_sectors = total_sectors;
 
   return 0;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]