Commit 20a58ac0d8e09d0bf1a74c6b68fea22784512b51

Authored by Igor Guryanov
Committed by Alexey Brodkin
1 parent dcb431e723

arc: introduce separate section for interrupt vector table

Even though existing implementation works fine in preparation to
submission of ARCv2 architecture we need this change.

In case of ARCv2 interrupt vector table consists of just addresses
of corresponding handlers. And if those addresses will be in .text
section then assembler will encode them as everything in .text section
as middle-endian and then on real execution CPU will read swapped
addresses and will jump into the wild.

Once introduced new section is situated so .text section remains the
first which allows us to use common linker option for linking everything
to a specified CONFIG_SYS_TEXT_BASE.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Igor Guryanov <guryanov@synopsys.com>

Showing 7 changed files with 46 additions and 31 deletions Side-by-side Diff

... ... @@ -2,8 +2,6 @@
2 2 # SPDX-License-Identifier: GPL-2.0+
3 3 #
4 4  
5   -head-y := arch/arc/cpu/$(CPU)/start.o
6   -
7 5 libs-y += arch/arc/cpu/$(CPU)/
8 6 libs-y += arch/arc/lib/
9 7  
arch/arc/cpu/arc700/Makefile
... ... @@ -4,11 +4,10 @@
4 4 # SPDX-License-Identifier: GPL-2.0+
5 5 #
6 6  
7   -extra-y += start.o
8   -
9 7 obj-y += cache.o
10 8 obj-y += cpu.o
11 9 obj-y += interrupts.o
12 10 obj-y += reset.o
  11 +obj-y += start.o
13 12 obj-y += timer.o
arch/arc/cpu/arc700/start.S
... ... @@ -88,11 +88,11 @@
88 88 #endif
89 89 .endm
90 90  
  91 +.section .ivt, "ax",@progbits
91 92 .align 4
92   -.globl _start
93   -_start:
  93 +_ivt:
94 94 /* Critical system events */
95   - j reset /* 0 - 0x000 */
  95 + j _start /* 0 - 0x000 */
96 96 j memory_error /* 1 - 0x008 */
97 97 j instruction_error /* 2 - 0x010 */
98 98  
... ... @@ -110,6 +110,28 @@
110 110 j EV_Trap /* 0x128, Trap exception (0x25) */
111 111 j EV_Extension /* 0x130, Extn Intruction Excp (0x26) */
112 112  
  113 +.text
  114 +.globl _start
  115 +_start:
  116 + /* Setup interrupt vector base that matches "__text_start" */
  117 + sr __ivt_start, [ARC_AUX_INTR_VEC_BASE]
  118 +
  119 + /* Setup stack pointer */
  120 + mov %sp, CONFIG_SYS_INIT_SP_ADDR
  121 + mov %fp, %sp
  122 +
  123 + /* Clear bss */
  124 + mov %r0, __bss_start
  125 + mov %r1, __bss_end
  126 +
  127 +clear_bss:
  128 + st.ab 0, [%r0, 4]
  129 + brlt %r0, %r1, clear_bss
  130 +
  131 + /* Zero the one and only argument of "board_init_f" */
  132 + mov_s %r0, 0
  133 + j board_init_f
  134 +
113 135 memory_error:
114 136 SAVE_ALL_SYS
115 137 SAVE_EXCEPTION_SOURCE
... ... @@ -163,27 +185,6 @@
163 185 SAVE_ALL_SYS
164 186 mov %r0, %sp
165 187 j do_extension
166   -
167   -
168   -reset:
169   - /* Setup interrupt vector base that matches "__text_start" */
170   - sr __text_start, [ARC_AUX_INTR_VEC_BASE]
171   -
172   - /* Setup stack pointer */
173   - mov %sp, CONFIG_SYS_INIT_SP_ADDR
174   - mov %fp, %sp
175   -
176   - /* Clear bss */
177   - mov %r0, __bss_start
178   - mov %r1, __bss_end
179   -
180   -clear_bss:
181   - st.ab 0, [%r0, 4]
182   - brlt %r0, %r1, clear_bss
183   -
184   - /* Zero the one and only argument of "board_init_f" */
185   - mov_s %r0, 0
186   - j board_init_f
187 188  
188 189 /*
189 190 * void relocate_code (addr_sp, gd, addr_moni)
arch/arc/cpu/arc700/u-boot.lds
... ... @@ -13,7 +13,6 @@
13 13 .text : {
14 14 *(.__text_start)
15 15 *(.__image_copy_start)
16   - CPUDIR/start.o (.text*)
17 16 *(.text*)
18 17 }
19 18  
... ... @@ -21,6 +20,20 @@
21 20 .text_end :
22 21 {
23 22 *(.__text_end)
  23 + }
  24 +
  25 + . = ALIGN(1024);
  26 + .ivt_start : {
  27 + *(.__ivt_start)
  28 + }
  29 +
  30 + .ivt :
  31 + {
  32 + *(.ivt)
  33 + }
  34 +
  35 + .ivt_end : {
  36 + *(.__ivt_end)
24 37 }
25 38  
26 39 . = ALIGN(4);
arch/arc/include/asm/sections.h
... ... @@ -10,6 +10,8 @@
10 10 #include <asm-generic/sections.h>
11 11  
12 12 extern ulong __text_end;
  13 +extern ulong __ivt_start;
  14 +extern ulong __ivt_end;
13 15  
14 16 #endif /* __ASM_ARC_SECTIONS_H */
arch/arc/lib/relocate.c
... ... @@ -44,7 +44,7 @@
44 44 #ifdef __LITTLE_ENDIAN__
45 45 /* If location in ".text" section swap value */
46 46 if ((unsigned int)offset_ptr_rom <
47   - (unsigned int)&__text_end)
  47 + (unsigned int)&__ivt_end)
48 48 val = (val << 16) | (val >> 16);
49 49 #endif
50 50  
... ... @@ -55,7 +55,7 @@
55 55 #ifdef __LITTLE_ENDIAN__
56 56 /* If location in ".text" section swap value */
57 57 if ((unsigned int)offset_ptr_rom <
58   - (unsigned int)&__text_end)
  58 + (unsigned int)&__ivt_end)
59 59 val = (val << 16) | (val >> 16);
60 60 #endif
61 61 memcpy(offset_ptr_ram, &val, sizeof(int));
arch/arc/lib/sections.c
... ... @@ -19,4 +19,6 @@
19 19 char __text_start[0] __attribute__((section(".__text_start")));
20 20 char __text_end[0] __attribute__((section(".__text_end")));
21 21 char __init_end[0] __attribute__((section(".__init_end")));
  22 +char __ivt_start[0] __attribute__((section(".__ivt_start")));
  23 +char __ivt_end[0] __attribute__((section(".__ivt_end")));