startup.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2020-2020, BLUETRUM Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "ab32vg1.h"
  7. .set _memcpy, 0x84044
  8. .global _start
  9. .section .reset, "ax"
  10. _start:
  11. la tp, _tp
  12. la gp, _gp
  13. //load comm
  14. la a0, __comm_vma
  15. la a1, __comm_lma
  16. la a2, __comm_size
  17. call _memcpy
  18. //load ram1
  19. la a0, __ram1_vma
  20. la a1, __ram1_lma
  21. la a2, __ram1_size
  22. call _memcpy
  23. la a0, __irq_stack_start //Stack清成0x23
  24. li a1, 0x23
  25. la a2, __irq_stack_size
  26. call rt_memset
  27. la ra, __irq_stack
  28. lui a5, 0x1
  29. sw zero, -1920(a5)
  30. sw zero, -1916(a5)
  31. //clear bss
  32. la a0, __bss_start
  33. li a1, 0
  34. la a2, __bss_size
  35. call rt_memset
  36. call cache_init
  37. la a0, __comm_vma
  38. sw a0, PICADR(zero)
  39. call entry
  40. la ra, __exception
  41. jr ra
  42. .section .vector, "ax"
  43. .org 0x10
  44. __exception:
  45. li sp, 0x10600 //出错后,不破坏错误点的堆栈数据
  46. jal exception_isr
  47. 1: j 1b
  48. mret
  49. .org 0x40
  50. jal x0, low_prio_irq
  51. .org 0x80
  52. #define METHOD 1
  53. #if METHOD == 1
  54. addi sp, sp, -6*4
  55. # lw a0, PICEN(zero)
  56. lw a1, EPC(zero)
  57. lw a2, EPICCON(zero)
  58. # sw a0, 3*4(sp)
  59. sw a1, 4*4(sp)
  60. sw a2, 5*4(sp)
  61. # andi a0, a0, 1
  62. # sw a0, PICEN(zero)
  63. li a2, 0
  64. sw a2, EPICCON(zero)
  65. la a0, 0f
  66. sw a0, EPC(zero)
  67. j isr_cache
  68. 0:
  69. sw a0, 0(sp)
  70. sw a1, 4(sp)
  71. sw a2, 8(sp)
  72. # lw a0, 3*4(sp)
  73. lw a1, 4*4(sp)
  74. lw a2, 5*4(sp)
  75. # sw a0, PICEN(zero)
  76. sw a1, EPC(zero)
  77. sw a2, EPICCON(zero)
  78. lw a0, 0(sp)
  79. lw a1, 4(sp)
  80. lw a2, 8(sp)
  81. addi sp, sp, 6*4
  82. mret
  83. #endif
  84. .global cpu_irq_comm
  85. cpu_irq_comm:
  86. la a5, __irq_stack
  87. mv sp, a5
  88. j cpu_irq_comm_do
  89. ret
  90. .global _tp
  91. .set _tp, 0x84800