asm_funcs.S 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <xtensa/coreasm.h>
  7. #include <xtensa/corebits.h>
  8. #include <xtensa/config/system.h>
  9. #include <xtensa/hal.h>
  10. /* get_ps_other_cpu(void *arg)
  11. *
  12. * It should be called by the CALLX0 command from the handler of High-priority interrupt.
  13. * Only these registers [a2, a3, a4] can be used here.
  14. * Returns PS.
  15. */
  16. .section .iram1, "ax"
  17. .align 4
  18. .global get_ps_other_cpu
  19. .type get_ps_other_cpu, @function
  20. // Args:
  21. // a2 - void* arg
  22. get_ps_other_cpu:
  23. rsr a3, PS
  24. s32i a3, a2, 0
  25. ret
  26. /* extended_ipc_isr_asm(void *arg)
  27. *
  28. * It should be called by the CALLX0 command from the handler of High-priority interrupt.
  29. * Only these registers [a2, a3, a4] can be used here.
  30. * This function receives a structure (arg) where can be saved some regs
  31. * to get them available here, at the end of the function we recover the saved regs.
  32. */
  33. .section .iram1, "ax"
  34. .align 4
  35. .global extended_ipc_isr_asm
  36. .type extended_ipc_isr_asm, @function
  37. // Args:
  38. // a2 - arg_data_t* arg
  39. extended_ipc_isr_asm:
  40. /* save all registers (a5-a15 -> regs[11]) */
  41. s32i a5, a2, 0
  42. s32i a6, a2, 4
  43. s32i a7, a2, 8
  44. s32i a8, a2, 12
  45. s32i a9, a2, 16
  46. s32i a10, a2, 20
  47. s32i a11, a2, 24
  48. s32i a12, a2, 28
  49. s32i a13, a2, 32
  50. s32i a14, a2, 36
  51. s32i a15, a2, 40
  52. /* do some work with a2 - a15 */
  53. l32i a5, a2, 44 /* a5 <- in[0] */
  54. l32i a6, a2, 48 /* a6 <- in[1] */
  55. l32i a7, a2, 52 /* a7 <- in[2] */
  56. or a8, a5, a6
  57. or a8, a8, a7
  58. add a9, a5, a6
  59. add a9, a9, a7
  60. mov a10, a7
  61. rsr a11, PS
  62. s32i a8, a2, 56 /* a8 -> out[0] */
  63. s32i a9, a2, 60 /* a9 -> out[1] */
  64. s32i a10, a2, 64 /* a10 -> out[2] */
  65. s32i a11, a2, 68 /* a11 -> out[3] */
  66. /* restore all saved registers (regs[11] -> a5-a15) */
  67. l32i a5, a2, 0
  68. l32i a6, a2, 4
  69. l32i a7, a2, 8
  70. l32i a8, a2, 12
  71. l32i a9, a2, 16
  72. l32i a10, a2, 20
  73. l32i a11, a2, 24
  74. l32i a12, a2, 28
  75. l32i a13, a2, 32
  76. l32i a14, a2, 36
  77. l32i a15, a2, 40
  78. ret