aboutsummaryrefslogtreecommitdiff
path: root/stand/efi
diff options
context:
space:
mode:
Diffstat (limited to 'stand/efi')
-rw-r--r--stand/efi/Makefile1
-rw-r--r--stand/efi/Makefile.inc3
-rw-r--r--stand/efi/boot1/Makefile20
-rw-r--r--stand/efi/boot1/Makefile.depend5
-rw-r--r--stand/efi/boot1/boot1.c23
-rw-r--r--stand/efi/boot1/boot_module.h5
-rw-r--r--stand/efi/boot1/proto.c3
-rw-r--r--stand/efi/boot1/proto.h2
-rw-r--r--stand/efi/boot1/ufs_module.c4
-rw-r--r--stand/efi/boot1/zfs_module.c65
-rw-r--r--stand/efi/fdt/Makefile1
-rw-r--r--stand/efi/fdt/Makefile.depend4
-rw-r--r--stand/efi/fdt/efi_fdt.c4
-rw-r--r--stand/efi/gptboot/Makefile2
-rw-r--r--stand/efi/gptboot/drv.h2
-rw-r--r--stand/efi/gptboot/gptboot.efi.86
-rw-r--r--stand/efi/gptboot/proto.c3
-rw-r--r--stand/efi/include/Guid/MemoryTypeInformation.h1
-rw-r--r--stand/efi/include/Guid/MtcVendor.h1
-rw-r--r--stand/efi/include/Guid/ZeroGuid.h1
-rw-r--r--stand/efi/include/Protocol/EdidActive.h1
-rw-r--r--stand/efi/include/Protocol/EdidDiscovered.h1
-rw-r--r--stand/efi/include/Protocol/EdidOverride.h1
-rw-r--r--stand/efi/include/Protocol/Http.h1
-rw-r--r--stand/efi/include/Protocol/Ip4Config2.h1
-rw-r--r--stand/efi/include/Protocol/ServiceBinding.h1
-rw-r--r--stand/efi/include/README1
-rw-r--r--stand/efi/include/amd64/efibind.h84
-rw-r--r--stand/efi/include/amd64/pe.h1
-rw-r--r--stand/efi/include/arm/efibind.h36
-rw-r--r--stand/efi/include/arm64/efibind.h77
-rw-r--r--stand/efi/include/efi.h32
-rw-r--r--stand/efi/include/efi_driver_utils.h2
-rw-r--r--stand/efi/include/efi_drivers.h2
-rw-r--r--stand/efi/include/efi_nii.h1
-rw-r--r--stand/efi/include/efiapi.h3
-rw-r--r--stand/efi/include/efichar.h10
-rw-r--r--stand/efi/include/eficon.h5
-rw-r--r--stand/efi/include/eficonsctl.h1
-rw-r--r--stand/efi/include/efidebug.h1
-rw-r--r--stand/efi/include/efidef.h1
-rw-r--r--stand/efi/include/efidevp.h1
-rw-r--r--stand/efi/include/efierr.h1
-rw-r--r--stand/efi/include/efifpswa.h1
-rw-r--r--stand/efi/include/efifs.h1
-rw-r--r--stand/efi/include/efigop.h1
-rw-r--r--stand/efi/include/efigpt.h1
-rw-r--r--stand/efi/include/efiip.h1
-rw-r--r--stand/efi/include/efilib.h6
-rw-r--r--stand/efi/include/efinet.h1
-rw-r--r--stand/efi/include/efipart.h1
-rw-r--r--stand/efi/include/efipciio.h1
-rw-r--r--stand/efi/include/efipoint.h1
-rw-r--r--stand/efi/include/efiprot.h1
-rw-r--r--stand/efi/include/efipxebc.h1
-rw-r--r--stand/efi/include/efirng.h50
-rw-r--r--stand/efi/include/efiser.h1
-rw-r--r--stand/efi/include/efistdarg.h1
-rw-r--r--stand/efi/include/efitcp.h1
-rw-r--r--stand/efi/include/efiudp.h1
-rw-r--r--stand/efi/include/efiuga.h1
-rw-r--r--stand/efi/include/efizfs.h2
-rw-r--r--stand/efi/include/i386/efibind.h84
-rw-r--r--stand/efi/include/i386/pe.h1
-rw-r--r--stand/efi/include/riscv/efibind.h77
-rw-r--r--stand/efi/libefi/Makefile4
-rw-r--r--stand/efi/libefi/Makefile.depend2
-rw-r--r--stand/efi/libefi/delay.c6
-rw-r--r--stand/efi/libefi/devicename.c157
-rw-r--r--stand/efi/libefi/devpath.c24
-rw-r--r--stand/efi/libefi/efi_console.c45
-rw-r--r--stand/efi/libefi/efi_driver_utils.c2
-rw-r--r--stand/efi/libefi/efichar.c20
-rw-r--r--stand/efi/libefi/eficom.c (renamed from stand/efi/loader/efiserialio.c)194
-rw-r--r--stand/efi/libefi/efienv.c3
-rw-r--r--stand/efi/libefi/efihttp.c9
-rw-r--r--stand/efi/libefi/efinet.c7
-rw-r--r--stand/efi/libefi/efipart.c11
-rw-r--r--stand/efi/libefi/efizfs.c5
-rw-r--r--stand/efi/libefi/env.c5
-rw-r--r--stand/efi/libefi/errno.c3
-rw-r--r--stand/efi/libefi/handles.c3
-rw-r--r--stand/efi/libefi/libefi.c3
-rw-r--r--stand/efi/libefi/time.c3
-rw-r--r--stand/efi/libefi/time_arm64.c3
-rw-r--r--stand/efi/libefi/time_event.c3
-rw-r--r--stand/efi/libefi/wchar.c5
-rw-r--r--stand/efi/loader/Makefile20
-rw-r--r--stand/efi/loader/Makefile.depend4
-rw-r--r--stand/efi/loader/Makefile.depend.arm16
-rw-r--r--stand/efi/loader/Makefile.depend.arm6416
-rw-r--r--stand/efi/loader/Makefile.depend.options7
-rw-r--r--stand/efi/loader/Makefile.depend.riscv16
-rw-r--r--stand/efi/loader/arch/amd64/Makefile.inc1
-rw-r--r--stand/efi/loader/arch/amd64/amd64.ldscript (renamed from stand/efi/loader/arch/amd64/ldscript.amd64)12
-rw-r--r--stand/efi/loader/arch/amd64/amd64_tramp.S3
-rw-r--r--stand/efi/loader/arch/amd64/elf64_freebsd.c61
-rw-r--r--stand/efi/loader/arch/amd64/exc.S3
-rw-r--r--stand/efi/loader/arch/amd64/multiboot2.c4
-rw-r--r--stand/efi/loader/arch/amd64/start.S1
-rw-r--r--stand/efi/loader/arch/amd64/trap.c41
-rw-r--r--stand/efi/loader/arch/arm/Makefile.inc2
-rw-r--r--stand/efi/loader/arch/arm/arm.ldscript (renamed from stand/efi/loader/arch/arm/ldscript.arm)11
-rw-r--r--stand/efi/loader/arch/arm/exec.c4
-rw-r--r--stand/efi/loader/arch/arm/start.S3
-rw-r--r--stand/efi/loader/arch/arm64/Makefile.inc2
-rw-r--r--stand/efi/loader/arch/arm64/arm64.ldscript (renamed from stand/efi/loader/arch/arm64/ldscript.arm64)17
-rw-r--r--stand/efi/loader/arch/arm64/exec.c44
-rw-r--r--stand/efi/loader/arch/arm64/start.S48
-rw-r--r--stand/efi/loader/arch/i386/Makefile.inc13
-rw-r--r--stand/efi/loader/arch/i386/elf32_freebsd.c103
-rw-r--r--stand/efi/loader/arch/i386/exec.c49
-rw-r--r--stand/efi/loader/arch/i386/i386_copy.c58
-rw-r--r--stand/efi/loader/arch/i386/ldscript.i38677
-rw-r--r--stand/efi/loader/arch/i386/start.S68
-rw-r--r--stand/efi/loader/arch/riscv/Makefile.inc2
-rw-r--r--stand/efi/loader/arch/riscv/exec.c3
-rw-r--r--stand/efi/loader/arch/riscv/riscv.ldscript (renamed from stand/efi/loader/arch/riscv/ldscript.riscv)12
-rw-r--r--stand/efi/loader/arch/riscv/start.S4
-rw-r--r--stand/efi/loader/autoload.c3
-rw-r--r--stand/efi/loader/bootinfo.c210
-rw-r--r--stand/efi/loader/conf.c16
-rw-r--r--stand/efi/loader/copy.c39
-rw-r--r--stand/efi/loader/efi_main.c11
-rw-r--r--stand/efi/loader/framebuffer.c24
-rw-r--r--stand/efi/loader/framebuffer.h5
-rw-r--r--stand/efi/loader/loader_efi.h6
-rw-r--r--stand/efi/loader/main.c216
-rw-r--r--stand/efi/loader/version1
-rw-r--r--stand/efi/loader/version.veriexec7
-rw-r--r--stand/efi/loader_4th/Makefile2
-rw-r--r--stand/efi/loader_4th/Makefile.depend0
-rw-r--r--stand/efi/loader_lua/Makefile2
-rw-r--r--stand/efi/loader_simp/Makefile1
134 files changed, 818 insertions, 1624 deletions
diff --git a/stand/efi/Makefile b/stand/efi/Makefile
index 94cb5bba5638..5177ea688ed1 100644
--- a/stand/efi/Makefile
+++ b/stand/efi/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
NO_OBJ=t
diff --git a/stand/efi/Makefile.inc b/stand/efi/Makefile.inc
index c2d803ddc1ab..a27eb5d97484 100644
--- a/stand/efi/Makefile.inc
+++ b/stand/efi/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Options used when building app-specific efi components
# See conf/kern.mk for the correct set of these
@@ -21,8 +20,6 @@ CFLAGS+= -fPIC
.if ${MACHINE_CPUARCH} == "amd64"
EFI_TARGET= efi-app-x86_64
-.elif ${MACHINE_CPUARCH} == "i386"
-EFI_TARGET= efi-app-ia32
.else
EFI_TARGET= binary
.endif
diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile
index af03e395b2a5..fb1c7d74eec1 100644
--- a/stand/efi/boot1/Makefile
+++ b/stand/efi/boot1/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.init.mk>
@@ -30,7 +29,7 @@ CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
CWARNFLAGS.zfs_module.c += -Wno-unused-function
# architecture-specific loader code
-SRCS+= boot1.c proto.c self_reloc.c start.S ufs_module.c devpath.c
+SRCS+= boot1.c proto.c self_reloc.c start.S ufs_module.c
.if ${MK_LOADER_ZFS} != "no"
SRCS+= zfs_module.c
CFLAGS.zfs_module.c+= -I${ZFSSRC}
@@ -59,19 +58,21 @@ CFLAGS+= -DEFI_DEBUG
.PATH: ${EFISRC}/loader/arch/${MACHINE}
.PATH: ${EFISRC}/loader
.PATH: ${LDRSRC}
-.PATH: ${EFISRC}/libefi
CFLAGS+= -I${LDRSRC}
FILES= ${BOOT1}.efi
FILESMODE_${BOOT1}.efi= ${BINMODE}
-LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
+LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/${MACHINE}.ldscript
LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
+.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400
+LDFLAGS+= -Wl,--no-dynamic-linker
+.endif
.if ${MACHINE_CPUARCH} == "aarch64"
CFLAGS+= -mgeneral-regs-only
.endif
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+.if ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -fPIC
LDFLAGS+= -Wl,-znocombreloc
.endif
@@ -79,17 +80,18 @@ LDFLAGS+= -Wl,-znocombreloc
LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a
#
-# Add libstand for the runtime functions used by the compiler - for example
-# __aeabi_* (arm) or __divdi3 (i386).
-# as well as required string and memory functions for all platforms.
+# Add libsa for the runtime functions used by the compiler as well as required
+# string and memory functions for all platforms.
#
DPADD+= ${LIBEFI} ${LIBSA}
LDADD+= ${LIBEFI} ${LIBSA}
DPADD+= ${LDSCRIPT}
+CLEANFILES+= ${BOOT1}.efi
+
${BOOT1}.efi: ${PROG}
- if ${NM} ${.ALLSRC} | grep ' U '; then \
+ @if ${NM} ${.ALLSRC} | grep ' U '; then \
echo "Undefined symbols in ${.ALLSRC}"; \
exit 1; \
fi
diff --git a/stand/efi/boot1/Makefile.depend b/stand/efi/boot1/Makefile.depend
index ffc5430cceec..9f7ade2e75eb 100644
--- a/stand/efi/boot1/Makefile.depend
+++ b/stand/efi/boot1/Makefile.depend
@@ -1,13 +1,8 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- include \
- include/xlocale \
- lib/libmd \
stand/efi/libefi \
stand/libsa \
- stand/zfs \
.include <dirdeps.mk>
diff --git a/stand/efi/boot1/boot1.c b/stand/efi/boot1/boot1.c
index 088821ecd1f8..908baf400972 100644
--- a/stand/efi/boot1/boot1.c
+++ b/stand/efi/boot1/boot1.c
@@ -19,9 +19,6 @@
* purpose.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <machine/elf.h>
#include <machine/stdarg.h>
@@ -96,6 +93,26 @@ try_boot(const boot_module_t *mod, dev_info_t *dev, void *loaderbuf, size_t load
buf = NULL;
}
+ /*
+ * See if there's any env variables the module wants to set. If so,
+ * append it to any config present.
+ */
+ if (mod->extra_env != NULL) {
+ const char *env = mod->extra_env();
+ if (env != NULL) {
+ size_t newlen = cmdsize + strlen(env) + 1;
+
+ cmd = realloc(cmd, newlen);
+ if (cmd == NULL)
+ goto errout;
+ if (cmdsize > 0)
+ strlcat(cmd, " ", newlen);
+ strlcat(cmd, env, newlen);
+ cmdsize = strlen(cmd);
+ free(__DECONST(char *, env));
+ }
+ }
+
if ((status = BS->LoadImage(TRUE, IH, efi_devpath_last_node(dev->devpath),
loaderbuf, loadersize, &loaderhandle)) != EFI_SUCCESS) {
printf("Failed to load image provided by %s, size: %zu, (%lu)\n",
diff --git a/stand/efi/boot1/boot_module.h b/stand/efi/boot1/boot_module.h
index 99046fb53577..dd86249fbe3e 100644
--- a/stand/efi/boot1/boot_module.h
+++ b/stand/efi/boot1/boot_module.h
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _BOOT_MODULE_H_
@@ -94,6 +92,9 @@ typedef struct boot_module_t
/* valid devices as found by probe. */
dev_info_t *(*devices)(void);
+
+ /* return any environment variables to pass to next stage */
+ const char *(*extra_env)(void);
} boot_module_t;
extern const boot_module_t *boot_modules[];
diff --git a/stand/efi/boot1/proto.c b/stand/efi/boot1/proto.c
index eeb3cd9568a4..6660d39a921b 100644
--- a/stand/efi/boot1/proto.c
+++ b/stand/efi/boot1/proto.c
@@ -19,9 +19,6 @@
* purpose.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <machine/elf.h>
#include <machine/stdarg.h>
diff --git a/stand/efi/boot1/proto.h b/stand/efi/boot1/proto.h
index 5d80f907a5a5..435da4714f12 100644
--- a/stand/efi/boot1/proto.h
+++ b/stand/efi/boot1/proto.h
@@ -21,8 +21,6 @@
* 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.
- *
- * $FreeBSD$
*/
void choice_protocol(EFI_HANDLE *handles, UINTN nhandles, EFI_DEVICE_PATH *imgpath);
diff --git a/stand/efi/boot1/ufs_module.c b/stand/efi/boot1/ufs_module.c
index edd7918e00b6..0bdd5c018b06 100644
--- a/stand/efi/boot1/ufs_module.c
+++ b/stand/efi/boot1/ufs_module.c
@@ -28,13 +28,11 @@
* 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.
- *
- * $FreeBSD$
*/
#include <stdarg.h>
#include <stdbool.h>
-#include <sys/cdefs.h>
+
#include <sys/param.h>
#include <sys/disk/bsd.h>
#include <efi.h>
diff --git a/stand/efi/boot1/zfs_module.c b/stand/efi/boot1/zfs_module.c
index 7aaca72e30f1..16722b33f0b9 100644
--- a/stand/efi/boot1/zfs_module.c
+++ b/stand/efi/boot1/zfs_module.c
@@ -22,13 +22,11 @@
* 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.
- *
- * $FreeBSD$
*/
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
-#include <sys/cdefs.h>
+
#include <sys/param.h>
#include <sys/queue.h>
#include <efi.h>
@@ -40,6 +38,8 @@
static dev_info_t *devices;
+static char zfs_bootonce[VDEV_PAD_SIZE];
+
uint64_t
ldi_get_size(void *priv)
{
@@ -142,6 +142,7 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize)
struct zfsmount zmount;
dnode_phys_t dn;
struct stat st;
+ uint64_t rootobj;
int err;
void *buf;
@@ -160,8 +161,47 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize)
return (EFI_NOT_FOUND);
}
- if ((err = zfs_mount_impl(spa, 0, &zmount)) != 0) {
- DPRINTF("Failed to mount pool '%s' (%d)\n", spa->spa_name, err);
+ if (zfs_get_bootonce_spa(spa, OS_BOOTONCE, zfs_bootonce,
+ sizeof(zfs_bootonce)) == 0) {
+ /*
+ * If bootonce attribute is present, use it as root dataset.
+ * Any attempt to use it should clear the 'once' flag. Prior
+ * to now, we'd not be able to clear it anyway. We don't care
+ * if we can't find the files to boot, or if there's a problem
+ * with it: we've tried to use it once we're able to mount the
+ * ZFS dataset.
+ *
+ * Note: the attribute is prefixed with "zfs:" and suffixed
+ * with ":".
+ */
+ char *dname, *end;
+
+ if (zfs_bootonce[0] != 'z' || zfs_bootonce[1] != 'f' ||
+ zfs_bootonce[2] != 's' || zfs_bootonce[3] != ':' ||
+ (dname = strchr(&zfs_bootonce[4], '/')) == NULL ||
+ (end = strrchr(&zfs_bootonce[4], ':')) == NULL) {
+ printf("INVALID zfs bootonce: %s\n", zfs_bootonce);
+ *zfs_bootonce = '\0';
+ rootobj = 0;
+ } else {
+ dname += 1;
+ *end = '\0';
+ if (zfs_lookup_dataset(spa, dname, &rootobj) != 0) {
+ printf("zfs bootonce dataset %s NOT FOUND\n",
+ dname);
+ *zfs_bootonce = '\0';
+ rootobj = 0;
+ } else
+ printf("zfs bootonce: %s\n", zfs_bootonce);
+ *end = ':';
+ }
+ } else {
+ *zfs_bootonce = '\0';
+ rootobj = 0;
+ }
+
+ if ((err = zfs_mount_impl(spa, rootobj, &zmount)) != 0) {
+ printf("Failed to mount pool '%s' (%d)\n", spa->spa_name, err);
return (EFI_NOT_FOUND);
}
@@ -220,6 +260,18 @@ status(void)
printf("\n");
}
+static const char *
+extra_env(void)
+{
+ char *rv = NULL; /* So we return NULL if asprintf fails */
+
+ if (*zfs_bootonce == '\0')
+ return NULL;
+ asprintf(&rv, "zfs-bootonce=%s", zfs_bootonce);
+ return (rv);
+}
+
+
static void
init(void)
{
@@ -241,5 +293,6 @@ const boot_module_t zfs_module =
.probe = probe,
.load = load,
.status = status,
- .devices = _devices
+ .devices = _devices,
+ .extra_env = extra_env,
};
diff --git a/stand/efi/fdt/Makefile b/stand/efi/fdt/Makefile
index 7f69ce1b3f11..518d7a75dc68 100644
--- a/stand/efi/fdt/Makefile
+++ b/stand/efi/fdt/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.init.mk>
diff --git a/stand/efi/fdt/Makefile.depend b/stand/efi/fdt/Makefile.depend
index 18be76b0cb6f..18537add9fe3 100644
--- a/stand/efi/fdt/Makefile.depend
+++ b/stand/efi/fdt/Makefile.depend
@@ -1,9 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- include \
- include/xlocale \
+ stand/libsa \
.include <dirdeps.mk>
diff --git a/stand/efi/fdt/efi_fdt.c b/stand/efi/fdt/efi_fdt.c
index cf3cbabee722..adf830e44182 100644
--- a/stand/efi/fdt/efi_fdt.c
+++ b/stand/efi/fdt/efi_fdt.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2014 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Andrew Turner under
* sponsorship from the FreeBSD Foundation.
@@ -27,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <stand.h>
#include <efi.h>
diff --git a/stand/efi/gptboot/Makefile b/stand/efi/gptboot/Makefile
index 2dcf8dda8f59..7d4c225bc5d4 100644
--- a/stand/efi/gptboot/Makefile
+++ b/stand/efi/gptboot/Makefile
@@ -1,4 +1,4 @@
-# $FreeBSD$
+.include <bsd.init.mk>
# ZFS is not supported, we want debugging until this is vetted and
# we don't want the gptboot.efifat thing created.
diff --git a/stand/efi/gptboot/drv.h b/stand/efi/gptboot/drv.h
index d7df6a10f1e4..aa58237180f0 100644
--- a/stand/efi/gptboot/drv.h
+++ b/stand/efi/gptboot/drv.h
@@ -21,8 +21,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _DRV_H_
diff --git a/stand/efi/gptboot/gptboot.efi.8 b/stand/efi/gptboot/gptboot.efi.8
index 134c5353e9f1..e520509e35e6 100644
--- a/stand/efi/gptboot/gptboot.efi.8
+++ b/stand/efi/gptboot/gptboot.efi.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 6, 2021
+.Dd April 13, 2023
.Dt GPTBOOT.EFI 8
.Os
.Sh NAME
@@ -274,7 +272,7 @@ gpart set -a bootonce -i 2 ada0
appeared in
.Fx 13.0
.Sh AUTHORS
-This manual page written by
+This manual page was written by
.An Warner Losh Aq imp@FreeBSD.org .
It is based heavily on the
.Xr gptboot 8
diff --git a/stand/efi/gptboot/proto.c b/stand/efi/gptboot/proto.c
index 38ccb5023c16..e2face6c23e5 100644
--- a/stand/efi/gptboot/proto.c
+++ b/stand/efi/gptboot/proto.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <machine/elf.h>
#include <machine/stdarg.h>
diff --git a/stand/efi/include/Guid/MemoryTypeInformation.h b/stand/efi/include/Guid/MemoryTypeInformation.h
index 50386b747d35..be9c4b5177a9 100644
--- a/stand/efi/include/Guid/MemoryTypeInformation.h
+++ b/stand/efi/include/Guid/MemoryTypeInformation.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
This file defines:
* Memory Type Information GUID for HOB and Variable.
diff --git a/stand/efi/include/Guid/MtcVendor.h b/stand/efi/include/Guid/MtcVendor.h
index 471e7df4d673..3aa774f55477 100644
--- a/stand/efi/include/Guid/MtcVendor.h
+++ b/stand/efi/include/Guid/MtcVendor.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
GUID is for MTC variable.
diff --git a/stand/efi/include/Guid/ZeroGuid.h b/stand/efi/include/Guid/ZeroGuid.h
index a7502cb83534..6de8c3821f5f 100644
--- a/stand/efi/include/Guid/ZeroGuid.h
+++ b/stand/efi/include/Guid/ZeroGuid.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
GUID has all zero values.
diff --git a/stand/efi/include/Protocol/EdidActive.h b/stand/efi/include/Protocol/EdidActive.h
index 88fc0c68ec37..1f6ff052a91c 100644
--- a/stand/efi/include/Protocol/EdidActive.h
+++ b/stand/efi/include/Protocol/EdidActive.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
EDID Active Protocol from the UEFI 2.0 specification.
diff --git a/stand/efi/include/Protocol/EdidDiscovered.h b/stand/efi/include/Protocol/EdidDiscovered.h
index a521e90d0056..c10b6ee89a82 100644
--- a/stand/efi/include/Protocol/EdidDiscovered.h
+++ b/stand/efi/include/Protocol/EdidDiscovered.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
EDID Discovered Protocol from the UEFI 2.0 specification.
diff --git a/stand/efi/include/Protocol/EdidOverride.h b/stand/efi/include/Protocol/EdidOverride.h
index d64d400e8c06..450c95641fce 100644
--- a/stand/efi/include/Protocol/EdidOverride.h
+++ b/stand/efi/include/Protocol/EdidOverride.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
EDID Override Protocol from the UEFI 2.0 specification.
diff --git a/stand/efi/include/Protocol/Http.h b/stand/efi/include/Protocol/Http.h
index 54f49ab5e35c..c88cc9f78847 100644
--- a/stand/efi/include/Protocol/Http.h
+++ b/stand/efi/include/Protocol/Http.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
This file defines the EFI HTTP Protocol interface. It is split into
the following two main sections:
diff --git a/stand/efi/include/Protocol/Ip4Config2.h b/stand/efi/include/Protocol/Ip4Config2.h
index 47241d7ad7d4..41b5abaafa02 100644
--- a/stand/efi/include/Protocol/Ip4Config2.h
+++ b/stand/efi/include/Protocol/Ip4Config2.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
This file provides a definition of the EFI IPv4 Configuration II
Protocol.
diff --git a/stand/efi/include/Protocol/ServiceBinding.h b/stand/efi/include/Protocol/ServiceBinding.h
index 39602b086e5b..ac501515ac67 100644
--- a/stand/efi/include/Protocol/ServiceBinding.h
+++ b/stand/efi/include/Protocol/ServiceBinding.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
UEFI Service Binding Protocol is defined in UEFI specification.
diff --git a/stand/efi/include/README b/stand/efi/include/README
index bf821fae7e60..126cfa752f69 100644
--- a/stand/efi/include/README
+++ b/stand/efi/include/README
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*-
Files in this directory and subdirectories are subject to the following
diff --git a/stand/efi/include/amd64/efibind.h b/stand/efi/include/amd64/efibind.h
index 8cfce5bbc5f1..d005ade221c4 100644
--- a/stand/efi/include/amd64/efibind.h
+++ b/stand/efi/include/amd64/efibind.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
@@ -27,89 +26,6 @@ Revision History
#pragma pack()
-
-#ifdef __FreeBSD__
-#include <sys/stdint.h>
-#else
-//
-// Basic int types of various widths
-//
-
-#if (__STDC_VERSION__ < 199901L )
-
- // No ANSI C 1999/2000 stdint.h integer width declarations
-
- #ifdef _MSC_EXTENSIONS
-
- // Use Microsoft C compiler integer width declarations
-
- typedef unsigned __int64 uint64_t;
- typedef __int64 int64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
- #ifdef UNIX_LP64
-
- // Use LP64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long uint64_t;
- typedef long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
-
- // Assume P64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long long uint64_t;
- typedef long long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #endif
- #endif
-#endif
-#endif /* __FreeBSD__ */
-
-//
-// Basic EFI types of various widths
-//
-
-#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine */
-#define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
-
-typedef uint64_t UINT64;
-typedef int64_t INT64;
-
-#ifndef _BASETSD_H_
- typedef uint32_t UINT32;
- typedef int32_t INT32;
-#endif
-
-typedef uint16_t UINT16;
-typedef int16_t INT16;
-typedef uint8_t UINT8;
-typedef int8_t INT8;
-
-#endif
-
-#undef VOID
-#define VOID void
-
-
-typedef int64_t INTN;
-typedef uint64_t UINTN;
-
#ifdef EFI_NT_EMULATOR
#define POST_CODE(_Data)
#else
diff --git a/stand/efi/include/amd64/pe.h b/stand/efi/include/amd64/pe.h
index f8033c55ac55..ad5985cc2740 100644
--- a/stand/efi/include/amd64/pe.h
+++ b/stand/efi/include/amd64/pe.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*
PE32+ header file
*/
diff --git a/stand/efi/include/arm/efibind.h b/stand/efi/include/arm/efibind.h
index 177032adc01a..a08d26ac84c4 100644
--- a/stand/efi/include/arm/efibind.h
+++ b/stand/efi/include/arm/efibind.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
@@ -41,41 +40,6 @@ Abstract:
#endif
-#ifdef __FreeBSD__
-#include <sys/stdint.h>
-#else
-//
-// Assume standard IA-32 alignment.
-// BugBug: Need to check portability of long long
-//
-typedef unsigned long long uint64_t;
-typedef long long int64_t;
-typedef unsigned int uint32_t;
-typedef int int32_t;
-typedef unsigned short uint16_t;
-typedef short int16_t;
-typedef unsigned char uint8_t;
-typedef signed char int8_t;
-#endif
-
-typedef uint64_t UINT64;
-typedef int64_t INT64;
-typedef uint32_t UINT32;
-typedef int32_t INT32;
-typedef uint16_t UINT16;
-typedef int16_t INT16;
-typedef uint8_t UINT8;
-typedef int8_t INT8;
-
-#undef VOID
-#define VOID void
-
-//
-// Native integer size in stdint.h
-//
-typedef uint32_t UINTN;
-typedef int32_t INTN;
-
#define EFIERR(a) (0x80000000 | a)
#define EFI_ERROR_MASK 0x80000000
#define EFIERR_OEM(a) (0xc0000000 | a)
diff --git a/stand/efi/include/arm64/efibind.h b/stand/efi/include/arm64/efibind.h
index 4751e2e944a8..417da1b4d4ff 100644
--- a/stand/efi/include/arm64/efibind.h
+++ b/stand/efi/include/arm64/efibind.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
@@ -27,82 +26,6 @@ Revision History
#pragma pack()
-
-#ifdef __FreeBSD__
-#include <sys/stdint.h>
-#else
-//
-// Basic int types of various widths
-//
-
-#if (__STDC_VERSION__ < 199901L )
-
- // No ANSI C 1999/2000 stdint.h integer width declarations
-
- #ifdef _MSC_EXTENSIONS
-
- // Use Microsoft C compiler integer width declarations
-
- typedef unsigned __int64 uint64_t;
- typedef __int64 int64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef unsigned __int16 uint16_t;
- typedef __int16 int16_t;
- typedef unsigned __int8 uint8_t;
- typedef __int8 int8_t;
- #else
- #ifdef UNIX_LP64
-
- // Use LP64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long uint64_t;
- typedef long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
-
- // Assume P64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long long uint64_t;
- typedef long long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #endif
- #endif
-#endif
-#endif /* __FreeBSD__ */
-
-//
-// Basic EFI types of various widths
-//
-
-
-typedef uint64_t UINT64;
-typedef int64_t INT64;
-typedef uint32_t UINT32;
-typedef int32_t INT32;
-typedef uint16_t UINT16;
-typedef int16_t INT16;
-typedef uint8_t UINT8;
-typedef int8_t INT8;
-
-
-#undef VOID
-#define VOID void
-
-
-typedef int64_t INTN;
-typedef uint64_t UINTN;
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BugBug: Code to debug
//
diff --git a/stand/efi/include/efi.h b/stand/efi/include/efi.h
index 7e44a5b819fc..b603c3a78205 100644
--- a/stand/efi/include/efi.h
+++ b/stand/efi/include/efi.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
@@ -40,6 +39,37 @@ Revision History
#define EFI_FIRMWARE_MINOR_REVISION 62
#define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION))
+//
+// Basic EFI types of various widths.
+//
+
+#include <stdint.h>
+#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine */
+#define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
+
+typedef uint64_t UINT64;
+typedef int64_t INT64;
+typedef uint32_t UINT32;
+typedef int32_t INT32;
+typedef uint16_t UINT16;
+typedef int16_t INT16;
+typedef uint8_t UINT8;
+typedef int8_t INT8;
+
+#ifdef __LP64__
+typedef int64_t INTN;
+typedef uint64_t UINTN;
+#else
+typedef int32_t INTN;
+typedef uint32_t UINTN;
+#endif
+
+#endif
+
+#undef VOID
+#define VOID void
+
+
#include "efibind.h"
#include "efidef.h"
#include "efidevp.h"
diff --git a/stand/efi/include/efi_driver_utils.h b/stand/efi/include/efi_driver_utils.h
index 520cff128a27..9f0b6dfd638d 100644
--- a/stand/efi/include/efi_driver_utils.h
+++ b/stand/efi/include/efi_driver_utils.h
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _EFI_DRIVER_UTILS_H_
diff --git a/stand/efi/include/efi_drivers.h b/stand/efi/include/efi_drivers.h
index 8df9133f73d4..938e17b6863d 100644
--- a/stand/efi/include/efi_drivers.h
+++ b/stand/efi/include/efi_drivers.h
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _EFI_DRIVERS_H_
diff --git a/stand/efi/include/efi_nii.h b/stand/efi/include/efi_nii.h
index 561cbd46a3ea..069e318428ea 100644
--- a/stand/efi/include/efi_nii.h
+++ b/stand/efi/include/efi_nii.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_NII_H
#define _EFI_NII_H
diff --git a/stand/efi/include/efiapi.h b/stand/efi/include/efiapi.h
index 0118027d4b3c..6c96c6f707ad 100644
--- a/stand/efi/include/efiapi.h
+++ b/stand/efi/include/efiapi.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_API_H
#define _EFI_API_H
@@ -438,7 +437,7 @@ VOID
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN CHAR16 *ResetData OPTIONAL
- );
+ ) __dead2;
typedef
EFI_STATUS
diff --git a/stand/efi/include/efichar.h b/stand/efi/include/efichar.h
index 49ff43b3cb20..0a40906aeedf 100644
--- a/stand/efi/include/efichar.h
+++ b/stand/efi/include/efichar.h
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _BOOT_EFI_EFICHAR_H_
@@ -39,4 +37,12 @@ int ucs2_to_utf8(const efi_char *, char **);
int utf8_to_ucs2(const char *, efi_char **, size_t *);
int ucs2len(const efi_char *);
+#ifdef _KERNEL
+#define EFICHAR_MALLOC(sz) malloc((sz), M_TEMP, M_WAITOK | M_ZERO)
+#define EFICHAR_FREE(sz) free((sz), M_TEMP)
+#else
+#define EFICHAR_MALLOC(sz) malloc(sz)
+#define EFICHAR_FREE(sz) free(sz)
+#endif
+
#endif /* _BOOT_EFI_EFICHAR_H_ */
diff --git a/stand/efi/include/eficon.h b/stand/efi/include/eficon.h
index b5a387cb08fd..3196ef4b4bf5 100644
--- a/stand/efi/include/eficon.h
+++ b/stand/efi/include/eficon.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_CON_H
#define _EFI_CON_H
@@ -421,7 +420,7 @@ EFI_STATUS
Routine Description:
Reads the next keystroke from the input device. The WaitForKey Event can
- be used to test for existance of a keystroke via WaitForEvent () call.
+ be used to test for existence of a keystroke via WaitForEvent () call.
Arguments:
This - Protocol instance pointer.
@@ -486,7 +485,7 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The notification function was registered successfully.
- EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
+ EFI_OUT_OF_RESOURCES - Unable to allocate resources for necessary data structures.
EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
--*/
diff --git a/stand/efi/include/eficonsctl.h b/stand/efi/include/eficonsctl.h
index 68be3d69f4fd..c7f5a137045e 100644
--- a/stand/efi/include/eficonsctl.h
+++ b/stand/efi/include/eficonsctl.h
@@ -29,7 +29,6 @@
* Abstract: Abstraction of a Text mode or GOP/UGA screen
*/
-/* $FreeBSD$ */
#ifndef _EFI_CONS_CTL_H
#define _EFI_CONS_CTL_H
diff --git a/stand/efi/include/efidebug.h b/stand/efi/include/efidebug.h
index 5576d5f4e48c..b43b62d1283c 100644
--- a/stand/efi/include/efidebug.h
+++ b/stand/efi/include/efidebug.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_DEBUG_H
#define _EFI_DEBUG_H
diff --git a/stand/efi/include/efidef.h b/stand/efi/include/efidef.h
index a8f88d41df24..54be3bb2a0ce 100644
--- a/stand/efi/include/efidef.h
+++ b/stand/efi/include/efidef.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_DEF_H
#define _EFI_DEF_H
diff --git a/stand/efi/include/efidevp.h b/stand/efi/include/efidevp.h
index b00b78f02c6a..409f2b23b9ef 100644
--- a/stand/efi/include/efidevp.h
+++ b/stand/efi/include/efidevp.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _DEVPATH_H
#define _DEVPATH_H
diff --git a/stand/efi/include/efierr.h b/stand/efi/include/efierr.h
index a8b655718599..2aa2622a3877 100644
--- a/stand/efi/include/efierr.h
+++ b/stand/efi/include/efierr.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_ERR_H
#define _EFI_ERR_H
diff --git a/stand/efi/include/efifpswa.h b/stand/efi/include/efifpswa.h
index 21823c5ff6f1..ed831d02e51b 100644
--- a/stand/efi/include/efifpswa.h
+++ b/stand/efi/include/efifpswa.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_FPSWA_H
#define _EFI_FPSWA_H
diff --git a/stand/efi/include/efifs.h b/stand/efi/include/efifs.h
index 76aa93d6d07f..3ba238496b23 100644
--- a/stand/efi/include/efifs.h
+++ b/stand/efi/include/efifs.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_FS_H
#define _EFI_FS_H
diff --git a/stand/efi/include/efigop.h b/stand/efi/include/efigop.h
index 104fa6e44b5a..e1d4b8163401 100644
--- a/stand/efi/include/efigop.h
+++ b/stand/efi/include/efigop.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
diff --git a/stand/efi/include/efigpt.h b/stand/efi/include/efigpt.h
index 045d49520b40..ac90a304f762 100644
--- a/stand/efi/include/efigpt.h
+++ b/stand/efi/include/efigpt.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_GPT_H
#define _EFI_GPT_H
/*++
diff --git a/stand/efi/include/efiip.h b/stand/efi/include/efiip.h
index ce0910a1b998..839507964f75 100644
--- a/stand/efi/include/efiip.h
+++ b/stand/efi/include/efiip.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_IP_H
#define _EFI_IP_H
diff --git a/stand/efi/include/efilib.h b/stand/efi/include/efilib.h
index 903e1f0d00e5..e1920430a7d1 100644
--- a/stand/efi/include/efilib.h
+++ b/stand/efi/include/efilib.h
@@ -23,8 +23,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _LOADER_EFILIB_H
@@ -85,9 +83,6 @@ efi_exit_boot_services(UINTN key)
}
int efi_getdev(void **vdev, const char *devspec, const char **path);
-char *efi_fmtdev(void *vdev);
-int efi_setcurrdev(struct env_var *ev, int flags, const void *value);
-
int efi_register_handles(struct devsw *, EFI_HANDLE *, EFI_HANDLE *, int);
EFI_HANDLE efi_find_handle(struct devsw *, int);
@@ -100,6 +95,7 @@ void efi_close_devpath(EFI_HANDLE);
EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *);
EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *);
EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *);
+EFI_DEVICE_PATH *efi_devpath_next_instance(EFI_DEVICE_PATH *);
bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
bool efi_devpath_match_node(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
diff --git a/stand/efi/include/efinet.h b/stand/efi/include/efinet.h
index 3ac58b2431ca..9cd13f5a4653 100644
--- a/stand/efi/include/efinet.h
+++ b/stand/efi/include/efinet.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFINET_H
#define _EFINET_H
diff --git a/stand/efi/include/efipart.h b/stand/efi/include/efipart.h
index ef1a8709d91b..32a715c8781b 100644
--- a/stand/efi/include/efipart.h
+++ b/stand/efi/include/efipart.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_PART_H
#define _EFI_PART_H
diff --git a/stand/efi/include/efipciio.h b/stand/efi/include/efipciio.h
index b42fa59395a0..4e9ca153f721 100644
--- a/stand/efi/include/efipciio.h
+++ b/stand/efi/include/efipciio.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
EFI PCI I/O Protocol provides the basic Memory, I/O, PCI configuration,
and DMA interfaces that a driver uses to access its PCI controller.
diff --git a/stand/efi/include/efipoint.h b/stand/efi/include/efipoint.h
index 99944f720378..46e92ffd3b48 100644
--- a/stand/efi/include/efipoint.h
+++ b/stand/efi/include/efipoint.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* Copyright (C) 2014 by John Cronin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/stand/efi/include/efiprot.h b/stand/efi/include/efiprot.h
index 351b2d347ad4..be11ea83b3a2 100644
--- a/stand/efi/include/efiprot.h
+++ b/stand/efi/include/efiprot.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_PROT_H
#define _EFI_PROT_H
diff --git a/stand/efi/include/efipxebc.h b/stand/efi/include/efipxebc.h
index ba0b2e9b6c5d..5d5c60a104b0 100644
--- a/stand/efi/include/efipxebc.h
+++ b/stand/efi/include/efipxebc.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFIPXEBC_H
#define _EFIPXEBC_H
diff --git a/stand/efi/include/efirng.h b/stand/efi/include/efirng.h
new file mode 100644
index 000000000000..3d6c77677981
--- /dev/null
+++ b/stand/efi/include/efirng.h
@@ -0,0 +1,50 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ * Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
+ * This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD License
+ * which accompanies this distribution. The full text of the license may be found at
+ * http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ *
+ */
+
+#ifndef _EFIRNG_H
+#define _EFIRNG_H
+
+#define EFI_RNG_PROTOCOL_GUID \
+ { 0x3152bca5, 0xeade, 0x433d, {0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44} }
+
+INTERFACE_DECL(_EFI_RNG_PROTOCOL);
+
+typedef EFI_GUID EFI_RNG_ALGORITHM;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_RNG_GET_INFO) (
+ IN struct _EFI_RNG_PROTOCOL *This,
+ IN OUT UINTN *RNGAlgorithmListSize,
+ OUT EFI_RNG_ALGORITHM *RNGAlgorithmList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_RNG_GET_RNG) (
+ IN struct _EFI_RNG_PROTOCOL *This,
+ IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL
+ IN UINTN RNGValueLength,
+ OUT UINT8 *RNGValue
+ );
+
+typedef struct _EFI_RNG_PROTOCOL {
+ EFI_RNG_GET_INFO GetInfo;
+ EFI_RNG_GET_RNG GetRNG;
+} EFI_RNG_PROTOCOL;
+
+static EFI_GUID rng_guid = EFI_RNG_PROTOCOL_GUID;
+
+#endif /* _EFIRNG_H */
diff --git a/stand/efi/include/efiser.h b/stand/efi/include/efiser.h
index e3d66e203a4b..9a13653453fb 100644
--- a/stand/efi/include/efiser.h
+++ b/stand/efi/include/efiser.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_SER_H
#define _EFI_SER_H
diff --git a/stand/efi/include/efistdarg.h b/stand/efi/include/efistdarg.h
index 25f556984112..f4cf0356563c 100644
--- a/stand/efi/include/efistdarg.h
+++ b/stand/efi/include/efistdarg.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFISTDARG_H_
#define _EFISTDARG_H_
diff --git a/stand/efi/include/efitcp.h b/stand/efi/include/efitcp.h
index 9f47b5ce8edc..6c5df7fd944d 100644
--- a/stand/efi/include/efitcp.h
+++ b/stand/efi/include/efitcp.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_TCP_H
#define _EFI_TCP_H
diff --git a/stand/efi/include/efiudp.h b/stand/efi/include/efiudp.h
index 82c8df79b59a..7c8b467eb9c4 100644
--- a/stand/efi/include/efiudp.h
+++ b/stand/efi/include/efiudp.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _EFI_UDP_H
#define _EFI_UDP_H
diff --git a/stand/efi/include/efiuga.h b/stand/efi/include/efiuga.h
index 00464b7cb4c0..b15c2176c32f 100644
--- a/stand/efi/include/efiuga.h
+++ b/stand/efi/include/efiuga.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/** @file
UGA Draw protocol from the EFI 1.1 specification.
diff --git a/stand/efi/include/efizfs.h b/stand/efi/include/efizfs.h
index 97f28097b2a1..b29fb8d1af7e 100644
--- a/stand/efi/include/efizfs.h
+++ b/stand/efi/include/efizfs.h
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <stdint.h>
diff --git a/stand/efi/include/i386/efibind.h b/stand/efi/include/i386/efibind.h
index 0f1d4f115598..e4cbceae8216 100644
--- a/stand/efi/include/i386/efibind.h
+++ b/stand/efi/include/i386/efibind.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
@@ -27,89 +26,6 @@ Revision History
#pragma pack()
-
-#ifdef __FreeBSD__
-#include <sys/stdint.h>
-#else
-//
-// Basic int types of various widths
-//
-
-#if (__STDC_VERSION__ < 199901L )
-
- // No ANSI C 1999/2000 stdint.h integer width declarations
-
- #ifdef _MSC_EXTENSIONS
-
- // Use Microsoft C compiler integer width declarations
-
- typedef unsigned __int64 uint64_t;
- typedef __int64 int64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
- #ifdef UNIX_LP64
-
- // Use LP64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long uint64_t;
- typedef long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
-
- // Assume P64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long long uint64_t;
- typedef long long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #endif
- #endif
-#endif
-#endif /* __FreeBSD__ */
-
-//
-// Basic EFI types of various widths
-//
-
-#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine, use those */
-#define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
-
-typedef uint64_t UINT64;
-typedef int64_t INT64;
-
-#ifndef _BASETSD_H_
- typedef uint32_t UINT32;
- typedef int32_t INT32;
-#endif
-
-typedef uint16_t UINT16;
-typedef int16_t INT16;
-typedef uint8_t UINT8;
-typedef int8_t INT8;
-
-#endif
-
-#undef VOID
-#define VOID void
-
-
-typedef int32_t INTN;
-typedef uint32_t UINTN;
-
#ifdef EFI_NT_EMULATOR
#define POST_CODE(_Data)
#else
diff --git a/stand/efi/include/i386/pe.h b/stand/efi/include/i386/pe.h
index e2ae25c3ddf6..ede10814939f 100644
--- a/stand/efi/include/i386/pe.h
+++ b/stand/efi/include/i386/pe.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*
PE32+ header file
*/
diff --git a/stand/efi/include/riscv/efibind.h b/stand/efi/include/riscv/efibind.h
index 4751e2e944a8..417da1b4d4ff 100644
--- a/stand/efi/include/riscv/efibind.h
+++ b/stand/efi/include/riscv/efibind.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
@@ -27,82 +26,6 @@ Revision History
#pragma pack()
-
-#ifdef __FreeBSD__
-#include <sys/stdint.h>
-#else
-//
-// Basic int types of various widths
-//
-
-#if (__STDC_VERSION__ < 199901L )
-
- // No ANSI C 1999/2000 stdint.h integer width declarations
-
- #ifdef _MSC_EXTENSIONS
-
- // Use Microsoft C compiler integer width declarations
-
- typedef unsigned __int64 uint64_t;
- typedef __int64 int64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef unsigned __int16 uint16_t;
- typedef __int16 int16_t;
- typedef unsigned __int8 uint8_t;
- typedef __int8 int8_t;
- #else
- #ifdef UNIX_LP64
-
- // Use LP64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long uint64_t;
- typedef long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
-
- // Assume P64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long long uint64_t;
- typedef long long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #endif
- #endif
-#endif
-#endif /* __FreeBSD__ */
-
-//
-// Basic EFI types of various widths
-//
-
-
-typedef uint64_t UINT64;
-typedef int64_t INT64;
-typedef uint32_t UINT32;
-typedef int32_t INT32;
-typedef uint16_t UINT16;
-typedef int16_t INT16;
-typedef uint8_t UINT8;
-typedef int8_t INT8;
-
-
-#undef VOID
-#define VOID void
-
-
-typedef int64_t INTN;
-typedef uint64_t UINTN;
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BugBug: Code to debug
//
diff --git a/stand/efi/libefi/Makefile b/stand/efi/libefi/Makefile
index 8f1a30d86900..7bc0184e2062 100644
--- a/stand/efi/libefi/Makefile
+++ b/stand/efi/libefi/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.init.mk>
@@ -11,6 +10,7 @@ SRCS= delay.c \
efi_console.c \
efi_driver_utils.c \
efichar.c \
+ eficom.c \
efienv.c \
efihttp.c \
efinet.c \
@@ -25,7 +25,7 @@ SRCS= delay.c \
.PATH: ${SYSDIR}/teken
SRCS+= teken.c
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= time.c
.elif ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv"
SRCS+= time_event.c
diff --git a/stand/efi/libefi/Makefile.depend b/stand/efi/libefi/Makefile.depend
index 73bc18c8c0fc..8a29d17bb768 100644
--- a/stand/efi/libefi/Makefile.depend
+++ b/stand/efi/libefi/Makefile.depend
@@ -1,8 +1,8 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
stand/libsa \
+ usr.bin/awk.host \
.include <dirdeps.mk>
diff --git a/stand/efi/libefi/delay.c b/stand/efi/libefi/delay.c
index 9eb123096636..af03f0075330 100644
--- a/stand/efi/libefi/delay.c
+++ b/stand/efi/libefi/delay.c
@@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
void
delay(int usecs)
{
- BS->Stall(usecs);
+ if (boot_services_active)
+ BS->Stall(usecs);
}
diff --git a/stand/efi/libefi/devicename.c b/stand/efi/libefi/devicename.c
index cdf4830697fd..c18017429665 100644
--- a/stand/efi/libefi/devicename.c
+++ b/stand/efi/libefi/devicename.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <string.h>
#include <sys/disklabel.h>
@@ -39,8 +36,6 @@ __FBSDID("$FreeBSD$");
#include <efilib.h>
#include <efizfs.h>
-static int efi_parsedev(struct devdesc **, const char *, const char **);
-
/*
* Point (dev) at an allocated device specifier for the device matching the
* path in (devspec). If it contains an explicit device specification,
@@ -57,159 +52,11 @@ efi_getdev(void **vdev, const char *devspec, const char **path)
* use the current device instead.
*/
if (devspec == NULL || *devspec == '/' || !strchr(devspec, ':')) {
- rv = efi_parsedev(dev, getenv("currdev"), NULL);
+ rv = devparse(dev, getenv("currdev"), NULL);
if (rv == 0 && path != NULL)
*path = devspec;
return (rv);
}
- /* Parse the device name off the beginning of the devspec. */
- return (efi_parsedev(dev, devspec, path));
-}
-
-/*
- * Point (dev) at an allocated device specifier matching the string version
- * at the beginning of (devspec). Return a pointer to the remaining
- * text in (path).
- *
- * In all cases, the beginning of (devspec) is compared to the names
- * of known devices in the device switch, and then any following text
- * is parsed according to the rules applied to the device type.
- *
- * For disk-type devices, the syntax is:
- *
- * fs<unit>:
- */
-static int
-efi_parsedev(struct devdesc **dev, const char *devspec, const char **path)
-{
- struct devdesc *idev;
- struct devsw *dv;
- int i, unit, err;
- char *cp;
- const char *np;
-
- /* minimum length check */
- if (strlen(devspec) < 2)
- return (EINVAL);
-
- /* look for a device that matches */
- for (i = 0; devsw[i] != NULL; i++) {
- dv = devsw[i];
- if (!strncmp(devspec, dv->dv_name, strlen(dv->dv_name)))
- break;
- }
- if (devsw[i] == NULL)
- return (ENOENT);
-
- np = devspec + strlen(dv->dv_name);
- idev = NULL;
- err = 0;
-
- switch (dv->dv_type) {
- case DEVT_NONE:
- break;
-
- case DEVT_DISK:
- idev = malloc(sizeof(struct disk_devdesc));
- if (idev == NULL)
- return (ENOMEM);
-
- err = disk_parsedev((struct disk_devdesc *)idev, np, path);
- if (err != 0)
- goto fail;
- break;
-
-#ifdef EFI_ZFS_BOOT
- case DEVT_ZFS:
- idev = malloc(sizeof(struct zfs_devdesc));
- if (idev == NULL)
- return (ENOMEM);
-
- err = zfs_parsedev((struct zfs_devdesc*)idev, np, path);
- if (err != 0)
- goto fail;
- break;
-#endif
- default:
- idev = malloc(sizeof(struct devdesc));
- if (idev == NULL)
- return (ENOMEM);
-
- unit = 0;
- cp = (char *)np;
-
- if (*np != '\0' && *np != ':') {
- errno = 0;
- unit = strtol(np, &cp, 0);
- if (errno != 0 || cp == np) {
- err = EUNIT;
- goto fail;
- }
- }
- if (*cp != '\0' && *cp != ':') {
- err = EINVAL;
- goto fail;
- }
-
- idev->d_unit = unit;
- if (path != NULL)
- *path = (*cp == 0) ? cp : cp + 1;
- break;
- }
-
- idev->d_dev = dv;
-
- if (dev != NULL)
- *dev = idev;
- else
- free(idev);
- return (0);
-
-fail:
- free(idev);
- return (err);
-}
-
-char *
-efi_fmtdev(void *vdev)
-{
- struct devdesc *dev = (struct devdesc *)vdev;
- static char buf[SPECNAMELEN + 1];
-
- switch(dev->d_dev->dv_type) {
- case DEVT_NONE:
- strcpy(buf, "(no device)");
- break;
-
- case DEVT_DISK:
- return (disk_fmtdev(vdev));
-
-#ifdef EFI_ZFS_BOOT
- case DEVT_ZFS:
- return (zfs_fmtdev(dev));
-#endif
- default:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
- break;
- }
-
- return (buf);
-}
-
-/*
- * Set currdev to suit the value being supplied in (value)
- */
-int
-efi_setcurrdev(struct env_var *ev, int flags, const void *value)
-{
- struct devdesc *ncurr;
- int rv;
-
- rv = efi_parsedev(&ncurr, value, NULL);
- if (rv != 0)
- return (rv);
- free(ncurr);
-
- return (mount_currdev(ev, flags, value));
+ return (devparse(dev, devspec, path));
}
diff --git a/stand/efi/libefi/devpath.c b/stand/efi/libefi/devpath.c
index b56c583b5fa7..85a5459c7d6b 100644
--- a/stand/efi/libefi/devpath.c
+++ b/stand/efi/libefi/devpath.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
#include <efichar.h>
@@ -146,8 +143,8 @@ efi_hw_dev_path(EFI_DEVICE_PATH *node, char *suffix)
switch (subtype) {
case HW_PCI_DP:
if (asprintf(&name, "Pci(%x,%x)%s",
- ((PCI_DEVICE_PATH *)node)->Function,
- ((PCI_DEVICE_PATH *)node)->Device, tail) < 0)
+ ((PCI_DEVICE_PATH *)node)->Device,
+ ((PCI_DEVICE_PATH *)node)->Function, tail) < 0)
name = NULL;
break;
case HW_PCCARD_DP:
@@ -575,6 +572,23 @@ efi_devpath_last_node(EFI_DEVICE_PATH *devpath)
return (devpath);
}
+/*
+ * Walk device path nodes, return next instance or end node.
+ */
+EFI_DEVICE_PATH *
+efi_devpath_next_instance(EFI_DEVICE_PATH *devpath)
+{
+ while (!IsDevicePathEnd(devpath)) {
+ devpath = NextDevicePathNode(devpath);
+ if (IsDevicePathEndType(devpath) &&
+ devpath->SubType == END_INSTANCE_DEVICE_PATH_SUBTYPE) {
+ devpath = NextDevicePathNode(devpath);
+ break;
+ }
+ }
+ return (devpath);
+}
+
EFI_DEVICE_PATH *
efi_devpath_trim(EFI_DEVICE_PATH *devpath)
{
diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c
index a63cba5e3f34..4a3219ef3017 100644
--- a/stand/efi/libefi/efi_console.c
+++ b/stand/efi/libefi/efi_console.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <efi.h>
#include <efilib.h>
@@ -437,36 +434,44 @@ efi_cons_probe(struct console *cp)
static bool
color_name_to_teken(const char *name, int *val)
{
+ int light = 0;
+ if (strncasecmp(name, "light", 5) == 0) {
+ name += 5;
+ light = TC_LIGHT;
+ } else if (strncasecmp(name, "bright", 6) == 0) {
+ name += 6;
+ light = TC_LIGHT;
+ }
if (strcasecmp(name, "black") == 0) {
- *val = TC_BLACK;
+ *val = TC_BLACK | light;
return (true);
}
if (strcasecmp(name, "red") == 0) {
- *val = TC_RED;
+ *val = TC_RED | light;
return (true);
}
if (strcasecmp(name, "green") == 0) {
- *val = TC_GREEN;
+ *val = TC_GREEN | light;
return (true);
}
- if (strcasecmp(name, "brown") == 0) {
- *val = TC_BROWN;
+ if (strcasecmp(name, "yellow") == 0 || strcasecmp(name, "brown") == 0) {
+ *val = TC_YELLOW | light;
return (true);
}
if (strcasecmp(name, "blue") == 0) {
- *val = TC_BLUE;
+ *val = TC_BLUE | light;
return (true);
}
if (strcasecmp(name, "magenta") == 0) {
- *val = TC_MAGENTA;
+ *val = TC_MAGENTA | light;
return (true);
}
if (strcasecmp(name, "cyan") == 0) {
- *val = TC_CYAN;
+ *val = TC_CYAN | light;
return (true);
}
if (strcasecmp(name, "white") == 0) {
- *val = TC_WHITE;
+ *val = TC_WHITE | light;
return (true);
}
return (false);
@@ -476,7 +481,7 @@ static int
efi_set_colors(struct env_var *ev, int flags, const void *value)
{
int val = 0;
- char buf[2];
+ char buf[3];
const void *evalue;
const teken_attr_t *ap;
teken_attr_t a;
@@ -489,14 +494,16 @@ efi_set_colors(struct env_var *ev, int flags, const void *value)
evalue = buf;
} else {
char *end;
+ long lval;
errno = 0;
- val = (int)strtol(value, &end, 0);
- if (errno != 0 || *end != '\0') {
+ lval = strtol(value, &end, 0);
+ if (errno != 0 || *end != '\0' || lval < 0 || lval > 15) {
printf("Allowed values are either ansi color name or "
- "number from range [0-7].\n");
+ "number from range [0-15].\n");
return (CMD_OK);
}
+ val = (int)lval;
evalue = value;
}
@@ -1352,6 +1359,9 @@ efi_cons_getchar(void)
if ((c = keybuf_getchar()) != 0)
return (c);
+ if (!boot_services_active)
+ return (-1);
+
key_pending = 0;
if (coninex == NULL) {
@@ -1373,6 +1383,9 @@ efi_cons_poll(void)
if (keybuf_ischar() || key_pending)
return (1);
+ if (!boot_services_active)
+ return (0);
+
/*
* Some EFI implementation (u-boot for example) do not support
* WaitForKey().
diff --git a/stand/efi/libefi/efi_driver_utils.c b/stand/efi/libefi/efi_driver_utils.c
index e5034c2e34d6..adb57f39fdce 100644
--- a/stand/efi/libefi/efi_driver_utils.c
+++ b/stand/efi/libefi/efi_driver_utils.c
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <stdbool.h>
diff --git a/stand/efi/libefi/efichar.c b/stand/efi/libefi/efichar.c
index 233027f4e6ea..659212799b6a 100644
--- a/stand/efi/libefi/efichar.c
+++ b/stand/efi/libefi/efichar.c
@@ -24,18 +24,22 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
+#ifndef _KERNEL
#include <errno.h>
+#endif
#ifdef _STANDALONE
#include <stand.h>
#else
+#ifdef _KERNEL
+#include <sys/malloc.h>
+#include <sys/systm.h>
+#else
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#endif
#include <sys/efi.h>
#include <machine/efi.h>
#endif
@@ -90,7 +94,7 @@ ucs2_to_utf8(const efi_char *nm, char **name)
if (*name != NULL)
cp = *name;
else
- cp = *name = malloc(sz);
+ cp = *name = EFICHAR_MALLOC(sz);
if (*name == NULL)
return (ENOMEM);
@@ -117,7 +121,7 @@ ucs2_to_utf8(const efi_char *nm, char **name)
if (len >= sz) {
/* Absent bugs, we'll never return EOVERFLOW */
if (freeit) {
- free(*name);
+ EFICHAR_FREE(*name);
*name = NULL;
}
return (EOVERFLOW);
@@ -138,7 +142,7 @@ utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len)
sz = strlen(name) * 2 + 2;
if (*nmp == NULL)
- *nmp = malloc(sz);
+ *nmp = EFICHAR_MALLOC(sz);
if (*nmp == NULL)
return (ENOMEM);
nm = *nmp;
@@ -186,7 +190,7 @@ utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len)
}
if (sz < 2) {
if (freeit) {
- free(nm);
+ EFICHAR_FREE(nm);
*nmp = NULL;
}
return (EDOOFUS);
@@ -197,7 +201,7 @@ utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len)
return (0);
ilseq:
if (freeit) {
- free(nm);
+ EFICHAR_FREE(nm);
*nmp = NULL;
}
return (EILSEQ);
diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/libefi/eficom.c
index 8b3f8e83e0b3..d5f3f07e083f 100644
--- a/stand/efi/loader/efiserialio.c
+++ b/stand/efi/libefi/eficom.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <sys/errno.h>
#include <bootstrap.h>
@@ -34,25 +31,20 @@ __FBSDID("$FreeBSD$");
#include <efi.h>
#include <efilib.h>
-#include "loader_efi.h"
-
static EFI_GUID serial = SERIAL_IO_PROTOCOL;
#define COMC_TXWAIT 0x40000 /* transmit timeout */
-#ifndef COMSPEED
-#define COMSPEED 9600
-#endif
-
#define PNP0501 0x501 /* 16550A-compatible COM port */
struct serial {
+ uint64_t newbaudrate;
uint64_t baudrate;
- uint8_t databits;
+ uint32_t timeout;
+ uint32_t receivefifodepth;
+ uint32_t databits;
EFI_PARITY_TYPE parity;
EFI_STOP_BITS_TYPE stopbits;
- uint8_t ignore_cd; /* boolean */
- uint8_t rtsdtr_off; /* boolean */
int ioaddr; /* index in handles array */
EFI_HANDLE currdev; /* current serial device */
EFI_HANDLE condev; /* EFI Console device */
@@ -72,16 +64,30 @@ static int comc_speed_set(struct env_var *, int, const void *);
static struct serial *comc_port;
extern struct console efi_console;
+struct console eficom = {
+ .c_name = "eficom",
+ .c_desc = "serial port",
+ .c_flags = 0,
+ .c_probe = comc_probe,
+ .c_init = comc_init,
+ .c_out = comc_putchar,
+ .c_in = comc_getchar,
+ .c_ready = comc_ischar,
+};
+
+#if defined(__aarch64__) && __FreeBSD_version < 1500000
+static void comc_probe_compat(struct console *);
struct console comconsole = {
.c_name = "comconsole",
.c_desc = "serial port",
.c_flags = 0,
- .c_probe = comc_probe,
+ .c_probe = comc_probe_compat,
.c_init = comc_init,
.c_out = comc_putchar,
.c_in = comc_getchar,
.c_ready = comc_ischar,
};
+#endif
static EFI_STATUS
efi_serial_init(EFI_HANDLE **handlep, int *nhandles)
@@ -245,6 +251,11 @@ comc_get_con_serial_handle(const char *name)
return (NULL);
}
+/*
+ * Called from cons_probe() to see if this device is available.
+ * Return immediately on x86, except for hyperv, since it interferes with
+ * common configurations otherwise (yes, this is just firewalling the bug).
+ */
static void
comc_probe(struct console *sc)
{
@@ -256,19 +267,28 @@ comc_probe(struct console *sc)
char *env, *buf, *ep;
size_t sz;
+#ifdef __amd64__
+ /*
+ * This driver tickles issues on a number of different firmware loads.
+ * It is only required for HyperV, and is only known to work on HyperV,
+ * so only allow it on HyperV.
+ */
+ env = getenv("smbios.bios.version");
+ if (env == NULL || strncmp(env, "Hyper-V", 7) != 0) {
+ return;
+ }
+#endif
+
if (comc_port == NULL) {
- comc_port = malloc(sizeof (struct serial));
+ comc_port = calloc(1, sizeof (struct serial));
if (comc_port == NULL)
return;
}
- comc_port->baudrate = COMSPEED;
- comc_port->ioaddr = 0; /* default port */
- comc_port->databits = 8; /* 8,n,1 */
- comc_port->parity = NoParity; /* 8,n,1 */
- comc_port->stopbits = OneStopBit; /* 8,n,1 */
- comc_port->ignore_cd = 1; /* ignore cd */
- comc_port->rtsdtr_off = 0; /* rts-dtr is on */
- comc_port->sio = NULL;
+
+ /* Use defaults from firmware */
+ comc_port->databits = 8;
+ comc_port->parity = DefaultParity;
+ comc_port->stopbits = DefaultStopBits;
handle = NULL;
env = getenv("efi_com_port");
@@ -292,8 +312,28 @@ comc_probe(struct console *sc)
(void**)&comc_port->sio, IH, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(status))
+ if (EFI_ERROR(status)) {
comc_port->sio = NULL;
+ } else {
+ comc_port->newbaudrate =
+ comc_port->baudrate = comc_port->sio->Mode->BaudRate;
+ comc_port->timeout = comc_port->sio->Mode->Timeout;
+ comc_port->receivefifodepth =
+ comc_port->sio->Mode->ReceiveFifoDepth;
+ comc_port->databits = comc_port->sio->Mode->DataBits;
+ comc_port->parity = comc_port->sio->Mode->Parity;
+ comc_port->stopbits = comc_port->sio->Mode->StopBits;
+ }
+ }
+
+ /*
+ * If there's no sio, then the device isn't there, so just return since
+ * the present flags aren't yet set.
+ */
+ if (comc_port->sio == NULL) {
+ free(comc_port);
+ comc_port = NULL;
+ return;
}
if (env != NULL)
@@ -303,8 +343,12 @@ comc_probe(struct console *sc)
comc_port_set, env_nounset);
env = getenv("efi_com_speed");
+ if (env == NULL)
+ /* fallback to comconsole setting */
+ env = getenv("comconsole_speed");
+
if (comc_parse_intval(env, &val) == CMD_OK)
- comc_port->baudrate = val;
+ comc_port->newbaudrate = val;
if (env != NULL)
unsetenv("efi_com_speed");
@@ -312,19 +356,43 @@ comc_probe(struct console *sc)
env_setenv("efi_com_speed", EV_VOLATILE, value,
comc_speed_set, env_nounset);
- comconsole.c_flags = 0;
- if (comc_setup())
+ if (comc_setup()) {
sc->c_flags = C_PRESENTIN | C_PRESENTOUT;
+ } else {
+ sc->c_flags &= ~(C_PRESENTIN | C_PRESENTOUT);
+ free(comc_port);
+ comc_port = NULL;
+ }
}
+#if defined(__aarch64__) && __FreeBSD_version < 1500000
+static void
+comc_probe_compat(struct console *sc)
+{
+ comc_probe(&eficom);
+ if (eficom.c_flags & (C_PRESENTIN | C_PRESENTOUT)) {
+ printf("comconsole: comconsole device name is deprecated, switch to eficom\n");
+ }
+ /*
+ * Note: We leave the present bits unset in sc to avoid ghosting.
+ */
+}
+#endif
+
+/*
+ * Called when the console is selected in cons_change. If we didn't detect the
+ * device, comc_port will be NULL, and comc_setup will fail. It may be called
+ * even when the device isn't present as a 'fallback' console or when listed
+ * specifically in console env, so we have to reset the c_flags in those case to
+ * say it's not present.
+ */
static int
comc_init(int arg __unused)
{
-
if (comc_setup())
return (CMD_OK);
- comconsole.c_flags = 0;
+ eficom.c_flags &= ~(C_ACTIVEIN | C_ACTIVEOUT);
return (CMD_ERROR);
}
@@ -426,7 +494,7 @@ comc_port_set(struct env_var *ev, int flags, const void *value)
EFI_HANDLE handle;
EFI_STATUS status;
- if (value == NULL)
+ if (value == NULL || comc_port == NULL)
return (CMD_ERROR);
if (comc_parse_intval(value, &port) != CMD_OK)
@@ -461,16 +529,15 @@ comc_speed_set(struct env_var *ev, int flags, const void *value)
{
unsigned speed;
- if (value == NULL)
+ if (value == NULL || comc_port == NULL)
return (CMD_ERROR);
if (comc_parse_intval(value, &speed) != CMD_OK)
return (CMD_ERROR);
- comc_port->baudrate = speed;
- (void) comc_setup();
-
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+ comc_port->newbaudrate = speed;
+ if (comc_setup())
+ env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
return (CMD_OK);
}
@@ -483,33 +550,52 @@ static bool
comc_setup(void)
{
EFI_STATUS status;
- UINT32 control;
+ char *ev;
- /* port is not usable */
- if (comc_port->sio == NULL)
+ /*
+ * If the device isn't active, or there's no port present.
+ */
+ if ((eficom.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0 || comc_port == NULL)
return (false);
- status = comc_port->sio->Reset(comc_port->sio);
- if (EFI_ERROR(status))
- return (false);
+ if (comc_port->sio->Reset != NULL) {
+ status = comc_port->sio->Reset(comc_port->sio);
+ if (EFI_ERROR(status))
+ return (false);
+ }
- status = comc_port->sio->SetAttributes(comc_port->sio,
- comc_port->baudrate, 0, 0, comc_port->parity,
- comc_port->databits, comc_port->stopbits);
- if (EFI_ERROR(status))
- return (false);
+ /*
+ * Avoid setting the baud rate on Hyper-V. Also, only set the baud rate
+ * if the baud rate has changed from the default. And pass in '0' or
+ * DefaultFoo when we're not changing those values. Some EFI
+ * implementations get cranky when you set things to the values reported
+ * back even when they are unchanged.
+ */
+ if (comc_port->sio->SetAttributes != NULL &&
+ comc_port->newbaudrate != comc_port->baudrate) {
+ ev = getenv("smbios.bios.version");
+ if (ev != NULL && strncmp(ev, "Hyper-V", 7) != 0) {
+ status = comc_port->sio->SetAttributes(comc_port->sio,
+ comc_port->newbaudrate, 0, 0, DefaultParity, 0,
+ DefaultStopBits);
+ if (EFI_ERROR(status))
+ return (false);
+ comc_port->baudrate = comc_port->newbaudrate;
+ }
+ }
- status = comc_port->sio->GetControl(comc_port->sio, &control);
- if (EFI_ERROR(status))
- return (false);
- if (comc_port->rtsdtr_off) {
- control &= ~(EFI_SERIAL_REQUEST_TO_SEND |
- EFI_SERIAL_DATA_TERMINAL_READY);
- } else {
+#ifdef EFI_FORCE_RTS
+ if (comc_port->sio->GetControl != NULL && comc_port->sio->SetControl != NULL) {
+ UINT32 control;
+
+ status = comc_port->sio->GetControl(comc_port->sio, &control);
+ if (EFI_ERROR(status))
+ return (false);
control |= EFI_SERIAL_REQUEST_TO_SEND;
+ (void) comc_port->sio->SetControl(comc_port->sio, control);
}
- (void) comc_port->sio->SetControl(comc_port->sio, control);
+#endif
/* Mark this port usable. */
- comconsole.c_flags |= (C_PRESENTIN | C_PRESENTOUT);
+ eficom.c_flags |= (C_PRESENTIN | C_PRESENTOUT);
return (true);
}
diff --git a/stand/efi/libefi/efienv.c b/stand/efi/libefi/efienv.c
index 04df6bc00fc3..83da2acc816b 100644
--- a/stand/efi/libefi/efienv.c
+++ b/stand/efi/libefi/efienv.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <efi.h>
#include <efichar.h>
diff --git a/stand/efi/libefi/efihttp.c b/stand/efi/libefi/efihttp.c
index 05d338fbaf04..bcc0f7e4d79e 100644
--- a/stand/efi/libefi/efihttp.c
+++ b/stand/efi/libefi/efihttp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Intel Corporation
*
@@ -23,13 +23,8 @@
* 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.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <netinet/in.h>
@@ -94,7 +89,7 @@ struct devsw efihttp_dev = {
.dv_close = efihttp_dev_close,
.dv_ioctl = noioctl,
.dv_print = NULL,
- .dv_cleanup = NULL,
+ .dv_cleanup = nullsys,
};
struct fs_ops efihttp_fsops = {
diff --git a/stand/efi/libefi/efinet.c b/stand/efi/libefi/efinet.c
index c52b11d32ec8..97890c9d9b43 100644
--- a/stand/efi/libefi/efinet.c
+++ b/stand/efi/libefi/efinet.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <net/ethernet.h>
#include <netinet/in.h>
@@ -351,11 +348,11 @@ struct devsw efinet_dev = {
.dv_close = NULL, /* Will be set in efinet_dev_init */
.dv_ioctl = noioctl,
.dv_print = efinet_dev_print,
- .dv_cleanup = NULL
+ .dv_cleanup = nullsys,
};
static int
-efinet_dev_init()
+efinet_dev_init(void)
{
struct netif_dif *dif;
struct netif_stats *stats;
diff --git a/stand/efi/libefi/efipart.c b/stand/efi/libefi/efipart.c
index 7807c17077a6..3df6034571f5 100644
--- a/stand/efi/libefi/efipart.c
+++ b/stand/efi/libefi/efipart.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/disk.h>
#include <sys/param.h>
#include <sys/time.h>
@@ -78,7 +75,7 @@ struct devsw efipart_fddev = {
.dv_close = efipart_close,
.dv_ioctl = efipart_ioctl,
.dv_print = efipart_printfd,
- .dv_cleanup = NULL
+ .dv_cleanup = nullsys,
};
struct devsw efipart_cddev = {
@@ -90,7 +87,7 @@ struct devsw efipart_cddev = {
.dv_close = efipart_close,
.dv_ioctl = efipart_ioctl,
.dv_print = efipart_printcd,
- .dv_cleanup = NULL
+ .dv_cleanup = nullsys,
};
struct devsw efipart_hddev = {
@@ -102,7 +99,9 @@ struct devsw efipart_hddev = {
.dv_close = efipart_close,
.dv_ioctl = efipart_ioctl,
.dv_print = efipart_printhd,
- .dv_cleanup = NULL
+ .dv_cleanup = nullsys,
+ .dv_fmtdev = disk_fmtdev,
+ .dv_parsedev = disk_parsedev,
};
static pdinfo_list_t fdinfo = STAILQ_HEAD_INITIALIZER(fdinfo);
diff --git a/stand/efi/libefi/efizfs.c b/stand/efi/libefi/efizfs.c
index 7f3986d47140..1c80f1ae26b9 100644
--- a/stand/efi/libefi/efizfs.c
+++ b/stand/efi/libefi/efizfs.c
@@ -25,9 +25,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <stand.h>
@@ -115,7 +112,7 @@ efi_zfs_probe(void)
snprintf(devname, sizeof(devname), "%s%dp%d:",
efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit);
guid = 0;
- if (zfs_probe_dev(devname, &guid) == 0) {
+ if (zfs_probe_dev(devname, &guid, false) == 0) {
insert_zfs(pd->pd_handle, guid);
if (pd->pd_handle == boot_img->DeviceHandle)
pool_guid = guid;
diff --git a/stand/efi/libefi/env.c b/stand/efi/libefi/env.c
index 77e232343040..328476a9f68b 100644
--- a/stand/efi/libefi/env.c
+++ b/stand/efi/libefi/env.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <string.h>
#include <efi.h>
@@ -537,7 +534,7 @@ efi_print_global(const CHAR16 *varnamearg, uint8_t *data, UINTN datasz)
goto done;
}
if (strncmp("Boot", var, 4) == 0 ||
- strncmp("Driver", var, 5) == 0 ||
+ strncmp("Driver", var, 6) == 0 ||
strncmp("SysPrep", var, 7) == 0 ||
strncmp("OsRecovery", var, 10) == 0) {
UINT16 filepathlistlen;
diff --git a/stand/efi/libefi/errno.c b/stand/efi/libefi/errno.c
index 0f354c3f3c8f..92050af7f4e1 100644
--- a/stand/efi/libefi/errno.c
+++ b/stand/efi/libefi/errno.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
diff --git a/stand/efi/libefi/handles.c b/stand/efi/libefi/handles.c
index a55239dbec8c..d3ec428b8d4a 100644
--- a/stand/efi/libefi/handles.c
+++ b/stand/efi/libefi/handles.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
diff --git a/stand/efi/libefi/libefi.c b/stand/efi/libefi/libefi.c
index e7b1406839fe..f615bd214bfc 100644
--- a/stand/efi/libefi/libefi.c
+++ b/stand/efi/libefi/libefi.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <eficonsctl.h>
#include <efilib.h>
diff --git a/stand/efi/libefi/time.c b/stand/efi/libefi/time.c
index fe0d2ef2702b..99d86e30ee96 100644
--- a/stand/efi/libefi/time.c
+++ b/stand/efi/libefi/time.c
@@ -38,9 +38,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
diff --git a/stand/efi/libefi/time_arm64.c b/stand/efi/libefi/time_arm64.c
index baa0f8bfa1ed..d3c7a4e236d0 100644
--- a/stand/efi/libefi/time_arm64.c
+++ b/stand/efi/libefi/time_arm64.c
@@ -28,9 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
diff --git a/stand/efi/libefi/time_event.c b/stand/efi/libefi/time_event.c
index f171bf997078..c4334412a4fe 100644
--- a/stand/efi/libefi/time_event.c
+++ b/stand/efi/libefi/time_event.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
diff --git a/stand/efi/libefi/wchar.c b/stand/efi/libefi/wchar.c
index 0a2b96b64f45..953f29418c21 100644
--- a/stand/efi/libefi/wchar.c
+++ b/stand/efi/libefi/wchar.c
@@ -23,15 +23,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <efi.h>
#include <efilib.h>
/*
* CHAR16 related functions moved from loader.
- * Perhaps we should move those to libstand afterall, but they are
+ * Perhaps we should move those to libsa afterall, but they are
* needed only by UEFI.
*/
diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile
index dd25c940e0e9..b3395bdfdf53 100644
--- a/stand/efi/loader/Makefile
+++ b/stand/efi/loader/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
LOADER_NET_SUPPORT?= yes
LOADER_MSDOS_SUPPORT?= yes
@@ -39,6 +38,8 @@ CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken
CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite
CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken
CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite
+CFLAGS.main.c += -I$(SRCTOP)/sys/teken
+CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite
CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
@@ -66,6 +67,7 @@ CFLAGS+= -DEFI
.if defined(HAVE_FDT) && ${MK_FDT} != "no"
.include "${BOOTSRC}/fdt.mk"
LIBEFI_FDT= ${BOOTOBJ}/efi/fdt/libefi_fdt.a
+HELP_FILES+= ${FDTSRC}/help.fdt
.endif
# Include bcache code.
@@ -81,6 +83,7 @@ CFLAGS+= -DEFI_SECUREBOOT
NEWVERSWHAT= "EFI loader" ${MACHINE}
VERSION_FILE= ${.CURDIR}/../loader/version
+HELP_FILENAME= loader.help.efi
# Always add MI sources
.include "${BOOTSRC}/loader.mk"
@@ -97,13 +100,16 @@ FILESMODE_${LOADER}.efi= ${BINMODE}
LINKS+= ${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
.endif
-LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
+LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/${MACHINE}.ldscript
LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
+.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400
+LDFLAGS+= -Wl,--no-dynamic-linker
+.endif
-CLEANFILES+= loader.efi
+CLEANFILES+= ${LOADER}.efi
${LOADER}.efi: ${PROG}
- if ${NM} ${.ALLSRC} | grep ' U '; then \
+ @if ${NM} ${.ALLSRC} | grep ' U '; then \
echo "Undefined symbols in ${.ALLSRC}"; \
exit 1; \
fi
@@ -111,12 +117,12 @@ ${LOADER}.efi: ${PROG}
${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
-j .dynamic -j .dynsym -j .rel.dyn \
-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
- -j set_Xficl_compile_set \
+ -j set_X${LOADER_INTERP}_compile_set \
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a
-DPADD= ${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
-LDADD= ${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA}
+DPADD= ${LDR_INTERP} ${LIBEFI} ${LIBSAFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
+LDADD= ${LDR_INTERP} ${LIBEFI} ${LIBSAFDT} ${LIBEFI_FDT} ${LIBSA}
.include <bsd.prog.mk>
diff --git a/stand/efi/loader/Makefile.depend b/stand/efi/loader/Makefile.depend
index 06e5b772c214..ae9e6b6efaa4 100644
--- a/stand/efi/loader/Makefile.depend
+++ b/stand/efi/loader/Makefile.depend
@@ -1,10 +1,10 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
stand/efi/libefi \
- stand/ficl \
stand/libsa \
+ usr.bin/awk.host \
.include <dirdeps.mk>
diff --git a/stand/efi/loader/Makefile.depend.arm b/stand/efi/loader/Makefile.depend.arm
new file mode 100644
index 000000000000..4ba1445d8a5f
--- /dev/null
+++ b/stand/efi/loader/Makefile.depend.arm
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ bin/sh.host \
+ stand/efi/fdt \
+ stand/efi/libefi \
+ stand/fdt \
+ stand/libsa \
+ usr.bin/awk.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/stand/efi/loader/Makefile.depend.arm64 b/stand/efi/loader/Makefile.depend.arm64
new file mode 100644
index 000000000000..4ba1445d8a5f
--- /dev/null
+++ b/stand/efi/loader/Makefile.depend.arm64
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ bin/sh.host \
+ stand/efi/fdt \
+ stand/efi/libefi \
+ stand/fdt \
+ stand/libsa \
+ usr.bin/awk.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/stand/efi/loader/Makefile.depend.options b/stand/efi/loader/Makefile.depend.options
new file mode 100644
index 000000000000..20292bab9bcd
--- /dev/null
+++ b/stand/efi/loader/Makefile.depend.options
@@ -0,0 +1,7 @@
+# options that impact our dependencies
+DIRDEPS_OPTIONS = LOADER_LUA
+
+DIRDEPS.LOADER_LUA.yes += \
+ stand/liblua \
+
+.include <dirdeps-options.mk>
diff --git a/stand/efi/loader/Makefile.depend.riscv b/stand/efi/loader/Makefile.depend.riscv
new file mode 100644
index 000000000000..4ba1445d8a5f
--- /dev/null
+++ b/stand/efi/loader/Makefile.depend.riscv
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ bin/sh.host \
+ stand/efi/fdt \
+ stand/efi/libefi \
+ stand/fdt \
+ stand/libsa \
+ usr.bin/awk.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/stand/efi/loader/arch/amd64/Makefile.inc b/stand/efi/loader/arch/amd64/Makefile.inc
index 0d9e2648cb59..00658b3b8636 100644
--- a/stand/efi/loader/arch/amd64/Makefile.inc
+++ b/stand/efi/loader/arch/amd64/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
SRCS+= amd64_tramp.S \
start.S \
diff --git a/stand/efi/loader/arch/amd64/ldscript.amd64 b/stand/efi/loader/arch/amd64/amd64.ldscript
index 874df9b08f9e..0e620654ea81 100644
--- a/stand/efi/loader/arch/amd64/ldscript.amd64
+++ b/stand/efi/loader/arch/amd64/amd64.ldscript
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
@@ -35,17 +34,6 @@ SECTIONS
*(COMMON)
}
. = ALIGN(4096);
- set_Xcommand_set : {
- __start_set_Xcommand_set = .;
- *(set_Xcommand_set)
- __stop_set_Xcommand_set = .;
- }
- set_Xficl_compile_set : {
- __start_set_Xficl_compile_set = .;
- *(set_Xficl_compile_set)
- __stop_set_Xficl_compile_set = .;
- }
- . = ALIGN(4096);
__gp = .;
.sdata : {
*(.got.plt .got)
diff --git a/stand/efi/loader/arch/amd64/amd64_tramp.S b/stand/efi/loader/arch/amd64/amd64_tramp.S
index 877705407f92..515ffc5d784d 100644
--- a/stand/efi/loader/arch/amd64/amd64_tramp.S
+++ b/stand/efi/loader/arch/amd64/amd64_tramp.S
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Benno Rice under sponsorship from
* the FreeBSD Foundation.
@@ -24,8 +23,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <machine/asmacros.h>
diff --git a/stand/efi/loader/arch/amd64/elf64_freebsd.c b/stand/efi/loader/arch/amd64/elf64_freebsd.c
index 4bdf675cd5a3..91dd979a677e 100644
--- a/stand/efi/loader/arch/amd64/elf64_freebsd.c
+++ b/stand/efi/loader/arch/amd64/elf64_freebsd.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define __ELF_WORD_SIZE 64
#include <sys/param.h>
#include <sys/exec.h>
@@ -43,17 +40,8 @@ __FBSDID("$FreeBSD$");
#include "bootstrap.h"
-#include "platform/acfreebsd.h"
-#include "acconfig.h"
-#define ACPI_SYSTEM_XFACE
-#include "actypes.h"
-#include "actbl.h"
-
#include "loader_efi.h"
-static EFI_GUID acpi_guid = ACPI_TABLE_GUID;
-static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID;
-
extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp,
bool exit_bs);
@@ -106,9 +94,6 @@ elf64_exec(struct preloaded_file *fp)
Elf_Ehdr *ehdr;
vm_offset_t modulep, kernend, trampcode, trampstack;
int err, i;
- ACPI_TABLE_RSDP *rsdp;
- char buf[24];
- int revision;
bool copy_auto;
copy_auto = copy_staging == COPY_STAGING_AUTO;
@@ -116,50 +101,6 @@ elf64_exec(struct preloaded_file *fp)
copy_staging = fp->f_kernphys_relocatable ?
COPY_STAGING_DISABLE : COPY_STAGING_ENABLE;
- /*
- * Report the RSDP to the kernel. While this can be found with
- * a BIOS boot, the RSDP may be elsewhere when booted from UEFI.
- * The old code used the 'hints' method to communite this to
- * the kernel. However, while convenient, the 'hints' method
- * is fragile and does not work when static hints are compiled
- * into the kernel. Instead, move to setting different tunables
- * that start with acpi. The old 'hints' can be removed before
- * we branch for FreeBSD 12.
- */
-
- rsdp = efi_get_table(&acpi20_guid);
- if (rsdp == NULL) {
- rsdp = efi_get_table(&acpi_guid);
- }
- if (rsdp != NULL) {
- sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
- setenv("hint.acpi.0.rsdp", buf, 1);
- setenv("acpi.rsdp", buf, 1);
- revision = rsdp->Revision;
- if (revision == 0)
- revision = 1;
- sprintf(buf, "%d", revision);
- setenv("hint.acpi.0.revision", buf, 1);
- setenv("acpi.revision", buf, 1);
- strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
- buf[sizeof(rsdp->OemId)] = '\0';
- setenv("hint.acpi.0.oem", buf, 1);
- setenv("acpi.oem", buf, 1);
- sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
- setenv("hint.acpi.0.rsdt", buf, 1);
- setenv("acpi.rsdt", buf, 1);
- if (revision >= 2) {
- /* XXX extended checksum? */
- sprintf(buf, "0x%016llx",
- (unsigned long long)rsdp->XsdtPhysicalAddress);
- setenv("hint.acpi.0.xsdt", buf, 1);
- setenv("acpi.xsdt", buf, 1);
- sprintf(buf, "%d", rsdp->Length);
- setenv("hint.acpi.0.xsdt_length", buf, 1);
- setenv("acpi.xsdt_length", buf, 1);
- }
- }
-
if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
return (EFTYPE);
ehdr = (Elf_Ehdr *)&(md->md_data);
@@ -181,7 +122,7 @@ elf64_exec(struct preloaded_file *fp)
trampoline = (void *)trampcode;
if (copy_staging == COPY_STAGING_ENABLE) {
- PT4 = (pml4_entry_t *)0x0000000040000000;
+ PT4 = (pml4_entry_t *)0x0000000040000000; /* 1G */
err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3,
(EFI_PHYSICAL_ADDRESS *)&PT4);
if (EFI_ERROR(err)) {
diff --git a/stand/efi/loader/arch/amd64/exc.S b/stand/efi/loader/arch/amd64/exc.S
index 0035d4a37e20..940bfa160161 100644
--- a/stand/efi/loader/arch/amd64/exc.S
+++ b/stand/efi/loader/arch/amd64/exc.S
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2016 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Konstantin Belousov under sponsorship
* from the FreeBSD Foundation.
@@ -25,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
.macro EH N, err=1
diff --git a/stand/efi/loader/arch/amd64/multiboot2.c b/stand/efi/loader/arch/amd64/multiboot2.c
index 4d7b2713685d..130caa82aa49 100644
--- a/stand/efi/loader/arch/amd64/multiboot2.c
+++ b/stand/efi/loader/arch/amd64/multiboot2.c
@@ -34,8 +34,6 @@
* https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html
*/
-#include <sys/cdefs.h>
-
#include <sys/param.h>
#include <sys/exec.h>
#include <sys/linker.h>
@@ -334,7 +332,7 @@ exec(struct preloaded_file *fp)
struct mb2hdr *hdr;
- CTASSERT(sizeof(header) <= PAGE_SIZE);
+ _Static_assert(sizeof(header) <= PAGE_SIZE, "header too big");
if ((md = file_findmetadata(fp,
MODINFOMD_NOCOPY | MODINFOMD_MB2HDR)) == NULL) {
diff --git a/stand/efi/loader/arch/amd64/start.S b/stand/efi/loader/arch/amd64/start.S
index 774ef4fa7901..34bf166c6501 100644
--- a/stand/efi/loader/arch/amd64/start.S
+++ b/stand/efi/loader/arch/amd64/start.S
@@ -33,7 +33,6 @@
/*
* crt0-efi-x86_64.S - x86_64 EFI startup code.
- * $FreeBSD$
*/
.text
diff --git a/stand/efi/loader/arch/amd64/trap.c b/stand/efi/loader/arch/amd64/trap.c
index e8cf188cf22f..95a42a18f719 100644
--- a/stand/efi/loader/arch/amd64/trap.c
+++ b/stand/efi/loader/arch/amd64/trap.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2016 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Konstantin Belousov under sponsorship
* from the FreeBSD Foundation.
@@ -27,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <string.h>
#include <sys/param.h>
@@ -79,11 +75,21 @@ static uint32_t loader_tss; /* Loader TSS segment */
static struct region_descriptor fw_gdt; /* Descriptor of pristine GDT */
static EFI_PHYSICAL_ADDRESS loader_gdt_pa; /* Address of loader shadow GDT */
+struct frame {
+ struct frame *fr_savfp;
+ uintptr_t fr_savpc;
+};
+
void report_exc(struct trapframe *tf);
void
report_exc(struct trapframe *tf)
{
+ struct frame *fp;
+ uintptr_t pc, base;
+ char buf[80];
+ int ret;
+ base = (uintptr_t)boot_img->ImageBase;
/*
* printf() depends on loader runtime and UEFI firmware health
* to produce the console output, in case of exception, the
@@ -109,6 +115,33 @@ report_exc(struct trapframe *tf)
tf->tf_rdi, tf->tf_rsi, tf->tf_rdx, tf->tf_rcx, tf->tf_r8,
tf->tf_r9, tf->tf_rax, tf->tf_rbx, tf->tf_rbp, tf->tf_r10,
tf->tf_r11, tf->tf_r12, tf->tf_r13, tf->tf_r14, tf->tf_r15);
+
+ fp = (struct frame *)tf->tf_rbp;
+ pc = tf->tf_rip;
+
+ printf("Stack trace:\n");
+ pager_open();
+ while (fp != NULL || pc != 0) {
+ char *source = "PC";
+
+ if (pc >= base && pc < base + boot_img->ImageSize) {
+ pc -= base;
+ source = "loader PC";
+ }
+ (void) snprintf(buf, sizeof (buf), "FP %016lx: %s 0x%016lx\n",
+ (uintptr_t)fp, source, pc);
+ if (pager_output(buf))
+ break;
+
+ if (fp != NULL)
+ fp = fp->fr_savfp;
+
+ if (fp != NULL)
+ pc = fp->fr_savpc;
+ else
+ pc = 0;
+ }
+ pager_close();
printf("Machine stopped.\n");
}
diff --git a/stand/efi/loader/arch/arm/Makefile.inc b/stand/efi/loader/arch/arm/Makefile.inc
index 284e517bfbb8..5761c8062117 100644
--- a/stand/efi/loader/arch/arm/Makefile.inc
+++ b/stand/efi/loader/arch/arm/Makefile.inc
@@ -1,7 +1,5 @@
-# $FreeBSD$
SRCS+= exec.c \
- efiserialio.c \
start.S
HAVE_FDT=yes
diff --git a/stand/efi/loader/arch/arm/ldscript.arm b/stand/efi/loader/arch/arm/arm.ldscript
index 68775a88a9cd..7b5c2af399c9 100644
--- a/stand/efi/loader/arch/arm/ldscript.arm
+++ b/stand/efi/loader/arch/arm/arm.ldscript
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
@@ -43,16 +42,6 @@ SECTIONS
*(.got.plt .got)
*(.sdata*.sdata.* .gnu.linkonce.s.*)
}
- set_Xcommand_set : {
- __start_set_Xcommand_set = .;
- *(set_Xcommand_set)
- __stop_set_Xcommand_set = .;
- }
- set_Xficl_compile_set : {
- __start_set_Xficl_compile_set = .;
- *(set_Xficl_compile_set)
- __stop_set_Xficl_compile_set = .;
- }
__gp = .;
.plt : { *(.plt) }
.reloc : { *(.reloc) }
diff --git a/stand/efi/loader/arch/arm/exec.c b/stand/efi/loader/arch/arm/exec.c
index a110f3d07cbc..85a8c26ade30 100644
--- a/stand/efi/loader/arch/arm/exec.c
+++ b/stand/efi/loader/arch/arm/exec.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker.h>
@@ -43,7 +40,6 @@ __FBSDID("$FreeBSD$");
#include "bootstrap.h"
#include "loader_efi.h"
-extern vm_offset_t md_load(char *, vm_offset_t *);
extern int bi_load(char *, vm_offset_t *, vm_offset_t *, bool);
static int
diff --git a/stand/efi/loader/arch/arm/start.S b/stand/efi/loader/arch/arm/start.S
index 5b6182d67d0a..5e4301ec7141 100644
--- a/stand/efi/loader/arch/arm/start.S
+++ b/stand/efi/loader/arch/arm/start.S
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <machine/asm.h>
@@ -140,6 +138,7 @@ section_table:
_end_header:
.text
+ .globl _start
_start:
/* Save the boot params to the stack */
push {r0, r1}
diff --git a/stand/efi/loader/arch/arm64/Makefile.inc b/stand/efi/loader/arch/arm64/Makefile.inc
index 9978d9c4ea9c..d19a23af0e9e 100644
--- a/stand/efi/loader/arch/arm64/Makefile.inc
+++ b/stand/efi/loader/arch/arm64/Makefile.inc
@@ -1,9 +1,7 @@
-# $FreeBSD$
HAVE_FDT=yes
SRCS+= exec.c \
- efiserialio.c \
start.S
.PATH: ${BOOTSRC}/arm64/libarm64
diff --git a/stand/efi/loader/arch/arm64/ldscript.arm64 b/stand/efi/loader/arch/arm64/arm64.ldscript
index d0ed320a319c..18aead05cb49 100644
--- a/stand/efi/loader/arch/arm64/ldscript.arm64
+++ b/stand/efi/loader/arch/arm64/arm64.ldscript
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*
OUTPUT_FORMAT("elf64-aarch64-freebsd", "elf64-aarch64-freebsd", "elf64-aarch64-freebsd")
*/
@@ -16,7 +15,9 @@ SECTIONS
*(.gnu.warning)
*(.plt)
} =0xD4200000
- . = ALIGN(16);
+ . = ALIGN(4096);
+ _etext = .;
+ __data_start = .;
.data : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.rodata1)
@@ -38,17 +39,6 @@ SECTIONS
__bss_end = .;
}
. = ALIGN(16);
- set_Xcommand_set : {
- __start_set_Xcommand_set = .;
- *(set_Xcommand_set)
- __stop_set_Xcommand_set = .;
- }
- set_Xficl_compile_set : {
- __start_set_Xficl_compile_set = .;
- *(set_Xficl_compile_set)
- __stop_set_Xficl_compile_set = .;
- }
- . = ALIGN(16);
__gp = .;
.sdata : {
*(.got.plt .got)
@@ -78,6 +68,7 @@ SECTIONS
. = ALIGN(16);
.dynsym : { *(.dynsym) }
_edata = .;
+ __data_size = . - __data_start;
/* Unused sections */
.interp : { *(.interp) }
diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c
index 6cf4a4fd8e4d..877cff658d1e 100644
--- a/stand/efi/loader/arch/arm64/exec.c
+++ b/stand/efi/loader/arch/arm64/exec.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <string.h>
@@ -42,16 +39,6 @@ __FBSDID("$FreeBSD$");
#include "loader_efi.h"
#include "cache.h"
-#include "platform/acfreebsd.h"
-#include "acconfig.h"
-#define ACPI_SYSTEM_XFACE
-#define ACPI_USE_SYSTEM_INTTYPES
-#include "actypes.h"
-#include "actbl.h"
-
-static EFI_GUID acpi_guid = ACPI_TABLE_GUID;
-static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID;
-
static int elf64_exec(struct preloaded_file *amp);
static int elf64_obj_exec(struct preloaded_file *amp);
@@ -75,39 +62,10 @@ elf64_exec(struct preloaded_file *fp)
vm_offset_t clean_addr;
size_t clean_size;
struct file_metadata *md;
- ACPI_TABLE_RSDP *rsdp;
Elf_Ehdr *ehdr;
- char buf[24];
- int err, revision;
+ int err;
void (*entry)(vm_offset_t);
- rsdp = efi_get_table(&acpi20_guid);
- if (rsdp == NULL) {
- rsdp = efi_get_table(&acpi_guid);
- }
- if (rsdp != NULL) {
- sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
- setenv("hint.acpi.0.rsdp", buf, 1);
- revision = rsdp->Revision;
- if (revision == 0)
- revision = 1;
- sprintf(buf, "%d", revision);
- setenv("hint.acpi.0.revision", buf, 1);
- strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
- buf[sizeof(rsdp->OemId)] = '\0';
- setenv("hint.acpi.0.oem", buf, 1);
- sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
- setenv("hint.acpi.0.rsdt", buf, 1);
- if (revision >= 2) {
- /* XXX extended checksum? */
- sprintf(buf, "0x%016llx",
- (unsigned long long)rsdp->XsdtPhysicalAddress);
- setenv("hint.acpi.0.xsdt", buf, 1);
- sprintf(buf, "%d", rsdp->Length);
- setenv("hint.acpi.0.xsdt_length", buf, 1);
- }
- }
-
if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
return(EFTYPE);
diff --git a/stand/efi/loader/arch/arm64/start.S b/stand/efi/loader/arch/arm64/start.S
index 675d4e153f36..6e30287453c5 100644
--- a/stand/efi/loader/arch/arm64/start.S
+++ b/stand/efi/loader/arch/arm64/start.S
@@ -22,8 +22,6 @@
* 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.
- *
- * $FreeBSD$
*/
/*
@@ -34,11 +32,14 @@
#define IMAGE_FILE_MACHINE_ARM64 0xaa64
+#define IMAGE_FILE_EXECUTABLE 0x0002
+
#define IMAGE_SCN_CNT_CODE 0x00000020
#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
#define IMAGE_SCN_MEM_EXECUTE 0x20000000
#define IMAGE_SCN_MEM_READ 0x40000000
+#define IMAGE_SCN_MEM_WRITE 0x80000000
.section .peheader,"a"
efi_start:
@@ -60,22 +61,22 @@ coff_head:
.long 0 /* No symbol table */
.long 0 /* No symbols */
.short section_table - optional_header /* Optional header size */
- .short 0 /* Characteristics TODO: Fill in */
+ .short IMAGE_FILE_EXECUTABLE /* Characteristics */
optional_header:
.short 0x020b /* PE32+ (64-bit addressing) */
.byte 0 /* Major linker version */
.byte 0 /* Minor linker version */
- .long _edata - _end_header /* Code size */
- .long 0 /* No initialized data */
+ .long _etext - _end_header /* Code size */
+ .long __data_size /* Initialized data size */
.long 0 /* No uninitialized data */
.long _start - efi_start /* Entry point */
.long _end_header - efi_start /* Start of code */
optional_windows_header:
.quad 0 /* Image base */
- .long 32 /* Section Alignment */
- .long 8 /* File alignment */
+ .long 4096 /* Section Alignment */
+ .long 512 /* File alignment */
.short 0 /* Major OS version */
.short 0 /* Minor OS version */
.short 0 /* Major image version */
@@ -104,36 +105,37 @@ optional_windows_header:
.quad 0
section_table:
- /* We need a .reloc section for EFI */
- .ascii ".reloc"
+ .ascii ".text"
+ .byte 0
.byte 0
.byte 0 /* Pad to 8 bytes */
- .long 0 /* Virtual size */
- .long 0 /* Virtual address */
- .long 0 /* Size of raw data */
- .long 0 /* Pointer to raw data */
+ .long _etext - _end_header /* Virtual size */
+ .long _end_header - efi_start /* Virtual address */
+ .long _etext - _end_header /* Size of raw data */
+ .long _end_header - efi_start /* Pointer to raw data */
.long 0 /* Pointer to relocations */
.long 0 /* Pointer to line numbers */
.short 0 /* Number of relocations */
.short 0 /* Number of line numbers */
- .long (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | \
- IMAGE_SCN_MEM_DISCARDABLE) /* Characteristics */
+ .long (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | \
+ IMAGE_SCN_MEM_READ) /* Characteristics */
- /* The contents of the loader */
- .ascii ".text"
+ .ascii ".data"
.byte 0
.byte 0
.byte 0 /* Pad to 8 bytes */
- .long _edata - _end_header /* Virtual size */
- .long _end_header - efi_start /* Virtual address */
- .long _edata - _end_header /* Size of raw data */
- .long _end_header - efi_start /* Pointer to raw data */
+ .long __data_size /* Virtual size */
+ .long __data_start - efi_start /* Virtual address */
+ .long __data_size /* Size of raw data */
+ .long __data_start - efi_start /* Pointer to raw data */
.long 0 /* Pointer to relocations */
.long 0 /* Pointer to line numbers */
.short 0 /* Number of relocations */
.short 0 /* Number of line numbers */
- .long (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | \
- IMAGE_SCN_MEM_READ) /* Characteristics */
+ .long (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | \
+ IMAGE_SCN_MEM_WRITE) /* Characteristics */
+
+ .align 12
_end_header:
.text
diff --git a/stand/efi/loader/arch/i386/Makefile.inc b/stand/efi/loader/arch/i386/Makefile.inc
deleted file mode 100644
index fcdb6324b2f0..000000000000
--- a/stand/efi/loader/arch/i386/Makefile.inc
+++ /dev/null
@@ -1,13 +0,0 @@
-# $FreeBSD$
-
-SRCS+= start.S \
- elf32_freebsd.c \
- exec.c
-
-.PATH: ${BOOTSRC}/i386/libi386
-SRCS+= nullconsole.c \
- comconsole.c \
- spinconsole.c
-
-CFLAGS+= -fPIC
-LDFLAGS+= -Wl,-znocombreloc
diff --git a/stand/efi/loader/arch/i386/elf32_freebsd.c b/stand/efi/loader/arch/i386/elf32_freebsd.c
deleted file mode 100644
index 97d114f09610..000000000000
--- a/stand/efi/loader/arch/i386/elf32_freebsd.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/exec.h>
-#include <sys/linker.h>
-#include <string.h>
-#include <machine/bootinfo.h>
-#include <machine/elf.h>
-#include <stand.h>
-
-#include <efi.h>
-#include <efilib.h>
-
-#include "bootstrap.h"
-#include "../libi386/libi386.h"
-#include "../btx/lib/btxv86.h"
-
-extern void __exec(caddr_t addr, ...);
-extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp,
- bool exit_bs);
-
-static int elf32_exec(struct preloaded_file *amp);
-static int elf32_obj_exec(struct preloaded_file *amp);
-
-struct file_format i386_elf = { elf32_loadfile, elf32_exec };
-struct file_format i386_elf_obj = { elf32_obj_loadfile, elf32_obj_exec };
-
-struct file_format *file_formats[] = {
- &i386_elf,
- &i386_elf_obj,
- NULL
-};
-
-/*
- * There is an ELF kernel and one or more ELF modules loaded.
- * We wish to start executing the kernel image, so make such
- * preparations as are required, and do so.
- */
-static int
-elf32_exec(struct preloaded_file *fp)
-{
- struct file_metadata *md;
- Elf_Ehdr *ehdr;
- vm_offset_t entry, bootinfop, modulep, kernend;
- int boothowto, err, bootdev;
-
- if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
- return(EFTYPE);
- ehdr = (Elf_Ehdr *)&(md->md_data);
-
- efi_time_fini();
-
- entry = ehdr->e_entry & 0xffffff;
-
- printf("Start @ 0x%x ...\n", entry);
-
- err = bi_load(fp->f_args, &modulep, &kernend, true);
- if (err != 0) {
- efi_time_init();
- return(err);
- }
-
- /* At this point we've called ExitBootServices, so we can't call
- * printf or any other function that uses Boot Services */
-
- dev_cleanup();
- __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop, modulep, kernend);
-
- panic("exec returned");
-}
-
-static int
-elf32_obj_exec(struct preloaded_file *fp)
-{
- return (EFTYPE);
-}
diff --git a/stand/efi/loader/arch/i386/exec.c b/stand/efi/loader/arch/i386/exec.c
deleted file mode 100644
index 579f5593b24b..000000000000
--- a/stand/efi/loader/arch/i386/exec.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org>
- * 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 AUTHOR ``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 AUTHOR 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stand.h>
-#include <machine/elf.h>
-#include "../btx/lib/btxv86.h"
-
-#include "../../common/bootstrap.h"
-
-uint32_t __base;
-struct __v86 __v86;
-
-void
-__v86int()
-{
- printf("%s\n", __func__);
- exit(1);
-}
-
-void
-__exec(caddr_t addr, ...)
-{
-}
diff --git a/stand/efi/loader/arch/i386/i386_copy.c b/stand/efi/loader/arch/i386/i386_copy.c
deleted file mode 100644
index 2c4b0deb49cf..000000000000
--- a/stand/efi/loader/arch/i386/i386_copy.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * MD primitives supporting placement of module data
- *
- * XXX should check load address/size against memory top.
- */
-#include <stand.h>
-
-#include "libi386.h"
-#include "btxv86.h"
-
-ssize_t
-i386_copyin(const void *src, vm_offset_t dest, const size_t len)
-{
- bcopy(src, PTOV(dest), len);
- return(len);
-}
-
-ssize_t
-i386_copyout(const vm_offset_t src, void *dest, const size_t len)
-{
- bcopy(PTOV(src), dest, len);
- return(len);
-}
-
-ssize_t
-i386_readin(readin_handle_t fd, vm_offset_t dest, const size_t len)
-{
- return (VECTX_READ(fd, PTOV(dest), len));
-}
diff --git a/stand/efi/loader/arch/i386/ldscript.i386 b/stand/efi/loader/arch/i386/ldscript.i386
deleted file mode 100644
index e17212a1bddd..000000000000
--- a/stand/efi/loader/arch/i386/ldscript.i386
+++ /dev/null
@@ -1,77 +0,0 @@
-/* $FreeBSD$ */
-OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd")
-OUTPUT_ARCH(i386)
-ENTRY(_start)
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- . = 0;
- ImageBase = .;
- . = SIZEOF_HEADERS;
- . = ALIGN(4096);
- .text : {
- *(.text .stub .text.* .gnu.linkonce.t.*)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.plt)
- } =0xCCCCCCCC
- . = ALIGN(4096);
- .data : {
- *(.rodata .rodata.* .gnu.linkonce.r.*)
- *(.rodata1)
- *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
- *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
- *(.opd)
- *(.data .data.* .gnu.linkonce.d.*)
- *(.data1)
- *(.plabel)
- *(.dynbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
- }
- . = ALIGN(4096);
- set_Xcommand_set : {
- __start_set_Xcommand_set = .;
- *(set_Xcommand_set)
- __stop_set_Xcommand_set = .;
- }
- set_Xficl_compile_set : {
- __start_set_Xficl_compile_set = .;
- *(set_Xficl_compile_set)
- __stop_set_Xficl_compile_set = .;
- }
- . = ALIGN(4096);
- __gp = .;
- .sdata : {
- *(.got.plt .got)
- *(.sdata .sdata.* .gnu.linkonce.s.*)
- *(dynsbss)
- *(.sbss .sbss.* .gnu.linkonce.sb.*)
- *(.scommon)
- }
- . = ALIGN(4096);
- .dynamic : { *(.dynamic) }
- . = ALIGN(4096);
- .rel.dyn : {
- *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
- *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
- *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
- *(.rel.got)
- *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
- *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
- *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
- *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
- *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
- *(.rel.plt)
- *(.relset_*)
- *(.rel.dyn .rel.dyn.*)
- }
- . = ALIGN(4096);
- .reloc : { *(.reloc) }
- . = ALIGN(4096);
- .hash : { *(.hash) }
- . = ALIGN(4096);
- .dynsym : { *(.dynsym) }
- . = ALIGN(4096);
- .dynstr : { *(.dynstr) }
-}
diff --git a/stand/efi/loader/arch/i386/start.S b/stand/efi/loader/arch/i386/start.S
deleted file mode 100644
index b597f419d4a1..000000000000
--- a/stand/efi/loader/arch/i386/start.S
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * Copyright (c) 2008-2010 Rui Paulo <rpaulo@FreeBSD.org>
- * 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 AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
- .text
-
-#include <machine/asm.h>
-
-#define EFI_SUCCESS 0
-
-/*
- * EFI entry point.
- * _start(EFI_IMAGE image_handle, EFI_SYSTEM_TABLE *system_table);
- *
- * We calculate the base address along with _DYNAMIC, relocate us and finally
- * pass control to efi_main.
- */
-
-ENTRY(_start)
- pushl %ebp
- movl %esp, %ebp
-
- pushl 12(%ebp) /* image_handle */
- pushl 8(%ebp) /* system_table */
- call 0f
-0: popl %eax
- movl %eax, %ebx
- addl $ImageBase-0b, %eax
- addl $_DYNAMIC-0b, %ebx
- pushl %ebx /* dynamic */
- pushl %eax /* ImageBase */
- call self_reloc
- popl %ebx /* remove ImageBase from the stack */
- popl %ebx /* remove dynamic from the stack */
- call efi_main
-1: leave
- ret
-END(_start)
-
- .data
- .section .reloc, "a"
- .long 0
- .long 10
- .word 0
diff --git a/stand/efi/loader/arch/riscv/Makefile.inc b/stand/efi/loader/arch/riscv/Makefile.inc
index 333b789e935d..c25f63c0b3b7 100644
--- a/stand/efi/loader/arch/riscv/Makefile.inc
+++ b/stand/efi/loader/arch/riscv/Makefile.inc
@@ -1,7 +1,5 @@
-# $FreeBSD$
HAVE_FDT=yes
SRCS+= exec.c \
- efiserialio.c \
start.S
diff --git a/stand/efi/loader/arch/riscv/exec.c b/stand/efi/loader/arch/riscv/exec.c
index c7d90a4f31d0..3c40517ea968 100644
--- a/stand/efi/loader/arch/riscv/exec.c
+++ b/stand/efi/loader/arch/riscv/exec.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker.h>
diff --git a/stand/efi/loader/arch/riscv/ldscript.riscv b/stand/efi/loader/arch/riscv/riscv.ldscript
index aa736f0d9b2a..63b71c3bd702 100644
--- a/stand/efi/loader/arch/riscv/ldscript.riscv
+++ b/stand/efi/loader/arch/riscv/riscv.ldscript
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
OUTPUT_ARCH(riscv64)
ENTRY(_start)
@@ -36,17 +35,6 @@ SECTIONS
__bss_end = .;
}
. = ALIGN(16);
- set_Xcommand_set : {
- __start_set_Xcommand_set = .;
- *(set_Xcommand_set)
- __stop_set_Xcommand_set = .;
- }
- set_Xficl_compile_set : {
- __start_set_Xficl_compile_set = .;
- *(set_Xficl_compile_set)
- __stop_set_Xficl_compile_set = .;
- }
- . = ALIGN(16);
.sdata : {
/*
* u-boot expects the gp register to be untouched by the EFI payload, so we
diff --git a/stand/efi/loader/arch/riscv/start.S b/stand/efi/loader/arch/riscv/start.S
index e63ce68d86ba..fb7d65f17c99 100644
--- a/stand/efi/loader/arch/riscv/start.S
+++ b/stand/efi/loader/arch/riscv/start.S
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Mitchell Horne <mhorne@FreeBSD.org>
*
@@ -23,8 +23,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <machine/asm.h>
diff --git a/stand/efi/loader/autoload.c b/stand/efi/loader/autoload.c
index d409285834c3..ba7997487ffc 100644
--- a/stand/efi/loader/autoload.c
+++ b/stand/efi/loader/autoload.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#if defined(LOADER_FDT_SUPPORT)
#include <sys/param.h>
#include <fdt_platform.h>
diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c
index ca7a2c8ce4b8..b55c2184d9fe 100644
--- a/stand/efi/loader/bootinfo.c
+++ b/stand/efi/loader/bootinfo.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <string.h>
#include <sys/param.h>
@@ -40,17 +37,24 @@ __FBSDID("$FreeBSD$");
#include <machine/metadata.h>
#include <machine/psl.h>
+#ifdef EFI
#include <efi.h>
#include <efilib.h>
+#else
+#include "kboot.h"
+#endif
#include "bootstrap.h"
-#include "loader_efi.h"
+#include "modinfo.h"
#if defined(__amd64__)
#include <machine/specialreg.h>
#endif
+#ifdef EFI
+#include "loader_efi.h"
#include "gfx_fb.h"
+#endif
#if defined(LOADER_FDT_SUPPORT)
#include <fdt_platform.h>
@@ -66,11 +70,14 @@ int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp,
static int
bi_getboothowto(char *kargs)
{
+#ifdef EFI
const char *sw, *tmp;
char *opts;
- char *console;
- int howto, speed, port;
+ int speed, port;
char buf[50];
+#endif
+ char *console;
+ int howto;
howto = boot_parse_cmdline(kargs);
howto |= boot_env_to_howto();
@@ -81,6 +88,7 @@ bi_getboothowto(char *kargs)
howto |= RB_SERIAL;
if (strcmp(console, "nullconsole") == 0)
howto |= RB_MUTE;
+#ifdef EFI
#if defined(__i386__) || defined(__amd64__)
if (strcmp(console, "efi") == 0 &&
getenv("efi_8250_uid") != NULL &&
@@ -108,10 +116,17 @@ bi_getboothowto(char *kargs)
if (tmp != NULL)
speed = strtol(tmp, NULL, 0);
tmp = getenv("efi_com_port");
- if (tmp == NULL)
- tmp = getenv("comconsole_port");
if (tmp != NULL)
port = strtol(tmp, NULL, 0);
+ if (port <= 0) {
+ tmp = getenv("comconsole_port");
+ if (tmp != NULL)
+ port = strtol(tmp, NULL, 0);
+ else {
+ if (port == 0)
+ port = 0x3f8;
+ }
+ }
if (speed != -1 && port != -1) {
snprintf(buf, sizeof(buf), "io:%d,br:%d", port,
speed);
@@ -120,139 +135,13 @@ bi_getboothowto(char *kargs)
}
}
#endif
+#endif
}
return (howto);
}
-/*
- * Copy the environment into the load area starting at (addr).
- * Each variable is formatted as <name>=<value>, with a single nul
- * separating each variable, and a double nul terminating the environment.
- */
-static vm_offset_t
-bi_copyenv(vm_offset_t start)
-{
- struct env_var *ep;
- vm_offset_t addr, last;
- size_t len;
-
- addr = last = start;
-
- /* Traverse the environment. */
- for (ep = environ; ep != NULL; ep = ep->ev_next) {
- len = strlen(ep->ev_name);
- if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len)
- break;
- addr += len;
- if (archsw.arch_copyin("=", addr, 1) != 1)
- break;
- addr++;
- if (ep->ev_value != NULL) {
- len = strlen(ep->ev_value);
- if ((size_t)archsw.arch_copyin(ep->ev_value, addr, len) != len)
- break;
- addr += len;
- }
- if (archsw.arch_copyin("", addr, 1) != 1)
- break;
- last = ++addr;
- }
-
- if (archsw.arch_copyin("", last++, 1) != 1)
- last = start;
- return(last);
-}
-
-/*
- * Copy module-related data into the load area, where it can be
- * used as a directory for loaded modules.
- *
- * Module data is presented in a self-describing format. Each datum
- * is preceded by a 32-bit identifier and a 32-bit size field.
- *
- * Currently, the following data are saved:
- *
- * MOD_NAME (variable) module name (string)
- * MOD_TYPE (variable) module type (string)
- * MOD_ARGS (variable) module parameters (string)
- * MOD_ADDR sizeof(vm_offset_t) module load address
- * MOD_SIZE sizeof(size_t) module size
- * MOD_METADATA (variable) type-specific metadata
- */
-#define COPY32(v, a, c) { \
- uint32_t x = (v); \
- if (c) \
- archsw.arch_copyin(&x, a, sizeof(x)); \
- a += sizeof(x); \
-}
-
-#define MOD_STR(t, a, s, c) { \
- COPY32(t, a, c); \
- COPY32(strlen(s) + 1, a, c); \
- if (c) \
- archsw.arch_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(u_long)); \
-}
-
-#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
-#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c)
-#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c)
-
-#define MOD_VAR(t, a, s, c) { \
- COPY32(t, a, c); \
- COPY32(sizeof(s), a, c); \
- if (c) \
- archsw.arch_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(u_long)); \
-}
-
-#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
-#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c)
-
-#define MOD_METADATA(a, mm, c) { \
- COPY32(MODINFO_METADATA | mm->md_type, a, c); \
- COPY32(mm->md_size, a, c); \
- if (c) \
- archsw.arch_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(u_long)); \
-}
-
-#define MOD_END(a, c) { \
- COPY32(MODINFO_END, a, c); \
- COPY32(0, a, c); \
-}
-
-static vm_offset_t
-bi_copymodules(vm_offset_t addr)
-{
- struct preloaded_file *fp;
- struct file_metadata *md;
- int c;
- uint64_t v;
-
- c = addr != 0;
- /* Start with the first module on the list, should be the kernel. */
- for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {
- MOD_NAME(addr, fp->f_name, c); /* This must come first. */
- MOD_TYPE(addr, fp->f_type, c);
- if (fp->f_args)
- MOD_ARGS(addr, fp->f_args, c);
- v = fp->f_addr;
-#if defined(__arm__)
- v -= __elfN(relocation_offset);
-#endif
- MOD_ADDR(addr, v, c);
- v = fp->f_size;
- MOD_SIZE(addr, v, c);
- for (md = fp->f_metadata; md != NULL; md = md->md_next)
- if (!(md->md_type & MODINFOMD_NOCOPY))
- MOD_METADATA(addr, md, c);
- }
- MOD_END(addr, c);
- return(addr);
-}
-
+#ifdef EFI
static EFI_STATUS
efi_do_vmap(EFI_MEMORY_DESCRIPTOR *mm, UINTN sz, UINTN mmsz, UINT32 mmver)
{
@@ -309,16 +198,19 @@ bi_load_efi_data(struct preloaded_file *kfp, bool exit_bs)
efifb.fb_mask_blue = gfx_state.tg_fb.fb_mask_blue;
efifb.fb_mask_reserved = gfx_state.tg_fb.fb_mask_reserved;
- printf("EFI framebuffer information:\n");
- printf("addr, size 0x%jx, 0x%jx\n", efifb.fb_addr, efifb.fb_size);
- printf("dimensions %d x %d\n", efifb.fb_width, efifb.fb_height);
- printf("stride %d\n", efifb.fb_stride);
- printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
- efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue,
- efifb.fb_mask_reserved);
+ if (efifb.fb_addr != 0) {
+ printf("EFI framebuffer information:\n");
+ printf("addr, size 0x%jx, 0x%jx\n",
+ efifb.fb_addr, efifb.fb_size);
+ printf("dimensions %d x %d\n",
+ efifb.fb_width, efifb.fb_height);
+ printf("stride %d\n", efifb.fb_stride);
+ printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
+ efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue,
+ efifb.fb_mask_reserved);
- if (efifb.fb_addr != 0)
file_addmetadata(kfp, MODINFOMD_EFI_FB, sizeof(efifb), &efifb);
+ }
#endif
do_vmap = true;
@@ -347,6 +239,7 @@ bi_load_efi_data(struct preloaded_file *kfp, bool exit_bs)
*/
sz = 0;
+ mm = NULL;
/*
* Matthew Garrett has observed at least one system changing the
@@ -420,6 +313,7 @@ bi_load_efi_data(struct preloaded_file *kfp, bool exit_bs)
return (0);
}
+#endif
/*
* Load the information expected by an amd64 kernel.
@@ -437,11 +331,15 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs)
struct devdesc *rootdev;
struct file_metadata *md;
vm_offset_t addr;
- uint64_t kernend, module;
+ uint64_t kernend;
+#ifdef MODINFOMD_MODULEP
+ uint64_t module;
+#endif
uint64_t envp;
vm_offset_t size;
char *rootdevname;
int howto;
+ bool is64 = sizeof(long) == 8;
#if defined(LOADER_FDT_SUPPORT)
vm_offset_t dtbp;
int dtb_size;
@@ -461,7 +359,6 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs)
#endif
};
#endif
-
howto = bi_getboothowto(args);
/*
@@ -477,25 +374,27 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs)
}
/* Try reading the /etc/fstab file to select the root device */
- getrootmount(efi_fmtdev((void *)rootdev));
+ getrootmount(devformat(rootdev));
addr = 0;
for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
- if (addr < (xp->f_addr + xp->f_size))
+ if (addr < xp->f_addr + xp->f_size)
addr = xp->f_addr + xp->f_size;
}
/* Pad to a page boundary. */
addr = roundup(addr, PAGE_SIZE);
+#ifdef EFI
addr = build_font_module(addr);
/* Pad to a page boundary. */
addr = roundup(addr, PAGE_SIZE);
+#endif
/* Copy our environment. */
envp = addr;
- addr = bi_copyenv(addr);
+ addr = md_copyenv(addr);
/* Pad to a page boundary. */
addr = roundup(addr, PAGE_SIZE);
@@ -518,7 +417,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs)
kernend = 0; /* fill it in later */
/* Figure out the size and location of the metadata. */
- module = *modulep = addr;
+ *modulep = addr;
file_addmetadata(kfp, MODINFOMD_HOWTO, sizeof(howto), &howto);
file_addmetadata(kfp, MODINFOMD_ENVP, sizeof(envp), &envp);
@@ -531,15 +430,22 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs)
#endif
file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof(kernend), &kernend);
#ifdef MODINFOMD_MODULEP
+ module = *modulep;
file_addmetadata(kfp, MODINFOMD_MODULEP, sizeof(module), &module);
#endif
+#ifdef EFI
file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(ST), &ST);
+#endif
#ifdef LOADER_GELI_SUPPORT
geli_export_key_metadata(kfp);
#endif
+#ifdef EFI
bi_load_efi_data(kfp, exit_bs);
+#else
+ bi_loadsmap(kfp);
+#endif
- size = bi_copymodules(0);
+ size = md_copymodules(0, is64); /* Find the size of the modules */
kernend = roundup(addr + size, PAGE_SIZE);
*kernendp = kernend;
@@ -564,7 +470,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs)
#endif
/* Copy module list and metadata. */
- (void)bi_copymodules(addr);
+ (void)md_copymodules(addr, is64);
return (0);
}
diff --git a/stand/efi/loader/conf.c b/stand/efi/loader/conf.c
index 863c9188c72c..3bc74ea6354c 100644
--- a/stand/efi/loader/conf.c
+++ b/stand/efi/loader/conf.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <bootstrap.h>
#include <efi.h>
@@ -80,16 +77,25 @@ struct netif_driver *netif_drivers[] = {
};
extern struct console efi_console;
+extern struct console eficom;
+#if defined(__aarch64__) && __FreeBSD_version < 1500000
+/* Hack for backward compatibility -- but only for a while */
+extern struct console comconsole;
+#endif
+#if defined(__amd64__)
extern struct console comconsole;
-#if defined(__amd64__) || defined(__i386__)
extern struct console nullconsole;
extern struct console spinconsole;
#endif
struct console *consoles[] = {
&efi_console,
+ &eficom,
+#if defined(__aarch64__) && __FreeBSD_version < 1500000
+ &comconsole,
+#endif
+#if defined(__amd64__)
&comconsole,
-#if defined(__amd64__) || defined(__i386__)
&nullconsole,
&spinconsole,
#endif
diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c
index 47e613ccc2f3..3f2d1c6c20b0 100644
--- a/stand/efi/loader/copy.c
+++ b/stand/efi/loader/copy.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Benno Rice under sponsorship from
* the FreeBSD Foundation.
@@ -26,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <stand.h>
@@ -42,7 +38,7 @@ __FBSDID("$FreeBSD$");
#define M(x) ((x) * 1024 * 1024)
#define G(x) (1UL * (x) * 1024 * 1024 * 1024)
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__amd64__)
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <machine/vmparam.h>
@@ -174,7 +170,7 @@ efi_verify_staging_size(unsigned long *nr_pages)
out:
free(map);
}
-#endif /* __i386__ || __amd64__ */
+#endif /* __amd64__ */
#if defined(__arm__)
#define DEFAULT_EFI_STAGING_SIZE 32
@@ -201,7 +197,7 @@ out:
static u_long staging_slop = EFI_STAGING_SLOP;
EFI_PHYSICAL_ADDRESS staging, staging_end, staging_base;
-int stage_offset_set = 0;
+bool stage_offset_set = false;
ssize_t stage_offset;
static void
@@ -209,7 +205,7 @@ efi_copy_free(void)
{
BS->FreePages(staging_base, (staging_end - staging_base) /
EFI_PAGE_SIZE);
- stage_offset_set = 0;
+ stage_offset_set = false;
stage_offset = 0;
}
@@ -285,9 +281,9 @@ command_staging_slop(int argc, char *argv[])
COMMAND_SET(staging_slop, "staging_slop", "set staging slop",
command_staging_slop);
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__amd64__)
/*
- * The staging area must reside in the the first 1GB or 4GB physical
+ * The staging area must reside in the first 1GB or 4GB physical
* memory: see elf64_exec() in
* boot/efi/loader/arch/amd64/elf64_freebsd.c.
*/
@@ -296,11 +292,7 @@ get_staging_max(void)
{
EFI_PHYSICAL_ADDRESS res;
-#if defined(__i386__)
- res = G(1);
-#elif defined(__amd64__)
res = copy_staging == COPY_STAGING_ENABLE ? G(1) : G(4);
-#endif
return (res);
}
#define EFI_ALLOC_METHOD AllocateMaxAddress
@@ -320,7 +312,7 @@ efi_copy_init(void)
ess = DEFAULT_EFI_STAGING_SIZE;
nr_pages = EFI_SIZE_TO_PAGES(M(1) * ess);
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__amd64__)
/*
* We'll decrease nr_pages, if it's too big. Currently we only
* apply this to FreeBSD VM running on Hyper-V. Why? Please see
@@ -331,7 +323,7 @@ efi_copy_init(void)
staging = get_staging_max();
#endif
- status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderData,
+ status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderCode,
nr_pages, &staging);
if (EFI_ERROR(status)) {
printf("failed to allocate staging area: %lu\n",
@@ -388,9 +380,8 @@ efi_check_space(vm_offset_t end)
end += staging_slop;
nr_pages = EFI_SIZE_TO_PAGES(end - staging_end);
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__amd64__)
/*
- * i386 needs all memory to be allocated under the 1G boundary.
* amd64 needs all memory to be allocated under the 1G or 4G boundary.
*/
if (end > get_staging_max())
@@ -399,7 +390,7 @@ efi_check_space(vm_offset_t end)
/* Try to allocate more space after the previous allocation */
addr = staging_end;
- status = BS->AllocatePages(AllocateAddress, EfiLoaderData, nr_pages,
+ status = BS->AllocatePages(AllocateAddress, EfiLoaderCode, nr_pages,
&addr);
if (!EFI_ERROR(status)) {
staging_end = staging_end + nr_pages * EFI_PAGE_SIZE;
@@ -416,7 +407,7 @@ before_staging:
addr = rounddown2(addr, M(2));
#endif
nr_pages = EFI_SIZE_TO_PAGES(staging_base - addr);
- status = BS->AllocatePages(AllocateAddress, EfiLoaderData, nr_pages,
+ status = BS->AllocatePages(AllocateAddress, EfiLoaderCode, nr_pages,
&addr);
if (!EFI_ERROR(status)) {
/*
@@ -436,10 +427,10 @@ expand:
#if EFI_STAGING_2M_ALIGN
nr_pages += M(2) / EFI_PAGE_SIZE;
#endif
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__amd64__)
new_base = get_staging_max();
#endif
- status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderData,
+ status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderCode,
nr_pages, &new_base);
if (!EFI_ERROR(status)) {
#if EFI_STAGING_2M_ALIGN
@@ -479,7 +470,7 @@ efi_copyin(const void *src, vm_offset_t dest, const size_t len)
if (!stage_offset_set) {
stage_offset = (vm_offset_t)staging - dest;
- stage_offset_set = 1;
+ stage_offset_set = true;
}
/* XXX: Callers do not check for failure. */
@@ -510,7 +501,7 @@ efi_readin(readin_handle_t fd, vm_offset_t dest, const size_t len)
if (!stage_offset_set) {
stage_offset = (vm_offset_t)staging - dest;
- stage_offset_set = 1;
+ stage_offset_set = true;
}
if (!efi_check_space(dest + stage_offset + len)) {
diff --git a/stand/efi/loader/efi_main.c b/stand/efi/loader/efi_main.c
index 736c1aa56c99..2a5120dc89d7 100644
--- a/stand/efi/loader/efi_main.c
+++ b/stand/efi/loader/efi_main.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <bootstrap.h>
#include <efi.h>
#include <eficonsctl.h>
@@ -40,8 +37,12 @@ void
efi_exit(EFI_STATUS exit_code)
{
- BS->FreePages(heap, EFI_SIZE_TO_PAGES(heapsize));
- BS->Exit(IH, exit_code, 0, NULL);
+ if (boot_services_active) {
+ BS->FreePages(heap, EFI_SIZE_TO_PAGES(heapsize));
+ BS->Exit(IH, exit_code, 0, NULL);
+ } else {
+ RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+ }
}
void
diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c
index d5504c9cff35..2f580309c2f3 100644
--- a/stand/efi/loader/framebuffer.c
+++ b/stand/efi/loader/framebuffer.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Benno Rice under sponsorship from
* the FreeBSD Foundation.
@@ -26,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <bootstrap.h>
#include <sys/endian.h>
#include <sys/param.h>
@@ -81,6 +77,11 @@ static struct named_resolution {
.height = 1080,
},
{
+ .name = "1440p",
+ .width = 2560,
+ .height = 1440,
+ },
+ {
.name = "2160p",
.alias = "4k",
.width = 3840,
@@ -536,6 +537,21 @@ efifb_get_edid(edid_res_list_t *res)
return (rv);
}
+bool
+efi_has_gop(void)
+{
+ EFI_STATUS status;
+ EFI_HANDLE *hlist;
+ UINTN hsize;
+
+ hsize = 0;
+ hlist = NULL;
+ status = BS->LocateHandle(ByProtocol, &gop_guid, NULL, &hsize, hlist);
+
+ return (status == EFI_BUFFER_TOO_SMALL);
+}
+
+
int
efi_find_framebuffer(teken_gfx_t *gfx_state)
{
diff --git a/stand/efi/loader/framebuffer.h b/stand/efi/loader/framebuffer.h
index 008df7f6c167..c6015f4ccbd3 100644
--- a/stand/efi/loader/framebuffer.h
+++ b/stand/efi/loader/framebuffer.h
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Benno Rice under sponsorship from
* the FreeBSD Foundation.
@@ -24,15 +23,15 @@
* 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.
- *
- * $FreeBSD$
*/
+#include <teken.h>
#include <gfx_fb.h>
#ifndef _EFIFB_H_
#define _EFIFB_H_
+bool efi_has_gop(void);
int efi_find_framebuffer(teken_gfx_t *gfx_state);
#endif /* _EFIFB_H_ */
diff --git a/stand/efi/loader/loader_efi.h b/stand/efi/loader/loader_efi.h
index 8254d16b1592..249860aa5e91 100644
--- a/stand/efi/loader/loader_efi.h
+++ b/stand/efi/loader/loader_efi.h
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Benno Rice under sponsorship from
* the FreeBSD Foundation.
@@ -24,8 +23,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _LOADER_EFI_COPY_H_
@@ -33,6 +30,7 @@
#include <stand.h>
#include <readin.h>
+#include <efi.h>
#ifdef __amd64__
enum {
@@ -43,6 +41,8 @@ enum {
extern int copy_staging;
#endif
+extern EFI_LOADED_IMAGE *boot_img;
+
int efi_autoload(void);
int efi_copy_init(void);
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 7b78f94eb368..e4d62f2e940c 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -27,9 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <sys/disk.h>
@@ -52,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <efi.h>
#include <efilib.h>
#include <efichar.h>
+#include <efirng.h>
#include <uuid.h>
@@ -59,6 +57,13 @@ __FBSDID("$FreeBSD$");
#include <smbios.h>
#include "efizfs.h"
+#include "framebuffer.h"
+
+#include "platform/acfreebsd.h"
+#include "acconfig.h"
+#define ACPI_SYSTEM_XFACE
+#include "actypes.h"
+#include "actbl.h"
#include "loader_efi.h"
@@ -184,25 +189,11 @@ out:
}
static void
-set_currdev(const char *devname)
-{
-
- env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
- env_nounset);
- /*
- * Don't execute hook here; the loaddev hook makes it immutable
- * once we've determined what the proper currdev is.
- */
- env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset,
- env_nounset);
-}
-
-static void
set_currdev_devdesc(struct devdesc *currdev)
{
const char *devname;
- devname = efi_fmtdev(currdev);
+ devname = devformat(currdev);
printf("Setting currdev to %s\n", devname);
set_currdev(devname);
}
@@ -262,42 +253,36 @@ sanity_check_currdev(void)
static bool
probe_zfs_currdev(uint64_t guid)
{
+ char buf[VDEV_PAD_SIZE];
char *devname;
struct zfs_devdesc currdev;
- char *buf = NULL;
- bool rv;
currdev.dd.d_dev = &zfs_dev;
currdev.dd.d_unit = 0;
currdev.pool_guid = guid;
currdev.root_guid = 0;
- set_currdev_devdesc((struct devdesc *)&currdev);
- devname = efi_fmtdev(&currdev);
+ devname = devformat(&currdev.dd);
+ set_currdev(devname);
+ printf("Setting currdev to %s\n", devname);
init_zfs_boot_options(devname);
- rv = sanity_check_currdev();
- if (rv) {
- buf = malloc(VDEV_PAD_SIZE);
- if (buf != NULL) {
- if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf,
- VDEV_PAD_SIZE) == 0) {
- printf("zfs bootonce: %s\n", buf);
- set_currdev(buf);
- setenv("zfs-bootonce", buf, 1);
- }
- free(buf);
- (void) zfs_attach_nvstore(&currdev);
- }
+ if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf, sizeof(buf)) == 0) {
+ printf("zfs bootonce: %s\n", buf);
+ set_currdev(buf);
+ setenv("zfs-bootonce", buf, 1);
}
- return (rv);
+ (void)zfs_attach_nvstore(&currdev);
+
+ return (sanity_check_currdev());
}
#endif
#ifdef MD_IMAGE_SIZE
+extern struct devsw md_dev;
+
static bool
probe_md_currdev(void)
{
- extern struct devsw md_dev;
bool rv;
set_currdev_devsw(&md_dev, 0);
@@ -700,8 +685,7 @@ interactive_interrupt(const char *msg)
static int
parse_args(int argc, CHAR16 *argv[])
{
- int i, j, howto;
- bool vargood;
+ int i, howto;
char var[128];
/*
@@ -718,7 +702,7 @@ parse_args(int argc, CHAR16 *argv[])
* method is flawed for non-ASCII characters).
*/
howto = 0;
- for (i = 1; i < argc; i++) {
+ for (i = 0; i < argc; i++) {
cpy16to8(argv[i], var, sizeof(var));
howto |= boot_parse_arg(var);
}
@@ -739,7 +723,10 @@ setenv_int(const char *key, int val)
* Parse ConOut (the list of consoles active) and see if we can find a
* serial port and/or a video port. It would be nice to also walk the
* ACPI name space to map the UID for the serial port to a port. The
- * latter is especially hard.
+ * latter is especially hard. Also check for ConIn as well. This will
+ * be enough to determine if we have serial, and if we don't, we default
+ * to video. If there's a dual-console situation with ConIn, this will
+ * currently fail.
*/
int
parse_uefi_con_out(void)
@@ -758,9 +745,23 @@ parse_uefi_con_out(void)
rv = efi_global_getenv("ConOut", buf, &sz);
if (rv != EFI_SUCCESS)
rv = efi_global_getenv("ConOutDev", buf, &sz);
+ if (rv != EFI_SUCCESS)
+ rv = efi_global_getenv("ConIn", buf, &sz);
if (rv != EFI_SUCCESS) {
- /* If we don't have any ConOut default to serial */
- how = RB_SERIAL;
+ /*
+ * If we don't have any ConOut default to both. If we have GOP
+ * make video primary, otherwise just make serial primary. In
+ * either case, try to use both the 'efi' console which will use
+ * the GOP, if present and serial. If there's an EFI BIOS that
+ * omits this, but has a serial port redirect, we'll
+ * unavioidably get doubled characters (but we'll be right in
+ * all the other more common cases).
+ */
+ if (efi_has_gop())
+ how = RB_MULTIPLE;
+ else
+ how = RB_MULTIPLE | RB_SERIAL;
+ setenv("console", "efi,comconsole", 1);
goto out;
}
ep = buf + sz;
@@ -907,6 +908,40 @@ ptov(uintptr_t x)
return ((caddr_t)x);
}
+static void
+acpi_detect(void)
+{
+ ACPI_TABLE_RSDP *rsdp;
+ char buf[24];
+ int revision;
+
+ feature_enable(FEATURE_EARLY_ACPI);
+ if ((rsdp = efi_get_table(&acpi20)) == NULL)
+ if ((rsdp = efi_get_table(&acpi)) == NULL)
+ return;
+
+ sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
+ setenv("acpi.rsdp", buf, 1);
+ revision = rsdp->Revision;
+ if (revision == 0)
+ revision = 1;
+ sprintf(buf, "%d", revision);
+ setenv("acpi.revision", buf, 1);
+ strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
+ buf[sizeof(rsdp->OemId)] = '\0';
+ setenv("acpi.oem", buf, 1);
+ sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
+ setenv("acpi.rsdt", buf, 1);
+ if (revision >= 2) {
+ /* XXX extended checksum? */
+ sprintf(buf, "0x%016llx",
+ (unsigned long long)rsdp->XsdtPhysicalAddress);
+ setenv("acpi.xsdt", buf, 1);
+ sprintf(buf, "%d", rsdp->Length);
+ setenv("acpi.xsdt_length", buf, 1);
+ }
+}
+
EFI_STATUS
main(int argc, CHAR16 *argv[])
{
@@ -934,9 +969,28 @@ main(int argc, CHAR16 *argv[])
archsw.arch_readin = efi_readin;
archsw.arch_zfs_probe = efi_zfs_probe;
+#if !defined(__arm__)
+ for (k = 0; k < ST->NumberOfTableEntries; k++) {
+ guid = &ST->ConfigurationTable[k].VendorGuid;
+ if (!memcmp(guid, &smbios, sizeof(EFI_GUID)) ||
+ !memcmp(guid, &smbios3, sizeof(EFI_GUID))) {
+ char buf[40];
+
+ snprintf(buf, sizeof(buf), "%p",
+ ST->ConfigurationTable[k].VendorTable);
+ setenv("hint.smbios.0.mem", buf, 1);
+ smbios_detect(ST->ConfigurationTable[k].VendorTable);
+ break;
+ }
+ }
+#endif
+
/* Get our loaded image protocol interface structure. */
(void) OpenProtocolByHandle(IH, &imgid, (void **)&boot_img);
+ /* Report the RSDP early. */
+ acpi_detect();
+
/*
* Chicken-and-egg problem; we want to have console output early, but
* some console attributes may depend on reading from eg. the boot
@@ -948,13 +1002,16 @@ main(int argc, CHAR16 *argv[])
setenv("console", "efi", 1);
uhowto = parse_uefi_con_out();
#if defined(__riscv)
+ /*
+ * This workaround likely is papering over a real issue
+ */
if ((uhowto & RB_SERIAL) != 0)
setenv("console", "comconsole", 1);
#endif
cons_probe();
/* Set up currdev variable to have hooks in place. */
- env_setenv("currdev", EV_VOLATILE, "", efi_setcurrdev, env_nounset);
+ env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset);
/* Init the time source */
efi_time_init();
@@ -974,9 +1031,7 @@ main(int argc, CHAR16 *argv[])
"failures\n", i);
}
- for (i = 0; devsw[i] != NULL; i++)
- if (devsw[i]->dv_init != NULL)
- (devsw[i]->dv_init)();
+ devinit();
/*
* Detect console settings two different ways: one via the command
@@ -1054,10 +1109,8 @@ main(int argc, CHAR16 *argv[])
*/
boot_howto_to_env(howto);
- if (efi_copy_init()) {
- printf("failed to allocate staging area\n");
+ if (efi_copy_init())
return (EFI_BUFFER_TOO_SMALL);
- }
if ((s = getenv("fail_timeout")) != NULL)
fail_timeout = strtol(s, NULL, 10);
@@ -1184,24 +1237,50 @@ main(int argc, CHAR16 *argv[])
autoload_font(false); /* Set up the font list for console. */
efi_init_environment();
-#if !defined(__arm__)
- for (k = 0; k < ST->NumberOfTableEntries; k++) {
- guid = &ST->ConfigurationTable[k].VendorGuid;
- if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) {
- char buf[40];
+ interact(); /* doesn't return */
- snprintf(buf, sizeof(buf), "%p",
- ST->ConfigurationTable[k].VendorTable);
- setenv("hint.smbios.0.mem", buf, 1);
- smbios_detect(ST->ConfigurationTable[k].VendorTable);
- break;
- }
+ return (EFI_SUCCESS); /* keep compiler happy */
+}
+
+COMMAND_SET(efi_seed_entropy, "efi-seed-entropy", "try to get entropy from the EFI RNG", command_seed_entropy);
+
+static int
+command_seed_entropy(int argc, char *argv[])
+{
+ EFI_STATUS status;
+ EFI_RNG_PROTOCOL *rng;
+ unsigned int size = 2048;
+ void *buf;
+
+ if (argc > 1) {
+ size = strtol(argv[1], NULL, 0);
}
-#endif
- interact(); /* doesn't return */
+ status = BS->LocateProtocol(&rng_guid, NULL, (VOID **)&rng);
+ if (status != EFI_SUCCESS) {
+ command_errmsg = "RNG protocol not found";
+ return (CMD_ERROR);
+ }
- return (EFI_SUCCESS); /* keep compiler happy */
+ if ((buf = malloc(size)) == NULL) {
+ command_errmsg = "out of memory";
+ return (CMD_ERROR);
+ }
+
+ status = rng->GetRNG(rng, NULL, size, (UINT8 *)buf);
+ if (status != EFI_SUCCESS) {
+ free(buf);
+ command_errmsg = "GetRNG failed";
+ return (CMD_ERROR);
+ }
+
+ if (file_addbuf("efi_rng_seed", "boot_entropy_platform", size, buf) != 0) {
+ free(buf);
+ return (CMD_ERROR);
+ }
+
+ free(buf);
+ return (CMD_OK);
}
COMMAND_SET(poweroff, "poweroff", "power off the system", command_poweroff);
@@ -1238,15 +1317,6 @@ command_reboot(int argc, char *argv[])
return (CMD_ERROR);
}
-COMMAND_SET(quit, "quit", "exit the loader", command_quit);
-
-static int
-command_quit(int argc, char *argv[])
-{
- exit(0);
- return (CMD_OK);
-}
-
COMMAND_SET(memmap, "memmap", "print memory map", command_memmap);
static int
diff --git a/stand/efi/loader/version b/stand/efi/loader/version
index 3a4c47c5efb1..2bed97c231d2 100644
--- a/stand/efi/loader/version
+++ b/stand/efi/loader/version
@@ -1,4 +1,3 @@
-$FreeBSD$
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important. Make sure the current version number is on line 6.
diff --git a/stand/efi/loader/version.veriexec b/stand/efi/loader/version.veriexec
new file mode 100644
index 000000000000..5c9292310c04
--- /dev/null
+++ b/stand/efi/loader/version.veriexec
@@ -0,0 +1,7 @@
+NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
+file is important. Make sure the current version number is on line 6.
+
+2.1: SMBIOS 3 support
+2.0: Secure boot support
+1.1: Keep in sync with i386 version.
+0.1: Initial i386 version. Derived from ia64.
diff --git a/stand/efi/loader_4th/Makefile b/stand/efi/loader_4th/Makefile
index 3659f7efe673..3ca078668437 100644
--- a/stand/efi/loader_4th/Makefile
+++ b/stand/efi/loader_4th/Makefile
@@ -1,6 +1,6 @@
-# $FreeBSD$
LOADER_INTERP=4th
+INSTALL_LOADER_HELP_FILE=no
.include "../loader/Makefile"
diff --git a/stand/efi/loader_4th/Makefile.depend b/stand/efi/loader_4th/Makefile.depend
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/stand/efi/loader_4th/Makefile.depend
diff --git a/stand/efi/loader_lua/Makefile b/stand/efi/loader_lua/Makefile
index 3a4268440cf6..6866e742290a 100644
--- a/stand/efi/loader_lua/Makefile
+++ b/stand/efi/loader_lua/Makefile
@@ -1,6 +1,6 @@
-# $FreeBSD$
LOADER_INTERP=lua
+INSTALL_LOADER_HELP_FILE=no
.include "../loader/Makefile"
diff --git a/stand/efi/loader_simp/Makefile b/stand/efi/loader_simp/Makefile
index 0c27d5673941..ac873c1a3033 100644
--- a/stand/efi/loader_simp/Makefile
+++ b/stand/efi/loader_simp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
LOADER_INTERP=simp