lwp_gcc.S 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * File : lwp_gcc.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. */
  23. #define Mode_USR 0x10
  24. #define Mode_FIQ 0x11
  25. #define Mode_IRQ 0x12
  26. #define Mode_SVC 0x13
  27. #define Mode_MON 0x16
  28. #define Mode_ABT 0x17
  29. #define Mode_UDF 0x1B
  30. #define Mode_SYS 0x1F
  31. #define A_Bit 0x100
  32. #define I_Bit 0x80 @; when I bit is set, IRQ is disabled
  33. #define F_Bit 0x40 @; when F bit is set, FIQ is disabled
  34. #define T_Bit 0x20
  35. .cpu arm9
  36. .syntax unified
  37. .text
  38. /*
  39. * void lwp_user_entry(args, text, data);
  40. */
  41. .global lwp_user_entry
  42. .type lwp_user_entry, % function
  43. lwp_user_entry:
  44. mrs r9, cpsr
  45. mov r8, r9
  46. bic r9, #0x1f
  47. orr r9, #Mode_USR
  48. orr r8, #I_Bit
  49. msr cpsr_c, r8
  50. msr spsr, r9
  51. /* set data address. */
  52. mov r9, r2
  53. movs pc, r1
  54. /*
  55. * void SVC_Handler(void);
  56. */
  57. .global SVC_Handler
  58. .type SVC_Handler, % function
  59. SVC_Handler:
  60. push {lr}
  61. mrs lr, spsr
  62. push {r4, r5, lr}
  63. mrs r4, cpsr
  64. bic r4, #I_Bit
  65. msr cpsr_c, r4
  66. push {r0 - r3, r12}
  67. and r0, r7, #0xff
  68. bl lwp_get_sys_api
  69. cmp r0, #0 /* r0 = api */
  70. mov r4, r0
  71. pop {r0 - r3, r12}
  72. beq svc_exit
  73. ldr lr, = svc_exit
  74. bx r4
  75. svc_exit:
  76. mrs r4, cpsr
  77. orr r4, #I_Bit
  78. msr cpsr_c, r4
  79. pop {r4, r5, lr}
  80. msr spsr_cxsf, lr
  81. pop {lr}
  82. movs pc, lr