2 * (C) Copyright 2011, Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
3 * (C) Copyright 2011, Julius Baxter <julius@opencores.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 #include <asm-offsets.h>
23 #include <asm/spr-defs.h>
25 #define EXCEPTION_STACK_SIZE (128+128)
27 #define HANDLE_EXCEPTION \
28 l.addi r1, r1, -EXCEPTION_STACK_SIZE ;\
31 l.movhi r2,hi(_exception_handler) ;\
32 l.ori r2,r2,lo(_exception_handler) ;\
36 l.addi r1, r1, EXCEPTION_STACK_SIZE ;\
40 .section .vectors, "ax"
46 /* there is no guarantee r0 is hardwired to zero, clear it here */
48 /* reset stack and frame pointers */
52 /* set supervisor mode */
57 l.movhi r3,hi(__start) /* source start address */
58 l.ori r3,r3,lo(__start)
59 l.movhi r4,hi(_stext) /* dest start address */
60 l.ori r4,r4,lo(_stext)
61 l.movhi r5,hi(__end) /* dest end address */
70 l.addi r4,r4,4 /* delay slot */
72 #ifdef CONFIG_SYS_RELOCATE_VECTORS
73 /* Relocate vectors from 0xf0000000 to 0x00000000 */
74 l.movhi r4, 0xf000 /* source */
75 l.movhi r5, 0 /* destination */
76 l.addi r6, r5, CONFIG_SYS_VECTORS_LEN /* length */
86 l.ori r4,r4,lo(_start)
98 /* instruction page fault */
110 /* illegal instruction */
114 /* external interrupt */
206 /* Startup routine */
210 /* Init stack and frame pointers */
211 l.movhi r1, hi(CONFIG_SYS_INIT_SP_ADDR)
212 l.ori r1, r1, lo(CONFIG_SYS_INIT_SP_ADDR)
215 /* clear BSS segments */
216 l.movhi r4, hi(_bss_start)
217 l.ori r4, r4, lo(_bss_start)
218 l.movhi r5, hi(_bss_end)
219 l.ori r5, r5, lo(_bss_end)
226 /* Reset registers before jumping to board_init */
259 .size _start, .-_start
262 * Store state onto stack and call the real exception handler
265 .extern exception_handler
266 .type _exception_handler,@function
269 /* Store state (r2 and r9 already saved)*/
299 /* Save return address */
301 /* Call exception handler with the link address as argument */
302 l.jal exception_handler
304 /* Load return address */