2003-08-20 19:31:12

by John Riggs

[permalink] [raw]
Subject: 48-bit Drives Incorrectly reporting 255 Heads?

With the 2.4.20 kernel, I have a 40GB disk with 240 heads, with 48-bit
mode enabled. The Linux ide driver automatically declares that anything
with 48-bit mode enabled has 255 heads. This is a problem, as I am
writing a utility to fix up a Windows PBR, and the PBR relies on the
head count as counted by the BIOS.
The Linux code in question is in ide-disk.c:

if (id->cfs_enable_2 & 0x0400) {
.
drive->head = drive->bios_head = 255;
.
}

What I would like to do is change the above to:

if (id->cfs_enable_2 & 0x0400) {
.
drive->head = 255;
.
}

Thereby not changing the bios head count. My initial tests seem to
have worked okay, with the correct geometry getting reported. Can
anybody point out to me why this will break something else?
Two more specific questions are:
1) Will this break drives > 137 GB?
2) Why would the head count be set to 255 in the first place?

Thank you,
John Riggs


2003-08-20 19:58:13

by Richard B. Johnson

[permalink] [raw]
Subject: Re: 48-bit Drives Incorrectly reporting 255 Heads?

On Wed, 20 Aug 2003, John Riggs wrote:

> With the 2.4.20 kernel, I have a 40GB disk with 240 heads, with 48-bit
> mode enabled. The Linux ide driver automatically declares that anything
[SNIPPED...]

> Two more specific questions are:
> 1) Will this break drives > 137 GB?
> 2) Why would the head count be set to 255 in the first place?

In the BIOS, in 'real-mode' the head to read/write is put into
the DH register. This is an 8-bit register. Drives that can boot
(they boot using interrupt 0x13 to read the drive), can't have more
that 256 heads (0->255).

Heads = 8 bits = 256
Cylinders = 10 bits = 1024
Sectors = 6 bits = 64

You get large media by translating to a large bytes/sector number.
If the "real" bytes/sector number is 256 this means that the largest
size media one could use (to boot) is 256 * 1024 * 64 * 256 =
4,294,967,296 bytes. A 137 GB needs 137/4 ~= 35 times more than
256 = 8960 bytes per sector or more.

If you tell GRUB or LILO that the media has more than 256 heads,
it won't (can't) write the boot tracks.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


2003-08-20 19:47:16

by Andries Brouwer

[permalink] [raw]
Subject: Re: 48-bit Drives Incorrectly reporting 255 Heads?

On Wed, Aug 20, 2003 at 01:31:08PM -0600, John Riggs wrote:

> With the 2.4.20 kernel, I have a 40GB disk with 240 heads, with 48-bit
> mode enabled. The Linux ide driver automatically declares that anything
> with 48-bit mode enabled has 255 heads. This is a problem, as I am
> writing a utility to fix up a Windows PBR, and the PBR relies on the
> head count as counted by the BIOS.
> The Linux code in question is in ide-disk.c:
>
> if (id->cfs_enable_2 & 0x0400) {
> .
> drive->head = drive->bios_head = 255;
> .
> }
>
> What I would like to do is change the above to:
>
> if (id->cfs_enable_2 & 0x0400) {
> .
> drive->head = 255;
> .
> }
>
> Thereby not changing the bios head count. My initial tests seem to
> have worked okay, with the correct geometry getting reported. Can
> anybody point out to me why this will break something else?
> Two more specific questions are:
> 1) Will this break drives > 137 GB?
> 2) Why would the head count be set to 255 in the first place?

No, this does not break anything.
Setting drive->head to 255 is completely ridiculous.
Setting drive->bios_head to 255 is rather pointless.
In 2.6 this junk has been removed already.

On the other hand, you are badly mistaken if you think that your changes
do anything useful. The value drive->bios_head must be regarded as
random, and is only vaguely related to what the BIOS thinks.
In 2.6 that vague relation has entirely disappeared.

2003-08-21 05:38:32

by jw schultz

[permalink] [raw]
Subject: Re: 48-bit Drives Incorrectly reporting 255 Heads?

On Wed, Aug 20, 2003 at 01:31:08PM -0600, John Riggs wrote:
> With the 2.4.20 kernel, I have a 40GB disk with 240 heads, with 48-bit

I don't beleive that. 240 heads, baloney!
Unless it is a very old drive it probably has 4 or 5 heads.
Quite likely it has only 2 or 3.

A 240 head drive would have to have multiple heads per
surface or the stack of disks on the spindle would be about
5 feet tall.



--
________________________________________________________________
J.W. Schultz Pegasystems Technologies
email address: [email protected]

Remember Cernan and Schmitt

2003-08-21 06:57:50

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: 48-bit Drives Incorrectly reporting 255 Heads?

On Wed, 20 Aug 2003 22:38:24 PDT, jw schultz <[email protected]> said:

> A 240 head drive would have to have multiple heads per
> surface or the stack of disks on the spindle would be about
> 5 feet tall.

That's an old Jedi mind trick, dating back at *least* as far as the IBM 3350
disk drive from 1976 (the 23xx drives from the S/360 and the 3330/3340 series
had single heads per surface) . 8 14" platters, 317.5M. 16 physical surfaces,
but it reported 30 heads, because each arm had an "inside" and "outside" head :

====\=====\ (arm)
=================| (platter)
====/=====/ (arm)

The outside heads were tracks 0-15 and servo-1, the inside heads were 16-29
and servo-2. It was also available with a second fixed-access arm that had enough
heads to read the first 5 cylinders without seeking at all - so that's another 150
heads. So that gets us to 180... not *quite* 240, but....

And it wasn't 5 foot tall, by a long shot: http://www.columbia.edu/acis/history/mss.html
The last picture has guys standing around a string of 3350 disk drives (the
actual drive was contained in the white head, the blue bottom part was power
supplies and control logic and the like).


Attachments:
(No filename) (226.00 B)

2003-08-21 07:42:19

by Alan

[permalink] [raw]
Subject: Re: 48-bit Drives Incorrectly reporting 255 Heads?

On Iau, 2003-08-21 at 06:38, jw schultz wrote:
> A 240 head drive would have to have multiple heads per
> surface or the stack of disks on the spindle would be about
> 5 feet tall.

PC class hardware is all about layers of compatibility hacks.
IDE "geometry" became fictional before 540Mb disks. Sectors/track
etc is all made up too nowdays.