]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2005-07-17 Yoshinori Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Sun, 17 Jul 2005 14:57:07 +0000 (14:57 +0000)
committerokuji <okuji@localhost>
Sun, 17 Jul 2005 14:57:07 +0000 (14:57 +0000)
* boot/i386/pc/boot.S (boot_drive_check): New label.

* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_DRIVE_CHECK): New
macro.

* util/i386/pc/grub-setup.c (setup): Added a workaround for BIOSes
which do not pass a boot drive correctly. Copied from GRUB Legacy.

ChangeLog
boot/i386/pc/boot.S
include/grub/i386/pc/boot.h
util/i386/pc/grub-setup.c

index 63a4c859932433b8dbe0b24f36ca42a7945a9cfd..e1aa12fdcfbc868cd419fb03ad0e6a35aada0f87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-07-17  Yoshinori Okuji  <okuji@enbug.org>
+
+       * boot/i386/pc/boot.S (boot_drive_check): New label.
+
+       * include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_DRIVE_CHECK): New
+       macro.
+
+       * util/i386/pc/grub-setup.c (setup): Added a workaround for BIOSes
+       which do not pass a boot drive correctly. Copied from GRUB Legacy.
+
 2005-07-17  Yoshinori Okuji  <okuji@enbug.org>
 
        * kern/i386/pc/startup.S (gate_a20_try_system_control_port_a):
index 2e2aaf51418a143d5c2cae6d380050a504f6f33d..0d7f4279def412759f169da4c8454df4dc5f6043 100644 (file)
@@ -1,7 +1,7 @@
 /* -*-Asm-*- */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002   Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2005   Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -108,6 +108,21 @@ after_BPB:
 /* general setup */
        cli             /* we're not safe here! */
 
+        /*
+         * This is a workaround for buggy BIOSes which don't pass boot
+         * drive correctly. If GRUB is installed into a HDD, check if
+         * DL is masked correctly. If not, assume that the BIOS passed
+         * a bogus value and set DL to 0x80, since this is the only
+         * possible boot drive. If GRUB is installed into a floppy,
+         * this does nothing (only jump).
+         */
+boot_drive_check:
+        jmp     1f
+        testb   $0x80, %dl
+        jnz     1f
+        movb    $0x80, %dl
+1:
+       
        /*
         * ljmp to the next instruction because some bogus BIOSes
         * jump to 07C0:0000 instead of 0000:7C00.
index a9e9e9800e0d60cf68c8b50f4968934542c1cbdc..967b499f14f372537753cc42c79d24f08c75dea1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2002   Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2002,2005   Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -47,6 +47,9 @@
 /* The offset of KERNEL_SEGMENT.  */
 #define GRUB_BOOT_MACHINE_KERNEL_SEGMENT       0x48
 
+/* The offset of BOOT_DRIVE_CHECK.  */
+#define GRUB_BOOT_MACHINE_DRIVE_CHECK  0x4b
+
 /* The offset of a magic number used by Windows NT.  */
 #define GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC     0x1b8
 
index 91e0d52b40c83097074b87209e61ad33c0d7e7c3..01d25a7fa8fc78667f63e25d38b539ffc8a6588e 100644 (file)
@@ -1,7 +1,7 @@
 /* grub-setup.c - make GRUB usable */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
  *
  *  GRUB is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -86,6 +86,7 @@ setup (const char *prefix, const char *dir,
   grub_device_t root_dev, dest_dev;
   grub_uint8_t *boot_drive;
   grub_uint32_t *kernel_sector;
+  grub_uint16_t *boot_drive_check;
   struct boot_blocklist *first_block, *block;
   grub_int32_t *install_dos_part, *install_bsd_part;
   char *install_prefix;
@@ -168,10 +169,12 @@ setup (const char *prefix, const char *dir,
   boot_img = grub_util_read_image (boot_path);
   free (boot_path);
 
-  /* Set the addresses of BOOT_DRIVE and KERNEL_SECTOR.  */
+  /* Set the addresses of BOOT_DRIVE, KERNEL_SECTOR and BOOT_DRIVE_CHECK.  */
   boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE);
   kernel_sector = (grub_uint32_t *) (boot_img
                                     + GRUB_BOOT_MACHINE_KERNEL_SECTOR);
+  boot_drive_check = (grub_uint16_t *) (boot_img
+                                       + GRUB_BOOT_MACHINE_DRIVE_CHECK);
   
   core_path = grub_util_get_path (dir, core_file);
   core_size = grub_util_get_image_size (core_path);
@@ -228,6 +231,13 @@ setup (const char *prefix, const char *dir,
 
   free (tmp_img);
   
+  /* If DEST_DRIVE is a hard disk, enable the workaround, which is
+     for buggy BIOSes which don't pass boot drive correctly. Instead,
+     they pass 0x00 or 0x01 even when booted from 0x80.  */
+  if (dest_dev->disk->id & 0x80)
+    /* Replace the jmp (2 bytes) with double nop's.  */
+    *boot_drive_check = 0x9090;
+  
   /* If the destination device can have partitions and it is the MBR,
      try to embed the core image into after the MBR.  */
   if (dest_dev->disk->has_partitions && ! dest_dev->disk->partition)