startup_gcc.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 __ASSEMBLY__
  13. #define SSTATUS_FS 0x00006000U /* initial state of FPU, clear to disable */
  14. #include <cpuport.h>
  15. .global _start
  16. .section ".start", "ax"
  17. _start:
  18. j 1f
  19. .word 0xdeadbeef
  20. .align 3
  21. .global g_wake_up
  22. g_wake_up:
  23. .dword 1
  24. .dword 0
  25. 1:
  26. csrw sie, 0
  27. csrw sip, 0
  28. la t0, trap_entry
  29. csrw stvec, t0
  30. li x1, 0
  31. li x2, 0
  32. li x3, 0
  33. li x4, 0
  34. li x5, 0
  35. li x6, 0
  36. li x7, 0
  37. li x8, 0
  38. li x9, 0
  39. li x10,0
  40. li x11,0
  41. li x12,0
  42. li x13,0
  43. li x14,0
  44. li x15,0
  45. li x16,0
  46. li x17,0
  47. li x18,0
  48. li x19,0
  49. li x20,0
  50. li x21,0
  51. li x22,0
  52. li x23,0
  53. li x24,0
  54. li x25,0
  55. li x26,0
  56. li x27,0
  57. li x28,0
  58. li x29,0
  59. li x30,0
  60. li x31,0
  61. /* set to disable FPU */
  62. li t0, SSTATUS_FS
  63. csrc sstatus, t0
  64. li t0, 0x40000 // SUM in sstatus
  65. csrs sstatus, t0
  66. .option push
  67. .option norelax
  68. la gp, __global_pointer$
  69. .option pop
  70. // removed SMP support here
  71. la sp, __stack_start__
  72. li t0, __STACKSIZE__
  73. add sp, sp, t0
  74. csrw sscratch, sp
  75. j primary_cpu_entry