Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GjqS6-0006lS-2X for mharc-grub-devel@gnu.org; Tue, 14 Nov 2006 00:03:18 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GjqS5-0006kz-5Z for grub-devel@gnu.org; Tue, 14 Nov 2006 00:03:17 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GjqS1-0006jL-LY for grub-devel@gnu.org; Tue, 14 Nov 2006 00:03:15 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GjqS1-0006jI-Gi for grub-devel@gnu.org; Tue, 14 Nov 2006 00:03:13 -0500 Received: from [66.249.82.235] (helo=wx-out-0506.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GjqS0-0000Za-Rt for grub-devel@gnu.org; Tue, 14 Nov 2006 00:03:13 -0500 Received: by wx-out-0506.google.com with SMTP id t10so1536029wxc for ; Mon, 13 Nov 2006 21:03:12 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=CKgpYAN8aSLvLicxqkqv5EnsezubdFZqwpMilxBD2kHXFFIKDJs/4H3Qog5jVWbU0csExPH95hx3l1nTUrHFI041e3l29YtxOcsezQdN4oTaa5UMjqUQIN5LJJvwKn2ub7YgOWsyjcgvrkcok1CKloA+QAFrQPqZrQiZAoCzi2c= Received: by 10.90.78.1 with SMTP id a1mr540226agb.1163480592073; Mon, 13 Nov 2006 21:03:12 -0800 (PST) Received: by 10.90.31.7 with HTTP; Mon, 13 Nov 2006 21:03:12 -0800 (PST) Message-ID: Date: Tue, 14 Nov 2006 13:03:12 +0800 From: "Zhixu Liu" To: "The development of GRUB 2" In-Reply-To: <1163475639.30879.25.camel@diesel> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_82320_7800760.1163480592041" References: <1163475639.30879.25.camel@diesel> Cc: GuangXu Liu Subject: Re: does disk geometry depend on partition table? X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2006 05:03:17 -0000 ------=_Part_82320_7800760.1163480592041 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Hollis, We've tried something like this, and found it works for some platform, but still failed for one platform. Indeed, in this weird platform, we get both wrong CHS value with and without partition table. But the OS always get the correct value. The problem is due to either BIOS or Disk for this particular platform, we think. But we're not clear. Anyway, the patch works for some cases, and should for most cases. Best regards! Zhixu On 11/14/06, Hollis Blanchard wrote: > > On Mon, 2006-11-06 at 17:07 +0800, Zhixu Liu wrote: > > Hi, all, > > > > We encounter a strange problem recently. In short, following is the > > output of geometry of > > hd0 in situation with correct partition in disk and without partition > > in disk. > > When with correct partition table in disk hd0: > > > > grub> geometry (hd0) > > drive 0x80: C/H/S = 500/16/32, The number of sectors = 256000, LBA > > > > When without partition table in disk hd0: > > grub> geometry (hd0) > > drive 0x80: C/H/S = 126/32/63, The number of sectors = 256000, LBA > > > > The former is correct! However, it's strange that the disk geometry > > depend on the partition table?! > > Maybe this is due to a buggy BIOS implementation. We also check the > > code in disk/i386/pc/biosdisk.c > > or (stage2/bios.c) for grub-0.97, and for code in function > > grub_biosdisk_open (or get_diskinfo in grub-0.97), > > there is a standard int13 check of disk after check with ext int13, > > > > if(drive & 0x80) { > > ... > > version = grub_biosdisk_check_int13_extension(); > > if(version) { > > grub_biosdisk_get_diskinfo_int13_extensions(); > > } > > } > > > > grub_biosdisk_get_diskinfo_standard() > > > > We're wondering does it really need to call > > grub_biosdisk_get_diskinfo_standard() again if we have get the > > necessary information > > from ext int13? I think we call the later only if ext int13 failed for > > some reason. Especially in our case the code should be . > > > > if(drive & 0x80) { > > ... > > version = grub_biosdisk_check_int13_extension(); > > if(version) { > > grub_biosdisk_get_diskinfo_int13_extensions(); > > } else { > > grub_biosdisk_get_diskinfo_standard() > > } > > } > > > > and it do works! > > Thanks for your report, Zhixu. Does this patch work? > > Index: disk/i386/pc/biosdisk.c > =================================================================== > RCS file: /cvsroot/grub/grub2/disk/i386/pc/biosdisk.c,v > retrieving revision 1.9 > diff -u -p -r1.9 biosdisk.c > --- disk/i386/pc/biosdisk.c 29 Jul 2006 10:11:01 -0000 1.9 > +++ disk/i386/pc/biosdisk.c 14 Nov 2006 03:39:47 -0000 > @@ -133,21 +133,24 @@ grub_biosdisk_open (const char *name, gr > } > } > > - if (grub_biosdisk_get_diskinfo_standard (drive, > - &data->cylinders, > - &data->heads, > - &data->sectors) != 0) > + if (! total_sectors) > { > - grub_free (data); > - return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values"); > - } > + /* FDD, or HDD without int13 extensions. */ > + if (grub_biosdisk_get_diskinfo_standard (drive, > + &data->cylinders, > + &data->heads, > + &data->sectors) != 0) > + { > + grub_free (data); > + return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S > values"); > + } > > - if (! total_sectors) > - total_sectors = data->cylinders * data->heads * data->sectors; > + total_sectors = data->cylinders * data->heads * data->sectors; > + } > > disk->total_sectors = total_sectors; > disk->data = data; > - > + > return GRUB_ERR_NONE; > } > > > -Hollis > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > -- Zhixu Liu ------=_Part_82320_7800760.1163480592041 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Hollis,

We've tried something like this, and found it works for some platform, but still failed for one platform.
Indeed, in this weird platform, we get both wrong CHS value with and without partition table. But the OS always
get the correct value. The problem is due to either BIOS or Disk for this particular platform, we think. But we're not clear.

Anyway, the patch works for some cases, and should for most cases.

Best regards!

Zhixu

On 11/14/06, Hollis Blanchard <hollis@penguinppc.org> wrote:
On Mon, 2006-11-06 at 17:07 +0800, Zhixu Liu wrote:
> Hi, all,
>
> We encounter a strange problem recently. In short, following is the
> output of geometry of
> hd0 in situation with correct partition in disk and without partition
> in disk.
> When with correct partition table in disk hd0:
>
>     grub> geometry (hd0)
>     drive 0x80: C/H/S = 500/16/32, The number of sectors = 256000, LBA
>
> When without partition table in disk hd0:
>     grub> geometry (hd0)
>     drive 0x80: C/H/S = 126/32/63, The number of sectors = 256000, LBA
>
> The former is correct! However, it's strange that the disk geometry
> depend on the partition table?!
> Maybe this is due to a buggy BIOS implementation. We also check the
> code in disk/i386/pc/biosdisk.c
> or (stage2/bios.c) for grub-0.97, and for code in function
> grub_biosdisk_open (or get_diskinfo in grub-0.97),
> there is a standard int13 check of disk after check with ext int13,
>
>   if(drive & 0x80) {
>      ...
>     version = grub_biosdisk_check_int13_extension();
>       if(version) {
>          grub_biosdisk_get_diskinfo_int13_extensions();
>       }
>    }
>
>    grub_biosdisk_get_diskinfo_standard()
>
> We're wondering does it really need to call
> grub_biosdisk_get_diskinfo_standard() again if we have get the
> necessary information
> from ext int13? I think we call the later only if ext int13 failed for
> some reason. Especially in our case the code should be .
>
>   if(drive & 0x80) {
>      ...
>     version = grub_biosdisk_check_int13_extension();
>       if(version) {
>          grub_biosdisk_get_diskinfo_int13_extensions();
>       } else {
>          grub_biosdisk_get_diskinfo_standard()
>       }
>    }
>
> and it do works!

Thanks for your report, Zhixu. Does this patch work?

Index: disk/i386/pc/biosdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/disk/i386/pc/biosdisk.c,v
retrieving revision 1.9
diff -u -p -r1.9 biosdisk.c
--- disk/i386/pc/biosdisk.c     29 Jul 2006 10:11:01 -0000      1.9
+++ disk/i386/pc/biosdisk.c     14 Nov 2006 03:39:47 -0000
@@ -133,21 +133,24 @@ grub_biosdisk_open (const char *name, gr
        }
     }

-  if (grub_biosdisk_get_diskinfo_standard (drive,
-                                          &data->cylinders,
-                                          &data->heads,
-                                          &data->sectors) != 0)
+  if (! total_sectors)
     {
-      grub_free (data);
-      return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
-    }
+      /* FDD, or HDD without int13 extensions.  */
+      if (grub_biosdisk_get_diskinfo_standard (drive,
+                                              &data->cylinders,
+                                              &data->heads,
+                                              &data->sectors) != 0)
+       {
+         grub_free (data);
+         return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
+       }

-  if (! total_sectors)
-    total_sectors = data->cylinders * data->heads * data->sectors;
+      total_sectors = data->cylinders * data->heads * data->sectors;
+    }

   disk->total_sectors = total_sectors;
   disk->data = data;
-
+
   return GRUB_ERR_NONE;
}


-Hollis



_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel



--
Zhixu Liu ------=_Part_82320_7800760.1163480592041--