2
0

head.S 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "sys.h"
  2. #include "picorv32.h"
  3. #define GP_IS_ZERO 1
  4. // The linker ensures that section .init is first
  5. .section ".init.reset","ax"
  6. .globl _reset
  7. _reset:
  8. rdtime s0 // Record timer at reset
  9. j __start
  10. .type _reset, @function
  11. .size _reset, . - _reset
  12. .section ".init","ax"
  13. .globl __start
  14. __start:
  15. li sp,STACK_TOP // Cheaper than using la sp,___stack_top
  16. not t0,zero
  17. maskirq zero,t0,zero
  18. #if !GP_IS_ZERO
  19. .option push
  20. .option norelax // Can't make gp references to set up gp...
  21. la gp, __global_pointer$
  22. .option pop
  23. #else
  24. // Zero gp (linker will usually replace with the zero reg)
  25. li gp,0
  26. #endif
  27. addqxi gp,gp,0 // Set gp for interrupt code too
  28. la a0,__BSS_START__
  29. li a1,0
  30. la a2,__BSS_LEN__
  31. jal memset
  32. sw s0, time_zero, t0
  33. j main
  34. .type __start, @function
  35. .size __start, . - __start
  36. .pushsection ".sbss","a"
  37. .balign 4
  38. .globl time_zero
  39. time_zero:
  40. .space 4
  41. .type time_zero, @object
  42. .size time_zero, . - time_zero
  43. .popsection
  44. .section ".stack","aw",@nobits
  45. .balign 4
  46. .globl ___stack_bottom
  47. ___stack:
  48. .space STACK_SIZE
  49. .type ___stack, @object
  50. .size ___stack, STACK_SIZE
  51. .globl ___stack_top
  52. ___stack_top: