Disk geometry

Hi all !

How is the disk geometry calculated?

Regards,
Dany

Hi,
First of, the Disk geometry is obtained through an
“IOCTL_DISK_GET_DRIVE_GEOMETRY”. The disk geometry is obtained in an
“DISK_GEOMETRY” structure. The disk class driver is supposed to provide
this on fetching from the device through the port driver.

If you are writing a virtual disk driver, then for your disk size you need
to calculate number of cylinders. Remaining can be hard coded or can be
combined from multiple disks (like FDisk).

DiskGeometry.DiskLength = 1024 * 1024; // Say 1 MB or fetched from multiple
disks.
DiskGeometry.BytesPerSector = 512;
DiskGeometry.SectorsPerTrack = 32;
DiskGeometry.TracksPerCylinder = 2;
DiskGeometry.NumberOfCylinders = DiskGeometry.DiskLength /
DiskGeometry.BytesPerSector /
DiskGeometry.SectorsPerTrack /
DiskGeometry.TracksPerCylinder;

For more clarity you can see the Ramdisk example given in Win NT DDK.

Hope this helps.

Regards,
Prasanna.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Dany Polovets
Sent: Tuesday, March 05, 2002 7:07 PM
To: NT Developers Interest List
Subject: [ntdev] Disk geometry

Hi all !

How is the disk geometry calculated?

Regards,
Dany


You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to %%email.unsub%%

Prasanna,
Thank you for an answer.
I have no problem with virtual geometry.
I would like to know, from where the SCSI disk receives its geometry.
Is it SCSI command that returns a geometry?
From the class disk code, they try to read it from BIOS first, and if
it fails, they try to read it from the port, but it is written, that
only some ports support it.
If it is read from BIOS, is there any known function BIOS uses to calculate geometry?

Regards,
Dany

-----Original Message-----
From: Prasanna B R [mailto:xxxxx@tataelxsi.co.in]
Sent: Tuesday, March 05, 2002 4:13 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Disk geometry

Hi,
First of, the Disk geometry is obtained through an
“IOCTL_DISK_GET_DRIVE_GEOMETRY”. The disk geometry is obtained in an
“DISK_GEOMETRY” structure. The disk class driver is supposed to provide
this on fetching from the device through the port driver.

If you are writing a virtual disk driver, then for your disk size you need
to calculate number of cylinders. Remaining can be hard coded or can be
combined from multiple disks (like FDisk).

DiskGeometry.DiskLength = 1024 * 1024; // Say 1 MB or fetched from multiple
disks.
DiskGeometry.BytesPerSector = 512;
DiskGeometry.SectorsPerTrack = 32;
DiskGeometry.TracksPerCylinder = 2;
DiskGeometry.NumberOfCylinders = DiskGeometry.DiskLength /
DiskGeometry.BytesPerSector /
DiskGeometry.SectorsPerTrack /
DiskGeometry.TracksPerCylinder;

For more clarity you can see the Ramdisk example given in Win NT DDK.

Hope this helps.

Regards,
Prasanna.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Dany Polovets
Sent: Tuesday, March 05, 2002 7:07 PM
To: NT Developers Interest List
Subject: [ntdev] Disk geometry

Hi all !

How is the disk geometry calculated?

Regards,
Dany


You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@store-age.com
To unsubscribe send a blank email to %%email.unsub%%

Disk class drivers get this information either from SCSI port /miniport
driver or through NTDETECT list. All bootable disks need to provide int13h
call, you could make these calls in assembly. you should be able to get
these info using scsi commands MODE SELECT and MODE SENSE

-----Original Message-----
From: Dany Polovets [mailto:xxxxx@store-age.com]
Sent: Tuesday, March 05, 2002 6:31 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Disk geometry

Prasanna,
Thank you for an answer.
I have no problem with virtual geometry.
I would like to know, from where the SCSI disk receives its geometry.
Is it SCSI command that returns a geometry?
From the class disk code, they try to read it from BIOS first, and if
it fails, they try to read it from the port, but it is written, that
only some ports support it.
If it is read from BIOS, is there any known function BIOS uses to calculate
geometry?

Regards,
Dany

-----Original Message-----
From: Prasanna B R [mailto:xxxxx@tataelxsi.co.in]
Sent: Tuesday, March 05, 2002 4:13 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Disk geometry

Hi,
First of, the Disk geometry is obtained through an
“IOCTL_DISK_GET_DRIVE_GEOMETRY”. The disk geometry is obtained in an
“DISK_GEOMETRY” structure. The disk class driver is supposed to provide
this on fetching from the device through the port driver.

If you are writing a virtual disk driver, then for your disk size you need
to calculate number of cylinders. Remaining can be hard coded or can be
combined from multiple disks (like FDisk).

DiskGeometry.DiskLength = 1024 * 1024; // Say 1 MB or fetched from multiple
disks.
DiskGeometry.BytesPerSector = 512;
DiskGeometry.SectorsPerTrack = 32;
DiskGeometry.TracksPerCylinder = 2;
DiskGeometry.NumberOfCylinders = DiskGeometry.DiskLength /
DiskGeometry.BytesPerSector /
DiskGeometry.SectorsPerTrack /
DiskGeometry.TracksPerCylinder;

For more clarity you can see the Ramdisk example given in Win NT DDK.

Hope this helps.

Regards,
Prasanna.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Dany Polovets
Sent: Tuesday, March 05, 2002 7:07 PM
To: NT Developers Interest List
Subject: [ntdev] Disk geometry

Hi all !

How is the disk geometry calculated?

Regards,
Dany


You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@store-age.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@Legato.COM
To unsubscribe send a blank email to %%email.unsub%%

It is taken from IDENTIFY data or SCSI mode pages reported by disk itself.
Nobody (except some bootloaders) cares these C/H/S values now - ATA uses LBA addressing long ago, SCSI always used it.
Anyway these values are fake (just to satisfy the BIOS) for any post-1992 or such disk.

Max

----- Original Message -----
From: “Dany Polovets”
To: “NT Developers Interest List”
Sent: Tuesday, March 05, 2002 4:37 PM
Subject: [ntdev] Disk geometry

Hi all !

How is the disk geometry calculated?

Regards,
Dany


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%

>Is it SCSI command that returns a geometry?

For SCSI, try sending MODE SENSE. Read SCSI-2 spec for details.
For IDE, use SMART_RCV_DRIVE_DATA. This works for non-SMART disks too, even on NT4 :slight_smile:

Max