Add FDT support to loader.efi. This will be used on arm and arm64.
Differential Revision: https://reviews.freebsd.org/D2219
This commit is contained in:
parent
1d2c0c460c
commit
60ac534440
@ -1,7 +1,15 @@
|
|||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
|
|
||||||
|
.include <src.opts.mk>
|
||||||
|
|
||||||
SUBDIR= libefi
|
SUBDIR= libefi
|
||||||
|
|
||||||
|
.if ${TARGET_CPUARCH} == "aarch64" || ${TARGET_CPUARCH} == "arm"
|
||||||
|
.if ${MK_FDT} != "no"
|
||||||
|
SUBDIR+= fdt
|
||||||
|
.endif
|
||||||
|
.endif
|
||||||
|
|
||||||
.if ${MACHINE_CPUARCH} == "amd64"
|
.if ${MACHINE_CPUARCH} == "amd64"
|
||||||
SUBDIR+= loader boot1
|
SUBDIR+= loader boot1
|
||||||
.endif
|
.endif
|
||||||
|
@ -42,6 +42,15 @@ CFLAGS+= -I${.CURDIR}/../../ficl/${MACHINE_CPUARCH}
|
|||||||
LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
|
LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
LOADER_FDT_SUPPORT?= no
|
||||||
|
.if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no"
|
||||||
|
CFLAGS+= -I${.CURDIR}/../../fdt
|
||||||
|
CFLAGS+= -I${.OBJDIR}/../../fdt
|
||||||
|
CFLAGS+= -DLOADER_FDT_SUPPORT
|
||||||
|
LIBEFI_FDT= ${.OBJDIR}/../../efi/fdt/libefi_fdt.a
|
||||||
|
LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
|
||||||
|
.endif
|
||||||
|
|
||||||
# Include bcache code.
|
# Include bcache code.
|
||||||
HAVE_BCACHE= yes
|
HAVE_BCACHE= yes
|
||||||
|
|
||||||
@ -88,8 +97,9 @@ loader.efi: loader.sym
|
|||||||
|
|
||||||
LIBEFI= ${.OBJDIR}/../libefi/libefi.a
|
LIBEFI= ${.OBJDIR}/../libefi/libefi.a
|
||||||
|
|
||||||
DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND} ${LDSCRIPT}
|
DPADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSTAND} \
|
||||||
LDADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND}
|
${LDSCRIPT}
|
||||||
|
LDADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSTAND}
|
||||||
|
|
||||||
.endif # ${COMPILER_TYPE} != "gcc"
|
.endif # ${COMPILER_TYPE} != "gcc"
|
||||||
|
|
||||||
|
@ -51,6 +51,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(LOADER_FDT_SUPPORT)
|
||||||
|
#include <fdt_platform.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
UINTN efi_mapkey;
|
UINTN efi_mapkey;
|
||||||
|
|
||||||
static const char howto_switches[] = "aCdrgDmphsv";
|
static const char howto_switches[] = "aCdrgDmphsv";
|
||||||
@ -324,6 +328,10 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
|
|||||||
vm_offset_t size;
|
vm_offset_t size;
|
||||||
char *rootdevname;
|
char *rootdevname;
|
||||||
int howto;
|
int howto;
|
||||||
|
#if defined(LOADER_FDT_SUPPORT)
|
||||||
|
vm_offset_t dtbp;
|
||||||
|
int dtb_size;
|
||||||
|
#endif
|
||||||
|
|
||||||
howto = bi_getboothowto(args);
|
howto = bi_getboothowto(args);
|
||||||
|
|
||||||
@ -358,6 +366,16 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
|
|||||||
/* Pad to a page boundary. */
|
/* Pad to a page boundary. */
|
||||||
addr = roundup(addr, PAGE_SIZE);
|
addr = roundup(addr, PAGE_SIZE);
|
||||||
|
|
||||||
|
#if defined(LOADER_FDT_SUPPORT)
|
||||||
|
/* Handle device tree blob */
|
||||||
|
dtbp = addr;
|
||||||
|
dtb_size = fdt_copy(addr);
|
||||||
|
|
||||||
|
/* Pad to a page boundary */
|
||||||
|
if (dtb_size)
|
||||||
|
addr += roundup(dtb_size, PAGE_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
kfp = file_findfile(NULL, "elf kernel");
|
kfp = file_findfile(NULL, "elf kernel");
|
||||||
if (kfp == NULL)
|
if (kfp == NULL)
|
||||||
kfp = file_findfile(NULL, "elf64 kernel");
|
kfp = file_findfile(NULL, "elf64 kernel");
|
||||||
@ -366,6 +384,13 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
|
|||||||
kernend = 0; /* fill it in later */
|
kernend = 0; /* fill it in later */
|
||||||
file_addmetadata(kfp, MODINFOMD_HOWTO, sizeof howto, &howto);
|
file_addmetadata(kfp, MODINFOMD_HOWTO, sizeof howto, &howto);
|
||||||
file_addmetadata(kfp, MODINFOMD_ENVP, sizeof envp, &envp);
|
file_addmetadata(kfp, MODINFOMD_ENVP, sizeof envp, &envp);
|
||||||
|
#if defined(LOADER_FDT_SUPPORT)
|
||||||
|
if (dtb_size)
|
||||||
|
file_addmetadata(kfp, MODINFOMD_DTBP, sizeof dtbp, &dtbp);
|
||||||
|
else
|
||||||
|
pager_output("WARNING! Trying to fire up the kernel, but no "
|
||||||
|
"device tree blob found!\n");
|
||||||
|
#endif
|
||||||
file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
|
file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
|
||||||
|
|
||||||
bi_load_efi_data(kfp);
|
bi_load_efi_data(kfp);
|
||||||
|
@ -387,3 +387,22 @@ command_nvram(int argc, char *argv[])
|
|||||||
|
|
||||||
return (CMD_OK);
|
return (CMD_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOADER_FDT_SUPPORT
|
||||||
|
extern int command_fdt_internal(int argc, char *argv[]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since proper fdt command handling function is defined in fdt_loader_cmd.c,
|
||||||
|
* and declaring it as extern is in contradiction with COMMAND_SET() macro
|
||||||
|
* (which uses static pointer), we're defining wrapper function, which
|
||||||
|
* calls the proper fdt handling routine.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
command_fdt(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
return (command_fdt_internal(argc, argv));
|
||||||
|
}
|
||||||
|
|
||||||
|
COMMAND_SET(fdt, "fdt", "flattened device tree handling", command_fdt);
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user