lwp_gcc.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 cortex-a9
  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. bic r9, #0x1f
  46. orr r9, #Mode_USR
  47. cpsid i
  48. msr spsr, r9
  49. /* set data address. */
  50. mov r9, r2
  51. movs pc, r1
  52. /*
  53. * void SVC_Handler(void);
  54. */
  55. .global SVC_Handler
  56. .type SVC_Handler, % function
  57. SVC_Handler:
  58. push {lr}
  59. mrs lr, spsr
  60. push {r4, r5, lr}
  61. cpsie i
  62. push {r0 - r3, r12}
  63. and r0, r7, #0xff
  64. bl lwp_get_sys_api
  65. cmp r0, #0 /* r0 = api */
  66. mov lr, r0
  67. pop {r0 - r3, r12}
  68. beq svc_exit
  69. blx lr
  70. svc_exit:
  71. cpsid i
  72. pop {r4, r5, lr}
  73. msr spsr_cxsf, lr
  74. pop {lr}
  75. movs pc, lr