Hi to all!
I have written the module for reading sectors of a hard disk. It uses ports 1F0-1F7 (not int13h) and works in normal mode (16 heads maximum) instead of LBA (up to 256 heads). How to detect the quantity of sectors, heads and cylinders on a disk for each mode in Windows9x?
Mike
Posted on 2002-08-24 10:05:55 by Mike
Hello Mike,

I'm not too sure what you want to do but maybe you want info from bios parameter block? Check this link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win9x/fat32_6l2o.asp This is implemented through Int 21h Function 440Dh Minor Code 60h.

hope this is helpful,
best regards,

czDrillard
Posted on 2002-08-24 12:58:29 by czDrillard
Thank you for reply. When somebody want to read sector of physical drive (e.g. MBR=Master Boot Record) he can do it using other methods.
1. CreateFile + ReadFile (only NT platform)
2. Int 13h (Only Win9x platform)
3. Send commands to ports of device (e.g.
mov edi, hParms
mov DX, 1F6h
mov AL, byte ptr
out DX, AL
.....
mov DX, 1F7h
mov AL, 20h (Read sector, see the list of commands below)
out DX, AL
.....)

When we use first or second methods we pass and recieve parameters (#cyl, #heads etc.) for LBA mode. For example, hard disk that has de-facto 8912 cylinders, 16 heads and 63 sectors per track (normal mode) in LBA mode has 524 cylinders, 256 heads and 63 sectors per track. We must use LBA mode for large disks otherwise int 13h can't works properly.

We can send to hard disks controllers such commands:
1xH = Restore to cylinder 0 (low nibble is step rate)
2xH = Read sector (low nibble indicates retry and ECC-read)
3xH = Write sector (low nibble indicates retry and ECC-read)
4xH = verify read (low nibble indicates retry)
50H = Format track
7xH = Seek to cylinder (low nibble is step rate)
90H = diagnose
91H = set parameters (max heads,sectors) for selected drive

It seems to me (I am not sure) that diagnose(90h) can resolve my problems but I don't know format of it's output because I never use it.
Am I right ? How can I do it? - that's my questions.

Mike
Posted on 2002-08-25 01:51:15 by Mike
Here is a way to do it. Take out the * to download it.
Is this what you want?

h*ttp://www.geocities.com/freehafer/zip/zhdpt.zip
Posted on 2002-08-27 21:58:13 by roaknog
Thank you roaknog!
It is not exactly this code that I need. The same I can get with int 13h if I'll insert it into vxd.

MOV AH,8
MOV DL,80h
INT 13h

MOV HEADS,DH
mov al,cl
and al,11000000B
shr al,6
mov ah,ch
MOV CYLINDER, AX

MOV AL,CL
and al,00111111B
MOV SECTOR, AL

All programs show me that my disk has 255 heads. But nobody can read/write head with number more than 15 because for number of head reserved only a half of byte! (port 1F6 = 0Axh where x = head number). Yes BIOS translates disk parameters from LBA mode (in which may be 255 heads) to normal and back, but device actually has another number of cylinders and heads. So I can use LBA parameters when I work on the interrupts level or higher (DOS, Windows etc) but not when I read/write via ports.

Regards,
Mike
Posted on 2002-08-28 06:52:06 by Mike