Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys Pull up following revision(s) (requested by nonaka in...
details: https://anonhg.NetBSD.org/src/rev/6a738d1715ed
branches: netbsd-8
changeset: 434824:6a738d1715ed
user: martin <martin%NetBSD.org@localhost>
date: Wed Apr 04 16:34:39 2018 +0000
description:
Pull up following revision(s) (requested by nonaka in ticket #692):
sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10
efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
diffstat:
sys/arch/i386/stand/efiboot/TODO.efiboot | 1 -
sys/arch/i386/stand/efiboot/boot.c | 10 +++++++-
sys/arch/i386/stand/efiboot/devopen.c | 20 ++++++++++++++---
sys/arch/i386/stand/efiboot/devopen.h | 5 +++-
sys/arch/i386/stand/efiboot/efidisk.c | 36 +++++++++++++++++++++++++++++++-
sys/arch/i386/stand/efiboot/efidisk.h | 3 +-
sys/arch/i386/stand/lib/biosdisk.c | 6 ++--
sys/arch/i386/stand/lib/biosdisk.h | 8 ++++++-
sys/arch/i386/stand/lib/bootmenu.c | 6 ++--
sys/arch/i386/stand/lib/bootmenu.h | 4 +-
sys/lib/libsa/bootcfg.c | 14 +++++++-----
sys/lib/libsa/bootcfg.h | 4 +-
12 files changed, 90 insertions(+), 27 deletions(-)
diffs (truncated from 319 to 300 lines):
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/efiboot/TODO.efiboot
--- a/sys/arch/i386/stand/efiboot/TODO.efiboot Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/TODO.efiboot Wed Apr 04 16:34:39 2018 +0000
@@ -1,6 +1,5 @@
- efiboot
* handle UEFI variables
- * load boot.cfg from EFI system partition (FAT32)
- kernel
* handle UEFI variables (/dev/efivar)
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/efiboot/boot.c
--- a/sys/arch/i386/stand/efiboot/boot.c Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/boot.c Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.5.2.3 2018/04/02 08:50:33 martin Exp $ */
+/* $NetBSD: boot.c,v 1.5.2.4 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -55,7 +55,9 @@
#define NUMNAMES __arraycount(names)
#define DEFFILENAME names[0][0]
-#define MAXDEVNAME 16
+#ifndef EFIBOOTCFG_FILENAME
+#define EFIBOOTCFG_FILENAME "esp:/EFI/NetBSD/boot.cfg"
+#endif
void command_help(char *);
void command_quit(char *);
@@ -273,6 +275,10 @@
default_filename = DEFFILENAME;
if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) {
+#ifdef EFIBOOTCFG_FILENAME
+ int rv = parsebootconf(EFIBOOTCFG_FILENAME);
+ if (rv)
+#endif
parsebootconf(BOOTCFG_FILENAME);
} else {
bootcfg_info.timeout = boot_params.bp_timeout;
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/efiboot/devopen.c
--- a/sys/arch/i386/stand/efiboot/devopen.c Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/devopen.c Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.1.12.2 2018/03/21 10:50:49 martin Exp $ */
+/* $NetBSD: devopen.c,v 1.1.12.3 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -59,6 +59,7 @@
#include <biosdisk.h>
#include "devopen.h"
#include <bootinfo.h>
+#include "efidisk.h"
static int
dev2bios(char *devname, int unit, int *biosdev)
@@ -103,9 +104,20 @@
int biosdev;
int error;
- if ((error = parsebootfile(fname, &fsname, &devname,
- &unit, &partition, (const char **) file))
- || (error = dev2bios(devname, unit, &biosdev)))
+ error = parsebootfile(fname, &fsname, &devname, &unit, &partition,
+ (const char **) file);
+ if (error)
+ return error;
+
+ if (strcmp(devname, "esp") == 0) {
+ bios2dev(boot_biosdev, boot_biossector, &devname, &unit,
+ &partition);
+ if (efidisk_get_efi_system_partition(boot_biosdev, &partition))
+ return ENXIO;
+ }
+
+ error = dev2bios(devname, unit, &biosdev);
+ if (error)
return error;
f->f_dev = &devsw[0]; /* must be biosdisk */
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/efiboot/devopen.h
--- a/sys/arch/i386/stand/efiboot/devopen.h Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/devopen.h Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.h,v 1.1 2017/01/24 11:09:14 nonaka Exp $ */
+/* $NetBSD: devopen.h,v 1.1.12.1 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -27,5 +27,8 @@
*/
extern int boot_biosdev;
+extern daddr_t boot_biossector;
+
+#define MAXDEVNAME 16
void bios2dev(int, daddr_t, char **, int *, int *);
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/efiboot/efidisk.c
--- a/sys/arch/i386/stand/efiboot/efidisk.c Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/efidisk.c Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efidisk.c,v 1.1.12.3 2018/04/02 08:50:33 martin Exp $ */
+/* $NetBSD: efidisk.c,v 1.1.12.4 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -213,3 +213,37 @@
{
return nefidisks;
}
+
+int
+efidisk_get_efi_system_partition(int dev, int *partition)
+{
+ extern const struct uuid GET_efi;
+ const struct efidiskinfo *edi;
+ struct biosdisk_partition *part;
+ int i, nparts;
+
+ edi = efidisk_getinfo(dev);
+ if (edi == NULL)
+ return ENXIO;
+
+ if (edi->type != BIOSDISK_TYPE_HD)
+ return ENOTSUP;
+
+ if (biosdisk_readpartition(edi->dev, &part, &nparts))
+ return EIO;
+
+ for (i = 0; i < nparts; i++) {
+ if (part[i].size == 0)
+ continue;
+ if (part[i].fstype == FS_UNUSED)
+ continue;
+ if (guid_is_equal(part[i].guid->guid, &GET_efi))
+ break;
+ }
+ dealloc(part, sizeof(*part) * nparts);
+ if (i == nparts)
+ return ENOENT;
+
+ *partition = i;
+ return 0;
+}
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/efiboot/efidisk.h
--- a/sys/arch/i386/stand/efiboot/efidisk.h Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/efidisk.h Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efidisk.h,v 1.1.12.1 2018/03/13 14:54:52 martin Exp $ */
+/* $NetBSD: efidisk.h,v 1.1.12.2 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -40,3 +40,4 @@
TAILQ_HEAD(efidiskinfo_lh, efidiskinfo);
const struct efidiskinfo *efidisk_getinfo(int);
+int efidisk_get_efi_system_partition(int, int *);
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/lib/biosdisk.c
--- a/sys/arch/i386/stand/lib/biosdisk.c Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/lib/biosdisk.c Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: biosdisk.c,v 1.46.6.2 2018/03/21 10:50:49 martin Exp $ */
+/* $NetBSD: biosdisk.c,v 1.46.6.3 2018/04/04 16:34:39 martin Exp $ */
/*
* Copyright (c) 1996, 1998
@@ -249,14 +249,14 @@
#endif
#ifndef NO_GPT
-static bool
+bool
guid_is_nil(const struct uuid *u)
{
static const struct uuid nil = { .time_low = 0 };
return (memcmp(u, &nil, sizeof(*u)) == 0 ? true : false);
}
-static bool
+bool
guid_is_equal(const struct uuid *a, const struct uuid *b)
{
return (memcmp(a, b, sizeof(*a)) == 0 ? true : false);
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/lib/biosdisk.h
--- a/sys/arch/i386/stand/lib/biosdisk.h Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/lib/biosdisk.h Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: biosdisk.h,v 1.8.52.1 2018/03/13 14:54:52 martin Exp $ */
+/* $NetBSD: biosdisk.h,v 1.8.52.2 2018/04/04 16:34:39 martin Exp $ */
/*
* Copyright (c) 1996
@@ -44,3 +44,9 @@
int biosdisk_ioctl(struct open_file *, u_long, void *);
int biosdisk_findpartition(int, daddr_t);
int biosdisk_readpartition(int, struct biosdisk_partition **, int *);
+
+#if !defined(NO_GPT)
+struct uuid;
+bool guid_is_nil(const struct uuid *);
+bool guid_is_equal(const struct uuid *, const struct uuid *);
+#endif
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/lib/bootmenu.c
--- a/sys/arch/i386/stand/lib/bootmenu.c Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.c Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bootmenu.c,v 1.16 2016/06/11 06:20:11 dholland Exp $ */
+/* $NetBSD: bootmenu.c,v 1.16.10.1 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,10 +63,10 @@
userconf_add(arg);
}
-void
+int
parsebootconf(const char *conf)
{
- perform_bootcfg(conf, &do_bootcfg_command, 32768);
+ return perform_bootcfg(conf, &do_bootcfg_command, 32768);
}
/*
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/arch/i386/stand/lib/bootmenu.h
--- a/sys/arch/i386/stand/lib/bootmenu.h Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.h Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bootmenu.h,v 1.5 2014/08/10 07:40:49 isaki Exp $ */
+/* $NetBSD: bootmenu.h,v 1.5.20.1 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#define COMMAND_SEPARATOR ';'
-void parsebootconf(const char *);
+int parsebootconf(const char *);
void doboottypemenu(void);
void bootdefault(void);
diff -r f2ea4afa45e5 -r 6a738d1715ed sys/lib/libsa/bootcfg.c
--- a/sys/lib/libsa/bootcfg.c Wed Apr 04 16:29:24 2018 +0000
+++ b/sys/lib/libsa/bootcfg.c Wed Apr 04 16:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bootcfg.c,v 1.2 2014/08/10 07:40:49 isaki Exp $ */
+/* $NetBSD: bootcfg.c,v 1.2.22.1 2018/04/04 16:34:39 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@
* consdev=com0
* default=1
*/
-void
+int
perform_bootcfg(const char *conf, bootcfg_command command, const off_t maxsz)
{
char *bc, *c;
@@ -114,25 +114,25 @@
fd = open(conf, 0);
if (fd < 0)
- return;
+ return ENOENT;
err = fstat(fd, &st);
if (err == -1) {
close(fd);
- return;
+ return EIO;
}
/* if a maximum size is being requested for the boot.cfg enforce it. */
if (0 < maxsz && st.st_size > maxsz) {
close(fd);
- return;
+ return EFBIG;
}
bc = alloc(st.st_size + 1);
if (bc == NULL) {
printf("Could not allocate memory for boot configuration\n");
close(fd);
- return;
+ return ENOMEM;
}
/*
@@ -269,4 +269,6 @@
bootcfg_info.def = 0;
if (bootcfg_info.def >= cmenu)
bootcfg_info.def = cmenu - 1;
+
+ return 0;
Home |
Main Index |
Thread Index |
Old Index