source: rtems/c/src/lib/libbsp/nios2/nios2_iss/start/start.S @ 783669fc

4.104.114.84.95
Last change on this file since 783669fc was 783669fc, checked in by Joel Sherrill <joel.sherrill@…>, on 08/09/06 at 20:57:11

2006-08-09 Kolja Waschk <waschk@…>

  • ChangeLog?, Makefile.am, README, acinclude.m4, configure.ac, nios2_iss/ChangeLog, nios2_iss/Makefile.am, nios2_iss/bsp_specs, nios2_iss/configure.ac, nios2_iss/nios2_iss.ptf, nios2_iss/nios2_iss.sh, nios2_iss/times, nios2_iss/console/console.c, nios2_iss/include/bsp.h, nios2_iss/include/bspopts.h.in, nios2_iss/include/coverhd.h, nios2_iss/include/tm27.h, nios2_iss/shmsupp/addrconv.c, nios2_iss/shmsupp/getcfg.c, nios2_iss/shmsupp/lock.c, nios2_iss/shmsupp/mpisr.c, nios2_iss/start/crtnn.s, nios2_iss/start/start.S, nios2_iss/startup/bspclean.c, nios2_iss/startup/bspstart.c, nios2_iss/startup/linkcmds, nios2_iss/startup/main.c, nios2_iss/startup/setvec.c, nios2_iss/timer/timer.c: New files.
  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*  NIOS2 startup code
2 *
3 *  This is the entry point on reset and when loading the
4 *  executive from a bootloader.
5 *
6 *  COPYRIGHT (c) 2005-2006 Kolja Waschk rtemsdev/ixo.de
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15     .section .entry
16     .align    3
17     movhi  et, %hiadj(start)
18     addi   et, et, %lo(start)
19     jmp    et
20
21     .section .irq
22     .align 3
23     movhi  et, %hiadj(_exception_vector)
24     addi   et, et, %lo(_exception_vector)
25     jmp    et
26
27    .section .text
28    .align  3
29    .globl  start
30    .type   start,@function
31
32    .extern _exception_vector
33
34start:
35    #------------------------------------------------------
36    # disable interrupts
37    wrctl status, zero
38    wrctl ienable, zero
39
40    #------------------------------------------------------
41    # invalidate instruction cache
42    mov r2, r0
43    movhi r3, %hi(__nios2_icache_size)
44    ori r3, r3, %lo(__nios2_icache_size)
45icache_init_loop:
46    initi r2
47    addi r2, r2, __nios2_icache_line_size
48    bltu r2, r3, icache_init_loop
49
50    #------------------------------------------------------
51    # invalidate data cache
52    mov r2, r0
53    movhi r3, %hi(__nios2_dcache_size)
54    ori r3, r3, %lo(__nios2_dcache_size)
55dcache_init_loop:
56    initd 0(r2)
57    addi r2, r2, __nios2_dcache_line_size
58    bltu r2, r3, dcache_init_loop
59
60    #------------------------------------------------------
61    # initialize stack pointer
62    movhi   sp, %hiadj(__alt_stack_pointer - 4)
63    addi    sp, sp, %lo(__alt_stack_pointer - 4)
64
65    # initialize global pointer
66    movhi gp, %hiadj(_gp)
67    addi gp, gp, %lo(_gp)
68
69    # initialize exception tmp register
70    movhi et, %hiadj(_end)
71    addi et, et, %lo(_end)
72
73    #------------------------------------------------------
74    # TODO: copy data from flash to RAM, if not there already
75    # For now its save to assume it is there already when we're
76    # loading code though JTAG into RAM-only system
77
78    # at least copy exception code to right place
79    movhi r2, %hiadj(__ram_exceptions_start)
80    addi r2, r2, %lo(__ram_exceptions_start)
81
82    movhi r3, %hiadj(brto_ev)
83    addi r3, r3, %lo(brto_ev)
84    ldw r4,  0(r3)
85    stw r4,  0(r2)
86    ldw r4,  4(r3)
87    stw r4,  4(r2)
88    ldw r4,  8(r3)
89    stw r4,  8(r2)
90    ldw r4, 12(r3)
91    stw r4, 12(r2)
92
93    #------------------------------------------------------
94    # clear bss
95    movhi r2, %hiadj(__bss_start)
96    addi r2, r2, %lo(__bss_start)
97
98    movhi r3, %hiadj(__bss_end)
99    addi r3, r3, %lo(__bss_end)
100
101    beq r2, r3, 1f
1020:
103    stw zero, (r2)
104    addi r2, r2, 4
105    bltu r2, r3, 0b
1061:
107    #------------------------------------------------------
108    # jump to (shared) boot_card (never comes back)
109    mov r4, zero
110    mov r5, zero
111    mov r6, zero
112    call    boot_card
113    # but just in case it does come back, stick here.
114_stuck_in_start:
115    br _stuck_in_start
116
117    #------------------------------------------------------
118    # code to be placed at exception address
119brto_ev:
120     movhi et, %hiadj(_exception_vector)
121     addi et, et, %lo(_exception_vector)
122     jmp et
123
124
Note: See TracBrowser for help on using the repository browser.