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/8c9b3e064218
branches: netbsd-8
changeset: 434884:8c9b3e064218
user: martin <martin%NetBSD.org@localhost>
date: Wed Apr 11 14:51:43 2018 +0000
description:
Pull up following revision(s) (requested by nonaka in ticket #739):
sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1
efiboot: Added network boot support.
diffstat:
sys/arch/i386/stand/efiboot/Makefile.efiboot | 30 +-
sys/arch/i386/stand/efiboot/boot.c | 31 +-
sys/arch/i386/stand/efiboot/conf.c | 50 ++-
sys/arch/i386/stand/efiboot/dev_net.c | 3 +
sys/arch/i386/stand/efiboot/devopen.c | 89 ++++-
sys/arch/i386/stand/efiboot/devopen.h | 12 +-
sys/arch/i386/stand/efiboot/efiboot.c | 13 +-
sys/arch/i386/stand/efiboot/efiboot.h | 18 +-
sys/arch/i386/stand/efiboot/efidisk.c | 4 +-
sys/arch/i386/stand/efiboot/efinet.c | 480 +++++++++++++++++++++++++++
sys/arch/i386/stand/efiboot/efinet.h | 29 +
sys/arch/i386/stand/efiboot/efipxe.c | 141 +++++++
12 files changed, 872 insertions(+), 28 deletions(-)
diffs (truncated from 1131 to 300 lines):
diff -r 02dc6175dee1 -r 8c9b3e064218 sys/arch/i386/stand/efiboot/Makefile.efiboot
--- a/sys/arch/i386/stand/efiboot/Makefile.efiboot Wed Apr 11 14:49:08 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/Makefile.efiboot Wed Apr 11 14:51:43 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.9.2.2 2018/04/02 08:50:33 martin Exp $
+# $NetBSD: Makefile.efiboot,v 1.9.2.3 2018/04/11 14:51:43 martin Exp $
S= ${.CURDIR}/../../../../..
@@ -8,12 +8,12 @@
AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-SOURCES?= start.S conf.c devopen.c efiboot.c self_reloc.c
-LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
-LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
-LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
-LIBI386SRCS+= efigetsecs.c efimemory.c
+SOURCES= start.S boot.c conf.c devopen.c dev_net.c self_reloc.c panic.c
+SOURCES+= efiboot.c efichar.c eficons.c efidelay.c efidev.c
+SOURCES+= efidisk.c efidisk_ll.c efigetsecs.c efimemory.c
+SOURCES+= efinet.c efipxe.c
+LIBI386SRCS= biosdisk.c bootinfo.c bootinfo_biosgeom.c bootmenu.c
+LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
PIE_CFLAGS=
@@ -57,10 +57,22 @@
CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
CPPFLAGS+= -DSUPPORT_DOSFS
CPPFLAGS+= -DSUPPORT_EXT2FS
+CPPFLAGS+= -DSUPPORT_BOOTP
+CPPFLAGS+= -DSUPPORT_DHCP
+CPPFLAGS+= -DSUPPORT_NFS
+#CPPFLAGS+= -DSUPPORT_TFTP
CPPFLAGS+= -DPASS_BIOSGEOM
CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048 # for bootinfo_biosgeom.c
CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
+#CPPFLAGS+= -DARP_DEBUG
+#CPPFLAGS+= -DBOOTP_DEBUG
+#CPPFLAGS+= -DNET_DEBUG
+#CPPFLAGS+= -DNETIF_DEBUG
+#CPPFLAGS+= -DNFS_DEBUG
+#CPPFLAGS+= -DRARP_DEBUG
+#CPPFLAGS+= -DRPC_DEBUG
+
EFIDIR= ${S}/external/bsd/gnu-efi/dist
GNUEFIARCH?= ${MACHINE_CPU}
CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
@@ -69,12 +81,12 @@
SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
-SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels
-SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
### find out what to use for libsa
SA_AS= library
SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
+SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes"
SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
.include "${S}/lib/libsa/Makefile.inc"
LIBSA= ${SALIB}
diff -r 02dc6175dee1 -r 8c9b3e064218 sys/arch/i386/stand/efiboot/boot.c
--- a/sys/arch/i386/stand/efiboot/boot.c Wed Apr 11 14:49:08 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/boot.c Wed Apr 11 14:51:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.5.2.4 2018/04/04 16:34:39 martin Exp $ */
+/* $NetBSD: boot.c,v 1.5.2.5 2018/04/11 14:51:43 martin Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -182,6 +182,21 @@
}
static char *
+snprint_bootdev(char *buf, size_t bufsize, const char *devname, int unit,
+ int partition)
+{
+ static const char *no_partition_devs[] = { "esp", "net", "nfs", "tftp" };
+ int i;
+
+ for (i = 0; i < __arraycount(no_partition_devs); i++)
+ if (strcmp(devname, no_partition_devs[i]) == 0)
+ break;
+ snprintf(buf, bufsize, "%s%d%c", devname, unit,
+ i < __arraycount(no_partition_devs) ? '\0' : 'a' + partition);
+ return buf;
+}
+
+static char *
sprint_bootsel(const char *filename)
{
char *fsname, *devname;
@@ -191,8 +206,8 @@
if (parsebootfile(filename, &fsname, &devname, &unit,
&partition, &file) == 0) {
- snprintf(buf, sizeof(buf), "%s%d%c:%s", devname, unit,
- 'a' + partition, file);
+ snprintf(buf, sizeof(buf), "%s:%s", snprint_bootdev(buf,
+ sizeof(buf), devname, unit, partition), file);
return buf;
}
return "(invalid)";
@@ -276,7 +291,9 @@
if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) {
#ifdef EFIBOOTCFG_FILENAME
- int rv = parsebootconf(EFIBOOTCFG_FILENAME);
+ int rv = EINVAL;
+ if (efi_bootdp_type != BOOT_DEVICE_TYPE_NET)
+ rv = parsebootconf(EFIBOOTCFG_FILENAME);
if (rv)
#endif
parsebootconf(BOOTCFG_FILENAME);
@@ -421,13 +438,15 @@
command_dev(char *arg)
{
static char savedevname[MAXDEVNAME + 1];
+ char buf[80];
char *fsname, *devname;
const char *file; /* dummy */
if (*arg == '\0') {
efi_disk_show();
- printf("default %s%d%c\n", default_devname, default_unit,
- 'a' + default_partition);
+ efi_net_show();
+ printf("default %s\n", snprint_bootdev(buf, sizeof(buf),
+ default_devname, default_unit, default_partition));
return;
}
diff -r 02dc6175dee1 -r 8c9b3e064218 sys/arch/i386/stand/efiboot/conf.c
--- a/sys/arch/i386/stand/efiboot/conf.c Wed Apr 11 14:49:08 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/conf.c Wed Apr 11 14:51:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $ */
+/* $NetBSD: conf.c,v 1.1.12.1 2018/04/11 14:51:43 martin Exp $ */
/*
* Copyright (c) 1997
@@ -43,15 +43,52 @@
#ifdef SUPPORT_CD9660
#include <lib/libsa/cd9660.h>
#endif
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+#include <lib/libsa/net.h>
+#include <lib/libsa/dev_net.h>
+#ifdef SUPPORT_NFS
+#include <lib/libsa/nfs.h>
+#endif
+#ifdef SUPPORT_TFTP
+#include <lib/libsa/tftp.h>
+#endif
+#endif
#include <biosdisk.h>
+#include "efinet.h"
struct devsw devsw[] = {
{ "disk", biosdisk_strategy, biosdisk_open, biosdisk_close, biosdisk_ioctl },
+ { "net", net_strategy, net_open, net_close, net_ioctl },
};
int ndevs = __arraycount(devsw);
+#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
+struct netif_driver *netif_drivers[] = {
+ &efinetif,
+};
+int n_netif_drivers = __arraycount(netif_drivers);
+#endif
+
struct fs_ops file_system[] = {
#ifdef SUPPORT_CD9660
+ FS_OPS(null),
+#endif
+ FS_OPS(null), FS_OPS(null),
+ FS_OPS(null), FS_OPS(null),
+#ifdef SUPPORT_EXT2FS
+ FS_OPS(null),
+#endif
+#ifdef SUPPORT_MINIXFS3
+ FS_OPS(null),
+#endif
+#ifdef SUPPORT_DOSFS
+ FS_OPS(null),
+#endif
+};
+int nfsys = __arraycount(file_system);
+
+struct fs_ops file_system_disk[] = {
+#ifdef SUPPORT_CD9660
FS_OPS(cd9660),
#endif
FS_OPS(ffsv1), FS_OPS(ffsv2),
@@ -66,4 +103,13 @@
FS_OPS(dosfs),
#endif
};
-int nfsys = __arraycount(file_system);
+__CTASSERT(__arraycount(file_system) == __arraycount(file_system_disk));
+const int nfsys_disk = __arraycount(file_system_disk);
+
+struct fs_ops file_system_null = FS_OPS(null);
+#ifdef SUPPORT_NFS
+struct fs_ops file_system_nfs = FS_OPS(nfs);
+#endif
+#ifdef SUPPORT_TFTP
+struct fs_ops file_system_tftp = FS_OPS(tftp);
+#endif
diff -r 02dc6175dee1 -r 8c9b3e064218 sys/arch/i386/stand/efiboot/dev_net.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/efiboot/dev_net.c Wed Apr 11 14:51:43 2018 +0000
@@ -0,0 +1,3 @@
+/* $NetBSD: dev_net.c,v 1.1.2.2 2018/04/11 14:51:43 martin Exp $ */
+
+#include <lib/libsa/dev_net.c>
diff -r 02dc6175dee1 -r 8c9b3e064218 sys/arch/i386/stand/efiboot/devopen.c
--- a/sys/arch/i386/stand/efiboot/devopen.c Wed Apr 11 14:49:08 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/devopen.c Wed Apr 11 14:51:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.1.12.3 2018/04/04 16:34:39 martin Exp $ */
+/* $NetBSD: devopen.c,v 1.1.12.4 2018/04/11 14:51:43 martin Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -56,6 +56,8 @@
#include "efiboot.h"
+#include <lib/libsa/dev_net.h>
+
#include <biosdisk.h>
#include "devopen.h"
#include <bootinfo.h>
@@ -81,7 +83,14 @@
*unit = biosdev & 0x7f;
- if (biosdev >= 0x80 + get_harddrives()) {
+ if (efi_bootdp_type == BOOT_DEVICE_TYPE_NET) {
+ *devname = "net";
+ *unit = efi_net_get_booted_interface_unit();
+ if (*unit < 0)
+ *unit = 0;
+ *partition = 0;
+ return;
+ } else if (biosdev >= 0x80 + get_harddrives()) {
*devname = "cd";
*unit -= get_harddrives();
} else
@@ -99,16 +108,90 @@
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 error;
+ int i, n, error;
error = parsebootfile(fname, &fsname, &devname, &unit, &partition,
(const char **) file);
if (error)
return error;
+ memcpy(file_system, file_system_disk, sizeof(*file_system) * nfsys);
+ nfsys = nfsys_disk;
+
+#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;
+ }
+ }
+#endif
+
+ for (i = 1; i < ndevs; i++) {
+ dev = &devsw[i];
+ if (strcmp(devname, DEV_NAME(dev)) == 0) {
+ if (strcmp(devname, "net") == 0) {
+ n = 0;
Home |
Main Index |
Thread Index |
Old Index