Hi

appended is a patch to stage 1 code. It removes a dependency on code
generation by the assembler,
and thus, eases maintainance of the code.

Wolf Lammen

-- 
GMX ProMail (250 MB Mailbox, 50 FreeSMS, Virenschutz, 2,99 EUR/Monat...)
jetzt 3 Monate GRATIS + 3x DER SPIEGEL +++ http://www.gmx.net/derspiegel +++
This is the forth in a series of patches that removes a bug and some glitches
from GRUB stage 1. This is against grub-0.94 (alpha), my first three patches
applied.

Submitted by Wolf Lammen, ookami1<at>gmx<dot>de

I looked through the complete code of stage 1 and found some oddities.
This patch addresses one: makes boot_drive_mask a variable at a fixed location.
Impact: increases code by 1 byte, eases maintainance of the code.

Use this patch together with stage1.S.patch.4. See that file contains for
more information.

--- stage1.h    2004-02-09 06:27:23.000000000 +0100
+++ stage1.h.new        2004-02-09 06:41:36.000000000 +0100
@@ -39,8 +39,8 @@
 /* The offset of BOOT_DRIVE.  */
 #define STAGE1_BOOT_DRIVE      0x40
 
-/* The offset of FORCE_LBA.  */
-#define STAGE1_FORCE_LBA       0x41
+/* The offset of BOOT_DRIVE_MASK.  */
+#define STAGE1_BOOT_DRIVE_MASK 0x41
 
 /* The offset of STAGE2_ADDRESS.  */
 #define STAGE1_STAGE2_ADDRESS  0x42
@@ -51,8 +51,8 @@
 /* The offset of STAGE2_SEGMENT.  */
 #define STAGE1_STAGE2_SEGMENT  0x48
 
-/* The offset of BOOT_DRIVE_MASK.  */
-#define STAGE1_BOOT_DRIVE_MASK 0x54
+/* The offset of FORCE_LBA.  */
+#define STAGE1_FORCE_LBA       0x49
 
 /* The offset of a magic number used by Windows NT.  */
 #define STAGE1_WINDOWS_NT_MAGIC        0x1b8
This is the forth in a series of patches that removes a bug and some glitches
from GRUB stage 1. This is against grub-0.94 (alpha), my first three patches
applied.

Submitted by Wolf Lammen, ookami1<at>gmx<dot>de

I looked through the complete code of stage 1 and found some oddities.
This patch addresses one: makes boot_drive_mask a variable at a fixed location.
Impact: increases code by 1 byte, eases maintainance of the code.

Details: Currently, the GRUB installer writes the value of boot_drive_mask
(corrects buggy BIOSes which do not supply the HDD_FLAG) directly into the
mid of an instruction. This method has its clear downsides:
1. Whenever somebody modifies the stage1.S code, s/he has to look whether the
compiler moved the patch location and s/he has to keep stage1.h adjusted, all
done by hand. For instance, I always had to compile stage 1 alone, make a
hex dump from the produced code to see where the patch location moved, edit
stage1.h to adjust the address for boot_drive_mask, and then compile the
package again. These are obviously some steps too much.
2. It is difficult to maintain orthogonal patches, because if both move the
patch location, they interfere with each other.
3. This is not a standard procedure, so programmers not familiar with GRUB
may easily overlook a necessary adjusting of stage1.h.

Instead of patching an instruction, make boot_drive_mask an ordinary variable
at a fixed location and let's have the compiler do what it is build for:
provide the hex math and address calculation.

This patch comes along with another one patching stage1.h. Use them both.

--- stage1.S    2004-02-09 06:27:23.000000000 +0100
+++ stage1.S.new        2004-02-09 06:42:12.000000000 +0100
@@ -93,14 +93,19 @@
 boot_drive:    
        .byte 0xff      /* the disk to load stage2 from */
                        /* 0xff means use the boot drive */
-force_lba:
-       .byte   0
+boot_drive_mask:
+       .byte 0         /* workaround for buggy BIOSes that */
+                       /* do not pass the drive number */
+                       /* correctly. If GRUB is installed */
+                       /* on a HDD, set this to 0x80, else 0 */
 stage2_address:
        .word   0x8000
 stage2_sector:
        .long   1
 stage2_segment:
        .word   0x800
+force_lba:
+       .byte   0
 
 after_BPB:
 
@@ -112,15 +117,7 @@
        movw    $STAGE1_STACKSEG, %sp
        sti             /* just in case the BIOS or a chainloader disabled interrupts 
*/
 
-
-       /*
-        * This is a workaround for buggy BIOSes which don't pass boot
-        * drive correctly. If GRUB is installed into a HDD, do
-        * "orb $0x80, %dl", otherwise "orb $0x00, %dl" (i.e. nop).
-        */
-       .byte   0x80, 0xca
-boot_drive_mask:
-       .byte   0x00
+       orb ABS(boot_drive_mask), %dl /* workaround for buggy BIOSes */
 
        /*
         * ljmp to the next instruction because some bogus BIOSes
_______________________________________________
Bug-grub mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-grub

Reply via email to