arch: add minimal aarch64 support
Subsystems (5)
RFC 1/1 arch: add minimal aarch64 support
This commit add minimal support for aarch64/arm64 architecture.
The main current limitations are:
- MMU not implemented
- barebox running at EL1
- barebox env not working
- only test on qemu
--- arch/arm64/Kconfig | 140 +++++++ arch/arm64/Makefile | 109 +++++ arch/arm64/boards/Makefile | 2 + arch/arm64/boards/virt/Kconfig | 8 + arch/arm64/boards/virt/Makefile | 3 + arch/arm64/boards/virt/env/config | 38 ++ arch/arm64/boards/virt/init.c | 52 +++ arch/arm64/boards/virt/lowlevel.c | 18 + arch/arm64/configs/virt_defconfig | 53 +++ arch/arm64/cpu/Kconfig | 54 +++ arch/arm64/cpu/Makefile | 30 ++ arch/arm64/cpu/cache-armv8.S | 168 ++++++++ arch/arm64/cpu/cache.c | 110 ++++++ arch/arm64/cpu/cpu.c | 106 +++++ arch/arm64/cpu/cpuinfo.c | 211 ++++++++++ arch/arm64/cpu/entry.c | 38 ++ arch/arm64/cpu/entry.h | 18 + arch/arm64/cpu/exceptions.S | 127 ++++++ arch/arm64/cpu/interrupts.c | 162 ++++++++ arch/arm64/cpu/lowlevel.S | 49 +++ arch/arm64/cpu/mmu-early.c | 53 +++ arch/arm64/cpu/mmu-early.h | 6 + arch/arm64/cpu/mmu.c | 492 +++++++++++++++++++++++ arch/arm64/cpu/mmu.h | 14 + arch/arm64/cpu/mmuinfo.c | 104 +++++ arch/arm64/cpu/no-mmu.c | 61 +++ arch/arm64/cpu/start-pbl.c | 102 +++++ arch/arm64/cpu/start.c | 247 ++++++++++++ arch/arm64/cpu/uncompress.c | 111 ++++++ arch/arm64/include/asm/armlinux.h | 43 ++ arch/arm64/include/asm/assembler.h | 116 ++++++ arch/arm64/include/asm/barebox-arm-head.h | 65 +++ arch/arm64/include/asm/barebox-arm.h | 165 ++++++++ arch/arm64/include/asm/barebox.h | 12 + arch/arm64/include/asm/bitops.h | 48 +++ arch/arm64/include/asm/bitsperlong.h | 1 + arch/arm64/include/asm/byteorder.h | 32 ++ arch/arm64/include/asm/cache-l2x0.h | 101 +++++ arch/arm64/include/asm/cache.h | 16 + arch/arm64/include/asm/common.h | 48 +++ arch/arm64/include/asm/cputype.h | 100 +++++ arch/arm64/include/asm/debug_ll_pl011.h | 25 ++ arch/arm64/include/asm/dma.h | 46 +++ arch/arm64/include/asm/elf.h | 119 ++++++ arch/arm64/include/asm/errata.h | 79 ++++ arch/arm64/include/asm/gic.h | 128 ++++++ arch/arm64/include/asm/hardware/arm_timer.h | 38 ++ arch/arm64/include/asm/hardware/sp810.h | 68 ++++ arch/arm64/include/asm/io.h | 87 ++++ arch/arm64/include/asm/linkage.h | 11 + arch/arm64/include/asm/memory.h | 19 + arch/arm64/include/asm/mmu.h | 65 +++ arch/arm64/include/asm/module.h | 13 + arch/arm64/include/asm/pgtable.h | 90 +++++ arch/arm64/include/asm/posix_types.h | 1 + arch/arm64/include/asm/processor.h | 131 ++++++ arch/arm64/include/asm/ptrace.h | 34 ++ arch/arm64/include/asm/sections.h | 34 ++ arch/arm64/include/asm/semihosting.h | 19 + arch/arm64/include/asm/setup.h | 216 ++++++++++ arch/arm64/include/asm/stacktrace.h | 16 + arch/arm64/include/asm/string.h | 13 + arch/arm64/include/asm/swab.h | 69 ++++ arch/arm64/include/asm/system.h | 125 ++++++ arch/arm64/include/asm/system_info.h | 194 +++++++++ arch/arm64/include/asm/types.h | 54 +++ arch/arm64/include/asm/unaligned.h | 19 + arch/arm64/include/asm/unified.h | 127 ++++++ arch/arm64/include/asm/unwind.h | 51 +++ arch/arm64/lib/Makefile | 16 + arch/arm64/lib/armlinux.c | 275 +++++++++++++ arch/arm64/lib/asm-offsets.c | 16 + arch/arm64/lib/barebox.lds | 125 ++++++ arch/arm64/lib/barebox.lds.S | 125 ++++++ arch/arm64/lib/bootm.c | 572 +++++++++++++++++++++++++++ arch/arm64/lib/bootu.c | 44 +++ arch/arm64/lib/bootz.c | 136 +++++++ arch/arm64/lib/copy_template.S | 192 +++++++++ arch/arm64/lib/div0.c | 27 ++ arch/arm64/lib/memcpy.S | 74 ++++ arch/arm64/lib/memset.S | 215 ++++++++++ arch/arm64/lib/module.c | 98 +++++ arch/arm64/lib/pbl.lds.S | 96 +++++ arch/arm64/lib/runtime-offset.S | 52 +++ arch/arm64/lib/unwind.c | 349 ++++++++++++++++ arch/arm64/mach-virt/Kconfig | 15 + arch/arm64/mach-virt/Makefile | 1 + arch/arm64/mach-virt/devices.c | 30 ++ arch/arm64/mach-virt/include/mach/debug_ll.h | 24 ++ arch/arm64/mach-virt/include/mach/devices.h | 13 + arch/arm64/mach-virt/reset.c | 24 ++ arch/arm64/pbl/Makefile | 58 +++ arch/arm64/pbl/piggy.gzip.S | 6 + arch/arm64/pbl/piggy.lz4.S | 6 + arch/arm64/pbl/piggy.lzo.S | 6 + arch/arm64/pbl/piggy.shipped.S | 6 + arch/arm64/pbl/piggy.xzkern.S | 6 + 97 files changed, 7931 insertions(+) create mode 100644 arch/arm64/Kconfig create mode 100644 arch/arm64/Makefile create mode 100644 arch/arm64/boards/Makefile create mode 100644 arch/arm64/boards/virt/Kconfig create mode 100644 arch/arm64/boards/virt/Makefile create mode 100644 arch/arm64/boards/virt/env/config create mode 100644 arch/arm64/boards/virt/init.c create mode 100644 arch/arm64/boards/virt/lowlevel.c create mode 100644 arch/arm64/configs/virt_defconfig create mode 100644 arch/arm64/cpu/Kconfig create mode 100644 arch/arm64/cpu/Makefile create mode 100644 arch/arm64/cpu/cache-armv8.S create mode 100644 arch/arm64/cpu/cache.c create mode 100644 arch/arm64/cpu/cpu.c create mode 100644 arch/arm64/cpu/cpuinfo.c create mode 100644 arch/arm64/cpu/entry.c create mode 100644 arch/arm64/cpu/entry.h create mode 100644 arch/arm64/cpu/exceptions.S create mode 100644 arch/arm64/cpu/interrupts.c create mode 100644 arch/arm64/cpu/lowlevel.S create mode 100644 arch/arm64/cpu/mmu-early.c create mode 100644 arch/arm64/cpu/mmu-early.h create mode 100644 arch/arm64/cpu/mmu.c create mode 100644 arch/arm64/cpu/mmu.h create mode 100644 arch/arm64/cpu/mmuinfo.c create mode 100644 arch/arm64/cpu/no-mmu.c create mode 100644 arch/arm64/cpu/start-pbl.c create mode 100644 arch/arm64/cpu/start.c create mode 100644 arch/arm64/cpu/uncompress.c create mode 100644 arch/arm64/include/asm/armlinux.h create mode 100644 arch/arm64/include/asm/assembler.h create mode 100644 arch/arm64/include/asm/barebox-arm-head.h create mode 100644 arch/arm64/include/asm/barebox-arm.h create mode 100644 arch/arm64/include/asm/barebox.h create mode 100644 arch/arm64/include/asm/bitops.h create mode 100644 arch/arm64/include/asm/bitsperlong.h create mode 100644 arch/arm64/include/asm/byteorder.h create mode 100644 arch/arm64/include/asm/cache-l2x0.h create mode 100644 arch/arm64/include/asm/cache.h create mode 100644 arch/arm64/include/asm/common.h create mode 100644 arch/arm64/include/asm/cputype.h create mode 100644 arch/arm64/include/asm/debug_ll_pl011.h create mode 100644 arch/arm64/include/asm/dma.h create mode 100644 arch/arm64/include/asm/elf.h create mode 100644 arch/arm64/include/asm/errata.h create mode 100644 arch/arm64/include/asm/gic.h create mode 100644 arch/arm64/include/asm/hardware/arm_timer.h create mode 100644 arch/arm64/include/asm/hardware/sp810.h create mode 100644 arch/arm64/include/asm/io.h create mode 100644 arch/arm64/include/asm/linkage.h create mode 100644 arch/arm64/include/asm/memory.h create mode 100644 arch/arm64/include/asm/mmu.h create mode 100644 arch/arm64/include/asm/module.h create mode 100644 arch/arm64/include/asm/pgtable.h create mode 100644 arch/arm64/include/asm/posix_types.h create mode 100644 arch/arm64/include/asm/processor.h create mode 100644 arch/arm64/include/asm/ptrace.h create mode 100644 arch/arm64/include/asm/sections.h create mode 100644 arch/arm64/include/asm/semihosting.h create mode 100644 arch/arm64/include/asm/setup.h create mode 100644 arch/arm64/include/asm/stacktrace.h create mode 100644 arch/arm64/include/asm/string.h create mode 100644 arch/arm64/include/asm/swab.h create mode 100644 arch/arm64/include/asm/system.h create mode 100644 arch/arm64/include/asm/system_info.h create mode 100644 arch/arm64/include/asm/types.h create mode 100644 arch/arm64/include/asm/unaligned.h create mode 100644 arch/arm64/include/asm/unified.h create mode 100644 arch/arm64/include/asm/unwind.h create mode 100644 arch/arm64/lib/Makefile create mode 100644 arch/arm64/lib/armlinux.c create mode 100644 arch/arm64/lib/asm-offsets.c create mode 100644 arch/arm64/lib/barebox.lds create mode 100644 arch/arm64/lib/barebox.lds.S create mode 100644 arch/arm64/lib/bootm.c create mode 100644 arch/arm64/lib/bootu.c create mode 100644 arch/arm64/lib/bootz.c create mode 100644 arch/arm64/lib/copy_template.S create mode 100644 arch/arm64/lib/div0.c create mode 100644 arch/arm64/lib/memcpy.S create mode 100644 arch/arm64/lib/memset.S create mode 100644 arch/arm64/lib/module.c create mode 100644 arch/arm64/lib/pbl.lds.S create mode 100644 arch/arm64/lib/runtime-offset.S create mode 100644 arch/arm64/lib/unwind.c create mode 100644 arch/arm64/mach-virt/Kconfig create mode 100644 arch/arm64/mach-virt/Makefile create mode 100644 arch/arm64/mach-virt/devices.c create mode 100644 arch/arm64/mach-virt/include/mach/debug_ll.h create mode 100644 arch/arm64/mach-virt/include/mach/devices.h create mode 100644 arch/arm64/mach-virt/reset.c create mode 100644 arch/arm64/pbl/Makefile create mode 100644 arch/arm64/pbl/piggy.gzip.S create mode 100644 arch/arm64/pbl/piggy.lz4.S create mode 100644 arch/arm64/pbl/piggy.lzo.S create mode 100644 arch/arm64/pbl/piggy.shipped.S create mode 100644 arch/arm64/pbl/piggy.xzkern.S
arch/arm64/Kconfig new file +140 -0
@@ -0,0 +1,140 @@ +config ARM + bool + select HAS_KALLSYMS + select HAS_MODULES + select HAS_DMA + select HAS_CACHE + select HAVE_CONFIGURABLE_TEXT_BASE + select HAVE_PBL_IMAGE + select HAVE_IMAGE_COMPRESSION + default y + +config ARM_LINUX + bool + default y + depends on CMD_BOOTZ || CMD_BOOTU || BOOTM + +config HAVE_MACH_ARM_HEAD + bool + +config ARM_USE_COMPRESSED_DTB + bool + select UNCOMPRESS + select LZO_DECOMPRESS + +menu "System Type" + +config BUILTIN_DTB + bool "link a DTB into the barebox image" + depends on OFTREE + depends on !HAVE_PBL_MULTI_IMAGES + +config BUILTIN_DTB_NAME + string "DTB to build into the barebox image" + depends on BUILTIN_DTB + default "canon-a1100" if MACH_CANON_A1100 + default "imx51-genesi-efika-sb" if MACH_EFIKA_MX_SMARTBOOK + default "versatile-pb" if ARCH_VERSATILE_PB + default "virt2real" if MACH_VIRT2REAL + default "module-mb7707" if MACH_MB7707 + +choice + prompt "ARM system type" + +config ARCH_VIRT + bool "ARM QEMU virt boards" + select HAS_DEBUG_LL + select CPU_V8 + select SYS_SUPPORTS_64BIT_KERNEL + select ARM_AMBA + select HAVE_CONFIGURABLE_MEMORY_LAYOUT + +endchoice + +source arch/arm64/cpu/Kconfig +source arch/arm64/mach-virt/Kconfig + +config ARM_ASM_UNIFIED + bool + +config AEABI + bool "Use the ARM EABI to compile barebox" + help + This option allows for barebox to be compiled using the latest + ARM ABI (aka EABI). + + To use this you need GCC version 4.0.0 or later. + +config ARM_BOARD_APPEND_ATAG + bool "Let board specific code to add ATAGs to be passed to the kernel" + depends on ARM_LINUX + help + This option is purely to start some vendor provided kernels. + ** DO NOT USE FOR YOUR OWN DESIGNS! ** + +endmenu + +choice + prompt "Barebox code model" + help + You should only select this option if you have a workload that + actually benefits from 64-bit processing or if your machine has + large memory. You will only be presented a single option in this + menu if your system does not support both 32-bit and 64-bit modes. + +config 32BIT + bool "32-bit barebox" + depends on CPU_SUPPORTS_32BIT_KERNEL && SYS_SUPPORTS_32BIT_KERNEL + help + Select this option if you want to build a 32-bit barebox. + +config 64BIT + bool "64-bit barebox" + depends on CPU_SUPPORTS_64BIT_KERNEL && SYS_SUPPORTS_64BIT_KERNEL + select ARCH_DMA_ADDR_T_64BIT + help + Select this option if you want to build a 64-bit barebox. + +endchoice + +menu "ARM specific settings" + +config ARM_OPTIMZED_STRING_FUNCTIONS + bool "use assembler optimized string functions" + help + Say yes here to use assembler optimized memcpy / memset functions. + These functions work much faster than the normal versions but + increase your binary size. + +config ARM_EXCEPTIONS + bool "enable arm exception handling support" + default y + +config ARM_UNWIND + bool "enable stack unwinding support" + depends on AEABI + help + This option enables stack unwinding support in barebox + using the information automatically generated by the + compiler. The resulting kernel image is slightly bigger but + the performance is not affected. Currently, this feature + only works with EABI compilers. If unsure say Y. + +config ARM_SEMIHOSTING + bool "enable ARM semihosting support" + help + This option enables ARM semihosting support in barebox. ARM + semihosting is a communication discipline that allows code + running on target ARM cpu perform system calls and access + the data on the host computer connected to the target via + debugging channel (JTAG, SWD). If unsure say N + +endmenu + +source common/Kconfig +source commands/Kconfig +source net/Kconfig +source drivers/Kconfig +source fs/Kconfig +source lib/Kconfig +source crypto/Kconfig
arch/arm64/Makefile new file +109 -0
109 lines not on this page · raw message
arch/arm64/boards/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# keep sorted by CONFIG_* macro name. +obj-$(CONFIG_MACH_VIRT) += virt/
arch/arm64/boards/virt/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ + +if MACH_VIRT + +config ARCH_TEXT_BASE + hex + default 0x40000000 + +endif
arch/arm64/boards/virt/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-y += init.o + +lwl-y += lowlevel.o
arch/arm64/boards/virt/env/config new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh + +# use 'dhcp' to do dhcp in barebox and in kernel +# use 'none' if you want to skip kernel ip autoconfiguration +ip=dhcp +global.dhcp.vendor_id=barebox-${global.hostname} + +# or set your networking parameters here +#eth0.ipaddr=a.b.c.d +#eth0.netmask=a.b.c.d +#eth0.gateway=a.b.c.d +#eth0.serverip=a.b.c.d + +# can be either 'nfs', 'tftp' or 'nor' +kernel_loc=tftp +# can be either 'net', 'nor' or 'initrd' +rootfs_loc=initrd + +# can be either 'jffs2' or 'ubifs' +rootfs_type=ubifs +rootfsimage=root.$rootfs_type + +kernelimage=zImage +#kernelimage=uImage +#kernelimage=Image +#kernelimage=Image.lzo + +nfsroot="$eth0.serverip:/opt/work/busybox/arm9/rootfs_arm" + +nor_parts="256k(barebox)ro,64k(bareboxenv),1536k(kernel),-(root)" +rootfs_mtdblock_nor=3 + +autoboot_timeout=3 + +bootargs="console=ttyAMA0,115200n8 CONSOLE=/dev/ttyAMA0" + +# set a fancy prompt (if support is compiled in) +PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# "
arch/arm64/boards/virt/init.c new file +52 -0
52 lines not on this page · raw message
arch/arm64/boards/virt/lowlevel.c new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPLv2 only +*/ + +#include <common.h> +#include <linux/sizes.h> +#include <asm/barebox-arm-head.h> +#include <asm/barebox-arm.h> +#include <asm/system_info.h> + +void barebox_arm_reset_vector (void ) +{ +arm_cpu_lowlevel_init (); + +barebox_arm_entry (0x40000000 ,SZ_512M ,NULL ); +}
arch/arm64/configs/virt_defconfig new file +53 -0
53 lines not on this page · raw message
arch/arm64/cpu/Kconfig new file +54 -0
54 lines not on this page · raw message
arch/arm64/cpu/Makefile new file +30 -0
@@ -0,0 +1,30 @@ +obj-y += cpu.o +obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o +obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o +obj-y += start.o entry.o + +# +# Any variants can be called as start-armxyz.S +# +obj-$(CONFIG_CMD_ARM_CPUINFO) += cpuinfo.o +obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o +obj-$(CONFIG_MMU) += mmu.o cache.o mmu-early.o +pbl-$(CONFIG_MMU) += mmu-early.o + +ifeq ($(CONFIG_MMU),) +#obj-y += no-mmu.o +endif + +AFLAGS_cache-armv8.o :=-Wa,-march=armv8-a +obj-$(CONFIG_CPU_64v8) += cache-armv8.o +AFLAGS_pbl-cache-armv8.o :=-Wa,-march=armv8-a +pbl-$(CONFIG_CPU_64v8) += cache-armv8.o + +pbl-y += setupc.o entry.o +pbl-$(CONFIG_PBL_SINGLE_IMAGE) += start-pbl.o +pbl-$(CONFIG_PBL_MULTI_IMAGES) += uncompress.o + +obj-y += cache.o +pbl-y += cache.o + +lwl-y += lowlevel.o
arch/arm64/cpu/cache-armv8.S new file +168 -0
168 lines not on this page · raw message
arch/arm64/cpu/cache.c new file +110 -0
110 lines not on this page · raw message
arch/arm64/cpu/cpu.c new file +106 -0
106 lines not on this page · raw message
arch/arm64/cpu/cpuinfo.c new file +211 -0
211 lines not on this page · raw message
arch/arm64/cpu/entry.c new file +38 -0
@@ -0,0 +1,38 @@ +#include <types.h> + +#include <asm/cache.h> + +#include "entry.h" + +/* +* Main ARM entry point. Call this with the memory region you can +* spare for barebox. This doesn't necessarily have to be the full +* SDRAM. The currently running binary can be inside or outside of +* this region. TEXT_BASE can be inside or outside of this +* region. boarddata will be preserved and can be accessed later with +* barebox_arm_boarddata(). +* +* -> membase + memsize +* STACK_SIZE - stack +* 16KiB, aligned to 16KiB - First level page table if early MMU support +* is enabled +* 128KiB - early memory space +* -> maximum end of barebox binary +* +* Usually a TEXT_BASE of 1MiB below your lowest possible end of memory should +* be fine. +*/ + +void __noreturn barebox_arm_entry (unsigned long membase, +unsigned long memsize,void *boarddata) +{ +arm_setup_stack (membase + memsize -16 ); +arm_early_mmu_cache_invalidate (); + +if (IS_ENABLED (CONFIG_PBL_MULTI_IMAGES )) +barebox_multi_pbl_start (membase, memsize, boarddata); +else if (IS_ENABLED (CONFIG_PBL_SINGLE_IMAGE )) +barebox_single_pbl_start (membase, memsize, boarddata); +else +barebox_non_pbl_start (membase, memsize, boarddata); +}
arch/arm64/cpu/entry.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __ENTRY_H__ +#define __ENTRY_H__ + +#include <common.h> + +void __noreturn barebox_non_pbl_start (unsigned long membase, +unsigned long memsize, +void *boarddata); + +void __noreturn barebox_multi_pbl_start (unsigned long membase, +unsigned long memsize, +void *boarddata); + +void __noreturn barebox_single_pbl_start (unsigned long membase, +unsigned long memsize, +void *boarddata); + +#endif
arch/arm64/cpu/exceptions.S new file +127 -0
127 lines not on this page · raw message
arch/arm64/cpu/interrupts.c new file +162 -0
162 lines not on this page · raw message
arch/arm64/cpu/lowlevel.S new file +49 -0
49 lines not on this page · raw message
arch/arm64/cpu/mmu-early.c new file +53 -0
53 lines not on this page · raw message
arch/arm64/cpu/mmu-early.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ARM_CPU_MMU_EARLY_H +#define __ARM_CPU_MMU_EARLY_H + +void mmu_early_enable (uint32_t membase,uint32_t memsize,uint32_t ttb); + +#endif /* __ARM_CPU_MMU_EARLY_H */
arch/arm64/cpu/mmu.c new file +492 -0
492 lines not on this page · raw message
arch/arm64/cpu/mmu.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __ARM_MMU_H +#define __ARM_MMU_H + +#ifdef CONFIG_MMU +void __mmu_cache_on (void ); +void __mmu_cache_off (void ); +void __mmu_cache_flush (void ); +#else +static inline void __mmu_cache_on (void ) {} +static inline void __mmu_cache_off (void ) {} +static inline void __mmu_cache_flush (void ) {} +#endif + +#endif /* __ARM_MMU_H */
arch/arm64/cpu/mmuinfo.c new file +104 -0
104 lines not on this page · raw message
arch/arm64/cpu/no-mmu.c new file +61 -0
61 lines not on this page · raw message
arch/arm64/cpu/start-pbl.c new file +102 -0
102 lines not on this page · raw message
arch/arm64/cpu/start.c new file +247 -0
247 lines not on this page · raw message
arch/arm64/cpu/uncompress.c new file +111 -0
111 lines not on this page · raw message
arch/arm64/include/asm/armlinux.h new file +43 -0
43 lines not on this page · raw message
arch/arm64/include/asm/assembler.h new file +116 -0
116 lines not on this page · raw message
arch/arm64/include/asm/barebox-arm-head.h new file +65 -0
65 lines not on this page · raw message
arch/arm64/include/asm/barebox-arm.h new file +165 -0
90 lines not on this page · raw message
arch/arm64/include/asm/barebox.h new file +12 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/bitops.h new file +48 -0
48 lines not on this page · raw message
arch/arm64/include/asm/bitsperlong.h new file +1 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/byteorder.h new file +32 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/cache-l2x0.h new file +101 -0
101 lines not on this page · raw message
arch/arm64/include/asm/cache.h new file +16 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/common.h new file +48 -0
48 lines not on this page · raw message
arch/arm64/include/asm/cputype.h new file +100 -0
100 lines not on this page · raw message
arch/arm64/include/asm/debug_ll_pl011.h new file +25 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/dma.h new file +46 -0
46 lines not on this page · raw message
arch/arm64/include/asm/elf.h new file +119 -0
119 lines not on this page · raw message
arch/arm64/include/asm/errata.h new file +79 -0
79 lines not on this page · raw message
arch/arm64/include/asm/gic.h new file +128 -0
128 lines not on this page · raw message
arch/arm64/include/asm/hardware/arm_timer.h new file +38 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/hardware/sp810.h new file +68 -0
68 lines not on this page · raw message
arch/arm64/include/asm/io.h new file +87 -0
87 lines not on this page · raw message
arch/arm64/include/asm/linkage.h new file +11 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/memory.h new file +19 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/mmu.h new file +65 -0
65 lines not on this page · raw message
arch/arm64/include/asm/module.h new file +13 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/pgtable.h new file +90 -0
90 lines not on this page · raw message
arch/arm64/include/asm/posix_types.h new file +1 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/processor.h new file +131 -0
131 lines not on this page · raw message
arch/arm64/include/asm/ptrace.h new file +34 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/sections.h new file +34 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/semihosting.h new file +19 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/setup.h new file +216 -0
216 lines not on this page · raw message
arch/arm64/include/asm/stacktrace.h new file +16 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/string.h new file +13 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/swab.h new file +69 -0
69 lines not on this page · raw message
arch/arm64/include/asm/system.h new file +125 -0
125 lines not on this page · raw message
arch/arm64/include/asm/system_info.h new file +194 -0
194 lines not on this page · raw message
arch/arm64/include/asm/types.h new file +54 -0
54 lines not on this page · raw message
arch/arm64/include/asm/unaligned.h new file +19 -0
Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/unified.h new file +127 -0
127 lines not on this page · raw message
arch/arm64/include/asm/unwind.h new file +51 -0
51 lines not on this page · raw message
arch/arm64/lib/armlinux.c new file +275 -0
275 lines not on this page · raw message
arch/arm64/lib/barebox.lds new file +125 -0
125 lines not on this page · raw message
arch/arm64/lib/barebox.lds.S new file +125 -0
125 lines not on this page · raw message
arch/arm64/lib/bootm.c new file +572 -0
572 lines not on this page · raw message
arch/arm64/lib/bootu.c new file +44 -0
44 lines not on this page · raw message
arch/arm64/lib/bootz.c new file +136 -0
136 lines not on this page · raw message
arch/arm64/lib/copy_template.S new file +192 -0
192 lines not on this page · raw message
arch/arm64/lib/memcpy.S new file +74 -0
74 lines not on this page · raw message
arch/arm64/lib/memset.S new file +215 -0
215 lines not on this page · raw message
arch/arm64/lib/module.c new file +98 -0
98 lines not on this page · raw message
arch/arm64/lib/pbl.lds.S new file +96 -0
96 lines not on this page · raw message
arch/arm64/lib/runtime-offset.S new file +52 -0
52 lines not on this page · raw message
arch/arm64/lib/unwind.c new file +349 -0
349 lines not on this page · raw message
arch/arm64/mach-virt/devices.c new file +30 -0
Lines of this file are not shown. View the raw message.
arch/arm64/mach-virt/include/mach/debug_ll.h new file +24 -0
Lines of this file are not shown. View the raw message.
arch/arm64/mach-virt/include/mach/devices.h new file +13 -0
Lines of this file are not shown. View the raw message.
arch/arm64/pbl/Makefile new file +58 -0
58 lines not on this page · raw message
arch/arm64/pbl/piggy.shipped.S new file +6 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Part of the diff is not shown here. View the raw message.
Quoted 7 lines · On Fri, 15 Apr 2016 10:05:25 +0200 Raphael Poggi <[email protected]> wrote:
This commit add minimal support for aarch64/arm64 architecture.
The main current limitations are:
- MMU not implemented
- barebox running at EL1
- barebox env not working
- only test on qemu
Your patch is suffering from whitespace errors.
Also please check pbl paths in your pbl code, e.g.:
$ grep arch/arm/ YOUR_PATCH | grep incbin + .incbin "arch/arm/pbl/piggy.gzip" + .incbin "arch/arm/pbl/piggy.lz4" + .incbin "arch/arm/pbl/piggy.lzo" + .incbin "arch/arm/pbl/piggy.shipped" + .incbin "arch/arm/pbl/piggy.xzkern"
Quoted 8,719 lines
Signed-off-by Raphael Poggi <[email protected]>--- arch/arm64/Kconfig | 140 +++++++ arch/arm64/Makefile | 109 +++++ arch/arm64/boards/Makefile | 2 + arch/arm64/boards/virt/Kconfig | 8 + arch/arm64/boards/virt/Makefile | 3 + arch/arm64/boards/virt/env/config | 38 ++ arch/arm64/boards/virt/init.c | 52 +++ arch/arm64/boards/virt/lowlevel.c | 18 + arch/arm64/configs/virt_defconfig | 53 +++ arch/arm64/cpu/Kconfig | 54 +++ arch/arm64/cpu/Makefile | 30 ++ arch/arm64/cpu/cache-armv8.S | 168 ++++++++ arch/arm64/cpu/cache.c | 110 ++++++ arch/arm64/cpu/cpu.c | 106 +++++ arch/arm64/cpu/cpuinfo.c | 211 ++++++++++ arch/arm64/cpu/entry.c | 38 ++ arch/arm64/cpu/entry.h | 18 + arch/arm64/cpu/exceptions.S | 127 ++++++ arch/arm64/cpu/interrupts.c | 162 ++++++++ arch/arm64/cpu/lowlevel.S | 49 +++ arch/arm64/cpu/mmu-early.c | 53 +++ arch/arm64/cpu/mmu-early.h | 6 + arch/arm64/cpu/mmu.c | 492 +++++++++++++++++++++++ arch/arm64/cpu/mmu.h | 14 + arch/arm64/cpu/mmuinfo.c | 104 +++++ arch/arm64/cpu/no-mmu.c | 61 +++ arch/arm64/cpu/start-pbl.c | 102 +++++ arch/arm64/cpu/start.c | 247 ++++++++++++ arch/arm64/cpu/uncompress.c | 111 ++++++ arch/arm64/include/asm/armlinux.h | 43 ++ arch/arm64/include/asm/assembler.h | 116 ++++++ arch/arm64/include/asm/barebox-arm-head.h | 65 +++ arch/arm64/include/asm/barebox-arm.h | 165 ++++++++ arch/arm64/include/asm/barebox.h | 12 + arch/arm64/include/asm/bitops.h | 48 +++ arch/arm64/include/asm/bitsperlong.h | 1 + arch/arm64/include/asm/byteorder.h | 32 ++ arch/arm64/include/asm/cache-l2x0.h | 101 +++++ arch/arm64/include/asm/cache.h | 16 + arch/arm64/include/asm/common.h | 48 +++ arch/arm64/include/asm/cputype.h | 100 +++++ arch/arm64/include/asm/debug_ll_pl011.h | 25 ++ arch/arm64/include/asm/dma.h | 46 +++ arch/arm64/include/asm/elf.h | 119 ++++++ arch/arm64/include/asm/errata.h | 79 ++++ arch/arm64/include/asm/gic.h | 128 ++++++ arch/arm64/include/asm/hardware/arm_timer.h | 38 ++ arch/arm64/include/asm/hardware/sp810.h | 68 ++++ arch/arm64/include/asm/io.h | 87 ++++ arch/arm64/include/asm/linkage.h | 11 + arch/arm64/include/asm/memory.h | 19 + arch/arm64/include/asm/mmu.h | 65 +++ arch/arm64/include/asm/module.h | 13 + arch/arm64/include/asm/pgtable.h | 90 +++++ arch/arm64/include/asm/posix_types.h | 1 + arch/arm64/include/asm/processor.h | 131 ++++++ arch/arm64/include/asm/ptrace.h | 34 ++ arch/arm64/include/asm/sections.h | 34 ++ arch/arm64/include/asm/semihosting.h | 19 + arch/arm64/include/asm/setup.h | 216 ++++++++++ arch/arm64/include/asm/stacktrace.h | 16 + arch/arm64/include/asm/string.h | 13 + arch/arm64/include/asm/swab.h | 69 ++++ arch/arm64/include/asm/system.h | 125 ++++++ arch/arm64/include/asm/system_info.h | 194 +++++++++ arch/arm64/include/asm/types.h | 54 +++ arch/arm64/include/asm/unaligned.h | 19 + arch/arm64/include/asm/unified.h | 127 ++++++ arch/arm64/include/asm/unwind.h | 51 +++ arch/arm64/lib/Makefile | 16 + arch/arm64/lib/armlinux.c | 275 +++++++++++++ arch/arm64/lib/asm-offsets.c | 16 + arch/arm64/lib/barebox.lds | 125 ++++++ arch/arm64/lib/barebox.lds.S | 125 ++++++ arch/arm64/lib/bootm.c | 572 +++++++++++++++++++++++++++ arch/arm64/lib/bootu.c | 44 +++ arch/arm64/lib/bootz.c | 136 +++++++ arch/arm64/lib/copy_template.S | 192 +++++++++ arch/arm64/lib/div0.c | 27 ++ arch/arm64/lib/memcpy.S | 74 ++++ arch/arm64/lib/memset.S | 215 ++++++++++ arch/arm64/lib/module.c | 98 +++++ arch/arm64/lib/pbl.lds.S | 96 +++++ arch/arm64/lib/runtime-offset.S | 52 +++ arch/arm64/lib/unwind.c | 349 ++++++++++++++++ arch/arm64/mach-virt/Kconfig | 15 + arch/arm64/mach-virt/Makefile | 1 + arch/arm64/mach-virt/devices.c | 30 ++ arch/arm64/mach-virt/include/mach/debug_ll.h | 24 ++ arch/arm64/mach-virt/include/mach/devices.h | 13 + arch/arm64/mach-virt/reset.c | 24 ++ arch/arm64/pbl/Makefile | 58 +++ arch/arm64/pbl/piggy.gzip.S | 6 + arch/arm64/pbl/piggy.lz4.S | 6 + arch/arm64/pbl/piggy.lzo.S | 6 + arch/arm64/pbl/piggy.shipped.S | 6 + arch/arm64/pbl/piggy.xzkern.S | 6 + 97 files changed, 7931 insertions(+) create mode 100644 arch/arm64/Kconfig create mode 100644 arch/arm64/Makefile create mode 100644 arch/arm64/boards/Makefile create mode 100644 arch/arm64/boards/virt/Kconfig create mode 100644 arch/arm64/boards/virt/Makefile create mode 100644 arch/arm64/boards/virt/env/config create mode 100644 arch/arm64/boards/virt/init.c create mode 100644 arch/arm64/boards/virt/lowlevel.c create mode 100644 arch/arm64/configs/virt_defconfig create mode 100644 arch/arm64/cpu/Kconfig create mode 100644 arch/arm64/cpu/Makefile create mode 100644 arch/arm64/cpu/cache-armv8.S create mode 100644 arch/arm64/cpu/cache.c create mode 100644 arch/arm64/cpu/cpu.c create mode 100644 arch/arm64/cpu/cpuinfo.c create mode 100644 arch/arm64/cpu/entry.c create mode 100644 arch/arm64/cpu/entry.h create mode 100644 arch/arm64/cpu/exceptions.S create mode 100644 arch/arm64/cpu/interrupts.c create mode 100644 arch/arm64/cpu/lowlevel.S create mode 100644 arch/arm64/cpu/mmu-early.c create mode 100644 arch/arm64/cpu/mmu-early.h create mode 100644 arch/arm64/cpu/mmu.c create mode 100644 arch/arm64/cpu/mmu.h create mode 100644 arch/arm64/cpu/mmuinfo.c create mode 100644 arch/arm64/cpu/no-mmu.c create mode 100644 arch/arm64/cpu/start-pbl.c create mode 100644 arch/arm64/cpu/start.c create mode 100644 arch/arm64/cpu/uncompress.c create mode 100644 arch/arm64/include/asm/armlinux.h create mode 100644 arch/arm64/include/asm/assembler.h create mode 100644 arch/arm64/include/asm/barebox-arm-head.h create mode 100644 arch/arm64/include/asm/barebox-arm.h create mode 100644 arch/arm64/include/asm/barebox.h create mode 100644 arch/arm64/include/asm/bitops.h create mode 100644 arch/arm64/include/asm/bitsperlong.h create mode 100644 arch/arm64/include/asm/byteorder.h create mode 100644 arch/arm64/include/asm/cache-l2x0.h create mode 100644 arch/arm64/include/asm/cache.h create mode 100644 arch/arm64/include/asm/common.h create mode 100644 arch/arm64/include/asm/cputype.h create mode 100644 arch/arm64/include/asm/debug_ll_pl011.h create mode 100644 arch/arm64/include/asm/dma.h create mode 100644 arch/arm64/include/asm/elf.h create mode 100644 arch/arm64/include/asm/errata.h create mode 100644 arch/arm64/include/asm/gic.h create mode 100644 arch/arm64/include/asm/hardware/arm_timer.h create mode 100644 arch/arm64/include/asm/hardware/sp810.h create mode 100644 arch/arm64/include/asm/io.h create mode 100644 arch/arm64/include/asm/linkage.h create mode 100644 arch/arm64/include/asm/memory.h create mode 100644 arch/arm64/include/asm/mmu.h create mode 100644 arch/arm64/include/asm/module.h create mode 100644 arch/arm64/include/asm/pgtable.h create mode 100644 arch/arm64/include/asm/posix_types.h create mode 100644 arch/arm64/include/asm/processor.h create mode 100644 arch/arm64/include/asm/ptrace.h create mode 100644 arch/arm64/include/asm/sections.h create mode 100644 arch/arm64/include/asm/semihosting.h create mode 100644 arch/arm64/include/asm/setup.h create mode 100644 arch/arm64/include/asm/stacktrace.h create mode 100644 arch/arm64/include/asm/string.h create mode 100644 arch/arm64/include/asm/swab.h create mode 100644 arch/arm64/include/asm/system.h create mode 100644 arch/arm64/include/asm/system_info.h create mode 100644 arch/arm64/include/asm/types.h create mode 100644 arch/arm64/include/asm/unaligned.h create mode 100644 arch/arm64/include/asm/unified.h create mode 100644 arch/arm64/include/asm/unwind.h create mode 100644 arch/arm64/lib/Makefile create mode 100644 arch/arm64/lib/armlinux.c create mode 100644 arch/arm64/lib/asm-offsets.c create mode 100644 arch/arm64/lib/barebox.lds create mode 100644 arch/arm64/lib/barebox.lds.S create mode 100644 arch/arm64/lib/bootm.c create mode 100644 arch/arm64/lib/bootu.c create mode 100644 arch/arm64/lib/bootz.c create mode 100644 arch/arm64/lib/copy_template.S create mode 100644 arch/arm64/lib/div0.c create mode 100644 arch/arm64/lib/memcpy.S create mode 100644 arch/arm64/lib/memset.S create mode 100644 arch/arm64/lib/module.c create mode 100644 arch/arm64/lib/pbl.lds.S create mode 100644 arch/arm64/lib/runtime-offset.S create mode 100644 arch/arm64/lib/unwind.c create mode 100644 arch/arm64/mach-virt/Kconfig create mode 100644 arch/arm64/mach-virt/Makefile create mode 100644 arch/arm64/mach-virt/devices.c create mode 100644 arch/arm64/mach-virt/include/mach/debug_ll.h create mode 100644 arch/arm64/mach-virt/include/mach/devices.h create mode 100644 arch/arm64/mach-virt/reset.c create mode 100644 arch/arm64/pbl/Makefile create mode 100644 arch/arm64/pbl/piggy.gzip.S create mode 100644 arch/arm64/pbl/piggy.lz4.S create mode 100644 arch/arm64/pbl/piggy.lzo.S create mode 100644 arch/arm64/pbl/piggy.shipped.S create mode 100644 arch/arm64/pbl/piggy.xzkern.Sarch/arm64/Kconfig new file +140
-0@@ -0,0 +1,140 @@ +config ARM + bool + select HAS_KALLSYMS + select HAS_MODULES + select HAS_DMA + select HAS_CACHE + select HAVE_CONFIGURABLE_TEXT_BASE + select HAVE_PBL_IMAGE + select HAVE_IMAGE_COMPRESSION + default y + +config ARM_LINUX + bool + default y + depends on CMD_BOOTZ || CMD_BOOTU || BOOTM + +config HAVE_MACH_ARM_HEAD + bool + +config ARM_USE_COMPRESSED_DTB + bool + select UNCOMPRESS + select LZO_DECOMPRESS + +menu "System Type" + +config BUILTIN_DTB + bool "link a DTB into the barebox image" + depends on OFTREE + depends on !HAVE_PBL_MULTI_IMAGES + +config BUILTIN_DTB_NAME + string "DTB to build into the barebox image" + depends on BUILTIN_DTB + default "canon-a1100" if MACH_CANON_A1100 + default "imx51-genesi-efika-sb" if MACH_EFIKA_MX_SMARTBOOK + default "versatile-pb" if ARCH_VERSATILE_PB + default "virt2real" if MACH_VIRT2REAL + default "module-mb7707" if MACH_MB7707 + +choice + prompt "ARM system type" + +config ARCH_VIRT + bool "ARM QEMU virt boards" + select HAS_DEBUG_LL + select CPU_V8 + select SYS_SUPPORTS_64BIT_KERNEL + select ARM_AMBA + select HAVE_CONFIGURABLE_MEMORY_LAYOUT + +endchoice + +source arch/arm64/cpu/Kconfig +source arch/arm64/mach-virt/Kconfig + +config ARM_ASM_UNIFIED + bool + +config AEABI + bool "Use the ARM EABI to compile barebox" + help + This option allows for barebox to be compiled using the latest + ARM ABI (aka EABI). + + To use this you need GCC version 4.0.0 or later. + +config ARM_BOARD_APPEND_ATAG + bool "Let board specific code to add ATAGs to be passed to the kernel" + depends on ARM_LINUX + help + This option is purely to start some vendor provided kernels. + ** DO NOT USE FOR YOUR OWN DESIGNS! ** + +endmenu + +choice + prompt "Barebox code model" + help + You should only select this option if you have a workload that + actually benefits from 64-bit processing or if your machine has + large memory. You will only be presented a single option in this + menu if your system does not support both 32-bit and 64-bit modes. + +config 32BIT + bool "32-bit barebox" + depends on CPU_SUPPORTS_32BIT_KERNEL && SYS_SUPPORTS_32BIT_KERNEL + help + Select this option if you want to build a 32-bit barebox. + +config 64BIT + bool "64-bit barebox" + depends on CPU_SUPPORTS_64BIT_KERNEL && SYS_SUPPORTS_64BIT_KERNEL + select ARCH_DMA_ADDR_T_64BIT + help + Select this option if you want to build a 64-bit barebox. + +endchoice + +menu "ARM specific settings" + +config ARM_OPTIMZED_STRING_FUNCTIONS + bool "use assembler optimized string functions" + help + Say yes here to use assembler optimized memcpy / memset functions. + These functions work much faster than the normal versions but + increase your binary size. + +config ARM_EXCEPTIONS + bool "enable arm exception handling support" + default y + +config ARM_UNWIND + bool "enable stack unwinding support" + depends on AEABI + help + This option enables stack unwinding support in barebox + using the information automatically generated by the + compiler. The resulting kernel image is slightly bigger but + the performance is not affected. Currently, this feature + only works with EABI compilers. If unsure say Y. + +config ARM_SEMIHOSTING + bool "enable ARM semihosting support" + help + This option enables ARM semihosting support in barebox. ARM + semihosting is a communication discipline that allows code + running on target ARM cpu perform system calls and access + the data on the host computer connected to the target via + debugging channel (JTAG, SWD). If unsure say N + +endmenu + +source common/Kconfig +source commands/Kconfig +source net/Kconfig +source drivers/Kconfig +source fs/Kconfig +source lib/Kconfig +source crypto/Kconfigarch/arm64/Makefile new file +109
-0@@ -0,0 +1,109 @@ + +CPPFLAGS += -D__ARM__ -fno-strict-aliasing +CPPFLAGS +=$(call cc-option,-maarch64,) + +ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) +CPPFLAGS += -mbig-endian +AS += -EB +LD += -EB +else +CPPFLAGS += -mlittle-endian +AS += -EL +LD += -EL +endif + +# This selects which instruction set is used. +# Note that GCC does not numerically define an architecture version +# macro, but instead defines a whole series of macros which makes +# testing for a specific architecture or later rather impossible. +arch-$(CONFIG_CPU_64v8) := -D__LINUX_ARM_ARCH__=8 $(call cc-option,-march=armv8-a) + +CFLAGS_ABI :=-mabi=lp64 + +ifeq ($(CONFIG_ARM_UNWIND),y) +CFLAGS_ABI +=-funwind-tables +endif + +CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y) + +AFLAGS += -include asm/unified.h + +# Machine directory name. This list is sorted alphanumerically +# by CONFIG_* macro name. +machine-$(CONFIG_ARCH_VIRT) := virt + + +machdirs := $(patsubst %,arch/arm64/mach-%/,$(machine-y)) + +ifeq ($(KBUILD_SRC),) +CPPFLAGS += $(patsubst %,-I%include,$(machdirs)) +else +CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs)) +endif + +TEXT_BASE = $(CONFIG_TEXT_BASE) + +CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) + +# Add cleanup flags +CPPFLAGS += -fdata-sections -ffunction-sections +LDFLAGS_barebox += --gc-sections + +ifdef CONFIG_RELOCATABLE +LDFLAGS_barebox += -pie +else +LDFLAGS_barebox += -static +endif + +ifdef CONFIG_IMAGE_COMPRESSION +KBUILD_BINARY := arch/arm64/pbl/zbarebox.bin +else +KBUILD_BINARY := barebox.bin +endif + +barebox.netx: $(KBUILD_BINARY) + $(Q)scripts/gen_netx_image -i $< -o barebox.netx \ + --sdramctrl=$(CONFIG_NETX_SDRAM_CTRL) \ + --sdramtimctrl=$(CONFIG_NETX_SDRAM_TIMING_CTRL) \ + --memctrl=$(CONFIG_NETX_MEM_CTRL) \ + --entrypoint=$(CONFIG_TEXT_BASE) \ + --cookie=$(CONFIG_NETX_COOKIE); + +ifeq ($(machine-y),netx) +KBUILD_IMAGE := barebox.netx +endif + +barebox.s5p: $(KBUILD_BINARY) + $(Q)scripts/s5p_cksum $< barebox.s5p + +boarddir = $(srctree)/arch/arm64/boards + +pbl := arch/arm64/pbl +$(pbl)/zbarebox.S $(pbl)/zbarebox.bin $(pbl)/zbarebox: barebox.bin FORCE + $(Q)$(MAKE) $(build)=$(pbl) $@ + +archclean: + $(MAKE) $(clean)=$(pbl) + +KBUILD_IMAGE ?= $(KBUILD_BINARY) + +ifneq ($(board-y),) +BOARD := arch/arm64/boards/$(board-y)/ +else +BOARD := +endif + +ifneq ($(machine-y),) +MACH := arch/arm64/mach-$(machine-y)/ +else +MACH := +endif + +common-y += $(BOARD) arch/arm64/boards/ $(MACH) +common-y += arch/arm64/lib/ arch/arm64/cpu/ + +lds-y := arch/arm64/lib/barebox.lds + +common- += $(patsubst %,arch/arm64/boards/%/,$(board-)) + +CLEAN_FILES += include/generated/mach-types.h arch/arm64/lib/barebox.lds barebox-flash-imagearch/arm64/boards/Makefile new file +2
-0@@ -0,0 +1,2 @@ +# keep sorted by CONFIG_* macro name. +obj-$(CONFIG_MACH_VIRT) += virt/arch/arm64/boards/virt/Kconfig new file +8
-0@@ -0,0 +1,8 @@ + +if MACH_VIRT + +config ARCH_TEXT_BASE + hex + default 0x40000000 + +endifarch/arm64/boards/virt/Makefile new file +3
-0@@ -0,0 +1,3 @@ +obj-y += init.o + +lwl-y += lowlevel.oarch/arm64/boards/virt/env/config new file +38
-0@@ -0,0 +1,38 @@ +#!/bin/sh + +# use 'dhcp' to do dhcp in barebox and in kernel +# use 'none' if you want to skip kernel ip autoconfiguration +ip=dhcp +global.dhcp.vendor_id=barebox-${global.hostname} + +# or set your networking parameters here +#eth0.ipaddr=a.b.c.d +#eth0.netmask=a.b.c.d +#eth0.gateway=a.b.c.d +#eth0.serverip=a.b.c.d + +# can be either 'nfs', 'tftp' or 'nor' +kernel_loc=tftp +# can be either 'net', 'nor' or 'initrd' +rootfs_loc=initrd + +# can be either 'jffs2' or 'ubifs' +rootfs_type=ubifs +rootfsimage=root.$rootfs_type + +kernelimage=zImage +#kernelimage=uImage +#kernelimage=Image +#kernelimage=Image.lzo + +nfsroot="$eth0.serverip:/opt/work/busybox/arm9/rootfs_arm" + +nor_parts="256k(barebox)ro,64k(bareboxenv),1536k(kernel),-(root)" +rootfs_mtdblock_nor=3 + +autoboot_timeout=3 + +bootargs="console=ttyAMA0,115200n8 CONSOLE=/dev/ttyAMA0" + +# set a fancy prompt (if support is compiled in) +PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# "arch/arm64/boards/virt/init.c new file +52
-0@@ -0,0 +1,52 @@ +/* +* Copyright (C) 2016 Raphaël Poggi <[email protected]> +* +* GPLv2 only +*/ + +#include <common.h> +#include <init.h> +#include <asm/armlinux.h> +#include <asm/system_info.h> +#include <mach/devices.h> +#include <environment.h> +#include <linux/sizes.h> +#include <io.h> +#include <globalvar.h> + +static int virt_mem_init (void ) +{ +virt_add_ddram (SZ_256M ); + +add_cfi_flash_device (0 ,0x00000000 ,SZ_4M ,0 ); + +devfs_add_partition ("nor0" ,0x00000 ,0x40000 ,DEVFS_PARTITION_FIXED ,"self0" ); +devfs_add_partition ("nor0" ,0x40000 ,0x20000 ,DEVFS_PARTITION_FIXED ,"env0" ); + +return 0 ; +} +mem_initcall (virt_mem_init); + +static int virt_console_init (void ) +{ +virt_register_uart (0 ); + +return 0 ; +} +console_initcall (virt_console_init); + +static int virt_core_init (void ) +{ +char *hostname ="virt" ; + +if (cpu_is_cortex_a53 ()) + hostname ="virt-a53" ; +else if (cpu_is_cortex_a57 ()) + hostname ="virt-a57" ; + +barebox_set_model ("ARM QEMU virt" ); +barebox_set_hostname (hostname); + +return 0 ; +} +postcore_initcall (virt_core_init);arch/arm64/boards/virt/lowlevel.c new file +18
-0@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPLv2 only +*/ + +#include <common.h> +#include <linux/sizes.h> +#include <asm/barebox-arm-head.h> +#include <asm/barebox-arm.h> +#include <asm/system_info.h> + +void barebox_arm_reset_vector (void ) +{ +arm_cpu_lowlevel_init (); + +barebox_arm_entry (0x40000000 ,SZ_512M ,NULL ); +}arch/arm64/configs/virt_defconfig new file +53
-0@@ -0,0 +1,53 @@ +CONFIG_AEABI=y +CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y +CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x05000000 +CONFIG_BAREBOX_MAX_BARE_INIT_SIZE=0x01000000 +CONFIG_MEMORY_LAYOUT_FIXED=y +CONFIG_STACK_BASE=0x60000000 +CONFIG_MALLOC_BASE=0x50000000 +CONFIG_PROMPT="virt: " +CONFIG_HUSH_FANCY_PROMPT=y +CONFIG_CMDLINE_EDITING=y +CONFIG_AUTO_COMPLETE=y +CONFIG_MENU=y +CONFIG_PASSWORD=y +CONFIG_PARTITION=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y +CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm64/boards/virt/env" +CONFIG_DEBUG_INFO=y +# CONFIG_CMD_ARM_CPUINFO is not set +CONFIG_LONGHELP=y +# CONFIG_CMD_BOOTM is not set +# CONFIG_CMD_BOOTU is not set +# CONFIG_CMD_MOUNT is not set +# CONFIG_CMD_UMOUNT is not set +# CONFIG_CMD_CAT is not set +# CONFIG_CMD_CD is not set +# CONFIG_CMD_CP is not set +# CONFIG_CMD_LS is not set +# CONFIG_CMD_MKDIR is not set +# CONFIG_CMD_PWD is not set +# CONFIG_CMD_RM is not set +# CONFIG_CMD_RMDIR is not set +# CONFIG_CMD_FALSE is not set +# CONFIG_CMD_TEST is not set +# CONFIG_CMD_TRUE is not set +# CONFIG_CMD_CLEAR is not set +# CONFIG_CMD_ECHO is not set +CONFIG_CMD_CRC=y +CONFIG_CMD_CRC_CMP=y +# CONFIG_CMD_MD is not set +# CONFIG_CMD_MEMCMP is not set +# CONFIG_CMD_MEMCPY is not set +# CONFIG_CMD_MEMSET is not set +# CONFIG_CMD_MW is not set +CONFIG_SERIAL_AMBA_PL011=y +# CONFIG_SPI is not set +CONFIG_MTD=y +CONFIG_DRIVER_CFI=y +CONFIG_DRIVER_CFI_BANK_WIDTH_8=y +CONFIG_CFI_BUFFER_WRITE=y +CONFIG_NAND=y +# CONFIG_FS_RAMFS is not set +CONFIG_DIGEST_SHA1_GENERIC=y +CONFIG_DIGEST_SHA256_GENERIC=yarch/arm64/cpu/Kconfig new file +54
-0@@ -0,0 +1,54 @@ +comment "Processor Type" + +config CPU_64 + bool + default y + +# Select CPU types depending on the architecture selected. This selects +# which CPUs we support in the kernel image, and the compiler instruction +# optimiser behaviour. + +# ARMv8 +config CPU_V8 + bool + select CPU_64v8 + select CPU_SUPPORTS_64BIT_KERNEL + +config CPU_64v8 + bool + +comment "processor features" + +config ARCH_SUPPORTS_BIG_ENDIAN + bool + +config CPU_BIG_ENDIAN + bool "Build big-endian kernel" + depends on ARCH_SUPPORTS_BIG_ENDIAN + help + Say Y if you plan on running a kernel in big-endian mode. + Note that your board must be properly built and your board + port must properly enable any big-endian related features + of your chipset/board/processor. + +config BOOT_ENDIANNESS_SWITCH + bool "Support switching of Linux kernel endianness" + help + Say Y here if you need to switch CPU endianness before running + Linux kernel, e.g. if you want big-endian Barebox to run + little-endian Linux. + + Currently implemented only by "bootz" command. + +config SYS_SUPPORTS_32BIT_KERNEL + bool + +config SYS_SUPPORTS_64BIT_KERNEL + bool + +config CPU_SUPPORTS_32BIT_KERNEL + bool + +config CPU_SUPPORTS_64BIT_KERNEL + bool +arch/arm64/cpu/Makefile new file +30
-0@@ -0,0 +1,30 @@ +obj-y += cpu.o +obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o +obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o +obj-y += start.o entry.o + +# +# Any variants can be called as start-armxyz.S +# +obj-$(CONFIG_CMD_ARM_CPUINFO) += cpuinfo.o +obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o +obj-$(CONFIG_MMU) += mmu.o cache.o mmu-early.o +pbl-$(CONFIG_MMU) += mmu-early.o + +ifeq ($(CONFIG_MMU),) +#obj-y += no-mmu.o +endif + +AFLAGS_cache-armv8.o :=-Wa,-march=armv8-a +obj-$(CONFIG_CPU_64v8) += cache-armv8.o +AFLAGS_pbl-cache-armv8.o :=-Wa,-march=armv8-a +pbl-$(CONFIG_CPU_64v8) += cache-armv8.o + +pbl-y += setupc.o entry.o +pbl-$(CONFIG_PBL_SINGLE_IMAGE) += start-pbl.o +pbl-$(CONFIG_PBL_MULTI_IMAGES) += uncompress.o + +obj-y += cache.o +pbl-y += cache.o + +lwl-y += lowlevel.oarch/arm64/cpu/cache-armv8.S new file +168
-0@@ -0,0 +1,168 @@ +/* + * (C) Copyright 2013 + * David Feng <[email protected]> + * + * This file is based on sample code from ARMv8 ARM. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <config.h> +#include <linux/linkage.h> +#include <init.h> + +/* + * void v8_flush_dcache_level(level) + * + * clean and invalidate one level cache. + * + * x0: cache level + * x1: 0 flush & invalidate, 1 invalidate only + * x2~x9: clobbered + */ +.section .text.v8_flush_dcache_level +ENTRY(v8_flush_dcache_level) + lsl x12, x0, #1 + msr csselr_el1, x12 /* select cache level */ + isb /* sync change of cssidr_el1 */ + mrs x6, ccsidr_el1 /* read the new cssidr_el1 */ + and x2, x6, #7 /* x2 <- log2(cache line size)-4 */ + add x2, x2, #4 /* x2 <- log2(cache line size) */ + mov x3, #0x3ff + and x3, x3, x6, lsr #3 /* x3 <- max number of #ways */ + clz w5, w3 /* bit position of #ways */ + mov x4, #0x7fff + and x4, x4, x6, lsr #13 /* x4 <- max number of #sets */ + /* x12 <- cache level << 1 */ + /* x2 <- line length offset */ + /* x3 <- number of cache ways - 1 */ + /* x4 <- number of cache sets - 1 */ + /* x5 <- bit position of #ways */ + +loop_set: + mov x6, x3 /* x6 <- working copy of #ways */ +loop_way: + lsl x7, x6, x5 + orr x9, x12, x7 /* map way and level to cisw value */ + lsl x7, x4, x2 + orr x9, x9, x7 /* map set number to cisw value */ + tbz w1, #0, 1f + dc isw, x9 + b 2f +1: dc cisw, x9 /* clean & invalidate by set/way */ +2: subs x6, x6, #1 /* decrement the way */ + b.ge loop_way + subs x4, x4, #1 /* decrement the set */ + b.ge loop_set + + ret +ENDPROC(v8_flush_dcache_level) + +/* + * void v8_flush_dcache_all(int invalidate_only) + * + * x0: 0 flush & invalidate, 1 invalidate only + * + * clean and invalidate all data cache by SET/WAY. + */ +.section .text.v8_dcache_all +ENTRY(v8_dcache_all) + mov x1, x0 + dsb sy + mrs x10, clidr_el1 /* read clidr_el1 */ + lsr x11, x10, #24 + and x11, x11, #0x7 /* x11 <- loc */ + cbz x11, finished /* if loc is 0, exit */ + mov x15, x30 + mov x0, #0 /* start flush at cache level 0 */ + /* x0 <- cache level */ + /* x10 <- clidr_el1 */ + /* x11 <- loc */ + /* x15 <- return address */ + +loop_level: + lsl x12, x0, #1 + add x12, x12, x0 /* x0 <- tripled cache level */ + lsr x12, x10, x12 + and x12, x12, #7 /* x12 <- cache type */ + cmp x12, #2 + b.lt skip /* skip if no cache or icache */ + bl v8_flush_dcache_level /* x1 = 0 flush, 1 invalidate */ +skip: + add x0, x0, #1 /* increment cache level */ + cmp x11, x0 + b.gt loop_level + + mov x0, #0 + msr csselr_el1, x0 /* restore csselr_el1 */ + dsb sy + isb + mov x30, x15 + +finished: + ret +ENDPROC(v8_dcache_all) + +.section .text.v8_flush_dcache_all +ENTRY(v8_flush_dcache_all) + mov x16, x30 + mov x0, #0 + bl v8_dcache_all + mov x30, x16 + ret +ENDPROC(v8_flush_dcache_all) + +.section .text.v8_invalidate_dcache_all +ENTRY(v8_invalidate_dcache_all) + mov x16, x30 + mov x0, #0x1 + bl v8_dcache_all + mov x30, x16 + ret +ENDPROC(v8_invalidate_dcache_all) + +/* + * void v8_flush_dcache_range(start, end) + * + * clean & invalidate data cache in the range + * + * x0: start address + * x1: end address + */ +.section .text.v8_flush_dcache_range +ENTRY(v8_flush_dcache_range) + mrs x3, ctr_el0 + lsr x3, x3, #16 + and x3, x3, #0xf + mov x2, #4 + lsl x2, x2, x3 /* cache line size */ + + /* x2 <- minimal cache line size in cache system */ + sub x3, x2, #1 + bic x0, x0, x3 +1: dc civac, x0 /* clean & invalidate data or unified cache */ + add x0, x0, x2 + cmp x0, x1 + b.lo 1b + dsb sy + ret +ENDPROC(v8_flush_dcache_range) + +/* + * void v8_invalidate_icache_all(void) + * + * invalidate all tlb entries. + */ +.section .text.v8_invalidate_icache_all +ENTRY(v8_invalidate_icache_all) + ic ialluis + isb sy + ret +ENDPROC(v8_invalidate_icache_all) + +.section .text.v8_flush_l3_cache +ENTRY(v8_flush_l3_cache) + mov x0, #0 /* return status as success */ + ret +ENDPROC(v8_flush_l3_cache) + .weak v8_flush_l3_cachearch/arm64/cpu/cache.c new file +110
-0@@ -0,0 +1,110 @@ +#include <common.h> +#include <init.h> +#include <asm/mmu.h> +#include <asm/cache.h> +#include <asm/system_info.h> + +struct cache_fns { +void (*dma_clean_range)(unsigned long start,unsigned long end); +void (*dma_flush_range)(unsigned long start,unsigned long end); +void (*dma_inv_range)(unsigned long start,unsigned long end); +void (*mmu_cache_on)(void ); +void (*mmu_cache_off)(void ); +void (*mmu_cache_flush)(void ); +}; + +struct cache_fns *cache_fns; + +#define DEFINE_CPU_FNS (arch) \ + void arch##_dma_clean_range(unsigned long start, unsigned long end); \ + void arch##_dma_flush_range(unsigned long start, unsigned long end); \ + void arch##_dma_inv_range(unsigned long start, unsigned long end); \ + void arch##_mmu_cache_on(void); \ + void arch##_mmu_cache_off(void); \ + void arch##_mmu_cache_flush(void); \ + \ + static struct cache_fns __maybe_unused cache_fns_arm##arch = { \ + .dma_clean_range = arch##_dma_clean_range, \ + .dma_flush_range = arch##_dma_flush_range, \ + .dma_inv_range = arch##_dma_inv_range, \ + .mmu_cache_on = arch##_mmu_cache_on, \ + .mmu_cache_off = arch##_mmu_cache_off, \ + .mmu_cache_flush = arch##_mmu_cache_flush, \ + }; + +DEFINE_CPU_FNS (v8) + +void __dma_clean_range(unsigned long start, unsigned long end) +{ +if (cache_fns) + cache_fns->dma_clean_range (start, end); +} + +void __dma_flush_range (unsigned long start,unsigned long end) +{ +if (cache_fns) + cache_fns->dma_flush_range (start, end); +} + +void __dma_inv_range (unsigned long start,unsigned long end) +{ +if (cache_fns) + cache_fns->dma_inv_range (start, end); +} + +void __mmu_cache_on (void ) +{ +if (cache_fns) + cache_fns->mmu_cache_on (); +} + +void __mmu_cache_off (void ) +{ +if (cache_fns) + cache_fns->mmu_cache_off (); +} + +void __mmu_cache_flush (void ) +{ +if (cache_fns) + cache_fns->mmu_cache_flush (); +if (outer_cache.flush_all) + outer_cache.flush_all (); +} + +int arm_set_cache_functions (void ) +{ +switch (cpu_architecture ()) { +case CPU_ARCH_ARMv8: + cache_fns = &cache_fns_armv8; +break ; +default : +while (1 ); + } + +return 0 ; +} + +/* +* Early function to flush the caches. This is for use when the +* C environment is not yet fully initialized. +*/ +void arm_early_mmu_cache_flush (void ) +{ +switch (arm_early_get_cpu_architecture ()) { +case CPU_ARCH_ARMv8: +// v7_mmu_cache_flush(); +return ; + } +} + +//void v7_mmu_cache_invalidate(void); + +void arm_early_mmu_cache_invalidate (void ) +{ +switch (arm_early_get_cpu_architecture ()) { +case CPU_ARCH_ARMv8: +// v7_mmu_cache_invalidate(); +return ; + } +}arch/arm64/cpu/cpu.c new file +106
-0@@ -0,0 +1,106 @@ +/* +* cpu.c - A few helper functions for ARM +* +* Copyright (c) 2007 Sascha Hauer <[email protected]>, Pengutronix +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +*/ + +/** +* @file +* @brief A few helper functions for ARM +*/ + +#include <common.h> +#include <init.h> +#include <command.h> +#include <cache.h> +#include <asm/mmu.h> +#include <asm/system.h> +#include <asm/memory.h> +#include <asm-generic/memory_layout.h> +#include <asm/cputype.h> +#include <asm/cache.h> +#include <asm/ptrace.h> + +#include "mmu.h" + +/** +* Enable processor's instruction cache +*/ +void icache_enable (void ) +{ +v8_invalidate_icache_all (); +set_sctlr (get_sctlr () |CR_I ); +} + +/** +* Disable processor's instruction cache +*/ +void icache_disable (void ) +{ +set_sctlr (get_sctlr () & ~CR_I ); +} + +/** +* Detect processor's current instruction cache status +* @return 0=disabled, 1=enabled +*/ +int icache_status (void ) +{ +return (get_sctlr () &CR_I ) !=0 ; +} + +/* +* SoC like the ux500 have the l2x0 always enable +* with or without MMU enable +*/ +struct outer_cache_fns outer_cache; + +/* +* Clean and invalide caches, disable MMU +*/ +void mmu_disable (void ) +{ +__mmu_cache_flush (); +if (outer_cache.disable) { + outer_cache.flush_all (); + outer_cache.disable (); + } +__mmu_cache_off (); +} + +/** +* Disable MMU and D-cache, flush caches +* @return 0 (always) +* +* This function is called by shutdown_barebox to get a clean +* memory/cache state. +*/ +static void arch_shutdown (void ) +{ +mmu_disable (); +flush_icache (); +} +archshutdown_exitcall (arch_shutdown); + +extern unsigned long arm_stack_top; + +static int arm_request_stack (void ) +{ +if (!request_sdram_region ("stack" , arm_stack_top -STACK_SIZE ,STACK_SIZE )) +pr_err ("Error: Cannot request SDRAM region for stack\n" ); + +return 0 ; +} +coredevice_initcall (arm_request_stack);arch/arm64/cpu/cpuinfo.c new file +211
-0@@ -0,0 +1,211 @@ +/* +* cpuinfo.c - Show information about cp15 registers +* +* Copyright (c) 2009 Sascha Hauer <[email protected]>, Pengutronix +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +*/ + +#include <common.h> +#include <command.h> +#include <complete.h> + +#define CPU_ARCH_UNKNOWN 0 +#define CPU_ARCH_ARMv8 10 + +#define ARM_CPU_PART_CORTEX_A53 0xD034 +#define ARM_CPU_PART_CORTEX_A57 0xD070 + +static void decode_cache (unsigned long size) +{ +int linelen =1 << ((size &0x3 ) +3 ); +int mult =2 + ((size >>2 ) &1 ); +int cache_size = mult << (((size >>6 ) &0x7 ) +8 ); + +if (((size >>2 ) &0xf ) ==1 ) +printf ("no cache\n" ); +else +printf ("%d bytes (linelen = %d)\n" , cache_size, linelen); +} + +static char *crbits[] = {"M" ,"A" ,"C" ,"W" ,"P" ,"D" ,"L" ,"B" ,"S" ,"R" , +"F" ,"Z" ,"I" ,"V" ,"RR" ,"L4" ,"DT" ,"" ,"IT" ,"ST" ,"" ,"FI" ,"U" ,"XP" , +"VE" ,"EE" ,"L2" ,"" ,"TRE" ,"AFE" ,"TE" }; + +static int do_cpuinfo (int argc,char *argv[]) +{ +unsigned long mainid, cache, cr; +char *architecture, *implementer; +int i; +int cpu_arch; + + __asm__ __volatile__( +"mrs %0, midr_el1\n" + :"=r" (mainid) + : + :"memory" ); + +// __asm__ __volatile__( +// "mrc p15, 0, %0, c0, c0, 1 @ read control reg\n" +// : "=r" (cache) +// : +// : "memory"); +// +// __asm__ __volatile__( +// "mrc p15, 0, %0, c1, c0, 0 @ read control reg\n" +// : "=r" (cr) +// : +// : "memory"); + +switch (mainid >>24 ) { +case 0x41 : + implementer ="ARM" ; +break ; +case 0x44 : + implementer ="Digital Equipment Corp." ; +break ; +case 0x40 : + implementer ="Motorola - Freescale Semiconductor Inc." ; +break ; +case 0x56 : + implementer ="Marvell Semiconductor Inc." ; +break ; +case 0x69 : + implementer ="Intel Corp." ; +break ; +default : + implementer ="Unknown" ; + } + +if ((mainid &0x0008f000 ) ==0 ) { + cpu_arch =CPU_ARCH_UNKNOWN ; + }else if ((mainid &0x0008f000 ) ==0x00007000 ) { + cpu_arch = (mainid & (1 <<23 )) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3; + }else if ((mainid &0x00080000 ) ==0x00000000 ) { + cpu_arch = (mainid >>16 ) &7 ; +if (cpu_arch) + cpu_arch += CPU_ARCH_ARMv3; + }else if ((mainid &0x000f0000 ) ==0x000f0000 ) { +unsigned int mmfr0; + +/* Revised CPUID format. Read the Memory Model Feature +* Register 0 and check for VMSAv7 or PMSAv7 */ +// asm("mrc p15, 0, %0, c0, c1, 4" +// : "=r" (mmfr0)); +if ((mmfr0 &0x0000000f ) >=0x00000003 || + (mmfr0 &0x000000f0 ) >=0x00000030 ) + cpu_arch = CPU_ARCH_ARMv7; +else if ((mmfr0 &0x0000000f ) ==0x00000002 || + (mmfr0 &0x000000f0 ) ==0x00000020 ) + cpu_arch = CPU_ARCH_ARMv6; +else + cpu_arch =CPU_ARCH_UNKNOWN ; + }else + cpu_arch =CPU_ARCH_UNKNOWN ; + +switch (cpu_arch) { +case CPU_ARCH_ARMv3: + architecture ="v3" ; +break ; +case CPU_ARCH_ARMv4: + architecture ="v4" ; +break ; +case CPU_ARCH_ARMv4T: + architecture ="v4T" ; +break ; +case CPU_ARCH_ARMv5: + architecture ="v5" ; +break ; +case CPU_ARCH_ARMv5T: + architecture ="v5T" ; +break ; +case CPU_ARCH_ARMv5TE: + architecture ="v5TE" ; +break ; +case CPU_ARCH_ARMv5TEJ: + architecture ="v5TEJ" ; +break ; +case CPU_ARCH_ARMv6: + architecture ="v6" ; +break ; +case CPU_ARCH_ARMv7: + architecture ="v7" ; +break ; +case CPU_ARCH_ARMv8: + architecture ="v8" ; +break ; +case CPU_ARCH_UNKNOWN : +default : + architecture ="Unknown" ; + } + +printf ("implementer: %s\narchitecture: %s\n" , + implementer, architecture); + +if (cpu_arch == CPU_ARCH_ARMv7) { +unsigned int major, minor; +char *part; + major = (mainid >>20 ) &0xf ; + minor = mainid &0xf ; +switch (mainid &0xfff0 ) { +case ARM_CPU_PART_CORTEX_A5 : + part ="Cortex-A5" ; +break ; +case ARM_CPU_PART_CORTEX_A7 : + part ="Cortex-A7" ; +break ; +case ARM_CPU_PART_CORTEX_A8 : + part ="Cortex-A8" ; +break ; +case ARM_CPU_PART_CORTEX_A9 : + part ="Cortex-A9" ; +break ; +case ARM_CPU_PART_CORTEX_A15 : + part ="Cortex-A15" ; +break ; +case ARM_CPU_PART_CORTEX_A53 : + part ="Cortex-A53" ; +default : + part ="unknown" ; + } +printf ("core: %s r%up%u\n" , part, major, minor); + } + +// if (cache & (1 << 24)) { +// /* separate I/D cache */ +// printf("I-cache: "); +// decode_cache(cache & 0xfff); +// printf("D-cache: "); +// decode_cache((cache >> 12) & 0xfff); +// } else { +// /* unified I/D cache */ +// printf("cache: "); +// decode_cache(cache & 0xfff); +// } + +// printf("Control register: "); +// for (i = 0; i < ARRAY_SIZE(crbits); i++) +// if (cr & (1 << i)) +// printf("%s ", crbits[i]); +// printf("\n"); + +return 0 ; +} + +BAREBOX_CMD_START (cpuinfo) + .cmd = do_cpuinfo, + BAREBOX_CMD_DESC("show info about CPU") + BAREBOX_CMD_GROUP(CMD_GRP_INFO) + BAREBOX_CMD_COMPLETE(empty_complete) +BAREBOX_CMD_END +arch/arm64/cpu/entry.c new file +38
-0@@ -0,0 +1,38 @@ +#include <types.h> + +#include <asm/cache.h> + +#include "entry.h" + +/* +* Main ARM entry point. Call this with the memory region you can +* spare for barebox. This doesn't necessarily have to be the full +* SDRAM. The currently running binary can be inside or outside of +* this region. TEXT_BASE can be inside or outside of this +* region. boarddata will be preserved and can be accessed later with +* barebox_arm_boarddata(). +* +* -> membase + memsize +* STACK_SIZE - stack +* 16KiB, aligned to 16KiB - First level page table if early MMU support +* is enabled +* 128KiB - early memory space +* -> maximum end of barebox binary +* +* Usually a TEXT_BASE of 1MiB below your lowest possible end of memory should +* be fine. +*/ + +void __noreturn barebox_arm_entry (unsigned long membase, +unsigned long memsize,void *boarddata) +{ +arm_setup_stack (membase + memsize -16 ); +arm_early_mmu_cache_invalidate (); + +if (IS_ENABLED (CONFIG_PBL_MULTI_IMAGES )) +barebox_multi_pbl_start (membase, memsize, boarddata); +else if (IS_ENABLED (CONFIG_PBL_SINGLE_IMAGE )) +barebox_single_pbl_start (membase, memsize, boarddata); +else +barebox_non_pbl_start (membase, memsize, boarddata); +}arch/arm64/cpu/entry.h new file +18
-0@@ -0,0 +1,18 @@ +#ifndef __ENTRY_H__ +#define __ENTRY_H__ + +#include <common.h> + +void __noreturn barebox_non_pbl_start (unsigned long membase, +unsigned long memsize, +void *boarddata); + +void __noreturn barebox_multi_pbl_start (unsigned long membase, +unsigned long memsize, +void *boarddata); + +void __noreturn barebox_single_pbl_start (unsigned long membase, +unsigned long memsize, +void *boarddata); + +#endif arch/arm64/cpu/exceptions.S new file +127
-0@@ -0,0 +1,127 @@ +/* + * (C) Copyright 2013 + * David Feng <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <config.h> +#include <asm/ptrace.h> +#include <linux/linkage.h> + +/* + * Enter Exception. + * This will save the processor state that is ELR/X0~X30 + * to the stack frame. + */ +.macro exception_entry + stp x29, x30, [sp, #-16]! + stp x27, x28, [sp, #-16]! + stp x25, x26, [sp, #-16]! + stp x23, x24, [sp, #-16]! + stp x21, x22, [sp, #-16]! + stp x19, x20, [sp, #-16]! + stp x17, x18, [sp, #-16]! + stp x15, x16, [sp, #-16]! + stp x13, x14, [sp, #-16]! + stp x11, x12, [sp, #-16]! + stp x9, x10, [sp, #-16]! + stp x7, x8, [sp, #-16]! + stp x5, x6, [sp, #-16]! + stp x3, x4, [sp, #-16]! + stp x1, x2, [sp, #-16]! + + /* Could be running at EL3/EL2/EL1 */ + mrs x11, CurrentEL + cmp x11, #0xC /* Check EL3 state */ + b.eq 1f + cmp x11, #0x8 /* Check EL2 state */ + b.eq 2f + cmp x11, #0x4 /* Check EL1 state */ + b.eq 3f +3: mrs x1, esr_el3 + mrs x2, elr_el3 + b 0f +2: mrs x1, esr_el2 + mrs x2, elr_el2 + b 0f +1: mrs x1, esr_el1 + mrs x2, elr_el1 +0: + stp x2, x0, [sp, #-16]! + mov x0, sp +.endm + +/* + * Exception vectors. + */ + .align 11 + .globl vectors +vectors: + .align 7 + b _do_bad_sync /* Current EL Synchronous Thread */ + + .align 7 + b _do_bad_irq /* Current EL IRQ Thread */ + + .align 7 + b _do_bad_fiq /* Current EL FIQ Thread */ + + .align 7 + b _do_bad_error /* Current EL Error Thread */ + + .align 7 + b _do_sync /* Current EL Synchronous Handler */ + + .align 7 + b _do_irq /* Current EL IRQ Handler */ + + .align 7 + b _do_fiq /* Current EL FIQ Handler */ + + .align 7 + b _do_error /* Current EL Error Handler */ + + +_do_bad_sync: + exception_entry + bl do_bad_sync + +_do_bad_irq: + exception_entry + bl do_bad_irq + +_do_bad_fiq: + exception_entry + bl do_bad_fiq + +_do_bad_error: + exception_entry + bl do_bad_error + +_do_sync: + exception_entry + bl do_sync + +_do_irq: + exception_entry + bl do_irq + +_do_fiq: + exception_entry + bl do_fiq + +_do_error: + exception_entry + bl do_error + +.section .data +.align 4 +.global arm_ignore_data_abort +arm_ignore_data_abort: +.word 0 /* When != 0 data aborts are ignored */ +.global arm_data_abort_occurred +arm_data_abort_occurred: +.word 0 /* set != 0 by the data abort handler */ +abort_stack: +.space 8arch/arm64/cpu/interrupts.c new file +162
-0@@ -0,0 +1,162 @@ +/* +* interrupts.c - Interrupt Support Routines +* +* Copyright (c) 2007 Sascha Hauer <[email protected]>, Pengutronix +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +* +*/ + +/** +* @file +* @brief Interrupt Support Routines +*/ + +#include <common.h> +#include <abort.h> +#include <asm/ptrace.h> +#include <asm/unwind.h> + +static void __noreturn do_exception (struct pt_regs *pt_regs) +{ +panic ("" ); +} + +/** +* The CPU runs into an undefined instruction. That really should not happen! +* @param[in] pt_regs Register set content when the accident happens +*/ +void do_undefined_instruction (struct pt_regs *pt_regs) +{ +printf ("undefined instruction\n" ); +do_exception (pt_regs); +} + +/** +* The CPU catches a software interrupt +* @param[in] pt_regs Register set content when the interrupt happens +* +* There is no function behind this feature. So what to do else than +* a reset? +*/ +void do_software_interrupt (struct pt_regs *pt_regs) +{ +printf ("software interrupt\n" ); +do_exception (pt_regs); +} + +/** +* The CPU catches a prefetch abort. That really should not happen! +* @param[in] pt_regs Register set content when the accident happens +* +* instruction fetch from an unmapped area +*/ +void do_prefetch_abort (struct pt_regs *pt_regs) +{ +printf ("prefetch abort\n" ); +do_exception (pt_regs); +} + +/** +* The CPU catches a data abort. That really should not happen! +* @param[in] pt_regs Register set content when the accident happens +* +* data fetch from an unmapped area +*/ +void do_data_abort (struct pt_regs *pt_regs) +{ +u32 far; + +printf ("unable to handle %s at address 0x%08x\n" , + far <PAGE_SIZE ?"NULL pointer dereference" : +"paging request" , far); + +do_exception (pt_regs); +} + +/** +* The CPU catches a fast interrupt request. +* @param[in] pt_regs Register set content when the interrupt happens +* +* We never enable FIQs, so this should not happen +*/ +void do_fiq (struct pt_regs *pt_regs) +{ +printf ("fast interrupt request\n" ); +do_exception (pt_regs); +} + +/** +* The CPU catches a regular interrupt. +* @param[in] pt_regs Register set content when the interrupt happens +* +* We never enable interrupts, so this should not happen +*/ +void do_irq (struct pt_regs *pt_regs) +{ +printf ("interrupt request\n" ); +do_exception (pt_regs); +} + +void do_bad_sync (struct pt_regs *pt_regs) +{ +printf ("bad sync\n" ); +do_exception (pt_regs); +} + +void do_bad_irq (struct pt_regs *pt_regs) +{ +printf ("bad irq\n" ); +do_exception (pt_regs); +} + +void do_bad_fiq (struct pt_regs *pt_regs) +{ +printf ("bad fiq\n" ); +do_exception (pt_regs); +} + +void do_bad_error (struct pt_regs *pt_regs) +{ +printf ("bad error\n" ); +do_exception (pt_regs); +} + +void do_sync (struct pt_regs *pt_regs) +{ +printf ("sync exception\n" ); +do_exception (pt_regs); +} + + +void do_error (struct pt_regs *pt_regs) +{ +printf ("error exception\n" ); +do_exception (pt_regs); +} + +extern volatile int arm_ignore_data_abort; +extern volatile int arm_data_abort_occurred; + +void data_abort_mask (void ) +{ + arm_data_abort_occurred =0 ; + arm_ignore_data_abort =1 ; +} + +int data_abort_unmask (void ) +{ + arm_ignore_data_abort =0 ; + +return arm_data_abort_occurred !=0 ; +}arch/arm64/cpu/lowlevel.S new file +49
-0@@ -0,0 +1,49 @@ +#include <linux/linkage.h> +#include <init.h> +#include <asm/system.h> +#include <asm/gic.h> +#include <asm-generic/memory_layout.h> + +.section ".text_bare_init_","ax" + +ENTRY(arm_cpu_lowlevel_init) + adr x0, vectors + mrs x1, CurrentEL + cmp x1, #0xC /* Check EL3 state */ + b.eq 1f + cmp x1, #0x8 /* Check EL2 state */ + b.eq 2f + cmp x1, #0x4 /* Check EL1 state */ + b.eq 3f + +1: + msr vbar_el3, x0 + mov x0, #1 /* Non-Secure EL0/1 */ + orr x0, x0, #(1 << 10) /* 64-bit EL2 */ + msr scr_el3, x0 + msr cptr_el3, xzr + b done + +2: + msr vbar_el2, x0 + mov x0, #0x33ff /* Enable FP/SIMD */ + msr cptr_el2, x0 + b done + + +3: + msr vbar_el1, x0 + mov x0, #(3 << 20) /* Enable FP/SIMD */ + msr cpacr_el1, x0 + b done + +done: + ldr x1, =STACK_BASE + mov sp, x1 + mov x29, #0 + stp x29, x29, [sp, #-16]! + mov x29, sp + + ret + +ENDPROC(arm_cpu_lowlevel_init)arch/arm64/cpu/mmu-early.c new file +53
-0@@ -0,0 +1,53 @@ +#include <common.h> +#include <asm/mmu.h> +#include <errno.h> +#include <linux/sizes.h> +#include <asm/memory.h> +#include <asm/system.h> +#include <asm/cache.h> + +#include "mmu.h" + +static uint32_t *ttb; + +static void create_sections (unsigned long addr,int size_m,unsigned int flags) +{ +int i; + + addr >>=20 ; + +for (i = size_m; i >0 ; i--, addr++) + ttb[addr] = (addr <<20 ) | flags; +} + +static void map_cachable (unsigned long start,unsigned long size) +{ + start &= ~(SZ_1M -1 ); + size = (size + (SZ_1M -1 )) & ~(SZ_1M -1 ); + +create_sections (start, size >>20 ,PMD_SECT_AP_WRITE | +PMD_SECT_AP_READ |PMD_TYPE_SECT |PMD_SECT_WB ); +} + +void mmu_early_enable (uint32_t membase,uint32_t memsize,uint32_t _ttb) +{ +int i; + + ttb = (uint32_t *)_ttb; + +arm_set_cache_functions (); + +/* Set the ttb register */ + asmvolatile ("mcr p15,0,%0,c2,c0,0" : :"r" (ttb)/*:*/ ); + +/* Set the Domain Access Control Register */ + i =0x3 ; + asmvolatile ("mcr p15,0,%0,c3,c0,0" : :"r" (i)/*:*/ ); + +create_sections (0 ,4096 ,PMD_SECT_AP_WRITE | +PMD_SECT_AP_READ |PMD_TYPE_SECT ); + +map_cachable (membase, memsize); + +__mmu_cache_on (); +}arch/arm64/cpu/mmu-early.h new file +6
-0@@ -0,0 +1,6 @@ +#ifndef __ARM_CPU_MMU_EARLY_H +#define __ARM_CPU_MMU_EARLY_H + +void mmu_early_enable (uint32_t membase,uint32_t memsize,uint32_t ttb); + +#endif /* __ARM_CPU_MMU_EARLY_H */ arch/arm64/cpu/mmu.c new file +492
-0@@ -0,0 +1,492 @@ +/* +* Copyright (c) 2009-2013 Sascha Hauer <[email protected]>, Pengutronix +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +* +*/ + +#define pr_fmt (fmt) "mmu: " fmt + +#include <common.h> +#include <dma-dir.h> +#include <init.h> +#include <mmu.h> +#include <errno.h> +#include <linux/sizes.h> +#include <asm/memory.h> +#include <asm/barebox-arm.h> +#include <asm/system.h> +#include <asm/cache.h> +#include <memory.h> +#include <asm/system_info.h> + +#include "mmu.h" + +static unsigned long *ttb; + +static void create_sections (unsigned long virt,unsigned long phys,int size_m, +unsigned int flags) +{ +int i; + + phys >>=20 ; + virt >>=20 ; + +for (i = size_m; i >0 ; i--, virt++, phys++) + ttb[virt] = (phys <<20 ) | flags; + +__mmu_cache_flush (); +} + +/* +* Do it the simple way for now and invalidate the entire +* tlb +*/ +static inline void tlb_invalidate (void ) +{ + asmvolatile ( +"mov r0, #0\n" +"mcr p15, 0, r0, c7, c10, 4; @ drain write buffer\n" +"mcr p15, 0, r0, c8, c6, 0; @ invalidate D TLBs\n" +"mcr p15, 0, r0, c8, c5, 0; @ invalidate I TLBs\n" + : + : + :"r0" + ); +} + +#define PTE_FLAGS_CACHED_V7 (PTE_EXT_TEX(1) | PTE_BUFFERABLE | PTE_CACHEABLE) +#define PTE_FLAGS_WC_V7 PTE_EXT_TEX(1) +#define PTE_FLAGS_UNCACHED_V7 (0) +#define PTE_FLAGS_CACHED_V4 (PTE_SMALL_AP_UNO_SRW | PTE_BUFFERABLE | PTE_CACHEABLE) +#define PTE_FLAGS_UNCACHED_V4 PTE_SMALL_AP_UNO_SRW + +/* +* PTE flags to set cached and uncached areas. +* This will be determined at runtime. +*/ +static uint32_t pte_flags_cached; +static uint32_t pte_flags_wc; +static uint32_t pte_flags_uncached; + +#define PTE_MASK ((1 << 12) - 1) + +static void arm_mmu_not_initialized_error (void ) +{ +/* +* This means: +* - one of the MMU functions like dma_alloc_coherent +* or remap_range is called too early, before the MMU is initialized +* - Or the MMU initialization has failed earlier +*/ +panic ("MMU not initialized\n" ); +} + +/* +* Create a second level translation table for the given virtual address. +* We initially create a flat uncached mapping on it. +* Not yet exported, but may be later if someone finds use for it. +*/ +static u32 *arm_create_pte (unsigned long virt) +{ +u32 *table; +int i; + + table =memalign (0x400 ,0x400 ); + +if (!ttb) +arm_mmu_not_initialized_error (); + + ttb[virt >>20 ] = (unsigned long )table |PMD_TYPE_TABLE ; + +for (i =0 ; i <256 ; i++) { + table[i] = virt |PTE_TYPE_SMALL | pte_flags_uncached; + virt +=PAGE_SIZE ; + } + +return table; +} + +static u32 *find_pte (unsigned long adr) +{ +u32 *table; + +if (!ttb) +arm_mmu_not_initialized_error (); + +if ((ttb[adr >>20 ] &PMD_TYPE_MASK ) !=PMD_TYPE_TABLE ) { +struct memory_bank *bank; +int i =0 ; + +/* +* This should only be called for page mapped memory inside our +* memory banks. It's a bug to call it with section mapped memory +* locations. +*/ +pr_crit ("%s: TTB for address 0x%08lx is not of type table\n" , + __func__, adr); +pr_crit ("Memory banks:\n" ); +for_each_memory_bank (bank) +pr_crit ("#%d 0x%08lx - 0x%08lx\n" , i, bank->start, + bank->start + bank->size -1 ); +BUG (); + } + +/* find the coarse page table base address */ + table = (u32 *)(ttb[adr >>20 ] & ~0x3ff ); + +/* find second level descriptor */ +return &table[(adr >>PAGE_SHIFT ) &0xff ]; +} + +static void dma_flush_range (unsigned long start,unsigned long end) +{ +__dma_flush_range (start, end); +if (outer_cache.flush_range) + outer_cache.flush_range (start, end); +} + +static void dma_inv_range (unsigned long start,unsigned long end) +{ +if (outer_cache.inv_range) + outer_cache.inv_range (start, end); +__dma_inv_range (start, end); +} + +static int __remap_range (void *_start,size_t size,u32 pte_flags) +{ +unsigned long start = (unsigned long )_start; +u32 *p; +int numentries, i; + + numentries = size >>PAGE_SHIFT ; + p =find_pte (start); + +for (i =0 ; i < numentries; i++) { + p[i] &= ~PTE_MASK ; + p[i] |= pte_flags |PTE_TYPE_SMALL ; + } + +dma_flush_range ((unsigned long )p, + (unsigned long )p + numentries *sizeof (u32)); + +tlb_invalidate (); + +return 0 ; +} + +int arch_remap_range (void *start,size_t size,unsigned flags) +{ +u32 pte_flags; + +switch (flags) { +case MAP_CACHED : + pte_flags = pte_flags_cached; +break ; +case MAP_UNCACHED : + pte_flags = pte_flags_uncached; +break ; +default : +return -EINVAL ; + } + +return __remap_range (start, size, pte_flags); +} + +void *map_io_sections (unsigned long phys,void *_start,size_t size) +{ +unsigned long start = (unsigned long )_start, sec; + + phys >>=20 ; +for (sec = start; sec < start + size; sec += (1 <<20 )) + ttb[sec >>20 ] = (phys++ <<20 ) |PMD_SECT_DEF_UNCACHED ; + +dma_flush_range ((unsigned long )ttb, (unsigned long )ttb +0x4000 ); +tlb_invalidate (); +return _start; +} + +/* +* remap the memory bank described by mem cachable and +* bufferable +*/ +static int arm_mmu_remap_sdram (struct memory_bank *bank) +{ +unsigned long phys = (unsigned long )bank->start; +unsigned long ttb_start = phys >>20 ; +unsigned long ttb_end = (phys >>20 ) + (bank->size >>20 ); +unsigned long num_ptes = bank->size >>12 ; +int i, pte; +u32 *ptes; + +pr_debug ("remapping SDRAM from 0x%08lx (size 0x%08lx)\n" , + phys, bank->size); + +/* +* We replace each 1MiB section in this range with second level page +* tables, therefore we must have 1Mib aligment here. +*/ +if ((phys & (SZ_1M -1 )) || (bank->size & (SZ_1M -1 ))) +return -EINVAL ; + + ptes =xmemalign (PAGE_SIZE , num_ptes *sizeof (u32)); + +pr_debug ("ptes: 0x%p ttb_start: 0x%08lx ttb_end: 0x%08lx\n" , + ptes, ttb_start, ttb_end); + +for (i =0 ; i < num_ptes; i++) { + ptes[i] = (phys + i *PAGE_SIZE ) |PTE_TYPE_SMALL | + pte_flags_cached; + } + + pte =0 ; + +for (i = ttb_start; i < ttb_end; i++) { + ttb[i] = (unsigned long )(&ptes[pte]) |PMD_TYPE_TABLE | + (0 <<4 ); + pte +=256 ; + } + +dma_flush_range ((unsigned long )ttb, (unsigned long )ttb +0x4000 ); +dma_flush_range ((unsigned long )ptes, + (unsigned long )ptes + num_ptes *sizeof (u32)); + +tlb_invalidate (); + +return 0 ; +} +/* +* We have 8 exception vectors and the table consists of absolute +* jumps, so we need 8 * 4 bytes for the instructions and another +* 8 * 4 bytes for the addresses. +*/ +#define ARM_VECTORS_SIZE (sizeof(u32) * 8 * 2) + +/* +* Map vectors and zero page +*/ +static void vectors_init (void ) +{ +u32 *exc, *zero =NULL ; +void *vectors; +u32 cr; + + cr =get_cr (); + cr |=CR_V ; +set_cr (cr); + cr =get_cr (); + +if (cr &CR_V ) { +/* +* If we can use high vectors, create the second level +* page table for the high vectors and zero page +*/ + exc =arm_create_pte (0xfff00000 ); + zero =arm_create_pte (0x0 ); + +/* Set the zero page to faulting */ + zero[0 ] =0 ; + }else { +/* +* Otherwise map the vectors to the zero page. We have to +* live without being able to catch NULL pointer dereferences +*/ + exc =arm_create_pte (0x0 ); + +if (cpu_architecture () >= CPU_ARCH_ARMv7) { +/* +* ARMv7 CPUs allow to remap low vectors from +* 0x0 to an arbitrary address using VBAR +* register, so let's make sure we have it +* pointing to the correct address +*/ +set_vbar (0x0 ); + } + } + +arm_fixup_vectors (); + + vectors =xmemalign (PAGE_SIZE ,PAGE_SIZE ); +memset (vectors,0 ,PAGE_SIZE ); +memcpy (vectors, __exceptions_start, __exceptions_stop - __exceptions_start); + +if (cr &CR_V ) + exc[256 -16 ] = (u32 )vectors |PTE_TYPE_SMALL | + pte_flags_cached; +else + exc[0 ] = (u32 )vectors |PTE_TYPE_SMALL | pte_flags_cached; +} + +/* +* Prepare MMU for usage enable it. +*/ +static int mmu_init (void ) +{ +struct memory_bank *bank; +int i; + +if (list_empty (&memory_banks)) +/* +* If you see this it means you have no memory registered. +* This can be done either with arm_add_mem_device() in an +* initcall prior to mmu_initcall or via devicetree in the +* memory node. +*/ +panic ("MMU: No memory bank found! Cannot continue\n" ); + +arm_set_cache_functions (); + +if (cpu_architecture () >= CPU_ARCH_ARMv7) { + pte_flags_cached =PTE_FLAGS_CACHED_V7 ; + pte_flags_wc =PTE_FLAGS_WC_V7 ; + pte_flags_uncached =PTE_FLAGS_UNCACHED_V7 ; + }else { + pte_flags_cached =PTE_FLAGS_CACHED_V4 ; + pte_flags_wc =PTE_FLAGS_UNCACHED_V4 ; + pte_flags_uncached =PTE_FLAGS_UNCACHED_V4 ; + } + +if (get_cr () &CR_M ) { +/* +* Early MMU code has already enabled the MMU. We assume a +* flat 1:1 section mapping in this case. +*/ + asmvolatile ("mrc p15,0,%0,c2,c0,0" :"=r" (ttb)); + +/* Clear unpredictable bits [13:0] */ + ttb = (unsigned long *)((unsigned long )ttb & ~0x3fff ); + +if (!request_sdram_region ("ttb" , (unsigned long )ttb,SZ_16K )) +/* +* This can mean that: +* - the early MMU code has put the ttb into a place +* which we don't have inside our available memory +* - Somebody else has occupied the ttb region which means +* the ttb will get corrupted. +*/ +pr_crit ("Critical Error: Can't request SDRAM region for ttb at %p\n" , + ttb); + }else { + ttb =memalign (0x10000 ,0x4000 ); + } + +pr_debug ("ttb: 0x%p\n" , ttb); + +/* Set the ttb register */ + asmvolatile ("mcr p15,0,%0,c2,c0,0" : :"r" (ttb)/*:*/ ); + +/* Set the Domain Access Control Register */ + i =0x3 ; + asmvolatile ("mcr p15,0,%0,c3,c0,0" : :"r" (i)/*:*/ ); + +/* create a flat mapping using 1MiB sections */ +create_sections (0 ,0 ,PAGE_SIZE ,PMD_SECT_AP_WRITE |PMD_SECT_AP_READ | +PMD_TYPE_SECT ); + +vectors_init (); + +/* +* First remap sdram cached using sections. +* This is to speed up the generation of 2nd level page tables +* below +*/ +for_each_memory_bank (bank) +create_sections (bank->start, bank->start, bank->size >>20 , +PMD_SECT_DEF_CACHED ); + +__mmu_cache_on (); + +/* +* Now that we have the MMU and caches on remap sdram again using +* page tables +*/ +for_each_memory_bank (bank) +arm_mmu_remap_sdram (bank); + +return 0 ; +} +mmu_initcall (mmu_init); + +void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle) +{ +void *ret; + + size =PAGE_ALIGN (size); + ret =xmemalign (PAGE_SIZE , size); +if (dma_handle) + *dma_handle = (dma_addr_t )ret; + +dma_inv_range ((unsigned long )ret, (unsigned long )ret + size); + +__remap_range (ret, size, pte_flags_uncached); + +return ret; +} + +void *dma_alloc_writecombine (size_t size,dma_addr_t *dma_handle) +{ +void *ret; + + size =PAGE_ALIGN (size); + ret =xmemalign (PAGE_SIZE , size); +if (dma_handle) + *dma_handle = (dma_addr_t )ret; + +dma_inv_range ((unsigned long )ret, (unsigned long )ret + size); + +__remap_range (ret, size, pte_flags_wc); + +return ret; +} + +unsigned long virt_to_phys (volatile void *virt) +{ +return (unsigned long )virt; +} + +void *phys_to_virt (unsigned long phys) +{ +return (void *)phys; +} + +void dma_free_coherent (void *mem,dma_addr_t dma_handle,size_t size) +{ + size =PAGE_ALIGN (size); +__remap_range (mem, size, pte_flags_cached); + +free (mem); +} + +void dma_sync_single_for_cpu (unsigned long address,size_t size, +enum dma_data_direction dir) +{ +if (dir !=DMA_TO_DEVICE ) { +if (outer_cache.inv_range) + outer_cache.inv_range (address, address + size); +__dma_inv_range (address, address + size); + } +} + +void dma_sync_single_for_device (unsigned long address,size_t size, +enum dma_data_direction dir) +{ +if (dir ==DMA_FROM_DEVICE ) { +__dma_inv_range (address, address + size); +if (outer_cache.inv_range) + outer_cache.inv_range (address, address + size); + }else { +__dma_clean_range (address, address + size); +if (outer_cache.clean_range) + outer_cache.clean_range (address, address + size); + } +}arch/arm64/cpu/mmu.h new file +14
-0@@ -0,0 +1,14 @@ +#ifndef __ARM_MMU_H +#define __ARM_MMU_H + +#ifdef CONFIG_MMU +void __mmu_cache_on (void ); +void __mmu_cache_off (void ); +void __mmu_cache_flush (void ); +#else +static inline void __mmu_cache_on (void ) {} +static inline void __mmu_cache_off (void ) {} +static inline void __mmu_cache_flush (void ) {} +#endif + +#endif /* __ARM_MMU_H */ arch/arm64/cpu/mmuinfo.c new file +104
-0@@ -0,0 +1,104 @@ +/* +* mmuinfo.c - Show MMU/cache information from cp15 registers +* +* Copyright (c) Jan Luebbe <[email protected]>, Pengutronix +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +* +*/ + +#include <common.h> +#include <command.h> + +static char *inner_attr[] = { +"0b000 Non-cacheable" , +"0b001 Strongly-ordered" , +"0b010 (reserved)" , +"0b011 Device" , +"0b100 (reserved)" , +"0b101 Write-Back, Write-Allocate" , +"0b110 Write-Through" , +"0b111 Write-Back, no Write-Allocate" , +}; + +static char *outer_attr[] = { +"0b00 Non-cacheable" , +"0b01 Write-Back, Write-Allocate" , +"0b10 Write-Through, no Write-Allocate" , +"0b11 Write-Back, no Write-Allocate" , +}; + +static void decode_par (unsigned long par) +{ +printf (" Physical Address [31:12]: 0x%08lx\n" , par &0xFFFFF000 ); +printf (" Reserved [11]: 0x%lx\n" , (par >>11 ) &0x1 ); +printf (" Not Outer Shareable [10]: 0x%lx\n" , (par >>10 ) &0x1 ); +printf (" Non-Secure [9]: 0x%lx\n" , (par >>9 ) &0x1 ); +printf (" Impl. def. [8]: 0x%lx\n" , (par >>8 ) &0x1 ); +printf (" Shareable [7]: 0x%lx\n" , (par >>7 ) &0x1 ); +printf (" Inner mem. attr. [6:4]: 0x%lx (%s)\n" , (par >>4 ) &0x7 , + inner_attr[(par >>4 ) &0x7 ]); +printf (" Outer mem. attr. [3:2]: 0x%lx (%s)\n" , (par >>2 ) &0x3 , + outer_attr[(par >>2 ) &0x3 ]); +printf (" SuperSection [1]: 0x%lx\n" , (par >>1 ) &0x1 ); +printf (" Failure [0]: 0x%lx\n" , (par >>0 ) &0x1 ); +} + +static int do_mmuinfo (int argc,char *argv[]) +{ +unsigned long addr =0 , priv_read, priv_write; + +if (argc <2 ) +return COMMAND_ERROR_USAGE ; + + addr =strtoul_suffix (argv[1 ],NULL ,0 ); + + __asm__ __volatile__( +"mcr p15, 0, %0, c7, c8, 0 @ write VA to PA translation (priv read)\n" + : + :"r" (addr) + :"memory" ); + + __asm__ __volatile__( +"mrc p15, 0, %0, c7, c4, 0 @ read PAR\n" + :"=r" (priv_read) + : + :"memory" ); + + __asm__ __volatile__( +"mcr p15, 0, %0, c7, c8, 1 @ write VA to PA translation (priv write)\n" + : + :"r" (addr) + :"memory" ); + + __asm__ __volatile__( +"mrc p15, 0, %0, c7, c4, 0 @ read PAR\n" + :"=r" (priv_write) + : + :"memory" ); + +printf ("PAR result for 0x%08lx: \n" , addr); +printf (" privileged read: 0x%08lx\n" , priv_read); +decode_par (priv_read); +printf (" privileged write: 0x%08lx\n" , priv_write); +decode_par (priv_write); + +return 0 ; +} + +BAREBOX_CMD_START (mmuinfo) + .cmd = do_mmuinfo, + BAREBOX_CMD_DESC("show MMU/cache information of an address") + BAREBOX_CMD_OPTS("ADDRESS") +BAREBOX_CMD_GROUP (CMD_GRP_INFO) +BAREBOX_CMD_END arch/arm64/cpu/no-mmu.c new file +61
-0@@ -0,0 +1,61 @@ +/* +* Copyright (c) 2015 Zodiac Inflight Innovation +* Author: Andrey Smirnov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +* +*/ + +#define pr_fmt (fmt) "nommu: " fmt + +#include <common.h> +#include <dma-dir.h> +#include <init.h> +#include <mmu.h> +#include <errno.h> +#include <linux/sizes.h> +#include <asm/memory.h> +#include <asm/barebox-arm.h> +#include <asm/system.h> +#include <asm/cache.h> +#include <memory.h> +#include <asm/system_info.h> +#include <debug_ll.h> + + +#define __exceptions_size (__exceptions_stop - __exceptions_start) + +static int nommu_v8_vectors_init (void ) +{ +void *vectors; +u32 cr; + +if (cpu_architecture () < CPU_ARCH_ARMv8) +return 0 ; + +// /* +// * High vectors cannot be re-mapped, so we have to use normal +// * vectors +// */ +// cr = get_cr(); +// cr &= ~CR_V; +// set_cr(cr); +// +// arm_fixup_vectors(); +// +// vectors = xmemalign(PAGE_SIZE, PAGE_SIZE); +// memset(vectors, 0, PAGE_SIZE); +// memcpy(vectors, __exceptions_start, __exceptions_size); +// +// set_vbar((unsigned int)vectors); + +return 0 ; +} +mmu_initcall (nommu_v8_vectors_init);arch/arm64/cpu/start-pbl.c new file +102
-0@@ -0,0 +1,102 @@ +/* +* start-pbl.c +* +* Copyright (c) 2010-2012 Sascha Hauer <[email protected]>, Pengutronix +* Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +* +*/ + +#include <common.h> +#include <init.h> +#include <linux/sizes.h> +#include <pbl.h> +#include <asm/barebox-arm.h> +#include <asm/barebox-arm-head.h> +#include <asm-generic/memory_layout.h> +#include <asm/sections.h> +#include <asm/pgtable.h> +#include <asm/cache.h> + +#include "mmu-early.h" + +unsigned long free_mem_ptr; +unsigned long free_mem_end_ptr; + +/* +* First instructions in the pbl image +*/ +void __naked __section(.text_head_entry) pbl_start(void) +{ +barebox_arm_head (); +} + +extern void *input_data; +extern void *input_data_end; + +__noreturn void barebox_single_pbl_start (unsigned long membase, +unsigned long memsize,void *boarddata) +{ +uint32_t offset; +uint32_t pg_start, pg_end, pg_len; +void __noreturn (*barebox)(unsigned long ,unsigned long ,void *); +uint32_t endmem = membase + memsize; +unsigned long barebox_base; + +if (IS_ENABLED (CONFIG_PBL_RELOCATABLE )) +relocate_to_current_adr (); + +/* Get offset between linked address and runtime address */ + offset =get_runtime_offset (); + + pg_start = (uint32_t )&input_data - offset; + pg_end = (uint32_t )&input_data_end - offset; + pg_len = pg_end - pg_start; + +if (IS_ENABLED (CONFIG_RELOCATABLE )) + barebox_base =arm_mem_barebox_image (membase, endmem, pg_len); +else + barebox_base =TEXT_BASE ; + +if (offset && (IS_ENABLED (CONFIG_PBL_FORCE_PIGGYDATA_COPY ) || +region_overlap (pg_start, pg_len, barebox_base, pg_len *4 ))) { +/* +* copy piggydata binary to its link address +*/ +memcpy (&input_data, (void *)pg_start, pg_len); + pg_start = (uint32_t )&input_data; + } + +setup_c (); + +if (IS_ENABLED (CONFIG_MMU_EARLY )) { +unsigned long ttb =arm_mem_ttb (membase, endmem); +mmu_early_enable (membase, memsize, ttb); + } + + free_mem_ptr =arm_mem_early_malloc (membase, endmem); + free_mem_end_ptr =arm_mem_early_malloc_end (membase, endmem); + +pbl_barebox_uncompress ((void *)barebox_base, (void *)pg_start, pg_len); + +arm_early_mmu_cache_flush (); +flush_icache (); + +if (IS_ENABLED (CONFIG_THUMB2_BAREBOX )) + barebox = (void *)(barebox_base +1 ); +else + barebox = (void *)barebox_base; + +barebox (membase, memsize, boarddata); +}arch/arm64/cpu/start.c new file +247
-0@@ -0,0 +1,247 @@ +/* +* Copyright (c) 2010 Sascha Hauer <[email protected]>, Pengutronix +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +* +*/ +#define pr_fmt (fmt) "start.c: " fmt + +#include <common.h> +#include <init.h> +#include <linux/sizes.h> +#include <of.h> +#include <asm/barebox-arm.h> +#include <asm/barebox-arm-head.h> +#include <asm-generic/memory_layout.h> +#include <asm/sections.h> +#include <asm/unaligned.h> +#include <asm/cache.h> +#include <memory.h> +#include <uncompress.h> +#include <malloc.h> + +#include <debug_ll.h> +#include "mmu-early.h" + +unsigned long arm_stack_top; +static unsigned long arm_head_bottom; +static unsigned long arm_barebox_size; +static void *barebox_boarddata; + +static bool blob_is_fdt (const void *blob) +{ +return get_unaligned_be32 (blob) ==FDT_MAGIC ; +} + +static bool blob_is_compressed_fdt (const void *blob) +{ +const struct barebox_arm_boarddata_compressed_dtb *dtb = blob; + +return dtb->magic ==BAREBOX_ARM_BOARDDATA_COMPRESSED_DTB_MAGIC ; +} + +static bool blob_is_arm_boarddata (const void *blob) +{ +const struct barebox_arm_boarddata *bd = blob; + +return bd->magic ==BAREBOX_ARM_BOARDDATA_MAGIC ; +} + +u32 barebox_arm_machine (void ) +{ +if (barebox_boarddata &&blob_is_arm_boarddata (barebox_boarddata)) { +const struct barebox_arm_boarddata *bd = barebox_boarddata; +return bd->machine; + }else { +return 0 ; + } +} + +void *barebox_arm_boot_dtb (void ) +{ +void *dtb; +void *data; +int ret; +struct barebox_arm_boarddata_compressed_dtb *compressed_dtb; + +if (barebox_boarddata &&blob_is_fdt (barebox_boarddata)) { +pr_debug ("%s: using barebox_boarddata\n" , __func__); +return barebox_boarddata; + } + +if (!IS_ENABLED (CONFIG_ARM_USE_COMPRESSED_DTB ) || !barebox_boarddata + || !blob_is_compressed_fdt (barebox_boarddata)) +return NULL ; + + compressed_dtb = barebox_boarddata; + +pr_debug ("%s: using compressed_dtb\n" , __func__); + + dtb =malloc (compressed_dtb->datalen_uncompressed); +if (!dtb) +return NULL ; + + data = compressed_dtb +1 ; + + ret =uncompress (data, compressed_dtb->datalen,NULL ,NULL , + dtb,NULL ,NULL ); +if (ret) { +pr_err ("uncompressing dtb failed\n" ); +free (dtb); +return NULL ; + } + + barebox_boarddata = dtb; + +return barebox_boarddata; +} + +static inline unsigned long arm_mem_boarddata (unsigned long membase, +unsigned long endmem, +unsigned long size) +{ +unsigned long mem; + + mem =arm_mem_barebox_image (membase, endmem, barebox_image_size); + mem -=ALIGN (size,64 ); + +return mem; +} + +unsigned long arm_mem_ramoops_get (void ) +{ +return arm_mem_ramoops (0 , arm_stack_top); +} +EXPORT_SYMBOL_GPL (arm_mem_ramoops_get); + +static int barebox_memory_areas_init (void ) +{ +unsigned long start = arm_head_bottom; +unsigned long size =arm_mem_barebox_image (0 , arm_stack_top, + arm_barebox_size) - + arm_head_bottom; +request_sdram_region ("board data" , start, size); + +return 0 ; +} +device_initcall (barebox_memory_areas_init); + +__noreturn void barebox_non_pbl_start (unsigned long membase, +unsigned long memsize,void *boarddata) +{ +unsigned long endmem = membase + memsize; +unsigned long malloc_start, malloc_end; +unsigned long barebox_size = barebox_image_size + + ((unsigned long )&__bss_stop - (unsigned long )&__bss_start); + +if (IS_ENABLED (CONFIG_RELOCATABLE )) { +unsigned long barebox_base =arm_mem_barebox_image (membase, + endmem, + barebox_size); +relocate_to_adr (barebox_base); + } + +// setup_c(); + +barrier (); + +pr_debug ("memory at 0x%08lx, size 0x%08lx\n" , membase, memsize); + + arm_stack_top = endmem; + arm_barebox_size = barebox_size; + arm_head_bottom =arm_mem_barebox_image (membase, endmem, + arm_barebox_size); + +if (IS_ENABLED (CONFIG_MMU_EARLY )) { +unsigned long ttb =arm_mem_ttb (membase, endmem); + +if (IS_ENABLED (CONFIG_PBL_IMAGE )) { +arm_set_cache_functions (); + }else { +pr_debug ("enabling MMU, ttb @ 0x%08lx\n" , ttb); +arm_early_mmu_cache_invalidate (); +mmu_early_enable (membase, memsize, ttb); + } + } + +if (boarddata) { +uint32_t totalsize =0 ; +const char *name; + +if (blob_is_fdt (boarddata)) { + totalsize =get_unaligned_be32 (boarddata +4 ); + name ="DTB" ; + }else if (blob_is_compressed_fdt (boarddata)) { +struct barebox_arm_boarddata_compressed_dtb *bd = boarddata; + totalsize = bd->datalen +sizeof (*bd); + name ="Compressed DTB" ; + }else if (blob_is_arm_boarddata (boarddata)) { + totalsize =sizeof (struct barebox_arm_boarddata ); + name ="machine type" ; + } + +if (totalsize) { +unsigned long mem =arm_mem_boarddata (membase, endmem, + totalsize); +pr_debug ("found %s in boarddata, copying to 0x%lu\n" , + name, mem); + barebox_boarddata =memcpy ((void *)mem, boarddata, + totalsize); + arm_head_bottom = mem; + } + } + + malloc_end = arm_head_bottom; + +/* +* Maximum malloc space is the Kconfig value if given +* or 1GB. +*/ +if (MALLOC_SIZE >0 ) { + malloc_start = malloc_end -MALLOC_SIZE ; +if (malloc_start < membase) + malloc_start = membase; + }else { + malloc_start = malloc_end - (malloc_end - membase) /2 ; +if (malloc_end - malloc_start >SZ_1G ) + malloc_start = malloc_end -SZ_1G ; + } + +pr_debug ("initializing malloc pool at 0x%08lx (size 0x%08lx)\n" , + malloc_start, malloc_end - malloc_start); + +mem_malloc_init ((void *)malloc_start, (void *)malloc_end -1 ); + +pr_debug ("starting barebox...\n" ); + +start_barebox (); +} + +#ifndef CONFIG_PBL_IMAGE + +void __section(.text_entry) start(void) +{ +barebox_arm_head (); +} + +#else +/* +* First function in the uncompressed image. We get here from +* the pbl. The stack already has been set up by the pbl. +*/ +void __section(.text_entry) start(unsigned long membase, + unsigned long memsize, void *boarddata) +{ + barebox_non_pbl_start(membase, memsize, boarddata); +} +#endif arch/arm64/cpu/uncompress.c new file +111
-0@@ -0,0 +1,111 @@ +/* +* uncompress.c - uncompressor code for self extracing pbl image +* +* Copyright (c) 2010-2013 Sascha Hauer <[email protected]>, Pengutronix +* Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program 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. +* +*/ +#define pr_fmt (fmt) "uncompress.c: " fmt + +#include <common.h> +#include <init.h> +#include <linux/sizes.h> +#include <pbl.h> +#include <asm/barebox-arm.h> +#include <asm/barebox-arm-head.h> +#include <asm-generic/memory_layout.h> +#include <asm/sections.h> +#include <asm/pgtable.h> +#include <asm/cache.h> + +#include <debug_ll.h> + +#include "mmu-early.h" + +unsigned long free_mem_ptr; +unsigned long free_mem_end_ptr; + +static int __attribute__((__used__)) + __attribute__((__section__ (".image_end" ))) + __image_end_dummy =0xdeadbeef ; + +void __noreturn barebox_multi_pbl_start (unsigned long membase, +unsigned long memsize,void *boarddata) +{ +uint32_t pg_len; +void __noreturn (*barebox)(unsigned long ,unsigned long ,void *); +uint32_t endmem = membase + memsize; +unsigned long barebox_base; +uint32_t *image_end; +void *pg_start; +unsigned long pc =get_pc (); + + image_end = (void *)ld_var (__image_end) -get_runtime_offset (); + +if (IS_ENABLED (CONFIG_PBL_RELOCATABLE )) { +/* +* If we run from inside the memory just relocate the binary +* to the current address. Otherwise it may be a readonly location. +* Copy and relocate to the start of the memory in this case. +*/ +if (pc > membase && pc < membase + memsize) +relocate_to_current_adr (); +else +relocate_to_adr (membase); + } + +/* +* image_end is the first location after the executable. It contains +* the size of the appended compressed binary followed by the binary. +*/ + pg_start = image_end +1 ; + pg_len = *(image_end); + +if (IS_ENABLED (CONFIG_RELOCATABLE )) + barebox_base =arm_mem_barebox_image (membase, endmem, + pg_len); +else + barebox_base =TEXT_BASE ; + +setup_c (); + +pr_debug ("memory at 0x%08lx, size 0x%08lx\n" , membase, memsize); + +if (IS_ENABLED (CONFIG_MMU_EARLY )) { +unsigned long ttb =arm_mem_ttb (membase, endmem); +pr_debug ("enabling MMU, ttb @ 0x%08lx\n" , ttb); +mmu_early_enable (membase, memsize, ttb); + } + + free_mem_ptr =arm_mem_early_malloc (membase, endmem); + free_mem_end_ptr =arm_mem_early_malloc_end (membase, endmem); + +pr_debug ("uncompressing barebox binary at 0x%p (size 0x%08x) to 0x%08lx\n" , + pg_start, pg_len, barebox_base); + +pbl_barebox_uncompress ((void *)barebox_base, pg_start, pg_len); + +arm_early_mmu_cache_flush (); +flush_icache (); + +if (IS_ENABLED (CONFIG_THUMB2_BAREBOX )) + barebox = (void *)(barebox_base +1 ); +else + barebox = (void *)barebox_base; + +pr_debug ("jumping to uncompressed image at 0x%p\n" , barebox); + +barebox (membase, memsize, boarddata); +}arch/arm64/include/asm/armlinux.h new file +43
-0@@ -0,0 +1,43 @@ +#ifndef __ARCH_ARMLINUX_H +#define __ARCH_ARMLINUX_H + +#include <asm/memory.h> +#include <asm/setup.h> + +#if definedCONFIG_ARM_LINUX +void armlinux_set_bootparams (void *params); +void armlinux_set_architecture (int architecture); +void armlinux_set_revision (unsigned int ); +void armlinux_set_serial (u64 ); +#else +static inline void armlinux_set_bootparams (void *params) +{ +} + +static inline void armlinux_set_architecture (int architecture) +{ +} + +static inline void armlinux_set_revision (unsigned int rev) +{ +} + +static inline void armlinux_set_serial (u64 serial) +{ +} +#endif + +#if definedCONFIG_ARM_BOARD_APPEND_ATAG +void armlinux_set_atag_appender (struct tag *(*)(struct tag *)); +#else +static inline void armlinux_set_atag_appender (struct tag *(*func)(struct tag *)) +{ +} +#endif + +struct image_data ; + +void start_linux (void *adr,int swap,unsigned long initrd_address, +unsigned long initrd_size,void *oftree); + +#endif /* __ARCH_ARMLINUX_H */ arch/arm64/include/asm/assembler.h new file +116
-0@@ -0,0 +1,116 @@ +/* +* arch/arm/include/asm/assembler.h +* +* Copyright (C) 1996-2000 Russell King +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This file contains arm architecture specific defines +* for the different processors. +* +* Do not include any C declarations in this file - it is included by +* assembler source. +*/ +#ifndef __ASSEMBLY__ +#error "Only include this from assembly code" +#endif + +#include <asm/ptrace.h> + +/* +* Endian independent macros for shifting bytes within registers. +*/ +#ifndef __ARMEB__ +#define pull lsr +#define push lsl +#define get_byte_0 lsl #0 +#define get_byte_1 lsr #8 +#define get_byte_2 lsr #16 +#define get_byte_3 lsr #24 +#define put_byte_0 lsl #0 +#define put_byte_1 lsl #8 +#define put_byte_2 lsl #16 +#define put_byte_3 lsl #24 +#else +#define pull lsl +#define push lsr +#define get_byte_0 lsr #24 +#define get_byte_1 lsr #16 +#define get_byte_2 lsr #8 +#define get_byte_3 lsl #0 +#define put_byte_0 lsl #24 +#define put_byte_1 lsl #16 +#define put_byte_2 lsl #8 +#define put_byte_3 lsl #0 +#endif + +/* +* Data preload for architectures that support it +*/ +#if __LINUX_ARM_ARCH__ >=5 +#define PLD(code...) code +#else +#define PLD(code...) +#endif + +/* +* This can be used to enable code to cacheline align the destination +* pointer when bulk writing to memory. Experiments on StrongARM and +* XScale didn't show this a worthwhile thing to do when the cache is not +* set to write-allocate (this would need further testing on XScale when WA +* is used). +* +* On Feroceon there is much to gain however, regardless of cache mode. +*/ +#ifdef CONFIG_CPU_FEROCEON +#define CALGN(code...) code +#else +#define CALGN(code...) +#endif + +/* +* Enable and disable interrupts +*/ +#if __LINUX_ARM_ARCH__ >=6 + .macro disable_irq + cpsid i + .endm + + .macro enable_irq + cpsie i + .endm +#else + .macro disable_irq + msr cpsr_c, #PSR_I_BIT | SVC_MODE + .endm + + .macro enable_irq + msr cpsr_c, #SVC_MODE + .endm +#endif + +/* +* Save the current IRQ state and disable IRQs. Note that this macro +* assumes FIQs are enabled, and that the processor is in SVC mode. +*/ + .macro save_and_disable_irqs, oldcpsr + mrs \oldcpsr, cpsr + disable_irq + .endm + +/* + * Restore interrupt state previously stored in a register. We don't + * guarantee that this will preserve the flags. + */ + .macro restore_irqs, oldcpsr + msr cpsr_c, \oldcpsr + .endm + +#define USER(x...) \ +9999: x; \ + .section __ex_table,"a"; \ +.align 3; \ +.long 9999b,9001f; \ + .previousarch/arm64/include/asm/barebox-arm-head.h new file +65
-0@@ -0,0 +1,65 @@ +#ifndef __ASM_ARM_HEAD_H +#define __ASM_ARM_HEAD_H + +#include <asm/system.h> + +#ifndef __ASSEMBLY__ + +void arm_cpu_lowlevel_init (void ); + +/* +* 32 bytes at this offset is reserved in the barebox head for board/SoC +* usage +*/ +#define ARM_HEAD_SPARE_OFS 0x30 +#define ARM_HEAD_SPARE_MARKER 0x55555555 + +#ifdef CONFIG_HAVE_MACH_ARM_HEAD +#include <mach/barebox-arm-head.h> +#else +static inline void __barebox_arm_head (void ) +{ + __asm__ __volatile__ ( +#ifdef CONFIG_THUMB2_BAREBOX + ".arm\n" + "adr r9, 1f + 1\n" + "bx r9\n" + ".thumb\n" + "1:\n" + "bl 2f\n" + ".rept 10\n" + "1: b 1b\n" + ".endr\n" +#else + "b 2f\n" + "1: b 1b\n" + "1: b 1b\n" + "1: b 1b\n" + "1: b 1b\n" + "1: b 1b\n" + "1: b 1b\n" + "1: b 1b\n" +#endif +".asciz \"barebox\"\n" +".word _text\n" /* text base. If copied there, +* barebox can skip relocation +*/ +".word _barebox_image_size\n" /* image size to copy */ +".rept 8\n" +".word 0x55555555\n" +".endr\n" +"2:\n" + ); +} +static inline void barebox_arm_head (void ) +{ +__barebox_arm_head (); + __asm__ __volatile__ ( +"b barebox_arm_reset_vector\n" + ); +} +#endif + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_ARM_HEAD_H */ arch/arm64/include/asm/barebox-arm.h new file +165
-0@@ -0,0 +1,165 @@ +/* +* (C) Copyright 2002 +* Sysgo Real-Time Solutions, GmbH <www.elinos.com> +* Marius Groeger <[email protected]> +* +* (C) Copyright 2002 +* Sysgo Real-Time Solutions, GmbH <www.elinos.com> +* Alex Zuepke <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program 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 program 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. +* +*/ + +#ifndef _BAREBOX_ARM_H_ +#define _BAREBOX_ARM_H_ + +#include <linux/sizes.h> +#include <asm-generic/memory_layout.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/compiler.h> +#include <asm/barebox-arm-head.h> + +/* cpu/.../cpu.c */ +int cleanup_before_linux (void ); + +/* arch/<arch>board(s)/.../... */ +int board_init (void ); +int dram_init (void ); + +extern char __exceptions_start[], __exceptions_stop[]; + +void board_init_lowlevel (void ); +uint32_t get_runtime_offset (void ); + +void setup_c (void ); +void relocate_to_current_adr (void ); +void relocate_to_adr (unsigned long target); +void __noreturn barebox_arm_entry (unsigned long membase,unsigned long memsize,void *boarddata); + +struct barebox_arm_boarddata { +#define BAREBOX_ARM_BOARDDATA_MAGIC 0xabe742c3 +u32 magic; +u32 machine;/* machine number to pass to barebox. This may or may +* not be a ARM machine number registered on arm.linux.org.uk. +* It must only be unique across barebox. Please use a number +* that do not potientially clashes with registered machines, +* i.e. use a number > 0x10000. +*/ +}; + +/* +* Create a boarddata struct at given address. Suitable to be passed +* as boarddata to barebox_arm_entry(). The machine can be retrieved +* later with barebox_arm_machine(). +*/ +static inline void boarddata_create (void *adr,u32 machine) +{ +struct barebox_arm_boarddata *bd = adr; + + bd->magic =BAREBOX_ARM_BOARDDATA_MAGIC ; + bd->machine = machine; +} + +u32 barebox_arm_machine (void ); + +struct barebox_arm_boarddata_compressed_dtb { +#define BAREBOX_ARM_BOARDDATA_COMPRESSED_DTB_MAGIC 0x7b66bcbd +u32 magic; +u32 datalen; +u32 datalen_uncompressed; +}; + +struct barebox_arm_boarddata *barebox_arm_get_boarddata (void ); + +#if defined(CONFIG_RELOCATABLE ) && defined(CONFIG_ARM_EXCEPTIONS ) +void arm_fixup_vectors (void ); +#else +static inline void arm_fixup_vectors (void )Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/barebox.h new file +12
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/bitops.h new file +48
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/bitsperlong.h new file +1
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/byteorder.h new file +32
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/cache-l2x0.h new file +101
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/cache.h new file +16
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/common.h new file +48
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/cputype.h new file +100
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/debug_ll_pl011.h new file +25
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/elf.h new file +119
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/errata.h new file +79
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/gic.h new file +128
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/hardware/arm_timer.h new file +38
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/hardware/sp810.h new file +68
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/linkage.h new file +11
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/memory.h new file +19
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/module.h new file +13
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/pgtable.h new file +90
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/posix_types.h new file +1
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/processor.h new file +131
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/ptrace.h new file +34
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/sections.h new file +34
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/semihosting.h new file +19
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/setup.h new file +216
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/stacktrace.h new file +16
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/string.h new file +13
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/swab.h new file +69
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/system.h new file +125
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/system_info.h new file +194
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/types.h new file +54
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/unaligned.h new file +19
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/unified.h new file +127
-0Lines of this file are not shown. View the raw message.
arch/arm64/include/asm/unwind.h new file +51
-0Lines of this file are not shown. View the raw message.
arch/arm64/lib/barebox.lds.S new file +125
-0Lines of this file are not shown. View the raw message.
arch/arm64/lib/copy_template.S new file +192
-0Lines of this file are not shown. View the raw message.
arch/arm64/lib/runtime-offset.S new file +52
-0Lines of this file are not shown. View the raw message.
arch/arm64/mach-virt/devices.c new file +30
-0Lines of this file are not shown. View the raw message.
arch/arm64/mach-virt/include/mach/debug_ll.h new file +24
-0Lines of this file are not shown. View the raw message.
arch/arm64/mach-virt/include/mach/devices.h new file +13
-0Lines of this file are not shown. View the raw message.
arch/arm64/pbl/piggy.shipped.S new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Part of the diff is not shown here. View the raw message.