Date: Sun, 20 Dec 2015 12:14:12 -0800 From: Thomas Skibo <thomasskibo@yahoo.com> To: Adrian Chadd <adrian.chadd@gmail.com> Cc: "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org> Subject: Re: u-boot and ubldr on arm64 Message-ID: <195ED9AE-7759-4833-846D-949BD6F85735@yahoo.com> In-Reply-To: <CAJ-VmokxwNDNM9fNEaPC_%2BKHwkjc8Y_F%2BxKK0dTsGTvZuNU39g@mail.gmail.com> References: <5695944F-A052-4959-8F9A-ACD4CD3413D6@yahoo.com> <CAJ-VmokxwNDNM9fNEaPC_%2BKHwkjc8Y_F%2BxKK0dTsGTvZuNU39g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
> On Dec 18, 2015, at 3:24 PM, Adrian Chadd <adrian.chadd@gmail.com> wrote:
>
> hey cool!
>
> Can you post your patches to freebsd and uboot? Let's get them
> somewhere reviewed!
>
>
> -a
>
>
Ok.
I’m attaching my changes so far. I’ve run out of time to play with this until after the holidays.
I’ve attached an unrelated patch to sys/arm64/arm64/machdep.c that gets me up and running with an FDT kernel. Opinions welcome from the arm64 guys.
Cheers,
—Thomas
—
Thomas Skibo
thomasskibo@yahoo.com
[-- Attachment #2 --]
Index: sys/boot/Makefile.arm64
===================================================================
--- sys/boot/Makefile.arm64 (revision 292455)
+++ sys/boot/Makefile.arm64 (working copy)
@@ -4,4 +4,4 @@
SUBDIR+= fdt
.endif
-SUBDIR+= efi
+SUBDIR+= efi uboot
Index: sys/boot/arm64/Makefile
===================================================================
--- sys/boot/arm64/Makefile (revision 292455)
+++ sys/boot/arm64/Makefile (working copy)
@@ -1,3 +1,5 @@
# $FreeBSD$
+SUBDIR= uboot
+
.include <bsd.subdir.mk>
Index: sys/boot/arm64/Makefile.inc
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/Makefile.inc 2015-12-19 17:47:30.916631000 -0800
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+.include "../Makefile.inc"
Index: sys/boot/arm64/uboot/version
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/uboot/version 2015-12-12 07:04:07.979566000 -0800
@@ -0,0 +1,9 @@
+$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.
+
+1.2: Extended with NAND FS support.
+1.1: Flattened Device Tree blob support.
+1.0: Added storage support. Booting from HDD, USB, etc. is now possible.
+0.5: Initial U-Boot/arm version (netbooting only).
Index: sys/boot/arm64/uboot/conf.c
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/uboot/conf.c 2015-12-12 07:02:16.820511000 -0800
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 2008 Semihalf, Rafal Jaworowski
+ * 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 <stand.h>
+#include "bootstrap.h"
+#include "libuboot.h"
+
+#if defined(LOADER_NET_SUPPORT)
+#include "dev_net.h"
+#endif
+
+struct devsw *devsw[] = {
+#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT)
+ &uboot_storage,
+#endif
+#if defined(LOADER_NET_SUPPORT)
+ &netdev,
+#endif
+ NULL
+};
+
+struct fs_ops *file_system[] = {
+#if defined(LOADER_UFS_SUPPORT)
+ &ufs_fsops,
+#endif
+#if defined(LOADER_CD9660_SUPPORT)
+ &cd9660_fsops,
+#endif
+#if defined(LOADER_EXT2FS_SUPPORT)
+ &ext2fs_fsops,
+#endif
+#if defined(LOADER_NANDFS_SUPPORT)
+ &nandfs_fsops,
+#endif
+#if defined(LOADER_NFS_SUPPORT)
+ &nfs_fsops,
+#endif
+#if defined(LOADER_TFTP_SUPPORT)
+ &tftp_fsops,
+#endif
+#if defined(LOADER_GZIP_SUPPORT)
+ &gzipfs_fsops,
+#endif
+#if defined(LOADER_BZIP2_SUPPORT)
+ &bzipfs_fsops,
+#endif
+ NULL
+};
+
+struct netif_driver *netif_drivers[] = {
+#if defined(LOADER_NET_SUPPORT)
+ &uboot_net,
+#endif
+ NULL,
+};
+
+struct file_format *file_formats[] = {
+ &uboot_elf,
+ NULL
+};
+
+extern struct console uboot_console;
+
+struct console *consoles[] = {
+ &uboot_console,
+ NULL
+};
Index: sys/boot/arm64/uboot/Makefile
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/uboot/Makefile 2015-12-17 09:03:26.981847000 -0800
@@ -0,0 +1,159 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+FILES= ubldr ubldr.bin
+
+NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH}
+BINDIR?= /boot
+INSTALLFLAGS= -b
+WARNS?= 1
+# Address at which ubldr will be loaded.
+# This varies for different boards and SOCs.
+UBLDR_LOADADDR?= 0x1000000
+
+# Architecture-specific loader code
+SRCS= start.S conf.c self_reloc.c vers.c
+
+.if !defined(LOADER_NO_DISK_SUPPORT)
+LOADER_DISK_SUPPORT?= yes
+.else
+LOADER_DISK_SUPPORT= no
+.endif
+LOADER_UFS_SUPPORT?= yes
+LOADER_CD9660_SUPPORT?= no
+LOADER_EXT2FS_SUPPORT?= no
+.if ${MK_NAND} != "no"
+LOADER_NANDFS_SUPPORT?= yes
+.else
+LOADER_NANDFS_SUPPORT?= no
+.endif
+LOADER_NET_SUPPORT?= yes
+LOADER_NFS_SUPPORT?= yes
+LOADER_TFTP_SUPPORT?= no
+LOADER_GZIP_SUPPORT?= no
+LOADER_BZIP2_SUPPORT?= no
+.if ${MK_FDT} != "no"
+LOADER_FDT_SUPPORT= yes
+.else
+LOADER_FDT_SUPPORT= no
+.endif
+
+.if ${LOADER_DISK_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_DISK_SUPPORT
+.endif
+.if ${LOADER_UFS_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_UFS_SUPPORT
+.endif
+.if ${LOADER_CD9660_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_CD9660_SUPPORT
+.endif
+.if ${LOADER_EXT2FS_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_EXT2FS_SUPPORT
+.endif
+.if ${LOADER_NANDFS_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_NANDFS_SUPPORT
+.endif
+.if ${LOADER_GZIP_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_GZIP_SUPPORT
+.endif
+.if ${LOADER_BZIP2_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_BZIP2_SUPPORT
+.endif
+.if ${LOADER_NET_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_NET_SUPPORT
+.endif
+.if ${LOADER_NFS_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_NFS_SUPPORT
+.endif
+.if ${LOADER_TFTP_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_TFTP_SUPPORT
+.endif
+.if ${LOADER_FDT_SUPPORT} == "yes"
+CFLAGS+= -I${.CURDIR}/../../fdt
+CFLAGS+= -I${.OBJDIR}/../../fdt
+CFLAGS+= -DLOADER_FDT_SUPPORT
+LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt/libuboot_fdt.a
+LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
+.endif
+
+CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE
+
+.if ${MK_FORTH} != "no"
+# Enable BootForth
+BOOT_FORTH= yes
+CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/aarch64
+LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
+.endif
+
+# Always add MI sources
+.PATH: ${.CURDIR}/../../common
+.include "${.CURDIR}/../../common/Makefile.inc"
+CFLAGS+= -I${.CURDIR}/../../common
+CFLAGS+= -I.
+
+CLEANFILES+= vers.c loader.help
+
+CFLAGS+= -ffreestanding -msoft-float
+
+LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
+
+# Pull in common loader code
+.PATH: ${.CURDIR}/../../uboot/common
+.include "${.CURDIR}/../../uboot/common/Makefile.inc"
+CFLAGS+= -I${.CURDIR}/../../uboot/common
+
+# U-Boot standalone support library
+LIBUBOOT= ${.OBJDIR}/../../uboot/lib/libuboot.a
+CFLAGS+= -I${.CURDIR}/../../uboot/lib
+CFLAGS+= -I${.OBJDIR}/../../uboot/lib
+
+# where to get libstand from
+CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
+
+# clang doesn't understand %D as a specifier to printf
+NO_WERROR.clang=
+
+DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSTAND}
+LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} -lstand
+
+OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
+
+vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
+ sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
+
+loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt
+ cat ${.ALLSRC} | \
+ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
+
+ldscript.abs:
+ echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >${.TARGET}
+
+ldscript.pie:
+ echo "UBLDR_LOADADDR = 0;" >${.TARGET}
+
+ubldr: ${OBJS} ldscript.abs ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD}
+ ${CC} ${CFLAGS} -T ldscript.abs ${LDFLAGS} \
+ -o ${.TARGET} ${OBJS} ${LDADD}
+
+ubldr.pie: ${OBJS} ldscript.pie ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD}
+ ${CC} ${CFLAGS} -T ldscript.pie ${LDFLAGS} -pie -Wl,-Bsymbolic \
+ -o ${.TARGET} ${OBJS} ${LDADD}
+
+ubldr.bin: ubldr.pie
+ ${OBJCOPY} -S -O binary ubldr.pie ${.TARGET}
+
+CLEANFILES+= ldscript.abs ldscript.pie ubldr ubldr.pie ubldr.bin
+
+.if !defined(LOADER_ONLY)
+.PATH: ${.CURDIR}/../../forth
+.include "${.CURDIR}/../../forth/Makefile.inc"
+
+# Install loader.rc.
+FILES+= loader.rc
+# Put sample menu.rc on disk but don't enable it by default.
+FILES+= menu.rc
+FILESNAME_menu.rc= menu.rc.sample
+.endif
+
+.include <bsd.prog.mk>
Index: sys/boot/arm64/uboot/start.S
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/uboot/start.S 2015-12-16 13:38:31.463576000 -0800
@@ -0,0 +1,122 @@
+/*-
+ * Copyright (c) 2008 Semihalf, Rafal Czubak
+ * 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$
+ */
+
+#include <machine/asm.h>
+#include <machine/armreg.h>
+
+ .text
+ .extern _C_LABEL(self_reloc), _C_LABEL(main)
+ .weak _DYNAMIC
+
+/*
+ * Entry point to the loader that U-Boot passes control to.
+ */
+ .globl _start
+_start:
+
+ /*
+ * Do self-relocation when the weak external symbol _DYNAMIC is non-NULL.
+ * When linked as a dynamic relocatable file, the linker automatically
+ * defines _DYNAMIC with a value that is the offset of the dynamic
+ * relocation info section.
+ * Note that we're still on u-boot's stack here, but the self_reloc
+ * code uses only a couple dozen bytes of stack space.
+ */
+ ldr x15, =.here_off /* .here_off is a symbol whose value */
+ ldr x0, [x15] /* is its own offset in the text seg. */
+ sub x0, x15, x0 /* Get its pc-relative address and */
+ ldr x1, .dynamic_off /* subtract its value and we get */
+ cmp x1, #0 /* x0 = physaddr we were loaded at. */
+ b.eq 2f
+ add x1, x1, x0 /* x1 = dynamic section physaddr. */
+ bl _C_LABEL(self_reloc) /* Do reloc if _DYNAMIC is non-NULL. */
+2:
+ /* Hint where to look for the API signature */
+ ldr x15, =uboot_address
+ mov x0, sp
+ str x0, [x15]
+
+ /* Save U-Boot's x18 */
+ ldr x15, =saved_regs
+ str x18, [x15, #0]
+
+ /*
+ * Start loader. This is basically a tail-recursion call; if main()
+ * returns, it returns to u-boot (which reports the value returned x0).
+ */
+ b main
+
+ /*
+ * Data for self-relocation, in the text segment for pc-rel access.
+ */
+ .align 3
+.here_off:
+ .quad .
+.dynamic_off:
+ .quad _DYNAMIC
+
+/*
+ * syscall()
+ */
+ENTRY(syscall)
+ /* Save caller's lr, x18 */
+ ldr x15, =saved_regs
+ str x18, [x15, #8]
+ str lr, [x15, #16]
+
+ /* Restore U-Boot's x18 */
+ ldr x18, saved_regs
+
+ /* Call into U-Boot */
+ ldr lr, =return_from_syscall
+ ldr x15, syscall_ptr
+ br x15
+return_from_syscall:
+ /* Restore loader's x18 and lr */
+ ldr lr, saved_regs + 16
+ ldr x18, saved_regs + 8
+ /* Return to caller */
+ ret
+
+/*
+ * Data section
+ */
+ .data
+ .align 3
+ .globl syscall_ptr
+syscall_ptr:
+ .quad 0
+
+ .globl uboot_address
+uboot_address:
+ .quad 0
+
+saved_regs:
+ .quad 0 /* U-Boot's x18 */
+ .quad 0 /* Loader's x18 */
+ .quad 0 /* Loader's lr */
Index: sys/boot/arm64/uboot/help.uboot
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/uboot/help.uboot 2015-12-12 07:02:24.667806000 -0800
@@ -0,0 +1,27 @@
+$FreeBSD$
+
+###############################################################################
+# Tubenv DShow or import U-Boot environment variables
+
+ ubenv <import | show> [varname ...]
+
+ Display U-Boot environment variables, or import them into the
+ loader environment (which makes them available in the kernel).
+
+###############################################################################
+# Tubenv Simport DImport U-Boot env vars
+
+ ubenv import [varname ...]
+
+ If no variable names are specified, all U-Boot environment
+ variables are imported. Each variable is prefixed with "uboot."
+ to avoid any possible conflicts with loader or kernel variables.
+
+###############################################################################
+# Tubenv Sshow DShow U-Boot env vars
+
+ ubenv show [varname ...]
+
+ If no variable names are specified, all U-Boot environment
+ variables are shown.
+
Index: sys/boot/arm64/uboot/loader.conf
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/uboot/loader.conf 2015-12-14 12:03:37.518477000 -0800
@@ -0,0 +1,13 @@
+# This is defaults/loader.conf for ARM 64, containing defaults for loader(8).
+# Do not modify the contents of this file, instead put your customizations
+# into /boot/loader.conf or /boot/loader.conf.local
+# $FreeBSD$
+
+autoboot_delay=10
+bootfile="kernel" # Kernel name (possibly absolute path)
+kernel="kernel" # /boot sub-directory containing kernel and modules
+loader_conf_files="/boot/loader.conf /boot/loader.conf.local"
+module_path="/boot/kernel;/boot/modules;/boot/dtb"
+nextboot_conf="/boot/nextboot.conf"
+nextboot_enable="NO"
+verbose_loading="NO"
Index: sys/boot/arm64/uboot/ldscript.aarch64
===================================================================
--- /dev/null 2015-12-19 17:44:00.000000000 -0800
+++ sys/boot/arm64/uboot/ldscript.aarch64 2015-12-12 07:03:01.792999000 -0800
@@ -0,0 +1,133 @@
+/* $FreeBSD$ */
+
+OUTPUT_ARCH(aarch64)
+ENTRY(_start)
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = UBLDR_LOADADDR + SIZEOF_HEADERS;
+ .text :
+ {
+ *(.text)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.gnu.linkonce.t*)
+ } =0
+ _etext = .;
+ PROVIDE (etext = .);
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rela.text :
+ { *(.rela.text) *(.rela.gnu.linkonce.t*) }
+ .rela.data :
+ { *(.rela.data) *(.rela.gnu.linkonce.d*) }
+ .rela.rodata :
+ { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+ .rela.got : { *(.rela.got) }
+ .rela.got1 : { *(.rela.got1) }
+ .rela.got2 : { *(.rela.got2) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rela.init : { *(.rela.init) }
+ .rela.fini : { *(.rela.fini) }
+ .rela.bss : { *(.rela.bss) }
+ .rela.plt : { *(.rela.plt) }
+ .rela.sdata : { *(.rela.sdata) }
+ .rela.sbss : { *(.rela.sbss) }
+ .rela.sdata2 : { *(.rela.sdata2) }
+ .rela.sbss2 : { *(.rela.sbss2) }
+ .init : { *(.init) } =0
+ .fini : { *(.fini) } =0
+ .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
+ .rodata1 : { *(.rodata1) }
+ .sdata2 : { *(.sdata2) }
+ .sbss2 : { *(.sbss2) }
+ /* Adjust the address for the data segment to the next page up. */
+ . = ((. + 0x1000) & ~(0x1000 - 1));
+ .data :
+ {
+ *(.data)
+ *(.gnu.linkonce.d*)
+ CONSTRUCTORS
+ }
+ .data1 : { *(.data1) }
+ .got1 : { *(.got1) }
+ .dynamic : { *(.dynamic) }
+ /* Put .ctors and .dtors next to the .got2 section, so that the pointers
+ get relocated with -mrelocatable. Also put in the .fixup pointers.
+ The current compiler no longer needs this, but keep it around for 2.7.2 */
+ PROVIDE (_GOT2_START_ = .);
+ .got2 : { *(.got2) }
+ PROVIDE (__CTOR_LIST__ = .);
+ .ctors : { *(.ctors) }
+ PROVIDE (__CTOR_END__ = .);
+ PROVIDE (__DTOR_LIST__ = .);
+ .dtors : { *(.dtors) }
+ PROVIDE (__DTOR_END__ = .);
+ PROVIDE (_FIXUP_START_ = .);
+ .fixup : { *(.fixup) }
+ PROVIDE (_FIXUP_END_ = .);
+ PROVIDE (_GOT2_END_ = .);
+ PROVIDE (_GOT_START_ = .);
+ .got : { *(.got) }
+ .got.plt : { *(.got.plt) }
+ PROVIDE (_GOT_END_ = .);
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+ .sdata : { *(.sdata) }
+ _edata = .;
+ PROVIDE (edata = .);
+ .sbss :
+ {
+ PROVIDE (__sbss_start = .);
+ *(.sbss)
+ *(.scommon)
+ *(.dynsbss)
+ PROVIDE (__sbss_end = .);
+ }
+ .plt : { *(.plt) }
+ .bss :
+ {
+ PROVIDE (__bss_start = .);
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ _end = . ;
+ PROVIDE (end = .);
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ /* These must appear regardless of . */
+}
Index: sys/boot/common/load_elf.c
===================================================================
--- sys/boot/common/load_elf.c (revision 292455)
+++ sys/boot/common/load_elf.c (working copy)
@@ -198,7 +198,7 @@
* leave dest set to the value calculated by archsw.arch_loadaddr() and
* passed in to this function.
*/
-#ifndef __arm__
+#if !defined(__arm__) && !defined(__aarch64__)
if (ehdr->e_type == ET_EXEC)
dest = (ehdr->e_entry & ~PAGE_MASK);
#endif
@@ -370,6 +370,24 @@
#ifdef ELF_VERBOSE
printf("ehdr->e_entry 0x%08x, va<->pa off %llx\n", ehdr->e_entry, off);
#endif
+#elif defined(__aarch64__)
+ /*
+ * The elf headers in arm kernels specify virtual addresses in all
+ * header fields, even the ones that should be physical addresses.
+ * We assume the entry point is in the first 2MB, and masking the lower
+ * bits will leave us with the virtual address the kernel was linked
+ * at. We subtract that from the load offset, making 'off' into the
+ * value which, when added to a virtual address in an elf header,
+ * translates it to a physical address. We do the va->pa conversion on
+ * the entry point address in the header now, so that later we can
+ * launch the kernel by just jumping to that address.
+ */
+#define KERN_ALIGN (2 * 1024 * 1024) /* XXX: where should this go? */
+ off -= ehdr->e_entry & ~(KERN_ALIGN-1);
+ ehdr->e_entry += off;
+#ifdef ELF_VERBOSE
+ printf("ehdr->e_entry %p, va<->pa off 0x%llx\n", ehdr->e_entry, off);
+#endif
#else
off = 0; /* other archs use direct mapped kernels */
#endif
Index: sys/boot/efi/loader/bootinfo.c
===================================================================
--- sys/boot/efi/loader/bootinfo.c (revision 292455)
+++ sys/boot/efi/loader/bootinfo.c (working copy)
@@ -217,7 +217,7 @@
if (fp->f_args)
MOD_ARGS(addr, fp->f_args, c);
v = fp->f_addr;
-#if defined(__arm__)
+#if defined(__arm__) || defined(__aarch64__)
v -= __elfN(relocation_offset);
#endif
MOD_ADDR(addr, v, c);
@@ -360,7 +360,7 @@
vm_offset_t dtbp;
int dtb_size;
#endif
-#if defined(__arm__)
+#if defined(__arm__) || defined(__aarch64__)
vm_offset_t vaddr;
int i;
/*
@@ -448,7 +448,7 @@
md = file_findmetadata(kfp, MODINFOMD_KERNEND);
bcopy(&kernend, md->md_data, sizeof kernend);
-#if defined(__arm__)
+#if defined(__arm__) || defined(__aarch64__)
*modulep -= __elfN(relocation_offset);
/* Do relocation fixup on metadata of each module. */
Index: sys/boot/uboot/common/main.c
===================================================================
--- sys/boot/uboot/common/main.c (revision 292455)
+++ sys/boot/uboot/common/main.c (working copy)
@@ -133,7 +133,7 @@
size = memsize(si, t[i]);
if (size > 0)
printf("%s: %lldMB\n", ub_mem_type(t[i]),
- size / 1024 / 1024);
+ (unsigned long long)size / 1024 / 1024);
}
}
@@ -512,7 +512,7 @@
{
printf("heap base at %p, top at %p, used %d\n", end, sbrk(0),
- sbrk(0) - end);
+ (int)(sbrk(0) - end));
return (CMD_OK);
}
@@ -605,7 +605,7 @@
}
/* If ldvar is malformed or there's no variable name left, punt. */
- if (ldvar[0] == 0 || var[0] == 0)
+ if ((action == UBENV_IMPORT && ldvar[0] == 0) || var[0] == 0)
return;
val = ub_env_get(var);
Index: sys/boot/uboot/fdt/Makefile
===================================================================
--- sys/boot/uboot/fdt/Makefile (revision 292455)
+++ sys/boot/uboot/fdt/Makefile (working copy)
@@ -24,7 +24,7 @@
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
machine:
- ln -sf ${.CURDIR}/../../../${MACHINE_CPUARCH}/include machine
+ ln -sf ${.CURDIR}/../../../${MACHINE}/include machine
CLEANFILES+= machine
Index: sys/boot/uboot/lib/Makefile
===================================================================
--- sys/boot/uboot/lib/Makefile (revision 292455)
+++ sys/boot/uboot/lib/Makefile (working copy)
@@ -42,7 +42,7 @@
.endif
machine:
- ln -sf ${.CURDIR}/../../../${MACHINE_CPUARCH}/include machine
+ ln -sf ${.CURDIR}/../../../${MACHINE}/include machine
CLEANFILES+= machine
Index: sys/boot/uboot/lib/copy.c
===================================================================
--- sys/boot/uboot/lib/copy.c (revision 292455)
+++ sys/boot/uboot/lib/copy.c (working copy)
@@ -40,7 +40,7 @@
* MD primitives supporting placement of module data
*/
-#ifdef __arm__
+#if defined(__arm__) || defined(__aarch64__)
#define KERN_ALIGN (2 * 1024 * 1024)
#else
#define KERN_ALIGN PAGE_SIZE
Index: sys/boot/uboot/lib/disk.c
===================================================================
--- sys/boot/uboot/lib/disk.c (revision 292455)
+++ sys/boot/uboot/lib/disk.c (working copy)
@@ -156,8 +156,8 @@
}
if (size % SI(dev).bsize) {
- stor_printf("size=%d not multiple of device block size=%d\n",
- size, SI(dev).bsize);
+ stor_printf("size=%ld not multiple of device block size=%d\n",
+ (long)size, SI(dev).bsize);
return (EIO);
}
bcount = size / SI(dev).bsize;
Index: sys/boot/uboot/lib/elf_freebsd.c
===================================================================
--- sys/boot/uboot/lib/elf_freebsd.c (revision 292455)
+++ sys/boot/uboot/lib/elf_freebsd.c (working copy)
@@ -81,7 +81,7 @@
return (error);
entry = (void *)e->e_entry;
- printf("Kernel entry at 0x%x...\n", (unsigned)entry);
+ printf("Kernel entry at 0x%p...\n", entry);
dev_cleanup();
printf("Kernel args: %s\n", fp->f_args);
Index: sys/boot/uboot/lib/glue.c
===================================================================
--- sys/boot/uboot/lib/glue.c (revision 292455)
+++ sys/boot/uboot/lib/glue.c (working copy)
@@ -109,7 +109,7 @@
{
int c;
- if (!syscall(API_GETC, NULL, (uint32_t)&c))
+ if (!syscall(API_GETC, NULL, (uintptr_t)&c))
return (-1);
return (c);
@@ -120,7 +120,7 @@
{
int t;
- if (!syscall(API_TSTC, NULL, (uint32_t)&t))
+ if (!syscall(API_TSTC, NULL, (uintptr_t)&t))
return (-1);
return (t);
@@ -130,14 +130,14 @@
ub_putc(char c)
{
- syscall(API_PUTC, NULL, (uint32_t)&c);
+ syscall(API_PUTC, NULL, (uintptr_t)&c);
}
void
ub_puts(const char *s)
{
- syscall(API_PUTS, NULL, (uint32_t)s);
+ syscall(API_PUTS, NULL, (uintptr_t)s);
}
/****************************************
@@ -166,7 +166,7 @@
si.mr_no = UB_MAX_MR;
memset(&mr, 0, sizeof(mr));
- if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si))
+ if (!syscall(API_GET_SYS_INFO, &err, (uintptr_t)&si))
return (NULL);
return ((err) ? NULL : &si);
@@ -483,7 +483,7 @@
{
char *value;
- if (!syscall(API_ENV_GET, NULL, (uint32_t)name, (uint32_t)&value))
+ if (!syscall(API_ENV_GET, NULL, (uintptr_t)name, (uintptr_t)&value))
return (NULL);
return (value);
@@ -493,7 +493,7 @@
ub_env_set(const char *name, char *value)
{
- syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value);
+ syscall(API_ENV_SET, NULL, (uintptr_t)name, (uintptr_t)value);
}
static char env_name[256];
@@ -510,7 +510,7 @@
* internally, which handles such case
*/
env = NULL;
- if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env))
+ if (!syscall(API_ENV_ENUM, NULL, (uintptr_t)last, (uintptr_t)&env))
return (NULL);
if (env == NULL || last == env)
[-- Attachment #3 --]
diff --git a/api/api.c b/api/api.c
index c5f6edb..2639ee5 100644
--- a/api/api.c
+++ b/api/api.c
@@ -52,7 +52,7 @@ static int API_getc(va_list ap)
{
int *c;
- if ((c = (int *)va_arg(ap, u_int32_t)) == NULL)
+ if ((c = (int *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
*c = getc();
@@ -68,7 +68,7 @@ static int API_tstc(va_list ap)
{
int *t;
- if ((t = (int *)va_arg(ap, u_int32_t)) == NULL)
+ if ((t = (int *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
*t = tstc();
@@ -84,7 +84,7 @@ static int API_putc(va_list ap)
{
char *c;
- if ((c = (char *)va_arg(ap, u_int32_t)) == NULL)
+ if ((c = (char *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
putc(*c);
@@ -100,7 +100,7 @@ static int API_puts(va_list ap)
{
char *s;
- if ((s = (char *)va_arg(ap, u_int32_t)) == NULL)
+ if ((s = (char *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
puts(s);
@@ -132,7 +132,7 @@ static int API_get_sys_info(va_list ap)
{
struct sys_info *si;
- si = (struct sys_info *)va_arg(ap, u_int32_t);
+ si = (struct sys_info *)va_arg(ap, uintptr_t);
if (si == NULL)
return API_ENOMEM;
@@ -148,7 +148,7 @@ static int API_udelay(va_list ap)
{
unsigned long *d;
- if ((d = (unsigned long *)va_arg(ap, u_int32_t)) == NULL)
+ if ((d = (unsigned long *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
udelay(*d);
@@ -164,11 +164,11 @@ static int API_get_timer(va_list ap)
{
unsigned long *base, *cur;
- cur = (unsigned long *)va_arg(ap, u_int32_t);
+ cur = (unsigned long *)va_arg(ap, uintptr_t);
if (cur == NULL)
return API_EINVAL;
- base = (unsigned long *)va_arg(ap, u_int32_t);
+ base = (unsigned long *)va_arg(ap, uintptr_t);
if (base == NULL)
return API_EINVAL;
@@ -199,7 +199,7 @@ static int API_dev_enum(va_list ap)
struct device_info *di;
/* arg is ptr to the device_info struct we are going to fill out */
- di = (struct device_info *)va_arg(ap, u_int32_t);
+ di = (struct device_info *)va_arg(ap, uintptr_t);
if (di == NULL)
return API_EINVAL;
@@ -233,7 +233,7 @@ static int API_dev_open(va_list ap)
int err = 0;
/* arg is ptr to the device_info struct */
- di = (struct device_info *)va_arg(ap, u_int32_t);
+ di = (struct device_info *)va_arg(ap, uintptr_t);
if (di == NULL)
return API_EINVAL;
@@ -265,7 +265,7 @@ static int API_dev_close(va_list ap)
int err = 0;
/* arg is ptr to the device_info struct */
- di = (struct device_info *)va_arg(ap, u_int32_t);
+ di = (struct device_info *)va_arg(ap, uintptr_t);
if (di == NULL)
return API_EINVAL;
@@ -319,7 +319,7 @@ static int API_dev_write(va_list ap)
int err = 0;
/* 1. arg is ptr to the device_info struct */
- di = (struct device_info *)va_arg(ap, u_int32_t);
+ di = (struct device_info *)va_arg(ap, uintptr_t);
if (di == NULL)
return API_EINVAL;
@@ -329,12 +329,12 @@ static int API_dev_write(va_list ap)
return API_ENODEV;
/* 2. arg is ptr to buffer from where to get data to write */
- buf = (void *)va_arg(ap, u_int32_t);
+ buf = (void *)va_arg(ap, uintptr_t);
if (buf == NULL)
return API_EINVAL;
/* 3. arg is length of buffer */
- len = (int *)va_arg(ap, u_int32_t);
+ len = (int *)va_arg(ap, uintptr_t);
if (len == NULL)
return API_EINVAL;
if (*len <= 0)
@@ -387,7 +387,7 @@ static int API_dev_read(va_list ap)
int *len_net, *act_len_net;
/* 1. arg is ptr to the device_info struct */
- di = (struct device_info *)va_arg(ap, u_int32_t);
+ di = (struct device_info *)va_arg(ap, uintptr_t);
if (di == NULL)
return API_EINVAL;
@@ -397,23 +397,23 @@ static int API_dev_read(va_list ap)
return API_ENODEV;
/* 2. arg is ptr to buffer from where to put the read data */
- buf = (void *)va_arg(ap, u_int32_t);
+ buf = (void *)va_arg(ap, uintptr_t);
if (buf == NULL)
return API_EINVAL;
if (di->type & DEV_TYP_STOR) {
/* 3. arg - ptr to var with # of blocks to read */
- len_stor = (lbasize_t *)va_arg(ap, u_int32_t);
+ len_stor = (lbasize_t *)va_arg(ap, uintptr_t);
if (!len_stor)
return API_EINVAL;
if (*len_stor <= 0)
return API_EINVAL;
/* 4. arg - ptr to var with start block */
- start = (lbastart_t *)va_arg(ap, u_int32_t);
+ start = (lbastart_t *)va_arg(ap, uintptr_t);
/* 5. arg - ptr to var where to put the len actually read */
- act_len_stor = (lbasize_t *)va_arg(ap, u_int32_t);
+ act_len_stor = (lbasize_t *)va_arg(ap, uintptr_t);
if (!act_len_stor)
return API_EINVAL;
@@ -422,14 +422,14 @@ static int API_dev_read(va_list ap)
} else if (di->type & DEV_TYP_NET) {
/* 3. arg points to the var with length of packet to read */
- len_net = (int *)va_arg(ap, u_int32_t);
+ len_net = (int *)va_arg(ap, uintptr_t);
if (!len_net)
return API_EINVAL;
if (*len_net <= 0)
return API_EINVAL;
/* 4. - ptr to var where to put the len actually read */
- act_len_net = (int *)va_arg(ap, u_int32_t);
+ act_len_net = (int *)va_arg(ap, uintptr_t);
if (!act_len_net)
return API_EINVAL;
@@ -453,9 +453,9 @@ static int API_env_get(va_list ap)
{
char *name, **value;
- if ((name = (char *)va_arg(ap, u_int32_t)) == NULL)
+ if ((name = (char *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
- if ((value = (char **)va_arg(ap, u_int32_t)) == NULL)
+ if ((value = (char **)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
*value = getenv(name);
@@ -476,9 +476,9 @@ static int API_env_set(va_list ap)
{
char *name, *value;
- if ((name = (char *)va_arg(ap, u_int32_t)) == NULL)
+ if ((name = (char *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
- if ((value = (char *)va_arg(ap, u_int32_t)) == NULL)
+ if ((value = (char *)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
setenv(name, value);
@@ -498,9 +498,9 @@ static int API_env_enum(va_list ap)
int i, n;
char *last, **next;
- last = (char *)va_arg(ap, u_int32_t);
+ last = (char *)va_arg(ap, uintptr_t);
- if ((next = (char **)va_arg(ap, u_int32_t)) == NULL)
+ if ((next = (char **)va_arg(ap, uintptr_t)) == NULL)
return API_EINVAL;
if (last == NULL)
@@ -586,7 +586,7 @@ static cfp_t calls_table[API_MAXCALL] = { NULL, };
* The main syscall entry point - this is not reentrant, only one call is
* serviced until finished.
*
- * e.g. syscall(1, int *, u_int32_t, u_int32_t, u_int32_t, u_int32_t);
+ * e.g. syscall(1, int *, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
*
* call: syscall number
*
diff --git a/examples/api/crt0.S b/examples/api/crt0.S
index 78d35a2..eb6312e 100644
--- a/examples/api/crt0.S
+++ b/examples/api/crt0.S
@@ -25,6 +25,22 @@ syscall:
mtctr %r11
bctr
+#elif defined(CONFIG_ARM64)
+
+ .text
+ .globl _start
+_start:
+ ldr x14, =search_hint
+ mov x15, sp
+ str x15, [x14]
+ b main
+
+
+ .globl syscall
+syscall:
+ ldr x15, syscall_ptr
+ br x15
+
#elif defined(CONFIG_ARM)
.text
@@ -45,10 +61,10 @@ syscall:
#endif
.globl syscall_ptr
+ .align 3
syscall_ptr:
- .align 4
- .long 0
+ .quad 0
.globl search_hint
search_hint:
- .long 0
+ .quad 0
diff --git a/examples/api/demo.c b/examples/api/demo.c
index 8c30457..e1693ef 100644
--- a/examples/api/demo.c
+++ b/examples/api/demo.c
@@ -43,12 +43,11 @@ int main(int argc, char * const argv[])
if (sig->version > API_SIG_VERSION)
return -3;
- printf("API signature found @%x\n", (unsigned int)sig);
+ printf("API signature found @0x%p\n", sig);
test_dump_sig(sig);
printf("\n*** Consumer API test ***\n");
- printf("syscall ptr 0x%08x@%08x\n", (unsigned int)syscall_ptr,
- (unsigned int)&syscall_ptr);
+ printf("syscall ptr 0x%p @0x%p\n", syscall_ptr, &syscall_ptr);
/* console activities */
ub_putc('B');
@@ -203,7 +202,7 @@ void test_dump_sig(struct api_signature *sig)
printf("signature:\n");
printf(" version\t= %d\n", sig->version);
printf(" checksum\t= 0x%08x\n", sig->checksum);
- printf(" sc entry\t= 0x%08x\n", (unsigned int)sig->syscall);
+ printf(" sc entry\t= 0x%p\n", (void *)sig->syscall);
}
void test_dump_si(struct sys_info *si)
@@ -296,7 +295,7 @@ void test_dump_di(int handle)
struct device_info *di = ub_dev_get(handle);
printf("device info (%d):\n", handle);
- printf(" cookie\t= 0x%08x\n", (uint32_t)di->cookie);
+ printf(" cookie\t= 0x%p\n", di->cookie);
printf(" type\t\t= 0x%08x\n", di->type);
if (di->type == DEV_TYP_NET) {
diff --git a/examples/api/glue.c b/examples/api/glue.c
index d619518..d5c1809 100644
--- a/examples/api/glue.c
+++ b/examples/api/glue.c
@@ -41,8 +41,8 @@ static int valid_sig(struct api_signature *sig)
int api_search_sig(struct api_signature **sig)
{
unsigned char *sp;
- uint32_t search_start = 0;
- uint32_t search_end = 0;
+ uintptr_t search_start = 0;
+ uintptr_t search_end = 0;
if (sig == NULL)
return 0;
@@ -77,7 +77,7 @@ int ub_getc(void)
{
int c;
- if (!syscall(API_GETC, NULL, (uint32_t)&c))
+ if (!syscall(API_GETC, NULL, (uintptr_t)&c))
return -1;
return c;
@@ -87,7 +87,7 @@ int ub_tstc(void)
{
int t;
- if (!syscall(API_TSTC, NULL, (uint32_t)&t))
+ if (!syscall(API_TSTC, NULL, (uintptr_t)&t))
return -1;
return t;
@@ -95,12 +95,12 @@ int ub_tstc(void)
void ub_putc(char c)
{
- syscall(API_PUTC, NULL, (uint32_t)&c);
+ syscall(API_PUTC, NULL, (uintptr_t)&c);
}
void ub_puts(const char *s)
{
- syscall(API_PUTS, NULL, (uint32_t)s);
+ syscall(API_PUTS, NULL, (uintptr_t)s);
}
/****************************************
@@ -126,7 +126,7 @@ struct sys_info * ub_get_sys_info(void)
si.mr_no = UB_MAX_MR;
memset(&mr, 0, sizeof(mr));
- if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si))
+ if (!syscall(API_GET_SYS_INFO, &err, (uintptr_t)&si))
return NULL;
return ((err) ? NULL : &si);
@@ -344,7 +344,7 @@ char * ub_env_get(const char *name)
{
char *value;
- if (!syscall(API_ENV_GET, NULL, (uint32_t)name, (uint32_t)&value))
+ if (!syscall(API_ENV_GET, NULL, (uintptr_t)name, (uintptr_t)&value))
return NULL;
return value;
@@ -352,7 +352,7 @@ char * ub_env_get(const char *name)
void ub_env_set(const char *name, char *value)
{
- syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value);
+ syscall(API_ENV_SET, NULL, (uintptr_t)name, (uintptr_t)value);
}
static char env_name[256];
@@ -369,7 +369,7 @@ const char * ub_env_enum(const char *last)
* 'name=val' string), since the API_ENUM_ENV call uses envmatch()
* internally, which handles such case
*/
- if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env))
+ if (!syscall(API_ENV_ENUM, NULL, (uintptr_t)last, (uintptr_t)&env))
return NULL;
if (!env)
@@ -396,7 +396,8 @@ int ub_display_get_info(int type, struct display_info *di)
{
int err = 0;
- if (!syscall(API_DISPLAY_GET_INFO, &err, (uint32_t)type, (uint32_t)di))
+ if (!syscall(API_DISPLAY_GET_INFO, &err, (uintptr_t)type,
+ (uintptr_t)di))
return API_ESYSC;
return err;
diff --git a/examples/api/glue.h b/examples/api/glue.h
index 91c8c1c..3e27a4e 100644
--- a/examples/api/glue.h
+++ b/examples/api/glue.h
@@ -19,7 +19,7 @@
#define UB_MAX_DEV 6 /* max devices number */
extern void *syscall_ptr;
-extern uint32_t search_hint;
+extern uintptr_t search_hint;
int syscall(int, int *, ...);
int api_search_sig(struct api_signature **sig);
diff --git a/examples/api/libgenwrap.c b/examples/api/libgenwrap.c
index c1afa5b..4f78c15 100644
--- a/examples/api/libgenwrap.c
+++ b/examples/api/libgenwrap.c
@@ -23,7 +23,7 @@ int printf (const char *fmt, ...)
{
va_list args;
uint i;
- char printbuffer[256];
+ char printbuffer[512];
va_start (args, fmt);
[-- Attachment #4 --]
Index: sys/arm64/arm64/machdep.c
===================================================================
--- sys/arm64/arm64/machdep.c (revision 292455)
+++ sys/arm64/arm64/machdep.c (working copy)
@@ -766,8 +766,19 @@
try_load_dtb(caddr_t kmdp)
{
vm_offset_t dtbp;
+ struct mem_region mem_regions[FDT_MEM_REGIONS];
+ uint32_t memsize; /* XXX: fdt_get_mem_regions() can't handle 64-bit */
+ int i, mem_regions_sz;
dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
+#ifdef FDT_DTB_STATIC
+ /*
+ * If the device tree blob was not retrieved from metadata,
+ * try to use the statically embedded one.
+ */
+ if (dtbp == (vm_offset_t)NULL)
+ dtbp = (vm_offset_t)&fdt_static_dtb;
+#endif
if (dtbp == (vm_offset_t)NULL) {
printf("ERROR loading DTB\n");
return;
@@ -778,6 +789,19 @@
if (OF_init((void *)dtbp) != 0)
panic("OF_init failed with the found device tree");
+
+ /* Grab physical memory regions information from device tree. */
+ if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, &memsize) != 0) {
+ printf("No physical memory regions in DTB\n");
+ return;
+ }
+
+ for (i = 0; i < mem_regions_sz; i++) {
+ if (!add_physmap_entry(mem_regions[i].mr_start,
+ mem_regions[i].mr_size, physmap,
+ &physmap_idx))
+ break;
+ }
}
#endif
@@ -822,10 +846,6 @@
boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
-#ifdef FDT
- try_load_dtb(kmdp);
-#endif
-
/* Find the address to start allocating from */
lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);
@@ -833,8 +853,13 @@
physmap_idx = 0;
efihdr = (struct efi_map_header *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_EFI_MAP);
- add_efi_map_entries(efihdr, physmap, &physmap_idx);
+ if (efihdr != NULL)
+ add_efi_map_entries(efihdr, physmap, &physmap_idx);
+#ifdef FDT
+ try_load_dtb(kmdp);
+#endif
+
/* Print the memory map */
mem_len = 0;
for (i = 0; i < physmap_idx; i += 2) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?195ED9AE-7759-4833-846D-949BD6F85735>
