To: SCSI-2 CAM Committee From: Judy Polonsky Subject: Physical to/from Logical Block Address Conversion Fixed disk boot devices are described physically in terms of CYLINDER/HEAD/SECTORS per TRACK through BIOS INT 13h, function 08h and by drive geometry table pointers INT 41h (drive 0) and INT 46h (drive 1). Operating systems (DOS, Xenix, Novell, OS/2,etc.) use the INT 13h call and/or examine the INT 41h/46h tables directly to determine device capacity and to issue I/O requests before O/S-specific ram-resident drivers are installed (which in some cases, continue to use the INT 13h protocol). The standard partition table structure, the means by which each O/S determines which portion of the device it "owns", also uses CYLINDER/HEAD/SECTOR to specify beginning/end of a given partition. Both the INT 13h interface and the partition table define 10 bits for cylinder, 8 bits for head, and 6 bits for sector. Since boot code uses the physical address in the partition table to load in a given OS's partition, a common algorithm by which to convert SCSI logical block capacity to this physical interface is essential for devices such as fixed removable media to maintain bootability across different host bus adapters. A standard conversion algorithm could be based on fake fixed physical parameters which bear no relation to real geometry, based on actual mode sense geometry within the bit constraints of INT 13h interface, or based on some combination of the above. Options for converting logical to physical capacity would be the following ( comments /criticisms needed!): I. Ignoring mode sense geometry a) Heads and Secs/trk fixed at maximum values (256 and 64 repectively) - This has advantage of being straightforward but can waste alot of disk space on the remainder of the disk which can't fit into an integral "cylinder" - up to 8MB (256 hds * 64 spt * 512 bytes). b) Heads and Secs/trk fixed initially at small values (4 and 17 respectively) - Calculate "cyls" as a function of fixed heads and spt. If they don't fit (> 1024), heads or spt can be bumped til logical capacity is fully described. Starting with 17 secs per track has the advantage of maintaining compatibility some O/S 's - old versions of DOS, Novell - which assume 17 secs/trk. However, it can result in greater number of smaller I/O requests under DOS versions which don't cross head boundaries than an algorithm which created larger "tracks" and fewer heads. Don't care under Unix/Xenix,Novell,etc. since the requests are fixed block sizes in those environments. II. Using Mode Sense Geometry If actual geometry parameters returned by MODE sense fit within the imposed bit constraints , use them. This allows for performance tuning. (NOTE: actual capacity reported to O/S does not include areas reserved by drive for defect management - READ CAPACITY results is probably the actual logical capacity to be described physically. Also, the last "cylinder" is reserved by INT 13h bios drivers for diagnostics ). If actual geometry does not fit, there are several options: 1) Truncation of cyls or spt ( whatever doesn't fit) - not a good option as much capacity can be lost. 2) Default to one of the algorithms in I. above (no relation to actual geometry). 3) Adjust remaining two physical parameter til the overflowing parameter is within its maximum allowable value (1024 cyls,64 spt) starting from their actual mode sense values rather than some small or large fixed defaults. Example. Cylinders too large - a) Bump heads exclusively till cylinders fit or max head value is reached. If max head is reached, bump secs/trk til cyls fit or max secs/trk is reached. If max secs/trk is reached , cylinders should be set to max cylinders (256 hds * 64 spt * 1024 cyls = 8 gigabytes). b) Bump spt exclusively till cylinders fit or max spt value is reached. If max spt is reached, bump heads til cyls fit or max heads is reached. If max heads is reached , cylinders should be set to max cylinders (256 hds * 64 spt * 1024 cyls = 8 gigabytes). Example. Sectors per Track too large - Leaving cylinders fixed, set sectors per track to maximum allowable value and calculate heads as a function of these 2 values. Example. Sectors per track and Cylinders too large - Set cylinders and secs per track to their maximum allowable values and calculate heads as a function of these two values.