bug-grub
[Top][All Lists]
Advanced

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

EZ-BIOS support


From: Jochen Hoenicke
Subject: EZ-BIOS support
Date: Mon, 30 Oct 2000 12:12:03 +0100 (MET)

Hello,

There was a bug report from Ning Ma recently, that turned out to be
caused by EZ-BIOS.  I researched what EZ-BIOS does and how grub must
be changed, so they work flawlessly together.

EZ-BIOS installs itself into the MBR in a transparent way: It backups
the MBR to the next sector, and puts its own code into the MBR and to
the remaining space after the MBR.  The EZ-BIOS code installs a INT13
handler that, besides other things, remaps all accesses to the MBR to
its backup copy.  Linux will do a similar remapping, so that fdisk
works.

The effect is, that you can still put anything you want into the MBR,
but you must not use the space after the MBR.  GRUB fails on the
second point.

The attached patch will detect if EZ-BIOS is present, and refuses to
embed grub after the MBR in that case.  The patch will look for a
signature at the begin of the EZ-BIOS code.  Since the remapping is a
bit inpredictable for the first few sectors, it will look for this
signature in two places.

If nobody argues, I will check it in.

  Jochen

diff -u -r1.96 builtins.c
--- builtins.c  2000/10/25 14:35:49     1.96
+++ builtins.c  2000/10/28 11:26:57
@@ -962,6 +962,7 @@
       /* Embed it after the MBR.  */
       
       char mbr[SECTOR_SIZE];
+      char ezbios_check[2*SECTOR_SIZE];
 
       /* No floppy has MBR.  */
       if (! (current_drive & 0x80))
@@ -984,6 +985,23 @@
       /* Check if the disk can store the Stage 1.5.  */
       if (PC_SLICE_START (mbr, 0) - 1 < size)
        {
+         errnum = ERR_DEV_VALUES;
+         return 1;
+       }
+
+      /* Check for EZ-BIOS signature. It should be in the third
+       * sector, but due to remapping it can appear in the second, so
+       * load and check both.  
+       */
+      if (! rawread (current_drive, 1, 0, 2 * SECTOR_SIZE, ezbios_check))
+       return 1;
+
+      if (! memcmp (ezbios_check + 3, "AERMH", 5)
+         || ! memcmp (ezbios_check + 512 + 3, "AERMH", 5))
+       {
+         /* The space after the MBR is used by EZ-BIOS which we must 
+          * not overwrite.
+          */
          errnum = ERR_DEV_VALUES;
          return 1;
        }




reply via email to

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