Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/stand/efiboot If the loader is loaded from the network, ...
details: https://anonhg.NetBSD.org/src/rev/d16c7f8eab9e
branches: trunk
changeset: 993323:d16c7f8eab9e
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Sep 04 21:29:54 2018 +0000
description:
If the loader is loaded from the network, try to load the kernel from the
same network device.
diffstat:
sys/stand/efiboot/efinet.c | 44 +++++++++++++++++++++++++++++++++++---------
1 files changed, 35 insertions(+), 9 deletions(-)
diffs (104 lines):
diff -r 1fc57f34c931 -r d16c7f8eab9e sys/stand/efiboot/efinet.c
--- a/sys/stand/efiboot/efinet.c Tue Sep 04 18:52:49 2018 +0000
+++ b/sys/stand/efiboot/efinet.c Tue Sep 04 21:29:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efinet.c,v 1.2 2018/09/04 15:08:30 riastradh Exp $ */
+/* $NetBSD: efinet.c,v 1.3 2018/09/04 21:29:54 jmcneill Exp $ */
/*-
* Copyright (c) 2001 Doug Rabson
@@ -28,6 +28,7 @@
*/
#include <sys/cdefs.h>
+#include <sys/param.h>
#include "efiboot.h"
@@ -334,7 +335,7 @@
EFI_HANDLE *handles;
EFI_STATUS status;
UINTN i, nhandles;
- int nifs;
+ int nifs, depth = -1;
bool found;
status = LibLocateHandle(ByProtocol, &SimpleNetworkProtocol, NULL,
@@ -347,6 +348,12 @@
return;
memset(enis, 0, nhandles * sizeof(*enis));
+ if (efi_bootdp) {
+ depth = efi_device_path_depth(efi_bootdp, HARDWARE_DEVICE_PATH);
+ if (depth == 0)
+ depth = 1;
+ }
+
nifs = 0;
for (i = 0; i < nhandles; i++) {
status = uefi_call_wrapper(BS->HandleProtocol, 3, handles[i],
@@ -402,6 +409,13 @@
FreePool(handles);
return;
}
+
+ if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) {
+ char devname[9];
+ snprintf(devname, sizeof(devname), "net%u", nifs);
+ set_default_device(devname);
+ }
+
nifs++;
}
}
@@ -489,9 +503,9 @@
int
efi_net_open(struct open_file *f, ...)
{
+ char **file, pathbuf[PATH_MAX], *default_device, *path, *ep;
+ const char *fname, *full_path;
struct devdesc desc;
- const char *fname;
- char **file, *ep;
intmax_t dev;
va_list ap;
int n;
@@ -501,13 +515,25 @@
file = va_arg(ap, char **);
va_end(ap);
- if (strncmp(fname, "net", 3) != 0)
+ default_device = get_default_device();
+ if (strchr(fname, ':') == NULL) {
+ if (strlen(default_device) > 0) {
+ snprintf(pathbuf, sizeof(pathbuf), "%s:%s", default_device, fname);
+ full_path = pathbuf;
+ path = __UNCONST(fname);
+ } else {
+ return EINVAL;
+ }
+ } else {
+ full_path = fname;
+ path = strchr(fname, ':') + 1;
+ }
+
+ if (strncmp(full_path, "net", 3) != 0)
return EINVAL;
- dev = strtoimax(fname + 3, &ep, 10);
+ dev = strtoimax(full_path + 3, &ep, 10);
if (dev < 0 || dev >= efinetif.netif_nifs)
return ENXIO;
- if (*ep != ':')
- return ENXIO;
for (n = 0; n < ndevs; n++)
if (strcmp(DEV_NAME(&devsw[n]), "net") == 0) {
@@ -517,7 +543,7 @@
if (n == ndevs)
return ENXIO;
- *file = ep + 1;
+ *file = path;
//try_bootp = 1;
Home |
Main Index |
Thread Index |
Old Index