asm.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. Entry point of all programs (_start).
  3. It initializes DWARF call frame information, the stack pointer, the
  4. frame pointer (needed for closures to work in start_rust) and the global
  5. pointer. Then it calls _start_rust.
  6. */
  7. .section .init, "ax"
  8. .global _start
  9. _start:
  10. .cfi_startproc
  11. .cfi_undefined ra
  12. // .option push
  13. // .option norelax
  14. lui gp, %hi(__global_pointer$)
  15. addi gp, gp, %lo(__global_pointer$)
  16. // .option pop
  17. lui sp, %hi(_stack_start)
  18. addi sp, sp, %lo(_stack_start)
  19. add s0, sp, zero
  20. jal zero, _start_rust
  21. .cfi_endproc
  22. /*
  23. Trap entry point (_start_trap)
  24. Saves caller saved registers ra, t0..6, a0..7, calls _start_trap_rust,
  25. restores caller saved registers and then returns.
  26. */
  27. .section .trap, "ax"
  28. .align 4
  29. .global _start_trap
  30. _start_trap:
  31. addi sp, sp, -16*4
  32. sw ra, 0*4(sp)
  33. sw t0, 1*4(sp)
  34. sw t1, 2*4(sp)
  35. sw t2, 3*4(sp)
  36. sw t3, 4*4(sp)
  37. sw t4, 5*4(sp)
  38. sw t5, 6*4(sp)
  39. sw t6, 7*4(sp)
  40. sw a0, 8*4(sp)
  41. sw a1, 9*4(sp)
  42. sw a2, 10*4(sp)
  43. sw a3, 11*4(sp)
  44. sw a4, 12*4(sp)
  45. sw a5, 13*4(sp)
  46. sw a6, 14*4(sp)
  47. sw a7, 15*4(sp)
  48. jal ra, _start_trap_rust
  49. lw ra, 0*4(sp)
  50. lw t0, 1*4(sp)
  51. lw t1, 2*4(sp)
  52. lw t2, 3*4(sp)
  53. lw t3, 4*4(sp)
  54. lw t4, 5*4(sp)
  55. lw t5, 6*4(sp)
  56. lw t6, 7*4(sp)
  57. lw a0, 8*4(sp)
  58. lw a1, 9*4(sp)
  59. lw a2, 10*4(sp)
  60. lw a3, 11*4(sp)
  61. lw a4, 12*4(sp)
  62. lw a5, 13*4(sp)
  63. lw a6, 14*4(sp)
  64. lw a7, 15*4(sp)
  65. addi sp, sp, 16*4
  66. mret
  67. /* Make sure there is an abort when linking */
  68. .section .init
  69. .globl abort
  70. abort:
  71. jal zero, _start