CONFIG_MBR_OFFSET tells dev/mbr.c where to find the MBR. FUZIX knows how to
parse a standard DOS master boot record and extract partition table entries
to locate and mount drives. A well-behaved disk will have its MBR at block 0.
- If you need to put your MBR elsewhere, use this.
+ If you need to put your MBR elsewhere, use this. Even with this defined,
+ block 0 is still checked first and a valid MBR there is used in preference.
- Set the basic system parameters
blk_op.is_read = true;
blk_op.is_user = false;
blk_op.addr = (uint8_t *)br;
-#ifdef CONFIG_MBR_OFFSET
- blk_op.lba = CONFIG_MBR_OFFSET;
-#else
blk_op.lba = 0;
-#endif
+
do{
blk_op.nblock = 1;
- if(!blk_op.blkdev->transfer() || le16_to_cpu(br->signature) != MBR_SIGNATURE)
+ if(!blk_op.blkdev->transfer() || le16_to_cpu(br->signature) != MBR_SIGNATURE){
+#ifdef CONFIG_MBR_OFFSET
+ if (blk_op.lba == 0) {
+ /* failed to find MBR on block 0. Go round again but this time
+ look at the fall-back location for this badly-behaved media
+ */
+ blk_op.lba = CONFIG_MBR_OFFSET;
+ continue;
+ }
+#endif
break;
+ }
/* avoid an infinite loop where extended boot records form a loop */
if(seen >= 50)
/* Boot devices */
#define BOOTDEVICENAMES "hd#,,,,,,,,dw"
-/* [NAC HACK 2016Apr24] nicer if I didn't hard-wire this? */
-/* This must be a 16-bit number, not a string! See start.c for examples/encoding */
-/* so this is hda1 */
-/* Without this defined, get prompted for root device at boot time */
+/* This must be a 16-bit number, not a string! See start.c for examples/encoding
+ -- so 0x0001 is hda1
+ Without this defined, get prompted for root device at boot time
+*/
#define BOOTDEVICE 0x0001
/* We need a tidier way to do this from the loader */
-/* [NAC HACK 2016Apr24] 0 because we don't have one */
#define CMDLINE NULL /* Location of root dev name */
/* Allow MBR to be other than at block 0. If so, the start LBA of partitions
defined in the MBR are defined relative to the position of the MBR, not
relative to the start of the disk (ie, the values they'd have if the
- MBR was in block 0)
+ MBR was in block 0). Even with this defined, it only acts as a back-up:
+ block 0 is still checked first.
*/
#define CONFIG_MBR_OFFSET (0x30000)