start_gcc.S 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /***************************************************************************//**
  2. * @file start_gcc.S
  3. * @brief Context switch functions
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. * @author onelife
  6. * @version 0.4 beta
  7. *******************************************************************************
  8. * @section License
  9. * The license and distribution terms for this file may be found in the file
  10. * LICENSE in this distribution or at http://www.rt-thread.org/license/LICENSE
  11. *******************************************************************************
  12. * @section Change Logs
  13. * Date Author Notes
  14. * 2010-12-21 onelife Initial creation for EFM32
  15. * 2011-07-06 onelife Modify to make use the start code in libraries
  16. ******************************************************************************/
  17. /***************************************************************************//**
  18. * @addtogroup cortex-m3
  19. * @{
  20. *******************************************************************************/
  21. .syntax unified
  22. .cpu cortex-m3
  23. .fpu softvfp
  24. .thumb
  25. /* start address for the initialization values of the .data section.
  26. defined in linker script */
  27. .word _sidata
  28. /* start address for the .data section. defined in linker script */
  29. .word _sdata
  30. /* end address for the .data section. defined in linker script */
  31. .word _edata
  32. /* start address for the .bss section. defined in linker script */
  33. .word _sbss
  34. /* end address for the .bss section. defined in linker script */
  35. .word _ebss
  36. /***************************************************************************//**
  37. * @brief This is the code that gets called when the processor first
  38. * starts execution following a reset event. Only the absolutely
  39. * necessary set is performed, after which the application
  40. * supplied main() routine is called.
  41. * @param None
  42. * @retval None
  43. *******************************************************************************/
  44. .thumb
  45. .thumb_func
  46. .section .cs3.init,"ax", %progbits
  47. .globl _start
  48. .type _start, %function
  49. _start:
  50. /* Copy the data segment initializers from flash to SRAM */
  51. movs r1, #0
  52. b LoopCopyDataInit
  53. CopyDataInit:
  54. ldr r3, =_sidata
  55. ldr r3, [r3, r1]
  56. str r3, [r0, r1]
  57. adds r1, r1, #4
  58. LoopCopyDataInit:
  59. ldr r0, =_sdata
  60. ldr r3, =_edata
  61. adds r2, r0, r1
  62. cmp r2, r3
  63. bcc CopyDataInit
  64. ldr r2, =_sbss
  65. b LoopFillZerobss
  66. /* Zero fill the bss segment. */
  67. FillZerobss:
  68. movs r3, #0
  69. str r3, [r2], #4
  70. LoopFillZerobss:
  71. ldr r3, = _ebss
  72. cmp r2, r3
  73. bcc FillZerobss
  74. /* Call the application's entry point.*/
  75. bl main
  76. bx lr
  77. .size _start, .-_start
  78. /***************************************************************************//**
  79. * @}
  80. *******************************************************************************/