Module Name: src
Committed By: mrg
Date: Wed May 26 09:42:36 UTC 2021
Modified Files:
src/sys/stand/efiboot: efiblock.c version
Log Message:
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.
ok jmcneill thorpej.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/version
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/stand/efiboot/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.10 src/sys/stand/efiboot/efiblock.c:1.11
--- src/sys/stand/efiboot/efiblock.c:1.10 Sat Nov 28 15:24:05 2020
+++ src/sys/stand/efiboot/efiblock.c Wed May 26 09:42:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.10 2020/11/28 15:24:05 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.11 2021/05/26 09:42:36 mrg Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <[email protected]>
@@ -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: src/sys/stand/efiboot/version
diff -u src/sys/stand/efiboot/version:1.23 src/sys/stand/efiboot/version:1.24
--- src/sys/stand/efiboot/version:1.23 Fri May 21 21:53:15 2021
+++ src/sys/stand/efiboot/version Wed May 26 09:42:36 2021
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.23 2021/05/21 21:53:15 jmcneill Exp $
+$NetBSD: version,v 1.24 2021/05/26 09:42:36 mrg Exp $
NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this
file is important - make sure the entries are appended on end, last item
@@ -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.