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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • 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.org/license/LICENSE.
11 */
12
13     .section .entry
14     .align    3
15     movhi  et, %hiadj(start)
16     addi   et, et, %lo(start)
17     jmp    et
18
19     .section .irq
20     .align 3
21     movhi  et, %hiadj(_exception_vector)
22     addi   et, et, %lo(_exception_vector)
23     jmp    et
24
25    .section .text
26    .align  3
27    .globl  start
28    .type   start,@function
29
30    .extern _exception_vector
31
32start:
33    #------------------------------------------------------
34    # disable interrupts
35    wrctl status, zero
36    wrctl ienable, zero
37
38    #------------------------------------------------------
39    # invalidate instruction cache
40    mov r2, r0
41    movhi r3, %hi(__nios2_icache_size)
42    ori r3, r3, %lo(__nios2_icache_size)
43icache_init_loop:
44    initi r2
45    addi r2, r2, __nios2_icache_line_size
46    bltu r2, r3, icache_init_loop
47
48    #------------------------------------------------------
49    # invalidate data cache
50    mov r2, r0
51    movhi r3, %hi(__nios2_dcache_size)
52    ori r3, r3, %lo(__nios2_dcache_size)
53dcache_init_loop:
54    initd 0(r2)
55    addi r2, r2, __nios2_dcache_line_size
56    bltu r2, r3, dcache_init_loop
57
58    #------------------------------------------------------
59    # initialize stack pointer
60    movhi   sp, %hiadj(__alt_stack_pointer - 4)
61    addi    sp, sp, %lo(__alt_stack_pointer - 4)
62
63    # initialize global pointer
64    movhi gp, %hiadj(_gp)
65    addi gp, gp, %lo(_gp)
66
67    # initialize exception tmp register
68    movhi et, %hiadj(_end)
69    addi et, et, %lo(_end)
70
71    #------------------------------------------------------
72    # TODO: copy data from flash to RAM, if not there already
73    # For now its save to assume it is there already when we're
74    # loading code though JTAG into RAM-only system
75
76    # at least copy exception code to right place
77    movhi r2, %hiadj(__ram_exceptions_start)
78    addi r2, r2, %lo(__ram_exceptions_start)
79
80    movhi r3, %hiadj(brto_ev)
81    addi r3, r3, %lo(brto_ev)
82    ldw r4,  0(r3)
83    stw r4,  0(r2)
84    ldw r4,  4(r3)
85    stw r4,  4(r2)
86    ldw r4,  8(r3)
87    stw r4,  8(r2)
88    ldw r4, 12(r3)
89    stw r4, 12(r2)
90
91    #------------------------------------------------------
92    # clear bss
93    movhi r2, %hiadj(__bss_start)
94    addi r2, r2, %lo(__bss_start)
95
96    movhi r3, %hiadj(__bss_end)
97    addi r3, r3, %lo(__bss_end)
98
99    beq r2, r3, 1f
1000:
101    stw zero, (r2)
102    addi r2, r2, 4
103    bltu r2, r3, 0b
1041:
105    #------------------------------------------------------
106    # jump to (shared) boot_card (never comes back)
107    mov r4, zero
108    mov r5, zero
109    mov r6, zero
110    call    boot_card
111    # but just in case it does come back, stick here.
112_stuck_in_start:
113    br _stuck_in_start
114
115    #------------------------------------------------------
116    # code to be placed at exception address
117brto_ev:
118     movhi et, %hiadj(_exception_vector)
119     addi et, et, %lo(_exception_vector)
120     jmp et
121
122
Note: See TracBrowser for help on using the repository browser.