start_gcc.S 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2010-12-21 onelife Initial creation for EFM32
  9. * 2011-07-06 onelife Modify to make use the start code in libraries
  10. * 2012-05-15 onelife Modified to compatible with CMSIS v3
  11. */
  12. /***************************************************************************//**
  13. * @addtogroup cortex-m3
  14. * @{
  15. *******************************************************************************/
  16. .syntax unified
  17. .cpu cortex-m3
  18. .fpu softvfp
  19. .thumb
  20. /* start address for the initialization values of the .data section.
  21. defined in linker script */
  22. .word __etext
  23. /* start address for the .data section. defined in linker script */
  24. .word __data_start__
  25. /* end address for the .data section. defined in linker script */
  26. .word __data_end__
  27. /* start address for the .bss section. defined in linker script */
  28. .word __bss_start__
  29. /* end address for the .bss section. defined in linker script */
  30. .word __bss_end__
  31. /***************************************************************************//**
  32. * @brief This is the code that gets called when the processor first
  33. * starts execution following a reset event. Only the absolutely
  34. * necessary set is performed, after which the application
  35. * supplied main() routine is called.
  36. * @param None
  37. * @retval None
  38. *******************************************************************************/
  39. .thumb
  40. .thumb_func
  41. .section .cs3.init,"ax", %progbits
  42. .globl _start
  43. .type _start, %function
  44. _start:
  45. /* Copy the data segment initializers from flash to SRAM */
  46. movs r1, #0
  47. b LoopCopyDataInit
  48. CopyDataInit:
  49. ldr r3, =__etext
  50. ldr r3, [r3, r1]
  51. str r3, [r0, r1]
  52. adds r1, r1, #4
  53. LoopCopyDataInit:
  54. ldr r0, =__data_start__
  55. ldr r3, =__data_end__
  56. adds r2, r0, r1
  57. cmp r2, r3
  58. bcc CopyDataInit
  59. ldr r2, =__bss_start__
  60. b LoopFillZerobss
  61. /* Zero fill the bss segment. */
  62. FillZerobss:
  63. movs r3, #0
  64. str r3, [r2], #4
  65. LoopFillZerobss:
  66. ldr r3, = __bss_end__
  67. cmp r2, r3
  68. bcc FillZerobss
  69. /* Call the application's entry point.*/
  70. bl main
  71. bx lr
  72. .size _start, .-_start
  73. /***************************************************************************//**
  74. * @}
  75. *******************************************************************************/