2
0

head.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include "sys.h"
  2. #include "picorv32.h"
  3. #define GP_IS_ZERO 1
  4. // The code in this file is sensitive to alignment, so
  5. // don't use compressed instructions (there are very few anyway)
  6. .option norvc
  7. // NULL pointer guard area
  8. // This needs to be an explicitly allocated section or the binary
  9. // memory initialization file ends up broken.
  10. //
  11. // This also contains a pointer to the ROM area associated
  12. // with this image. For a non-primary image it is patched to
  13. // the preferred value.
  14. .section ".null","a"
  15. .globl _NULL
  16. _NULL:
  17. .space 8
  18. .type _NULL, @object
  19. .size _NULL, . - _NULL
  20. .globl __dram_checksum
  21. __dram_checksum:
  22. .long 0 // Filled in post-link
  23. .type __dram_checksum, @object
  24. .size __dram_checksum, . - __dram_checksum
  25. .globl __rom_offset
  26. __rom_offset:
  27. .long ROM_OFFSET
  28. .type __rom_offset, @object
  29. .size __rom_offset, . - __rom_offset
  30. // The linker will always assign this to _PC_RESET
  31. .section ".init.reset","ax"
  32. .globl _reset
  33. _reset:
  34. rdtime s0 // Record timer at reset
  35. li sp,STACK_TOP // Cheaper than using la sp,___stack_top
  36. j __start
  37. .type _reset, @function
  38. .size _reset, . - _reset
  39. .section ".init","ax"
  40. .globl __start
  41. __start:
  42. not t0,zero
  43. maskirq zero,t0,zero
  44. #if !GP_IS_ZERO
  45. .option push
  46. .option norelax // Can't make gp references to set up gp...
  47. la gp, __global_pointer$
  48. .option pop
  49. #else
  50. // Zero gp (linker will usually replace with the zero reg)
  51. li gp,0
  52. #endif
  53. addqxi gp,gp,0 // Set gp for interrupt code too
  54. // Clear bss
  55. la a0,__BSS_START__
  56. la a1,__BSS_END__
  57. .L_clear_bss_loop:
  58. sw zero,(a0)
  59. sw zero,4(a0)
  60. sw zero,8(a0)
  61. sw zero,12(a0)
  62. sw zero,16(a0)
  63. sw zero,20(a0)
  64. sw zero,24(a0)
  65. sw zero,28(a0)
  66. addi a0,a0,32
  67. bltu a0,a1,.L_clear_bss_loop
  68. sw s0, time_zero, t0
  69. j main
  70. .type __start, @function
  71. .size __start, . - __start
  72. __sbss
  73. .balign 4
  74. .globl time_zero
  75. time_zero:
  76. .space 4
  77. .type time_zero, @object
  78. .size time_zero, . - time_zero
  79. .popsection
  80. // Time stamp definition as patched in by FPGA build
  81. .section ".datestamp","a"
  82. .globl __datestamp
  83. __datestamp:
  84. .space 32
  85. .type __datestamp, @object
  86. .size __datestamp, . - __datestamp
  87. // Stack definition
  88. .section ".stack","aw",@nobits
  89. .balign 4
  90. .globl ___stack_bottom
  91. ___stack:
  92. .space STACK_SIZE
  93. .type ___stack, @object
  94. .size ___stack, STACK_SIZE
  95. .globl ___stack_top
  96. ___stack_top: