Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:44

0001 /*  LM32 startup code
0002  *
0003  *  This is the entry point on reset and when loading the
0004  *  executive from a bootloader.
0005  *
0006  *  The license and distribution terms for this file may be
0007  *  found in the file LICENSE in this distribution or at
0008  *  http://www.rtems.org/license/LICENSE.
0009  *
0010  *  Jukka Pietarinen <jukka.pietarinen@mrf.fi>, 2008,
0011  *  Micro-Research Finland Oy
0012  */
0013 
0014 #include "bspopts.h"
0015 
0016      .section .boot,"a",@progbits
0017      .align    4
0018 
0019      .globl  start
0020      .type   start,@function
0021      .globl  _start
0022      .type   _start,@function
0023      .globl  __start
0024      .type   __start,@function
0025      .globl  LatticeDDInit
0026      .type   LatticeDDInit,@function
0027      .globl  crt0
0028      .type   crt0,@function
0029 
0030 LatticeDDInit:
0031 __start:
0032 _start:
0033 start:
0034     /* Clear r0 */
0035     xor r0,r0,r0
0036     /* Disable interrupts */
0037     wcsr    IE, r0
0038     /* Mask all interrupts */
0039     wcsr    IM,r0
0040     /* Set exception base address */
0041     mvhi    r1, hi(start)
0042     ori r1, r1, lo(start)
0043     wcsr    EBA, r1
0044     bi  crt0
0045     nop
0046 /*
0047  * Unused handlers call debug handlers
0048  */
0049 breakpoint_handler:
0050     rcsr    r7, DEBA
0051     addi    r7, r7, 32
0052     b   r7
0053     nop
0054     nop
0055     nop
0056     nop
0057     nop
0058 instruction_bus_error_handler:
0059     rcsr    r7, DEBA
0060     addi    r7, r7, 64
0061     b   r7
0062     nop
0063     nop
0064     nop
0065     nop
0066     nop
0067 watchpoint_handler:
0068     rcsr    r7, DEBA
0069     addi    r7, r7, 96
0070     b   r7
0071     nop
0072     nop
0073     nop
0074     nop
0075     nop
0076 data_bus_error_handler:
0077     rcsr    r7, DEBA
0078     addi    r7, r7, 128
0079     b   r7
0080     nop
0081     nop
0082     nop
0083     nop
0084     nop
0085 divide_by_zero_handler:
0086     rcsr    r7, DEBA
0087     addi    r7, r7, 160
0088     b   r7
0089     nop
0090     nop
0091     nop
0092     nop
0093     nop
0094 interrupt_handler:
0095     .extern _ISR_Handler
0096     mvhi    r0, hi(_ISR_Handler)
0097     ori r0, r0, lo(_ISR_Handler)
0098     b   r0
0099     nop
0100     nop
0101     nop
0102     nop
0103     nop
0104 system_call_handler:
0105     rcsr    r7, DEBA
0106     addi    r7, r7, 224
0107     b   r7
0108     nop
0109     nop
0110     nop
0111     nop
0112     nop
0113 
0114 crt0:
0115     /* Flush data cache */
0116     addi    r1, r0, 1
0117     wcsr    DCC, r1
0118     nop
0119     nop
0120     nop
0121     nop
0122     /* Flush Instruction Cache */
0123     wcsr    ICC, r1
0124     nop
0125     nop
0126     nop
0127     nop
0128     /* Initialize stack pointer */
0129     mvhi    sp, hi(_ISR_Stack_area_end-4)
0130     ori sp, sp, lo(_ISR_Stack_area_end-4)
0131     /* Initialize global pointer */
0132     mvhi    gp, hi(_edata)
0133     ori gp, gp, lo(_edata)
0134     /* Clear bss */
0135     mvhi    r1, hi(_clear_start)
0136     ori r1, r1, lo(_clear_start)
0137     mvhi    r3, hi(_clear_end)
0138     ori r3, r3, lo(_clear_end)
0139 .clear_bss:
0140     be  r1, r3, .end_clear_bss
0141     sw  (r1+0), r0
0142     addi    r1, r1, 4
0143     bi  .clear_bss
0144 .end_clear_bss:
0145     mvi r1, 0
0146     be  r4, r0, .no_rescue
0147     mvhi    r1, hi(.rescue_str)
0148     ori r1, r1, lo(.rescue_str)
0149 .no_rescue:
0150     mvhi    r7, hi(boot_card)
0151     ori r7, r7, lo(boot_card)
0152     call    r7
0153     # boot_card returns when RTEMS is shutdown
0154 .dead_end:
0155     bi  .dead_end
0156 
0157 .section .rodata
0158 .rescue_str:
0159     .ascii "rescue"
0160