startup_gcc.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #define SSTATUS_FS 0x00006000U /* initial state of FPU, clear to disable */
  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, 0x40000 // SUM in sstatus
  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. /**
  82. * sscratch is always zero on kernel mode
  83. */
  84. csrw sscratch, zero
  85. j primary_cpu_entry