From owner-svn-src-all@FreeBSD.ORG Tue Oct 14 10:11:15 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 854861065686; Tue, 14 Oct 2008 10:11:15 +0000 (UTC) (envelope-from raj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71C878FC25; Tue, 14 Oct 2008 10:11:15 +0000 (UTC) (envelope-from raj@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m9EABFlH002291; Tue, 14 Oct 2008 10:11:15 GMT (envelope-from raj@svn.freebsd.org) Received: (from raj@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9EABEJW002276; Tue, 14 Oct 2008 10:11:14 GMT (envelope-from raj@svn.freebsd.org) Message-Id: <200810141011.m9EABEJW002276@svn.freebsd.org> From: Rafal Jaworowski Date: Tue, 14 Oct 2008 10:11:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r183878 - in head/sys: arm/arm arm/include boot boot/arm boot/arm/uboot boot/common boot/ficl boot/uboot/lib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Oct 2008 10:11:15 -0000 Author: raj Date: Tue Oct 14 10:11:14 2008 New Revision: 183878 URL: http://svn.freebsd.org/changeset/base/183878 Log: Initial support of loader(8) for ARM machines running U-Boot. This uses the common U-Boot support lib (sys/boot/uboot, already used on FreeBSD/powerpc), and assumes the underlying firmware has the modern API for stand-alone apps enabled in the config (CONFIG_API). Only netbooting is supported at the moment. Obtained from: Marvell, Semihalf Added: head/sys/arm/include/bootinfo.h (contents, props changed) head/sys/boot/arm/uboot/ head/sys/boot/arm/uboot/Makefile (contents, props changed) head/sys/boot/arm/uboot/conf.c (contents, props changed) head/sys/boot/arm/uboot/help.uboot (contents, props changed) head/sys/boot/arm/uboot/ldscript.arm (contents, props changed) head/sys/boot/arm/uboot/start.S (contents, props changed) head/sys/boot/arm/uboot/version (contents, props changed) Modified: head/sys/arm/arm/locore.S head/sys/arm/include/metadata.h head/sys/boot/Makefile head/sys/boot/arm/Makefile head/sys/boot/common/Makefile.inc head/sys/boot/common/load_elf.c head/sys/boot/ficl/Makefile head/sys/boot/uboot/lib/glue.c Modified: head/sys/arm/arm/locore.S ============================================================================== --- head/sys/arm/arm/locore.S Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/arm/arm/locore.S Tue Oct 14 10:11:14 2008 (r183878) @@ -66,6 +66,13 @@ __FBSDID("$FreeBSD$"); ENTRY_NP(btext) ASENTRY_NP(_start) + +/* + * Move metadata ptr to r12 (ip) + */ + + mov ip, r0 + #if defined (FLASHADDR) && defined(LOADERRAMADDR) /* Check if we're running from flash. */ ldr r7, =FLASHADDR @@ -170,6 +177,8 @@ mmu_done: ldr pc, .Lvirt_done virt_done: + mov r0, ip /* Load argument: metadata ptr */ + mov fp, #0 /* trace back starts here */ bl _C_LABEL(initarm) /* Off we go */ Added: head/sys/arm/include/bootinfo.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/include/bootinfo.h Tue Oct 14 10:11:14 2008 (r183878) @@ -0,0 +1,72 @@ +/*- + * Copyright (C) 2006-2008 Semihalf, Marian Balakowicz + * 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_BOOTINFO_H_ +#define _MACHINE_BOOTINFO_H_ + +#if !defined(LOCORE) + +/* Platform hardware spec, received from loader(8) */ + +#define BI_VERSION 1 + +struct bi_mem_region { + vm_paddr_t mem_base; + vm_size_t mem_size; +}; + +struct bi_eth_addr { + u_int8_t mac_addr[6]; + u_int8_t padding[2]; +}; + +struct bootinfo { + u_int32_t bi_version; + vm_offset_t bi_bar_base; + u_int32_t bi_cpu_clk; + u_int32_t bi_bus_clk; + u_int8_t bi_mem_reg_no; + u_int8_t bi_eth_addr_no; + u_int8_t padding[2]; + + u_int8_t bi_data[1]; + /* + * The bi_data container is allocated in run time and has the + * following layout: + * + * - bi_mem_reg_no elements of struct bi_mem_region + * - bi_eth_addr_no elements of struct bi_eth_addr + */ +}; + +extern struct bootinfo *bootinfo; + +struct bi_mem_region *bootinfo_mr(void); +struct bi_eth_addr *bootinfo_eth(void); +#endif + +#endif /* _MACHINE_BOOTINFO_H_ */ Modified: head/sys/arm/include/metadata.h ============================================================================== --- head/sys/arm/include/metadata.h Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/arm/include/metadata.h Tue Oct 14 10:11:14 2008 (r183878) @@ -29,6 +29,6 @@ #ifndef _MACHINE_METADATA_H_ #define _MACHINE_METADATA_H_ -#define MODINFOMD_SMAP 0x1001 +#define MODINFOMD_BOOTINFO 0x1001 #endif /* !_MACHINE_METADATA_H_ */ Modified: head/sys/boot/Makefile ============================================================================== --- head/sys/boot/Makefile Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/boot/Makefile Tue Oct 14 10:11:14 2008 (r183878) @@ -22,7 +22,7 @@ SUBDIR+= ofw .endif # Build U-Boot library. -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "arm" SUBDIR+= uboot .endif Modified: head/sys/boot/arm/Makefile ============================================================================== --- head/sys/boot/arm/Makefile Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/boot/arm/Makefile Tue Oct 14 10:11:14 2008 (r183878) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= +SUBDIR= uboot .include Added: head/sys/boot/arm/uboot/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/arm/uboot/Makefile Tue Oct 14 10:11:14 2008 (r183878) @@ -0,0 +1,96 @@ +# $FreeBSD$ + +PROG= ubldr +NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} +BINDIR?= /boot +INSTALLFLAGS= -b +NO_MAN= +WARNS?= 1 + +# Architecture-specific loader code +SRCS= start.S conf.c vers.c + +LOADER_DISK_SUPPORT?= no +LOADER_UFS_SUPPORT?= no +LOADER_CD9660_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= no +LOADER_BZIP2_SUPPORT?= no + +.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_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 !defined(NO_FORTH) +# Enable BootForth +BOOT_FORTH= yes +CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/arm +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 ${PROG}.help + +CFLAGS+= -ffreestanding + +LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.arm + +# 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/ + +DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBUBOOT} -lstand + +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version + sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} + +${PROG}.help: help.common help.uboot + cat ${.ALLSRC} | \ + awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} + +.PATH: ${.CURDIR}/../../forth +FILES= ${PROG}.help + +.include Added: head/sys/boot/arm/uboot/conf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/arm/uboot/conf.c Tue Oct 14 10:11:14 2008 (r183878) @@ -0,0 +1,91 @@ +/*- + * 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 +__FBSDID("$FreeBSD$"); + +#include +#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_disk, +#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_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 +}; Added: head/sys/boot/arm/uboot/help.uboot ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/arm/uboot/help.uboot Tue Oct 14 10:11:14 2008 (r183878) @@ -0,0 +1 @@ +$FreeBSD$ Added: head/sys/boot/arm/uboot/ldscript.arm ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/arm/uboot/ldscript.arm Tue Oct 14 10:11:14 2008 (r183878) @@ -0,0 +1,134 @@ +/* $FreeBSD$ */ + +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x1000000 + SIZEOF_HEADERS; + .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) } + .text : + { + *(.text) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =0 + _etext = .; + PROVIDE (etext = .); + .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 . */ +} Added: head/sys/boot/arm/uboot/start.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/arm/uboot/start.S Tue Oct 14 10:11:14 2008 (r183878) @@ -0,0 +1,93 @@ +/*- + * 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 + +/* + * Entry point to the loader that U-Boot passes control to. + */ + .text + .globl _start +_start: + /* Hint where to look for the API signature */ + ldr ip, =uboot_address + str sp, [ip] + + /* Save U-Boot's r8 */ + ldr ip, =saved_regs + str r8, [ip, #0] + + /* Start loader */ + b main + +/* + * syscall() + */ +ENTRY(syscall) + /* Save caller's lr */ + ldr ip, =saved_regs + str lr, [ip, #4] + /* Save loader's r8 */ + ldr ip, =saved_regs + str r8, [ip, #8] + + /* Restore U-Boot's r8 */ + ldr ip, =saved_regs + ldr r8, [ip, #0] + /* Call into U-Boot */ + ldr lr, =return_from_syscall + ldr ip, =syscall_ptr + ldr pc, [ip] + +return_from_syscall: + /* Restore loader's r8 */ + ldr ip, =saved_regs + ldr r8, [ip, #8] + /* Restore caller's lr */ + ldr ip, =saved_regs + ldr lr, [ip, #4] + /* Return to caller */ + mov pc, lr + +/* + * Data section + */ + .data + .align 4 + .globl syscall_ptr +syscall_ptr: + .long 0 + + .globl uboot_address +uboot_address: + .long 0 + +saved_regs: + .long 0 /* U-Boot's r8 */ + .long 0 /* Loader's r8 */ + .long 0 /* Loader's lr */ Added: head/sys/boot/arm/uboot/version ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/arm/uboot/version Tue Oct 14 10:11:14 2008 (r183878) @@ -0,0 +1,6 @@ +$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. + +0.5: Initial U-Boot/arm version (netbooting only). Modified: head/sys/boot/common/Makefile.inc ============================================================================== --- head/sys/boot/common/Makefile.inc Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/boot/common/Makefile.inc Tue Oct 14 10:11:14 2008 (r183878) @@ -9,7 +9,7 @@ SRCS+= load_elf32.c load_elf32_obj.c rel SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c .elif ${MACHINE} == "pc98" SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c -.elif ${MACHINE_ARCH} == "powerpc" +.elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "arm" SRCS+= load_elf32.c reloc_elf32.c .elif ${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} == "ia64" SRCS+= load_elf64.c reloc_elf64.c Modified: head/sys/boot/common/load_elf.c ============================================================================== --- head/sys/boot/common/load_elf.c Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/boot/common/load_elf.c Tue Oct 14 10:11:14 2008 (r183878) @@ -289,7 +289,16 @@ __elfN(loadimage)(struct preloaded_file #ifdef ELF_VERBOSE printf("Converted entry 0x%08x\n", ehdr->e_entry); #endif - } else + } else + off = 0; +#elif defined(__arm__) + if (off & 0xf0000000u) { + off = -(off & 0xf0000000u); + ehdr->e_entry += off; +#ifdef ELF_VERBOSE + printf("Converted entry 0x%08x\n", ehdr->e_entry); +#endif + } else off = 0; #else off = 0; /* other archs use direct mapped kernels */ Modified: head/sys/boot/ficl/Makefile ============================================================================== --- head/sys/boot/ficl/Makefile Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/boot/ficl/Makefile Tue Oct 14 10:11:14 2008 (r183878) @@ -14,7 +14,7 @@ CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -m .if ${MACHINE_ARCH} == "i386" CFLAGS+= -mno-sse3 .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "arm" CFLAGS+= -msoft-float .endif .if ${MACHINE} == "pc98" Modified: head/sys/boot/uboot/lib/glue.c ============================================================================== --- head/sys/boot/uboot/lib/glue.c Tue Oct 14 10:09:32 2008 (r183877) +++ head/sys/boot/uboot/lib/glue.c Tue Oct 14 10:11:14 2008 (r183878) @@ -147,7 +147,7 @@ api_search_sig(struct api_signature **si uboot_address = 255 * 1024 * 1024; sp = (void *)(uboot_address & ~0x000fffff); - spend = sp + 0x00100000 - API_SIG_MAGLEN; + spend = sp + 0x00300000 - API_SIG_MAGLEN; while (sp < spend) { if (!bcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) { *sig = (struct api_signature *)sp;