Re: 10.2 Gig HDD : 2.0.36 patch for better C/H/S translation

Riley Williams (rhw@BigFoot.Com)
Sun, 24 Jan 1999 16:38:17 +0000 (GMT)


Hi there.

> However, the C/H/S reported by the bios is 1024/255/63, while
> C/H/S reported by the IDE probe is 25113/16/63. The former is saved for
> fdisk's benefit, but should be corrected to 1575/255/63.
>
> Yes, precisely.
>
> I've tried with 2.2.0-pre9, and it gets this right.
>
> Yes.
>
> Here's a patch for 2.0.36 that makes it work in this special case.
>
> Disclaimer: This patch works for me and should be safe, at least for
> "normal" situations (I don't know about disk managers).
>
> --- ide.c.org Sat Jan 23 01:42:35 1999
> +++ ide.c Sat Jan 23 01:55:04 1999
> @@ -2585,6 +2585,19 @@
> if (drive->sect == drive->bios_sect && drive->head == drive->bios_head) {
> if (drive->cyl > drive->bios_cyl)
> drive->bios_cyl = drive->cyl;
> +
> + /* same, when the bios value is as big as it can be, but the ide
> + * probe didn't return the same number of heads -orabidoo
> + */
> + } else if (drive->sect == 63 && drive->head == 16 &&
> + drive->bios_sect == 63 && drive->bios_head == 255 &&
> + drive->bios_cyl == 1024) {
> +
> + unsigned long my_cyl = drive->cyl * 16 / 255;
> +
> + /* more than 128G (ide limit) => probably bogus */
> + if (my_cyl > 1024 && my_cyl < 16384)
> + drive->bios_cyl = my_cyl;
> }
>
> if (!strncmp(id->model, "BMI ", 4) &&
>
>
> Yes, that is more or less correct. But not good enough:
> For example, I have also seen BIOSes that produce 1027/255/63
> probably because they compute 16383*16/255 = 1027.

I've also seen a BIOS produce 1023/255/63, presumably because 1023 is
the largest valid 9-bit unsigned number...

Those case can be dealt with by applying the following modification to
the above patch:

> + drive->bios_cyl == 1024) {

becomes either

> + drive->bios_cyl > 1022) {

or

> + drive->bios_cyl > 1022 && drive->bios_cyl < 1030) {

Basically, does it matter if we were given valid figures, but
recalculate them anyway?

Best wishes from Riley.

---
 * ftp://ftp.MemAlpha.cx/pub/rhw/Linux
 * http://www.MemAlpha.cx/~rhw/kernel.versions.html

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/