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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [common/] [crt0.S] - Diff between revs 11 and 12

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

Rev 11 Rev 12
Line 40... Line 40...
  .section .text
  .section .text
  .balign 4
  .balign 4
  .global _start
  .global _start
 
 
 
 
  // custom CSRs
 
  .set CSR_MISPACEBASE, 0xfc4  // CUSTOM (r/-): Base address of instruction memory space (via MEM_ISPACE_BASE generic) */
 
  .set CSR_MDSPACEBASE, 0xfc5  // CUSTOM (r/-): Base address of data memory space (via MEM_DSPACE_BASE generic) */
 
  .set CSR_MISPACESIZE, 0xfc6  // CUSTOM (r/-): Total size of instruction memory space in byte (via MEM_ISPACE_SIZE generic) */
 
  .set CSR_MDSPACESIZE, 0xfc7  // CUSTOM (r/-): Total size of data memory space in byte (via MEM_DSPACE_SIZE generic) */
 
 
 
  // IO region
  // IO region
  .set IO_BEGIN,    0xFFFFFF80  // start of processor-internal IO region
  .set IO_BEGIN,    0xFFFFFF80  // start of processor-internal IO region
  .set MTIMECMP_LO, 0xFFFFFF98
 
  .set MTIMECMP_HI, 0xFFFFFF9C
  // SYSINFO
 
  .set SYSINFO_DSPACE_BASE, 0xFFFFFFF4
 
  .set SYSINFO_DSPACE_SIZE, 0xFFFFFFFC
 
 
 
 
_start:
_start:
  .cfi_startproc
  .cfi_startproc
  .cfi_undefined ra
  .cfi_undefined ra
Line 112... Line 108...
 
 
// *********************************************************
// *********************************************************
// Setup stack pointer
// Setup stack pointer
// *********************************************************
// *********************************************************
__crt0_stack_pointer_init:
__crt0_stack_pointer_init:
  csrr  x11, CSR_MDSPACEBASE // data memory space base address
  lw    x11, SYSINFO_DSPACE_BASE(zero) // data memory space base address
  csrr  x12, CSR_MDSPACESIZE // data memory space size
  lw    x12, SYSINFO_DSPACE_SIZE(zero) // data memory space size
  add   sp, x11, x12
  add   sp, x11, x12
  addi  sp, sp, -4 // stack pointer = last entry
  addi  sp, sp, -4 // stack pointer = last entry
  addi  fp, sp, 0  // frame pointer = stack pointer
  addi  fp, sp, 0  // frame pointer = stack pointer
 
 
 
 
Line 136... Line 132...
// *********************************************************
// *********************************************************
__crt0_neorv32_rte_init:
__crt0_neorv32_rte_init:
  la    x11, __crt0_neorv32_rte
  la    x11, __crt0_neorv32_rte
  csrw  mtvec, x11 // set address of first-level exception handler
  csrw  mtvec, x11 // set address of first-level exception handler
 
 
  csrr  x11, CSR_MDSPACEBASE // data memory space base address
  lw    x11, SYSINFO_DSPACE_BASE(zero) // data memory space base address
  la    x12, __crt0_neorv32_rte_dummy_hanlder
  la    x12, __crt0_neorv32_rte_dummy_hanlder
  li    x13, 2*16  // number of entries (16xEXC, 16xIRQ)
  li    x13, 2*16  // number of entries (16xEXC, 16xIRQ)
 
 
__crt0_neorv32_rte_init_loop:
__crt0_neorv32_rte_init_loop:
  sw  x12,  0(x11) // set dummy handler
  sw  x12,  0(x11) // set dummy handler
Line 160... Line 156...
__crt0_reset_io_loop:
__crt0_reset_io_loop:
  sw   zero, 0(x11)
  sw   zero, 0(x11)
  addi x11, x11, 4
  addi x11, x11, 4
  bne  zero, x11, __crt0_reset_io_loop
  bne  zero, x11, __crt0_reset_io_loop
 
 
  // set mtime_compare to MAX (to prevent an IRQ)
 
  li x11, -1
 
  sw x11, MTIMECMP_LO(zero)
 
  sw x11, MTIMECMP_HI(zero)
 
 
 
 
 
// *********************************************************
// *********************************************************
// Clear .bss section (byte-wise)
// Clear .bss section (byte-wise)
// *********************************************************
// *********************************************************
__crt0_clear_bss:
__crt0_clear_bss:
Line 225... Line 216...
 
 
 
 
// *********************************************************
// *********************************************************
// NEORV32 runtime environment: First-level exception/interrupt handler
// NEORV32 runtime environment: First-level exception/interrupt handler
// *********************************************************
// *********************************************************
 
.align 4
__crt0_neorv32_rte:
__crt0_neorv32_rte:
 
 
  // --------------------------------------------
  // --------------------------------------------
  // full context save
  // full context save
  // --------------------------------------------
  // --------------------------------------------
Line 277... Line 269...
  // --------------------------------------------
  // --------------------------------------------
  csrr  t0, mcause        // get cause code
  csrr  t0, mcause        // get cause code
 
 
  andi  t1, t0, 0x0f      // isolate cause ID
  andi  t1, t0, 0x0f      // isolate cause ID
  slli  t1, t1, 2         // make address offset
  slli  t1, t1, 2         // make address offset
  csrr  ra, CSR_MDSPACEBASE  // data memory space base address
  lw    ra, SYSINFO_DSPACE_BASE(zero)  // data memory space base address
  add   t1, t1, ra        // get vetor table entry address (EXC vectors)
  add   t1, t1, ra        // get vetor table entry address (EXC vectors)
 
 
  csrr  ra, mepc          // get return address
  csrr  ra, mepc          // get return address
 
 
  blt   t0, zero, __crt0_neorv32_rte_is_irq  // branch if this is an INTERRUPT
  blt   t0, zero, __crt0_neorv32_rte_is_irq  // branch if this is an INTERRUPT

powered by: WebSVN 2.1.0

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