2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
4 * SPDX-License-Identifier: GPL-2.0+
7 #include <asm-offsets.h>
9 #include <asm/arcregs.h>
12 * Note on the LD/ST addressing modes with address register write-back
16 * LD.a reg1, [reg2, x] => Pre Incr
17 * Eff Addr for load = [reg2 + x]
19 * LD.ab reg1, [reg2, x] => Post Incr
20 * Eff Addr for load = [reg2]
63 st %r0, [%sp, 8] /* ECR */
82 /* Critical system events */
83 j reset /* 0 - 0x000 */
84 j memory_error /* 1 - 0x008 */
85 j instruction_error /* 2 - 0x010 */
87 /* Device interrupts */
89 j interrupt_handler /* 3:31 - 0x018:0xF8 */
92 j EV_MachineCheck /* 0x100, Fatal Machine check (0x20) */
93 j EV_TLBMissI /* 0x108, Intruction TLB miss (0x21) */
94 j EV_TLBMissD /* 0x110, Data TLB miss (0x22) */
95 j EV_TLBProtV /* 0x118, Protection Violation (0x23)
96 or Misaligned Access */
97 j EV_PrivilegeV /* 0x120, Privilege Violation (0x24) */
98 j EV_Trap /* 0x128, Trap exception (0x25) */
99 j EV_Extension /* 0x130, Extn Intruction Excp (0x26) */
111 j do_instruction_error
114 /* Todo - save and restore CPU context when interrupts will be in use */
115 bl do_interrupt_handler
122 j do_machine_check_fault
138 j do_tlb_prot_violation
143 j do_privilege_violation
157 /* Setup interrupt vector base that matches "__text_start" */
158 sr __text_start, [ARC_AUX_INTR_VEC_BASE]
160 /* Setup stack pointer */
161 mov %sp, CONFIG_SYS_INIT_SP_ADDR
170 brlt %r0, %r1, clear_bss
172 /* Zero the one and only argument of "board_init_f" */
177 * void relocate_code (addr_sp, gd, addr_moni)
179 * This "function" does not return, instead it continues in RAM
180 * after relocating the monitor code.
190 * r0-r12 might be clobbered by C functions
191 * so we use r13-r16 for storage here
193 mov %r13, %r0 /* save addr_sp */
194 mov %r14, %r1 /* save addr of gd */
195 mov %r15, %r2 /* save addr of destination */
197 mov %r16, %r2 /* %r9 - relocation offset */
198 sub %r16, %r16, __image_copy_start
200 /* Set up the stack */
205 /* Check if monitor is loaded right in place for relocation */
206 mov %r0, __image_copy_start
207 cmp %r0, %r15 /* skip relocation if code loaded */
208 bz do_board_init_r /* in target location already */
210 /* Copy data (__image_copy_start - __image_copy_end) to new location */
212 mov %r2, __image_copy_end
213 sub %r2, %r2, %r0 /* r3 <- amount of bytes to copy */
214 asr %r2, %r2, 2 /* r3 <- amount of words to copy */
221 /* Fix relocations related issues */
222 bl do_elf_reloc_fixups
223 #ifndef CONFIG_SYS_ICACHE_OFF
224 bl invalidate_icache_all
226 #ifndef CONFIG_SYS_DCACHE_OFF
230 /* Update position of intterupt vector table */
231 lr %r0, [ARC_AUX_INTR_VEC_BASE] /* Read current position */
232 add %r0, %r0, %r16 /* Update address */
233 sr %r0, [ARC_AUX_INTR_VEC_BASE] /* Write new position */
236 /* Prepare for exection of "board_init_r" in relocated monitor */
237 mov %r2, board_init_r /* old address of "board_init_r()" */
238 add %r2, %r2, %r16 /* new address of "board_init_r()" */
239 mov %r0, %r14 /* 1-st parameter: gd_t */
240 mov %r1, %r15 /* 2-nd parameter: dest_addr */