context_gcc.S 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 2020, Shenzhen Academy of Aerospace Technology
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-10-16 Dystopia the first version
  9. */
  10. #define SPARC_PSR_PIL_MASK 0x00000F00
  11. #define SPARC_PSR_ET_MASK 0x00000020
  12. /*
  13. * rt_base_t rt_hw_interrupt_disable();
  14. */
  15. .globl rt_hw_interrupt_disable
  16. rt_hw_interrupt_disable:
  17. mov %psr, %o0
  18. or %o0, SPARC_PSR_PIL_MASK, %o1
  19. mov %o1, %psr
  20. nop
  21. nop
  22. nop
  23. retl
  24. nop
  25. /*
  26. * void rt_hw_interrupt_enable(rt_base_t level);
  27. */
  28. .globl rt_hw_interrupt_enable
  29. rt_hw_interrupt_enable:
  30. mov %o0, %psr
  31. nop
  32. nop
  33. nop
  34. retl
  35. nop
  36. /*
  37. * void rt_hw_context_switch(rt_uint32 from, rt_uint32 to);
  38. * o0 --> from
  39. * o1 --> to
  40. */
  41. .globl rt_hw_context_switch
  42. rt_hw_context_switch:
  43. ta 2
  44. retl
  45. nop
  46. /*
  47. * void rt_hw_context_switch_to(rt_uint32 to);
  48. * o0 --> to
  49. */
  50. .globl rt_hw_context_switch_to
  51. rt_hw_context_switch_to:
  52. mov %o0, %o1
  53. ta 3
  54. retl
  55. nop
  56. /*
  57. * void rt_hw_context_switch_interrupt(rt_uint32 from, rt_uint32 to);
  58. */
  59. .globl rt_thread_switch_interrupt_flag
  60. .globl rt_interrupt_from_thread
  61. .globl rt_interrupt_to_thread
  62. .globl rt_hw_context_switch_interrupt
  63. rt_hw_context_switch_interrupt:
  64. set rt_thread_switch_interrupt_flag, %o2
  65. ld [%o2], %o3
  66. cmp %o3, 1
  67. be _reswitch
  68. nop
  69. mov 1, %o3
  70. st %o3, [%o2]
  71. set rt_interrupt_from_thread, %o2
  72. st %o0, [%o2]
  73. _reswitch:
  74. set rt_interrupt_to_thread, %o2
  75. st %o1, [%o2]
  76. retl
  77. nop