start_gcc.S 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /***************************************************************************//**
  2. * @file start_gcc.S
  3. * @brief Context switch functions
  4. * COPYRIGHT (C) 2012, RT-Thread Development Team
  5. * @author onelife
  6. * @version 1.0
  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. * 2012-05-15 onelife Modified to compatible with CMSIS v3
  17. ******************************************************************************/
  18. /***************************************************************************//**
  19. * @addtogroup cortex-m3
  20. * @{
  21. *******************************************************************************/
  22. .syntax unified
  23. .cpu cortex-m3
  24. .fpu softvfp
  25. .thumb
  26. /* start address for the initialization values of the .data section.
  27. defined in linker script */
  28. .word __etext
  29. /* start address for the .data section. defined in linker script */
  30. .word __data_start__
  31. /* end address for the .data section. defined in linker script */
  32. .word __data_end__
  33. /* start address for the .bss section. defined in linker script */
  34. .word __bss_start__
  35. /* end address for the .bss section. defined in linker script */
  36. .word __bss_end__
  37. /***************************************************************************//**
  38. * @brief This is the code that gets called when the processor first
  39. * starts execution following a reset event. Only the absolutely
  40. * necessary set is performed, after which the application
  41. * supplied main() routine is called.
  42. * @param None
  43. * @retval None
  44. *******************************************************************************/
  45. .thumb
  46. .thumb_func
  47. .section .cs3.init,"ax", %progbits
  48. .globl _start
  49. .type _start, %function
  50. _start:
  51. /* Copy the data segment initializers from flash to SRAM */
  52. movs r1, #0
  53. b LoopCopyDataInit
  54. CopyDataInit:
  55. ldr r3, =__etext
  56. ldr r3, [r3, r1]
  57. str r3, [r0, r1]
  58. adds r1, r1, #4
  59. LoopCopyDataInit:
  60. ldr r0, =__data_start__
  61. ldr r3, =__data_end__
  62. adds r2, r0, r1
  63. cmp r2, r3
  64. bcc CopyDataInit
  65. ldr r2, =__bss_start__
  66. b LoopFillZerobss
  67. /* Zero fill the bss segment. */
  68. FillZerobss:
  69. movs r3, #0
  70. str r3, [r2], #4
  71. LoopFillZerobss:
  72. ldr r3, = __bss_end__
  73. cmp r2, r3
  74. bcc FillZerobss
  75. /* Call the application's entry point.*/
  76. bl main
  77. bx lr
  78. .size _start, .-_start
  79. /***************************************************************************//**
  80. * @}
  81. *******************************************************************************/