startup_gcc.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018/10/01 Bernard The first version
  9. * 2018/12/27 Jesven Add SMP support
  10. * 2020/6/12 Xim Port to QEMU and remove SMP support
  11. */
  12. #include <encoding.h>
  13. #include <cpuport.h>
  14. boot_hartid: .int
  15. .global boot_hartid
  16. .global _start
  17. .section ".start", "ax"
  18. _start:
  19. j 1f
  20. .word 0xdeadbeef
  21. .align 3
  22. .global g_wake_up
  23. g_wake_up:
  24. .dword 1
  25. .dword 0
  26. 1:
  27. /* save hartid */
  28. la t0, boot_hartid /* global varible rt_boot_hartid */
  29. mv t1, a0 /* get hartid in S-mode frome a0 register */
  30. sw t1, (t0) /* store t1 register low 4 bits in memory address which is stored in t0 */
  31. /* clear Interrupt Registers */
  32. csrw sie, 0
  33. csrw sip, 0
  34. /* set Trap Vector Base Address Register */
  35. la t0, trap_entry
  36. csrw stvec, t0
  37. li x1, 0
  38. li x2, 0
  39. li x3, 0
  40. li x4, 0
  41. li x5, 0
  42. li x6, 0
  43. li x7, 0
  44. li x8, 0
  45. li x9, 0
  46. li x10,0
  47. li x11,0
  48. li x12,0
  49. li x13,0
  50. li x14,0
  51. li x15,0
  52. li x16,0
  53. li x17,0
  54. li x18,0
  55. li x19,0
  56. li x20,0
  57. li x21,0
  58. li x22,0
  59. li x23,0
  60. li x24,0
  61. li x25,0
  62. li x26,0
  63. li x27,0
  64. li x28,0
  65. li x29,0
  66. li x30,0
  67. li x31,0
  68. /* set to disable FPU */
  69. li t0, SSTATUS_FS
  70. csrc sstatus, t0
  71. li t0, SSTATUS_SUM
  72. csrs sstatus, t0
  73. .option push
  74. .option norelax
  75. la gp, __global_pointer$
  76. .option pop
  77. /* removed SMP support here */
  78. la sp, __stack_start__
  79. li t0, __STACKSIZE__
  80. add sp, sp, t0
  81. csrw sscratch, sp
  82. call init_bss
  83. call sbi_init
  84. j primary_cpu_entry