socsvn commit: r287130 - in soc2015/mihai/boot-wrapper: . libfdt
mihai at FreeBSD.org
mihai at FreeBSD.org
Mon Jun 15 19:51:37 UTC 2015
Author: mihai
Date: Mon Jun 15 19:51:31 2015
New Revision: 287130
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287130
Log:
soc2015: mihai: add boot-wrapper for fast-models
Added:
soc2015/mihai/boot-wrapper/ (props changed)
soc2015/mihai/boot-wrapper/LICENSE.txt
soc2015/mihai/boot-wrapper/Makefile
soc2015/mihai/boot-wrapper/README.txt
soc2015/mihai/boot-wrapper/boot.S
soc2015/mihai/boot-wrapper/build_freebsd.sh (contents, props changed)
soc2015/mihai/boot-wrapper/c_start.c
soc2015/mihai/boot-wrapper/config-default.mk
soc2015/mihai/boot-wrapper/libfdt/ (props changed)
soc2015/mihai/boot-wrapper/libfdt/Makefile.libfdt
soc2015/mihai/boot-wrapper/libfdt/fdt.c
soc2015/mihai/boot-wrapper/libfdt/fdt.h
soc2015/mihai/boot-wrapper/libfdt/fdt_ro.c
soc2015/mihai/boot-wrapper/libfdt/fdt_rw.c
soc2015/mihai/boot-wrapper/libfdt/fdt_strerror.c
soc2015/mihai/boot-wrapper/libfdt/fdt_sw.c
soc2015/mihai/boot-wrapper/libfdt/fdt_wip.c
soc2015/mihai/boot-wrapper/libfdt/libfdt.h
soc2015/mihai/boot-wrapper/libfdt/libfdt_env.h
soc2015/mihai/boot-wrapper/libfdt/libfdt_internal.h
soc2015/mihai/boot-wrapper/model.lds.S
soc2015/mihai/boot-wrapper/semi_loader.c
soc2015/mihai/boot-wrapper/semi_loader.h
soc2015/mihai/boot-wrapper/semihosting.c
soc2015/mihai/boot-wrapper/semihosting.h
soc2015/mihai/boot-wrapper/string.c
soc2015/mihai/boot-wrapper/string.h
Added: soc2015/mihai/boot-wrapper/LICENSE.txt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/LICENSE.txt Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,28 @@
+Copyright (c) 2011, ARM Limited
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * 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.
+ * Neither the name of ARM nor the names of its contributors may be
+ used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+HOLDER 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.
Added: soc2015/mihai/boot-wrapper/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/Makefile Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,78 @@
+# Makefile - build a kernel+filesystem image for stand-alone Linux booting
+#
+# Copyright (C) 2011 ARM Limited. All rights reserved.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE.txt file.
+
+
+# Include config file (prefer config.mk, fall back to config-default.mk)
+ifneq ($(wildcard config.mk),)
+include config.mk
+else
+include config-default.mk
+endif
+
+LIBFDTOBJS = libfdt/fdt.o libfdt/fdt_ro.o libfdt/fdt_wip.o \
+ libfdt/fdt_sw.o libfdt/fdt_rw.o libfdt/fdt_strerror.o
+BOOTLOADER = boot.S
+OBJS = boot.o c_start.o semihosting.o string.o semi_loader.o $(LIBFDTOBJS)
+KERNEL = uImage
+
+IMAGE = linux-system.axf
+SEMIIMG = linux-system-semi.axf
+LD_SCRIPT = model.lds.S
+
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CROSS_COMPILE)ld
+
+# These are needed by the underlying kernel make
+export CROSS_COMPILE ARCH
+
+# Build all wrappers
+all: $(IMAGE) $(SEMIIMG)
+
+# Build just the semihosting wrapper
+semi: $(SEMIIMG)
+
+clean distclean:
+ rm -f $(IMAGE) $(SEMIIMG) \
+ model.lds modelsemi.lds $(OBJS) $(KERNEL)
+
+$(KERNEL): $(KERNEL_SRC)/arch/arm/boot/uImage
+ cp $< $@
+
+$(IMAGE): $(OBJS) model.lds $(KERNEL) $(FILESYSTEM) Makefile
+ $(LD) -o $@ $(OBJS) --script=model.lds
+
+$(SEMIIMG): $(OBJS) modelsemi.lds
+ $(LD) -o $@ $(OBJS) --script=modelsemi.lds
+
+boot.o: $(BOOTLOADER)
+ $(CC) $(CPPFLAGS) -DKCMD='$(KCMD)' -c -o $@ $<
+
+%.o: %.c
+ $(CC) $(CPPFLAGS) -O2 -ffreestanding -I. -Ilibfdt -c -o $@ $<
+
+model.lds: $(LD_SCRIPT) Makefile
+ $(CC) $(CPPFLAGS) -E -P -C -o $@ $<
+
+modelsemi.lds: $(LD_SCRIPT) Makefile
+ $(CC) $(CPPFLAGS) -DSEMIHOSTING=1 -E -P -C -o $@ $<
+
+$(KERNEL_SRC)/arch/arm/boot/uImage: force
+ $(MAKE) -C $(KERNEL_SRC) -j4 uImage
+
+# Pass any target we don't know about through to the kernel makefile.
+# This is a convenience rule so we can say 'make menuconfig' etc here.
+# Note that any rules in this file must have a command or be marked as
+# .PHONY.
+%: force
+ $(MAKE) -C $(KERNEL_SRC) $@
+
+force: ;
+
+Makefile: ;
+
+.PHONY: all semi clean distclean config.mk config-default.mk
Added: soc2015/mihai/boot-wrapper/README.txt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/README.txt Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,74 @@
+boot-wrapper: Start Linux kernels under ARM Fast Models
+
+The boot-wrapper is a fairly simple implementation of a boot loader
+intended to run under an ARM Fast Model and boot Linux.
+
+License
+=======
+
+The boot-wrapper is generally under a 3 clause BSD license
+(see LICENSE.txt for details). Note that some source files
+are under similar but compatible licenses. In particular
+libfdt is dual-license GPL/2-clause-BSD.
+
+Compilation
+===========
+
+The expected method of building is to cross-compile on an
+x86 box. You'll need an ARM cross-compiler. On Ubuntu you
+can get this by installing the packages:
+ gcc-4.6-arm-linux-gnueabi binutils-arm-linux-gnueabi
+ libc6-armel-cross linux-libc-dev-armel-cross gcc-arm-linux-gnueabi
+ libc6-dev-armel-cross cpp-arm-linux-gnueabi
+
+The boot-wrapper can be compiled in two ways:
+ (1) as a small standalone binary which uses the model's semihosting
+ ABI to load a kernel (and optionally initrd and flattened device tree)
+ when you run the model
+ (2) with a specific kernel and initrd compiled into the binary;
+ this is less flexible but may be useful in some situations
+
+For case (1) you can just run:
+ make CROSS_COMPILE=arm-linux-gnueabi- semi
+which will build "linux-system-semi.axf".
+(As with a Linux kernel cross-compile, the CROSS_COMPILE
+variable is set to the prefix of the cross toolchain.
+"arm-linux-gnueabi-" matches the prefix used by the Ubuntu
+cross toolchain.)
+
+For case (2) you'll need a Linux kernel tree to hand; the
+boot-wrapper makefile will automatically look into it to
+extract the kernel. By default this tree is assumed to be in
+"../linux-kvm-arm". Assuming you have that tree set up and
+have built a kernel in it, you can run:
+ make CROSS_COMPILE=arm-linux-gnueabi-
+which will build "linux-system.axf".
+
+You can configure the makefile system by copying config-default.mk
+to config.mk and editing it. This is only likely to be useful for
+case (2); see the comments in config-default.mk for more information.
+
+Running
+=======
+
+To run a model with a linux-system-semi.axf:
+
+RTSM_VE_Cortex-A15x1 linux-system-semi.axf -C cluster.cpu0.semihosting-cmd_line="--kernel /path/to/zImage [--initrd /path/to/initrd] [--dtb /path/to/dtb] [-- kernel command line arguments]"
+
+The paths to the kernel, initrd and device tree blob should all be
+host filesystem paths. The initrd and dtb are both optional. Any text
+following '--' is passed to the kernel as its command line; this is
+also optional.
+
+You may also want to pass other options to the model (for instance
+to enable networking); these are not described here. See the Fast
+Models documentation for more information.
+
+Running a linux-system.axf is the same, except that since all
+the files are built in there's no need to pass a command line:
+
+RTSM_VE_Cortex-A15x1 linux-system.axf
+
+Passing a command line to linux-system.axf is allowed, and any
+kernel/initrd/dtb/commandline specified will override the compiled-in
+version.
Added: soc2015/mihai/boot-wrapper/boot.S
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/boot.S Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,216 @@
+/*
+ * boot.S - simple register setup code for stand-alone Linux booting
+ *
+ * Copyright (C) 2011 ARM Limited. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE.txt file.
+ */
+
+ .syntax unified
+ .arch_extension sec
+ .arch_extension virt
+ .text
+
+.macro enter_hyp
+ @ We assume we're entered in Secure Supervisor mode. To
+ @ get to Hyp mode we have to pass through Monitor mode
+ @ and NS-Supervisor mode. Note that there is no way to
+ @ return to the Secure world once we've done this.
+ @
+ @ This will trash r10 and r11.
+ ldr r10, =vectors
+ mcr p15, 0, r10, c12, c0, 1 @ Monitor vector base address
+ @ Switch to monitor mode, which will set up the HVBAR and
+ @ then return to us in NS-SVC
+ smc #0
+ @ Now we're in NS-SVC, make a Hyp call to get into Hyp mode
+// hvc #0
+ @ We will end up here in NS-Hyp.
+.endm
+
+.align 5
+/* We use the same vector table for Hyp and Monitor mode, since
+ * we will only use each once and they don't overlap.
+ */
+vectors:
+ .word 0 /* reset */
+ .word 0 /* undef */
+ b 2f /* smc */
+ .word 0 /* pabt */
+ .word 0 /* dabt */
+ b 1f
+ .word 0 /* irq */
+ .word 0 /* fiq */
+
+/* Return directly back to the caller without leaving Hyp mode: */
+1: mrs lr, elr_hyp
+ mov pc, lr
+
+/* In monitor mode, set up HVBAR and SCR then return to caller in NS-SVC. */
+2:
+ @ Set up HVBAR
+ mrc p15, 0, r10, c1, c1, 0 @ SCR
+ @ Set SCR.NS=1 (needed for setting HVBAR and also returning to NS state)
+ @ .IRQ,FIQ,EA=0 (don't take aborts/exceptions to Monitor mode)
+ @ .FW,AW=1 (CPSR.A,F modifiable in NS state)
+ @ .nET=0 (early termination OK)
+ @ .SCD=1 (SMC in NS mode is UNDEF, so accidental SMCs don't
+ @ cause us to leap back into this code confusingly)
+ @ .HCE=1 (HVC does Hyp call)
+ bic r10, r10, #0x07f
+ ldr r11, =0x1b1
+ orr r10, r10, r11
+ mcr p15, 0, r11, c1, c1, 0
+ isb
+ ldr r11, =vectors
+ mcr p15, 4, r11, c12, c0, 0 @ set HVBAR
+ @ ...and return to calling code in NS state
+ movs pc, lr
+
+
+ .globl start
+start:
+#ifdef SMP
+#ifdef VEXPRESS
+ @
+ @ Program architected timer frequency
+ @
+ mrc p15, 0, r0, c0, c1, 1 @ CPUID_EXT_PFR1
+ lsr r0, r0, #16
+ and r0, r0, #1 @ Check generic timer support
+ beq 1f
+ ldr r0, =24000000 @ 24MHz timer frequency
+ mcr p15, 0, r0, c14, c0, 0 @ CNTFRQ
+1:
+#endif
+ @
+ @ CPU initialisation
+ @
+ mrc p15, 0, r4, c0, c0, 5 @ MPIDR (ARMv7 only)
+ and r4, r4, #15 @ CPU number
+
+ @
+ @ Hypervisor / TrustZone initialization
+ @
+
+ @ Set all interrupts to be non-secure
+ ldr r0, =0x2c001000 @ Dist GIC base
+ ldr r1, [r0, #0x04] @ Type Register
+ cmp r4, #0
+ andeq r1, r1, #0x1f
+ movne r1, #0
+ add r2, r0, #0x080 @ Security Register 0
+ mvn r3, #0
+2: str r3, [r2]
+ sub r1, r1, #1
+ add r2, r2, #4 @ Next security register
+ cmp r1, #-1
+ bne 2b
+
+ @ Set GIC priority mask bit [7] = 1
+ ldr r0, =0x2c002000 @ CPU GIC base
+ mov r1, #0x80
+ str r1, [r0, #0x4] @ GIC ICCPMR
+
+ @ Set NSACR to allow coprocessor access from non-secure
+ mrc p15, 0, r0, c1, c1, 2
+ ldr r1, =0x43fff
+ orr r0, r0, r1
+ mcr p15, 0, r0, c1, c1, 2
+
+ @ Check CPU nr again
+ mrc p15, 0, r0, c0, c0, 5 @ MPIDR (ARMv7 only)
+ bfc r0, #24, #8 @ CPU number, taking multicluster into account
+ cmp r0, #0 @ primary CPU?
+ beq 2f
+
+ @
+ @ Secondary CPUs (following the RealView SMP booting protocol)
+ @
+ enter_hyp
+
+ ldr r1, =fs_start - 0x100
+ adr r2, 1f
+ ldmia r2, {r3 - r7} @ move the code to a location
+ stmia r1, {r3 - r7} @ less likely to be overridden
+#ifdef VEXPRESS
+ ldr r0, =0x1c010030 @ VE SYS_FLAGS register
+#else
+ ldr r0, =0x10000030 @ RealView SYS_FLAGS register
+#endif
+ mov pc, r1 @ branch to the relocated code
+1:
+#ifdef VEXPRESS
+ wfe
+#endif
+ ldr r1, [r0]
+ cmp r1, #0
+ beq 1b
+ mov pc, r1 @ branch to the given address
+#endif
+
+2:
+ @
+ @ UART initialisation (38400 8N1)
+ @
+#ifdef MACH_MPS
+ ldr r0, =0x1f005000 @ UART3 base (MPS)
+#elif defined (VEXPRESS)
+ ldr r0, =0x1c090000 @ UART base (Versatile Express)
+#else
+ ldr r0, =0x10009000 @ UART base (RealView/EB)
+#endif
+ mov r1, #0x10 @ ibrd
+ str r1, [r0, #0x24]
+ mov r1, #0xc300
+ orr r1, #0x0001 @ cr
+ str r1, [r0, #0x30]
+
+ @ Now we've got rid of the secondary CPUs, set up a stack
+ @ for CPU 0 so we can write most of this in C.
+ ldr sp, =stacktop
+
+ @ And call the C entrypoint
+ bl c_start
+ @ Never reached
+1: b 1b
+
+ @
+ @ Function for C code to make semihosting calls:
+ @
+ .globl __semi_call
+__semi_call:
+#if defined(MACH_MPS)
+ @ M profile semihosting is via bpkt
+ bkpt 0xab
+#elif defined(__thumb__)
+ @ Otherwise, different SVC numbers for ARM or Thumb mode
+ svc 0xab
+#else
+ svc 0x123456
+#endif
+ mov pc, lr
+
+.globl __boot_kernel
+__boot_kernel:
+ mov r4, r0
+ stmfd sp!, {r1-r3}
+ ldmia sp, {r0-r3}
+
+ enter_hyp
+
+ bx r4
+.type __boot_kernel, %function
+
+ @
+ @ Data
+ @
+ /* The kernel boot command line for builtin kernels is defined in the Make system */
+ .globl kernel_cmd
+ .globl kernel_cmd_end
+kernel_cmd:
+#ifdef KCMD
+ .asciz KCMD
+#endif
+kernel_cmd_end:
Added: soc2015/mihai/boot-wrapper/build_freebsd.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/build_freebsd.sh Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1 @@
+gmake CROSS_COMPILE=arm-none-eabi- semi
Added: soc2015/mihai/boot-wrapper/c_start.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/c_start.c Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012 Linaro Limited
+ * 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.
+ * 3. Neither the name of Linaro Limited nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ */
+
+/* This file just contains a small glue function which fishes the
+ * location of kernel etc out of linker script defined symbols, and
+ * calls semi_loader functions to do the actual work of loading
+ * and booting the kernel.
+ */
+
+#include <stdint.h>
+#include "semihosting.h"
+#include "semi_loader.h"
+
+/* Linker script defined symbols for any preloaded kernel/initrd */
+extern uint8_t fs_start, fs_end, kernel_entry, kernel_start, kernel_end;
+/* Symbols defined by boot.S */
+extern uint8_t kernel_cmd, kernel_cmd_end;
+
+static struct loader_info loader;
+
+#ifdef MACH_MPS
+#define PLAT_ID 10000 /* MPS (temporary) */
+#elif defined (VEXPRESS)
+#define PLAT_ID 2272 /* Versatile Express */
+#else
+#define PLAT_ID 827 /* RealView/EB */
+#endif
+
+void c_start(void)
+{
+ /* Main C entry point */
+ loader.kernel_size = (uint32_t)&kernel_end - (uint32_t)&kernel_start;
+ loader.initrd_start = (uint32_t)&fs_start;
+ loader.initrd_size = (uint32_t)&fs_end - (uint32_t)&fs_start;
+ loader.kernel_entry = (uint32_t)&kernel_entry;
+ if (loader.kernel_size) {
+ loader.cmdline_start = (uint32_t)&kernel_cmd;
+ loader.cmdline_size = &kernel_cmd_end - &kernel_cmd;
+ }
+ load_kernel(&loader);
+
+ /* Start the kernel */
+ if(loader.fdt_start) {
+ boot_kernel(&loader, 0, -1, loader.fdt_start, 0);
+ } else {
+ boot_kernel(&loader, 0, PLAT_ID, loader.atags_start, 0);
+ }
+
+ semi_write0("[bootwrapper] ERROR: returned from boot_kernel\n");
+}
Added: soc2015/mihai/boot-wrapper/config-default.mk
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/config-default.mk Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,100 @@
+# Configuration file included in Makefile
+#
+# Copyright (C) 2011 Columbia University. All rights reserved.
+# Christoffer Dall <cdall at cs.columbia.edu>
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE.txt file.
+#
+# This is a sample configuration file. To make changes, copy this file to
+# config.mk and modify that file.
+#
+# For all systems you can override USE_INITRD and KCMD from the command-line.
+#
+
+###########################################################################
+# Main options
+#
+CROSS_COMPILE ?= arm-unknown-eabi-
+ARCH ?= arm
+KERNEL_SRC ?= ../linux-kvm-arm
+
+# Select system:
+# mps: MPS (Cortex-M3)
+# realview_eb: RealViewPB, EB, etc.
+# vexpress: Versatile Express
+SYSTEM ?= vexpress
+
+###########################################################################
+# Turn this on to use an initrd whose contents are in filesystem.cpio.gz
+USE_INITRD ?= no
+ifeq ($(USE_INITRD),yes)
+CPPFLAGS += -DUSE_INITRD
+FILESYSTEM ?= filesystem.cpio.gz
+else
+FILESYSTEM =
+endif
+
+###########################################################################
+# Default NFS root
+NFS_ROOT ?= /srv/nfsroot
+ifeq ($(origin NFS_SERVER), undefined)
+NFS_SERVER := $(shell ip addr show scope global | \
+ sed -ne '/inet/{s/ *inet \([^/]*\)\/.*/\1/p;q}')
+endif
+
+
+###########################################################################
+# MPS (Cortex-M3) definitions
+#
+ifeq ($(SYSTEM),mps)
+# C-flags
+CPPFLAGS += -DMACH_MPS -DTHUMB2_KERNEL
+CPPFLAGS += -march=armv7-m
+CPPFLAGS += -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always
+
+# Kernel command line
+KCMD ?= "rdinit=/bin/sh console=ttyAMA3 mem=4M earlyprintk"
+endif # SYSTEM = mps
+
+
+###########################################################################
+# EB, RealviewPB, etc
+#
+ifeq ($(SYSTEM),realview_eb)
+
+CPPFLAGS += -DSMP
+CPPFLAGS += -march=armv7-a -marm
+#CPPFLAGS += -DTHUMB2_KERNEL
+
+# Default kernel command line, using initrd:
+ifeq ($(USE_INITRD),yes)
+ KCMD ?= "console=ttyAMA0 mem=256M earlyprintk"
+endif
+#
+# Default kernel command line, without initrd:
+ifneq ($(USE_INITRD),yes)
+ KCMD ?= "root=/dev/nfs nfsroot=$(NFS_HOST):$(NFS_ROOT) ip=dhcp console=ttyAMA0 mem=256M earlyprintk"
+endif
+endif # SYSTEM = realvire_eb
+
+
+###########################################################################
+# Versatile Express
+#
+ifeq ($(SYSTEM),vexpress)
+
+CPPFLAGS += -DSMP
+CPPFLAGS += -march=armv7-a -marm
+#CPPFLAGS += -DTHUMB2_KERNEL
+CPPFLAGS += -DVEXPRESS
+
+# Default kernel command line, using initrd:
+ifeq ($(USE_INITRD),yes)
+ KCMD ?= "console=ttyAMA0 mem=512M mem=512M at 0x880000000 earlyprintk ip=dhcp"
+endif
+#
+# Default kernel command line, without initrd:
+ifneq ($(USE_INITRD),yes)
+ KCMD ?= "console=ttyAMA0 mem=512M mem=512M at 0x880000000 earlyprintk root=/dev/nfs nfsroot=$(NFS_SERVER):$(NFS_ROOT),tcp rw ip=dhcp nfsrootdebug"
+endif
+endif # SYSTEM = vexpress
Added: soc2015/mihai/boot-wrapper/libfdt/Makefile.libfdt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/libfdt/Makefile.libfdt Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,24 @@
+# Makefile.libfdt
+#
+# This is not a complete Makefile of itself. Instead, it is designed to
+# be easily embeddable into other systems of Makefiles.
+#
+-include $(d)/*.d
+
+LIBFDT_CPPFLAGS += -I$(d)
+LIBFDT_OBJS := \
+ $(d)/fdt.o \
+ $(d)/fdt_ro.o \
+ $(d)/fdt_wip.o \
+ $(d)/fdt_sw.o \
+ $(d)/fdt_rw.o \
+ $(d)/fdt_strerror.o
+
+CLEAN_SUBDIRS += $(d)
+
+OBJS-libfdt.a = $(LIBFDT_OBJS)
+libfdt.a: $(OBJS-libfdt.a)
+
+$(d)/%.o: $(d)/%.c
+ @echo " CC[LIB] $<"
+ $(Q)$(CC) $(LIBFDT_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
Added: soc2015/mihai/boot-wrapper/libfdt/fdt.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/libfdt/fdt.c Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,201 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ * a) This library 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 library 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 library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ * b) 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+int fdt_check_header(const void *fdt)
+{
+ if (fdt_magic(fdt) == FDT_MAGIC) {
+ /* Complete tree */
+ if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
+ return -FDT_ERR_BADVERSION;
+ if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)
+ return -FDT_ERR_BADVERSION;
+ } else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
+ /* Unfinished sequential-write blob */
+ if (fdt_size_dt_struct(fdt) == 0)
+ return -FDT_ERR_BADSTATE;
+ } else {
+ return -FDT_ERR_BADMAGIC;
+ }
+
+ return 0;
+}
+
+const void *fdt_offset_ptr(const void *fdt, int offset, int len)
+{
+ const char *p;
+
+ if (fdt_version(fdt) >= 0x11)
+ if (((offset + len) < offset)
+ || ((offset + len) > fdt_size_dt_struct(fdt)))
+ return NULL;
+
+ p = _fdt_offset_ptr(fdt, offset);
+
+ if (p + len < p)
+ return NULL;
+ return p;
+}
+
+uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset)
+{
+ const uint32_t *tagp, *lenp;
+ uint32_t tag;
+ const char *p;
+
+ if (offset % FDT_TAGSIZE)
+ return -1;
+
+ tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE);
+ if (! tagp)
+ return FDT_END; /* premature end */
+ tag = fdt32_to_cpu(*tagp);
+ offset += FDT_TAGSIZE;
+
+ switch (tag) {
+ case FDT_BEGIN_NODE:
+ /* skip name */
+ do {
+ p = fdt_offset_ptr(fdt, offset++, 1);
+ } while (p && (*p != '\0'));
+ if (! p)
+ return FDT_END;
+ break;
+ case FDT_PROP:
+ lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));
+ if (! lenp)
+ return FDT_END;
+ /* skip name offset, length and value */
+ offset += 2*FDT_TAGSIZE + fdt32_to_cpu(*lenp);
+ break;
+ }
+
+ if (nextoffset)
+ *nextoffset = FDT_TAGALIGN(offset);
+
+ return tag;
+}
+
+int _fdt_check_node_offset(const void *fdt, int offset)
+{
+ if ((offset < 0) || (offset % FDT_TAGSIZE)
+ || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))
+ return -FDT_ERR_BADOFFSET;
+
+ return offset;
+}
+
+int fdt_next_node(const void *fdt, int offset, int *depth)
+{
+ int nextoffset = 0;
+ uint32_t tag;
+
+ if (offset >= 0)
+ if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0)
+ return nextoffset;
+
+ do {
+ offset = nextoffset;
+ tag = fdt_next_tag(fdt, offset, &nextoffset);
+
+ switch (tag) {
+ case FDT_PROP:
+ case FDT_NOP:
+ break;
+
+ case FDT_BEGIN_NODE:
+ if (depth)
+ (*depth)++;
+ break;
+
+ case FDT_END_NODE:
+ if (depth)
+ (*depth)--;
+ break;
+
+ case FDT_END:
+ return -FDT_ERR_NOTFOUND;
+
+ default:
+ return -FDT_ERR_BADSTRUCTURE;
+ }
+ } while (tag != FDT_BEGIN_NODE);
+
+ return offset;
+}
+
+const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
+{
+ int len = strlen(s) + 1;
+ const char *last = strtab + tabsize - len;
+ const char *p;
+
+ for (p = strtab; p <= last; p++)
+ if (memcmp(p, s, len) == 0)
+ return p;
+ return NULL;
+}
+
+int fdt_move(const void *fdt, void *buf, int bufsize)
+{
+ FDT_CHECK_HEADER(fdt);
+
+ if (fdt_totalsize(fdt) > bufsize)
+ return -FDT_ERR_NOSPACE;
+
+ memmove(buf, fdt, fdt_totalsize(fdt));
+ return 0;
+}
Added: soc2015/mihai/boot-wrapper/libfdt/fdt.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/libfdt/fdt.h Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,60 @@
+#ifndef _FDT_H
+#define _FDT_H
+
+#ifndef __ASSEMBLY__
+
+struct fdt_header {
+ uint32_t magic; /* magic word FDT_MAGIC */
+ uint32_t totalsize; /* total size of DT block */
+ uint32_t off_dt_struct; /* offset to structure */
+ uint32_t off_dt_strings; /* offset to strings */
+ uint32_t off_mem_rsvmap; /* offset to memory reserve map */
+ uint32_t version; /* format version */
+ uint32_t last_comp_version; /* last compatible version */
+
+ /* version 2 fields below */
+ uint32_t boot_cpuid_phys; /* Which physical CPU id we're
+ booting on */
+ /* version 3 fields below */
+ uint32_t size_dt_strings; /* size of the strings block */
+
+ /* version 17 fields below */
+ uint32_t size_dt_struct; /* size of the structure block */
+};
+
+struct fdt_reserve_entry {
+ uint64_t address;
+ uint64_t size;
+};
+
+struct fdt_node_header {
+ uint32_t tag;
+ char name[0];
+};
+
+struct fdt_property {
+ uint32_t tag;
+ uint32_t len;
+ uint32_t nameoff;
+ char data[0];
+};
+
+#endif /* !__ASSEMBLY */
+
+#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
+#define FDT_TAGSIZE sizeof(uint32_t)
+
+#define FDT_BEGIN_NODE 0x1 /* Start node: full name */
+#define FDT_END_NODE 0x2 /* End node */
+#define FDT_PROP 0x3 /* Property: name off,
+ size, content */
+#define FDT_NOP 0x4 /* nop */
+#define FDT_END 0x9
+
+#define FDT_V1_SIZE (7*sizeof(uint32_t))
+#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(uint32_t))
+#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V16_SIZE FDT_V3_SIZE
+#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(uint32_t))
+
+#endif /* _FDT_H */
Added: soc2015/mihai/boot-wrapper/libfdt/fdt_ro.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2015/mihai/boot-wrapper/libfdt/fdt_ro.c Mon Jun 15 19:51:31 2015 (r287130)
@@ -0,0 +1,469 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ * a) This library 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 library 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 library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ * b) 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+static int _fdt_nodename_eq(const void *fdt, int offset,
+ const char *s, int len)
+{
+ const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
+
+ if (! p)
+ /* short match */
+ return 0;
+
+ if (memcmp(p, s, len) != 0)
+ return 0;
+
+ if (p[len] == '\0')
+ return 1;
+ else if (!memchr(s, '@', len) && (p[len] == '@'))
+ return 1;
+ else
+ return 0;
+}
+
+const char *fdt_string(const void *fdt, int stroffset)
+{
+ return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
+}
+
+int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
+{
+ FDT_CHECK_HEADER(fdt);
+ *address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);
+ *size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);
+ return 0;
+}
+
+int fdt_num_mem_rsv(const void *fdt)
+{
+ int i = 0;
+
+ while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->size) != 0)
+ i++;
+ return i;
+}
+
+int fdt_subnode_offset_namelen(const void *fdt, int offset,
+ const char *name, int namelen)
+{
+ int depth;
+
+ FDT_CHECK_HEADER(fdt);
+
+ for (depth = 0, offset = fdt_next_node(fdt, offset, &depth);
+ (offset >= 0) && (depth > 0);
+ offset = fdt_next_node(fdt, offset, &depth)) {
+ if (depth < 0)
+ return -FDT_ERR_NOTFOUND;
+ else if ((depth == 1)
+ && _fdt_nodename_eq(fdt, offset, name, namelen))
+ return offset;
+ }
+
+ if (offset < 0)
+ return offset; /* error */
+ else
+ return -FDT_ERR_NOTFOUND;
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-soc-all
mailing list