OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [common/] [crt0.S] - Diff between revs 22 and 23

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 22 Rev 23
Line 39... Line 39...
 
 
 
 
// IO region
// IO region
.equ IO_BEGIN, 0xFFFFFF80 // start of processor-internal IO region
.equ IO_BEGIN, 0xFFFFFF80 // start of processor-internal IO region
 
 
// SYSINFO
 
.equ SYSINFO_DSPACE_BASE, 0xFFFFFFF4
 
.equ SYSINFO_DSPACE_SIZE, 0xFFFFFFFC
 
 
 
 
 
_start:
_start:
.cfi_startproc
.cfi_startproc
.cfi_undefined ra
.cfi_undefined ra
 
 
Line 66... Line 62...
  addi  x8,  x0, 0
  addi  x8,  x0, 0
  addi  x9,  x0, 0
  addi  x9,  x0, 0
//addi x10,  x0, 0
//addi x10,  x0, 0
//addi x11,  x0, 0
//addi x11,  x0, 0
//addi x12,  x0, 0
//addi x12,  x0, 0
  addi x13,  x0, 0
//addi x13,  x0, 0
  addi x14,  x0, 0
  addi x14,  x0, 0
  addi x15,  x0, 0
  addi x15,  x0, 0
 
 
 
 
// *********************************************************
// *********************************************************
// Setup stack pointer
// No interrupts, thanks
// *********************************************************
// *********************************************************
__crt0_stack_pointer_init:
__crt0_status_init:
  lw    x11, SYSINFO_DSPACE_BASE(zero) // data memory space base address
  li x10, 0x00001800    // clear mstatus and set mpp(1:0)
  lw    x12, SYSINFO_DSPACE_SIZE(zero) // data memory space size
  csrrw zero, mstatus, x10
  add   sp, x11, x12
  csrrw zero, mie, zero // clear mie
  addi  sp, sp, -4 // stack pointer = last entry
 
  addi  fp, sp, 0  // frame pointer = stack pointer
 
 
 
 
 
// *********************************************************
// *********************************************************
// Setup global pointer
// Setup pointers using linker script symbol
// *********************************************************
// *********************************************************
__crt0_global_pointer_init:
__crt0_pointer_init:
.option push
.option push
.option norelax
.option norelax
  la gp, __global_pointer$
  la    sp, __crt0_stack_begin
 
  andi  sp, sp, 0xfffffffc // make sure this is aligned
 
  addi  fp, sp, 0          // frame pointer = stack pointer
 
  la gp, __global_pointer$ // global pointer
.option pop
.option pop
 
 
 
 
// *********************************************************
// *********************************************************
// Init trap handler base address
// Init trap handler base address
Line 115... Line 112...
  addi x11, x11, 4
  addi x11, x11, 4
  bne  zero, x11, __crt0_reset_io_loop
  bne  zero, x11, __crt0_reset_io_loop
 
 
 
 
// *********************************************************
// *********************************************************
// Clear .bss section (byte-wise)
// Clear .bss section (byte-wise) using linker script symbols
// *********************************************************
// *********************************************************
__crt0_clear_bss:
__crt0_clear_bss:
  la x11, __crt0_bss_start
  la x11, __crt0_bss_start
  la x12, __crt0_bss_end
  la x12, __crt0_bss_end
 
 
Line 131... Line 128...
 
 
__crt0_clear_bss_loop_end:
__crt0_clear_bss_loop_end:
 
 
 
 
// *********************************************************
// *********************************************************
// Copy initialized .data section from ROM to RAM (byte-wise)
// Copy initialized .data section from ROM to RAM (byte-wise) using linker script symbols
// *********************************************************
// *********************************************************
__crt0_copy_data:
__crt0_copy_data:
  la x11, __crt0_copy_data_src_begin  // start of data area (copy source)
  la x11, __crt0_copy_data_src_begin  // start of data area (copy source)
  la x12, __crt0_copy_data_dst_begin  // start of data area (copy destination)
  la x12, __crt0_copy_data_dst_begin  // start of data area (copy destination)
  la x13, __crt0_copy_data_dst_end    // last address of destination data area
  la x13, __crt0_copy_data_dst_end    // last address of destination data area
Line 187... Line 184...
  blt   x8, zero, __crt0_dummy_trap_handler_irq  // skip mepc modification if interrupt
  blt   x8, zero, __crt0_dummy_trap_handler_irq  // skip mepc modification if interrupt
 
 
  csrr  x8, mepc
  csrr  x8, mepc
 
 
// is compressed instruction?
// is compressed instruction?
 
__crt0_dummy_trap_handler_exc_c_check:
  lh    x9, 0(x8)   // get compressed instruction or lower 16 bits of uncompressed instruction that caused exception
  lh    x9, 0(x8)   // get compressed instruction or lower 16 bits of uncompressed instruction that caused exception
  andi  x9, x9, 3   // mask: isolate lowest 2 opcode bits (= 11 for uncompressed instructions)
  andi  x9, x9, 3   // mask: isolate lowest 2 opcode bits (= 11 for uncompressed instructions)
 
 
  addi  x8, x8, +2  // only this for compressed instructions
  addi  x8, x8, +2  // only this for compressed instructions
  csrw  mepc, x8    // set return address when compressed instruction
  csrw  mepc, x8    // set return address when compressed instruction
 
 
  addi  x8, zero, 3
  addi  x8, zero, 3
  bne   x8, x9, __crt0_dummy_trap_handler_irq // jump if compressed instruction
  bne   x8, x9, __crt0_dummy_trap_handler_irq // jump if compressed instruction
 
 
// is uncompressed instruction
// is uncompressed instruction
 
__crt0_dummy_trap_handler_exc_uncrompressed:
  csrr  x8, mepc
  csrr  x8, mepc
  addi  x8, x8, +2  // add another 2 (making +4) for uncompressed instructions
  addi  x8, x8, +2  // add another 2 (making +4) for uncompressed instructions
  csrw  mepc, x8
  csrw  mepc, x8
 
 
__crt0_dummy_trap_handler_irq:
__crt0_dummy_trap_handler_irq:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.