This document discusses the LBA addressing modification made to ADFS.

Change Log:

SBP: Simon Proven

SBP: 22-Aug-1994 Created document.

1.0 Definitions
    
1.1 CHS - Cylinder-Head-Sector
This is the disk addressing method currently used by ADFS (2.93 and less).  
This mechanism causes a clash between DOS and IDE which limits IDE disks 
under DOS to 528MBytes.  ADFS does not suffer from the addressing 
limitations of DOS (although it has its own FileCore induced ones which 
we wish to fix).
          
1.2 LBA - Logical Block Address
A cure for the DOS/IDE addressing problem.  In this method, the sector 
address is treated as a 28 bit number, giving a potential address space of 
128Gbytes.

2.0 Issues
    
2.1 Performance gains
There is a small performance and code size gain in the use of LBA for the 
addressing of IDE disks.  The code size improvement is not an issue, however, 
as we must retain support for the CHS addressing method, in order that disks 
that do not support LBA will still work correctly under ADFS.
    
However, LBA address calculations are much simpler to perform, as all 
operations to generate the task file register fields, can rely on shifting 
and masking operations.  Under CHS addressing, ADFS must do full 32bit 
divide & remainder operations to determine the CHS fields from the block 
address passed by FileCore.
    
2.2 Future Proof
We'll probably need to switch to LBA addressing in the future to support 
very large disks.  We may as well implement this change now while work is 
being done on ADFS, rather than initiate a further change down the road.

2.3 Possible clash between CHS/LBA?
Question: Do sectors have the same physical address under LBA as they did 
under CHS?
                 
There does not at present appear to be a clash.  A disk formatted LBA will 
work with an older version of ADFS.
    
Another problem might be the location of the boot block on the disk.  Before 
we know whether to use CHS or LBA, we must read the boot block.  Fortunately, 
the boot block is very early on the disk, ie near the start of track 0.  This 
should mean we can read it without worrying about the disk addrs getting 
messed up.  Of course, a disk might have a strange mapping which makes this 
assumption untrue, but it seems unlikely. Once we have read the boot block, 
we then start using either CHS or LBA for that disk as defined in the boot 
block.
    
Where do we store the information re LBA vs CHS in the boot block?  The only 
available place is in the hardware dependant information, between &1b0 and 
&1bf (inc.) in the boot block.  We will be in trouble if this is corrupted, 
since any program which has to rebuild the boot block will have to guess 
the CHS/LBA mode.  Its obvious if the drive doesn't support LBA, but 
otherwise it will have to ask the user or make some form of intelligent guess.
 
Formatting may also be an issue, as the disk drive only accepts logical track 
numbers for formatting.  For large drives, with secs per track set to 63, 
we run out of bits in the cylinder no.  Can we assume that for very large 
drives, the number of sectors may be >63, allowing format to work properly?
    
Also, format has another problem.  The boot block will be undefined, meaning 
that ADFS will not know whether to use CHS or LBA.  Three approaches strike 
me as feasible:
    
1)  If the disk hasn't yet been mounted, use the Identify Disk information 
and assume LBA to be used if supported.  This isn't very flexible.
        
2)  Assume that the disc record is always at &C00.  (PRM page 2-213, ”Hard 
discs contain a 512 byte boot block at disc address &C00...•  As the boot 
block will always be in this place, ADFS may assume that any disc address 
up to and including the boot block should be read or written CHS.  After 
boot block has been read, we know the LBA flag.  When we format a disk, 
in order to get ADFS to choose the correct CHS/LBA mode when writing the 
map & root directory, we mount the disc after writing the boot block.  Thus 
ADFS reads the CHS/LBA flag.

3)  Have a SWI to tell ADFS to use CHS or LBA in the absence of any other 
method to tell ADFS this information.
        
I have decided upon method 2.

3.0 Bits to change
    To implement LBA addressing, we need to:
    
Add support for the LBA bit in the boot block h/w dependant area, ie in ADFS 
mount (FileCore_MiscOp 0), and in !Hform.  Need to know what ADFS already 
stores in there...
    
Add code to WinIDESetPhysAddress (s.Adfs14 line 1511) to set up the LBA 
parameters if supported.  Also code to convert in the opposite direction 
(WinIDEPhysicalToLogical or something).  Need to watch out though - only 
a subset of commands use LBA; format track for instance has to use CHS.
    
Add support to !HForm for checking the LBA feature in the drive and adjusting 
the boot block as necessary.
    
4.0 Summary of alterations
4.1 Change to ADFS mount routine
ADFS mount now checks the LBA bit in the disk record and records this 
fact in internal workspace for the drive.

4.2 Change to ADFS disk addressing
ADFS will use LBA if the feature is enabled in the boot block when 
addressing the disk.
    
4.3 Change to formatter (!Hform)
Formatter will write boot block with CHS or LBA mode selected, as 
determined by the user.  LBA option will not be presented by !HForm if 
this option is not available.

5.0 Alternate IDE controller?
ADFS allows an alternate controller for the IDE hard disk to be specified.  
How does this controller affect the operation of CHS/LBA mode?

