summaryrefslogtreecommitdiff
path: root/sys/stand
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>2021-05-26 09:42:36 +0000
committermrg <mrg@NetBSD.org>2021-05-26 09:42:36 +0000
commite4249c081d63bf98d9d8bee2e78a21a25c9ea0a8 (patch)
tree135667128d3106ba7b76340512fae26d3f8df0ec /sys/stand
parent26600852cd0e84a0d0a04cb335a6ce2197e4f023 (diff)
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.
Diffstat (limited to 'sys/stand')
-rw-r--r--sys/stand/efiboot/efiblock.c21
-rw-r--r--sys/stand/efiboot/version3
2 files changed, 20 insertions, 4 deletions
diff --git a/sys/stand/efiboot/efiblock.c b/sys/stand/efiboot/efiblock.c
index edfeeb44c9d..024911bb046 100644
--- a/sys/stand/efiboot/efiblock.c
+++ b/sys/stand/efiboot/efiblock.c
@@ -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 <nonaka@netbsd.org>
@@ -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(struct efi_block_dev *bdev, struct mbr_secto
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(struct efi_block_dev *bdev, struct mbr_secto
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(struct efi_block_dev *bdev, struct gpt_hdr *
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);
diff --git a/sys/stand/efiboot/version b/sys/stand/efiboot/version
index c6be233699d..ac4d48c92bf 100644
--- a/sys/stand/efiboot/version
+++ b/sys/stand/efiboot/version
@@ -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.