Skip to contentSkip to conversation

Add basic support for arm64

PATCH Superseded Raphael Poggi 3 participants 26 messages Jun 2, 2016 – Jun 7, 2016

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Add basic support for arm64

Hello,

This patch series introduces a basic support for arm64.

The arm64 code is merged in the current arch/arm directory. I try to be iterative in the merge process, and find correct solutions to handle both architecture at some places.

I test the patch series by compiling arm64 virt machine and arm32 vexpress-a9 and test it in qemu, everything seems to work.

Thanks,
Raphaël

 arch/arm/Kconfig                           |  32 ++
 arch/arm/Makefile                          |  30 +-
 arch/arm/boards/Makefile                   |   1 +
 arch/arm/boards/virt/Kconfig               |   8 +
 arch/arm/boards/virt/Makefile              |   1 +
 arch/arm/boards/virt/env/bin/_update       |  36 ++
 arch/arm/boards/virt/env/bin/boot          |  38 ++
 arch/arm/boards/virt/env/bin/init          |  20 +
 arch/arm/boards/virt/env/bin/update_kernel |   8 +
 arch/arm/boards/virt/env/bin/update_root   |   8 +
 arch/arm/boards/virt/env/config            |  38 ++
 arch/arm/boards/virt/env/init/mtdparts-nor |  11 +
 arch/arm/boards/virt/init.c                |  67 ++++
 arch/arm/configs/virt_defconfig            |  55 +++
 arch/arm/cpu/Kconfig                       |  29 +-
 arch/arm/cpu/Makefile                      |  22 +-
 arch/arm/cpu/cache-armv8.S                 | 168 +++++++++
 arch/arm/cpu/cache.c                       |  19 +
 arch/arm/cpu/cpu.c                         |   5 +
 arch/arm/cpu/cpuinfo.c                     |  58 ++-
 arch/arm/cpu/exceptions_64.S               | 127 +++++++
 arch/arm/cpu/interrupts.c                  |  47 +++
 arch/arm/cpu/lowlevel.S                    |  38 ++
 arch/arm/cpu/mmu.h                         | 160 ++++++++
 arch/arm/cpu/mmu_64.c                      | 335 +++++++++++++++++
 arch/arm/cpu/start.c                       |   2 +
 arch/arm/include/asm/bitops.h              |   5 +
 arch/arm/include/asm/cache.h               |   9 +
 arch/arm/include/asm/mmu.h                 |   4 +-
 arch/arm/include/asm/pgtable.h             |   8 +
 arch/arm/include/asm/system.h              |  46 ++-
 arch/arm/include/asm/system_info.h         |  38 ++
 arch/arm/lib64/Makefile                    |  16 +
 arch/arm/lib64/armlinux.c                  | 275 ++++++++++++++
 arch/arm/lib64/asm-offsets.c               |  16 +
 arch/arm/lib64/barebox.lds                 | 125 +++++++
 arch/arm/lib64/barebox.lds.S               | 125 +++++++
 arch/arm/lib64/bootm.c                     | 572 +++++++++++++++++++++++++++++
 arch/arm/lib64/bootu.c                     |  44 +++
 arch/arm/lib64/bootz.c                     | 136 +++++++
 arch/arm/lib64/copy_template.S             | 192 ++++++++++
 arch/arm/lib64/div0.c                      |  27 ++
 arch/arm/lib64/memcpy.S                    |  74 ++++
 arch/arm/lib64/memset.S                    | 215 +++++++++++
 arch/arm/lib64/module.c                    |  98 +++++
 arch/arm/lib64/pbl.lds.S                   |  96 +++++
 arch/arm/lib64/runtime-offset.S            |  52 +++
 arch/arm/lib64/unwind.c                    | 349 ++++++++++++++++++
 arch/arm/mach-virt/Kconfig                 |  15 +
 arch/arm/mach-virt/Makefile                |   3 +
 arch/arm/mach-virt/devices.c               |  30 ++
 arch/arm/mach-virt/include/mach/debug_ll.h |  24 ++
 arch/arm/mach-virt/include/mach/devices.h  |  13 +
 arch/arm/mach-virt/lowlevel.c              |  19 +
 arch/arm/mach-virt/reset.c                 |  24 ++
 55 files changed, 3999 insertions(+), 14 deletions(-)

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#2 lore raw

PATCH 2/12 arm: Makefile: rework makefile to handle armv8

---
 arch/arm/Makefile | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
arch/arm/Makefile +28 -2
index 5ccdb83..df4832f 100644
@@ -1,7 +1,11 @@
 
 CPPFLAGS	+= -D__ARM__ -fno-strict-aliasing
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
+ifeq ($(CONFIG_CPU_V8),y)
+CPPFLAGS	+=$(call cc-option,-maarch64,)
+else
 CPPFLAGS	+=$(call cc-option,-marm,)
+endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
 CPPFLAGS	+= -mbig-endian
@@ -17,7 +21,9 @@ endif
 # at least some of the code would be executed with MMU off, lets be
 # conservative and instruct the compiler not to generate any unaligned
 # accesses
+ifeq ($(CONFIG_CPU_V8),n)
 CFLAGS += -mno-unaligned-access
+endif
 
 
 # This selects which instruction set is used.
@@ -33,12 +39,17 @@ arch-$(CONFIG_CPU_32v4T)	:=-D__LINUX_ARM_ARCH__=4 -march=armv4t
 tune-$(CONFIG_CPU_ARM920T)	:=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_ARM926T)	:=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_XSCALE)	:=$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
+arch-$(CONFIG_CPU_64v8)		:= -D__LINUX_ARM_ARCH__=8 $(call cc-option,-march=armv8-a)
 
+ifeq ($(CONFIG_CPU_V8), y)
+CFLAGS_ABI	:=-mabi=lp64
+else
 ifeq ($(CONFIG_AEABI),y)
 CFLAGS_ABI	:=-mabi=aapcs-linux -mno-thumb-interwork
 else
 CFLAGS_ABI	:=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
 endif
+endif
 
 ifeq ($(CONFIG_ARM_UNWIND),y)
 CFLAGS_ABI	+=-funwind-tables
@@ -51,8 +62,13 @@ CFLAGS_THUMB2	:=-mthumb $(AFLAGS_AUTOIT) $(AFLAGS_NOWARN)
 AFLAGS_THUMB2	:=$(CFLAGS_THUMB2) -Wa$(comma)-mthumb
 endif
 
+ifeq ($(CONFIG_CPU_V8), y)
+CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y)
+AFLAGS   += -include asm/unified.h
+else
 CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float $(CFLAGS_THUMB2)
 AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
+endif
 
 # Machine directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.
@@ -78,6 +94,7 @@ machine-$(CONFIG_ARCH_VEXPRESS)		:= vexpress
 machine-$(CONFIG_ARCH_TEGRA)		:= tegra
 machine-$(CONFIG_ARCH_UEMD)		:= uemd
 machine-$(CONFIG_ARCH_ZYNQ)		:= zynq
+machine-$(CONFIG_ARCH_VIRT)		:= virt
 
 
 # Board directory name.  This list is sorted alphanumerically
@@ -275,12 +292,21 @@ MACH :=
 endif
 
 common-y += $(BOARD) arch/arm/boards/ $(MACH)
-common-y += arch/arm/lib/ arch/arm/cpu/
-common-y += arch/arm/crypto/
+common-y += arch/arm/cpu/
+
+ifeq ($(CONFIG_CPU_V8), y)
+common-y += arch/arm/lib64/
+else
+common-y += arch/arm/lib/ arch/arm/crypto/
+endif
 
 common-$(CONFIG_OFTREE) += arch/arm/dts/
 
+ifeq ($(CONFIG_CPU_V8), y)
+lds-y	:= arch/arm/lib64/barebox.lds
+else
 lds-y	:= arch/arm/lib/barebox.lds
+endif
 
 common- += $(patsubst %,arch/arm/boards/%/,$(board-))
 
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/12 arm: add armv8 Kconfig entries

In reply to Raphael Poggi
---
 arch/arm/Kconfig     | 23 +++++++++++++++++++++++
 arch/arm/cpu/Kconfig | 29 ++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 1 deletion(-)
arch/arm/Kconfig +23 -0
index 1fc887b..986fdaa 100644
@@ -315,6 +315,29 @@ config ARM_BOARD_APPEND_ATAG
 
 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
arch/arm/cpu/Kconfig +28 -1
index 4f5d9b6..fd327a8 100644
@@ -2,7 +2,9 @@ comment "Processor Type"
 
 config CPU_32
 	bool
-	default y
+
+config CPU_64
+	bool
 
 # Select CPU types depending on the architecture selected. This selects
 # which CPUs we support in the kernel image, and the compiler instruction
@@ -69,6 +71,12 @@ config CPU_V7
 	bool
 	select CPU_32v7
 
+# ARMv8
+config CPU_V8
+	bool
+	select CPU_64v8
+	select CPU_SUPPORTS_64BIT_KERNEL
+
 config CPU_XSC3
         bool
         select CPU_32v4T
@@ -84,15 +92,23 @@ config CPU_XSCALE
 # This defines the compiler instruction set which depends on the machine type.
 config CPU_32v4T
 	bool
+	select CPU_32
 
 config CPU_32v5
 	bool
+	select CPU_32
 
 config CPU_32v6
 	bool
+	select CPU_32
 
 config CPU_32v7
 	bool
+	select CPU_32
+
+config CPU_64v8
+	bool
+	select CPU_64
 
 comment "processor features"
 
@@ -124,3 +140,14 @@ config CACHE_L2X0
 	bool "Enable L2x0 PrimeCell"
 	depends on MMU && ARCH_HAS_L2X0
 
+config SYS_SUPPORTS_32BIT_KERNEL
+	bool
+
+config SYS_SUPPORTS_64BIT_KERNEL
+	bool
+
+config CPU_SUPPORTS_32BIT_KERNEL
+	bool
+
+config CPU_SUPPORTS_64BIT_KERNEL
+	bool
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 4/12 arm: cpu: add arm64 specific code

In reply to Raphael Poggi

This patch adds arm64 specific codes, which are:
- exception support
- cache support
- rework Makefile to support arm64

---
 arch/arm/cpu/Makefile        |  17 ++++-
 arch/arm/cpu/cache-armv8.S   | 168 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/cache.c         |  19 +++++
 arch/arm/cpu/exceptions_64.S | 127 ++++++++++++++++++++++++++++++++
 arch/arm/cpu/interrupts.c    |  47 ++++++++++++
 arch/arm/cpu/lowlevel.S      |  38 ++++++++++
 arch/arm/include/asm/cache.h |   9 +++
 7 files changed, 423 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/cpu/cache-armv8.S
 create mode 100644 arch/arm/cpu/exceptions_64.S
arch/arm/cpu/Makefile +15 -2
index 854df60..95a2b00 100644
@@ -1,7 +1,17 @@
 obj-y += cpu.o
+
+ifeq ($(CONFIG_CPU_64v8), y)
+obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions_64.o
+else
 obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
+endif
+
 obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
-obj-y += start.o setupc.o entry.o
+obj-y += start.o entry.o
+
+ifeq ($(CONFIG_CPU_64v8), )
+obj-y += setupc.o
+endif
 
 #
 # Any variants can be called as start-armxyz.S
@@ -11,7 +21,6 @@ obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o
 obj-$(CONFIG_OFDEVICE) += dtb.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
@@ -27,6 +36,10 @@ obj-$(CONFIG_CPU_32v7) += cache-armv7.o
 AFLAGS_pbl-cache-armv7.o       :=-Wa,-march=armv7-a
 pbl-$(CONFIG_CPU_32v7) += cache-armv7.o
 obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o
+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
arch/arm/cpu/cache-armv8.S new file +168 -0

168 lines not on this page · raw message

arch/arm/cpu/cache.c +19 -0
index 27ead1c..929c385 100644
@@ -36,6 +36,7 @@ DEFINE_CPU_FNS(v4)
 DEFINE_CPU_FNS(v5)
 DEFINE_CPU_FNS(v6)
 DEFINE_CPU_FNS(v7)
+DEFINE_CPU_FNS(v8)
 
 void __dma_clean_range(unsigned long start, unsigned long end)
 {
@@ -101,6 +102,11 @@ int arm_set_cache_functions(void)
 		cache_fns = &cache_fns_armv7;
 		break;
 #endif
+#ifdef CONFIG_CPU_64v8
+	case CPU_ARCH_ARMv8:
+		cache_fns = &cache_fns_armv8;
+		break;
+#endif
 	default:
 		while(1);
 	}
@@ -138,6 +144,11 @@ void arm_early_mmu_cache_flush(void)
 		v7_mmu_cache_flush();
 		return;
 #endif
+#ifdef CONFIG_CPU_64v8
+	case CPU_ARCH_ARMv8:
+		v8_dcache_all();
+		return;
+#endif
 	}
 }
 
@@ -146,6 +157,7 @@ void v7_mmu_cache_invalidate(void);
 void arm_early_mmu_cache_invalidate(void)
 {
 	switch (arm_early_get_cpu_architecture()) {
+#if __LINUX_ARM_ARCH__ <= 7
 	case CPU_ARCH_ARMv4T:
 	case CPU_ARCH_ARMv5:
 	case CPU_ARCH_ARMv5T:
@@ -159,5 +171,12 @@ void arm_early_mmu_cache_invalidate(void)
 		v7_mmu_cache_invalidate();
 		return;
 #endif
+#else
+#ifdef CONFIG_CPU_64v8
+	case CPU_ARCH_ARMv8:
+		v8_invalidate_icache_all();
+		return;
+#endif
+#endif
 	}
 }
arch/arm/cpu/exceptions_64.S new file +127 -0

127 lines not on this page · raw message

arch/arm/cpu/interrupts.c +47 -0

81 lines not on this page · raw message

arch/arm/cpu/lowlevel.S +38 -0
index b76222d..67df43f 100644
@@ -3,6 +3,7 @@
 #include <asm/system.h>
 
 .section ".text_bare_init_","ax"
+#if __LINUX_ARM_ARCH__ <= 7
 ENTRY(arm_cpu_lowlevel_init)
 	/* set the cpu to SVC32 mode, mask irq and fiq */
 	mrs	r12, cpsr
@@ -56,3 +57,40 @@ ENTRY(arm_cpu_lowlevel_init)
 
 	mov	pc, lr
 ENDPROC(arm_cpu_lowlevel_init)
+#else
+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:
+	ret
+
+ENDPROC(arm_cpu_lowlevel_init)
+#endif
arch/arm/include/asm/cache.h +9 -0
index 2f6eab0..8fcdb64 100644
@@ -1,9 +1,18 @@
 #ifndef __ASM_CACHE_H
 #define __ASM_CACHE_H
 
+#ifdef CONFIG_CPU_64v8
+extern void v8_invalidate_icache_all(void);
+extern void v8_dcache_all(void);
+#endif
+
 static inline void flush_icache(void)
 {
+#if __LINUX_ARM_ARCH__ <= 7
 	asm volatile("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
+#else
+	v8_invalidate_icache_all();
+#endif
 }
 
 int arm_set_cache_functions(void);
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#11 lore raw

PATCH 7/12 arm: include: bitops: arm64 use generic __fls

In reply to Raphael Poggi
---
 arch/arm/include/asm/bitops.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/include/asm/bitops.h +5 -0
index 138ebe2..b51225e 100644
@@ -177,6 +177,11 @@ static inline unsigned long ffz(unsigned long word)
 #include <asm-generic/bitops/ffs.h>
 #include <asm-generic/bitops/fls.h>
 #endif		/* __ARM__USE_GENERIC_FF */
+
+#if __LINUX_ARM_ARCH__ == 8
+#include <asm-generic/bitops/__fls.h>
+#endif
+
 #include <asm-generic/bitops/fls64.h>
 
 #include <asm-generic/bitops/hweight.h>
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

PATCH 5/12 arm: include: system: add arm64 helper functions

In reply to Raphael Poggi
---
 arch/arm/include/asm/system.h | 46 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
arch/arm/include/asm/system.h +45 -1
index b118a42..57c7618 100644
@@ -3,7 +3,11 @@
 
 #if __LINUX_ARM_ARCH__ >= 7
 #define isb() __asm__ __volatile__ ("isb" : : : "memory")
+#ifdef CONFIG_CPU_64v8
+#define dsb() __asm__ __volatile__ ("dsb sy" : : : "memory")
+#else
 #define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
+#endif
 #define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
 #elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6
 #define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
@@ -57,17 +61,58 @@
 #define CR_TE   (1 << 30)	/* Thumb exception enable		*/
 
 #ifndef __ASSEMBLY__
+#if __LINUX_ARM_ARCH__ >= 7
+static inline unsigned int current_el(void)
+{
+	unsigned int el;
+	asm volatile("mrs %0, CurrentEL" : "=r" (el) : : "cc");
+	return el >> 2;
+}
+
+static inline unsigned long read_mpidr(void)
+{
+	unsigned long val;
+
+	asm volatile("mrs %0, mpidr_el1" : "=r" (val));
+
+	return val;
+}
+#endif
 static inline unsigned int get_cr(void)
 {
 	unsigned int val;
+
+#ifdef CONFIG_CPU_64v8
+	unsigned int el = current_el();
+	if (el == 1)
+		asm volatile("mrs %0, sctlr_el1" : "=r" (val) : : "cc");
+	else if (el == 2)
+		asm volatile("mrs %0, sctlr_el2" : "=r" (val) : : "cc");
+	else
+		asm volatile("mrs %0, sctlr_el3" : "=r" (val) : : "cc");
+#else
 	asm volatile ("mrc p15, 0, %0, c1, c0, 0  @ get CR" : "=r" (val) : : "cc");
+#endif
+
 	return val;
 }
 
 static inline void set_cr(unsigned int val)
 {
+#ifdef CONFIG_CPU_64v8
+	unsigned int el;
+
+	el = current_el();
+	if (el == 1)
+		asm volatile("msr sctlr_el1, %0" : : "r" (val) : "cc");
+	else if (el == 2)
+		asm volatile("msr sctlr_el2, %0" : : "r" (val) : "cc");
+	else
+		asm volatile("msr sctlr_el3, %0" : : "r" (val) : "cc");
+#else
 	asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR"
 	  : : "r" (val) : "cc");
+#endif
 	isb();
 }
 
@@ -90,7 +135,6 @@ static inline void set_vbar(unsigned int vbar)
 static inline unsigned int get_vbar(void) { return 0; }
 static inline void set_vbar(unsigned int vbar) {}
 #endif
-
 #endif
 
 #endif /* __ASM_ARM_SYSTEM_H */
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

PATCH 6/12 arm: cpu: start: arm64 does not support relocation

In reply to Raphael Poggi

For now, the relocation is not supported in arm64, so enclosed call to "setup_c" with #if directive

---
 arch/arm/cpu/start.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/cpu/start.c +2 -0
index d03d1ed..25ba5fc 100644
@@ -151,7 +151,9 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
 		relocate_to_adr(barebox_base);
 	}
 
+#if __LINUX_ARM_ARCH__ <= 7
 	setup_c();
+#endif
 
 	barrier();
 
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw

PATCH 8/12 arm: include: system_info: add armv8 identification

In reply to Raphael Poggi
---
 arch/arm/include/asm/system_info.h | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
arch/arm/include/asm/system_info.h +38 -0
index 0761848..25fffd2 100644
@@ -13,6 +13,7 @@
 #define CPU_ARCH_ARMv5TEJ	7
 #define CPU_ARCH_ARMv6		8
 #define CPU_ARCH_ARMv7		9
+#define CPU_ARCH_ARMv8		10
 
 #define CPU_IS_ARM720		0x41007200
 #define CPU_IS_ARM720_MASK	0xff00fff0
@@ -41,6 +42,12 @@
 #define CPU_IS_CORTEX_A15	0x410fc0f0
 #define CPU_IS_CORTEX_A15_MASK	0xff0ffff0
 
+#define CPU_IS_CORTEX_A53	0x410fd034
+#define CPU_IS_CORTEX_A53_MASK	0xff0ffff0
+
+#define CPU_IS_CORTEX_A57	0x411fd070
+#define CPU_IS_CORTEX_A57_MASK	0xff0ffff0
+
 #define CPU_IS_PXA250		0x69052100
 #define CPU_IS_PXA250_MASK	0xfffff7f0
 
@@ -112,6 +119,19 @@
 #define cpu_is_cortex_a15() (0)
 #endif
 
+#ifdef CONFIG_CPU_64v8
+#ifdef ARM_ARCH
+#define ARM_MULTIARCH
+#else
+#define ARM_ARCH CPU_ARCH_ARMv8
+#endif
+#define cpu_is_cortex_a53() cpu_is_arm(CORTEX_A53)
+#define cpu_is_cortex_a57() cpu_is_arm(CORTEX_A57)
+#else
+#define cpu_is_cortex_a53() (0)
+#define cpu_is_cortex_a57() (0)
+#endif
+
 #ifndef __ASSEMBLY__
 
 #ifdef ARM_MULTIARCH
@@ -133,6 +153,23 @@ static inline int arm_early_get_cpu_architecture(void)
 		if (cpu_arch)
 			cpu_arch += CPU_ARCH_ARMv3;
 	} else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) {
+#ifdef CONFIG_CPU_64v8
+		unsigned int isar2;
+
+		__asm__ __volatile__(
+			"mrs	%0, id_isar2_el1\n"
+			: "=r" (isar2)
+			:
+			: "memory");
+
+
+		/* Check Load/Store acquire to check if ARMv8 or not */
+
+		if (isar2 & 0x2)
+			cpu_arch = CPU_ARCH_ARMv8;
+		else
+			cpu_arch = CPU_ARCH_UNKNOWN;
+#else
 		unsigned int mmfr0;
 
 		/* Revised CPUID format. Read the Memory Model Feature
@@ -149,6 +186,7 @@ static inline int arm_early_get_cpu_architecture(void)
 			cpu_arch = CPU_ARCH_UNKNOWN;
 	} else
 		cpu_arch = CPU_ARCH_UNKNOWN;
+#endif
 
 	return cpu_arch;
 }
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#14 lore raw

PATCH 10/12 arm: cpu: disable code portion in armv8 case

In reply to Raphael Poggi

Enclosed by #if directive OMAP specific code
and mmu_disable (ARMv8 code will implemented it somewhere else).

---
 arch/arm/cpu/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/cpu/cpu.c +5 -0
index eb12166..cc54324 100644
@@ -68,6 +68,7 @@ int icache_status(void)
 	return (get_cr () & CR_I) != 0;
 }
 
+#if __LINUX_ARM_ARCH__ <= 7
 /*
  * SoC like the ux500 have the l2x0 always enable
  * with or without MMU enable
@@ -86,6 +87,7 @@ void mmu_disable(void)
 	}
 	__mmu_cache_off();
 }
+#endif
 
 /**
  * Disable MMU and D-cache, flush caches
@@ -100,6 +102,8 @@ static void arch_shutdown(void)
 
 	mmu_disable();
 	flush_icache();
+
+#if __LINUX_ARM_ARCH__ <= 7
 	/*
 	 * barebox normally does not use interrupts, but some functionalities
 	 * (eg. OMAP4_USBBOOT) require them enabled. So be sure interrupts are
@@ -108,6 +112,7 @@ static void arch_shutdown(void)
 	__asm__ __volatile__("mrs %0, cpsr" : "=r"(r));
 	r |= PSR_I_BIT;
 	__asm__ __volatile__("msr cpsr, %0" : : "r"(r));
+#endif
 }
 archshutdown_exitcall(arch_shutdown);
 
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#13 lore raw

PATCH 9/12 arm: cpu: cpuinfo: add armv8 support

In reply to Raphael Poggi
---
 arch/arm/cpu/cpuinfo.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 4 deletions(-)
arch/arm/cpu/cpuinfo.c +54 -4
index 8b22e9b..86e19d9 100644
@@ -30,12 +30,15 @@
 #define CPU_ARCH_ARMv5TEJ	7
 #define CPU_ARCH_ARMv6		8
 #define CPU_ARCH_ARMv7		9
+#define CPU_ARCH_ARMv8		10
 
 #define ARM_CPU_PART_CORTEX_A5      0xC050
 #define ARM_CPU_PART_CORTEX_A7      0xC070
 #define ARM_CPU_PART_CORTEX_A8      0xC080
 #define ARM_CPU_PART_CORTEX_A9      0xC090
 #define ARM_CPU_PART_CORTEX_A15     0xC0F0
+#define ARM_CPU_PART_CORTEX_A53	    0xD030
+#define ARM_CPU_PART_CORTEX_A57	    0xD070
 
 static void decode_cache(unsigned long size)
 {
@@ -60,6 +63,25 @@ static int do_cpuinfo(int argc, char *argv[])
 	int i;
 	int cpu_arch;
 
+#ifdef CONFIG_CPU_64v8
+	__asm__ __volatile__(
+		"mrs	%0, midr_el1\n"
+		: "=r" (mainid)
+		:
+		: "memory");
+
+	__asm__ __volatile__(
+		"mrs	%0, ctr_el0\n"
+		: "=r" (cache)
+		:
+		: "memory");
+
+	__asm__ __volatile__(
+		"mrs	%0, sctlr_el1\n"
+		: "=r" (cr)
+		:
+		: "memory");
+#else
 	__asm__ __volatile__(
 		"mrc    p15, 0, %0, c0, c0, 0   @ read control reg\n"
 		: "=r" (mainid)
@@ -74,9 +96,10 @@ static int do_cpuinfo(int argc, char *argv[])
 
 	__asm__ __volatile__(
 		"mrc    p15, 0, %0, c1, c0, 0   @ read control reg\n"
-			: "=r" (cr)
-			:
-			: "memory");
+		: "=r" (cr)
+		:
+		: "memory");
+#endif
 
 	switch (mainid >> 24) {
 	case 0x41:
@@ -107,6 +130,23 @@ static int do_cpuinfo(int argc, char *argv[])
 		if (cpu_arch)
 			cpu_arch += CPU_ARCH_ARMv3;
 	} else if ((mainid & 0x000f0000) == 0x000f0000) {
+#ifdef CONFIG_CPU_64v8
+		unsigned int isar2;
+
+		__asm__ __volatile__(
+			"mrs	%0, id_isar2_el1\n"
+			: "=r" (isar2)
+			:
+			: "memory");
+
+
+		/* Check Load/Store acquire to check if ARMv8 or not */
+
+		if (isar2 & 0x2)
+			cpu_arch = CPU_ARCH_ARMv8;
+		else
+			cpu_arch = CPU_ARCH_UNKNOWN;
+#else
 		unsigned int mmfr0;
 
 		/* Revised CPUID format. Read the Memory Model Feature
@@ -121,6 +161,7 @@ static int do_cpuinfo(int argc, char *argv[])
 			cpu_arch = CPU_ARCH_ARMv6;
 		else
 			cpu_arch = CPU_ARCH_UNKNOWN;
+#endif
 	} else
 		cpu_arch = CPU_ARCH_UNKNOWN;
 
@@ -152,6 +193,9 @@ static int do_cpuinfo(int argc, char *argv[])
 	case CPU_ARCH_ARMv7:
 		architecture = "v7";
 		break;
+	case CPU_ARCH_ARMv8:
+		architecture = "v8";
+		break;
 	case CPU_ARCH_UNKNOWN:
 	default:
 		architecture = "Unknown";
@@ -160,7 +204,7 @@ static int do_cpuinfo(int argc, char *argv[])
 	printf("implementer: %s\narchitecture: %s\n",
 			implementer, architecture);
 
-	if (cpu_arch == CPU_ARCH_ARMv7) {
+	if (cpu_arch >= CPU_ARCH_ARMv7) {
 		unsigned int major, minor;
 		char *part;
 		major = (mainid >> 20) & 0xf;
@@ -181,6 +225,12 @@ static int do_cpuinfo(int argc, char *argv[])
 		case ARM_CPU_PART_CORTEX_A15:
 			part = "Cortex-A15";
 			break;
+		case ARM_CPU_PART_CORTEX_A53:
+			part = "Cortex-A53";
+			break;
+		case ARM_CPU_PART_CORTEX_A57:
+			part = "Cortex-A57";
+			break;
 		default:
 			part = "unknown";
 		}
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#17 lore raw

PATCH 12/12 arm: boards: add virt board

In reply to Raphael Poggi

Add qemu virt board which emulates arm64 board.

---
 arch/arm/Kconfig                           |  9 ++++
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/virt/Kconfig               |  8 ++++
 arch/arm/boards/virt/Makefile              |  1 +
 arch/arm/boards/virt/env/bin/_update       | 36 ++++++++++++++++
 arch/arm/boards/virt/env/bin/boot          | 38 +++++++++++++++++
 arch/arm/boards/virt/env/bin/init          | 20 +++++++++
 arch/arm/boards/virt/env/bin/update_kernel |  8 ++++
 arch/arm/boards/virt/env/bin/update_root   |  8 ++++
 arch/arm/boards/virt/env/config            | 38 +++++++++++++++++
 arch/arm/boards/virt/env/init/mtdparts-nor | 11 +++++
 arch/arm/boards/virt/init.c                | 67 ++++++++++++++++++++++++++++++
 arch/arm/configs/virt_defconfig            | 55 ++++++++++++++++++++++++
 arch/arm/mach-virt/Kconfig                 | 15 +++++++
 arch/arm/mach-virt/Makefile                |  3 ++
 arch/arm/mach-virt/devices.c               | 30 +++++++++++++
 arch/arm/mach-virt/include/mach/debug_ll.h | 24 +++++++++++
 arch/arm/mach-virt/include/mach/devices.h  | 13 ++++++
 arch/arm/mach-virt/lowlevel.c              | 19 +++++++++
 arch/arm/mach-virt/reset.c                 | 24 +++++++++++
 20 files changed, 428 insertions(+)
 create mode 100644 arch/arm/boards/virt/Kconfig
 create mode 100644 arch/arm/boards/virt/Makefile
 create mode 100644 arch/arm/boards/virt/env/bin/_update
 create mode 100644 arch/arm/boards/virt/env/bin/boot
 create mode 100644 arch/arm/boards/virt/env/bin/init
 create mode 100644 arch/arm/boards/virt/env/bin/update_kernel
 create mode 100644 arch/arm/boards/virt/env/bin/update_root
 create mode 100644 arch/arm/boards/virt/env/config
 create mode 100644 arch/arm/boards/virt/env/init/mtdparts-nor
 create mode 100644 arch/arm/boards/virt/init.c
 create mode 100644 arch/arm/configs/virt_defconfig
 create mode 100644 arch/arm/mach-virt/Kconfig
 create mode 100644 arch/arm/mach-virt/Makefile
 create mode 100644 arch/arm/mach-virt/devices.c
 create mode 100644 arch/arm/mach-virt/include/mach/debug_ll.h
 create mode 100644 arch/arm/mach-virt/include/mach/devices.h
 create mode 100644 arch/arm/mach-virt/lowlevel.c
 create mode 100644 arch/arm/mach-virt/reset.c
arch/arm/Kconfig +9 -0
index 986fdaa..71b90e7 100644
@@ -255,6 +255,14 @@ config ARCH_ZYNQ
 	bool "Xilinx Zynq-based boards"
 	select HAS_DEBUG_LL
 
+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/arm/cpu/Kconfig
@@ -280,6 +288,7 @@ source arch/arm/mach-vexpress/Kconfig
 source arch/arm/mach-tegra/Kconfig
 source arch/arm/mach-uemd/Kconfig
 source arch/arm/mach-zynq/Kconfig
+source arch/arm/mach-virt/Kconfig
 
 config ARM_ASM_UNIFIED
 	bool
arch/arm/boards/Makefile +1 -0
index 5a755c9..da0af74 100644
@@ -134,3 +134,4 @@ obj-$(CONFIG_MACH_VIRT2REAL)			+= virt2real/
 obj-$(CONFIG_MACH_ZEDBOARD)			+= avnet-zedboard/
 obj-$(CONFIG_MACH_ZYLONITE)			+= zylonite/
 obj-$(CONFIG_MACH_VARISCITE_MX6)		+= variscite-mx6/
+obj-$(CONFIG_MACH_VIRT)			+= virt/
arch/arm/boards/virt/Kconfig new file +8 -0
new file mode 100644
index 0000000..b239127
@@ -0,0 +1,8 @@
+
+if MACH_VIRT
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x40000000
+
+endif
arch/arm/boards/virt/Makefile new file +1 -0
new file mode 100644
index 0000000..eb072c0
@@ -0,0 +1 @@
+obj-y += init.o
arch/arm/boards/virt/env/bin/_update new file +36 -0
new file mode 100644
index 0000000..014bce3
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+if [ -z "$part" -o -z "$image" ]; then
+	echo "define \$part and \$image"
+	exit 1
+fi
+
+if [ ! -e "$part" ]; then
+	echo "Partition $part does not exist"
+	exit 1
+fi
+
+if [ $# = 1 ]; then
+	image=$1
+fi
+
+if [ x$ip = xdhcp ]; then
+	dhcp
+fi
+
+ping $eth0.serverip
+if [ $? -ne 0 ] ; then
+	echo "update aborted"
+	exit 1
+fi
+
+unprotect $part
+
+echo
+echo "erasing partition $part"
+erase $part
+
+echo
+echo "flashing $image to $part"
+echo
+tftp $image $part
arch/arm/boards/virt/env/bin/boot new file +38 -0
new file mode 100644
index 0000000..3859dc1
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+. /env/config
+
+if [ x$1 = xflash ]; then
+	root=flash
+	kernel=flash
+fi
+
+if [ x$1 = xnet ]; then
+	root=net
+	kernel=net
+fi
+
+if [ x$ip = xdhcp ]; then
+	bootargs="$bootargs ip=dhcp"
+else
+	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
+fi
+
+if [ x$root = xflash ]; then
+	bootargs="$bootargs root=$rootpart rootfstype=jffs2"
+else
+	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
+fi
+
+bootargs="$bootargs mtdparts=physmap-flash.0:$mtdparts"
+
+if [ $kernel = net ]; then
+	if [ x$ip = xdhcp ]; then
+		dhcp
+	fi
+	tftp $uimage uImage || exit 1
+	bootm uImage
+else
+	bootm /dev/nor0.kernel
+fi
+
arch/arm/boards/virt/env/bin/init new file +20 -0
new file mode 100644
index 0000000..48e2139
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+addpart /dev/nor0 $mtdparts
+
+echo
+echo -n "Hit any key to stop autoboot: "
+timeout -a $autoboot_timeout
+if [ $? != 0 ]; then
+	echo
+	echo "type update_kernel [<imagename>] to update kernel into flash"
+	echo "type udate_root [<imagename>] to update rootfs into flash"
+	echo
+	exit
+fi
+
+boot
\ No newline at end of file
arch/arm/boards/virt/env/bin/update_kernel new file +8 -0
new file mode 100644
index 0000000..1ad95fc
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. /env/config
+
+image=$uimage
+part=/dev/nor0.kernel
+
+. /env/bin/_update $1
arch/arm/boards/virt/env/bin/update_root new file +8 -0
new file mode 100644
index 0000000..b757a5b
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. /env/config
+
+image=$jffs2
+part=/dev/nor0.root
+
+. /env/bin/_update $1
arch/arm/boards/virt/env/config new file +38 -0
new file mode 100644
index 0000000..6c0abda
@@ -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/arm/boards/virt/env/init/mtdparts-nor new file +11 -0
new file mode 100644
index 0000000..3307596
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+        init-menu-add-entry "$0" "NOR partitions"
+        exit
+fi
+
+mtdparts="2048k@0(nor0.barebox)ro,256k(nor0.barebox-env),256k(nor0.barebox-logo),256k(nor0.barebox-logo2),5120k(nor0.kernel),-(nor0.root)"
+kernelname="application-flash"
+
+mtdparts-add -d nor0 -k ${kernelname} -p ${mtdparts}
arch/arm/boards/virt/init.c new file +67 -0

67 lines not on this page · raw message

arch/arm/configs/virt_defconfig new file +55 -0

55 lines not on this page · raw message

arch/arm/mach-virt/Kconfig new file +15 -0
new file mode 100644
index 0000000..1f43606
@@ -0,0 +1,15 @@
+if ARCH_VIRT
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x40000000
+
+choice
+	prompt "ARM Board type"
+
+config MACH_VIRT
+	bool "ARM QEMU virt"
+
+endchoice
+
+endif
arch/arm/mach-virt/Makefile new file +3 -0
new file mode 100644
index 0000000..3924a10
@@ -0,0 +1,3 @@
+obj-y += devices.o reset.o
+
+lwl-y += lowlevel.o
arch/arm/mach-virt/devices.c new file +30 -0
new file mode 100644
index 0000000..999f463
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016 Raphaël Poggi <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#include <common.h>
+#include <linux/amba/bus.h>
+#include <asm/memory.h>
+#include <mach/devices.h>
+#include <linux/ioport.h>
+
+void virt_add_ddram(u32 size)
+{
+	arm_add_mem_device("ram0", 0x40000000, size);
+}
+
+void virt_register_uart(unsigned id)
+{
+	resource_size_t start;
+
+	switch (id) {
+	case 0:
+		start = 0x09000000;
+		break;
+	default:
+		return;
+	}
+	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
+}
arch/arm/mach-virt/include/mach/debug_ll.h new file +24 -0
new file mode 100644
index 0000000..89b0692
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2013 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#ifndef __MACH_DEBUG_LL_H__
+#define   __MACH_DEBUG_LL_H__
+
+#include <linux/amba/serial.h>
+#include <io.h>
+
+#define DEBUG_LL_PHYS_BASE		0x10000000
+#define DEBUG_LL_PHYS_BASE_RS1		0x1c000000
+
+#ifdef MP
+#define DEBUG_LL_UART_ADDR DEBUG_LL_PHYS_BASE
+#else
+#define DEBUG_LL_UART_ADDR DEBUG_LL_PHYS_BASE_RS1
+#endif
+
+#include <asm/debug_ll_pl011.h>
+
+#endif
arch/arm/mach-virt/include/mach/devices.h new file +13 -0
new file mode 100644
index 0000000..9872c61
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2016 Raphaël Poggi <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#ifndef __ASM_ARCH_DEVICES_H__
+#define __ASM_ARCH_DEVICES_H__
+
+void virt_add_ddram(u32 size);
+void virt_register_uart(unsigned id);
+
+#endif /* __ASM_ARCH_DEVICES_H__ */
arch/arm/mach-virt/lowlevel.c new file +19 -0
new file mode 100644
index 0000000..6f695a5
@@ -0,0 +1,19 @@
+/*
+ * 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();
+	arm_setup_stack(STACK_BASE);
+
+	barebox_arm_entry(0x40000000, SZ_512M, NULL);
+}
arch/arm/mach-virt/reset.c new file +24 -0
new file mode 100644
index 0000000..fb895eb
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 Raphaël Poggi <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#include <common.h>
+#include <io.h>
+#include <init.h>
+#include <restart.h>
+#include <mach/devices.h>
+
+static void virt_reset_soc(struct restart_handler *rst)
+{
+	hang();
+}
+
+static int restart_register_feature(void)
+{
+	restart_handler_register_fn(virt_reset_soc);
+
+	return 0;
+}
+coredevice_initcall(restart_register_feature);
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#15 lore raw

PATCH 11/12 arm: cpu: add basic arm64 mmu support

In reply to Raphael Poggi

This commit adds basic mmu support, ie:
- DMA cache handling is not supported
- Remapping memory region also

The current mmu setting is:
- 4KB granularity
- 3 level lookup (skipping L0)
- 33 bits per VA

This is based on coreboot and u-boot mmu configuration.

---
 arch/arm/cpu/Makefile          |   7 +-
 arch/arm/cpu/mmu.h             | 160 ++++++++++++++++++++
 arch/arm/cpu/mmu_64.c          | 335 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/mmu.h     |   4 +-
 arch/arm/include/asm/pgtable.h |   8 +
 5 files changed, 509 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/cpu/mmu_64.c
arch/arm/cpu/Makefile +5 -2
index 95a2b00..e2def01 100644
@@ -2,8 +2,11 @@ obj-y += cpu.o
 
 ifeq ($(CONFIG_CPU_64v8), y)
 obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions_64.o
+obj-$(CONFIG_MMU) += mmu_64.o
 else
 obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
+obj-$(CONFIG_MMU) += mmu.o mmu-early.o
+pbl-$(CONFIG_MMU) += mmu-early.o
 endif
 
 obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
@@ -19,8 +22,8 @@ endif
 obj-$(CONFIG_CMD_ARM_CPUINFO) += cpuinfo.o
 obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o
 obj-$(CONFIG_OFDEVICE) += dtb.o
-obj-$(CONFIG_MMU) += mmu.o cache.o mmu-early.o
-pbl-$(CONFIG_MMU) += mmu-early.o
+obj-$(CONFIG_MMU) += cache.o
+
 ifeq ($(CONFIG_MMU),)
 obj-y += no-mmu.o
 endif
arch/arm/cpu/mmu.h +160 -0

166 lines not on this page · raw message

arch/arm/cpu/mmu_64.c new file +335 -0

335 lines not on this page · raw message

arch/arm/include/asm/mmu.h +1 -3
index 8de6544..80aa96b 100644
@@ -13,9 +13,7 @@
 
 struct arm_memory;
 
-static inline void mmu_enable(void)
-{
-}
+void mmu_enable(void);
 void mmu_disable(void);
 static inline void arm_create_section(unsigned long virt, unsigned long phys, int size_m,
 		unsigned int flags)
arch/arm/include/asm/pgtable.h +8 -0
index fd1521d..7ae33de 100644
@@ -18,8 +18,16 @@
  */
 #define PMD_TYPE_MASK		(3 << 0)
 #define PMD_TYPE_FAULT		(0 << 0)
+
+#ifdef CONFIG_CPU_64v8
+#define PMD_TYPE_TABLE		(3 << 0)
+#define PMD_TYPE_PAGE		(3 << 0)
+#define PMD_TYPE_SECT		(1 << 0)
+#else
 #define PMD_TYPE_TABLE		(1 << 0)
 #define PMD_TYPE_SECT		(2 << 0)
+#endif
+
 #define PMD_BIT4		(1 << 4)
 #define PMD_DOMAIN(x)		((x) << 5)
 #define PMD_PROTECTION		(1 << 9)	/* v5 */
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 3/12 arm: introduce lib64 for arm64 related stuff

In reply to Raphael Poggi
---
 arch/arm/lib64/Makefile         |  16 ++
 arch/arm/lib64/armlinux.c       | 275 +++++++++++++++++++
 arch/arm/lib64/asm-offsets.c    |  16 ++
 arch/arm/lib64/barebox.lds      | 125 +++++++++
 arch/arm/lib64/barebox.lds.S    | 125 +++++++++
 arch/arm/lib64/bootm.c          | 572 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/lib64/bootu.c          |  44 ++++
 arch/arm/lib64/bootz.c          | 136 ++++++++++
 arch/arm/lib64/copy_template.S  | 192 ++++++++++++++
 arch/arm/lib64/div0.c           |  27 ++
 arch/arm/lib64/memcpy.S         |  74 ++++++
 arch/arm/lib64/memset.S         | 215 +++++++++++++++
 arch/arm/lib64/module.c         |  98 +++++++
 arch/arm/lib64/pbl.lds.S        |  96 +++++++
 arch/arm/lib64/runtime-offset.S |  52 ++++
 arch/arm/lib64/unwind.c         | 349 ++++++++++++++++++++++++
 16 files changed, 2412 insertions(+)
 create mode 100644 arch/arm/lib64/Makefile
 create mode 100644 arch/arm/lib64/armlinux.c
 create mode 100644 arch/arm/lib64/asm-offsets.c
 create mode 100644 arch/arm/lib64/barebox.lds
 create mode 100644 arch/arm/lib64/barebox.lds.S
 create mode 100644 arch/arm/lib64/bootm.c
 create mode 100644 arch/arm/lib64/bootu.c
 create mode 100644 arch/arm/lib64/bootz.c
 create mode 100644 arch/arm/lib64/copy_template.S
 create mode 100644 arch/arm/lib64/div0.c
 create mode 100644 arch/arm/lib64/memcpy.S
 create mode 100644 arch/arm/lib64/memset.S
 create mode 100644 arch/arm/lib64/module.c
 create mode 100644 arch/arm/lib64/pbl.lds.S
 create mode 100644 arch/arm/lib64/runtime-offset.S
 create mode 100644 arch/arm/lib64/unwind.c
arch/arm/lib64/Makefile new file +16 -0
new file mode 100644
index 0000000..5b9d4a5
@@ -0,0 +1,16 @@
+obj-$(CONFIG_ARM_LINUX)	+= armlinux.o
+obj-$(CONFIG_BOOTM)	+= bootm.o
+obj-$(CONFIG_CMD_BOOTZ)	+= bootz.o
+obj-$(CONFIG_CMD_BOOTU)	+= bootu.o
+obj-y	+= div0.o
+obj-y	+= runtime-offset.o
+pbl-y	+= runtime-offset.o
+obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memcpy.o
+obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memset.o
+obj-$(CONFIG_ARM_UNWIND) += unwind.o
+obj-$(CONFIG_MODULES) += module.o
+extra-y += barebox.lds
+
+pbl-y	+= lib1funcs.o
+pbl-y	+= ashldi3.o
+pbl-y	+= div0.o
arch/arm/lib64/armlinux.c new file +275 -0

275 lines not on this page · raw message

arch/arm/lib64/asm-offsets.c new file +16 -0
new file mode 100644
index 0000000..7bf6d12
@@ -0,0 +1,16 @@
+/*
+ * Generate definitions needed by assembly language modules.
+ * This code generates raw asm output which is post-processed to extract
+ * and format the required data.
+ *
+ * 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.
+ */
+
+#include <linux/kbuild.h>
+
+int main(void)
+{
+	return 0;
+}
arch/arm/lib64/barebox.lds new file +125 -0

125 lines not on this page · raw message

arch/arm/lib64/barebox.lds.S new file +125 -0

125 lines not on this page · raw message

arch/arm/lib64/bootm.c new file +572 -0

572 lines not on this page · raw message

arch/arm/lib64/bootu.c new file +44 -0

44 lines not on this page · raw message

arch/arm/lib64/bootz.c new file +136 -0

136 lines not on this page · raw message

arch/arm/lib64/copy_template.S new file +192 -0

192 lines not on this page · raw message

arch/arm/lib64/div0.c new file +27 -0
new file mode 100644
index 0000000..852cb72
@@ -0,0 +1,27 @@
+/*
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, [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.
+ *
+ */
+#include <common.h>
+
+extern void __div0(void);
+
+/* Replacement (=dummy) for GNU/Linux division-by zero handler */
+void __div0 (void)
+{
+	panic("division by zero\n");
+}
arch/arm/lib64/memcpy.S new file +74 -0

74 lines not on this page · raw message

arch/arm/lib64/memset.S new file +215 -0

215 lines not on this page · raw message

arch/arm/lib64/module.c new file +98 -0

98 lines not on this page · raw message

arch/arm/lib64/pbl.lds.S new file +96 -0

96 lines not on this page · raw message

arch/arm/lib64/runtime-offset.S new file +52 -0

52 lines not on this page · raw message

arch/arm/lib64/unwind.c new file +349 -0

349 lines not on this page · raw message

Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [PATCH 02/12] arm: Makefile: rework makefile to handle armv8

In reply to Raphael Poggi
Quoted 32 lines · Raphael Poggi
---
 arch/arm/Makefile | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
arch/arm/Makefile +6 -0
index 5ccdb83..df4832f 100644
@@ -1,7 +1,11 @@
 
 CPPFLAGS	+= -D__ARM__ -fno-strict-aliasing
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
+ifeq ($(CONFIG_CPU_V8),y)
+CPPFLAGS	+=$(call cc-option,-maarch64,)
+else
 CPPFLAGS	+=$(call cc-option,-marm,)
+endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
 CPPFLAGS	+= -mbig-endian
@@ -17,7 +21,9 @@ endif
 # at least some of the code would be executed with MMU off, lets be
 # conservative and instruct the compiler not to generate any unaligned
 # accesses
+ifeq ($(CONFIG_CPU_V8),n)
 CFLAGS += -mno-unaligned-access
+endif
 
 
 # This selects which instruction set is used.

arch/arm/Makefile arch-$(CONFIG_CPU_32v4T) :=-D__LINUX_ARM_ARCH__=4 -march=armv4t · line 42

Quoted 4 lines
arch/arm/Makefile +1 -0
@@ -33,12 +39,17 @@ arch-$(CONFIG_CPU_32v4T)	:=-D__LINUX_ARM_ARCH__=4 -march=armv4t
 tune-$(CONFIG_CPU_ARM920T)	:=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_ARM926T)	:=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_XSCALE)	:=$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
+arch-$(CONFIG_CPU_64v8)		:= -D__LINUX_ARM_ARCH__=8 $(call cc-option,-march=armv8-a)

Can we move this above the arch-$(CONFIG_CPU_32v7) line?

Quoted 28 lines
arch/arm/Makefile +9 -0
+ifeq ($(CONFIG_CPU_V8), y)
+CFLAGS_ABI	:=-mabi=lp64
+else
 ifeq ($(CONFIG_AEABI),y)
 CFLAGS_ABI	:=-mabi=aapcs-linux -mno-thumb-interwork
 else
 CFLAGS_ABI	:=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
 endif
+endif
 
 ifeq ($(CONFIG_ARM_UNWIND),y)
 CFLAGS_ABI	+=-funwind-tables
@@ -51,8 +62,13 @@ CFLAGS_THUMB2	:=-mthumb $(AFLAGS_AUTOIT) $(AFLAGS_NOWARN)
 AFLAGS_THUMB2	:=$(CFLAGS_THUMB2) -Wa$(comma)-mthumb
 endif
 
+ifeq ($(CONFIG_CPU_V8), y)
+CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y)
+AFLAGS   += -include asm/unified.h
+else
 CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float $(CFLAGS_THUMB2)
 AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
+endif
 
 # Machine directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.

arch/arm/Makefile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress · line 97

Quoted 4 lines
arch/arm/Makefile +1 -0
@@ -78,6 +94,7 @@ machine-$(CONFIG_ARCH_VEXPRESS)		:= vexpress
 machine-$(CONFIG_ARCH_TEGRA)		:= tegra
 machine-$(CONFIG_ARCH_UEMD)		:= uemd
 machine-$(CONFIG_ARCH_ZYNQ)		:= zynq
+machine-$(CONFIG_ARCH_VIRT)		:= virt

This hunk belongs to the patch adding mach-virt.

Otherwise this looks fine to me.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

Re: [PATCH 02/12] arm: Makefile: rework makefile to handle armv8

2016-06-03 9:27 GMT+02:00 Sascha Hauer <[email protected]>:

Quoted 31 lines · Raphael Poggi
Quoted 30 lines
---
 arch/arm/Makefile | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
arch/arm/Makefile +6 -0
index 5ccdb83..df4832f 100644
@@ -1,7 +1,11 @@
 
 CPPFLAGS     += -D__ARM__ -fno-strict-aliasing
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
+ifeq ($(CONFIG_CPU_V8),y)
+CPPFLAGS     +=$(call cc-option,-maarch64,)
+else
 CPPFLAGS     +=$(call cc-option,-marm,)
+endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
 CPPFLAGS     += -mbig-endian
@@ -17,7 +21,9 @@ endif
 # at least some of the code would be executed with MMU off, lets be
 # conservative and instruct the compiler not to generate any unaligned
 # accesses
+ifeq ($(CONFIG_CPU_V8),n)
 CFLAGS += -mno-unaligned-access
+endif
 
 
Quoted 8 lines

arch/arm/Makefile arch-$(CONFIG_CPU_32v4T) :=-D__LINUX_ARM_ARCH__=4 -march=armv4t · line 42

Quoted 6 lines
arch/arm/Makefile +1 -0
 # This selects which instruction set is used.
@@ -33,12 +39,17 @@ arch-$(CONFIG_CPU_32v4T)  :=-D__LINUX_ARM_ARCH__=4 -march=armv4t
 tune-$(CONFIG_CPU_ARM920T)   :=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_ARM926T)   :=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_XSCALE)    :=$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
+arch-$(CONFIG_CPU_64v8)              := -D__LINUX_ARM_ARCH__=8 $(call cc-option,-march=armv8-a)

Can we move this above the arch-$(CONFIG_CPU_32v7) line?

Yes, no problem.

Quoted 26 lines
Quoted 26 lines
arch/arm/Makefile +9 -0
+ifeq ($(CONFIG_CPU_V8), y)
+CFLAGS_ABI   :=-mabi=lp64
+else
 ifeq ($(CONFIG_AEABI),y)
 CFLAGS_ABI   :=-mabi=aapcs-linux -mno-thumb-interwork
 else
 CFLAGS_ABI   :=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
 endif
+endif
 
 ifeq ($(CONFIG_ARM_UNWIND),y)
 CFLAGS_ABI   +=-funwind-tables
@@ -51,8 +62,13 @@ CFLAGS_THUMB2      :=-mthumb $(AFLAGS_AUTOIT) $(AFLAGS_NOWARN)
 AFLAGS_THUMB2        :=$(CFLAGS_THUMB2) -Wa$(comma)-mthumb
 endif
 
+ifeq ($(CONFIG_CPU_V8), y)
+CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y)
+AFLAGS   += -include asm/unified.h
+else
 CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float $(CFLAGS_THUMB2)
 AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
+endif
 
Quoted 9 lines

arch/arm/Makefile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress · line 97

Quoted 7 lines
arch/arm/Makefile +1 -0
 # Machine directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.
@@ -78,6 +94,7 @@ machine-$(CONFIG_ARCH_VEXPRESS)             := vexpress
 machine-$(CONFIG_ARCH_TEGRA)         := tegra
 machine-$(CONFIG_ARCH_UEMD)          := uemd
 machine-$(CONFIG_ARCH_ZYNQ)          := zynq
+machine-$(CONFIG_ARCH_VIRT)          := virt

This hunk belongs to the patch adding mach-virt.

Oops you are right, I will correct it in v2.

Quoted 11 lines

Otherwise this looks fine to me.

Sascha

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Quoted 4 lines

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#6 lore raw

Re: [PATCH 03/12] arm: introduce lib64 for arm64 related stuff

In reply to Raphael Poggi
Quoted 12 lines · Raphael Poggi
---
 arch/arm/lib64/Makefile         |  16 ++
 arch/arm/lib64/armlinux.c       | 275 +++++++++++++++++++
 arch/arm/lib64/asm-offsets.c    |  16 ++
 arch/arm/lib64/barebox.lds      | 125 +++++++++
 arch/arm/lib64/barebox.lds.S    | 125 +++++++++
 arch/arm/lib64/bootm.c          | 572 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/lib64/bootu.c          |  44 ++++
 arch/arm/lib64/bootz.c          | 136 ++++++++++
 arch/arm/lib64/copy_template.S  | 192 ++++++++++++++
 arch/arm/lib64/div0.c           |  27 ++
Quoted 8 lines
 arch/arm/lib64/memcpy.S         |  74 ++++++
 arch/arm/lib64/memset.S         | 215 +++++++++++++++
 arch/arm/lib64/module.c         |  98 +++++++
 arch/arm/lib64/pbl.lds.S        |  96 +++++++
 arch/arm/lib64/runtime-offset.S |  52 ++++
 arch/arm/lib64/unwind.c         | 349 ++++++++++++++++++++++++
 16 files changed, 2412 insertions(+)
 create mode 100644 arch/arm/lib64/barebox.lds

This file shouldn't be necessary, it's generated from barebox.lds.S

Quoted 7 lines
 create mode 100644 arch/arm/lib64/Makefile
 create mode 100644 arch/arm/lib64/barebox.lds.S
 create mode 100644 arch/arm/lib64/asm-offsets.c
 create mode 100644 arch/arm/lib64/copy_template.S
 create mode 100644 arch/arm/lib64/div0.c
 create mode 100644 arch/arm/lib64/memcpy.S
 create mode 100644 arch/arm/lib64/memset.S

These are most likely fine as they are. Can you make a separate patch from them?

Quoted 1 line
 create mode 100644 arch/arm/lib64/bootm.c

Not sure how much should be merged into common code for arm/arm64. We can keep it like this for now.

Quoted 2 lines
 create mode 100644 arch/arm/lib64/bootu.c
 create mode 100644 arch/arm/lib64/bootz.c

These shouldn't be needed for arm64, bootm.c is enough.

Quoted 1 line
 create mode 100644 arch/arm/lib64/module.c

We can drop module support for arm64. I guess this would need substantial changes for arm64 anyway, so we can remove it here.

Quoted 3 lines
 create mode 100644 arch/arm/lib64/pbl.lds.S
 create mode 100644 arch/arm/lib64/runtime-offset.S
 create mode 100644 arch/arm/lib64/unwind.c

How much of this code is already used? If it's unused you can remove it for now.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

Re: [PATCH 04/12] arm: cpu: add arm64 specific code

In reply to Raphael Poggi
Quoted 59 lines · Raphael Poggi

This patch adds arm64 specific codes, which are:
- exception support
- cache support
- rework Makefile to support arm64

---
 arch/arm/cpu/Makefile        |  17 ++++-
 arch/arm/cpu/cache-armv8.S   | 168 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/cache.c         |  19 +++++
 arch/arm/cpu/exceptions_64.S | 127 ++++++++++++++++++++++++++++++++
 arch/arm/cpu/interrupts.c    |  47 ++++++++++++
 arch/arm/cpu/lowlevel.S      |  38 ++++++++++
 arch/arm/include/asm/cache.h |   9 +++
 7 files changed, 423 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/cpu/cache-armv8.S
 create mode 100644 arch/arm/cpu/exceptions_64.S
arch/arm/cpu/lowlevel.S +28 -0
@@ -3,6 +3,7 @@
 #include <asm/system.h>
 
 .section ".text_bare_init_","ax"
+#if __LINUX_ARM_ARCH__ <= 7
 ENTRY(arm_cpu_lowlevel_init)
 	/* set the cpu to SVC32 mode, mask irq and fiq */
 	mrs	r12, cpsr
@@ -56,3 +57,40 @@ ENTRY(arm_cpu_lowlevel_init)
 
 	mov	pc, lr
 ENDPROC(arm_cpu_lowlevel_init)
+#else
+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:

arch/arm/cpu/lowlevel.S ENTRY(arm_cpu_lowlevel_init) · line 96

Quoted 10 lines
arch/arm/cpu/lowlevel.S +10 -0
+	msr	vbar_el1, x0
+	mov	x0, #(3 << 20)		/* Enable FP/SIMD */
+	msr	cpacr_el1, x0
+	b	done
+
+done:
+	ret
+
+ENDPROC(arm_cpu_lowlevel_init)
+#endif

Better create a lowlevel64.S? The code is completely different anyway.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#16 lore raw

Re: [PATCH 11/12] arm: cpu: add basic arm64 mmu support

In reply to Raphael Poggi
Quoted 160 lines · Raphael Poggi

This commit adds basic mmu support, ie:
- DMA cache handling is not supported
- Remapping memory region also

The current mmu setting is:
- 4KB granularity
- 3 level lookup (skipping L0)
- 33 bits per VA

This is based on coreboot and u-boot mmu configuration.

---
 arch/arm/cpu/Makefile          |   7 +-
 arch/arm/cpu/mmu.h             | 160 ++++++++++++++++++++
 arch/arm/cpu/mmu_64.c          | 335 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/mmu.h     |   4 +-
 arch/arm/include/asm/pgtable.h |   8 +
 5 files changed, 509 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/cpu/mmu_64.c
arch/arm/cpu/Makefile +5 -2
index 95a2b00..e2def01 100644
@@ -2,8 +2,11 @@ obj-y += cpu.o
 
 ifeq ($(CONFIG_CPU_64v8), y)
 obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions_64.o
+obj-$(CONFIG_MMU) += mmu_64.o
 else
 obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
+obj-$(CONFIG_MMU) += mmu.o mmu-early.o
+pbl-$(CONFIG_MMU) += mmu-early.o
 endif
 
 obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
@@ -19,8 +22,8 @@ endif
 obj-$(CONFIG_CMD_ARM_CPUINFO) += cpuinfo.o
 obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o
 obj-$(CONFIG_OFDEVICE) += dtb.o
-obj-$(CONFIG_MMU) += mmu.o cache.o mmu-early.o
-pbl-$(CONFIG_MMU) += mmu-early.o
+obj-$(CONFIG_MMU) += cache.o
+
 ifeq ($(CONFIG_MMU),)
 obj-y += no-mmu.o
 endif
arch/arm/cpu/mmu.h +104 -0
index 79ebc80..bcc0e2d 100644
@@ -1,6 +1,166 @@
 #ifndef __ARM_MMU_H
 #define __ARM_MMU_H
 
+#ifdef CONFIG_CPU_64v8
+
+#define UL(x)		_AC(x, UL)
+
+#define UNUSED_DESC                0x6EbAAD0BBADbA6E0
+
+#define VA_START                   0x0
+#define BITS_PER_VA                33
+
+/* Granule size of 4KB is being used */
+#define GRANULE_SIZE_SHIFT         12
+#define GRANULE_SIZE               (1 << GRANULE_SIZE_SHIFT)
+#define XLAT_ADDR_MASK             ((1UL << BITS_PER_VA) - GRANULE_SIZE)
+#define GRANULE_SIZE_MASK          ((1 << GRANULE_SIZE_SHIFT) - 1)
+
+#define BITS_RESOLVED_PER_LVL   (GRANULE_SIZE_SHIFT - 3)
+#define L1_ADDR_SHIFT           (GRANULE_SIZE_SHIFT + BITS_RESOLVED_PER_LVL * 2)
+#define L2_ADDR_SHIFT           (GRANULE_SIZE_SHIFT + BITS_RESOLVED_PER_LVL * 1)
+#define L3_ADDR_SHIFT           (GRANULE_SIZE_SHIFT + BITS_RESOLVED_PER_LVL * 0)
+
+
+#define L1_ADDR_MASK     (((1UL << BITS_RESOLVED_PER_LVL) - 1) << L1_ADDR_SHIFT)
+#define L2_ADDR_MASK     (((1UL << BITS_RESOLVED_PER_LVL) - 1) << L2_ADDR_SHIFT)
+#define L3_ADDR_MASK     (((1UL << BITS_RESOLVED_PER_LVL) - 1) << L3_ADDR_SHIFT)
+
+/* These macros give the size of the region addressed by each entry of a xlat
+   table at any given level */
+#define L3_XLAT_SIZE               (1UL << L3_ADDR_SHIFT)
+#define L2_XLAT_SIZE               (1UL << L2_ADDR_SHIFT)
+#define L1_XLAT_SIZE               (1UL << L1_ADDR_SHIFT)
+
+#define GRANULE_MASK	GRANULE_SIZE
+
+/*
+ * Memory types
+ */
+#define MT_DEVICE_NGNRNE	0
+#define MT_DEVICE_NGNRE		1
+#define MT_DEVICE_GRE		2
+#define MT_NORMAL_NC		3
+#define MT_NORMAL		4
+
+#define MEMORY_ATTRIBUTES	((0x00 << (MT_DEVICE_NGNRNE*8)) |	\
+		(0x04 << (MT_DEVICE_NGNRE*8)) |		\
+		(0x0c << (MT_DEVICE_GRE*8)) |		\
+		(0x44 << (MT_NORMAL_NC*8)) |		\
+		(UL(0xff) << (MT_NORMAL*8)))
+
+/*
+ * Hardware page table definitions.
+ *
+ * Level 2 descriptor (PMD).
+ */
+#define PMD_TYPE_MASK		(3 << 0)
+#define PMD_TYPE_FAULT		(0 << 0)
+#define PMD_TYPE_TABLE		(3 << 0)
+#define PMD_TYPE_PAGE		(3 << 0)
+#define PMD_TYPE_SECT		(1 << 0)
+
+/*
+ * Section
+ */
+#define PMD_SECT_NON_SHARE	(0 << 8)
+#define PMD_SECT_OUTER_SHARE	(2 << 8)
+#define PMD_SECT_INNER_SHARE	(3 << 8)
+#define PMD_SECT_AF		(1 << 10)
+#define PMD_SECT_NG		(1 << 11)
+#define PMD_SECT_PXN		(UL(1) << 53)
+#define PMD_SECT_UXN		(UL(1) << 54)
+
+/*
+ * AttrIndx[2:0]
+ */
+#define PMD_ATTRINDX(t)		((t) << 2)
+#define PMD_ATTRINDX_MASK	(7 << 2)
+
+/*
+ * TCR flags.
+ */
+#define TCR_T0SZ(x)		((64 - (x)) << 0)
+#define TCR_IRGN_NC		(0 << 8)
+#define TCR_IRGN_WBWA		(1 << 8)
+#define TCR_IRGN_WT		(2 << 8)
+#define TCR_IRGN_WBNWA		(3 << 8)
+#define TCR_IRGN_MASK		(3 << 8)
+#define TCR_ORGN_NC		(0 << 10)
+#define TCR_ORGN_WBWA		(1 << 10)
+#define TCR_ORGN_WT		(2 << 10)
+#define TCR_ORGN_WBNWA		(3 << 10)
+#define TCR_ORGN_MASK		(3 << 10)
+#define TCR_SHARED_NON		(0 << 12)
+#define TCR_SHARED_OUTER	(2 << 12)
+#define TCR_SHARED_INNER	(3 << 12)
+#define TCR_TG0_4K		(0 << 14)
+#define TCR_TG0_64K		(1 << 14)
+#define TCR_TG0_16K		(2 << 14)
+#define TCR_EL1_IPS_BITS	(UL(3) << 32)	/* 42 bits physical address */
+#define TCR_EL2_IPS_BITS	(3 << 16)	/* 42 bits physical address */
+#define TCR_EL3_IPS_BITS	(3 << 16)	/* 42 bits physical address */
+
+#define TCR_EL1_RSVD		(1 << 31)
+#define TCR_EL2_RSVD		(1 << 31 | 1 << 23)
+#define TCR_EL3_RSVD		(1 << 31 | 1 << 23)
+

arch/arm/cpu/mmu.h line 117

Quoted 10 lines
arch/arm/cpu/mmu.h +10 -0
+#define TCR_FLAGS		(TCR_TG0_4K | \
+		TCR_SHARED_OUTER | \
+		TCR_SHARED_INNER | \
+		TCR_IRGN_WBWA | \
+		TCR_ORGN_WBWA | \
+		TCR_T0SZ(BITS_PER_VA))
+
+#define MEMORY_ATTR     (PMD_SECT_AF | PMD_SECT_INNER_SHARE |    \
+		PMD_ATTRINDX(MT_NORMAL) |       \
+		PMD_TYPE_SECT)

For arm32 we have these defines in arch/arm/include/asm/pgtable.h, so for arm64 they should probably live in arch/arm/include/asm/pgtable64.h.

Quoted 11 lines
arch/arm/include/asm/pgtable.h +3 -0
index fd1521d..7ae33de 100644
@@ -18,8 +18,16 @@
  */
 #define PMD_TYPE_MASK		(3 << 0)
 #define PMD_TYPE_FAULT		(0 << 0)
+
+#ifdef CONFIG_CPU_64v8
+#define PMD_TYPE_TABLE		(3 << 0)

arch/arm/include/asm/pgtable.h line 33

Quoted 10 lines
arch/arm/include/asm/pgtable.h +5 -0
+#define PMD_TYPE_PAGE		(3 << 0)
+#define PMD_TYPE_SECT		(1 << 0)
+#else
 #define PMD_TYPE_TABLE		(1 << 0)
 #define PMD_TYPE_SECT		(2 << 0)
+#endif
+
 #define PMD_BIT4		(1 << 4)
 #define PMD_DOMAIN(x)		((x) << 5)
 #define PMD_PROTECTION		(1 << 9)	/* v5 */

Maybe we have to create a arch/arm/include/asm/pgtable32.h aswell and only leave the common stuff in arch/arm/include/asm/pgtable.h? I don't know how much of arch/arm/include/asm/pgtable.h is used for arm64.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#18 lore raw

Re: [PATCH 12/12] arm: boards: add virt board

In reply to Raphael Poggi
Quoted 49 lines · Raphael Poggi

Add qemu virt board which emulates arm64 board.

---
 arch/arm/Kconfig                           |  9 ++++
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/virt/Kconfig               |  8 ++++
 arch/arm/boards/virt/Makefile              |  1 +
 arch/arm/boards/virt/env/bin/_update       | 36 ++++++++++++++++
 arch/arm/boards/virt/env/bin/boot          | 38 +++++++++++++++++
 arch/arm/boards/virt/env/bin/init          | 20 +++++++++
 arch/arm/boards/virt/env/bin/update_kernel |  8 ++++
 arch/arm/boards/virt/env/bin/update_root   |  8 ++++
 arch/arm/boards/virt/env/config            | 38 +++++++++++++++++
 arch/arm/boards/virt/env/init/mtdparts-nor | 11 +++++
 arch/arm/boards/virt/init.c                | 67 ++++++++++++++++++++++++++++++
 arch/arm/configs/virt_defconfig            | 55 ++++++++++++++++++++++++
 arch/arm/mach-virt/Kconfig                 | 15 +++++++
 arch/arm/mach-virt/Makefile                |  3 ++
 arch/arm/mach-virt/devices.c               | 30 +++++++++++++
 arch/arm/mach-virt/include/mach/debug_ll.h | 24 +++++++++++
 arch/arm/mach-virt/include/mach/devices.h  | 13 ++++++
 arch/arm/mach-virt/lowlevel.c              | 19 +++++++++
 arch/arm/mach-virt/reset.c                 | 24 +++++++++++
 20 files changed, 428 insertions(+)
 create mode 100644 arch/arm/boards/virt/Kconfig
 create mode 100644 arch/arm/boards/virt/Makefile
 create mode 100644 arch/arm/boards/virt/env/bin/_update
 create mode 100644 arch/arm/boards/virt/env/bin/boot
 create mode 100644 arch/arm/boards/virt/env/bin/init
 create mode 100644 arch/arm/boards/virt/env/bin/update_kernel
 create mode 100644 arch/arm/boards/virt/env/bin/update_root
 create mode 100644 arch/arm/boards/virt/env/config
 create mode 100644 arch/arm/boards/virt/env/init/mtdparts-nor
 create mode 100644 arch/arm/boards/virt/init.c
 create mode 100644 arch/arm/configs/virt_defconfig
 create mode 100644 arch/arm/mach-virt/Kconfig
 create mode 100644 arch/arm/mach-virt/Makefile
 create mode 100644 arch/arm/mach-virt/devices.c
 create mode 100644 arch/arm/mach-virt/include/mach/debug_ll.h
 create mode 100644 arch/arm/mach-virt/include/mach/devices.h
 create mode 100644 arch/arm/mach-virt/lowlevel.c
 create mode 100644 arch/arm/mach-virt/reset.c
arch/arm/Kconfig +0 -0
index 986fdaa..71b90e7 100644

arch/arm/Kconfig config ARCH_ZYNQ · line 264

Quoted 10 lines
arch/arm/Kconfig +7 -0
@@ -255,6 +255,14 @@ config ARCH_ZYNQ
 	bool "Xilinx Zynq-based boards"
 	select HAS_DEBUG_LL
 
+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

This should have 64 somewhere in the name to distinguish between 64 and 32 bit qemu platforms.

arch/arm/boards/virt/env/bin/_update

Quoted 43 lines
arch/arm/Kconfig +2 -0
+
 endchoice
 
 source arch/arm/cpu/Kconfig
@@ -280,6 +288,7 @@ source arch/arm/mach-vexpress/Kconfig
 source arch/arm/mach-tegra/Kconfig
 source arch/arm/mach-uemd/Kconfig
 source arch/arm/mach-zynq/Kconfig
+source arch/arm/mach-virt/Kconfig
 
 config ARM_ASM_UNIFIED
 	bool
arch/arm/boards/Makefile +1 -0
index 5a755c9..da0af74 100644
@@ -134,3 +134,4 @@ obj-$(CONFIG_MACH_VIRT2REAL)			+= virt2real/
 obj-$(CONFIG_MACH_ZEDBOARD)			+= avnet-zedboard/
 obj-$(CONFIG_MACH_ZYLONITE)			+= zylonite/
 obj-$(CONFIG_MACH_VARISCITE_MX6)		+= variscite-mx6/
+obj-$(CONFIG_MACH_VIRT)			+= virt/
arch/arm/boards/virt/Kconfig new file +8 -0
new file mode 100644
index 0000000..b239127
@@ -0,0 +1,8 @@
+
+if MACH_VIRT
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x40000000
+
+endif
arch/arm/boards/virt/Makefile new file +1 -0
new file mode 100644
index 0000000..eb072c0
@@ -0,0 +1 @@
+obj-y += init.o
arch/arm/boards/virt/env/bin/_update +0 -0

Please drop these environment files. New boards for sure should use defenv2 and normally for this you don't need any board specific environment files.

Quoted 57 lines
arch/arm/boards/virt/init.c new file +51 -0
new file mode 100644
index 0000000..9626067
@@ -0,0 +1,67 @@
+/*
+ * 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>
+#include <asm/mmu.h>
+
+static int virt_mem_init(void)
+{
+	virt_add_ddram(SZ_512M);
+
+	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;

arch/arm/boards/virt/init.c line 61

Quoted 10 lines
arch/arm/boards/virt/init.c new file +10 -0
+}
+postcore_initcall(virt_core_init);
+
+static int virt_mmu_enable(void)
+{
+	/* Mapping all periph range */
+	arch_remap_range(0x09000000, 0x01000000, PMD_SECT_DEF_CACHED);
+
+	/* Mapping all flash range */
+	arch_remap_range(0x00000000, 0x08000000, PMD_SECT_DEF_CACHED);

Hm, mapping the peripherals and the flash cached? This seems wrong. Either the mapping does not work or your periphals do not work ;)

Quoted 26 lines
arch/arm/boards/virt/init.c new file +6 -0
+
+	mmu_enable();
+
+	return 0;
+}
+postmmu_initcall(virt_mmu_enable);
arch/arm/mach-virt/reset.c new file +14 -0
new file mode 100644
index 0000000..fb895eb
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 Raphaël Poggi <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#include <common.h>
+#include <io.h>
+#include <init.h>
+#include <restart.h>
+#include <mach/devices.h>
+
+static void virt_reset_soc(struct restart_handler *rst)
+{

arch/arm/mach-virt/reset.c line 24

Quoted 10 lines
arch/arm/mach-virt/reset.c new file +10 -0
+	hang();
+}
+
+static int restart_register_feature(void)
+{
+	restart_handler_register_fn(virt_reset_soc);
+
+	return 0;
+}
+coredevice_initcall(restart_register_feature);

You can drop this. When no restart_handler is registered then hang() is the default behaviour anyway.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#24 lore raw
In reply to Raphael Poggi
Quoted 10 lines · Raphael Poggi

Hello,

This patch series introduces a basic support for arm64.

The arm64 code is merged in the current arch/arm directory. I try to be iterative in the merge process, and find correct solutions to handle both architecture at some places.

I test the patch series by compiling arm64 virt machine and arm32 vexpress-a9 and test it in qemu, everything seems to work.

Overall this looks quite good already and I think we can soon start merging the first steps. What's important for me is that arm32 is unaffected by the changes (seems to be the case for this series) and that we do not merge code that does not work and is only present because it's copied from arm32

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#25 lore raw

Hi,

2016-06-03 11:16 GMT+02:00 Sascha Hauer <[email protected]>:

Quoted 9 lines · Raphael Poggi
Quoted 8 lines

Hello,

This patch series introduces a basic support for arm64.

The arm64 code is merged in the current arch/arm directory. I try to be iterative in the merge process, and find correct solutions to handle both architecture at some places.

Quoted 8 lines
Quoted 2 lines

I test the patch series by compiling arm64 virt machine and arm32 vexpress-a9 and test it in qemu, everything seems to work.

Overall this looks quite good already and I think we can soon start merging the first steps. What's important for me is that arm32 is unaffected by the changes (seems to be the case for this series) and that we do not merge code that does not work and is only present because it's copied from arm32

Thanks for the code review, I will fix and rework all the points you raised and send a v2.

I will take care to don't add code which will be unused (like I did in lib64 directory...) for arm64.

Raphaël

Quoted 8 lines

Sascha

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#19 lore raw

Re: [PATCH 12/12] arm: boards: add virt board

In reply to Sascha Hauer

Hi,

2016-06-03 10:50 GMT+02:00 Sascha Hauer <[email protected]>:

Quoted 53 lines · Raphael Poggi
Quoted 52 lines

Add qemu virt board which emulates arm64 board.

---
 arch/arm/Kconfig                           |  9 ++++
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/virt/Kconfig               |  8 ++++
 arch/arm/boards/virt/Makefile              |  1 +
 arch/arm/boards/virt/env/bin/_update       | 36 ++++++++++++++++
 arch/arm/boards/virt/env/bin/boot          | 38 +++++++++++++++++
 arch/arm/boards/virt/env/bin/init          | 20 +++++++++
 arch/arm/boards/virt/env/bin/update_kernel |  8 ++++
 arch/arm/boards/virt/env/bin/update_root   |  8 ++++
 arch/arm/boards/virt/env/config            | 38 +++++++++++++++++
 arch/arm/boards/virt/env/init/mtdparts-nor | 11 +++++
 arch/arm/boards/virt/init.c                | 67 ++++++++++++++++++++++++++++++
 arch/arm/configs/virt_defconfig            | 55 ++++++++++++++++++++++++
 arch/arm/mach-virt/Kconfig                 | 15 +++++++
 arch/arm/mach-virt/Makefile                |  3 ++
 arch/arm/mach-virt/devices.c               | 30 +++++++++++++
 arch/arm/mach-virt/include/mach/debug_ll.h | 24 +++++++++++
 arch/arm/mach-virt/include/mach/devices.h  | 13 ++++++
 arch/arm/mach-virt/lowlevel.c              | 19 +++++++++
 arch/arm/mach-virt/reset.c                 | 24 +++++++++++
 20 files changed, 428 insertions(+)
 create mode 100644 arch/arm/boards/virt/Kconfig
 create mode 100644 arch/arm/boards/virt/Makefile
 create mode 100644 arch/arm/boards/virt/env/bin/_update
 create mode 100644 arch/arm/boards/virt/env/bin/boot
 create mode 100644 arch/arm/boards/virt/env/bin/init
 create mode 100644 arch/arm/boards/virt/env/bin/update_kernel
 create mode 100644 arch/arm/boards/virt/env/bin/update_root
 create mode 100644 arch/arm/boards/virt/env/config
 create mode 100644 arch/arm/boards/virt/env/init/mtdparts-nor
 create mode 100644 arch/arm/boards/virt/init.c
 create mode 100644 arch/arm/configs/virt_defconfig
 create mode 100644 arch/arm/mach-virt/Kconfig
 create mode 100644 arch/arm/mach-virt/Makefile
 create mode 100644 arch/arm/mach-virt/devices.c
 create mode 100644 arch/arm/mach-virt/include/mach/debug_ll.h
 create mode 100644 arch/arm/mach-virt/include/mach/devices.h
 create mode 100644 arch/arm/mach-virt/lowlevel.c
 create mode 100644 arch/arm/mach-virt/reset.c
arch/arm/Kconfig +0 -0
index 986fdaa..71b90e7 100644
@@ -255,6 +255,14 @@ config ARCH_ZYNQ
      bool "Xilinx Zynq-based boards"
      select HAS_DEBUG_LL
 
Quoted 10 lines

arch/arm/Kconfig config ARCH_ZYNQ · line 264

Quoted 7 lines
arch/arm/Kconfig +7 -0
+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

This should have 64 somewhere in the name to distinguish between 64 and 32 bit qemu platforms.

Only in the Kconfig entry or also in the mach/board name (virt64 or something like that) ?

Quoted 111 lines

arch/arm/boards/virt/env/bin/_update

Quoted 44 lines
arch/arm/Kconfig +2 -0
+
 endchoice
 
 source arch/arm/cpu/Kconfig
@@ -280,6 +288,7 @@ source arch/arm/mach-vexpress/Kconfig
 source arch/arm/mach-tegra/Kconfig
 source arch/arm/mach-uemd/Kconfig
 source arch/arm/mach-zynq/Kconfig
+source arch/arm/mach-virt/Kconfig
 
 config ARM_ASM_UNIFIED
      bool
arch/arm/boards/Makefile +1 -0
index 5a755c9..da0af74 100644
@@ -134,3 +134,4 @@ obj-$(CONFIG_MACH_VIRT2REAL)                      += virt2real/
 obj-$(CONFIG_MACH_ZEDBOARD)                  += avnet-zedboard/
 obj-$(CONFIG_MACH_ZYLONITE)                  += zylonite/
 obj-$(CONFIG_MACH_VARISCITE_MX6)             += variscite-mx6/
+obj-$(CONFIG_MACH_VIRT)                      += virt/
arch/arm/boards/virt/Kconfig new file +8 -0
new file mode 100644
index 0000000..b239127
@@ -0,0 +1,8 @@
+
+if MACH_VIRT
+
+config ARCH_TEXT_BASE
+     hex
+     default 0x40000000
+
+endif
arch/arm/boards/virt/Makefile new file +1 -0
new file mode 100644
index 0000000..eb072c0
@@ -0,0 +1 @@
+obj-y += init.o
arch/arm/boards/virt/env/bin/_update +0 -0

Please drop these environment files. New boards for sure should use defenv2 and normally for this you don't need any board specific environment files.

Quoted 62 lines
arch/arm/boards/virt/init.c new file +56 -0
new file mode 100644
index 0000000..9626067
@@ -0,0 +1,67 @@
+/*
+ * 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>
+#include <asm/mmu.h>
+
+static int virt_mem_init(void)
+{
+     virt_add_ddram(SZ_512M);
+
+     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);
+
+static int virt_mmu_enable(void)
+{
Quoted 8 lines

arch/arm/boards/virt/init.c line 61

Quoted 5 lines
arch/arm/boards/virt/init.c new file +5 -0
+     /* Mapping all periph range */
+     arch_remap_range(0x09000000, 0x01000000, PMD_SECT_DEF_CACHED);
+
+     /* Mapping all flash range */
+     arch_remap_range(0x00000000, 0x08000000, PMD_SECT_DEF_CACHED);

Hm, mapping the peripherals and the flash cached? This seems wrong. Either the mapping does not work or your periphals do not work ;)

You are right, in fact I figure out that qemu does not handle instruction or data cache, that's why it was working...

Quoted 49 lines
Quoted 27 lines
arch/arm/boards/virt/init.c new file +6 -0
+
+     mmu_enable();
+
+     return 0;
+}
+postmmu_initcall(virt_mmu_enable);
arch/arm/mach-virt/reset.c new file +14 -0
new file mode 100644
index 0000000..fb895eb
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 Raphaël Poggi <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#include <common.h>
+#include <io.h>
+#include <init.h>
+#include <restart.h>
+#include <mach/devices.h>
+
+static void virt_reset_soc(struct restart_handler *rst)
+{

arch/arm/mach-virt/reset.c line 24

Quoted 10 lines
arch/arm/mach-virt/reset.c new file +10 -0
+     hang();
+}
+
+static int restart_register_feature(void)
+{
+     restart_handler_register_fn(virt_reset_soc);
+
+     return 0;
+}
+coredevice_initcall(restart_register_feature);

You can drop this. When no restart_handler is registered then hang() is the default behaviour anyway.

Sascha

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Quoted 4 lines

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#20 lore raw

Re: [PATCH 12/12] arm: boards: add virt board

In reply to Raphael Poggi
Quoted 7 lines · On Thu, 2 Jun 2016 10:06:58 +0200 Raphael Poggi <[email protected]> wrote:

Add qemu virt board which emulates arm64 board.

---
 arch/arm/Kconfig                           |  9 ++++
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/virt/Kconfig               |  8 ++++

Can we use a more descriptive 'qemu-virt' name for this machine/board instead of 'virt'?

Quoted 3 lines
 arch/arm/boards/virt/Makefile              |  1 +
 arch/arm/boards/virt/env/bin/_update       | 36 ++++++++++++++++
 arch/arm/boards/virt/env/bin/boot          | 38 +++++++++++++++++

... skipped ...

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#21 lore raw

Re: [PATCH 12/12] arm: boards: add virt board

2016-06-07 13:00 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 5 lines
Quoted 2 lines · On Thu, 2 Jun 2016 10:06:58 +0200 Raphael Poggi <[email protected]> wrote:

Add qemu virt board which emulates arm64 board.

Quoted 7 lines
Quoted 5 lines
---
 arch/arm/Kconfig                           |  9 ++++
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/virt/Kconfig               |  8 ++++

Can we use a more descriptive 'qemu-virt' name for this machine/board instead of 'virt'?

Qemu virt machine support armv7 and armv8 cpu, maybe we can use the name "mach-qemu" for the machine and "qemu-virt64" for the board.

With this approach we use a generic name for the machine (since qemu virt machine support armv7/armv8, we do not need to distinguish between arm/arm64),
and made the distinction arm/arm64 only in board name.

This also lets the possibility, for someone who wants to add support for qemu virt arm32 board, to not create another machine folder.

What do you think about that ?

Raphaël

Quoted 7 lines
Quoted 4 lines
 arch/arm/boards/virt/Makefile              |  1 +
 arch/arm/boards/virt/env/bin/_update       | 36 ++++++++++++++++
 arch/arm/boards/virt/env/bin/boot          | 38 +++++++++++++++++

... skipped ...

Quoted 8 lines

--
Best regards,
Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#22 lore raw

Re: [PATCH 12/12] arm: boards: add virt board

Quoted 22 lines · On Tue, 7 Jun 2016 13:53:49 +0200 Raphaël Poggi <[email protected]> wrote:

2016-06-07 13:00 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 5 lines
Quoted 2 lines · On Thu, 2 Jun 2016 10:06:58 +0200 Raphael Poggi <[email protected]> wrote:

Add qemu virt board which emulates arm64 board.

Quoted 7 lines
Quoted 5 lines
---
 arch/arm/Kconfig                           |  9 ++++
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/virt/Kconfig               |  8 ++++

Can we use a more descriptive 'qemu-virt' name for this machine/board instead of 'virt'?

Qemu virt machine support armv7 and armv8 cpu, maybe we can use the name "mach-qemu" for the machine and "qemu-virt64" for the board.

With this approach we use a generic name for the machine (since qemu virt machine support armv7/armv8, we do not need to distinguish between arm/arm64),
and made the distinction arm/arm64 only in board name.

Quoted 4 lines

This also lets the possibility, for someone who wants to add support for qemu virt arm32 board, to not create another machine folder.

What do you think about that ?

So you are proposing to introduce these directories:

arch/arm/boards/qemu-virt64/
arch/arm/mach-qemu/

I propose to use 'arch/arm/mach-qemu-virt' for machine dir, because qemu supports several arm-based machines, not only the virt machine.

On the other hand the 'mach-qemu-virt' name is too long and 'mach-qemu' may be is a better solution.

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
 arch/arm/boards/virt/Makefile              |  1 +
 arch/arm/boards/virt/env/bin/_update       | 36 ++++++++++++++++
 arch/arm/boards/virt/env/bin/boot          | 38 +++++++++++++++++

... skipped ...

--
Best regards,
Antony Pavlov

_______________________________________________
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
#23 lore raw

Re: [PATCH 12/12] arm: boards: add virt board

2016-06-07 14:59 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 28 lines
Quoted 25 lines · On Tue, 7 Jun 2016 13:53:49 +0200 Raphaël Poggi <[email protected]> wrote:

2016-06-07 13:00 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 5 lines
Quoted 2 lines · On Thu, 2 Jun 2016 10:06:58 +0200 Raphael Poggi <[email protected]> wrote:

Add qemu virt board which emulates arm64 board.

Quoted 7 lines
Quoted 5 lines
---
 arch/arm/Kconfig                           |  9 ++++
 arch/arm/boards/Makefile                   |  1 +
 arch/arm/boards/virt/Kconfig               |  8 ++++

Can we use a more descriptive 'qemu-virt' name for this machine/board instead of 'virt'?

Qemu virt machine support armv7 and armv8 cpu, maybe we can use the name "mach-qemu" for the machine and "qemu-virt64" for the board.

With this approach we use a generic name for the machine (since qemu virt machine support armv7/armv8, we do not need to distinguish between arm/arm64),
and made the distinction arm/arm64 only in board name.

This also lets the possibility, for someone who wants to add support for qemu virt arm32 board, to not create another machine folder.

Quoted 6 lines
Quoted 1 line

What do you think about that ?

So you are proposing to introduce these directories:

arch/arm/boards/qemu-virt64/
arch/arm/mach-qemu/

Yes, exactly.

Quoted 6 lines

I propose to use 'arch/arm/mach-qemu-virt' for machine dir, because qemu supports several arm-based machines, not only the virt machine.

On the other hand the 'mach-qemu-virt' name is too long and 'mach-qemu' may be is a better solution.

"mach-qemu-virt" seems too long.

Another proposition: we can choose "mach-qemu", and to distinguish qemu machine use the same way as mach-at91, ie:

arch/arm/mach-qemu/
--> virt_devices.c
--> virt_lowlevel.c
--> etc...

This also implies to add some Kconfig entries to handle the multiple qemu machines.

Quoted 24 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines


 arch/arm/boards/virt/Makefile              |  1 +
 arch/arm/boards/virt/env/bin/_update       | 36 ++++++++++++++++
 arch/arm/boards/virt/env/bin/boot          | 38 +++++++++++++++++

... skipped ...

Quoted 8 lines
Quoted 8 lines

--
Best regards,
Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

--
--
Best regards,
Antony Pavlov

Quoted 4 lines

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox