Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/stand efiboot: system can boot from CD/DVD-ROM...
details: https://anonhg.NetBSD.org/src/rev/b30177e992d2
branches: trunk
changeset: 321270:b30177e992d2
user: nonaka <nonaka%NetBSD.org@localhost>
date: Thu Mar 08 10:34:33 2018 +0000
description:
efiboot: system can boot from CD/DVD-ROM media.
diffstat:
sys/arch/i386/stand/efiboot/Makefile.efiboot | 9 +-
sys/arch/i386/stand/efiboot/TODO.efiboot | 1 -
sys/arch/i386/stand/efiboot/boot.c | 9 +-
sys/arch/i386/stand/efiboot/devopen.c | 13 ++-
sys/arch/i386/stand/efiboot/efiboot.c | 14 +-
sys/arch/i386/stand/efiboot/efiboot.h | 8 +-
sys/arch/i386/stand/efiboot/efidev.c | 59 ++++++++++
sys/arch/i386/stand/efiboot/efidisk.c | 145 +++++++++++++++++++++-----
sys/arch/i386/stand/efiboot/efidisk.h | 4 +-
sys/arch/i386/stand/efiboot/efidisk_ll.c | 16 +-
sys/arch/i386/stand/lib/biosdisk.c | 105 ++++++++++++++++--
sys/arch/i386/stand/lib/biosdisk.h | 16 ++-
sys/arch/i386/stand/lib/biosdisk_ll.h | 4 +-
13 files changed, 333 insertions(+), 70 deletions(-)
diffs (truncated from 727 to 300 lines):
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/Makefile.efiboot
--- a/sys/arch/i386/stand/efiboot/Makefile.efiboot Thu Mar 08 10:17:22 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/Makefile.efiboot Thu Mar 08 10:34:33 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.9 2017/04/29 00:05:35 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.10 2018/03/08 10:34:33 nonaka Exp $
S= ${.CURDIR}/../../../../..
@@ -12,8 +12,8 @@
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+= eficons.c efidelay.c efidisk.c efidisk_ll.c efigetsecs.c
-LIBI386SRCS+= efimemory.c
+LIBI386SRCS+= eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
+LIBI386SRCS+= efigetsecs.c efimemory.c
SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
PIE_CFLAGS=
@@ -54,9 +54,11 @@
CPPFLAGS+= -DEFI_ALLOCATE_MAX_ADDRESS=0x100000000ULL
CPPFLAGS+= -DHEAP_VARIABLE
CPPFLAGS+= -DSUPPORT_CD9660
+CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
CPPFLAGS+= -DSUPPORT_DOSFS
CPPFLAGS+= -DSUPPORT_EXT2FS
CPPFLAGS+= -DPASS_BIOSGEOM
+CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048 # for bootinfo_biosgeom.c
CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
EFIDIR= ${S}/external/bsd/gnu-efi/dist
@@ -66,6 +68,7 @@
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
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/TODO.efiboot
--- a/sys/arch/i386/stand/efiboot/TODO.efiboot Thu Mar 08 10:17:22 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/TODO.efiboot Thu Mar 08 10:34:33 2018 +0000
@@ -1,6 +1,5 @@
- efiboot
* handle UEFI variables
- * boot from CD/DVD (bootable from CD/DVD, but root fs not found.)
* load boot.cfg from EFI system partition (FAT32)
- kernel
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/boot.c
--- a/sys/arch/i386/stand/efiboot/boot.c Thu Mar 08 10:17:22 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/boot.c Thu Mar 08 10:34:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.5 2017/05/01 13:03:01 nonaka Exp $ */
+/* $NetBSD: boot.c,v 1.6 2018/03/08 10:34:33 nonaka Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -419,7 +419,7 @@
const char *file; /* dummy */
if (*arg == '\0') {
- biosdisk_probe();
+ efi_disk_show();
printf("default %s%d%c\n", default_devname, default_unit,
'a' + default_partition);
return;
@@ -554,6 +554,7 @@
void
command_version(char *arg)
{
+ CHAR16 *path;
if (strcmp(arg, "full") == 0) {
printf("ImageBase: 0x%" PRIxPTR "\n",
@@ -563,6 +564,10 @@
ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
Print(L"EFI Firmware: %s (rev %d.%02d)\n", ST->FirmwareVendor,
ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
+ path = DevicePathToStr(efi_bootdp);
+ Print(L"Boot DevicePath: %d:%d:%s\n", DevicePathType(efi_bootdp),
+ DevicePathSubType(efi_bootdp), path);
+ FreePool(path);
}
printf("\n"
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/devopen.c
--- a/sys/arch/i386/stand/efiboot/devopen.c Thu Mar 08 10:17:22 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/devopen.c Thu Mar 08 10:34:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $ */
+/* $NetBSD: devopen.c,v 1.2 2018/03/08 10:34:33 nonaka Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -66,8 +66,11 @@
if (strcmp(devname, "hd") == 0)
*biosdev = 0x80 + unit;
+ if (strcmp(devname, "cd") == 0)
+ *biosdev = 0x80 + get_harddrives() + unit;
else
return ENXIO;
+
return 0;
}
@@ -76,7 +79,13 @@
{
*unit = biosdev & 0x7f;
- *devname = "hd";
+
+ if (biosdev >= 0x80 + get_harddrives()) {
+ *devname = "cd";
+ *unit -= get_harddrives();
+ } else
+ *devname = "hd";
+
*partition = biosdisk_findpartition(biosdev, sector);
}
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/efiboot.c
--- a/sys/arch/i386/stand/efiboot/efiboot.c Thu Mar 08 10:17:22 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/efiboot.c Thu Mar 08 10:34:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.c,v 1.4 2017/02/11 10:23:39 nonaka Exp $ */
+/* $NetBSD: efiboot.c,v 1.5 2018/03/08 10:34:33 nonaka Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -28,11 +28,13 @@
#include "efiboot.h"
+#include "biosdisk_ll.h"
#include "bootinfo.h"
#include "devopen.h"
EFI_HANDLE IH;
EFI_DEVICE_PATH *efi_bootdp;
+int efi_bootdp_type = BIOSDISK_TYPE_HD;
EFI_LOADED_IMAGE *efi_li;
uintptr_t efi_main_sp;
physaddr_t efi_loadaddr, efi_kernel_start;
@@ -71,15 +73,13 @@
&DevicePathProtocol, (void **)&dp0);
if (EFI_ERROR(status))
Panic(L"HandleProtocol(DevicePathProtocol): %r", status);
+ efi_bootdp = dp0;
for (dp = dp0; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp)) {
- if (DevicePathType(dp) == MEDIA_DEVICE_PATH)
- continue;
- if (DevicePathSubType(dp) == MEDIA_HARDDRIVE_DP) {
- boot_biosdev = 0x80;
- efi_bootdp = dp;
+ if (DevicePathType(dp) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType(dp) == MEDIA_CDROM_DP) {
+ efi_bootdp_type = BIOSDISK_TYPE_CD;
break;
}
- break;
}
efi_disk_probe();
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/efiboot.h
--- a/sys/arch/i386/stand/efiboot/efiboot.h Thu Mar 08 10:17:22 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/efiboot.h Thu Mar 08 10:34:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.h,v 1.5 2017/05/01 13:03:01 nonaka Exp $ */
+/* $NetBSD: efiboot.h,v 1.6 2018/03/08 10:34:33 nonaka Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -46,6 +46,7 @@
/* efiboot.c */
extern EFI_HANDLE IH;
extern EFI_DEVICE_PATH *efi_bootdp;
+extern int efi_bootdp_type;
extern EFI_LOADED_IMAGE *efi_li;
extern uintptr_t efi_main_sp;
extern physaddr_t efi_loadaddr, efi_kernel_start;
@@ -59,8 +60,13 @@
void command_text(char *);
void command_gop(char *);
+/* efidev.c */
+int efi_device_path_depth(EFI_DEVICE_PATH *dp, int);
+int efi_device_path_ncmp(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *, int);
+
/* efidisk.c */
void efi_disk_probe(void);
+void efi_disk_show(void);
/* efimemory.c */
void efi_memory_probe(void);
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/efidev.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/efiboot/efidev.c Thu Mar 08 10:34:33 2018 +0000
@@ -0,0 +1,59 @@
+/* $NetBSD: efidev.c,v 1.1 2018/03/08 10:34:33 nonaka Exp $ */
+/* $OpenBSD: efiboot.c,v 1.28 2017/11/25 19:02:07 patrick Exp $ */
+
+/*
+ * Copyright (c) 2015 YASUOKA Masahiko <yasuoka%yasuoka.net@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "efiboot.h"
+
+/*
+ * Determine the number of nodes up to, but not including, the first
+ * node of the specified type.
+ */
+int
+efi_device_path_depth(EFI_DEVICE_PATH *dp, int dptype)
+{
+ int i;
+
+ for (i = 0; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp), i++) {
+ if (DevicePathType(dp) == dptype)
+ return (i);
+ }
+
+ return (-1);
+}
+
+int
+efi_device_path_ncmp(EFI_DEVICE_PATH *dpa, EFI_DEVICE_PATH *dpb, int deptn)
+{
+ int i, cmp;
+
+ for (i = 0; i < deptn; i++) {
+ if (IsDevicePathEnd(dpa) || IsDevicePathEnd(dpb))
+ return ((IsDevicePathEnd(dpa) && IsDevicePathEnd(dpb))
+ ? 0 : (IsDevicePathEnd(dpa))? -1 : 1);
+ cmp = DevicePathNodeLength(dpa) - DevicePathNodeLength(dpb);
+ if (cmp)
+ return (cmp);
+ cmp = memcmp(dpa, dpb, DevicePathNodeLength(dpa));
+ if (cmp)
+ return (cmp);
+ dpa = NextDevicePathNode(dpa);
+ dpb = NextDevicePathNode(dpb);
+ }
+
+ return (0);
+}
diff -r c3098b4837d1 -r b30177e992d2 sys/arch/i386/stand/efiboot/efidisk.c
--- a/sys/arch/i386/stand/efiboot/efidisk.c Thu Mar 08 10:17:22 2018 +0000
+++ b/sys/arch/i386/stand/efiboot/efidisk.c Thu Mar 08 10:34:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efidisk.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $ */
+/* $NetBSD: efidisk.c,v 1.2 2018/03/08 10:34:33 nonaka Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -26,8 +26,15 @@
* SUCH DAMAGE.
*/
+#define FSTYPENAMES /* for sys/disklabel.h */
+
#include "efiboot.h"
+#include <sys/disklabel.h>
+
+#include "biosdisk.h"
+#include "biosdisk_ll.h"
+#include "devopen.h"
#include "efidisk.h"
static struct efidiskinfo_lh efi_disklist;
@@ -41,10 +48,9 @@
EFI_HANDLE *handles;
EFI_BLOCK_IO *bio;
EFI_BLOCK_IO_MEDIA *media;
+ EFI_DEVICE_PATH *dp;
struct efidiskinfo *edi;
- EFI_DEVICE_PATH *dp, *bdp;
- bool bootdev;
- int dev;
+ int dev, depth = -1;
TAILQ_INIT(&efi_disklist);
@@ -53,6 +59,18 @@
if (EFI_ERROR(status))
Home |
Main Index |
Thread Index |
Old Index