/* Custom CSR definitions */ /* Reset vector */ .section .init,"ax",@progbits .global _start .align 8 _start: /* Initialize GP */ .option push .option norelax la gp, __global_pointer$ .option pop csrw mie, x0 csrw mip, x0 li t0, 0x70013 csrw 0x7c2, t0 /* MCOR */ li t0, 0 csrw 0x7c1, t0 /* MHCR */ /* Enable FP */ li t0, 0xa00007900 csrw mstatus, t0 /* Initialize SP */ la sp, __stack_top /* Data section has been copied by framework. */ clear_bss: /* Clear bss section */ la a0, _sbss la a1, _ebss bgeu a0, a1, main_entry loop_clear_bss: sd zero, (a0) addi a0, a0, 8 bltu a0, a1, loop_clear_bss /* Exception system */ la t0, vec_base addi t0, t0, 1 csrw mtvec, t0 main_entry: jal SystemInit jal main dead_loop: j dead_loop .option push .option norvc .align 8 vec_base: j Exception_Handler /* 00 Exception */ j S_Software_IRQHandler /* 01 Supervisor software interrupt */ j Default_Handler /* 02 Reserved */ j M_Software_IRQHandler /* 03 Machine software interrupt */ j Default_Handler /* 04 Reserved */ j S_Timer_IRQHandler /* 05 Supervisor timer interrupt */ j Default_Handler /* 06 Reserved */ j M_Timer_IRQHandler /* 07 Machine timer interrupt */ .option pop .weak Exception_Handler .weak S_Software_IRQHandler .weak M_Software_IRQHandler .weak S_Timer_IRQHandler .weak M_Timer_IRQHandler .align 8 Exception_Handler: S_Software_IRQHandler: M_Software_IRQHandler: S_Timer_IRQHandler: M_Timer_IRQHandler: j Default_Handler