add basic raidframe support to efiboot. if raid disklabel or gpt is found, add this partition with the offset/size adjusted by RF_PROTECTED_SECTORS. note don't le32toh() the disklabel. if it was wrong-endian, then getdisklabel() will have swapped it. Index: efiblock.c =================================================================== RCS file: /cvsroot/src/sys/stand/efiboot/efiblock.c,v retrieving revision 1.10 diff -p -u -r1.10 efiblock.c --- efiblock.c 28 Nov 2020 15:24:05 -0000 1.10 +++ efiblock.c 26 May 2021 04:11:15 -0000 @@ -38,6 +38,13 @@ #include "efiboot.h" #include "efiblock.h" +/* + * The raidframe support is basic. Ideally, it should be expanded to + * consider raid volumes a first-class citizen like the x86 efiboot does, + * but for now, we simply assume each RAID is potentially bootable. + */ +#define RF_PROTECTED_SECTORS 64 /* XXX refer to <.../rf_optnames.h> */ + static EFI_HANDLE *efi_block; static UINTN efi_nblock; static struct efi_block_part *efi_block_booted = NULL; @@ -217,6 +224,10 @@ efi_block_find_partitions_disklabel(stru case FS_MSDOS: case FS_BSDLFS: break; + case FS_RAID: + p->p_size -= RF_PROTECTED_SECTORS; + p->p_offset += RF_PROTECTED_SECTORS; + break; default: continue; } @@ -225,7 +236,7 @@ efi_block_find_partitions_disklabel(stru bpart->index = n; bpart->bdev = bdev; bpart->type = EFI_BLOCK_PART_DISKLABEL; - bpart->disklabel.secsize = le32toh(d.d_secsize); + bpart->disklabel.secsize = d.d_secsize; bpart->disklabel.part = *p; efi_block_generate_hash_mbr(bpart, mbr); TAILQ_INSERT_TAIL(&bdev->partitions, bpart, entries); @@ -310,6 +321,10 @@ efi_block_find_partitions_gpt_entry(stru bpart->type = EFI_BLOCK_PART_GPT; bpart->gpt.fstype = fstype; bpart->gpt.ent = *ent; + if (fstype == FS_RAID) { + bpart->gpt.ent.ent_lba_start += RF_PROTECTED_SECTORS; + bpart->gpt.ent.ent_lba_end -= RF_PROTECTED_SECTORS; + } memcpy(bpart->hash, ent->ent_guid, sizeof(bpart->hash)); TAILQ_INSERT_TAIL(&bdev->partitions, bpart, entries); @@ -436,7 +451,7 @@ efi_block_probe(void) fstype = FS_ISO9660; break; } - if (fstype == FS_BSDFFS || fstype == FS_ISO9660) { + if (fstype == FS_BSDFFS || fstype == FS_ISO9660 || fstype == FS_RAID) { char devname[9]; snprintf(devname, sizeof(devname), "hd%u%c", bdev->index, bpart->index + 'a'); set_default_device(devname); Index: version =================================================================== RCS file: /cvsroot/src/sys/stand/efiboot/version,v retrieving revision 1.23 diff -p -u -r1.23 version --- version 21 May 2021 21:53:15 -0000 1.23 +++ version 26 May 2021 04:11:15 -0000 @@ -27,3 +27,4 @@ is taken as the current. 2.4: Add ISO9660 support. 2.5: Recognize the EFI system partion as fstype MSDOS. 2.6: Disable ACPI support when booting big endian kernels. +2.7: Add basic support for booting from RAID1 volumes.