Re: [Fwd: Hard disk geometry]

Andrew Clausen (clausen@alphalink.com.au)
Thu, 21 Oct 1999 20:44:20 -0400


Hi, (linux-kernel people: please cc me)

Simon Kirby wrote:
> Hi Andrew,
>
> Remembering what I've read on linux-kernel, I thought that the INT 0x13
> geometry interface was not reliable due to how old bioses don't support
> reading the extended geometry off of big disks (where the geometry is
> bigger than 1023, and more recently, where the geometry is bigger than
> 16383 (I think the INT 0x13 interface returns this in a short and so the
> ATA spec now says that drives are supposed to return this size and the
> BIOS/operating system should later use another call to find the real
> geometry)).

I was more thinking of using the new INT 0x13 interface, which uses
32-bit values. From Ralph Brown's interrupt list:

--------d-1348-------------------------------
INT 13 - IBM/MS INT 13 Extensions - GET DRIVE PARAMETERS
AH = 48h
DL = drive (80h-FFh)
DS:SI -> buffer for drive parameters (see #00273)
Return: CF clear if successful
AH = 00h
DS:SI buffer filled
CF set on error
AH = error code (see #00234)
BUG: several different Compaq BIOSes incorrectly report high-numbered
drives (such as 90h, B0h, D0h, and F0h) as present, giving
them the
same geometry as drive 80h; as a workaround, scan through disk
numbers, stopping as soon as the number of valid drives
encountered
equals the value in 0040h:0075h
SeeAlso: AH=08h,AH=41h,AH=49h,MEM 0040h:0075h

Format of IBM/MS INT 13 Extensions drive parameters:
Offset Size Description (Table 00273)
00h WORD (call) size of buffer
(001Ah for v1.x, 001Eh for v2.x, 42h for v3.0)
(ret) size of returned data
02h WORD information flags (see #00274)
04h DWORD number of physical cylinders on drive
08h DWORD number of physical heads on drive
0Ch DWORD number of physical sectors per track
10h QWORD total number of sectors on drive
18h WORD bytes per sector

<snip>

> >From what I remember also, I thought Linux got geometry information this
> way:
>
> 1. User specified on commad line
> 2. The partition table (not sure how)
> 3. Its own direct disk probing
> 4. INT 0x13

I don't think it uses INT 0x13. There's a comment in the source
suggesting an implementation.

> Also, "fdisk" reads this information from the kernel somehow, so you
> might want to look at the code for it. :)

fdisk (and parted) use the HDIO_GETGEOMETRY ioctl. However, Linux
isn't good at detecting the geometry, so the ioctl sometimes returns
the wrong geometry.

Andrew Clausen

-
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/