Pi1MHz
Pi1MHz copied to clipboard
BeebSCSI assumes 33 sectors per track
The Adaptec ACB4000 controller emulated by BeebSCSI/Pi1MHzSCSI allows 32 or 33 sectors per track. This cannot be directly set by the user but is calculated by the controller depending on the interleave value sent during the format command. For an interleave of 1, the sectors per track is 32, for all other interleaves it is 33 (see Adaptec Manual p. 2-5).
However, BeebSCSI always assumes 33 sectors per track and this value is hard-coded throughout filesystem.c and scsi.c.
For Superform-formatted Winchester discs this is not a problem as Superform uses an interleave which generates 33 sectors per track. However, other formatters may allow a variable interleave to be selected. It also makes more sense when dealing with flash-memory card storage to use the more convenient value of 32 for sectors per track, since interleave has no meaning or effect on memory cards, to allow the full ADFS size of 2097152 sectors (1024 cyl x 64 hd x 32 spt) to be used with no wastage.
To allow this, the interleave parameter should be read from the format parameters during command code &4 in scsi.c (code is currently commented out) and then a new sectorspertrack variable created depending on the result. This variable should then be used in place of "33" elsewhere in filesystem.c and scsi.c.
A problem is that there is no way to read the interleave value of a formatted disc at a later time, or the sectors per track value. Adaptec Mode Sense will store the sectors per track value in the final byte of a 24-byte mode select/mode sense command block, but this officially is only supported for hard sectored or removable drives, with normal Winchester drives only using a 22-byte block. BeebSCSI only supports 22 byte blocks, using in the ".dsc" files associated with the LUN files.
Either BeebSCSI could be modified to support 24-byte .dsc files, or one of the reserved bytes in the existing 22-byte block could be re-assigned for BeebSCSI purposes as an interleave or sectors-per-track value.