|
@@ -1,27 +1,49 @@
|
|
|
#include "sys.h"
|
|
|
#include "picorv32.h"
|
|
|
|
|
|
+#define GP_IS_ZERO 1
|
|
|
+
|
|
|
// The linker ensures that section .init is first
|
|
|
.section ".init.reset","ax"
|
|
|
.globl _reset
|
|
|
_reset:
|
|
|
- rdtime t0 // Record timer at reset
|
|
|
+ rdtime s0 // Record timer at reset
|
|
|
+ j __start
|
|
|
+ .type _reset, @function
|
|
|
+ .size _reset, . - _reset
|
|
|
+
|
|
|
+ .section ".init","ax"
|
|
|
+ .globl __start
|
|
|
+__start:
|
|
|
li sp,STACK_TOP // Cheaper than using la sp,___stack_top
|
|
|
+ not t0,zero
|
|
|
+ maskirq zero,t0,zero
|
|
|
+#if !GP_IS_ZERO
|
|
|
.option push
|
|
|
.option norelax // Can't make gp references to set up gp...
|
|
|
la gp, __global_pointer$
|
|
|
.option pop
|
|
|
+#else
|
|
|
+ // Zero gp (linker will usually replace with the zero reg)
|
|
|
+ li gp,0
|
|
|
+#endif
|
|
|
addqxi gp,gp,0 // Set gp for interrupt code too
|
|
|
- sw t0, time_zero, t1
|
|
|
- j _start
|
|
|
- .type _reset, @function
|
|
|
- .size _reset, . - _reset
|
|
|
|
|
|
- .pushsection ".sdata","a"
|
|
|
+ la a0,__BSS_START__
|
|
|
+ li a1,0
|
|
|
+ la a2,__BSS_LEN__
|
|
|
+ jal memset
|
|
|
+
|
|
|
+ sw s0, time_zero, t0
|
|
|
+ j main
|
|
|
+ .type __start, @function
|
|
|
+ .size __start, . - __start
|
|
|
+
|
|
|
+ .pushsection ".sbss","a"
|
|
|
.balign 4
|
|
|
.globl time_zero
|
|
|
time_zero:
|
|
|
- .long 0
|
|
|
+ .space 4
|
|
|
.type time_zero, @object
|
|
|
.size time_zero, . - time_zero
|
|
|
.popsection
|