ARC updates
cover ARC updates
This patchset is meant to prepare ARC for device model utilization. The most important things done:
[1] Separation of interrupt vectore tables from start.S
[2] Merge of low-level start-up code (written in assembly) for ARCompat and ARCv2 architectures
[3] Separation of interrupt and exception handling code in a separate source file (ints_low.S)
[4] Major clean-up of start-up code and switch to heavy use of routines written in C (re-use implementations for x86 in board_f.c)
Alexey Brodkin (6):
arc: merge common start-up code between ARC and ARCv2
arc: move low-level interrupt and exception handlers in a separate
file
arc: clean-up init procedure
arc: get rid of CONFIG_SYS_GENERIC_GLOBAL_DATA
arc: minor fixes in Kconfig
arc: re-generate defconfigs
arch/arc/Kconfig | 10 +- arch/arc/cpu/arcv1/Makefile | 2 +- arch/arc/cpu/arcv1/ivt.S | 27 ++++ arch/arc/cpu/arcv1/start.S | 254 ------------------------------------ arch/arc/cpu/arcv2/Makefile | 2 +- arch/arc/cpu/arcv2/ivt.S | 27 ++++ arch/arc/cpu/arcv2/start.S | 254 ------------------------------------ arch/arc/include/asm/config.h | 1 - arch/arc/include/asm/init_helpers.h | 12 ++ arch/arc/include/asm/relocate.h | 16 +++ arch/arc/include/asm/u-boot-arc.h | 3 + arch/arc/lib/Makefile | 3 + arch/arc/lib/cpu.c | 13 -- arch/arc/lib/init_helpers.c | 27 ++++ arch/arc/lib/ints_low.S | 151 +++++++++++++++++++++ arch/arc/lib/relocate.c | 19 +++ arch/arc/lib/start.S | 51 ++++++++ common/board_f.c | 8 +- configs/arcangel4-be_defconfig | 4 +- configs/arcangel4_defconfig | 2 +- configs/axs101_defconfig | 6 +- configs/axs103_defconfig | 4 +- configs/tb100_defconfig | 4 +- 23 files changed, 361 insertions(+), 539 deletions(-) create mode 100644 arch/arc/cpu/arcv1/ivt.S delete mode 100644 arch/arc/cpu/arcv1/start.S create mode 100644 arch/arc/cpu/arcv2/ivt.S delete mode 100644 arch/arc/cpu/arcv2/start.S create mode 100644 arch/arc/include/asm/init_helpers.h create mode 100644 arch/arc/include/asm/relocate.h create mode 100644 arch/arc/lib/init_helpers.c create mode 100644 arch/arc/lib/ints_low.S create mode 100644 arch/arc/lib/start.S
Signature · 1 line
2.1.0
PATCH 1/6 arc: merge common start-up code between ARC and ARCv2
Even though ARCompact and ARCv2 are not binary compatible most of assembly instructions are used in both. With this change we'll get rid of duplicate code.
Still IVTs are implemented differently so we're keeping them in separate files.
---
arch/arc/cpu/arcv1/Makefile | 2 +-
arch/arc/cpu/arcv1/ivt.S | 27 ++++
arch/arc/cpu/arcv2/Makefile | 2 +-
arch/arc/cpu/arcv2/ivt.S | 27 ++++
arch/arc/cpu/arcv2/start.S | 254 ------------------------------------
arch/arc/lib/Makefile | 1 +
arch/arc/{cpu/arcv1 => lib}/start.S | 63 ++++-----
7 files changed, 82 insertions(+), 294 deletions(-)
create mode 100644 arch/arc/cpu/arcv1/ivt.S
create mode 100644 arch/arc/cpu/arcv2/ivt.S
delete mode 100644 arch/arc/cpu/arcv2/start.S
rename arch/arc/{cpu/arcv1 => lib}/start.S (82%)arch/arc/cpu/arcv1/Makefile +1 -1
@@ -4,4 +4,4 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += start.o +obj-y += ivt.o
arch/arc/cpu/arcv1/ivt.S new file +27 -0
@@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +.section .ivt, "ax", at progbits +.align 4 +_ivt: + /* Critical system events */ + j _start /* 0 - 0x000 */ + j memory_error /* 1 - 0x008 */ + j instruction_error /* 2 - 0x010 */ + + /* Device interrupts */ +.rept 29 + j interrupt_handler /* 3:31 - 0x018:0xF8 */ +.endr + /* Exceptions */ + j EV_MachineCheck /* 0x100, Fatal Machine check (0x20) */ + j EV_TLBMissI /* 0x108, Intruction TLB miss (0x21) */ + j EV_TLBMissD /* 0x110, Data TLB miss (0x22) */ + j EV_TLBProtV /* 0x118, Protection Violation (0x23) + or Misaligned Access */ + j EV_PrivilegeV /* 0x120, Privilege Violation (0x24) */ + j EV_Trap /* 0x128, Trap exception (0x25) */ + j EV_Extension /* 0x130, Extn Intruction Excp (0x26) */
arch/arc/cpu/arcv2/Makefile +1 -1
@@ -4,4 +4,4 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += start.o +obj-y += ivt.o
arch/arc/cpu/arcv2/ivt.S new file +27 -0
@@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +.section .ivt, "a", at progbits +.align 4 + /* Critical system events */ +.word _start /* 0 - 0x000 */ +.word memory_error /* 1 - 0x008 */ +.word instruction_error /* 2 - 0x010 */ + + /* Exceptions */ +.word EV_MachineCheck /* 0x100, Fatal Machine check (0x20) */ +.word EV_TLBMissI /* 0x108, Intruction TLB miss (0x21) */ +.word EV_TLBMissD /* 0x110, Data TLB miss (0x22) */ +.word EV_TLBProtV /* 0x118, Protection Violation (0x23) + or Misaligned Access */ +.word EV_PrivilegeV /* 0x120, Privilege Violation (0x24) */ +.word EV_Trap /* 0x128, Trap exception (0x25) */ +.word EV_Extension /* 0x130, Extn Intruction Excp (0x26) */ + + /* Device interrupts */ +.rept 29 + j interrupt_handler /* 3:31 - 0x018:0xF8 */ +.endr
arch/arc/cpu/arcv2/start.S deleted +0 -254
254 lines not on this page · raw message
arch/arc/lib/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-y += memcpy-700.o obj-y += memset.o obj-y += reset.o obj-y += timer.o +obj-y += start.o obj-$(CONFIG_CMD_BOOTM) += bootm.o
arch/arc/lib/start.S renamed from arch/arc/cpu/arcv1/start.S +25 -38
134 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 2/6 arc: move low-level interrupt and exception handlers in a separate file
In reply to Alexey BrodkinThis separation makes maintenance of code easier because those low-level interrupt- or exception handling routines are pretty static and usually require not much care while start-up code is a subject of modifications and enhancements.
---
arch/arc/lib/Makefile | 1 +
arch/arc/lib/{start.S => ints_low.S} | 92 +---------------------
arch/arc/lib/start.S | 144 -----------------------------------
3 files changed, 2 insertions(+), 235 deletions(-)
copy arch/arc/lib/{start.S => ints_low.S} (50%)arch/arc/lib/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-y += memset.o obj-y += reset.o obj-y += timer.o obj-y += start.o +obj-y += ints_low.o obj-$(CONFIG_CMD_BOOTM) += bootm.o
arch/arc/lib/ints_low.S renamed from arch/arc/lib/start.S +1 -91
110 lines not on this page · raw message
arch/arc/lib/start.S +0 -144
156 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 3/6 arc: clean-up init procedure
In reply to Alexey BrodkinIntention behind this work was elimination of as much assembly-written code as it is possible.
In case of ARC we already have relocation fix-up implemented in C so why don't we use C for U-Boot copying, .bss zeroing etc.
It turned out x86 uses pretty similar approach so we re-used parts of code in "board_f.c" initially implemented for x86.
Now assembly usage during init is limited to stack- and frame-pointer setup before and after relocation.
--- arch/arc/include/asm/init_helpers.h | 12 ++++++ arch/arc/include/asm/relocate.h | 16 ++++++++ arch/arc/include/asm/u-boot-arc.h | 3 ++ arch/arc/lib/Makefile | 1 + arch/arc/lib/cpu.c | 13 ------- arch/arc/lib/init_helpers.c | 27 +++++++++++++ arch/arc/lib/relocate.c | 19 +++++++++ arch/arc/lib/start.S | 77 +++++++------------------------------ common/board_f.c | 8 ++-- 9 files changed, 95 insertions(+), 81 deletions(-) create mode 100644 arch/arc/include/asm/init_helpers.h create mode 100644 arch/arc/include/asm/relocate.h create mode 100644 arch/arc/lib/init_helpers.c
arch/arc/include/asm/init_helpers.h new file +12 -0
@@ -0,0 +1,12 @@ +/* +* Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _ASM_ARC_INIT_HELPERS_H +#define _ASM_ARC_INIT_HELPERS_H + +int init_cache_f_r (void ); + +#endif /* _ASM_ARC_INIT_HELPERS_H */
arch/arc/include/asm/relocate.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _ASM_ARC_RELOCATE_H +#define _ASM_ARC_RELOCATE_H + +#include <common.h> + +int copy_uboot_to_ram (void ); +int clear_bss (void ); +int do_elf_reloc_fixups (void ); + +#endif /* _ASM_ARC_RELOCATE_H */
arch/arc/include/asm/u-boot-arc.h +3 -0
@@ -9,4 +9,7 @@int arch_early_init_r (void ); +void board_init_f_r_trampoline (ulong ) __attribute__ ((noreturn)); +void board_init_f_r (void ) __attribute__ ((noreturn)); +#endif /* __ASM_ARC_U_BOOT_ARC_H__ */
arch/arc/lib/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-y += reset.o obj-y += timer.o obj-y += start.o obj-y += ints_low.o +obj-y += init_helpers.o obj-$(CONFIG_CMD_BOOTM) += bootm.o
arch/arc/lib/cpu.c +0 -13
@@ -12,19 +12,6 @@ DECLARE_GLOBAL_DATA_PTR;int arch_cpu_init (void ) { -#ifdef CONFIG_SYS_ICACHE_OFF -icache_disable (); -#else -icache_enable (); -invalidate_icache_all (); -#endif - -flush_dcache_all (); -#ifdef CONFIG_SYS_DCACHE_OFF -dcache_disable (); -#else -dcache_enable (); -#endif timer_init ();/* In simulation (ISS) "CHIPID" and "ARCNUM" are all "ff" */
arch/arc/lib/init_helpers.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> + +DECLARE_GLOBAL_DATA_PTR ; + +int init_cache_f_r (void ) +{ +#ifdef CONFIG_SYS_ICACHE_OFF +icache_disable (); +#else +icache_enable (); +invalidate_icache_all (); +#endif + +flush_dcache_all (); +#ifdef CONFIG_SYS_DCACHE_OFF +dcache_disable (); +#else +dcache_enable (); +#endif +return 0 ; +}
arch/arc/lib/relocate.c +19 -0
@@ -10,6 +10,25 @@DECLARE_GLOBAL_DATA_PTR ; +int copy_uboot_to_ram (void ) +{ +size_t len = (size_t )&__image_copy_end - (size_t )&__image_copy_start; + +memcpy ((void *)gd->relocaddr, (void *)&__image_copy_start, len); + +return 0 ; +} + +int clear_bss (void ) +{ +ulong dst_addr = (ulong )&__bss_start + gd->reloc_off; +size_t len = (size_t )&__bss_end - (size_t )&__bss_start; + +memset ((void *)dst_addr,0x00 , len); + +return 0 ; +} +/* * Base functionality is taken from x86 version with added ARC-specifics */
arch/arc/lib/start.S +13 -64
94 lines not on this page · raw message
common/board_f.c +4 -4
@@ -47,7 +47,7 @@#include <asm/errno.h> #include <asm/io.h> #include <asm/sections.h> -#ifdef CONFIG_X86 +#if defined(CONFIG_X86 ) || defined(CONFIG_ARC )#include <asm/init_helpers.h> #include <asm/relocate.h> #endif
@@ -760,7 +760,7 @@ static int jump_to_copy(void)* similarly for all archs. When we do generic relocation, hopefully * we can make all archs enable the dcache prior to relocation. */ -#ifdef CONFIG_X86 +#if defined(CONFIG_X86 ) || defined(CONFIG_ARC )/* * SDRAM and console are now initialised. The final stack can now * be setup in SDRAM. Code execution will continue in Flash, but
@@ -996,7 +996,7 @@ static init_fnc_t init_sequence_f[] = { INIT_FUNC_WATCHDOG_RESET reloc_fdt, setup_reloc, -#ifdef CONFIG_X86 +#if defined(CONFIG_X86 ) || defined(CONFIG_ARC ) copy_uboot_to_ram, clear_bss, do_elf_reloc_fixups,
@@ -1040,7 +1040,7 @@ void board_init_f(ulong boot_flags)#endif } -#ifdef CONFIG_X86 +#if defined(CONFIG_X86 ) || defined(CONFIG_ARC )/* * For now this code is only used on x86. *
Signature · 1 line
2.1.0
PATCH 4/6 arc: get rid of CONFIG_SYS_GENERIC_GLOBAL_DATA
In reply to Alexey BrodkinAs discussed on mailing list we're drifting away from CONFIG_SYS_GENERIC_GLOBAL_DATA in favour to use of board_init_f_mem() for global data.
So do this for ARC architecture.
--- arch/arc/include/asm/config.h | 1 - arch/arc/lib/start.S | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-)
arch/arc/include/asm/config.h +0 -1
@@ -8,7 +8,6 @@#define __ASM_ARC_CONFIG_H_#define CONFIG_SYS_GENERIC_BOARD -#define CONFIG_SYS_GENERIC_GLOBAL_DATA #define CONFIG_SYS_BOOT_RAMDISK_HIGH #define CONFIG_ARCH_EARLY_INIT_R
arch/arc/lib/start.S +6 -1
@@ -13,9 +13,14 @@ ENTRY(_start) /* Setup interrupt vector base that matches "__text_start" */ sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] - /* Setup stack pointer */ + /* Setup stack- and frame-pointers */ mov %sp, CONFIG_SYS_INIT_SP_ADDR mov %fp, %sp + mov %r0, %sp + bl board_init_f_mem + /* Update stack- and frame-pointers */ + mov %sp, %r0 + mov %fp, %sp /* Zero the one and only argument of "board_init_f" */ mov_s %r0, 0
Signature · 1 line
2.1.0
PATCH 5/6 arc: minor fixes in Kconfig
In reply to Alexey Brodkin [1] Fix misspeling in ARC_CACHE_LINE_SHIFT dependency, now cache-line
lenth selection is correctly enabled if either I$ or D$ are enabled.
[2] Add dummy entry to target list to make sure target type is always
mentioned in defconfig. Otherwise defconfig for the first target in the list will not have target name and later on with addition of the new target on top of the list in Kconfig will lead to corrupted configuration expanded from defconfig.
--- arch/arc/Kconfig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arc/Kconfig +9 -1
@@ -123,7 +123,7 @@ config ARC_CACHE_LINE_SHIFT int "Cache Line Length (as power of 2)" range 5 7 default "6" - depends on !SYS_DCACHE_OFF || !SYS_DCACHE_OFF + depends on !SYS_DCACHE_OFF || !SYS_ICACHE_OFF help Starting with ARC700 4.9, Cache line length is configurable, This option specifies "N", with Line-len = 2 power N
@@ -133,6 +133,14 @@ config ARC_CACHE_LINE_SHIFT choice prompt "Target select" +config TARGET_DUMMY + bool "Dummy target" + help + Please select one of real target boards below! + This target is only meant to force "makedefconfig" to put + TARGET_xxx in defconfig even this is the first target from the list + below. + config TARGET_TB100 bool "Support tb100"
Signature · 1 line
2.1.0
PATCH 6/6 arc: re-generate defconfigs
In reply to Alexey BrodkinBefore that moment our defconfigs were manually modified with addition of new options. That means once anybody wants to addd another option and re-genarate defconfig with "make defconfig" there will be lots of differences. So to make future modifications more clean we'll do bulk re-generation right away.
--- configs/arcangel4-be_defconfig | 4 ++-- configs/arcangel4_defconfig | 2 +- configs/axs101_defconfig | 6 +++--- configs/axs103_defconfig | 4 ++-- configs/tb100_defconfig | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-)
configs/arcangel4-be_defconfig +2 -2
@@ -1,5 +1,5 @@ CONFIG_ARC=y -CONFIG_TARGET_ARCANGEL4=y -CONFIG_SYS_CLK_FREQ=70000000 CONFIG_CPU_BIG_ENDIAN=y +CONFIG_TARGET_ARCANGEL4=y CONFIG_SYS_TEXT_BASE=0x81000000 +CONFIG_SYS_CLK_FREQ=70000000
configs/arcangel4_defconfig +1 -1
@@ -1,4 +1,4 @@ CONFIG_ARC=y CONFIG_TARGET_ARCANGEL4=y -CONFIG_SYS_CLK_FREQ=70000000 CONFIG_SYS_TEXT_BASE=0x81000000 +CONFIG_SYS_CLK_FREQ=70000000
configs/axs101_defconfig +3 -3
@@ -1,6 +1,6 @@ CONFIG_ARC=y +CONFIG_SYS_DCACHE_OFF=y +CONFIG_ARC_CACHE_LINE_SHIFT=5 CONFIG_TARGET_AXS101=y +CONFIG_SYS_TEXT_BASE=0x81000000 CONFIG_SYS_CLK_FREQ=750000000 -CONFIG_ARC_CACHE_LINE_SHIFT=5 -CONFIG_SYS_DCACHE_OFF=y -CONFIG_SYS_TEXT_BASE=0x81000000
configs/axs103_defconfig +2 -2
@@ -1,5 +1,5 @@ -CONFIG_SYS_TEXT_BASE=0x81000000 -CONFIG_SYS_CLK_FREQ=50000000 CONFIG_ARC=y CONFIG_ISA_ARCV2=y CONFIG_TARGET_AXS101=y +CONFIG_SYS_TEXT_BASE=0x81000000 +CONFIG_SYS_CLK_FREQ=50000000
configs/tb100_defconfig +2 -2
@@ -1,5 +1,5 @@ CONFIG_ARC=y -CONFIG_TARGET_TB100=y -CONFIG_SYS_CLK_FREQ=500000000 CONFIG_ARC_CACHE_LINE_SHIFT=5 +CONFIG_TARGET_TB100=y CONFIG_SYS_TEXT_BASE=0x84000000 +CONFIG_SYS_CLK_FREQ=500000000
Signature · 1 line
2.1.0
PATCH 6/6 arc: re-generate defconfigs
Hi Alexey,
2015-03-17 21:13 GMT+09:00 Alexey Brodkin <[email protected]>:
Quoted 2 lines
Before that moment our defconfigs were manually modified with addition of new options. That means once anybody wants to addd another option and
I just noticed a typo. s/addd/add/
You need not to submit v2 for such a minor error. Please fix it when you apply this patch, if you remember.
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH 6/6 arc: re-generate defconfigs
Hello Masahiro-san,
Quoted 10 lines · Masahiro Yamada
Hi Alexey,
2015-03-17 21:13 GMT+09:00 Alexey Brodkin <[email protected]>:
Quoted 2 lines
Before that moment our defconfigs were manually modified with addition of new options. That means once anybody wants to addd another option and
I just noticed a typo. s/addd/add/
You need not to submit v2 for such a minor error. Please fix it when you apply this patch, if you remember.
Thanks for catching this typo.
I was going to send v2 respin of entire series due to important fixes I've done recently and mentioned typo will be addressed there as well.
-Alexey