asm.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. la gp, __global_pointer$
  15. .option pop
  16. la sp, _stack_start
  17. add s0, sp, zero
  18. jal zero, _start_rust
  19. .cfi_endproc
  20. /*
  21. Trap entry point (_start_trap)
  22. Saves caller saved registers ra, t0..6, a0..7, calls _start_trap_rust,
  23. restores caller saved registers and then returns.
  24. */
  25. .section .trap, "ax"
  26. .global _start_trap
  27. _start_trap:
  28. addi sp, sp, -16*4
  29. sw ra, 0*4(sp)
  30. sw t0, 1*4(sp)
  31. sw t1, 2*4(sp)
  32. sw t2, 3*4(sp)
  33. sw t3, 4*4(sp)
  34. sw t4, 5*4(sp)
  35. sw t5, 6*4(sp)
  36. sw t6, 7*4(sp)
  37. sw a0, 8*4(sp)
  38. sw a1, 9*4(sp)
  39. sw a2, 10*4(sp)
  40. sw a3, 11*4(sp)
  41. sw a4, 12*4(sp)
  42. sw a5, 13*4(sp)
  43. sw a6, 14*4(sp)
  44. sw a7, 15*4(sp)
  45. jal ra, _start_trap_rust
  46. lw ra, 0*4(sp)
  47. lw t0, 1*4(sp)
  48. lw t1, 2*4(sp)
  49. lw t2, 3*4(sp)
  50. lw t3, 4*4(sp)
  51. lw t4, 5*4(sp)
  52. lw t5, 6*4(sp)
  53. lw t6, 7*4(sp)
  54. lw a0, 8*4(sp)
  55. lw a1, 9*4(sp)
  56. lw a2, 10*4(sp)
  57. lw a3, 11*4(sp)
  58. lw a4, 12*4(sp)
  59. lw a5, 13*4(sp)
  60. lw a6, 14*4(sp)
  61. lw a7, 15*4(sp)
  62. addi sp, sp, 16*4
  63. mret
  64. /* Make sure there is an abort when linking */
  65. .section .init
  66. .globl abort
  67. abort:
  68. jal zero, _start