]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-02-03 Yoshinori K. Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Sun, 3 Feb 2008 18:56:08 +0000 (18:56 +0000)
committerokuji <okuji@localhost>
Sun, 3 Feb 2008 18:56:08 +0000 (18:56 +0000)
    Add support for having a grub directory in a different drive. This
    is still only the data handling part.

    * kern/i386/pc/startup.S (multiboot_trampoline): Set %dh to 0xFF.
    (codestart): Save %dh in GRUB_ROOT_DRIVE.
    (grub_root_drive): New variable.

    * kern/i386/pc/init.c (make_install_device): Use GRUB_ROOT_DRIVE
    instead of GRUB_BOOT_DRIVE to construct a device name. Set
    GRUB_ROOT_DRIVE to GRUB_BOOT_DRIVE if it is 0xFF, otherwise use it
    as it was.

    * include/grub/i386/pc/kernel.h (grub_root_drive): New prototype.

    * include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_ROOT_DRIVE): New
    macro.
    (GRUB_BOOT_MACHINE_DRIVE_CHECK): Set to 0x4f.

    * boot/i386/pc/pxeboot.S (_start): Set %dh to 0xFF. For now, this
    is bogus, because PXE booting does not specify any drive
    correctly.

    * boot/i386/pc/lnxboot.S (reg_edx): Set the second byte to 0xFF. I
    am not sure if this is really correct.

    * boot/i386/pc/cdboot.S: Set %dh to 0xFF, because the root drive
    is always identical to the boot drive when booting from a CD.

    * boot/i386/pc/boot.S (MOV_MEM_TO_AL): Removed. Not needed any
    longer.
    (root_drive): New variable.
    (real_start): Unconditionally set %dh to ROOT_DRIVE.
    (setup_sectors): Push %dx right after popping it, because %dh will
    be modified later.
    (copy_buffer): Restore %dx.

ChangeLog
boot/i386/pc/boot.S
boot/i386/pc/cdboot.S
boot/i386/pc/lnxboot.S
boot/i386/pc/pxeboot.S
include/grub/i386/pc/boot.h
include/grub/i386/pc/kernel.h
kern/i386/pc/init.c
kern/i386/pc/startup.S

index 5450e7b57ba4afcb91b2a285cd73e60a85a04c41..c7075d68184c73a58e84d88043b53cf8dc759e92 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2008-02-03  Yoshinori K. Okuji  <okuji@enbug.org>
+
+       Add support for having a grub directory in a different drive. This
+       is still only the data handling part.
+       
+       * kern/i386/pc/startup.S (multiboot_trampoline): Set %dh to 0xFF.
+       (codestart): Save %dh in GRUB_ROOT_DRIVE.
+       (grub_root_drive): New variable.
+
+       * kern/i386/pc/init.c (make_install_device): Use GRUB_ROOT_DRIVE
+       instead of GRUB_BOOT_DRIVE to construct a device name. Set
+       GRUB_ROOT_DRIVE to GRUB_BOOT_DRIVE if it is 0xFF, otherwise use it
+       as it was.
+
+       * include/grub/i386/pc/kernel.h (grub_root_drive): New prototype.
+
+       * include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_ROOT_DRIVE): New
+       macro.
+       (GRUB_BOOT_MACHINE_DRIVE_CHECK): Set to 0x4f.
+
+       * boot/i386/pc/pxeboot.S (_start): Set %dh to 0xFF. For now, this
+       is bogus, because PXE booting does not specify any drive
+       correctly.
+
+       * boot/i386/pc/lnxboot.S (reg_edx): Set the second byte to 0xFF. I
+       am not sure if this is really correct.
+
+       * boot/i386/pc/cdboot.S: Set %dh to 0xFF, because the root drive
+       is always identical to the boot drive when booting from a CD.
+
+       * boot/i386/pc/boot.S (MOV_MEM_TO_AL): Removed. Not needed any
+       longer.
+       (root_drive): New variable.
+       (real_start): Unconditionally set %dh to ROOT_DRIVE.
+       (setup_sectors): Push %dx right after popping it, because %dh will
+       be modified later.
+       (copy_buffer): Restore %dx.
+
 2008-02-03  Robert Millan  <rmh@aybabtu.com>
 
        * util/i386/pc/grub-mkrescue.in: Rewrite most of image generation to
index 187b7d2d49be144c214b888a0c461176c8e51b2c..64d40c8fba20d02758e2c6d0da468a44d7914c77 100644 (file)
@@ -32,9 +32,6 @@
        /* Print message string */
 #define MSG(x) movw $ABS(x), %si; call message
 
-       /* XXX: binutils-2.9.1.0.x doesn't produce a short opcode for this. */
-#define        MOV_MEM_TO_AL(x)        .byte 0xa0;  .word x
-       
        .file   "boot.S"
 
        .text
@@ -99,6 +96,8 @@ kernel_sector:
 boot_drive:    
        .byte 0xff      /* the disk to load kernel from */
                        /* 0xff means use the boot drive */
+root_drive:
+        .byte 0xff
 
 after_BPB:
 
@@ -141,7 +140,9 @@ real_start:
        /*
         *  Check if we have a forced disk reference here
         */
-       MOV_MEM_TO_AL(ABS(boot_drive))  /* movb ABS(boot_drive), %al */
+        /* assign root_drive at the same time */
+        movw    ABS(boot_drive), %ax
+        movb    %ah, %dh
        cmpb    $0xff, %al
        je      1f
        movb    %al, %dl
@@ -303,6 +304,7 @@ setup_sectors:
 
        /* restore %dl */
        popw    %dx
+        pushw   %dx
 
        /* head start */
        movb    %al, %dh
@@ -353,6 +355,7 @@ copy_buffer:
 
        popw    %ds
        popa
+        popw    %dx
 
        /* boot kernel */
        jmp     *(kernel_address)
index 61ef84ee9ad5e8a4fa7387797a7990733f44de01..1709b8c89990e7be64152a6acdca71eb6bbff7a4 100644 (file)
@@ -78,6 +78,9 @@ bi_reserved:
 
        call    read_cdrom
 
+        /* Root drive will default to boot drive */
+        movb    $0xFF, %dh
+        
        ljmp    $(DATA_ADDR >> 4), $0
 
 /*
index 6a4de8dd5b811d4e99ab4ce5d8199389646e33ee..2a913ba9c4e7021b4a1cf5595c0fd16d39064e3b 100644 (file)
@@ -115,7 +115,7 @@ gdt_dst2:
        .long   0, 0, 0, 0              /* More space for the BIOS.  */
 
 reg_edx:
-       .byte   0x80,0,0xFF,0xFF
+       .byte   0x80, 0xFF, 0xFF, 0xFF
 
 data_leng:
        .long   0
index 8c547733ae4aa0915cd5845e40d654a9debbe1be..7f2a143965fa7dfe52ab354c3af6a08ec1d8a646 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2000,2005,2007   Free Software Foundation, Inc.
+ *  Copyright (C) 2000,2005,2007,2008   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
@@ -25,6 +25,9 @@
        /* Let's go */
 .globl _start; _start:
 
+        /* Root drive will default to boot drive */
+        movb    $0xFF, %dh
+        
        /* Jump to the real world */
        ljmp    $0, $0x8200
 
index fcc961b1abd4a6371c7552116a6b0a981b61899c..3862214146e614fb6cd30c88db6b97b59e218245 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2002,2005,2006,2007   Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2002,2005,2006,2007,2008   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
@@ -34,6 +34,9 @@
 /* The offset of BOOT_DRIVE.  */
 #define GRUB_BOOT_MACHINE_BOOT_DRIVE   0x4c
 
+/* The offset of ROOT_DRIVE.  */
+#define GRUB_BOOT_MACHINE_ROOT_DRIVE   0x4d
+
 /* The offset of KERNEL_ADDRESS.  */
 #define GRUB_BOOT_MACHINE_KERNEL_ADDRESS       0x40
 
@@ -44,7 +47,7 @@
 #define GRUB_BOOT_MACHINE_KERNEL_SEGMENT       0x42
 
 /* The offset of BOOT_DRIVE_CHECK.  */
-#define GRUB_BOOT_MACHINE_DRIVE_CHECK  0x4e
+#define GRUB_BOOT_MACHINE_DRIVE_CHECK  0x4f
 
 /* The offset of a magic number used by Windows NT.  */
 #define GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC     0x1b8
index ca16df788e6dfb05c98e51518f48da6852f7fe46..848dad10d75f25b01c7869b63614e7c824c4f2e6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003,2007  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2003,2007,2008  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
@@ -73,6 +73,9 @@ extern char grub_prefix[];
 /* The boot BIOS drive number.  */
 extern grub_int32_t grub_boot_drive;
 
+/* The root BIOS drive number.  */
+extern grub_int32_t grub_root_drive;
+
 /* The end address of the kernel.  */
 extern grub_addr_t grub_end_addr;
 
index 908e2d79108488aa1ea50594a529bd2738a1a5c0..72374929cd8b252b1c217b149de57021236f998f 100644 (file)
@@ -72,13 +72,18 @@ make_install_device (void)
     }
   else if (grub_install_dos_part != -2)
     {
-      if (grub_boot_drive >= GRUB_BIOSDISK_MACHINE_CDROM_START)
+      /* If the root drive is not set explicitly, assume that it is identical
+         to the boot drive.  */
+      if (grub_root_drive == 0xFF)
+        grub_root_drive = grub_boot_drive;
+      
+      if (grub_root_drive >= GRUB_BIOSDISK_MACHINE_CDROM_START)
         grub_sprintf (dev, "(cd%u",
-                     grub_boot_drive - GRUB_BIOSDISK_MACHINE_CDROM_START);
+                     grub_root_drive - GRUB_BIOSDISK_MACHINE_CDROM_START);
       else
         grub_sprintf (dev, "(%cd%u",
-                     (grub_boot_drive & 0x80) ? 'h' : 'f',
-                     grub_boot_drive & 0x7f);
+                     (grub_root_drive & 0x80) ? 'h' : 'f',
+                     grub_root_drive & 0x7f);
       
       if (grub_install_dos_part >= 0)
        grub_sprintf (dev + grub_strlen (dev), ",%u", grub_install_dos_part + 1);
index 0bfe2b37db9f6f087c270d1da09b2683b0e3db8e..0a38b994c9d5c580ad1673ebba3711a7c3536949 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007 Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 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
@@ -162,6 +162,7 @@ multiboot_trampoline:
        movl    %ebx, EXT_C(grub_install_bsd_part)
 2:
        shrl    $24, %edx
+        movb    $0xFF, %dh
        /* enter the usual booting */
        call    prot_to_real
        .code16
@@ -182,8 +183,9 @@ codestart:
 
        sti             /* we're safe again */
 
-       /* save boot drive reference */
+       /* save boot and root drive references */
        ADDR32  movb    %dl, EXT_C(grub_boot_drive)
+       ADDR32  movb    %dh, EXT_C(grub_root_drive)
 
        /* reset disk system (%ah = 0) */
        int     $0x13
@@ -255,6 +257,9 @@ codestart:
 VARIABLE(grub_boot_drive)
        .long   0
 
+VARIABLE(grub_root_drive)
+       .long   0
+
 VARIABLE(grub_start_addr)
        .long   START_SYMBOL