Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/stand/efiboot Add ISO9660 support.
details: https://anonhg.NetBSD.org/src/rev/a3b1d5e96719
branches: trunk
changeset: 955774:a3b1d5e96719
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Oct 11 14:03:33 2020 +0000
description:
Add ISO9660 support.
diffstat:
sys/stand/efiboot/Makefile.efiboot | 4 +-
sys/stand/efiboot/boot.c | 41 +++++++++++++++++++++--
sys/stand/efiboot/conf.c | 4 +-
sys/stand/efiboot/efiblock.c | 64 ++++++++++++++++++++++++++++++++++++-
sys/stand/efiboot/efiblock.h | 5 +-
sys/stand/efiboot/efiboot.h | 4 +-
sys/stand/efiboot/version | 3 +-
7 files changed, 112 insertions(+), 13 deletions(-)
diffs (294 lines):
diff -r 1fb214e44840 -r a3b1d5e96719 sys/stand/efiboot/Makefile.efiboot
--- a/sys/stand/efiboot/Makefile.efiboot Sun Oct 11 10:12:53 2020 +0000
+++ b/sys/stand/efiboot/Makefile.efiboot Sun Oct 11 14:03:33 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.18 2020/09/06 07:20:31 mrg Exp $
+# $NetBSD: Makefile.efiboot,v 1.19 2020/10/11 14:03:33 jmcneill Exp $
S= ${.CURDIR}/../../..
@@ -71,7 +71,7 @@
CPPFLAGS+= -Wno-pointer-sign
CPPFLAGS+= -DHEAP_VARIABLE
-#CPPFLAGS+= -DSUPPORT_CD9660
+CPPFLAGS+= -DSUPPORT_CD9660
CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
CPPFLAGS+= -DSUPPORT_DOSFS
#CPPFLAGS+= -DSUPPORT_EXT2FS
diff -r 1fb214e44840 -r a3b1d5e96719 sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c Sun Oct 11 10:12:53 2020 +0000
+++ b/sys/stand/efiboot/boot.c Sun Oct 11 14:03:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.27 2020/06/28 11:39:50 jmcneill Exp $ */
+/* $NetBSD: boot.c,v 1.28 2020/10/11 14:03:33 jmcneill Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -75,6 +75,7 @@
};
static char default_device[32];
+static int default_fstype = FS_UNUSED;
static char initrd_path[255];
static char dtb_path[255];
static char netbsd_path[255];
@@ -128,6 +129,27 @@
{ NULL, NULL },
};
+static int
+bootcfg_path(char *pathbuf, size_t pathbuflen)
+{
+ /*
+ * Special handling of boot.cfg on ISO9660 because fs protocol doesn't
+ * seem to work.
+ */
+ if (default_fstype == FS_ISO9660) {
+ snprintf(pathbuf, pathbuflen, "%s:%s", default_device, BOOTCFG_FILENAME);
+ return 0;
+ }
+
+ /*
+ * Fall back to fs protocol for loading boot.cfg
+ */
+ if (efi_bootdp == NULL)
+ return ENXIO;
+
+ return efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, pathbuflen);
+}
+
void
command_help(char *arg)
{
@@ -318,8 +340,7 @@
ST->FirmwareRevision);
FreePool(ufirmware);
}
- if (efi_bootdp != NULL &&
- efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, sizeof(pathbuf)) == 0) {
+ if (bootcfg_path(pathbuf, sizeof(pathbuf)) == 0) {
printf("Config path: %s\n", pathbuf);
}
@@ -355,6 +376,18 @@
return default_device;
}
+void
+set_default_fstype(int fstype)
+{
+ default_fstype = fstype;
+}
+
+int
+get_default_fstype(void)
+{
+ return default_fstype;
+}
+
int
set_initrd_path(const char *arg)
{
@@ -432,7 +465,7 @@
char pathbuf[80];
int currname, c;
- if (efi_bootdp != NULL && efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, sizeof(pathbuf)) == 0) {
+ if (bootcfg_path(pathbuf, sizeof(pathbuf)) == 0) {
twiddle_toggle = 1;
parsebootconf(pathbuf);
}
diff -r 1fb214e44840 -r a3b1d5e96719 sys/stand/efiboot/conf.c
--- a/sys/stand/efiboot/conf.c Sun Oct 11 10:12:53 2020 +0000
+++ b/sys/stand/efiboot/conf.c Sun Oct 11 14:03:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.4 2018/11/15 23:52:33 jmcneill Exp $ */
+/* $NetBSD: conf.c,v 1.5 2020/10/11 14:03:33 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -33,6 +33,7 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/ufs.h>
#include <lib/libsa/dosfs.h>
+#include <lib/libsa/cd9660.h>
#include <lib/libsa/tftp.h>
#include <lib/libsa/nfs.h>
#include <lib/libsa/net.h>
@@ -55,6 +56,7 @@
FS_OPS(ffsv1),
FS_OPS(ffsv2),
FS_OPS(dosfs),
+ FS_OPS(cd9660),
};
int nfsys = __arraycount(file_system);
diff -r 1fb214e44840 -r a3b1d5e96719 sys/stand/efiboot/efiblock.c
--- a/sys/stand/efiboot/efiblock.c Sun Oct 11 10:12:53 2020 +0000
+++ b/sys/stand/efiboot/efiblock.c Sun Oct 11 14:03:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.7 2019/09/27 20:10:42 jakllsch Exp $ */
+/* $NetBSD: efiblock.c,v 1.8 2020/10/11 14:03:33 jmcneill Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -33,6 +33,8 @@
#include <sys/md5.h>
#include <sys/uuid.h>
+#include <fs/cd9660/iso.h>
+
#include "efiboot.h"
#include "efiblock.h"
@@ -116,6 +118,53 @@
}
static int
+efi_block_find_partitions_cd9660(struct efi_block_dev *bdev)
+{
+ struct efi_block_part *bpart;
+ struct iso_primary_descriptor *vd;
+ void *buf, *buf_start;
+ EFI_STATUS status;
+ EFI_LBA lba;
+ UINT32 sz;
+
+ sz = __MAX(sizeof(*vd), bdev->bio->Media->BlockSize);
+ sz = roundup(sz, bdev->bio->Media->BlockSize);
+ if ((buf = efi_block_allocate_device_buffer(bdev, sz, &buf_start)) == NULL)
+ return ENOMEM;
+
+ for (lba = 16;; lba++) {
+ status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id,
+ lba, sz, buf_start);
+ if (EFI_ERROR(status))
+ goto io_error;
+
+ vd = (struct iso_primary_descriptor *)buf_start;
+ if (memcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0)
+ goto io_error;
+ if (isonum_711(vd->type) == ISO_VD_END)
+ goto io_error;
+ if (isonum_711(vd->type) == ISO_VD_PRIMARY)
+ break;
+ }
+
+ if (isonum_723(vd->logical_block_size) != ISO_DEFAULT_BLOCK_SIZE)
+ goto io_error;
+
+ bpart = alloc(sizeof(*bpart));
+ bpart->index = 0;
+ bpart->bdev = bdev;
+ bpart->type = EFI_BLOCK_PART_CD9660;
+ TAILQ_INSERT_TAIL(&bdev->partitions, bpart, entries);
+
+ FreePool(buf);
+ return 0;
+
+io_error:
+ FreePool(buf);
+ return EIO;
+}
+
+static int
efi_block_find_partitions_disklabel(struct efi_block_dev *bdev, struct mbr_sector *mbr, uint32_t start, uint32_t size)
{
struct efi_block_part *bpart;
@@ -310,6 +359,8 @@
error = efi_block_find_partitions_gpt(bdev);
if (error)
error = efi_block_find_partitions_mbr(bdev);
+ if (error)
+ error = efi_block_find_partitions_cd9660(bdev);
return error;
}
@@ -365,11 +416,15 @@
case EFI_BLOCK_PART_GPT:
fstype = bpart->gpt.fstype;
break;
+ case EFI_BLOCK_PART_CD9660:
+ fstype = FS_ISO9660;
+ break;
}
- if (fstype == FS_BSDFFS) {
+ if (fstype == FS_BSDFFS || fstype == FS_ISO9660) {
char devname[9];
snprintf(devname, sizeof(devname), "hd%u%c", bdev->index, bpart->index + 'a');
set_default_device(devname);
+ set_default_fstype(fstype);
break;
}
}
@@ -451,6 +506,9 @@
printf("%s\n", fstypenames[bpart->gpt.fstype]);
break;
+ case EFI_BLOCK_PART_CD9660:
+ printf(" hd%u%c %s\n", bdev->index, bpart->index + 'a', fstypenames[FS_ISO9660]);
+ break;
default:
break;
}
@@ -533,6 +591,8 @@
}
dblk += le64toh(bpart->gpt.ent.ent_lba_start);
break;
+ case EFI_BLOCK_PART_CD9660:
+ break;
default:
return EINVAL;
}
diff -r 1fb214e44840 -r a3b1d5e96719 sys/stand/efiboot/efiblock.h
--- a/sys/stand/efiboot/efiblock.h Sun Oct 11 10:12:53 2020 +0000
+++ b/sys/stand/efiboot/efiblock.h Sun Oct 11 14:03:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.h,v 1.3 2018/11/01 00:43:38 jmcneill Exp $ */
+/* $NetBSD: efiblock.h,v 1.4 2020/10/11 14:03:33 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,8 @@
enum efi_block_part_type {
EFI_BLOCK_PART_DISKLABEL,
- EFI_BLOCK_PART_GPT
+ EFI_BLOCK_PART_GPT,
+ EFI_BLOCK_PART_CD9660
};
struct efi_block_part;
diff -r 1fb214e44840 -r a3b1d5e96719 sys/stand/efiboot/efiboot.h
--- a/sys/stand/efiboot/efiboot.h Sun Oct 11 10:12:53 2020 +0000
+++ b/sys/stand/efiboot/efiboot.h Sun Oct 11 14:03:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.h,v 1.13 2020/07/15 00:51:40 jmcneill Exp $ */
+/* $NetBSD: efiboot.h,v 1.14 2020/10/11 14:03:33 jmcneill Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -56,6 +56,8 @@
void command_help(char *);
int set_default_device(const char *);
char *get_default_device(void);
+void set_default_fstype(int);
+int get_default_fstype(void);
int set_initrd_path(const char *);
char *get_initrd_path(void);
int set_dtb_path(const char *);
diff -r 1fb214e44840 -r a3b1d5e96719 sys/stand/efiboot/version
--- a/sys/stand/efiboot/version Sun Oct 11 10:12:53 2020 +0000
+++ b/sys/stand/efiboot/version Sun Oct 11 14:03:33 2020 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.20 2020/10/10 19:17:39 jmcneill Exp $
+$NetBSD: version,v 1.21 2020/10/11 14:03:33 jmcneill 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
@@ -24,3 +24,4 @@
2.1: Remove efiboot.plist support; support dtoverlay in boot.cfg.
2.2: Remove support for storing settings in EFI env vars.
2.3: EFI RT and GOP support for devicetree mode.
+2.4: Add ISO9660 support.
Home |
Main Index |
Thread Index |
Old Index