Index: share/mk/src.opts.mk =================================================================== --- share/mk/src.opts.mk +++ share/mk/src.opts.mk @@ -315,8 +315,8 @@ .if ${__T:Mpowerpc*} == "" BROKEN_OPTIONS+=LOADER_OFW .endif -# UBOOT is only for arm, mips and powerpc, exclude others -.if ${__T:Marm*} == "" && ${__T:Mmips*} == "" && ${__T:Mpowerpc*} == "" +# UBOOT is only for arm, and big-endian powerpc +.if (${__T:Marm*} == "" && ${__fT:Mpowerpc*} == "") || ${__T} == "powerpc64le" BROKEN_OPTIONS+=LOADER_UBOOT .endif # GELI and Lua in loader currently cause boot failures on powerpc. Index: stand/Makefile =================================================================== --- stand/Makefile +++ stand/Makefile @@ -81,6 +81,11 @@ SUBDIR_DEPEND_efi+= fdt .endif +SUBDIR_DEPEND_uboot+= ${INTERP_DEPENDS} +.if ${MK_FDT} != "no" +SUBDIR_DEPEND_uboot+= fdt +.endif + SUBDIR_PARALLEL= yes .include Index: stand/arm/Makefile =================================================================== --- stand/arm/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD$ - -NO_OBJ=t - -SUBDIR= uboot - -.include Index: stand/arm/Makefile.inc =================================================================== --- stand/arm/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -.include "../Makefile.inc" Index: stand/arm/uboot/Makefile =================================================================== --- stand/arm/uboot/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# $FreeBSD$ - -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= no -LOADER_MSDOS_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 - -.include - -FILES+= ubldr ubldr.bin - -NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} -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 ${COMPILER_TYPE} == "gcc" -CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized -.endif - -HELP_FILES= ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt - -# Always add MI sources -.include "${BOOTSRC}/loader.mk" - -LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH} -LDFLAGS+= -Wl,-znotext - -# Pull in common loader code -.include "${BOOTSRC}/uboot.mk" - -CFLAGS+= -fPIC - -DPADD= ${LDR_INTERP} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} -LDADD= ${LDR_INTERP} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} - -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -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 - -.include Index: stand/arm/uboot/conf.c =================================================================== --- /dev/null +++ stand/arm/uboot/conf.c @@ -1,94 +0,0 @@ -/*- - * 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 - -/* Make sure we have an explicit reference to exit so libsa's panic pulls in the MD exit */ -void (*exitfn)(int) = exit; - -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_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: stand/arm/uboot/help.uboot =================================================================== --- /dev/null +++ stand/arm/uboot/help.uboot @@ -1,27 +0,0 @@ -$FreeBSD$ - -############################################################################### -# Tubenv DShow or import U-Boot environment variables - - ubenv [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: stand/arm/uboot/ldscript.arm =================================================================== --- /dev/null +++ stand/arm/uboot/ldscript.arm @@ -1,134 +0,0 @@ -/* $FreeBSD$ */ - -OUTPUT_ARCH(arm) -ENTRY(_start) -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = UBLDR_LOADADDR + SIZEOF_HEADERS; - . = ALIGN(8); - .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) } - .dynamic : { *(.dynamic) } - PROVIDE (_GOT_START_ = .); - .got : { *(.got) } - .got.plt : { *(.got.plt) } - PROVIDE (_GOT_END_ = .); - .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 doubleword boundary. */ - . = ALIGN(8); - .data : - { - *(.data) - *(.gnu.linkonce.d*) - CONSTRUCTORS - } - .data1 : { *(.data1) } - .got1 : { *(.got1) } - /* 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_ = .); - /* 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: stand/arm/uboot/start.S =================================================================== --- /dev/null +++ stand/arm/uboot/start.S @@ -1,143 +0,0 @@ -/*- - * 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 -#include - - .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: - - mrc p15, 0, ip, c1, c0, 0 - orr ip, ip, #(CPU_CONTROL_UNAL_ENABLE) - orr ip, ip, #(CPU_CONTROL_AFLT_ENABLE) - mcr p15, 0, ip, c1, c0, 0 - - /* Save the arguments and return register before calling self_reloc */ - push {r0, r1, r9, lr} - - /* - * 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. - */ - adr ip, .here_off /* .here_off is a symbol whose value */ - ldr r0, [ip] /* is its own offset in the text seg. */ - sub r0, ip, r0 /* Get its pc-relative address and */ - ldr r1, .dynamic_off /* subtract its value and we get */ - teq r1, #0 /* r0 = physaddr we were loaded at. */ - addne r1, r1, r0 /* r1 = dynamic section physaddr. */ - blne _C_LABEL(self_reloc) /* Do reloc if _DYNAMIC is non-NULL. */ - - /* Restore saved arguments */ - pop {r0, r1, r9, lr} - - /* Hint where to look for the API signature */ - ldr ip, =uboot_address - str sp, [ip] - - /* Save U-Boot's r8 and r9 for syscall trampoline */ - ldr ip, =saved_regs - str r8, [ip, #0] /* old gd pointer (use to hold lr) */ - str r9, [ip, #4] /* new gd pointer */ - - /* - * Start loader. Save return address first (r8 is available from - * trampoline save). - */ - mov r8, lr - bl main - mov lr, r8 - - /* Restore U-Boot environment */ - ldr ip, =saved_regs - ldr r8, [ip, #0] - ldr r9, [ip, #4] - mov pc, lr - - /* - * Data for self-relocation, in the text segment for pc-rel access. - */ -.here_off: - .word . -.dynamic_off: - .word _DYNAMIC - -/* - * syscall() - */ -ENTRY(syscall) - /* Save caller's lr, r8 and r9 */ - ldr ip, =saved_regs - str r8, [ip, #8] - str r9, [ip, #12] - str lr, [ip, #16] - /* Restore U-Boot's r8 and r9 */ - ldr r8, [ip, #0] - ldr r9, [ip, #4] - /* Call into U-Boot */ - ldr lr, =return_from_syscall - ldr ip, =syscall_ptr - ldr pc, [ip] -return_from_syscall: - /* Restore loader's r8, r9 and lr */ - ldr ip, =saved_regs - ldr lr, [ip, #16] - ldr r9, [ip, #12] - ldr r8, [ip, #8] - /* 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 /* U-Boot's r9 */ - .long 0 /* Loader's r8 */ - .long 0 /* Loader's r9 */ - .long 0 /* Loader's lr */ Index: stand/arm/uboot/version =================================================================== --- stand/arm/uboot/version +++ /dev/null @@ -1,10 +0,0 @@ -$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.3: Remove NAND FS support. -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: stand/powerpc/Makefile =================================================================== --- stand/powerpc/Makefile +++ stand/powerpc/Makefile @@ -6,10 +6,6 @@ SUBDIR.yes= boot1.chrp ofw -.if "${MACHINE_ARCH}" != "powerpc64le" -SUBDIR.${MK_FDT}+= uboot -.endif - .if "${MACHINE_ARCH}" == "powerpc64" SUBDIR.${MK_FDT}+= kboot .endif Index: stand/powerpc/uboot/Makefile =================================================================== --- stand/powerpc/uboot/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# $FreeBSD$ - -LOADER_UFS_SUPPORT?= yes -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 - -.include - -BINDIR= /boot/uboot -PROG= ubldr -NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} -INSTALLFLAGS= -b - -# Architecture-specific loader code -SRCS= start.S conf.c vers.c ppc64_elf_freebsd.c -SRCS+= ucmpdi2.c - -# Always add MI sources -.include "${BOOTSRC}/loader.mk" -.PATH: ${SYSDIR}/libkern - -LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc - -.include "${BOOTSRC}/uboot.mk" - -DPADD= ${LDR_INTERP} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} -LDADD= ${LDR_INTERP} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} - -MK_PIE= no - -.include Index: stand/powerpc/uboot/conf.c =================================================================== --- /dev/null +++ stand/powerpc/uboot/conf.c @@ -1,114 +0,0 @@ -/*- - * Copyright (c) 1999 Michael Smith - * 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 - -/* Make sure we have an explicit reference to exit so libsa's panic pulls in the MD exit */ -void (*exitfn)(int) = exit; - -/* - * We could use linker sets for some or all of these, but - * then we would have to control what ended up linked into - * the bootstrap. So it's easier to conditionalise things - * here. - * - * XXX rename these arrays to be consistent and less namespace-hostile - */ - -/* Exported for libstand */ -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_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, -}; - -/* Exported for PowerPC only */ -/* - * Sort formats so that those that can detect based on arguments - * rather than reading the file go first. - */ -extern struct file_format uboot_elf64; - -struct file_format *file_formats[] = { - &uboot_elf, - &uboot_elf64, - NULL -}; - -/* - * Consoles - */ -extern struct console uboot_console; - -struct console *consoles[] = { - &uboot_console, - NULL -}; Index: stand/powerpc/uboot/ldscript.powerpc =================================================================== --- /dev/null +++ stand/powerpc/uboot/ldscript.powerpc @@ -1,138 +0,0 @@ -/* $FreeBSD$ */ - -OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", - "elf32-powerpc-freebsd") -OUTPUT_ARCH(powerpc:common) -ENTRY(_start) -SEARCH_DIR(/usr/lib); -PROVIDE (__stack = 0); -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = 0x00010000 + 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 . */ -} - Index: stand/powerpc/uboot/ppc64_elf_freebsd.c =================================================================== --- /dev/null +++ stand/powerpc/uboot/ppc64_elf_freebsd.c @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 2001 Benno Rice - * 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$"); - -#define __ELF_WORD_SIZE 64 - -#include -#include - -#include -#include -#include - -#include - -#include "bootstrap.h" -#include "libuboot.h" - -vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb); -extern char end[]; -extern vm_offset_t reloc; /* From /conf.c */ - -int -ppc64_uboot_elf_loadfile(char *filename, uint64_t dest, - struct preloaded_file **result) -{ - int r; - - r = __elfN(loadfile)(filename, dest, result); - if (r != 0) - return (r); - - /* - * No need to sync the icache for modules: this will - * be done by the kernel after relocation. - */ - if (!strcmp((*result)->f_type, "elf kernel")) - __syncicache((void *) (*result)->f_addr, (*result)->f_size); - return (0); -} - -int -ppc64_uboot_elf_exec(struct preloaded_file *fp) -{ - struct file_metadata *fmp; - vm_offset_t mdp, dtbp; - Elf_Ehdr *e; - int error; - void (*entry)(void *); - - if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { - return(EFTYPE); - } - e = (Elf_Ehdr *)&fmp->md_data; - - /* Handle function descriptor for ELFv1 kernels */ - if ((e->e_flags & 3) == 2) - entry = (void (*)(void*))(intptr_t)e->e_entry; - else - entry = *(void (*)(void*))(uint64_t *)(intptr_t)e->e_entry; - - if ((error = md_load64(fp->f_args, &mdp, &dtbp)) != 0) - return (error); - - dev_cleanup(); - printf("Kernel args: %s\n", fp->f_args); - - (*entry)((void *)mdp); - panic("exec returned"); -} - -struct file_format uboot_elf64 = -{ - ppc64_uboot_elf_loadfile, - ppc64_uboot_elf_exec -}; Index: stand/powerpc/uboot/start.S =================================================================== --- /dev/null +++ stand/powerpc/uboot/start.S @@ -1,100 +0,0 @@ -/*- - * Copyright (c) 2007 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. - * - * $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 */ - lis %r11, uboot_address@ha - addi %r11, %r11, uboot_address@l - stw %r1, 0(%r11) - /* Save U-Boot's r14 and r30 */ - lis %r11, saved_regs@ha - addi %r11, %r11, saved_regs@l - stw %r14, 0(%r11) - stw %r30, 4(%r11) - /* Disable interrupts */ - mfmsr %r11 - andi. %r11, %r11, ~0x8000@l - mtmsr %r11 - b main - -/* - * syscall() - */ -ENTRY(syscall) - stwu %r1, -32(%r1) - mflr %r0 - stw %r14, 8(%r1) - stw %r30, 12(%r1) - stw %r0, 36(%r1) - /* Restore U-Boot's r14 and r30 */ - lis %r11, saved_regs@ha - addi %r11, %r11, saved_regs@l - lwz %r14, 0(%r11) - lwz %r30, 4(%r11) - /* Enable interrupts */ - mfmsr %r11 - ori %r11, %r11, 0x8000@l - mtmsr %r11 - /* Call into U-Boot */ - lis %r11, syscall_ptr@ha - addi %r11, %r11, syscall_ptr@l - lwz %r11, 0(%r11) - mtctr %r11 - bctrl - /* Disable interrupts */ - mfmsr %r11 - andi. %r11, %r11, ~0x8000@l - mtmsr %r11 - /* Epilogue */ - lwz %r11, 0(%r1) - lwz %r0, 4(%r11) - mtlr %r0 - lwz %r14, 8(%r1) - lwz %r30, 12(%r1) - mr %r1, %r11 - blr -END(syscall) - -/* - * Data section - */ - .data -GLOBAL(syscall_ptr) - .long 0 -GLOBAL(saved_regs) - .long 0 /* R14 */ - .long 0 /* R30 */ -GLOBAL(uboot_address) - .long 0 Index: stand/powerpc/uboot/version =================================================================== --- stand/powerpc/uboot/version +++ /dev/null @@ -1,11 +0,0 @@ -$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.1: Flattened Device Tree blob support. -1.0: Added storage support. -0.6: Integrated with the new U-Boot API -0.5: Full network functionality. -0.2: Initial U-Boot/PowerPC version derived from the existing - OpenFirmware-based. Index: stand/uboot.mk =================================================================== --- stand/uboot.mk +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ - -SRCS+= main.c - -.PATH: ${UBOOTSRC}/common - -CFLAGS+= -I${UBOOTSRC}/common - -# U-Boot standalone support library -LIBUBOOT= ${BOOTOBJ}/uboot/lib/libuboot.a -CFLAGS+= -I${UBOOTSRC}/lib -CFLAGS+= -I${BOOTOBJ}/uboot/lib -.if ${MACHINE_CPUARCH} == "arm" -SRCS+= metadata.c -.endif - -.include "${BOOTSRC}/fdt.mk" - -.if ${MK_FDT} == "yes" -LIBUBOOT_FDT= ${BOOTOBJ}/uboot/fdt/libuboot_fdt.a -.endif Index: stand/uboot/Makefile =================================================================== --- stand/uboot/Makefile +++ stand/uboot/Makefile @@ -1,9 +1,82 @@ # $FreeBSD$ +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= no +LOADER_MSDOS_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 +LOADER_DISK_SUPPORT?= yes + .include -SUBDIR.yes= lib +.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc" + +.if ${MK_PIE} == "yes" +FILES+= ubldr ubldr.bin +OBJS+= ${SRCS:N*.h:R:S/$/.o/g} +.else +PROG= ubldr +.endif + +NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} +BINDIR= /boot/uboot +INSTALLFLAGS= -b +WARNS?= 1 + +.PATH: ${BOOTSRC}/common +.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH} + + +.if ${COMPILER_TYPE} == "gcc" +CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized +.endif + +HELP_FILES= ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt + +# Always add MI sources +.include "${BOOTSRC}/loader.mk" + +LDSCRIPT= ${.CURDIR}/arch/${MACHINE_CPUARCH}/ldscript.${MACHINE_CPUARCH} +LDFLAGS= -nostdlib -static -T ${LDSCRIPT} +LDFLAGS+= -Wl,-znotext + +SRCS+= main.c vers.c +SRCS+= copy.c devicename.c elf_freebsd.c glue.c +SRCS+= net.c reboot.c time.c gfx_fb.c +SRCS+= uboot_console.c uboot_disk.c uboot_fdt.c uboot_module.c + +CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite +CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/teken +CFLAGS.glue.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib + +CFLAGS+= -I${BOOTSRC}/common +CFLAGS+= -I${.CURDIR} +CFLAGS+= -I${.OBJDIR} + +.if ${MACHINE_CPUARCH} == "arm" +SRCS+= metadata.c +.endif + +.include "${BOOTSRC}/fdt.mk" + +CFLAGS+= -fPIC + +# Pick up the bootstrap header for some interface items +CFLAGS+= -I${LDRSRC} + +# libfdt headers +CFLAGS+= -I${FDTSRC} + +.ifdef(BOOT_DISK_DEBUG) +# Make the disk code more talkative +CFLAGS+= -DDISK_DEBUG +.endif -SUBDIR.${MK_FDT}+=fdt +DPADD= ${LDR_INTERP} ${LIBFDT} ${LIBSA} +LDADD= ${LDR_INTERP} ${LIBFDT} ${LIBSA} -.include +.include Index: stand/uboot/Makefile.inc =================================================================== --- stand/uboot/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -.include "../Makefile.inc" Index: stand/uboot/common/main.c =================================================================== --- /dev/null +++ stand/uboot/common/main.c @@ -1,726 +0,0 @@ -/*- - * Copyright (c) 2000 Benno Rice - * Copyright (c) 2000 Stephane Potvin - * Copyright (c) 2007-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 AUTHORS 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 - -#include "api_public.h" -#include "bootstrap.h" -#include "glue.h" -#include "libuboot.h" - -#ifndef nitems -#define nitems(x) (sizeof((x)) / sizeof((x)[0])) -#endif - -#ifndef HEAP_SIZE -#define HEAP_SIZE (2 * 1024 * 1024) -#endif - -struct uboot_devdesc currdev; -struct arch_switch archsw; /* MI/MD interface boundary */ -int devs_no; - -uintptr_t uboot_heap_start; -uintptr_t uboot_heap_end; - -struct device_type { - const char *name; - int type; -} device_types[] = { - { "disk", DEV_TYP_STOR }, - { "ide", DEV_TYP_STOR | DT_STOR_IDE }, - { "mmc", DEV_TYP_STOR | DT_STOR_MMC }, - { "sata", DEV_TYP_STOR | DT_STOR_SATA }, - { "scsi", DEV_TYP_STOR | DT_STOR_SCSI }, - { "usb", DEV_TYP_STOR | DT_STOR_USB }, - { "net", DEV_TYP_NET } -}; - -extern char end[]; - -extern unsigned char _etext[]; -extern unsigned char _edata[]; -extern unsigned char __bss_start[]; -extern unsigned char __sbss_start[]; -extern unsigned char __sbss_end[]; -extern unsigned char _end[]; - -#ifdef LOADER_FDT_SUPPORT -extern int command_fdt_internal(int argc, char *argv[]); -#endif - -static void -dump_sig(struct api_signature *sig) -{ -#ifdef DEBUG - 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", sig->syscall); -#endif -} - -static void -dump_addr_info(void) -{ -#ifdef DEBUG - printf("\naddresses info:\n"); - printf(" _etext (sdata) = 0x%08x\n", (uint32_t)_etext); - printf(" _edata = 0x%08x\n", (uint32_t)_edata); - printf(" __sbss_start = 0x%08x\n", (uint32_t)__sbss_start); - printf(" __sbss_end = 0x%08x\n", (uint32_t)__sbss_end); - printf(" __sbss_start = 0x%08x\n", (uint32_t)__bss_start); - printf(" _end = 0x%08x\n", (uint32_t)_end); - printf(" syscall entry = 0x%08x\n", (uint32_t)syscall_ptr); -#endif -} - -static uint64_t -memsize(struct sys_info *si, int flags) -{ - uint64_t size; - int i; - - size = 0; - for (i = 0; i < si->mr_no; i++) - if (si->mr[i].flags == flags && si->mr[i].size) - size += (si->mr[i].size); - - return (size); -} - -static void -meminfo(void) -{ - uint64_t size; - struct sys_info *si; - int t[3] = { MR_ATTR_DRAM, MR_ATTR_FLASH, MR_ATTR_SRAM }; - int i; - - if ((si = ub_get_sys_info()) == NULL) - panic("could not retrieve system info"); - - for (i = 0; i < 3; i++) { - size = memsize(si, t[i]); - if (size > 0) - printf("%s: %juMB\n", ub_mem_type(t[i]), - (uintmax_t)(size / 1024 / 1024)); - } -} - -static const char * -get_device_type(const char *devstr, int *devtype) -{ - int i; - int namelen; - struct device_type *dt; - - if (devstr) { - for (i = 0; i < nitems(device_types); i++) { - dt = &device_types[i]; - namelen = strlen(dt->name); - if (strncmp(dt->name, devstr, namelen) == 0) { - *devtype = dt->type; - return (devstr + namelen); - } - } - printf("Unknown device type '%s'\n", devstr); - } - - *devtype = DEV_TYP_NONE; - return (NULL); -} - -static const char * -device_typename(int type) -{ - int i; - - for (i = 0; i < nitems(device_types); i++) - if (device_types[i].type == type) - return (device_types[i].name); - - return (""); -} - -/* - * Parse a device string into type, unit, slice and partition numbers. A - * returned value of -1 for type indicates a search should be done for the - * first loadable device, otherwise a returned value of -1 for unit - * indicates a search should be done for the first loadable device of the - * given type. - * - * The returned values for slice and partition are interpreted by - * disk_open(). - * - * The device string can be a standard loader(8) disk specifier: - * - * disks disk0s1 - * disks disk1s2a - * diskp disk0p4 - * - * or one of the following formats: - * - * Valid device strings: For device types: - * - * DEV_TYP_STOR, DEV_TYP_NET - * DEV_TYP_STOR, DEV_TYP_NET - * : DEV_TYP_STOR, DEV_TYP_NET - * : DEV_TYP_STOR - * :. DEV_TYP_STOR - * :. DEV_TYP_STOR - * - * For valid type names, see the device_types array, above. - * - * Slice numbers are 1-based. 0 is a wildcard. - */ -static void -get_load_device(int *type, int *unit, int *slice, int *partition) -{ - struct disk_devdesc dev; - char *devstr; - const char *p; - char *endp; - - *type = DEV_TYP_NONE; - *unit = -1; - *slice = D_SLICEWILD; - *partition = D_PARTWILD; - - devstr = ub_env_get("loaderdev"); - if (devstr == NULL) { - printf("U-Boot env: loaderdev not set, will probe all devices.\n"); - return; - } - printf("U-Boot env: loaderdev='%s'\n", devstr); - - p = get_device_type(devstr, type); - - /* - * If type is DEV_TYP_STOR we have a disk-like device. If the remainder - * of the string contains spaces, dots, or a colon in any location other - * than the last char, it's legacy format. Otherwise it might be - * standard loader(8) format (e.g., disk0s2a or mmc1p12), so try to - * parse the remainder of the string as such, and if it works, return - * those results. Otherwise we'll fall through to the code that parses - * the legacy format. - */ - if (*type & DEV_TYP_STOR) { - size_t len = strlen(p); - if (strcspn(p, " .") == len && strcspn(p, ":") >= len - 1 && - disk_parsedev(&dev, p, NULL) == 0) { - *unit = dev.dd.d_unit; - *slice = dev.d_slice; - *partition = dev.d_partition; - return; - } - } - - /* Ignore optional spaces after the device name. */ - while (*p == ' ') - p++; - - /* Unknown device name, or a known name without unit number. */ - if ((*type == DEV_TYP_NONE) || (*p == '\0')) { - return; - } - - /* Malformed unit number. */ - if (!isdigit(*p)) { - *type = DEV_TYP_NONE; - return; - } - - /* Guaranteed to extract a number from the string, as *p is a digit. */ - *unit = strtol(p, &endp, 10); - p = endp; - - /* Known device name with unit number and nothing else. */ - if (*p == '\0') { - return; - } - - /* Device string is malformed beyond unit number. */ - if (*p != ':') { - *type = DEV_TYP_NONE; - *unit = -1; - return; - } - - p++; - - /* No slice and partition specification. */ - if ('\0' == *p ) - return; - - /* Only DEV_TYP_STOR devices can have a slice specification. */ - if (!(*type & DEV_TYP_STOR)) { - *type = DEV_TYP_NONE; - *unit = -1; - return; - } - - *slice = strtoul(p, &endp, 10); - - /* Malformed slice number. */ - if (p == endp) { - *type = DEV_TYP_NONE; - *unit = -1; - *slice = D_SLICEWILD; - return; - } - - p = endp; - - /* No partition specification. */ - if (*p == '\0') - return; - - /* Device string is malformed beyond slice number. */ - if (*p != '.') { - *type = DEV_TYP_NONE; - *unit = -1; - *slice = D_SLICEWILD; - return; - } - - p++; - - /* No partition specification. */ - if (*p == '\0') - return; - - *partition = strtol(p, &endp, 10); - p = endp; - - /* Full, valid device string. */ - if (*endp == '\0') - return; - - /* Junk beyond partition number. */ - *type = DEV_TYP_NONE; - *unit = -1; - *slice = D_SLICEWILD; - *partition = D_PARTWILD; -} - -static void -print_disk_probe_info() -{ - char slice[32]; - char partition[32]; - - if (currdev.d_disk.d_slice == D_SLICENONE) - strlcpy(slice, "", sizeof(slice)); - else if (currdev.d_disk.d_slice == D_SLICEWILD) - strlcpy(slice, "", sizeof(slice)); - else - snprintf(slice, sizeof(slice), "%d", currdev.d_disk.d_slice); - - if (currdev.d_disk.d_partition == D_PARTNONE) - strlcpy(partition, "", sizeof(partition)); - else if (currdev.d_disk.d_partition == D_PARTWILD) - strlcpy(partition, "", sizeof(partition)); - else - snprintf(partition, sizeof(partition), "%d", - currdev.d_disk.d_partition); - - printf(" Checking unit=%d slice=%s partition=%s...", - currdev.dd.d_unit, slice, partition); - -} - -static int -probe_disks(int devidx, int load_type, int load_unit, int load_slice, - int load_partition) -{ - int open_result, unit; - struct open_file f; - - currdev.d_disk.d_slice = load_slice; - currdev.d_disk.d_partition = load_partition; - - f.f_devdata = &currdev; - open_result = -1; - - if (load_type == -1) { - printf(" Probing all disk devices...\n"); - /* Try each disk in succession until one works. */ - for (currdev.dd.d_unit = 0; currdev.dd.d_unit < UB_MAX_DEV; - currdev.dd.d_unit++) { - print_disk_probe_info(); - open_result = devsw[devidx]->dv_open(&f, &currdev); - if (open_result == 0) { - printf(" good.\n"); - return (0); - } - printf("\n"); - } - return (-1); - } - - if (load_unit == -1) { - printf(" Probing all %s devices...\n", device_typename(load_type)); - /* Try each disk of given type in succession until one works. */ - for (unit = 0; unit < UB_MAX_DEV; unit++) { - currdev.dd.d_unit = uboot_diskgetunit(load_type, unit); - if (currdev.dd.d_unit == -1) - break; - print_disk_probe_info(); - open_result = devsw[devidx]->dv_open(&f, &currdev); - if (open_result == 0) { - printf(" good.\n"); - return (0); - } - printf("\n"); - } - return (-1); - } - - if ((currdev.dd.d_unit = uboot_diskgetunit(load_type, load_unit)) != -1) { - print_disk_probe_info(); - open_result = devsw[devidx]->dv_open(&f,&currdev); - if (open_result == 0) { - printf(" good.\n"); - return (0); - } - printf("\n"); - } - - printf(" Requested disk type/unit/slice/partition not found\n"); - return (-1); -} - -int -main(int argc, char **argv) -{ - struct api_signature *sig = NULL; - int load_type, load_unit, load_slice, load_partition; - int i; - const char *ldev; - - /* - * We first check if a command line argument was passed to us containing - * API's signature address. If it wasn't then we try to search for the - * API signature via the usual hinted address. - * If we can't find the magic signature and related info, exit with a - * unique error code that U-Boot reports as "## Application terminated, - * rc = 0xnnbadab1". Hopefully 'badab1' looks enough like "bad api" to - * provide a clue. It's better than 0xffffffff anyway. - */ - if (!api_parse_cmdline_sig(argc, argv, &sig) && !api_search_sig(&sig)) - return (0x01badab1); - - syscall_ptr = sig->syscall; - if (syscall_ptr == NULL) - return (0x02badab1); - - if (sig->version > API_SIG_VERSION) - return (0x03badab1); - - /* Clear BSS sections */ - bzero(__sbss_start, __sbss_end - __sbss_start); - bzero(__bss_start, _end - __bss_start); - - /* - * Initialise the heap as early as possible. Once this is done, - * alloc() is usable. We are using the stack u-boot set up near the top - * of physical ram; hopefully there is sufficient space between the end - * of our bss and the bottom of the u-boot stack to avoid overlap. - */ - uboot_heap_start = round_page((uintptr_t)end); - uboot_heap_end = uboot_heap_start + HEAP_SIZE; - setheap((void *)uboot_heap_start, (void *)uboot_heap_end); - - /* - * Set up console. - */ - cons_probe(); - printf("Compatible U-Boot API signature found @%p\n", sig); - - printf("\n%s", bootprog_info); - printf("\n"); - - dump_sig(sig); - dump_addr_info(); - - meminfo(); - - /* Set up currdev variable to have hooks in place. */ - env_setenv("currdev", EV_VOLATILE, "", uboot_setcurrdev, env_nounset); - - /* - * Enumerate U-Boot devices - */ - if ((devs_no = ub_dev_enum()) == 0) { - printf("no U-Boot devices found"); - goto do_interact; - } - printf("Number of U-Boot devices: %d\n", devs_no); - - get_load_device(&load_type, &load_unit, &load_slice, &load_partition); - - /* - * March through the device switch probing for things. - */ - for (i = 0; devsw[i] != NULL; i++) { - - if (devsw[i]->dv_init == NULL) - continue; - if ((devsw[i]->dv_init)() != 0) - continue; - - printf("Found U-Boot device: %s\n", devsw[i]->dv_name); - - currdev.dd.d_dev = devsw[i]; - currdev.dd.d_unit = 0; - - if ((load_type == DEV_TYP_NONE || (load_type & DEV_TYP_STOR)) && - strcmp(devsw[i]->dv_name, "disk") == 0) { - if (probe_disks(i, load_type, load_unit, load_slice, - load_partition) == 0) - break; - } - - if ((load_type == DEV_TYP_NONE || (load_type & DEV_TYP_NET)) && - strcmp(devsw[i]->dv_name, "net") == 0) - break; - } - - /* - * If we couldn't find a boot device, return an error to u-boot. - * U-boot may be running a boot script that can try something different - * so returning an error is better than forcing a reboot. - */ - if (devsw[i] == NULL) { - printf("No boot device found!\n"); - return (0xbadef1ce); - } - - ldev = uboot_fmtdev(&currdev); - env_setenv("currdev", EV_VOLATILE, ldev, uboot_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, ldev, env_noset, env_nounset); - printf("Booting from %s\n", ldev); - -do_interact: - setenv("LINES", "24", 1); /* optional */ - setenv("prompt", "loader>", 1); -#ifdef __powerpc__ - setenv("usefdt", "1", 1); -#endif - - archsw.arch_loadaddr = uboot_loadaddr; - archsw.arch_getdev = uboot_getdev; - archsw.arch_copyin = uboot_copyin; - archsw.arch_copyout = uboot_copyout; - archsw.arch_readin = uboot_readin; - archsw.arch_autoload = uboot_autoload; - - interact(); /* doesn't return */ - - return (0); -} - - -COMMAND_SET(heap, "heap", "show heap usage", command_heap); -static int -command_heap(int argc, char *argv[]) -{ - - printf("heap base at %p, top at %p, used %td\n", end, sbrk(0), - sbrk(0) - end); - - return (CMD_OK); -} - -COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); -static int -command_reboot(int argc, char *argv[]) -{ - - printf("Resetting...\n"); - ub_reset(); - - printf("Reset failed!\n"); - while (1); - __unreachable(); -} - -COMMAND_SET(devinfo, "devinfo", "show U-Boot devices", command_devinfo); -static int -command_devinfo(int argc, char *argv[]) -{ - int i; - - if ((devs_no = ub_dev_enum()) == 0) { - command_errmsg = "no U-Boot devices found!?"; - return (CMD_ERROR); - } - - printf("U-Boot devices:\n"); - for (i = 0; i < devs_no; i++) { - ub_dump_di(i); - printf("\n"); - } - return (CMD_OK); -} - -COMMAND_SET(sysinfo, "sysinfo", "show U-Boot system info", command_sysinfo); -static int -command_sysinfo(int argc, char *argv[]) -{ - struct sys_info *si; - - if ((si = ub_get_sys_info()) == NULL) { - command_errmsg = "could not retrieve U-Boot sys info!?"; - return (CMD_ERROR); - } - - printf("U-Boot system info:\n"); - ub_dump_si(si); - return (CMD_OK); -} - -enum ubenv_action { - UBENV_UNKNOWN, - UBENV_SHOW, - UBENV_IMPORT -}; - -static void -handle_uboot_env_var(enum ubenv_action action, const char * var) -{ - char ldvar[128]; - const char *val; - char *wrk; - int len; - - /* - * On an import with the variable name formatted as ldname=ubname, - * import the uboot variable ubname into the loader variable ldname, - * otherwise the historical behavior is to import to uboot.ubname. - */ - if (action == UBENV_IMPORT) { - len = strcspn(var, "="); - if (len == 0) { - printf("name cannot start with '=': '%s'\n", var); - return; - } - if (var[len] == 0) { - strcpy(ldvar, "uboot."); - strncat(ldvar, var, sizeof(ldvar) - 7); - } else { - len = MIN(len, sizeof(ldvar) - 1); - strncpy(ldvar, var, len); - ldvar[len] = 0; - var = &var[len + 1]; - } - } - - /* - * If the user prepended "uboot." (which is how they usually see these - * names) strip it off as a convenience. - */ - if (strncmp(var, "uboot.", 6) == 0) { - var = &var[6]; - } - - /* If there is no variable name left, punt. */ - if (var[0] == 0) { - printf("empty variable name\n"); - return; - } - - val = ub_env_get(var); - if (action == UBENV_SHOW) { - if (val == NULL) - printf("uboot.%s is not set\n", var); - else - printf("uboot.%s=%s\n", var, val); - } else if (action == UBENV_IMPORT) { - if (val != NULL) { - setenv(ldvar, val, 1); - } - } -} - -static int -command_ubenv(int argc, char *argv[]) -{ - enum ubenv_action action; - const char *var; - int i; - - action = UBENV_UNKNOWN; - if (argc > 1) { - if (strcasecmp(argv[1], "import") == 0) - action = UBENV_IMPORT; - else if (strcasecmp(argv[1], "show") == 0) - action = UBENV_SHOW; - } - if (action == UBENV_UNKNOWN) { - command_errmsg = "usage: 'ubenv [var ...]"; - return (CMD_ERROR); - } - - if (argc > 2) { - for (i = 2; i < argc; i++) - handle_uboot_env_var(action, argv[i]); - } else { - var = NULL; - for (;;) { - if ((var = ub_env_enum(var)) == NULL) - break; - handle_uboot_env_var(action, var); - } - } - - return (CMD_OK); -} -COMMAND_SET(ubenv, "ubenv", "show or import U-Boot env vars", command_ubenv); - -#ifdef LOADER_FDT_SUPPORT -/* - * 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 Index: stand/uboot/fdt/Makefile =================================================================== --- stand/uboot/fdt/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ - -.include - -.PATH: ${LDRSRC} - -LIB= uboot_fdt -WARNS?= 2 - -SRCS= uboot_fdt.c - -# U-Boot library headers -CFLAGS+= -I${UBOOTSRC}/lib - -# libfdt headers -CFLAGS+= -I${FDTSRC} - -# Pick up the bootstrap header for some interface items -CFLAGS+= -I${LDRSRC} - -.include Index: stand/uboot/fdt/uboot_fdt.c =================================================================== --- /dev/null +++ stand/uboot/fdt/uboot_fdt.c @@ -1,213 +0,0 @@ -/*- - * Copyright (c) 2009-2010 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Semihalf under sponsorship from - * the FreeBSD Foundation. - * - * 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 -#include - -#include "glue.h" - -#define STR(number) #number -#define STRINGIFY(number) STR(number) - -static int -fdt_platform_load_from_ubenv(const char *var) -{ - struct fdt_header *hdr; - const char *s; - char *p; - - s = ub_env_get(var); - if (s == NULL || *s == '\0') - return (1); - - hdr = (struct fdt_header *)strtoul(s, &p, 16); - if (*p != '\0') - return (1); - - if (fdt_load_dtb_addr(hdr) == 0) { - printf("Using DTB provided by U-Boot at " - "address %p.\n", hdr); - return (0); - } - - return (1); -} - -#define FDT_DTB_PADSZ 1024 - -int -fdt_platform_load_dtb(void) -{ - struct fdt_header *hdr; - const char *s; - char *p; - int rv; - - /* - * If the U-boot environment contains a variable giving the address of a - * valid blob in memory, use it. The U-boot README says the right - * variable for fdt data loaded into ram is fdt_addr_r, so try that - * first. Board vendors also use both fdtaddr and fdt_addr names. - */ - if ((rv = fdt_platform_load_from_ubenv("fdt_addr_r")) == 0) - goto exit; - if ((rv = fdt_platform_load_from_ubenv("fdt_addr")) == 0) - goto exit; - if ((rv = fdt_platform_load_from_ubenv("fdtaddr")) == 0) - goto exit; - - rv = 1; - - /* - * Try to get FDT filename first from loader env and then from u-boot env - */ - s = getenv("fdt_file"); - if (s == NULL) - s = ub_env_get("fdtfile"); - if (s == NULL) - s = ub_env_get("fdt_file"); - if (s != NULL && *s != '\0') { - if (fdt_load_dtb_file(s) == 0) { - printf("Loaded DTB from file '%s'.\n", s); - rv = 0; - goto exit; - } - } - -exit: - return (rv); -} - -void -fdt_platform_load_overlays(void) -{ - - fdt_load_dtb_overlays(ub_env_get("fdt_overlays")); -} - -void -fdt_platform_fixups(void) -{ - static struct fdt_mem_region regions[UB_MAX_MR]; - const char *env, *str; - char *end, *ethstr; - int eth_no, i, len, n; - struct sys_info *si; - - env = NULL; - eth_no = 0; - ethstr = NULL; - - /* Apply overlays before anything else */ - if (fdt_apply_overlays() > 0) - fdt_pad_dtb(FDT_DTB_PADSZ); - - /* Acquire sys_info */ - si = ub_get_sys_info(); - - while ((env = ub_env_enum(env)) != NULL) { - if (strncmp(env, "eth", 3) == 0 && - strncmp(env + (strlen(env) - 4), "addr", 4) == 0) { - /* - * Handle Ethernet addrs: parse uboot env eth%daddr - */ - - if (!eth_no) { - /* - * Check how many chars we will need to store - * maximal eth iface number. - */ - len = strlen(STRINGIFY(TMP_MAX_ETH)) + - strlen("ethernet") + 1; - - /* - * Reserve mem for string "ethernet" and len - * chars for iface no. - */ - ethstr = (char *)malloc(len * sizeof(char)); - bzero(ethstr, len * sizeof(char)); - strcpy(ethstr, "ethernet0"); - } - - /* Extract interface number */ - i = strtol(env + 3, &end, 10); - if (end == (env + 3)) - /* 'ethaddr' means interface 0 address */ - n = 0; - else - n = i; - - if (n > TMP_MAX_ETH) - continue; - - str = ub_env_get(env); - - if (n != 0) { - /* - * Find the length of the interface id by - * taking in to account the first 3 and - * last 4 characters. - */ - i = strlen(env) - 7; - strncpy(ethstr + 8, env + 3, i); - } - - /* Modify blob */ - fdt_fixup_ethernet(str, ethstr, len); - - /* Clear ethernet..XXXX.. string */ - bzero(ethstr + 8, len - 8); - - if (n + 1 > eth_no) - eth_no = n + 1; - } else if (strcmp(env, "consoledev") == 0) { - str = ub_env_get(env); - fdt_fixup_stdout(str); - } - } - - /* Modify cpu(s) and bus clock frequenties in /cpus node [Hz] */ - fdt_fixup_cpubusfreqs(si->clk_cpu, si->clk_bus); - - /* Extract the DRAM regions into fdt_mem_region format. */ - for (i = 0, n = 0; i < si->mr_no && n < nitems(regions); i++) { - if (si->mr[i].flags == MR_ATTR_DRAM) { - regions[n].start = si->mr[i].start; - regions[n].size = si->mr[i].size; - n++; - } - } - - /* Fixup memory regions */ - fdt_fixup_memory(regions, n); -} Index: stand/uboot/lib/Makefile =================================================================== --- stand/uboot/lib/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# $FreeBSD$ - -.include - -.PATH: ${LDRSRC} - -LIB= uboot -WARNS?= 2 - -SRCS= console.c copy.c devicename.c elf_freebsd.c glue.c -SRCS+= module.c net.c reboot.c time.c gfx_fb.c - -CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite -CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/teken -CFLAGS.glue.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib - -.if ${LOADER_DISK_SUPPORT:Uyes} == "yes" -SRCS+= disk.c -.endif - -.include "${BOOTSRC}/fdt.mk" - -# Pick up the bootstrap header for some interface items -CFLAGS+= -I${LDRSRC} - -.ifdef(BOOT_DISK_DEBUG) -# Make the disk code more talkative -CFLAGS+= -DDISK_DEBUG -.endif - -.include Index: stand/uboot/lib/api_public.h =================================================================== --- /dev/null +++ stand/uboot/lib/api_public.h @@ -1,160 +0,0 @@ -/* - * (C) Copyright 2007-2008 Semihalf - * - * Written by: Rafal Jaworowski - * - * This file is dual licensed; you can use it under the terms of - * either the GPL, or the BSD license, at your option. - * - * I. GPL: - * - * This file is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - * - * Alternatively, - * - * II. BSD license: - * - * 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$ - * - * This file needs to be kept in sync with U-Boot reference: - * http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=include/api_public.h - */ - -#ifndef _API_PUBLIC_H_ -#define _API_PUBLIC_H_ - -#define API_EINVAL 1 /* invalid argument(s) */ -#define API_ENODEV 2 /* no device */ -#define API_ENOMEM 3 /* no memory */ -#define API_EBUSY 4 /* busy, occupied etc. */ -#define API_EIO 5 /* I/O error */ -#define API_ESYSC 6 /* syscall error */ - -typedef int (*scp_t)(int, int *, ...); - -#define API_SIG_VERSION 1 -#define API_SIG_MAGIC "UBootAPI" -#define API_SIG_MAGLEN 8 - -struct api_signature { - char magic[API_SIG_MAGLEN]; /* magic string */ - uint16_t version; /* API version */ - uint32_t checksum; /* checksum of this sig struct */ - scp_t syscall; /* entry point to the API */ -}; - -enum { - API_RSVD = 0, - API_GETC, - API_PUTC, - API_TSTC, - API_PUTS, - API_RESET, - API_GET_SYS_INFO, - API_UDELAY, - API_GET_TIMER, - API_DEV_ENUM, - API_DEV_OPEN, - API_DEV_CLOSE, - API_DEV_READ, - API_DEV_WRITE, - API_ENV_ENUM, - API_ENV_GET, - API_ENV_SET, - API_MAXCALL -}; - -#define MR_ATTR_FLASH 0x0001 -#define MR_ATTR_DRAM 0x0002 -#define MR_ATTR_SRAM 0x0003 - -struct mem_region { - unsigned long start; - unsigned long size; - int flags; -}; - -struct sys_info { - unsigned long clk_bus; - unsigned long clk_cpu; - unsigned long bar; - struct mem_region *mr; - int mr_no; /* number of memory regions */ -}; - -#undef CFG_64BIT_LBA -#ifdef CFG_64BIT_LBA -typedef uint64_t lbasize_t; -#else -typedef unsigned long lbasize_t; -#endif -typedef unsigned long lbastart_t; - -#define DEV_TYP_NONE 0x0000 -#define DEV_TYP_NET 0x0001 - -#define DEV_TYP_STOR 0x0002 -#define DT_STOR_IDE 0x0010 -#define DT_STOR_SCSI 0x0020 -#define DT_STOR_USB 0x0040 -#define DT_STOR_MMC 0x0080 -#define DT_STOR_SATA 0x0100 - -#define DEV_STA_CLOSED 0x0000 /* invalid, closed */ -#define DEV_STA_OPEN 0x0001 /* open i.e. active */ - -struct device_info { - int type; - void *cookie; - - union { - struct { - lbasize_t block_count; /* no of blocks */ - unsigned long block_size; /* size of one block */ - } storage; - - struct { - unsigned char hwaddr[6]; - } net; - } info; -#define di_stor info.storage -#define di_net info.net - - int state; -}; - -#endif /* _API_PUBLIC_H_ */ Index: stand/uboot/lib/console.c =================================================================== --- /dev/null +++ stand/uboot/lib/console.c @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 2007 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 "glue.h" - -int console; - -static void uboot_cons_probe(struct console *cp); -static int uboot_cons_init(int); -static void uboot_cons_putchar(int); -static int uboot_cons_getchar(void); -static int uboot_cons_poll(void); - -struct console uboot_console = { - "uboot", - "U-Boot console", - 0, - uboot_cons_probe, - uboot_cons_init, - uboot_cons_putchar, - uboot_cons_getchar, - uboot_cons_poll, -}; - -static void -uboot_cons_probe(struct console *cp) -{ - - cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); -} - -static int -uboot_cons_init(int arg) -{ - - return (0); -} - -static void -uboot_cons_putchar(int c) -{ - - if (c == '\n') - ub_putc('\r'); - - ub_putc(c); -} - -static int -uboot_cons_getchar() -{ - - return (ub_getc()); -} - -static int -uboot_cons_poll() -{ - - return (ub_tstc()); -} Index: stand/uboot/lib/copy.c =================================================================== --- /dev/null +++ stand/uboot/lib/copy.c @@ -1,166 +0,0 @@ -/*- - * Copyright (c) 1998 Michael Smith - * Copyright (c) 2007 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 -#include - -#include "api_public.h" -#include "glue.h" -#include "libuboot.h" - -/* - * MD primitives supporting placement of module data - */ - -#ifdef __arm__ -#define KERN_ALIGN (2 * 1024 * 1024) -#else -#define KERN_ALIGN PAGE_SIZE -#endif - -/* - * Avoid low memory, u-boot puts things like args and dtb blobs there. - */ -#define KERN_MINADDR max(KERN_ALIGN, (1024 * 1024)) - -extern void _start(void); /* ubldr entry point address. */ - -/* - * This is called for every object loaded (kernel, module, dtb file, etc). The - * expected return value is the next address at or after the given addr which is - * appropriate for loading the given object described by type and data. On each - * call the addr is the next address following the previously loaded object. - * - * The first call is for loading the kernel, and the addr argument will be zero, - * and we search for a big block of ram to load the kernel and modules. - * - * On subsequent calls the addr will be non-zero, and we just round it up so - * that each object begins on a page boundary. - */ -uint64_t -uboot_loadaddr(u_int type, void *data, uint64_t addr) -{ - struct sys_info *si; - uint64_t sblock, eblock, subldr, eubldr; - uint64_t biggest_block, this_block; - uint64_t biggest_size, this_size; - int i; - char *envstr; - - if (addr == 0) { - /* - * If the loader_kernaddr environment variable is set, blindly - * honor it. It had better be right. We force interpretation - * of the value in base-16 regardless of any leading 0x prefix, - * because that's the U-Boot convention. - */ - envstr = ub_env_get("loader_kernaddr"); - if (envstr != NULL) - return (strtoul(envstr, NULL, 16)); - - /* - * Find addr/size of largest DRAM block. Carve our own address - * range out of the block, because loading the kernel over the - * top ourself is a poor memory-conservation strategy. Avoid - * memory at beginning of the first block of physical ram, - * since u-boot likes to pass args and data there. Assume that - * u-boot has moved itself to the very top of ram and - * optimistically assume that we won't run into it up there. - */ - if ((si = ub_get_sys_info()) == NULL) - panic("could not retrieve system info"); - - biggest_block = 0; - biggest_size = 0; - subldr = rounddown2((uintptr_t)_start, KERN_ALIGN); - eubldr = roundup2((uint64_t)uboot_heap_end, KERN_ALIGN); - for (i = 0; i < si->mr_no; i++) { - if (si->mr[i].flags != MR_ATTR_DRAM) - continue; - sblock = roundup2((uint64_t)si->mr[i].start, - KERN_ALIGN); - eblock = rounddown2((uint64_t)si->mr[i].start + - si->mr[i].size, KERN_ALIGN); - if (biggest_size == 0) - sblock += KERN_MINADDR; - if (subldr >= sblock && subldr < eblock) { - if (subldr - sblock > eblock - eubldr) { - this_block = sblock; - this_size = subldr - sblock; - } else { - this_block = eubldr; - this_size = eblock - eubldr; - } - } else if (subldr < sblock && eubldr < eblock) { - /* Loader is below or engulfs the sblock */ - this_block = (eubldr < sblock) ? sblock : eubldr; - this_size = eblock - this_block; - } else { - this_block = 0; - this_size = 0; - } - if (biggest_size < this_size) { - biggest_block = this_block; - biggest_size = this_size; - } - } - if (biggest_size == 0) - panic("Not enough DRAM to load kernel"); -#if 0 - printf("Loading kernel into region 0x%08jx-0x%08jx (%ju MiB)\n", - (uintmax_t)biggest_block, - (uintmax_t)biggest_block + biggest_size - 1, - (uintmax_t)biggest_size / 1024 / 1024); -#endif - return (biggest_block); - } - return roundup2(addr, PAGE_SIZE); -} - -ssize_t -uboot_copyin(const void *src, vm_offset_t dest, const size_t len) -{ - bcopy(src, (void *)dest, len); - return (len); -} - -ssize_t -uboot_copyout(const vm_offset_t src, void *dest, const size_t len) -{ - bcopy((void *)src, dest, len); - return (len); -} - -ssize_t -uboot_readin(readin_handle_t fd, vm_offset_t dest, const size_t len) -{ - return (VECTX_READ(fd, (void *)dest, len)); -} Index: stand/uboot/lib/devicename.c =================================================================== --- /dev/null +++ stand/uboot/lib/devicename.c @@ -1,200 +0,0 @@ -/*- - * Copyright (c) 1998 Michael Smith - * 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 - -#include "bootstrap.h" -#include "disk.h" -#include "libuboot.h" - -static int uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, - const char **path); - -/* - * Point (dev) at an allocated device specifier for the device matching the - * path in (devspec). If it contains an explicit device specification, - * use that. If not, use the default device. - */ -int -uboot_getdev(void **vdev, const char *devspec, const char **path) -{ - struct uboot_devdesc **dev = (struct uboot_devdesc **)vdev; - int rv; - - /* - * If it looks like this is just a path and no - * device, go with the current device. - */ - if ((devspec == NULL) || (devspec[0] == '/') || - (strchr(devspec, ':') == NULL)) { - - if (((rv = uboot_parsedev(dev, getenv("currdev"), NULL)) == 0) - && (path != NULL)) - *path = devspec; - return(rv); - } - - /* - * Try to parse the device name off the beginning of the devspec. - */ - return (uboot_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: - * - * disk[]: - * - */ -static int -uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, - const char **path) -{ - struct uboot_devdesc *idev; - struct devsw *dv; - char *cp; - const char *np; - int i, unit, err; - - /* minimum length check */ - if (strlen(devspec) < 2) - return(EINVAL); - - /* look for a device that matches */ - for (i = 0, dv = NULL; devsw[i] != NULL; i++) { - if (!strncmp(devspec, devsw[i]->dv_name, - strlen(devsw[i]->dv_name))) { - dv = devsw[i]; - break; - } - } - if (dv == NULL) - return(ENOENT); - idev = malloc(sizeof(struct uboot_devdesc)); - err = 0; - np = (devspec + strlen(dv->dv_name)); - - switch(dv->dv_type) { - case DEVT_NONE: - break; - -#ifdef LOADER_DISK_SUPPORT - case DEVT_DISK: - err = disk_parsedev((struct disk_devdesc *)idev, np, path); - if (err != 0) - goto fail; - break; -#endif - - case DEVT_NET: - unit = 0; - - if (*np && (*np != ':')) { - /* get unit number if present */ - unit = strtol(np, &cp, 0); - if (cp == np) { - err = EUNIT; - goto fail; - } - } - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; - } - idev->dd.d_unit = unit; - - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - - default: - err = EINVAL; - goto fail; - } - idev->dd.d_dev = dv; - if (dev == NULL) { - free(idev); - } else { - *dev = idev; - } - return (0); - -fail: - free(idev); - return (err); -} - - -char * -uboot_fmtdev(void *vdev) -{ - struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev; - static char buf[128]; - - switch(dev->dd.d_dev->dv_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; - - case DEVT_DISK: -#ifdef LOADER_DISK_SUPPORT - return (disk_fmtdev(vdev)); -#endif - - case DEVT_NET: - sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); - break; - } - return(buf); -} - -/* - * Set currdev to suit the value being supplied in (value). - */ -int -uboot_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct uboot_devdesc *ncurr; - int rv; - - if ((rv = uboot_parsedev(&ncurr, value, NULL)) != 0) - return (rv); - free(ncurr); - - return (mount_currdev(ev, flags, value)); -} Index: stand/uboot/lib/disk.c =================================================================== --- /dev/null +++ stand/uboot/lib/disk.c @@ -1,320 +0,0 @@ -/*- - * Copyright (c) 2008 Semihalf, Rafal Jaworowski - * Copyright (c) 2009 Semihalf, Piotr Ziecik - * Copyright (c) 2012 Andrey V. Elsukov - * 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. - * - */ - -/* - * Block storage I/O routines for U-Boot - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include "api_public.h" -#include "bootstrap.h" -#include "disk.h" -#include "glue.h" -#include "libuboot.h" - -#define stor_printf(fmt, args...) do { \ - printf("%s%d: ", dev->dd.d_dev->dv_name, dev->dd.d_unit); \ - printf(fmt, ##args); \ -} while (0) - -#ifdef DEBUG -#define debugf(fmt, args...) do { printf("%s(): ", __func__); \ - printf(fmt,##args); } while (0) -#else -#define debugf(fmt, args...) -#endif - -static struct { - int opened; /* device is opened */ - int handle; /* storage device handle */ - int type; /* storage type */ - off_t blocks; /* block count */ - u_int bsize; /* block size */ -} stor_info[UB_MAX_DEV]; - -#define SI(dev) (stor_info[(dev)->dd.d_unit]) - -static int stor_info_no = 0; -static int stor_opendev(struct disk_devdesc *); -static int stor_readdev(struct disk_devdesc *, daddr_t, size_t, char *); - -/* devsw I/F */ -static int stor_init(void); -static int stor_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static int stor_open(struct open_file *, ...); -static int stor_close(struct open_file *); -static int stor_ioctl(struct open_file *f, u_long cmd, void *data); -static int stor_print(int); -static void stor_cleanup(void); - -struct devsw uboot_storage = { - "disk", - DEVT_DISK, - stor_init, - stor_strategy, - stor_open, - stor_close, - stor_ioctl, - stor_print, - stor_cleanup -}; - -static int -stor_init(void) -{ - struct device_info *di; - int i; - - if (devs_no == 0) { - printf("No U-Boot devices! Really enumerated?\n"); - return (-1); - } - - for (i = 0; i < devs_no; i++) { - di = ub_dev_get(i); - if ((di != NULL) && (di->type & DEV_TYP_STOR)) { - if (stor_info_no >= UB_MAX_DEV) { - printf("Too many storage devices: %d\n", - stor_info_no); - return (-1); - } - stor_info[stor_info_no].handle = i; - stor_info[stor_info_no].opened = 0; - stor_info[stor_info_no].type = di->type; - stor_info[stor_info_no].blocks = - di->di_stor.block_count; - stor_info[stor_info_no].bsize = - di->di_stor.block_size; - stor_info_no++; - } - } - - if (!stor_info_no) { - debugf("No storage devices\n"); - return (-1); - } - - debugf("storage devices found: %d\n", stor_info_no); - return (0); -} - -static void -stor_cleanup(void) -{ - int i; - - for (i = 0; i < stor_info_no; i++) - if (stor_info[i].opened > 0) - ub_dev_close(stor_info[i].handle); -} - -static int -stor_strategy(void *devdata, int rw, daddr_t blk, size_t size, - char *buf, size_t *rsize) -{ - struct disk_devdesc *dev = (struct disk_devdesc *)devdata; - daddr_t bcount; - int err; - - rw &= F_MASK; - if (rw != F_READ) { - stor_printf("write attempt, operation not supported!\n"); - return (EROFS); - } - - if (size % SI(dev).bsize) { - stor_printf("size=%zu not multiple of device " - "block size=%d\n", - size, SI(dev).bsize); - return (EIO); - } - bcount = size / SI(dev).bsize; - if (rsize) - *rsize = 0; - - err = stor_readdev(dev, blk + dev->d_offset, bcount, buf); - if (!err && rsize) - *rsize = size; - - return (err); -} - -static int -stor_open(struct open_file *f, ...) -{ - va_list ap; - struct disk_devdesc *dev; - - va_start(ap, f); - dev = va_arg(ap, struct disk_devdesc *); - va_end(ap); - - return (stor_opendev(dev)); -} - -static int -stor_opendev(struct disk_devdesc *dev) -{ - int err; - - if (dev->dd.d_unit < 0 || dev->dd.d_unit >= stor_info_no) - return (EIO); - - if (SI(dev).opened == 0) { - err = ub_dev_open(SI(dev).handle); - if (err != 0) { - stor_printf("device open failed with error=%d, " - "handle=%d\n", err, SI(dev).handle); - return (ENXIO); - } - SI(dev).opened++; - } - return (disk_open(dev, SI(dev).blocks * SI(dev).bsize, - SI(dev).bsize)); -} - -static int -stor_close(struct open_file *f) -{ - struct disk_devdesc *dev; - - dev = (struct disk_devdesc *)(f->f_devdata); - return (disk_close(dev)); -} - -static int -stor_readdev(struct disk_devdesc *dev, daddr_t blk, size_t size, char *buf) -{ - lbasize_t real_size; - int err; - - debugf("reading blk=%d size=%d @ 0x%08x\n", (int)blk, size, (uint32_t)buf); - - err = ub_dev_read(SI(dev).handle, buf, size, blk, &real_size); - if (err != 0) { - stor_printf("read failed, error=%d\n", err); - return (EIO); - } - - if (real_size != size) { - stor_printf("real size != size\n"); - err = EIO; - } - - return (err); -} - -static int -stor_print(int verbose) -{ - struct disk_devdesc dev; - static char line[80]; - int i, ret = 0; - - if (stor_info_no == 0) - return (ret); - - printf("%s devices:", uboot_storage.dv_name); - if ((ret = pager_output("\n")) != 0) - return (ret); - - for (i = 0; i < stor_info_no; i++) { - dev.dd.d_dev = &uboot_storage; - dev.dd.d_unit = i; - dev.d_slice = D_SLICENONE; - dev.d_partition = D_PARTNONE; - snprintf(line, sizeof(line), "\tdisk%d (%s)\n", i, - ub_stor_type(SI(&dev).type)); - if ((ret = pager_output(line)) != 0) - break; - if (stor_opendev(&dev) == 0) { - sprintf(line, "\tdisk%d", i); - ret = disk_print(&dev, line, verbose); - disk_close(&dev); - if (ret != 0) - break; - } - } - return (ret); -} - -static int -stor_ioctl(struct open_file *f, u_long cmd, void *data) -{ - struct disk_devdesc *dev; - int rc; - - dev = (struct disk_devdesc *)f->f_devdata; - rc = disk_ioctl(dev, cmd, data); - if (rc != ENOTTY) - return (rc); - - switch (cmd) { - case DIOCGSECTORSIZE: - *(u_int *)data = SI(dev).bsize; - break; - case DIOCGMEDIASIZE: - *(uint64_t *)data = SI(dev).bsize * SI(dev).blocks; - break; - default: - return (ENOTTY); - } - return (0); -} - - -/* - * Return the device unit number for the given type and type-relative unit - * number. - */ -int -uboot_diskgetunit(int type, int type_unit) -{ - int local_type_unit; - int i; - - local_type_unit = 0; - for (i = 0; i < stor_info_no; i++) { - if ((stor_info[i].type & type) == type) { - if (local_type_unit == type_unit) { - return (i); - } - local_type_unit++; - } - } - - return (-1); -} Index: stand/uboot/lib/elf_freebsd.c =================================================================== --- /dev/null +++ stand/uboot/lib/elf_freebsd.c @@ -1,96 +0,0 @@ -/*- - * Copyright (c) 2001 Benno Rice - * Copyright (c) 2007 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 - -#include -#include -#include - -#include - -#include "bootstrap.h" -#include "libuboot.h" - -extern vm_offset_t md_load(char *, vm_offset_t *, vm_offset_t *); - -int -__elfN(uboot_load)(char *filename, uint64_t dest, - struct preloaded_file **result) -{ - int r; - - r = __elfN(loadfile)(filename, dest, result); - if (r != 0) - return (r); - -#if defined(__powerpc__) - /* - * No need to sync the icache for modules: this will - * be done by the kernel after relocation. - */ - if (!strcmp((*result)->f_type, "elf kernel")) - __syncicache((void *) (*result)->f_addr, (*result)->f_size); -#endif - return (0); -} - -int -__elfN(uboot_exec)(struct preloaded_file *fp) -{ - struct file_metadata *fmp; - vm_offset_t mdp; - Elf_Ehdr *e; - int error; - void (*entry)(void *); - - if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) - return (EFTYPE); - - e = (Elf_Ehdr *)&fmp->md_data; - - if ((error = md_load(fp->f_args, &mdp, NULL)) != 0) - return (error); - - entry = (void *)e->e_entry; - printf("Kernel entry at %p...\n", entry); - - dev_cleanup(); - printf("Kernel args: %s\n", fp->f_args); - - (*entry)((void *)mdp); - panic("exec returned"); -} - -struct file_format uboot_elf = { - __elfN(uboot_load), - __elfN(uboot_exec) -}; Index: stand/uboot/lib/gfx_fb.c =================================================================== --- /dev/null +++ stand/uboot/lib/gfx_fb.c @@ -1,78 +0,0 @@ -/*- - * Copyright 2021 Toomas Soome - * 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$"); - -/* - * U-Boot-specific gfx stubs. - */ - -#include -#include -#include "bootstrap.h" -#include "gfx_fb.h" - -font_list_t fonts = STAILQ_HEAD_INITIALIZER(fonts); -teken_gfx_t gfx_state = { 0 }; - -void -gfx_fb_setpixel(uint32_t x __unused, uint32_t y __unused) -{ -} - -void -gfx_fb_drawrect(uint32_t x1 __unused, uint32_t y1 __unused, - uint32_t x2 __unused, uint32_t y2 __unused, uint32_t fill __unused) -{ -} - -void -gfx_term_drawrect(uint32_t x1 __unused, uint32_t y1 __unused, - uint32_t x2 __unused, uint32_t y2 __unused) -{ -} - -void -gfx_fb_line(uint32_t x0 __unused, uint32_t y0 __unused, - uint32_t x1 __unused, uint32_t y1 __unused, uint32_t w __unused) -{ -} - -void -gfx_fb_bezier(uint32_t x0 __unused, uint32_t y0 __unused, - uint32_t x1 __unused, uint32_t y1 __unused, uint32_t x2 __unused, - uint32_t y2 __unused, uint32_t w __unused) -{ -} - -int -gfx_fb_putimage(png_t *png __unused, uint32_t ux1 __unused, - uint32_t uy1 __unused, uint32_t ux2 __unused, uint32_t uy2 __unused, - uint32_t flags __unused) -{ - return (1); -} Index: stand/uboot/lib/glue.h =================================================================== --- /dev/null +++ stand/uboot/lib/glue.h @@ -1,98 +0,0 @@ -/*- - * 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. - * - * $FreeBSD$ - */ - -/* - * This is the header file for conveniency wrapper routines (API glue) - */ - -#ifndef _API_GLUE_H_ -#define _API_GLUE_H_ - -#include "api_public.h" - -/* - * Mask used to align the start address for API signature search to 1MiB - */ -#define API_SIG_SEARCH_MASK ~0x000fffff - -/* - * Search for the API signature within 3MiB of the 1MiB-aligned address that - * U-Boot has hinted us. - */ -#define API_SIG_SEARCH_LEN 0x00300000 - -int syscall(int, int *, ...); -extern void *syscall_ptr; - -int api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig); -int api_search_sig(struct api_signature **sig); - -#define UB_MAX_MR 16 /* max mem regions number */ -#define UB_MAX_DEV 6 /* max devices number */ - -/* - * The ub_ library calls are part of the application, not U-Boot code! They - * are front-end wrappers that are used by the consumer application: they - * prepare arguments for particular syscall and jump to the low level - * syscall() - */ - -/* console */ -int ub_getc(void); -int ub_tstc(void); -void ub_putc(char); -void ub_puts(const char *); - -/* system */ -void ub_reset(void) __dead2; -struct sys_info *ub_get_sys_info(void); - -/* time */ -void ub_udelay(unsigned long); -unsigned long ub_get_timer(unsigned long); - -/* env vars */ -char *ub_env_get(const char *); -void ub_env_set(const char *, char *); -const char *ub_env_enum(const char *); - -/* devices */ -int ub_dev_enum(void); -int ub_dev_open(int); -int ub_dev_close(int); -int ub_dev_read(int, void *, lbasize_t, lbastart_t, lbasize_t *); -int ub_dev_send(int, void *, int); -int ub_dev_recv(int, void *, int, int *); -struct device_info *ub_dev_get(int); - -void ub_dump_di(int); -void ub_dump_si(struct sys_info *); -char *ub_mem_type(int); -char *ub_stor_type(int); - -#endif /* _API_GLUE_H_ */ Index: stand/uboot/lib/glue.c =================================================================== --- /dev/null +++ stand/uboot/lib/glue.c @@ -1,566 +0,0 @@ -/*- - * Copyright (c) 2007-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 -#include -#include "api_public.h" -#include "glue.h" - -#ifdef DEBUG -#define debugf(fmt, args...) do { printf("%s(): ", __func__); printf(fmt,##args); } while (0) -#else -#define debugf(fmt, args...) -#endif - -/* Some random address used by U-Boot. */ -extern long uboot_address; - -static int -valid_sig(struct api_signature *sig) -{ - uint32_t checksum; - struct api_signature s; - - if (sig == NULL) - return (0); - /* - * Clear the checksum field (in the local copy) so as to calculate the - * CRC with the same initial contents as at the time when the sig was - * produced - */ - s = *sig; - s.checksum = crc32(0, Z_NULL, 0); - - checksum = crc32(s.checksum, (void *)&s, sizeof(struct api_signature)); - - if (checksum != sig->checksum) - return (0); - - return (1); -} - -/* - * Checks to see if API signature's address was given to us as a command line - * argument by U-Boot. - * - * returns 1/0 depending on found/not found result - */ -int -api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig) -{ - unsigned long api_address; - int c; - - api_address = 0; - opterr = 0; - optreset = 1; - optind = 1; - - while ((c = getopt (argc, argv, "a:")) != -1) - switch (c) { - case 'a': - api_address = strtoul(optarg, NULL, 16); - break; - default: - break; - } - - if (api_address != 0) { - *sig = (struct api_signature *)api_address; - if (valid_sig(*sig)) - return (1); - } - - return (0); -} - -/* - * Searches for the U-Boot API signature - * - * returns 1/0 depending on found/not found result - */ -int -api_search_sig(struct api_signature **sig) -{ - unsigned char *sp, *spend; - - if (sig == NULL) - return (0); - - if (uboot_address == 0) - uboot_address = 255 * 1024 * 1024; - - sp = (void *)(uboot_address & API_SIG_SEARCH_MASK); - spend = sp + API_SIG_SEARCH_LEN - API_SIG_MAGLEN; - - while (sp < spend) { - if (!bcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) { - *sig = (struct api_signature *)sp; - if (valid_sig(*sig)) - return (1); - } - sp += API_SIG_MAGLEN; - } - - *sig = NULL; - return (0); -} - -/**************************************** - * - * console - * - ****************************************/ - -int -ub_getc(void) -{ - int c; - - if (!syscall(API_GETC, NULL, &c)) - return (-1); - - return (c); -} - -int -ub_tstc(void) -{ - int t; - - if (!syscall(API_TSTC, NULL, &t)) - return (-1); - - return (t); -} - -void -ub_putc(const char c) -{ - - syscall(API_PUTC, NULL, &c); -} - -void -ub_puts(const char *s) -{ - - syscall(API_PUTS, NULL, s); -} - -/**************************************** - * - * system - * - ****************************************/ - -void -ub_reset(void) -{ - - syscall(API_RESET, NULL); - while (1); /* fallback if API_RESET failed */ - __unreachable(); -} - -static struct mem_region mr[UB_MAX_MR]; -static struct sys_info si; - -struct sys_info * -ub_get_sys_info(void) -{ - int err = 0; - - memset(&si, 0, sizeof(struct sys_info)); - si.mr = mr; - si.mr_no = UB_MAX_MR; - memset(&mr, 0, sizeof(mr)); - - if (!syscall(API_GET_SYS_INFO, &err, &si)) - return (NULL); - - return ((err) ? NULL : &si); -} - -/**************************************** - * - * timing - * - ****************************************/ - -void -ub_udelay(unsigned long usec) -{ - - syscall(API_UDELAY, NULL, &usec); -} - -unsigned long -ub_get_timer(unsigned long base) -{ - unsigned long cur; - - if (!syscall(API_GET_TIMER, NULL, &cur, &base)) - return (0); - - return (cur); -} - -/**************************************************************************** - * - * devices - * - * Devices are identified by handles: numbers 0, 1, 2, ..., UB_MAX_DEV-1 - * - ***************************************************************************/ - -static struct device_info devices[UB_MAX_DEV]; - -struct device_info * -ub_dev_get(int i) -{ - - return ((i < 0 || i >= UB_MAX_DEV) ? NULL : &devices[i]); -} - -/* - * Enumerates the devices: fills out device_info elements in the devices[] - * array. - * - * returns: number of devices found - */ -int -ub_dev_enum(void) -{ - struct device_info *di; - int n = 0; - - memset(&devices, 0, sizeof(struct device_info) * UB_MAX_DEV); - di = &devices[0]; - - if (!syscall(API_DEV_ENUM, NULL, di)) - return (0); - - while (di->cookie != NULL) { - - if (++n >= UB_MAX_DEV) - break; - - /* take another device_info */ - di++; - - /* pass on the previous cookie */ - di->cookie = devices[n - 1].cookie; - - if (!syscall(API_DEV_ENUM, NULL, di)) - return (0); - } - - return (n); -} - -/* - * handle: 0-based id of the device - * - * returns: 0 when OK, err otherwise - */ -int -ub_dev_open(int handle) -{ - struct device_info *di; - int err = 0; - - if (handle < 0 || handle >= UB_MAX_DEV) - return (API_EINVAL); - - di = &devices[handle]; - if (!syscall(API_DEV_OPEN, &err, di)) - return (-1); - - return (err); -} - -int -ub_dev_close(int handle) -{ - struct device_info *di; - - if (handle < 0 || handle >= UB_MAX_DEV) - return (API_EINVAL); - - di = &devices[handle]; - if (!syscall(API_DEV_CLOSE, NULL, di)) - return (-1); - - return (0); -} - -/* - * Validates device for read/write, it has to: - * - * - have sane handle - * - be opened - * - * returns: 0/1 accordingly - */ -static int -dev_valid(int handle) -{ - - if (handle < 0 || handle >= UB_MAX_DEV) - return (0); - - if (devices[handle].state != DEV_STA_OPEN) - return (0); - - return (1); -} - -static int -dev_stor_valid(int handle) -{ - - if (!dev_valid(handle)) - return (0); - - if (!(devices[handle].type & DEV_TYP_STOR)) - return (0); - - return (1); -} - -int -ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start, - lbasize_t *rlen) -{ - struct device_info *di; - lbasize_t act_len; - int err = 0; - - if (!dev_stor_valid(handle)) - return (API_ENODEV); - - di = &devices[handle]; - if (!syscall(API_DEV_READ, &err, di, buf, &len, &start, &act_len)) - return (API_ESYSC); - - if (!err && rlen) - *rlen = act_len; - - return (err); -} - -static int -dev_net_valid(int handle) -{ - - if (!dev_valid(handle)) - return (0); - - if (devices[handle].type != DEV_TYP_NET) - return (0); - - return (1); -} - -int -ub_dev_recv(int handle, void *buf, int len, int *rlen) -{ - struct device_info *di; - int err = 0, act_len; - - if (!dev_net_valid(handle)) - return (API_ENODEV); - - di = &devices[handle]; - if (!syscall(API_DEV_READ, &err, di, buf, &len, &act_len)) - return (API_ESYSC); - - if (!err) - *rlen = act_len; - - return (err); -} - -int -ub_dev_send(int handle, void *buf, int len) -{ - struct device_info *di; - int err = 0; - - if (!dev_net_valid(handle)) - return (API_ENODEV); - - di = &devices[handle]; - if (!syscall(API_DEV_WRITE, &err, di, buf, &len)) - return (API_ESYSC); - - return (err); -} - -char * -ub_stor_type(int type) -{ - - if (type & DT_STOR_IDE) - return ("IDE"); - - if (type & DT_STOR_SCSI) - return ("SCSI"); - - if (type & DT_STOR_USB) - return ("USB"); - - if (type & DT_STOR_MMC) - return ("MMC"); - - if (type & DT_STOR_SATA) - return ("SATA"); - - return ("Unknown"); -} - -char * -ub_mem_type(int flags) -{ - - switch (flags & 0x000F) { - case MR_ATTR_FLASH: - return ("FLASH"); - case MR_ATTR_DRAM: - return ("DRAM"); - case MR_ATTR_SRAM: - return ("SRAM"); - default: - return ("Unknown"); - } -} - -void -ub_dump_di(int handle) -{ - struct device_info *di = ub_dev_get(handle); - int i; - - printf("device info (%d):\n", handle); - printf(" cookie\t= %p\n", di->cookie); - printf(" type\t\t= 0x%08x\n", di->type); - - if (di->type == DEV_TYP_NET) { - printf(" hwaddr\t= "); - for (i = 0; i < 6; i++) - printf("%02x ", di->di_net.hwaddr[i]); - - printf("\n"); - - } else if (di->type & DEV_TYP_STOR) { - printf(" type\t\t= %s\n", ub_stor_type(di->type)); - printf(" blk size\t\t= %ld\n", di->di_stor.block_size); - printf(" blk count\t\t= %ld\n", di->di_stor.block_count); - } -} - -void -ub_dump_si(struct sys_info *si) -{ - int i; - - printf("sys info:\n"); - printf(" clkbus\t= %ld MHz\n", si->clk_bus / 1000 / 1000); - printf(" clkcpu\t= %ld MHz\n", si->clk_cpu / 1000 / 1000); - printf(" bar\t\t= 0x%08lx\n", si->bar); - - printf("---\n"); - for (i = 0; i < si->mr_no; i++) { - if (si->mr[i].flags == 0) - break; - - printf(" start\t= 0x%08lx\n", si->mr[i].start); - printf(" size\t= 0x%08lx\n", si->mr[i].size); - printf(" type\t= %s\n", ub_mem_type(si->mr[i].flags)); - printf("---\n"); - } -} - -/**************************************** - * - * env vars - * - ****************************************/ - -char * -ub_env_get(const char *name) -{ - char *value; - - if (!syscall(API_ENV_GET, NULL, name, &value)) - return (NULL); - - return (value); -} - -void -ub_env_set(const char *name, char *value) -{ - - syscall(API_ENV_SET, NULL, name, value); -} - -static char env_name[256]; - -const char * -ub_env_enum(const char *last) -{ - const char *env, *str; - int i; - - /* - * It's OK to pass only the name piece as last (and not the whole - * 'name=val' string), since the API_ENUM_ENV call uses envmatch() - * internally, which handles such case - */ - env = NULL; - if (!syscall(API_ENV_ENUM, NULL, last, &env)) - return (NULL); - - if (env == NULL || last == env) - /* no more env. variables to enumerate */ - return (NULL); - - /* next enumerated env var */ - memset(env_name, 0, 256); - for (i = 0, str = env; *str != '=' && *str != '\0';) - env_name[i++] = *str++; - - env_name[i] = '\0'; - - return (env_name); -} Index: stand/uboot/lib/libuboot.h =================================================================== --- /dev/null +++ stand/uboot/lib/libuboot.h @@ -1,77 +0,0 @@ -/*- - * Copyright (C) 2000 Benno Rice. - * Copyright (C) 2007 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. - * - * $FreeBSD$ - */ - -#include -#include - -struct uboot_devdesc { - union { - struct devdesc dd; - struct disk_devdesc d_disk; - }; -}; - -/* - * Default network packet alignment in memory. On arm arches packets must be - * aligned to cacheline boundaries. - */ -#if defined(__aarch64__) -#define PKTALIGN 128 -#elif defined(__arm__) -#define PKTALIGN 64 -#else -#define PKTALIGN 32 -#endif - -int uboot_getdev(void **vdev, const char *devspec, const char **path); -char *uboot_fmtdev(void *vdev); -int uboot_setcurrdev(struct env_var *ev, int flags, const void *value); - -extern int devs_no; -extern struct netif_driver uboot_net; -extern struct devsw uboot_storage; - -extern uintptr_t uboot_heap_start; -extern uintptr_t uboot_heap_end; - -uint64_t uboot_loadaddr(u_int type, void *data, uint64_t addr); -ssize_t uboot_copyin(const void *src, vm_offset_t dest, const size_t len); -ssize_t uboot_copyout(const vm_offset_t src, void *dest, const size_t len); -ssize_t uboot_readin(readin_handle_t fd, vm_offset_t dest, const size_t len); -extern int uboot_autoload(void); - -struct preloaded_file; -struct file_format; - -extern struct file_format uboot_elf; - -void reboot(void); - -int uboot_diskgetunit(int type, int type_unit); - Index: stand/uboot/lib/module.c =================================================================== --- /dev/null +++ stand/uboot/lib/module.c @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1998 Michael Smith - * 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$"); - -/* - * U-Boot-specific module functionality. - */ - -#include -#include - -#if defined(LOADER_FDT_SUPPORT) -#include -#endif - -#include "bootstrap.h" -#include "libuboot.h" - -int -uboot_autoload(void) -{ -#if defined(LOADER_FDT_SUPPORT) - int err; - - if ((err = fdt_setup_fdtp()) != 0) { - printf("No valid device tree blob found!\n"); - return (err); - } -#endif - - return(0); -} Index: stand/uboot/lib/net.c =================================================================== --- /dev/null +++ stand/uboot/lib/net.c @@ -1,364 +0,0 @@ -/*- - * Copyright (c) 2000-2001 Benno Rice - * Copyright (c) 2007 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 -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "api_public.h" -#include "glue.h" -#include "libuboot.h" -#include "dev_net.h" - -static int net_probe(struct netif *, void *); -static int net_match(struct netif *, void *); -static void net_init(struct iodesc *, void *); -static ssize_t net_get(struct iodesc *, void **, time_t); -static ssize_t net_put(struct iodesc *, void *, size_t); -static void net_end(struct netif *); - -extern struct netif_stats net_stats[]; - -struct netif_dif net_ifs[] = { - /* dif_unit dif_nsel dif_stats dif_private */ - { 0, 1, &net_stats[0], 0, }, -}; - -struct netif_stats net_stats[nitems(net_ifs)]; - -struct netif_driver uboot_net = { - "uboot_eth", /* netif_bname */ - net_match, /* netif_match */ - net_probe, /* netif_probe */ - net_init, /* netif_init */ - net_get, /* netif_get */ - net_put, /* netif_put */ - net_end, /* netif_end */ - net_ifs, /* netif_ifs */ - nitems(net_ifs) /* netif_nifs */ -}; - -struct uboot_softc { - uint32_t sc_pad; - uint8_t sc_rxbuf[ETHER_MAX_LEN]; - uint8_t sc_txbuf[ETHER_MAX_LEN + PKTALIGN]; - uint8_t *sc_txbufp; - int sc_handle; /* device handle for ub_dev_xxx */ -}; - -static struct uboot_softc uboot_softc; - -/* - * get_env_net_params() - * - * Attempt to obtain all the parms we need for netbooting from the U-Boot - * environment. If we fail to obtain the values it may still be possible to - * netboot; the net_dev code will attempt to get the values from bootp, rarp, - * and other such sources. - * - * If rootip.s_addr is non-zero net_dev assumes the required global variables - * are set and skips the bootp inquiry. For that reason, we don't set rootip - * until we've verified that we have at least the minimum required info. - * - * This is called from netif_init() which can result in it getting called - * multiple times, by design. The network code at higher layers zeroes out - * rootip when it closes a network interface, so if it gets opened again we have - * to obtain all this info again. - */ -static void -get_env_net_params() -{ - char *envstr; - in_addr_t rootaddr, serveraddr; - - /* - * Silently get out right away if we don't have rootpath, because none - * of the other info we obtain below is sufficient to boot without it. - * - * If we do have rootpath, copy it into the global var and also set - * dhcp.root-path in the env. If we don't get all the other info from - * the u-boot env below, we will still try dhcp/bootp, but the server- - * provided path will not replace the user-provided value we set here. - */ - if ((envstr = ub_env_get("rootpath")) == NULL) - return; - strlcpy(rootpath, envstr, sizeof(rootpath)); - setenv("dhcp.root-path", rootpath, 0); - - /* - * Our own IP address must be valid. Silently get out if it's not set, - * but whine if it's there and we can't parse it. - */ - if ((envstr = ub_env_get("ipaddr")) == NULL) - return; - if ((myip.s_addr = inet_addr(envstr)) == INADDR_NONE) { - printf("Could not parse ipaddr '%s'\n", envstr); - return; - } - - /* - * Netmask is optional, default to the "natural" netmask for our IP, but - * whine if it was provided and we couldn't parse it. - */ - if ((envstr = ub_env_get("netmask")) != NULL && - (netmask = inet_addr(envstr)) == INADDR_NONE) { - printf("Could not parse netmask '%s'\n", envstr); - } - if (netmask == INADDR_NONE) { - if (IN_CLASSA(myip.s_addr)) - netmask = IN_CLASSA_NET; - else if (IN_CLASSB(myip.s_addr)) - netmask = IN_CLASSB_NET; - else - netmask = IN_CLASSC_NET; - } - - /* - * Get optional serverip before rootpath; the latter can override it. - * Whine only if it's present but can't be parsed. - */ - serveraddr = INADDR_NONE; - if ((envstr = ub_env_get("serverip")) != NULL) { - if ((serveraddr = inet_addr(envstr)) == INADDR_NONE) - printf("Could not parse serverip '%s'\n", envstr); - } - - /* - * There must be a rootpath. It may be ip:/path or it may be just the - * path in which case the ip needs to be in serverip. - */ - rootaddr = net_parse_rootpath(); - if (rootaddr == INADDR_NONE) - rootaddr = serveraddr; - if (rootaddr == INADDR_NONE) { - printf("No server address for rootpath '%s'\n", envstr); - return; - } - rootip.s_addr = rootaddr; - - /* - * Gateway IP is optional unless rootip is on a different net in which - * case whine if it's missing or we can't parse it, and set rootip addr - * to zero, which signals to other network code that network params - * aren't set (so it will try dhcp, bootp, etc). - */ - envstr = ub_env_get("gatewayip"); - if (!SAMENET(myip, rootip, netmask)) { - if (envstr == NULL) { - printf("Need gatewayip for a root server on a " - "different network.\n"); - rootip.s_addr = 0; - return; - } - if ((gateip.s_addr = inet_addr(envstr)) == INADDR_NONE) { - printf("Could not parse gatewayip '%s'\n", envstr); - rootip.s_addr = 0; - return; - } - } -} - -static int -net_match(struct netif *nif, void *machdep_hint) -{ - char **a = (char **)machdep_hint; - - if (memcmp("net", *a, 3) == 0) - return (1); - - printf("net_match: could not match network device\n"); - return (0); -} - -static int -net_probe(struct netif *nif, void *machdep_hint) -{ - struct device_info *di; - int i; - - for (i = 0; i < devs_no; i++) - if ((di = ub_dev_get(i)) != NULL) - if (di->type == DEV_TYP_NET) - break; - - if (i == devs_no) { - printf("net_probe: no network devices found, maybe not" - " enumerated yet..?\n"); - return (-1); - } - -#if defined(NETIF_DEBUG) - printf("net_probe: network device found: %d\n", i); -#endif - uboot_softc.sc_handle = i; - - return (0); -} - -static ssize_t -net_put(struct iodesc *desc, void *pkt, size_t len) -{ - struct netif *nif = desc->io_netif; - struct uboot_softc *sc = nif->nif_devdata; - size_t sendlen; - ssize_t rv; - -#if defined(NETIF_DEBUG) - struct ether_header *eh; - - printf("net_put: desc %p, pkt %p, len %d\n", desc, pkt, len); - eh = pkt; - printf("dst: %s ", ether_sprintf(eh->ether_dhost)); - printf("src: %s ", ether_sprintf(eh->ether_shost)); - printf("type: 0x%x\n", eh->ether_type & 0xffff); -#endif - - if (len < ETHER_MIN_LEN - ETHER_CRC_LEN) { - sendlen = ETHER_MIN_LEN - ETHER_CRC_LEN; - bzero(sc->sc_txbufp, sendlen); - } else - sendlen = len; - - memcpy(sc->sc_txbufp, pkt, len); - - rv = ub_dev_send(sc->sc_handle, sc->sc_txbufp, sendlen); - -#if defined(NETIF_DEBUG) - printf("net_put: ub_send returned %d\n", rv); -#endif - if (rv == 0) - rv = len; - else - rv = -1; - - return (rv); -} - -static ssize_t -net_get(struct iodesc *desc, void **pkt, time_t timeout) -{ - struct netif *nif = desc->io_netif; - struct uboot_softc *sc = nif->nif_devdata; - time_t t; - int err, rlen; - size_t len; - char *buf; - -#if defined(NETIF_DEBUG) - printf("net_get: pkt %p, timeout %d\n", pkt, timeout); -#endif - t = getsecs(); - len = sizeof(sc->sc_rxbuf); - do { - err = ub_dev_recv(sc->sc_handle, sc->sc_rxbuf, len, &rlen); - - if (err != 0) { - printf("net_get: ub_dev_recv() failed, error=%d\n", - err); - rlen = 0; - break; - } - } while ((rlen == -1 || rlen == 0) && (getsecs() - t < timeout)); - -#if defined(NETIF_DEBUG) - printf("net_get: received len %d (%x)\n", rlen, rlen); -#endif - - if (rlen > 0) { - buf = malloc(rlen + ETHER_ALIGN); - if (buf == NULL) - return (-1); - memcpy(buf + ETHER_ALIGN, sc->sc_rxbuf, rlen); - *pkt = buf; - return ((ssize_t)rlen); - } - - return (-1); -} - -static void -net_init(struct iodesc *desc, void *machdep_hint) -{ - struct netif *nif = desc->io_netif; - struct uboot_softc *sc; - struct device_info *di; - int err; - - sc = nif->nif_devdata = &uboot_softc; - - if ((err = ub_dev_open(sc->sc_handle)) != 0) - panic("%s%d: initialisation failed with error %d", - nif->nif_driver->netif_bname, nif->nif_unit, err); - - /* Get MAC address */ - di = ub_dev_get(sc->sc_handle); - memcpy(desc->myea, di->di_net.hwaddr, 6); - if (memcmp (desc->myea, "\0\0\0\0\0\0", 6) == 0) { - panic("%s%d: empty ethernet address!", - nif->nif_driver->netif_bname, nif->nif_unit); - } - - /* Attempt to get netboot params from the u-boot env. */ - get_env_net_params(); - if (myip.s_addr != 0) - desc->myip = myip; - -#if defined(NETIF_DEBUG) - printf("network: %s%d attached to %s\n", nif->nif_driver->netif_bname, - nif->nif_unit, ether_sprintf(desc->myea)); -#endif - - /* Set correct alignment for TX packets */ - sc->sc_txbufp = sc->sc_txbuf; - if ((unsigned long)sc->sc_txbufp % PKTALIGN) - sc->sc_txbufp += PKTALIGN - - (unsigned long)sc->sc_txbufp % PKTALIGN; -} - -static void -net_end(struct netif *nif) -{ - struct uboot_softc *sc = nif->nif_devdata; - int err; - - if ((err = ub_dev_close(sc->sc_handle)) != 0) - panic("%s%d: net_end failed with error %d", - nif->nif_driver->netif_bname, nif->nif_unit, err); -} Index: stand/uboot/lib/reboot.c =================================================================== --- /dev/null +++ stand/uboot/lib/reboot.c @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2007 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 "glue.h" - -void -exit(int code) -{ - - ub_reset(); -} Index: stand/uboot/lib/time.c =================================================================== --- /dev/null +++ stand/uboot/lib/time.c @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 2000 Benno Rice - * Copyright (c) 2007 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 "glue.h" - -/* - * Return the time in seconds since the beginning of the day. - */ -time_t -time(time_t *tloc) -{ - int secs; - - secs = ub_get_timer(0) / 1000; - if (tloc) - *tloc = secs; - - return (secs); -} - -time_t -getsecs(void) -{ - - return (time(NULL)); -} - -/* - * Use U-Boot udelay() function to wait for a given microseconds period - */ -void -delay(int usecs) -{ - - ub_udelay(usecs); -} Index: stand/uboot/version =================================================================== --- /dev/null +++ stand/uboot/version @@ -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. + +1.5: Unified ubldr build