Showing changes from revision #2 to #3:
Added | Removed | Changed
On specific types of formatted discs, a boot block is used to store data that contains important information pertaining to the disc. Currently, FileCore’s boot block is 512 bytes long, and is stored at disc address &C00. The format of the boot block is as follows:
Offset | Contents |
---|---|
&000 upwards | Defect list |
&1BF downwards | Hardware-dependent information |
&1C0 | Disc record |
&1FC | Non-ADFS partition descriptor |
1FF | Checksum byte |
Note: In memory, this information would be stored in the order:
This is to facilitate passing the values to FileCore SWIs.
A defect list contains a list of known defective sectors on the disc. FileCore may use up to two lists to identify all defective sectors on the disc.
The method to determine whether a second defect list is present is by checking the big_flag byte in the disc record. If bit 0 is set, then the second defect list must be present.
Although both lists are similar in how they store the list of defective sectors, there are important differences that should be noted:
Desription | List 1 | List 2 |
---|---|---|
Defective Errors Found | Up to first 512MB on disc | Beyond 512MB on disc |
Data Size | 4 Bytes | 4 Bytes |
Data Format | &ddddddxx |
&ddddddxx |
Meaning of dddddd |
First byte of defective sector | Absolute number of defective sectors |
Meaning of xx |
Checksum byte | Checksum byte |
End of list flag | &200000xx |
&400000xx |
Checksum calculation | Previous entries in first list only | Previous entries in second list only |
Assuming only one list is required (due to an older, ‘small disc record’ being used), this example shows there are no defective sectors.
Offset | Value | Contents |
---|---|---|
&000 | &20000000 | End of list 1 flag |
Assuming two lists are required (due to the newer ‘large disc record’ being used, this example shows there are no defective sectors.
Offset | Value | Contents |
---|---|---|
&000 | &20000000 | End of list 1 flag |
&004 | &40000000 | End of list 2 flag |
The checksum byte is only based on the previous entries contained in their respective list. i.e. checksum byte in list 2 does not compare against entries in list 1, and vice-versa.
The following Assembly code can be used to correctly calculate and update the checksum byte.
MOV Rb,#0 ;init check loop LDR Rc,[Ra],#4 ; get next entry CMPS Rc,#&20000000 ;all done ? EORCC Rb,Rc,Rb,ROR #13 BCC loop EOR Rb,Rb,Rb,LSR #16 ;compress word to byte EOR Rb,Rb,Rb,LSR #8 AND Rb,Rb,#&FF
Where on entry:
Ra = pointer to start defect list
Where on exit:
Ra = corrupt
Rb = checkbyte
Rc = corrupt
As the name suggests, this part of the boot block is used to store information that is specific to the underlying hardware, and as a result will vary in size and contents.
The purpose of the boot block disc record is to give the necessary information to find the disc’s map. You should not rely on the information it contains for any other purpose, unless it is unavailable in the disc’s map. Consequently:
More information on the disc record is found here.
The purpose of this part of the boot block is to decribe any non-ADFS partition on the disc. Such a partition must come at the end of the disc, and is excluded from all descriptions of the ADFS partition.
Offset | Contents |
---|---|
&1FC | Format identifier and flags: |
bits 0 – 3 = Partition format 1 => RISC 2 => RISC iX SCSI LBA addressing |
|
bits 4 – 7 = Flags (reserved- must be zero) | |
&1FD | Low byte of start cylinder |
&1FE | High byte of start cylinder |
You can calculate the disc address of the start of the non-ADFS partition as follows:
start cylinder × heads on drive × sectors per track × bytes per sector
The last byte of the boot block is a checksum. The value of the byte is calculated as follows:
Perform an 8 bit add with carry on each of the other bytes in the block, starting with value 0
CheckSum ROUT STMFD R13!, {R1, LR} ADDS LR, R0, R1 ;->end+1 C=0 SUB R1, LR, #1 ;->check byte MOV R2, #0 B %FT20 10 LDRB LR, [R1,#-1] ! ;get next byte ADC R2, R2, LR ;add into checksum MOVS R2, R2, LSL #24 ;bit 8 = carry MOV R2, R2, LSR #24 20 TEQS R0, R1 BNE %BT10 ;loop until done LDMFD R13!, {R1, LR}
Where on entry:
R0 = Start
R1 = block length
Where on exit:
R0 = Preserved
R1 = Preserved
R2 = Checksum
Please note that the checksum does not include the last byte (itself).