How to debug 'out of disk' error.
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
So any suggestions on how to go about debuagging this? Or even any ideas why grub would give such an error.
Signature · 1 line
Len Sorensen
Quoted 8 lines · Lennart Sorensen
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
ls -l should show how big it thinks the disk is. Compare it with its real size
Quoted 7 lines
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
Looks like int13 is borked. Perhaps it's borked in a way which prevents GRUB from detecting 13/42 function. You can try to force int13/42 by:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +2 -0
@@ -145,6 +145,8 @@ { struct grub_bios_int_registers regs; + return 1; + regs.edx = drive & 0xff; regs.eax = 0x4100; regs.ebx = 0x55aa;
Quoted 4 lines
So any suggestions on how to go about debuagging this? Or even any ideas why grub would give such an error.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 24 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 8 lines · Lennart Sorensen
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
ls -l should show how big it thinks the disk is. Compare it with its real size
Quoted 7 lines
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
Looks like int13 is borked. Perhaps it's borked in a way which prevents GRUB from detecting 13/42 function. You can try to force int13/42 by:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 line 152
Quoted 8 lines
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +2
-0@@ -145,6 +145,8 @@ { struct grub_bios_int_registers regs; + return 1; + regs.edx = drive & 0xff; regs.eax = 0x4100; regs.ebx = 0x55aa;
OK, the code in 1.98(plus some git stuff) that is in debian uses assembly code for that part. I changed the place calling it instead and added some debug info.
When running from linux, the diskinfo bios call returns a total_sectors of 4352 sectors, for an 80G drive. That's just messed up. I haven't tried booting it yet to see if it returns the same value then, but I suspect it will.
Signature · 1 line
Len Sorensen
Quoted 43 lines · Lennart Sorensen
Quoted 29 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Lennart Sorensen
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
ls -l should show how big it thinks the disk is. Compare it with its real size
Quoted 8 lines
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
Looks like int13 is borked. Perhaps it's borked in a way which prevents GRUB from detecting 13/42 function. You can try to force int13/42 by:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 line 152
Quoted 8 lines
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +2
-0@@ -145,6 +145,8 @@ { struct grub_bios_int_registers regs; + return 1; + regs.edx = drive & 0xff; regs.eax = 0x4100; regs.ebx = 0x55aa;OK, the code in 1.98(plus some git stuff) that is in debian uses assembly code for that part. I changed the place calling it instead and added some debug info.
Quoted 6 lines
When running from linux, the diskinfo bios call returns a
total_sectorsof 4352 sectors, for an 80G drive. That's just messed up. I haven't tried booting it yet to see if it returns the same value then, but I suspect it will.
Following change would make GRUB ignore the total_sectors (as an investigation measure):
@@ -398,7 +400,7 @@
total_sectors = data->cylinders * data->heads * data->sectors;
}- disk->total_sectors = total_sectors;
+ disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
disk->data = data;
return GRUB_ERR_NONE;
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 24 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 8 lines · Lennart Sorensen
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
ls -l should show how big it thinks the disk is. Compare it with its real size
Quoted 7 lines
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
Looks like int13 is borked. Perhaps it's borked in a way which prevents GRUB from detecting 13/42 function. You can try to force int13/42 by:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 line 152
Quoted 8 lines
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +2
-0@@ -145,6 +145,8 @@ { struct grub_bios_int_registers regs; + return 1; + regs.edx = drive & 0xff; regs.eax = 0x4100; regs.ebx = 0x55aa;
So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
Signature · 1 line
len Sorensen
Quoted 47 lines · Lennart Sorensen
Quoted 29 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Lennart Sorensen
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
ls -l should show how big it thinks the disk is. Compare it with its real size
Quoted 8 lines
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
Looks like int13 is borked. Perhaps it's borked in a way which prevents GRUB from detecting 13/42 function. You can try to force int13/42 by:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 line 152
Quoted 8 lines
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +2
-0@@ -145,6 +145,8 @@ { struct grub_bios_int_registers regs; + return 1; + regs.edx = drive & 0xff; regs.eax = 0x4100; regs.ebx = 0x55aa;So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>
Quoted 5 lines
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
Could you post the debug code you added?
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 8 lines · Lennart Sorensen
So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>
Quoted 6 lines
Quoted 5 lines
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
Could you post the debug code you added?
I will try. I am currently having an argument with the quilt patch system debian's grub package is using.
Here is the modified biosdisk.c I am using (slightly changed since the above was done).
Signature · 1 line
Len Sorensen
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRUB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/machine/biosdisk.h>
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/mm.h>
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/term.h>
static int cd_drive = 0;
static intgrub_biosdisk_get_drive (const char *name)
{
unsigned long drive;
if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd')
goto fail;
drive = grub_strtoul (name + 2, 0, 10);
if (grub_errno != GRUB_ERR_NONE)
goto fail;
if (name[0] == 'h')
drive += 0x80;
return (int) drive ; fail:
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a biosdisk"); return -1;
}
static intgrub_biosdisk_call_hook (int (*hook) (const char *name), int drive) {
char name[10];
grub_snprintf (name, sizeof (name),
(drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80));
return hook (name);
}
static intgrub_biosdisk_iterate (int (*hook) (const char *name)) {
int drive;
int num_floppies;
/* For hard disks, attempt to read the MBR. */
for (drive = 0x80; drive < 0x90; drive++)
{
if (grub_biosdisk_rw_standard (0x02, drive, 0, 0, 1, 1,
GRUB_MEMORY_MACHINE_SCRATCH_SEG) != 0)
{
grub_dprintf ("disk", "Read error when probing drive 0x%2x\n", drive);
break;
}
if (grub_biosdisk_call_hook (hook, drive))
return 1;
} if (cd_drive)
{
if (grub_biosdisk_call_hook (hook, cd_drive))
return 1;
} /* For floppy disks, we can get the number safely. */ num_floppies = grub_biosdisk_get_num_floppies (); for (drive = 0; drive < num_floppies; drive++)
if (grub_biosdisk_call_hook (hook, drive))
return 1;
return 0;
}
static grub_err_tgrub_biosdisk_open (const char *name, grub_disk_t disk) {
grub_uint64_t total_sectors = 0;
int drive;
struct grub_biosdisk_data *data;
drive = grub_biosdisk_get_drive (name);
if (drive < 0)
return grub_errno;
disk->has_partitions = cd_drive ? (drive != cd_drive) : 1;
disk->id = drive;
data = (struct grub_biosdisk_data *) grub_zalloc (sizeof (*data));
if (! data)
return grub_errno;
data->drive = drive;
if ((cd_drive) && (drive == cd_drive))
{
data->flags = GRUB_BIOSDISK_FLAG_LBA | GRUB_BIOSDISK_FLAG_CDROM;
data->sectors = 32;
/* TODO: get the correct size. */
total_sectors = GRUB_DISK_SIZE_UNKNOWN;
}
else if (drive & 0x80)
{
/* HDD */
int version; grub_printf ("Checking int13_extensions.\n");
version = grub_biosdisk_check_int13_extensions (drive);
grub_printf ("...version=%d.\n",version);
if (!version)
{
version = 1;
}
if (version)
{
struct grub_biosdisk_drp *drp
= (struct grub_biosdisk_drp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
/* Clear out the DRP. */
grub_memset (drp, 0, sizeof (*drp));
drp->size = sizeof (*drp);
if (! grub_biosdisk_get_diskinfo_int13_extensions (drive, drp))
{
data->flags = GRUB_BIOSDISK_FLAG_LBA;
if (drp->total_sectors)
{
total_sectors = drp->total_sectors;
grub_printf ("total_sectors (C=%u H=%u S=%u)=%llu.\n",drp->cylinders,drp->heads,drp->sectors,total_sectors);
}
else
{
/* Some buggy BIOSes doesn't return the total sectors
correctly but returns zero. So if it is zero, compute
it by C/H/S returned by the LBA BIOS call. */
total_sectors = drp->cylinders * drp->heads * drp->sectors;
grub_printf ("total_sectors (buggy bios) (C=%u H=%u S=%u)=%llu.\n",drp->cylinders,drp->heads,drp->sectors,total_sectors);
}
}
}
} if (! (data->flags & GRUB_BIOSDISK_FLAG_CDROM))
{
if (grub_biosdisk_get_diskinfo_standard (drive,
&data->cylinders,
&data->heads,
&data->sectors) != 0)
{
if (total_sectors && (data->flags & GRUB_BIOSDISK_FLAG_LBA))
{
data->sectors = 63;
data->heads = 255;
data->cylinders
= grub_divmod64 (total_sectors
+ data->heads * data->sectors - 1,
data->heads * data->sectors, 0);
}
else
{
grub_free (data);
return grub_error (GRUB_ERR_BAD_DEVICE, "%s cannot get C/H/S values", disk->name);
}
}
if (! total_sectors)
total_sectors = data->cylinders * data->heads * data->sectors;
}disk->total_sectors = total_sectors; disk->data = data;
return GRUB_ERR_NONE;
}
static voidgrub_biosdisk_close (grub_disk_t disk)
{
grub_free (disk->data);
}
/* For readability. */
#define GRUB_BIOSDISK_READ 0
#define GRUB_BIOSDISK_WRITE 1
#define GRUB_BIOSDISK_CDROM_RETRY_COUNT 3
static grub_err_tgrub_biosdisk_rw (int cmd, grub_disk_t disk,
grub_disk_addr_t sector, grub_size_t size, unsigned segment)
{
struct grub_biosdisk_data *data = disk->data;
if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
{
struct grub_biosdisk_dap *dap; dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
+ (data->sectors
<< GRUB_DISK_SECTOR_BITS));
dap->length = sizeof (*dap);
dap->reserved = 0;
dap->blocks = size;
dap->buffer = segment << 16; /* The format SEGMENT:ADDRESS. */
dap->block = sector;
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
{
int i;
if (cmd)
return grub_error (GRUB_ERR_WRITE_ERROR, "can\'t write to cdrom");
dap->blocks = ALIGN_UP (dap->blocks, 4) >> 2;
dap->block >>= 2;
for (i = 0; i < GRUB_BIOSDISK_CDROM_RETRY_COUNT; i++)
if (! grub_biosdisk_rw_int13_extensions (0x42, data->drive, dap))
break;
if (i == GRUB_BIOSDISK_CDROM_RETRY_COUNT)
return grub_error (GRUB_ERR_READ_ERROR, "cdrom read error");
}
else
if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap))
{
/* Fall back to the CHS mode. */
data->flags &= ~GRUB_BIOSDISK_FLAG_LBA;
grub_printf ("Falling back to CHS\n");
disk->total_sectors = data->cylinders * data->heads * data->sectors;
return grub_biosdisk_rw (cmd, disk, sector, size, segment);
}
}
else
{
unsigned coff, hoff, soff;
unsigned head;
grub_printf ("CHS=%d,%d,%d\n",data->cylinders,data->heads,data->sectors);
/* It is impossible to reach over 8064 MiB (a bit less than LBA24) with
the traditional CHS access. */
if (sector >
1024 /* cylinders */ *
256 /* heads */ *
63 /* spt */)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk(1)", disk->name);
soff = ((grub_uint32_t) sector) % data->sectors + 1;
head = ((grub_uint32_t) sector) / data->sectors;
hoff = head % data->heads;
coff = head / data->heads;
if (coff >= data->cylinders)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk(2)", disk->name);
if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
coff, hoff, soff, size, segment))
{
switch (cmd)
{
case GRUB_BIOSDISK_READ:
return grub_error (GRUB_ERR_READ_ERROR, "%s read error", disk->name);
case GRUB_BIOSDISK_WRITE:
return grub_error (GRUB_ERR_WRITE_ERROR, "%s write error", disk->name);
}
}
} return GRUB_ERR_NONE;
}
/* Return the number of sectors which can be read safely at a time. */ static grub_size_tget_safe_sectors (grub_disk_addr_t sector, grub_uint32_t sectors) {
grub_size_t size;
grub_uint32_t offset;
/* OFFSET = SECTOR % SECTORS */ grub_divmod64 (sector, sectors, &offset); size = sectors - offset;
/* Limit the max to 0x7f because of Phoenix EDD. */ if (size > 0x7f)
size = 0x7f;
return size;
}
static grub_err_tgrub_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
struct grub_biosdisk_data *data = disk->data;
while (size)
{
grub_size_t len;
grub_size_t cdoff = 0; len = get_safe_sectors (sector, data->sectors);
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
{
cdoff = (sector & 3) << GRUB_DISK_SECTOR_BITS;
len = ALIGN_UP (sector + len, 4) - (sector & ~3);
sector &= ~3;
}
if (len > size)
len = size;
if (grub_biosdisk_rw (GRUB_BIOSDISK_READ, disk, sector, len,
GRUB_MEMORY_MACHINE_SCRATCH_SEG))
return grub_errno;
grub_memcpy (buf, (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + cdoff),
len << GRUB_DISK_SECTOR_BITS);
buf += len << GRUB_DISK_SECTOR_BITS;
sector += len;
size -= len;
} return grub_errno;
}
static grub_err_tgrub_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, const char *buf)
{
struct grub_biosdisk_data *data = disk->data;
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
return grub_error (GRUB_ERR_IO, "can't write to CDROM");
while (size)
{
grub_size_t len; len = get_safe_sectors (sector, data->sectors);
if (len > size)
len = size;
grub_memcpy ((void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR, buf,
len << GRUB_DISK_SECTOR_BITS);
if (grub_biosdisk_rw (GRUB_BIOSDISK_WRITE, disk, sector, len,
GRUB_MEMORY_MACHINE_SCRATCH_SEG))
return grub_errno;
buf += len << GRUB_DISK_SECTOR_BITS;
sector += len;
size -= len;
} return grub_errno;
}
static struct grub_disk_dev grub_biosdisk_dev =
{
.name = "biosdisk",
.id = GRUB_DISK_DEVICE_BIOSDISK_ID,
.iterate = grub_biosdisk_iterate,
.open = grub_biosdisk_open,
.close = grub_biosdisk_close,
.read = grub_biosdisk_read,
.write = grub_biosdisk_write,
.next = 0
};
static voidgrub_disk_biosdisk_fini (void)
{
grub_disk_dev_unregister (&grub_biosdisk_dev);
}
GRUB_MOD_INIT(biosdisk)
{
struct grub_biosdisk_cdrp *cdrp
= (struct grub_biosdisk_cdrp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
if (grub_disk_firmware_is_tainted)
{
grub_printf ("Firmware is marked as tainted, refusing to initialize.\n");
return;
}
grub_disk_firmware_fini = grub_disk_biosdisk_fini;
grub_memset (cdrp, 0, sizeof (*cdrp));
cdrp->size = sizeof (*cdrp);
cdrp->media_type = 0xFF;
if ((! grub_biosdisk_get_cdinfo_int13_extensions (grub_boot_drive, cdrp)) &&
((cdrp->media_type & GRUB_BIOSDISK_CDTYPE_MASK)
== GRUB_BIOSDISK_CDTYPE_NO_EMUL))
cd_drive = cdrp->drive_no; grub_disk_dev_register (&grub_biosdisk_dev);
}
GRUB_MOD_FINI(biosdisk)
{
grub_disk_biosdisk_fini ();
}
Quoted 11 lines · Lennart Sorensen
So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
What does the partition table look like? It doesn't extend beyond sector 156312575 does it?
Also I wonder about why H=16. It should be 255.
Quoted 9 lines · Phillip Susi
Quoted 8 lines · Lennart Sorensen
So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>
Quoted 8 lines
Quoted 3 lines
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
What does the partition table look like? It doesn't extend beyond sector 156312575 does it?
Also I wonder about why H=16. It should be 255.
Well usually it should, but not always.
Here is the partition table:
Disk /dev/sda: 80.0 GB, 80032038912 bytes
255 heads, 63 sectors/track, 9730 cylinders, total 156312576 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004a073
Device Boot Start End Blocks Id System /dev/sda1 * 2048 152350719 76174336 83 Linux /dev/sda2 152352766 156311551 1979393 5 Extended /dev/sda5 152352768 156311551 1979392 82 Linux swap / Solaris
Signature · 1 line
Len Sorensen
Quoted 30 lines · Lennart Sorensen
Quoted 9 lines · Phillip Susi
Quoted 8 lines · Lennart Sorensen
So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>Quoted 8 lines
Quoted 3 lines
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
What does the partition table look like? It doesn't extend beyond sector 156312575 does it?
Also I wonder about why H=16. It should be 255.
Well usually it should, but not always.
Here is the partition table:
Disk
/dev/sda: 80.0 GB, 80032038912 bytes
255 heads, 63 sectors/track, 9730 cylinders, total 156312576 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x0004a073
Quoted 4 lines
Device Boot Start End Blocks Id System /dev/sda1 * 2048 152350719 76174336 83 Linux /dev/sda2 152352766 156311551 1979393 5 Extended /dev/sda5 152352768 156311551 1979392 82 Linux swap / Solaris
I have now determined that the call to grub_biosdisk_rw_int13_extensions fails here:
if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap))
{
/* Fall back to the CHS mode. */
data->flags &= ~GRUB_BIOSDISK_FLAG_LBA;
disk->total_sectors = data->cylinders * data->heads * data->sectors;
return grub_biosdisk_rw (cmd, disk, sector, size, segment);
}Then LBA gets disabled, and access beyond CHS range is gone, and the error about 'out of disk' happens.
Signature · 1 line
Len Sorensen
Quoted 50 lines · Lennart Sorensen
Quoted 32 lines · Lennart Sorensen
Quoted 10 lines · Phillip Susi
Quoted 8 lines · Lennart Sorensen
So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>Quoted 9 lines
Quoted 4 lines
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
What does the partition table look like? It doesn't extend beyond sector 156312575 does it?
Also I wonder about why H=16. It should be 255.
Well usually it should, but not always.
Here is the partition table:
Disk
/dev/sda: 80.0 GB, 80032038912 bytes
255 heads, 63 sectors/track, 9730 cylinders, total 156312576 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x0004a073Quoted 5 lines
Device Boot Start End Blocks Id System /dev/sda1 * 2048 152350719 76174336 83 Linux /dev/sda2 152352766 156311551 1979393 5 Extended /dev/sda5 152352768 156311551 1979392 82 Linux swap / SolarisI have now determined that the call to
grub_biosdisk_rw_int13_extensionsfails here:if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap)) { /* Fall back to the CHS mode. */ data->flags &= ~GRUB_BIOSDISK_FLAG_LBA; disk->total_sectors = data->cylinders * data->heads * data->sectors; return grub_biosdisk_rw (cmd, disk, sector, size, segment); }
Quoted 4 lines
Then LBA gets disabled, and access beyond CHS range is gone, and the error about 'out of disk' happens.
Following may help:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'
disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +3 -0
@@ -80,6 +80,9 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + return (regs.eax >> 8) & 0xff; }
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 line 87
Quoted 13 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Following may help:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +3
-0@@ -80,6 +80,9 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + return (regs.eax >> 8) & 0xff; }
I now got this:
GRUB loading.
Welcome to GRUB!
int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag int13_ext fixup due to CARRY flag
Failed int13_ext call: ah=42, drive=80, dap= 6fe00 returned eax=8000
error: hd0 out of disk. Entering rescue mode...
grub rescue>
I am now using 1.99-rc1. Here is the biosdisk.c with my changes.
Signature · 1 line
Len Sorensen
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRUB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/machine/biosdisk.h> #include <grub/machine/kernel.h> #include <grub/machine/memory.h> #include <grub/machine/int.h> #include <grub/disk.h> #include <grub/dl.h>
#include <grub/mm.h>
#include <grub/types.h> #include <grub/misc.h> #include <grub/err.h> #include <grub/term.h>
static int cd_drive = 0;
static int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap);
static int grub_biosdisk_get_num_floppies (void) {
struct grub_bios_int_registers regs; int drive;
/* reset the disk system first */
regs.eax = 0;
regs.edx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
for (drive = 0; drive < 2; drive++)
{
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT | GRUB_CPU_INT_FLAGS_CARRY;
regs.edx = drive; /* call GET DISK TYPE */
regs.eax = 0x1500;
grub_bios_interrupt (0x13, ®s);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
break;
/* check if this drive exists */
if (!(regs.eax & 0x300))
break;
} return drive;
}
/*
* Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP * is passed for disk address packet. If an error occurs, return * non-zero, otherwise zero.
*/
static intgrub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) {
int ret;
struct grub_bios_int_registers regs;
regs.eax = ah << 8;
/* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4; regs.esi = (((grub_addr_t) dap) & 0xffff);
regs.edx = drive;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
ret = (regs.eax >> 8) & 0xff;
if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY))
{
grub_printf ("int13_ext fixup due to CARRY flag\n");
ret = 0;
}
if (ret)
{
grub_printf ("Failed int13_ext call: ah=%x, drive=%x, dap=%8x returned eax=%x\n", ah, drive, (grub_addr_t) dap, regs.eax);
}
//else
//{
//grub_printf ("Successful int13_ext call: ah=%x, drive=%x, dap=%8x returned eax=%x\n", ah, drive, (grub_addr_t) dap, regs.eax);
//} return ret;
}
/*
* Call standard and old INT13 (int 13 %ah=AH) for DRIVE. Read/write * NSEC sectors from COFF/HOFF/SOFF into SEGMENT. If an error occurs, * return non-zero, otherwise zero.
*/
static intgrub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
int soff, int nsec, int segment)
{
int ret, i;
/* Try 3 times. */
for (i = 0; i < 3; i++)
{
struct grub_bios_int_registers regs; /* set up CHS information */
/* set %ch to low eight bits of cylinder */
regs.ecx = (coff << 8) & 0xff00;
/* set bits 6-7 of %cl to high two bits of cylinder */
regs.ecx |= (coff >> 2) & 0xc0;
/* set bits 0-5 of %cl to sector */
regs.ecx |= soff & 0x3f;
/* set %dh to head and %dl to drive */
regs.edx = (drive & 0xff) | ((hoff << 8) & 0xff00);
/* set %ah to AH */
regs.eax = (ah << 8) & 0xff00;
/* set %al to NSEC */
regs.eax |= nsec & 0xff;
regs.ebx = 0;
regs.es = segment;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
/* check if successful */
if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY))
return 0;
/* save return value */
ret = regs.eax >> 8;
/* if fail, reset the disk system */
regs.eax = 0;
regs.edx = (drive & 0xff);
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
} return ret;
}
/*
* Check if LBA is supported for DRIVE. If it is supported, then return
* the major version of extensions, otherwise zero.
*/
static int grub_biosdisk_check_int13_extensions (int drive) {
struct grub_bios_int_registers regs;
regs.edx = drive & 0xff; regs.eax = 0x4100; regs.ebx = 0x55aa; regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
return 0;
if ((regs.ebx & 0xffff) != 0xaa55)
return 0;
/* check if AH=0x42 is supported */ if (!(regs.ecx & 1))
return 0;
return (regs.eax >> 8) & 0xff;
}
/*
* Return the geometry of DRIVE in CYLINDERS, HEADS and SECTORS. If an
* error occurs, then return non-zero, otherwise zero.
*/
static intgrub_biosdisk_get_diskinfo_standard (int drive,
unsigned long *cylinders, unsigned long *heads, unsigned long *sectors)
{
struct grub_bios_int_registers regs;
regs.eax = 0x0800;
regs.edx = drive & 0xff;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
/* Check if unsuccessful. Ignore return value if carry isn't set to
workaround some buggy BIOSes. */
if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
return (regs.eax & 0xff00) >> 8; /* bogus BIOSes may not return an error number */ /* 0 sectors means no disk */
if (!(regs.ecx & 0x3f))
/* XXX 0x60 is one of the unused error numbers */
return 0x60; /* the number of heads is counted from zero */
*heads = ((regs.edx >> 8) & 0xff) + 1;
*cylinders = (((regs.ecx >> 8) & 0xff) | ((regs.ecx << 2) & 0x0300)) + 1; *sectors = regs.ecx & 0x3f;
return 0;
}
static intgrub_biosdisk_get_diskinfo_real (int drive, void *drp, grub_uint16_t ax) {
struct grub_bios_int_registers regs;
regs.eax = ax;
/* compute the address of drive parameters */
regs.esi = ((grub_addr_t) drp) & 0xf;
regs.ds = ((grub_addr_t) drp) >> 4;
regs.edx = drive & 0xff;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
/* Check if unsuccessful. Ignore return value if carry isn't set to
workaround some buggy BIOSes. */
if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
return (regs.eax & 0xff00) >> 8; return 0;
}
/*
* Return the cdrom information of DRIVE in CDRP. If an error occurs,
* then return non-zero, otherwise zero.
*/
static intgrub_biosdisk_get_cdinfo_int13_extensions (int drive, void *cdrp) {
return grub_biosdisk_get_diskinfo_real (drive, cdrp, 0x4b01);
}
/*
* Return the geometry of DRIVE in a drive parameters, DRP. If an error
* occurs, then return non-zero, otherwise zero.
*/
static intgrub_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp) {
return grub_biosdisk_get_diskinfo_real (drive, drp, 0x4800);
}
static intgrub_biosdisk_get_drive (const char *name) {
unsigned long drive;
if (name[0] == 'c' && name[1] == 'd' && name[2] == 0 && cd_drive)
return cd_drive;
if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd')
goto fail;
drive = grub_strtoul (name + 2, 0, 10);
if (grub_errno != GRUB_ERR_NONE)
goto fail;
if (name[0] == 'h')
drive += 0x80;
return (int) drive ; fail:
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a biosdisk"); return -1;
}
static intgrub_biosdisk_call_hook (int (*hook) (const char *name), int drive) {
char name[10];
if (cd_drive && drive == cd_drive)
return hook ("cd"); grub_snprintf (name, sizeof (name),
(drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80));
return hook (name);
}
static intgrub_biosdisk_iterate (int (*hook) (const char *name)) {
int drive;
int num_floppies;
/* For hard disks, attempt to read the MBR. */ for (drive = 0x80; drive < 0x90; drive++)
{
if (grub_biosdisk_rw_standard (0x02, drive, 0, 0, 1, 1,
GRUB_MEMORY_MACHINE_SCRATCH_SEG) != 0)
{
grub_dprintf ("disk", "Read error when probing drive 0x%2x\n", drive);
break;
}
if (grub_biosdisk_call_hook (hook, drive))
return 1;
} if (cd_drive)
{
if (grub_biosdisk_call_hook (hook, cd_drive))
return 1;
} /* For floppy disks, we can get the number safely. */ num_floppies = grub_biosdisk_get_num_floppies (); for (drive = 0; drive < num_floppies; drive++)
if (grub_biosdisk_call_hook (hook, drive))
return 1;
return 0;
}
static grub_err_tgrub_biosdisk_open (const char *name, grub_disk_t disk) {
grub_uint64_t total_sectors = 0;
int drive;
struct grub_biosdisk_data *data;
drive = grub_biosdisk_get_drive (name);
if (drive < 0)
return grub_errno;
disk->id = drive;
data = (struct grub_biosdisk_data *) grub_zalloc (sizeof (*data));
if (! data)
return grub_errno;
data->drive = drive;
if ((cd_drive) && (drive == cd_drive))
{
data->flags = GRUB_BIOSDISK_FLAG_LBA | GRUB_BIOSDISK_FLAG_CDROM;
data->sectors = 32;
/* TODO: get the correct size. */
total_sectors = GRUB_DISK_SIZE_UNKNOWN;
}
else
{
/* HDD */
int version; version = grub_biosdisk_check_int13_extensions (drive);
if (version)
{
struct grub_biosdisk_drp *drp
= (struct grub_biosdisk_drp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
/* Clear out the DRP. */
grub_memset (drp, 0, sizeof (*drp));
drp->size = sizeof (*drp);
if (! grub_biosdisk_get_diskinfo_int13_extensions (drive, drp))
{
data->flags = GRUB_BIOSDISK_FLAG_LBA;
if (drp->total_sectors)
total_sectors = drp->total_sectors;
else
/* Some buggy BIOSes doesn't return the total sectors
correctly but returns zero. So if it is zero, compute
it by C/H/S returned by the LBA BIOS call. */
total_sectors = drp->cylinders * drp->heads * drp->sectors;
}
}
} if (! (data->flags & GRUB_BIOSDISK_FLAG_CDROM))
{
if (grub_biosdisk_get_diskinfo_standard (drive,
&data->cylinders,
&data->heads,
&data->sectors) != 0)
{
if (total_sectors && (data->flags & GRUB_BIOSDISK_FLAG_LBA))
{
data->sectors = 63;
data->heads = 255;
data->cylinders
= grub_divmod64 (total_sectors
+ data->heads * data->sectors - 1,
data->heads * data->sectors, 0);
}
else
{
grub_free (data);
return grub_error (GRUB_ERR_BAD_DEVICE, "%s cannot get C/H/S values", disk->name);
}
}
if (! total_sectors)
total_sectors = data->cylinders * data->heads * data->sectors;
}disk->total_sectors = total_sectors; disk->data = data;
return GRUB_ERR_NONE;
}
static voidgrub_biosdisk_close (grub_disk_t disk) {
grub_free (disk->data);
}
/* For readability. */
#define GRUB_BIOSDISK_READ 0
#define GRUB_BIOSDISK_WRITE 1
#define GRUB_BIOSDISK_CDROM_RETRY_COUNT 3
static grub_err_tgrub_biosdisk_rw (int cmd, grub_disk_t disk,
grub_disk_addr_t sector, grub_size_t size, unsigned segment)
{
struct grub_biosdisk_data *data = disk->data;
if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
{
struct grub_biosdisk_dap *dap; dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
+ (data->sectors
<< GRUB_DISK_SECTOR_BITS));
dap->length = sizeof (*dap);
dap->reserved = 0;
dap->blocks = size;
dap->buffer = segment << 16; /* The format SEGMENT:ADDRESS. */
dap->block = sector;
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
{
int i;
if (cmd)
return grub_error (GRUB_ERR_WRITE_ERROR, "can\'t write to cdrom");
dap->blocks = ALIGN_UP (dap->blocks, 4) >> 2;
dap->block >>= 2;
for (i = 0; i < GRUB_BIOSDISK_CDROM_RETRY_COUNT; i++)
if (! grub_biosdisk_rw_int13_extensions (0x42, data->drive, dap))
break;
if (i == GRUB_BIOSDISK_CDROM_RETRY_COUNT)
return grub_error (GRUB_ERR_READ_ERROR, "cdrom read error");
}
else
if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap))
{
/* Fall back to the CHS mode. */
data->flags &= ~GRUB_BIOSDISK_FLAG_LBA;
disk->total_sectors = data->cylinders * data->heads * data->sectors;
return grub_biosdisk_rw (cmd, disk, sector, size, segment);
}
}
else
{
unsigned coff, hoff, soff;
unsigned head;
/* It is impossible to reach over 8064 MiB (a bit less than LBA24) with
the traditional CHS access. */
if (sector >
1024 /* cylinders */ *
256 /* heads */ *
63 /* spt */)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk", disk->name);
soff = ((grub_uint32_t) sector) % data->sectors + 1;
head = ((grub_uint32_t) sector) / data->sectors;
hoff = head % data->heads;
coff = head / data->heads;
if (coff >= data->cylinders)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk", disk->name);
if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
coff, hoff, soff, size, segment))
{
switch (cmd)
{
case GRUB_BIOSDISK_READ:
return grub_error (GRUB_ERR_READ_ERROR, "%s read error", disk->name);
case GRUB_BIOSDISK_WRITE:
return grub_error (GRUB_ERR_WRITE_ERROR, "%s write error", disk->name);
}
}
} return GRUB_ERR_NONE;
}
/* Return the number of sectors which can be read safely at a time. */ static grub_size_tget_safe_sectors (grub_disk_addr_t sector, grub_uint32_t sectors) {
grub_size_t size;
grub_uint32_t offset;
/* OFFSET = SECTOR % SECTORS */ grub_divmod64 (sector, sectors, &offset); size = sectors - offset;
/* Limit the max to 0x7f because of Phoenix EDD. */ if (size > 0x7f)
size = 0x7f;
return size;
}
static grub_err_tgrub_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
struct grub_biosdisk_data *data = disk->data;
while (size)
{
grub_size_t len;
grub_size_t cdoff = 0; len = get_safe_sectors (sector, data->sectors);
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
{
cdoff = (sector & 3) << GRUB_DISK_SECTOR_BITS;
len = ALIGN_UP (sector + len, 4) - (sector & ~3);
sector &= ~3;
}
if (len > size)
len = size;
if (grub_biosdisk_rw (GRUB_BIOSDISK_READ, disk, sector, len,
GRUB_MEMORY_MACHINE_SCRATCH_SEG))
return grub_errno;
grub_memcpy (buf, (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + cdoff),
len << GRUB_DISK_SECTOR_BITS);
buf += len << GRUB_DISK_SECTOR_BITS;
sector += len;
size -= len;
} return grub_errno;
}
static grub_err_tgrub_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, const char *buf)
{
struct grub_biosdisk_data *data = disk->data;
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
return grub_error (GRUB_ERR_IO, "can't write to CDROM");
while (size)
{
grub_size_t len; len = get_safe_sectors (sector, data->sectors);
if (len > size)
len = size;
grub_memcpy ((void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR, buf,
len << GRUB_DISK_SECTOR_BITS);
if (grub_biosdisk_rw (GRUB_BIOSDISK_WRITE, disk, sector, len,
GRUB_MEMORY_MACHINE_SCRATCH_SEG))
return grub_errno;
buf += len << GRUB_DISK_SECTOR_BITS;
sector += len;
size -= len;
} return grub_errno;
}
static struct grub_disk_dev grub_biosdisk_dev =
{
.name = "biosdisk",
.id = GRUB_DISK_DEVICE_BIOSDISK_ID, .iterate = grub_biosdisk_iterate, .open = grub_biosdisk_open,
.close = grub_biosdisk_close,
.read = grub_biosdisk_read,
.write = grub_biosdisk_write,
.next = 0
};
static voidgrub_disk_biosdisk_fini (void)
{
grub_disk_dev_unregister (&grub_biosdisk_dev);
}
GRUB_MOD_INIT(biosdisk)
{
struct grub_biosdisk_cdrp *cdrp
= (struct grub_biosdisk_cdrp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
if (grub_disk_firmware_is_tainted)
{
grub_printf ("Firmware is marked as tainted, refusing to initialize.\n");
return;
}
grub_disk_firmware_fini = grub_disk_biosdisk_fini;
grub_memset (cdrp, 0, sizeof (*cdrp));
cdrp->size = sizeof (*cdrp);
cdrp->media_type = 0xFF;
if ((! grub_biosdisk_get_cdinfo_int13_extensions (grub_boot_drive, cdrp)) &&
((cdrp->media_type & GRUB_BIOSDISK_CDTYPE_MASK)
== GRUB_BIOSDISK_CDTYPE_NO_EMUL))
cd_drive = cdrp->drive_no;
/* Since diskboot.S rejects devices over 0x90 it must be a CD booted with
cdboot.S
*/
if (grub_boot_drive >= 0x90)
cd_drive = grub_boot_drive; grub_disk_dev_register (&grub_biosdisk_dev);
}
GRUB_MOD_FINI(biosdisk)
{
grub_disk_biosdisk_fini ();
}
Quoted 21 lines · Lennart Sorensen
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Following may help:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 line 88
Quoted 9 lines
disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +3
-0@@ -80,6 +80,9 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + return (regs.eax >> 8) & 0xff; }I now got this:
GRUB loading.
Welcome to GRUB!
Quoted 10 lines
int13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flag
It's not really a fixup. Correct return on no error is CF=0 AH=0. Some BIOSes in some other functions returned CF=0, AH!= 0 on no error so it was a wild guess.
Quoted 2 lines
Failed
int13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000
Error 0x80 according to
http://www.delorie.com/djgpp/doc/rbinter/it/34/2.html means timeout. Following code would retry on timeout:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'
disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +12 -0
@@ -72,6 +72,8 @@ grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) { struct grub_bios_int_registers regs; + int tries = 4; + retry: regs.eax = ah << 8; /* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;
@@ -80,6 +82,16 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + + if (((regs.eax >> 8) & 0xff) == 0x80 && tries) + { + grub_millisleep (10); + tries--; + goto retry; + } + return (regs.eax >> 8) & 0xff; }
Quoted 14 lines
error: hd0 out of disk. Entering rescue mode...
grub rescue>I am now using 1.99-rc1. Here is the
biosdisk.cwith my changes._______________________________________________
Grub-devel mailing list [email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 79 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 21 lines · Lennart Sorensen
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Following may help:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 line 88
Quoted 9 lines
disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +3
-0@@ -80,6 +80,9 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + return (regs.eax >> 8) & 0xff; }I now got this:
GRUB loading.
Welcome to GRUB!Quoted 10 lines
int13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagIt's not really a fixup. Correct return on no error is CF=0 AH=0. Some BIOSes in some other functions returned CF=0, AH!= 0 on no error so it was a wild guess.
Quoted 2 lines
Failed
int13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000Error
0x80according to
http://www.delorie.com/djgpp/doc/rbinter/it/34/2.html means timeout. Following code would retry on timeout:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +12
-0@@ -72,6 +72,8 @@ grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) { struct grub_bios_int_registers regs; + int tries = 4; + retry: regs.eax = ah << 8; /* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;@@ -80,6 +82,16 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + + if (((regs.eax >> 8) & 0xff) == 0x80 && tries) + { + grub_millisleep (10); + tries--; + goto retry; + } + return (regs.eax >> 8) & 0xff; }Quoted 10 lines
error: hd0 out of disk. Entering rescue mode...
grub rescue>I am now using 1.99-rc1. Here is the
biosdisk.cwith my changes.
Quoted 5 lines
Quoted 5 lines
_______________________________________________
Grub-devel mailing list [email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
I am trying that now.
By the way I think I spotted a bug:
else
if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap))
{
/* Fall back to the CHS mode. */
data->flags &= ~GRUB_BIOSDISK_FLAG_LBA;
disk->total_sectors = data->cylinders * data->heads * data->sectors;
return grub_biosdisk_rw (cmd, disk, sector, size, segment);
}I think that + 0x42 is wrong. The extended commands are 0x40 above the normal ones. + 0x40 makes more sense to me.
0x42 = extended read.0x02 = normal read.
0x48 = extended parameter read.0x08 = normal parameter read.
Signature · 1 line
Len Sorensen
Quoted 99 lines · Lennart Sorensen
Quoted 79 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 21 lines · Lennart Sorensen
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Following may help:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 line 88
Quoted 9 lines
disk/i386/pc/biosdisk.c 2011-03-16 20:17:57 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +3
-0@@ -80,6 +80,9 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + return (regs.eax >> 8) & 0xff; }I now got this:
GRUB loading.
Welcome to GRUB!Quoted 10 lines
int13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagint13_extfixup due to CARRY flagIt's not really a fixup. Correct return on no error is CF=0 AH=0. Some BIOSes in some other functions returned CF=0, AH!= 0 on no error so it was a wild guess.
Quoted 2 lines
Failed
int13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000Error
0x80according to
http://www.delorie.com/djgpp/doc/rbinter/it/34/2.html means timeout. Following code would retry on timeout:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +12
-0@@ -72,6 +72,8 @@ grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) { struct grub_bios_int_registers regs; + int tries = 4; + retry: regs.eax = ah << 8; /* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;@@ -80,6 +82,16 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; + + if (((regs.eax >> 8) & 0xff) == 0x80 && tries) + { + grub_millisleep (10); + tries--; + goto retry; + } + return (regs.eax >> 8) & 0xff; }Quoted 10 lines
error: hd0 out of disk. Entering rescue mode...
grub rescue>I am now using 1.99-rc1. Here is the
biosdisk.cwith my changes.Quoted 5 lines
Quoted 5 lines
_______________________________________________
Grub-devel mailing list [email protected]
http://lists.gnu.org/mailman/listinfo/grub-develI am trying that now.
By the way I think I spotted a bug:
else if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap)) { /* Fall back to the CHS mode. */ data->flags &= ~GRUB_BIOSDISK_FLAG_LBA; disk->total_sectors = data->cylinders * data->heads * data->sectors; return grub_biosdisk_rw (cmd, disk, sector, size, segment); }
Quoted 8 lines
I think that +
0x42is wrong. The extended commands are0x40above the normal ones. +0x40makes more sense to me.
0x42= extended read.0x02= normal read.
0x48= extended parameter read.0x08= normal parameter read.
Never mind. cmd = 0 for read, not 0x2. Oh well. I found it adds 0x02 in _standard, so it works the same.
Still testing the other stuff.
Signature · 1 line
Len Sorensen
Quoted 26 lines · Vladimir 'φ-coder/phcoder' Serbinenko
It's not really a fixup. Correct return on no error is CF=0 AH=0. Some BIOSes in some other functions returned CF=0, AH!= 0 on no error so it was a wild guess.
Quoted 2 lines
Failed
int13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000Error
0x80according to
http://www.delorie.com/djgpp/doc/rbinter/it/34/2.html means timeout. Following code would retry on timeout:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +4
-0@@ -72,6 +72,8 @@ grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) { struct grub_bios_int_registers regs; + int tries = 4; + retry: regs.eax = ah << 8; /* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;@@ -80,6 +82,16 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0;
disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 line 96
Quoted 10 lines
disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +8
-0+ + if (((regs.eax >> 8) & 0xff) == 0x80 && tries) + { + grub_millisleep (10); + tries--; + goto retry; + } + return (regs.eax >> 8) & 0xff; }
So that didn't make any difference to it.
It just keeps returning 0x8000 in eax on every retry.
I really want to find out what this BIOS is doing wrong so I can tell the system maker what to fix.
I am going to add some debuging to find out what is in the dap being passed to the BIOS.
Signature · 1 line
Len Sorensen
Quoted 43 lines · Lennart Sorensen
Quoted 29 lines · Vladimir 'φ-coder/phcoder' Serbinenko
It's not really a fixup. Correct return on no error is CF=0 AH=0. Some BIOSes in some other functions returned CF=0, AH!= 0 on no error so it was a wild guess.
Quoted 3 lines
Failed
int13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000Error
0x80according to
http://www.delorie.com/djgpp/doc/rbinter/it/34/2.html means timeout. Following code would retry on timeout:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +5
-0@@ -72,6 +72,8 @@ grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) { struct grub_bios_int_registers regs; + int tries = 4; + retry: regs.eax = ah << 8; /* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;@@ -80,6 +82,16 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; +disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 line 97
Quoted 10 lines
disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +7
-0+ if (((regs.eax >> 8) & 0xff) == 0x80 && tries) + { + grub_millisleep (10); + tries--; + goto retry; + } + return (regs.eax >> 8) & 0xff; }So that didn't make any difference to it.
Quoted 3 lines
It just keeps returning
0x8000in eax on every retry.
Another wild guess:
@@ -506,6 +520,8 @@ get_safe_sectors (grub_disk_addr_t secto
grub_size_t size;
grub_uint32_t offset;
+ return 1;
+
/* OFFSET = SECTOR % SECTORS */
grub_divmod64 (sector, sectors, &offset);
Quoted 7 lines
I really want to find out what this BIOS is doing wrong so I can tell the system maker what to fix.
I am going to add some debuging to find out what is in the dap being passed to the BIOS.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 49 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 43 lines · Lennart Sorensen
Quoted 29 lines · Vladimir 'φ-coder/phcoder' Serbinenko
It's not really a fixup. Correct return on no error is CF=0 AH=0. Some BIOSes in some other functions returned CF=0, AH!= 0 on no error so it was a wild guess.
Quoted 3 lines
Failed
int13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000Error
0x80according to
http://www.delorie.com/djgpp/doc/rbinter/it/34/2.html means timeout. Following code would retry on timeout:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +5
-0@@ -72,6 +72,8 @@ grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) { struct grub_bios_int_registers regs; + int tries = 4; + retry: regs.eax = ah << 8; /* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;@@ -80,6 +82,16 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; +disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 line 97
Quoted 10 lines
disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +7
-0+ if (((regs.eax >> 8) & 0xff) == 0x80 && tries) + { + grub_millisleep (10); + tries--; + goto retry; + } + return (regs.eax >> 8) & 0xff; }So that didn't make any difference to it.
Quoted 3 lines
It just keeps returning
0x8000in eax on every retry.Another wild guess:
Review get_safe_sectors (grub_disk_addr_t secto · line 526
Quoted 7 lines
(quoted diff) +2
-0@@ -506,6 +520,8 @@ get_safe_sectors (grub_disk_addr_t secto grub_size_t size; grub_uint32_t offset; + return 1; + /* OFFSET = SECTOR % SECTORS */ grub_divmod64 (sector, sectors, &offset);
No go either.
Here is what I see with some more debugging:
[snip]int13_ext call: ah=42, drive=80, dap= 6fe00 (len=16 rsvd=0 blks=1 buf=1744830464 sec=2078)int13_ext call: ah=42, drive=80, dap= 6fe00 (len=16 rsvd=0 blks=1 buf=1744830464 sec=2079)int13_ext call: ah=42, drive=80, dap= 6fe00 (len=16 rsvd=0 blks=1 buf=1744830464 sec=72091664)
failed int13_ext call: ah=42, drive=80, dap= 6fe00 returned eax=8000
error: hd0 out of disk.
Entering rescue mode...
grub rescue>
Now it has no excuse for failing a call for sector 72091664 when the drive has 156000000 or so sectors.
I imagine if I made a small boot partition (less than 8G), the stupid thing would boot fine, but that's not acceptable on a brand new design. I am going to try resizing the partition as a test.
Signature · 1 line
Len Sorensen
Quoted 60 lines · Lennart Sorensen
Quoted 58 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 47 lines · Lennart Sorensen
Quoted 32 lines · Vladimir 'φ-coder/phcoder' Serbinenko
It's not really a fixup. Correct return on no error is CF=0 AH=0. Some BIOSes in some other functions returned CF=0, AH!= 0 on no error so it was a wild guess.
Quoted 4 lines
Failed
int13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000Error
0x80according to
http://www.delorie.com/djgpp/doc/rbinter/it/34/2.html means timeout. Following code would retry on timeout:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +5
-0@@ -72,6 +72,8 @@ grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) { struct grub_bios_int_registers regs; + int tries = 4; + retry: regs.eax = ah << 8; /* compute the address of disk_address_packet */ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;@@ -80,6 +82,16 @@ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x13, ®s); + if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY)) + return 0; +disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 line 97
Quoted 10 lines
disk/i386/pc/biosdisk.c 2011-03-16 22:13:12 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +7
-0+ if (((regs.eax >> 8) & 0xff) == 0x80 && tries) + { + grub_millisleep (10); + tries--; + goto retry; + } + return (regs.eax >> 8) & 0xff; }So that didn't make any difference to it.
Quoted 4 lines
It just keeps returning
0x8000in eax on every retry.Another wild guess:
(quoted diff) +0
-0@@ -506,6 +520,8 @@ get_safe_sectors (grub_disk_addr_t secto grub_size_t size; grub_uint32_t offset;
Quoted 8 lines
Review get_safe_sectors (grub_disk_addr_t secto · line 527
Quoted 5 lines
(quoted diff) +2
-0+ return 1; + /* OFFSET = SECTOR % SECTORS */ grub_divmod64 (sector, sectors, &offset);No go either.
Can you dump complete drp before and after every call?
(19:52:44) phcoder: cjwatson: may the Lennart's last message be caused by 4K sectors?(idk if he has 512B or 4K sectors)
(19:56:14) cjwatson: possible; he can find out by printing drp->bytes_per_sector after the call to grub_biosdisk_get_diskinfo_int13_extensions in grub-core/disk/i386/pc/biosdisk.c
(19:56:25) cjwatson: at least find out what the BIOS thinks
Quoted 19 lines
Here is what I see with some more debugging:
[snip]
int13_extcall: ah=42, drive=80, dap= 6fe00 (len=16 rsvd=0 blks=1 buf=1744830464 sec=2078)int13_extcall: ah=42, drive=80, dap= 6fe00 (len=16 rsvd=0 blks=1 buf=1744830464 sec=2079)int13_extcall: ah=42, drive=80, dap= 6fe00 (len=16 rsvd=0 blks=1 buf=1744830464 sec=72091664)
failedint13_extcall: ah=42, drive=80, dap= 6fe00 returned eax=8000
error: hd0 out of disk.
Entering rescue mode...
grub rescue>Now it has no excuse for failing a call for sector 72091664 when the drive has 156000000 or so sectors.
I imagine if I made a small boot partition (less than 8G), the stupid thing would boot fine, but that's not acceptable on a brand new design. I am going to try resizing the partition as a test.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko
Can you dump complete drp before and after every call?
I can try. Of course transscribing them by hand is a pain. I wonder if the serial port works on this thing, so I can make grub use that (assuming I can get grub to load itself first, before hitting the BIOS bug. I might be able to.)
Quoted 7 lines
(19:52:44) phcoder: cjwatson: may the Lennart's last message be caused by 4K sectors?(idk if he has 512B or 4K sectors)
(19:56:14) cjwatson: possible; he can find out by printingdrp->bytes_per_sectorafter the call togrub_biosdisk_get_diskinfo_int13_extensionsingrub-core/disk/i386/pc/biosdisk.c
(19:56:25) cjwatson: at least find out what the BIOS thinks
It's a VERY old 80G WD SATA drive. No 4k sectors here.
By the way, making the partition smaller than 8G made it boot just fine, so it seems the BIOS is failing with higher sector numbers only. That's simply pathetic.
Signature · 1 line
Len Sorensen
Quoted 9 lines · Phillip Susi
Quoted 8 lines · Lennart Sorensen
So I now have some debug info:
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>
Quoted 8 lines
Quoted 3 lines
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
What does the partition table look like? It doesn't extend beyond sector 156312575 does it?
Also I wonder about why H=16. It should be 255.
I didn't look at the code, but this is probably the ATA geometry of the disk, which is returned by the INT-13h (Extended) function 48h (Read Drive Parameters). If I remember correctly, this geometry is always 16383/16/63 for disks larger than 8.4GB.
Grégoire
Quoted 4 lines · Grégoire Sutre
I didn't look at the code, but this is probably the ATA geometry of the disk, which is returned by the INT-13h (Extended) function 48h (Read Drive Parameters). If I remember correctly, this geometry is always 16383/16/63 for disks larger than 8.4GB.
That does match what is returned.
Grub later assumes H=255 if it falls back to CHS as far as I can tell.
H=255 S=63 would be really bad for alignment on SSDs and such (not that H=16 is a whole lot better, but it is better).
Signature · 1 line
Len Sorensen
Quoted 9 lines · Lennart Sorensen
Quoted 4 lines · Grégoire Sutre
I didn't look at the code, but this is probably the ATA geometry of the disk, which is returned by the INT-13h (Extended) function 48h (Read Drive Parameters). If I remember correctly, this geometry is always 16383/16/63 for disks larger than 8.4GB.
That does match what is returned.
Grub later assumes H=255 if it falls back to CHS as far as I can tell.
If the standard (non-extended) INT-13h interface is used, then addressing is performed via CHS, and w.r.t. to the BIOS geometry (which need not be the same as the ATA geometry reported by the disk itself, due to potential address translation by the BIOS). I guess that H=255 is the from the BIOS geometry of the disk (as returned by the INT-13h function 08h).
Quoted 2 lines
H=255 S=63 would be really bad for alignment on SSDs and such (not that H=16 is a whole lot better, but it is better).
The geometry just says how to interpret CHS addresses, it does not imply any partition alignment. You can have 1MiB-aligned partitions even with a n/255/63 BIOS geometry.
Grégoire
Quoted 5 lines · Grégoire Sutre
If the standard (non-extended) INT-13h interface is used, then addressing is performed via CHS, and w.r.t. to the BIOS geometry (which need not be the same as the ATA geometry reported by the disk itself, due to potential address translation by the BIOS). I guess that H=255 is the from the BIOS geometry of the disk (as returned by the INT-13h function 08h).
Very likely.
Quoted 3 lines
The geometry just says how to interpret CHS addresses, it does not imply any partition alignment. You can have 1MiB-aligned partitions even with a n/255/63 BIOS geometry.
Certainly true.
Signature · 1 line
Len Sorensen
Quoted 41 lines · Lennart Sorensen
Quoted 29 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Lennart Sorensen
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
ls -l should show how big it thinks the disk is. Compare it with its real size
Quoted 8 lines
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
Looks like int13 is borked. Perhaps it's borked in a way which prevents GRUB from detecting 13/42 function. You can try to force int13/42 by:
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 line 152
Quoted 8 lines
disk/i386/pc/biosdisk.c 2011-03-16 15:28:26 +0000 renamed from disk/i386/pc/biosdisk.c 2011-01-04 14:42:47 +0000 +2
-0@@ -145,6 +145,8 @@ { struct grub_bios_int_registers regs; + return 1; + regs.edx = drive & 0xff; regs.eax = 0x4100; regs.ebx = 0x55aa;So I now have some debug info:
Quoted 7 lines
version=48
total_sectors=156312576 C=16383 H=16 S=63
error: hd0,msdos1 out of disk.
Entering rescue mode...
grub rescue>
These are correct values. However it may be that the correct value is returned only on the first call. Could you try forcing
version=48
total_sectors=156312576
Quoted 5 lines
So version is returning something, and it is actually getting the disk size properly. I wonder what else could cause the out of disk message then.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 7 lines · Lennart Sorensen
I am trying to figure out why grub2 (from Debian Squeeze) gives an 'out of disk' error when trying to boot from the HD after doing an install. It ends up at a grub rescue prompt, given it can't even read the disk well enough to load the full grub. Doing ls shows the disks, and I can show the root directory of a partition, but anything further seems to hit the same 'out of disk' error.
I have another idea. Could you try GRUB 1.97 and GRUB Legacy? A similar report on our BTS seems to indicate that GRUB Legacy works. Major difference between Legacy and latest GRUB2 is that GRUB2 uses C-wrappers around BIOS calls whereas in GRUB Legacy they are in asm. The change happened after 1.97
Quoted 9 lines
The system is a Compulab CM-iTC which uses an intel tunnelcreek atom (the new one) with a phoenix bios. So far Compulab's response when told it won't boot grub2 was "We know, but syslinux works fine.", which to me is not a solution at all. The same system also hangs the Linux 2.6.32 kernel unless 'edd=off' is added to the kernel command line.
So any suggestions on how to go about debuagging this? Or even any ideas why grub would give such an error.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
I have another idea. Could you try GRUB 1.97 and GRUB Legacy? A similar report on our BTS seems to indicate that GRUB Legacy works. Major difference between Legacy and latest GRUB2 is that GRUB2 uses C-wrappers around BIOS calls whereas in GRUB Legacy they are in asm. The change happened after 1.97
I managed to get the maker of the board to confirm the BIOS has a bug. They are going to fix it. It incorrectly returns error when you try to do LBA access beyond 8GB, which makes grub fall back to CHS and report 'out of disk'. They have been trying to add SD card support to the BIOS and I think they broke this in the process.
So grub is fine as far as I can tell.
Signature · 1 line
Len Sorensen