svn commit: r269350 - in projects/arm64/sys: arm64/arm64 arm64/include boot/arm64/efi
Andrew Turner
andrew at FreeBSD.org
Thu Jul 31 20:55:07 UTC 2014
Author: andrew
Date: Thu Jul 31 20:55:05 2014
New Revision: 269350
URL: http://svnweb.freebsd.org/changeset/base/269350
Log:
Pass the dtb from loader to the kernel. For now loader tries to load
foundation.dtb from the disk and pass this to the kernel.
The dtb is expected to be after the kernel and the data passed in is its
offset from the start of the kernel.
Modified:
projects/arm64/sys/arm64/arm64/machdep.c
projects/arm64/sys/arm64/include/metadata.h
projects/arm64/sys/boot/arm64/efi/autoload.c
projects/arm64/sys/boot/arm64/efi/bootinfo.c
Modified: projects/arm64/sys/arm64/arm64/machdep.c
==============================================================================
--- projects/arm64/sys/arm64/arm64/machdep.c Thu Jul 31 20:28:17 2014 (r269349)
+++ projects/arm64/sys/arm64/arm64/machdep.c Thu Jul 31 20:55:05 2014 (r269350)
@@ -62,6 +62,10 @@ __FBSDID("$FreeBSD$");
#include <machine/reg.h>
#include <machine/vmparam.h>
+#include <dev/ofw/openfirm.h>
+
+#include "opt_platform.h"
+
struct pcpu __pcpu[MAXCPU];
struct pcpu *pcpup = &__pcpu[0];
@@ -484,6 +488,28 @@ add_efi_map_entries(struct efi_map_heade
}
}
+#ifdef FDT
+static void
+try_load_dtb(caddr_t kmdp)
+{
+ vm_offset_t dtboff;
+ void *dtbp;
+
+ dtboff = MD_FETCH(kmdp, MODINFOMD_DTB_OFF, vm_offset_t);
+ if (dtboff == 0)
+ return;
+
+ dtbp = (void *)(KERNBASE + dtboff);
+ printf("dtbp = %llx\n", *(uint64_t *)(KERNBASE + dtboff));
+
+ if (OF_install(OFW_FDT, 0) == FALSE)
+ panic("Cannot install FDT");
+
+ if (OF_init((void *)dtbp) != 0)
+ panic("OF_init failed with the found device tree");
+}
+#endif
+
void
initarm(struct arm64_bootparams *abp)
{
@@ -503,6 +529,10 @@ initarm(struct arm64_bootparams *abp)
if (kmdp == NULL)
kmdp = preload_search_by_type("elf64 kernel");
+#ifdef FDT
+ try_load_dtb(kmdp);
+#endif
+
/* Find the address to start allocating from */
lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);
Modified: projects/arm64/sys/arm64/include/metadata.h
==============================================================================
--- projects/arm64/sys/arm64/include/metadata.h Thu Jul 31 20:28:17 2014 (r269349)
+++ projects/arm64/sys/arm64/include/metadata.h Thu Jul 31 20:55:05 2014 (r269350)
@@ -30,6 +30,7 @@
#define _MACHINE_METADATA_H_
#define MODINFOMD_EFI_MAP 0x1001
+#define MODINFOMD_DTB_OFF 0x1002
struct efi_map_header {
size_t memory_size;
Modified: projects/arm64/sys/boot/arm64/efi/autoload.c
==============================================================================
--- projects/arm64/sys/boot/arm64/efi/autoload.c Thu Jul 31 20:28:17 2014 (r269349)
+++ projects/arm64/sys/boot/arm64/efi/autoload.c Thu Jul 31 20:55:05 2014 (r269350)
@@ -27,9 +27,37 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#if 1
+#include <stand.h>
+#include "bootstrap.h"
+
+/* HACK: Load the foundation model dtb from disk */
+static int
+load_dtb_file(const char *filename)
+{
+ struct preloaded_file *bfp, *oldbfp;
+ int err;
+
+ oldbfp = file_findfile(NULL, "dtb");
+
+ /* Attempt to load and validate a new dtb from a file. */
+ if ((bfp = file_loadraw(filename, "dtb")) == NULL) {
+ printf("failed to load file '%s': %s\n", filename, command_errbuf);
+ return (1);
+ }
+
+ /* A new dtb was validated, discard any previous file. */
+ if (oldbfp)
+ file_discard(oldbfp);
+ return (0);
+}
+#endif
+
int
amd64_autoload(void)
{
+ load_dtb_file("/foundation.dtb");
+
return (0);
}
Modified: projects/arm64/sys/boot/arm64/efi/bootinfo.c
==============================================================================
--- projects/arm64/sys/boot/arm64/efi/bootinfo.c Thu Jul 31 20:28:17 2014 (r269349)
+++ projects/arm64/sys/boot/arm64/efi/bootinfo.c Thu Jul 31 20:55:05 2014 (r269350)
@@ -198,10 +198,11 @@ bi_load_efi_data(struct preloaded_file *
int
bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
{
- struct preloaded_file *xp, *kfp;
+ struct preloaded_file *xp, *kfp, *dtbfp;
struct file_metadata *md;
uint64_t kernend;
vm_offset_t addr, size;
+ vm_offset_t dtbp;
/* find the last module in the chain */
addr = 0;
@@ -218,6 +219,15 @@ bi_load(char *args, vm_offset_t *modulep
if (kfp == NULL)
panic("can't find kernel file");
kernend = 0; /* fill it in later */
+
+ dtbfp = file_findfile(NULL, "dtb");
+ if (dtbfp != NULL) {
+ printf("dtbfp = %llx %lld\n", dtbfp->f_addr, dtbfp->f_addr - kfp->f_addr);
+
+ dtbp = dtbfp->f_addr - kfp->f_addr;
+ file_addmetadata(kfp, MODINFOMD_DTB_OFF, sizeof dtbp, &dtbp);
+ }
+
file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
bi_load_efi_data(kfp);
More information about the svn-src-projects
mailing list