Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/arch/i386/stand/efiboot Pull up following revision(s)...
details: https://anonhg.NetBSD.org/src/rev/b55507ae135a
branches: netbsd-8
changeset: 454777:b55507ae135a
user: martin <martin%NetBSD.org@localhost>
date: Fri Sep 27 09:40:08 2019 +0000
description:
Pull up following revision(s) (requested by nonaka in ticket #1392):
sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3
x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
diffstat:
sys/arch/i386/stand/efiboot/boot.c | 31 ++++-
sys/arch/i386/stand/efiboot/conf.c | 21 +++-
sys/arch/i386/stand/efiboot/dev_net.c | 10 +-
sys/arch/i386/stand/efiboot/devopen.c | 193 +++++++++++++++++++++++----------
sys/arch/i386/stand/efiboot/devopen.h | 12 +-
5 files changed, 192 insertions(+), 75 deletions(-)
diffs (truncated from 453 to 300 lines):
diff -r 155daa85bfd9 -r b55507ae135a sys/arch/i386/stand/efiboot/boot.c
--- a/sys/arch/i386/stand/efiboot/boot.c Fri Sep 27 09:38:07 2019 +0000
+++ b/sys/arch/i386/stand/efiboot/boot.c Fri Sep 27 09:40:08 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.5.2.8 2019/09/18 17:30:05 martin Exp $ */
+/* $NetBSD: boot.c,v 1.5.2.9 2019/09/27 09:40:08 martin Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -109,6 +109,7 @@
{ NULL, NULL },
};
+static char *default_fsname;
static char *default_devname;
static int default_unit, default_partition;
static const char *default_filename;
@@ -123,8 +124,11 @@
{
const char *col;
static char savedevname[MAXDEVNAME+1];
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+ const struct netboot_fstab *nf;
+#endif
- *fsname = "ufs";
+ *fsname = default_fsname;
if (default_part_name == NULL) {
*devname = default_devname;
} else {
@@ -150,6 +154,7 @@
if (strstr(fname, "NAME=") == fname) {
strlcpy(savedevname, fname, devlen + 1);
+ *fsname = "ufs";
*devname = savedevname;
*unit = -1;
*partition = -1;
@@ -186,6 +191,13 @@
if (i != devlen)
return ENXIO;
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+ nf = netboot_fstab_find(savedevname);
+ if (nf != NULL)
+ *fsname = (char *)nf->name;
+ else
+#endif
+ *fsname = "ufs";
*devname = savedevname;
*unit = u;
*partition = p;
@@ -276,6 +288,9 @@
{
int currname;
int c;
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+ const struct netboot_fstab *nf;
+#endif
boot_modules_enabled = !(boot_params.bp_flags & X86_BP_FLAGS_NOMODULES);
@@ -286,6 +301,14 @@
/* if the user types "boot" without filename */
default_filename = DEFFILENAME;
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+ nf = netboot_fstab_find(default_devname);
+ if (nf != NULL)
+ default_fsname = (char *)nf->name;
+ else
+#endif
+ default_fsname = "ufs";
+
if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) {
#ifdef EFIBOOTCFG_FILENAME
int rv = EINVAL;
@@ -444,7 +467,7 @@
{
static char savedevname[MAXDEVNAME + 1];
char buf[80];
- char *fsname, *devname;
+ char *devname;
const char *file; /* dummy */
if (*arg == '\0') {
@@ -462,7 +485,7 @@
}
if (strchr(arg, ':') == NULL ||
- parsebootfile(arg, &fsname, &devname, &default_unit,
+ parsebootfile(arg, &default_fsname, &devname, &default_unit,
&default_partition, &file)) {
command_help(NULL);
return;
diff -r 155daa85bfd9 -r b55507ae135a sys/arch/i386/stand/efiboot/conf.c
--- a/sys/arch/i386/stand/efiboot/conf.c Fri Sep 27 09:38:07 2019 +0000
+++ b/sys/arch/i386/stand/efiboot/conf.c Fri Sep 27 09:40:08 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.1.12.1 2018/04/11 14:51:43 martin Exp $ */
+/* $NetBSD: conf.c,v 1.1.12.2 2019/09/27 09:40:08 martin Exp $ */
/*
* Copyright (c) 1997
@@ -54,20 +54,23 @@
#endif
#endif
#include <biosdisk.h>
+#include "devopen.h"
#include "efinet.h"
struct devsw devsw[] = {
{ "disk", biosdisk_strategy, biosdisk_open, biosdisk_close, biosdisk_ioctl },
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
{ "net", net_strategy, net_open, net_close, net_ioctl },
+#endif
};
int ndevs = __arraycount(devsw);
+struct netif_driver *netif_drivers[] = {
#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
-struct netif_driver *netif_drivers[] = {
&efinetif,
+#endif
};
int n_netif_drivers = __arraycount(netif_drivers);
-#endif
struct fs_ops file_system[] = {
#ifdef SUPPORT_CD9660
@@ -113,3 +116,15 @@
#ifdef SUPPORT_TFTP
struct fs_ops file_system_tftp = FS_OPS(tftp);
#endif
+
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+const struct netboot_fstab netboot_fstab[] = {
+#ifdef SUPPORT_NFS
+ { "nfs", &file_system_nfs },
+#endif
+#ifdef SUPPORT_TFTP
+ { "tftp", &file_system_tftp },
+#endif
+};
+const int nnetboot_fstab = __arraycount(netboot_fstab);
+#endif
diff -r 155daa85bfd9 -r b55507ae135a sys/arch/i386/stand/efiboot/dev_net.c
--- a/sys/arch/i386/stand/efiboot/dev_net.c Fri Sep 27 09:38:07 2019 +0000
+++ b/sys/arch/i386/stand/efiboot/dev_net.c Fri Sep 27 09:40:08 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dev_net.c,v 1.1.2.3 2019/08/01 13:22:48 martin Exp $ */
+/* $NetBSD: dev_net.c,v 1.1.2.4 2019/09/27 09:40:08 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -76,23 +76,23 @@
net_open(struct open_file *f, ...)
{
va_list ap;
- char *devname; /* Device part of file name (or NULL). */
+ struct devdesc *dev;
int error = 0;
va_start(ap, f);
- devname = va_arg(ap, char *);
+ dev = va_arg(ap, struct devdesc *);
va_end(ap);
#ifdef NETIF_DEBUG
if (debug)
- printf("%s\n", devname);
+ printf("%s\n", dev->devname);
#endif
/* On first open, do netif open, mount, etc. */
if (netdev_opens == 0) {
/* Find network interface. */
if (netdev_sock < 0) {
- netdev_sock = netif_open(devname);
+ netdev_sock = netif_open(dev);
if (netdev_sock < 0) {
printf("netif_open() failed\n");
return ENXIO;
diff -r 155daa85bfd9 -r b55507ae135a sys/arch/i386/stand/efiboot/devopen.c
--- a/sys/arch/i386/stand/efiboot/devopen.c Fri Sep 27 09:38:07 2019 +0000
+++ b/sys/arch/i386/stand/efiboot/devopen.c Fri Sep 27 09:40:08 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.1.12.5 2019/09/17 18:26:53 martin Exp $ */
+/* $NetBSD: devopen.c,v 1.1.12.6 2019/09/27 09:40:08 martin Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -57,6 +57,7 @@
#include "efiboot.h"
#include <lib/libsa/dev_net.h>
+#include <lib/libsa/net.h>
#include <biosdisk.h>
#include "devopen.h"
@@ -106,6 +107,40 @@
}
}
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+const struct netboot_fstab *
+netboot_fstab_find(const char *name)
+{
+ int i;
+
+ if (strcmp(name, "net") == 0)
+ return &netboot_fstab[0];
+
+ for (i = 0; i < nnetboot_fstab; i++) {
+ if (strcmp(name, netboot_fstab[i].name) == 0)
+ return &netboot_fstab[i];
+ }
+
+ return NULL;
+}
+
+static const struct netboot_fstab *
+netboot_fstab_findn(const char *name, size_t len)
+{
+ int i;
+
+ if (strncmp(name, "net", len) == 0)
+ return &netboot_fstab[0];
+
+ for (i = 0; i < nnetboot_fstab; i++) {
+ if (strncmp(name, netboot_fstab[i].name, len) == 0)
+ return &netboot_fstab[i];
+ }
+
+ return NULL;
+}
+#endif
+
struct btinfo_bootpath bibp;
extern bool kernel_loaded;
@@ -115,28 +150,27 @@
int
devopen(struct open_file *f, const char *fname, char **file)
{
-#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
- static const char *net_devnames[] = {
-#if defined(SUPPORT_NFS)
- "nfs",
-#endif
-#if defined(SUPPORT_TFTP)
- "tftp",
-#endif
- };
-#endif
- struct devdesc desc;
- struct devsw *dev;
char *fsname, *devname;
int unit, partition;
int biosdev;
- int i, n, error;
+ int i, error;
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+ struct devdesc desc;
+ const struct netboot_fstab *nf;
+ char *filename;
+ size_t fsnamelen;
+ int n;
+#endif
error = parsebootfile(fname, &fsname, &devname, &unit, &partition,
(const char **) file);
if (error)
return error;
+ memcpy(file_system, file_system_disk,
+ sizeof(struct fs_ops) * nfsys_disk);
+ nfsys = nfsys_disk;
+
/* Search by GPT label or raidframe name */
if ((strstr(devname, "NAME=") == devname) ||
(strstr(devname, "raid") == devname)) {
@@ -151,64 +185,99 @@
return error;
}
- memcpy(file_system, file_system_disk, sizeof(*file_system) * nfsys);
- nfsys = nfsys_disk;
-
+ /*
+ * Network
+ */
#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
- for (i = 0; i < __arraycount(net_devnames); i++) {
- if (strcmp(devname, net_devnames[i]) == 0) {
- fsname = devname;
- devname = "net";
- break;
+ nf = netboot_fstab_find(devname);
+ if (nf != NULL) {
Home |
Main Index |
Thread Index |
Old Index