Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Initial commit of native amd64 EFI boot loader.
details: https://anonhg.NetBSD.org/src/rev/29fa4466fda7
branches: trunk
changeset: 350838:29fa4466fda7
user: nonaka <nonaka%NetBSD.org@localhost>
date: Tue Jan 24 11:09:14 2017 +0000
description:
Initial commit of native amd64 EFI boot loader.
diffstat:
distrib/sets/lists/base/md.amd64 | 4 +-
sys/arch/i386/stand/Makefile | 5 +-
sys/arch/i386/stand/efiboot/Makefile | 6 +
sys/arch/i386/stand/efiboot/Makefile.efiboot | 133 +++
sys/arch/i386/stand/efiboot/boot.c | 619 +++++++++++++++++
sys/arch/i386/stand/efiboot/bootia32/Makefile | 17 +
sys/arch/i386/stand/efiboot/bootia32/efiboot_machdep.h | 29 +
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c | 51 +
sys/arch/i386/stand/efiboot/bootia32/ldscript | 76 ++
sys/arch/i386/stand/efiboot/bootia32/start.S | 74 ++
sys/arch/i386/stand/efiboot/bootx64/Makefile | 12 +
sys/arch/i386/stand/efiboot/bootx64/efiboot_machdep.h | 29 +
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c | 75 ++
sys/arch/i386/stand/efiboot/bootx64/ldscript | 66 +
sys/arch/i386/stand/efiboot/bootx64/start.S | 79 ++
sys/arch/i386/stand/efiboot/bootx64/startprog64.S | 155 ++++
sys/arch/i386/stand/efiboot/conf.c | 69 +
sys/arch/i386/stand/efiboot/devopen.c | 110 +++
sys/arch/i386/stand/efiboot/devopen.h | 31 +
sys/arch/i386/stand/efiboot/efiboot.c | 137 +++
sys/arch/i386/stand/efiboot/efiboot.h | 66 +
sys/arch/i386/stand/efiboot/eficons.c | 557 +++++++++++++++
sys/arch/i386/stand/efiboot/efidelay.c | 46 +
sys/arch/i386/stand/efiboot/efidisk.c | 127 +++
sys/arch/i386/stand/efiboot/efidisk.h | 40 +
sys/arch/i386/stand/efiboot/efidisk_ll.c | 200 +++++
sys/arch/i386/stand/efiboot/efigetsecs.c | 52 +
sys/arch/i386/stand/efiboot/efimemory.c | 350 +++++++++
sys/arch/i386/stand/efiboot/panic.c | 69 +
sys/arch/i386/stand/efiboot/self_reloc.c | 99 ++
sys/arch/i386/stand/efiboot/version | 7 +
sys/arch/i386/stand/lib/biosdisk.c | 105 ++-
sys/arch/i386/stand/lib/bootinfo_biosgeom.c | 3 +-
sys/arch/i386/stand/lib/diskbuf.c | 10 +-
sys/arch/i386/stand/lib/exec.c | 54 +-
sys/arch/i386/stand/lib/libi386.h | 7 +-
sys/arch/i386/stand/lib/vbe.c | 3 +-
sys/arch/x86/acpi/acpi_machdep.c | 71 +-
sys/arch/x86/include/bootinfo.h | 18 +-
sys/arch/x86/include/efi.h | 12 +-
sys/arch/x86/x86/efi.c | 74 +-
sys/arch/x86/x86/x86_machdep.c | 85 +-
sys/lib/libgnuefi/Makefile | 48 +-
sys/lib/libgnuefi/Makefile.inc | 3 +-
sys/lib/libgnuefi/arch/i386/Makefile.inc | 3 +
sys/lib/libgnuefi/arch/x86_64/Makefile.inc | 3 +
46 files changed, 3813 insertions(+), 76 deletions(-)
diffs (truncated from 4454 to 300 lines):
diff -r 06b4de567f50 -r 29fa4466fda7 distrib/sets/lists/base/md.amd64
--- a/distrib/sets/lists/base/md.amd64 Tue Jan 24 10:18:33 2017 +0000
+++ b/distrib/sets/lists/base/md.amd64 Tue Jan 24 11:09:14 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.267 2015/09/26 01:46:14 christos Exp $
+# $NetBSD: md.amd64,v 1.268 2017/01/24 11:09:14 nonaka Exp $
./dev/lms0 base-obsolete obsolete
./dev/mms0 base-obsolete obsolete
./libexec/ld.elf_so-i386 base-sys-shlib compat,pic
@@ -30,6 +30,8 @@
./usr/mdec/biosboot_com0_57600.sym base-obsolete obsolete
./usr/mdec/biosboot_com0_9600.sym base-obsolete obsolete
./usr/mdec/boot base-sysutil-bin
+./usr/mdec/bootia32.efi base-sysutil-bin
+./usr/mdec/bootx64.efi base-sysutil-bin
./usr/mdec/bootxx_cd9660 base-sysutil-bin
./usr/mdec/bootxx_dosfs base-obsolete obsolete
./usr/mdec/bootxx_ext2fs base-sysutil-bin
diff -r 06b4de567f50 -r 29fa4466fda7 sys/arch/i386/stand/Makefile
--- a/sys/arch/i386/stand/Makefile Tue Jan 24 10:18:33 2017 +0000
+++ b/sys/arch/i386/stand/Makefile Tue Jan 24 11:09:14 2017 +0000
@@ -1,8 +1,11 @@
-# $NetBSD: Makefile,v 1.27 2012/01/27 08:41:35 jnemeth Exp $
+# $NetBSD: Makefile,v 1.28 2017/01/24 11:09:14 nonaka Exp $
SUBDIR= mbr boot
SUBDIR+= bootxx cdboot fatboot
SUBDIR+= dosboot misc
SUBDIR+= pxeboot
+.if ${MACHINE} == "amd64"
+SUBDIR+= efiboot
+.endif
.include <bsd.subdir.mk>
diff -r 06b4de567f50 -r 29fa4466fda7 sys/arch/i386/stand/efiboot/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/efiboot/Makefile Tue Jan 24 11:09:14 2017 +0000
@@ -0,0 +1,6 @@
+# $NetBSD: Makefile,v 1.1 2017/01/24 11:09:14 nonaka Exp $
+
+SUBDIR= bootx64
+SUBDIR+= bootia32
+
+.include <bsd.subdir.mk>
diff -r 06b4de567f50 -r 29fa4466fda7 sys/arch/i386/stand/efiboot/Makefile.efiboot
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/efiboot/Makefile.efiboot Tue Jan 24 11:09:14 2017 +0000
@@ -0,0 +1,133 @@
+# $NetBSD: Makefile.efiboot,v 1.1 2017/01/24 11:09:14 nonaka Exp $
+
+S= ${.CURDIR}/../../../../..
+
+NOMAN= # defined
+PROG?= boot.efi
+NEWVERSWHAT?= "EFI Boot"
+VERSIONFILE?= ${.CURDIR}/../version
+
+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 boot_params.S 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
+SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
+.if !make(depend)
+SRCS+= vers.c
+.endif
+
+PIE_CFLAGS=
+PIE_LDFLAGS=
+PIE_AFLAGS=
+
+.include <bsd.own.mk>
+
+STRIPFLAG= # nothing
+
+LIBCRT0= # nothing
+LIBCRTI= # nothing
+LIBCRTBEGIN= # nothing
+LIBCRTEND= # nothing
+LIBC= # nothing
+
+BINDIR=/usr/mdec
+BINMODE=444
+
+.PATH: ${.CURDIR} ${.CURDIR}/..
+.PATH: ${.CURDIR}/../../lib
+
+LDSCRIPT?= ${.CURDIR}/ldscript
+LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared -nocombreloc
+CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/.. -I$S/lib/libsa
+CPPFLAGS+= -I${.OBJDIR}
+CPPFLAGS+= -I${.CURDIR}/../../lib
+
+COPTS+= -ffreestanding -fPIC -fshort-wchar -fno-strict-aliasing -fno-builtin
+COPTS+= -fno-stack-protector -falign-functions=16
+CPPFLAGS+= -nostdinc -D_STANDALONE
+CPPFLAGS+= -DEFIBOOT
+
+CPPFLAGS+= -Wall -Wmissing-prototypes
+CPPFLAGS+= -Wno-pointer-sign
+
+CPPFLAGS+= -DEFI_ALLOCATE_MAX_ADDRESS=0x100000000ULL
+CPPFLAGS+= -DHEAP_VARIABLE
+CPPFLAGS+= -DSUPPORT_CD9660
+CPPFLAGS+= -DSUPPORT_DOSFS
+CPPFLAGS+= -DSUPPORT_EXT2FS
+CPPFLAGS+= -DPASS_BIOSGEOM
+CPPFLAGS+= -DPASS_MEMMAP
+CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
+
+EFIDIR= ${S}/external/bsd/gnu-efi/dist
+GNUEFIARCH?= ${MACHINE_CPU}
+CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
+CPPFLAGS+= -I${EFIDIR}/inc/protocol
+
+SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
+SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
+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_ENABLE_LS_OP=yes"
+.include "${S}/lib/libsa/Makefile.inc"
+LIBSA= ${SALIB}
+
+### find out what to use for libkern
+KERN_AS= library
+LIBKERN_ARCH?= ${MACHINE_ARCH}
+KERNMISCMAKEFLAGS+="LIBKERN_ARCH=${LIBKERN_ARCH}"
+.include "${S}/lib/libkern/Makefile.inc"
+LIBKERN= ${KERNLIB}
+
+### find out what to use for libz
+Z_AS= library
+.include "${S}/lib/libz/Makefile.inc"
+LIBZ= ${ZLIB}
+
+### find out what to use for libgnuefi
+GNUEFI_AS= library
+LIBGNUEFI_ARCH?= ${MACHINE_ARCH}
+GNUEFIMISCMAKEFLAGS+="LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH}"
+GNUEFIMISCCPPFLAGS+= -I${EFIDIR}/lib
+.include "${S}/lib/libgnuefi/Makefile.inc"
+LIBGNUEFI= ${GNUEFILIB}
+
+cleandir distclean: .WAIT cleanlibdir
+
+cleanlibdir:
+ -rm -rf lib
+
+LIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA}
+
+CLEANFILES+= vers.c
+
+vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.efiboot
+ ${HOST_SH} ${S}/conf/newvers_stand.sh ${VERSIONFILE} x86 ${NEWVERSWHAT}
+
+CLEANFILES+= ${PROG}.so ${PROG}.tmp
+
+${PROG}: ${PROG}.so
+ ${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
+ -j .rel -j .rel.* -j .rela -j .rela.* -j .reloc \
+ --subsystem efi-app --target=${OBJFMT} ${PROG}.so ${.TARGET}
+
+.include <bsd.prog.mk>
+
+${PROG}.so: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.efiboot
+ ${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LIBLIST}
+ @if ${OBJDUMP} -t ${.TARGET}.tmp | grep 'UND'; then \
+ (echo Undefined symbols; false); \
+ fi
+ rm -f ${.TARGET}
+ mv ${.TARGET}.tmp ${.TARGET}
+
+KLINK_MACHINE?= ${MACHINE}
+.include <bsd.klinks.mk>
diff -r 06b4de567f50 -r 29fa4466fda7 sys/arch/i386/stand/efiboot/boot.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/efiboot/boot.c Tue Jan 24 11:09:14 2017 +0000
@@ -0,0 +1,619 @@
+/* $NetBSD: boot.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $ */
+
+/*-
+ * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "efiboot.h"
+
+#include <sys/bootblock.h>
+#include <sys/boot_flag.h>
+
+#include <lib/libsa/bootcfg.h>
+
+#include <bootmod.h>
+#include <bootmenu.h>
+#include "devopen.h"
+
+int errno;
+int boot_biosdev;
+daddr_t boot_biossector;
+
+extern const char bootprog_name[], bootprog_rev[], bootprog_kernrev[];
+
+extern struct x86_boot_params boot_params;
+extern char twiddle_toggle;
+
+static const char * const names[][2] = {
+ { "netbsd", "netbsd.gz" },
+ { "onetbsd", "onetbsd.gz" },
+ { "netbsd.old", "netbsd.old.gz" },
+};
+
+#define NUMNAMES __arraycount(names)
+#define DEFFILENAME names[0][0]
+
+#define MAXDEVNAME 16
+
+void command_help(char *);
+void command_quit(char *);
+void command_boot(char *);
+void command_consdev(char *);
+void command_dev(char *);
+void command_devpath(char *);
+void command_efivar(char *);
+void command_gop(char *);
+#if LIBSA_ENABLE_LS_OP
+void command_ls(char *);
+#endif
+void command_memmap(char *);
+#ifndef SMALL
+void command_menu(char *);
+#endif
+void command_modules(char *);
+void command_multiboot(char *);
+void command_text(char *);
+void command_version(char *);
+
+const struct bootblk_command commands[] = {
+ { "help", command_help },
+ { "?", command_help },
+ { "quit", command_quit },
+ { "boot", command_boot },
+ { "consdev", command_consdev },
+ { "dev", command_dev },
+ { "devpath", command_devpath },
+ { "efivar", command_efivar },
+ { "fs", fs_add },
+ { "gop", command_gop },
+ { "load", module_add },
+#if LIBSA_ENABLE_LS_OP
+ { "ls", command_ls },
+#endif
+ { "memmap", command_memmap },
+#ifndef SMALL
+ { "menu", command_menu },
+#endif
+ { "modules", command_modules },
+ { "multiboot", command_multiboot },
+ { "rndseed", rnd_add },
+ { "splash", splash_add },
+ { "text", command_text },
+ { "userconf", userconf_add },
+ { "version", command_version },
+ { NULL, NULL },
+};
+
+static char *default_devname;
+static int default_unit, default_partition;
+static const char *default_filename;
+
+static char *sprint_bootsel(const char *);
+static void bootit(const char *, int);
+
Home |
Main Index |
Thread Index |
Old Index