resethandler_m0.s 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2018 Damien P. George
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. .syntax unified
  27. .cpu cortex-m0
  28. .thumb
  29. .section .text.Reset_Handler
  30. .global Reset_Handler
  31. .type Reset_Handler, %function
  32. Reset_Handler:
  33. /* Save the first argument to pass through to stm32_main */
  34. mov r4, r0
  35. /* Load the stack pointer */
  36. ldr r0, =_estack
  37. mov sp, r0
  38. /* Initialise the data section */
  39. ldr r1, =_sidata
  40. ldr r2, =_sdata
  41. ldr r3, =_edata
  42. b .data_copy_entry
  43. .data_copy_loop:
  44. ldr r0, [r1]
  45. adds r1, #4
  46. str r0, [r2]
  47. adds r2, #4
  48. .data_copy_entry:
  49. cmp r2, r3
  50. bcc .data_copy_loop
  51. /* Zero out the BSS section */
  52. movs r0, #0
  53. ldr r1, =_sbss
  54. ldr r2, =_ebss
  55. b .bss_zero_entry
  56. .bss_zero_loop:
  57. str r0, [r1]
  58. adds r1, #4
  59. .bss_zero_entry:
  60. cmp r1, r2
  61. bcc .bss_zero_loop
  62. /* Initialise the system and jump to the main code */
  63. bl SystemInit
  64. mov r0, r4
  65. bl stm32_main
  66. .size Reset_Handler, .-Reset_Handler