context_gcc.S 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021/07/14 JasonHu First version
  9. */
  10. #define __ASSEMBLY__
  11. #include <rtconfig.h>
  12. .code32
  13. .text
  14. /*
  15. * void rt_hw_context_switch_to_real(rt_ubase_t to);
  16. */
  17. .globl rt_hw_context_switch_to_real
  18. rt_hw_context_switch_to_real:
  19. movl 0x4(%esp), %eax // get thread "to"
  20. movl (%eax), %esp // restore sp
  21. popl %ebp
  22. popl %ebx
  23. popl %edi
  24. popl %esi
  25. ret
  26. /*
  27. * void rt_hw_context_switch_real(rt_ubase_t from, rt_ubase_t to);
  28. */
  29. .globl rt_hw_context_switch_real
  30. rt_hw_context_switch_real:
  31. pushl %esi
  32. pushl %edi
  33. pushl %ebx
  34. pushl %ebp
  35. movl 0x14(%esp), %eax // get "from"
  36. movl %esp, (%eax) // save sp
  37. movl 0x18(%esp), %eax // get "to"
  38. movl (%eax), %esp // restore sp
  39. popl %ebp
  40. popl %ebx
  41. popl %edi
  42. popl %esi
  43. ret