reset_program.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ;;/*********************************************************************************************************************
  2. ;;* DISCLAIMER
  3. ;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products.
  4. ;;* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all
  5. ;;* applicable laws, including copyright laws.
  6. ;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIESREGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED
  7. ;;* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  8. ;;* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY
  9. ;;* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT,
  10. ;;* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR
  11. ;;* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  12. ;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability
  13. ;;* of this software. By using this software, you agree to the additional terms and conditions found by accessing the
  14. ;;* following link:
  15. ;;* http://www.renesas.com/disclaimer
  16. ;;*
  17. ;;* Copyright (C) 2015, 2017 Renesas Electronics Corporation. All rights reserved.
  18. ;;*********************************************************************************************************************/
  19. ;;/*
  20. ;;**********************************************************************************************************************
  21. ;;* File Name : reset_program.asm
  22. ;;* Version : 2.0 (2017-11-17)
  23. ;;* Device(s) : RX
  24. ;;* Tool-Chain : GCCRX
  25. ;;* Description : This is start up file for RX.
  26. ;;**********************************************************************************************************************
  27. ;;*/
  28. #ifdef __GNUC__
  29. ;;reset_program.asm
  30. .list
  31. .section .text
  32. .global _PowerON_Reset_PC ;;global Start routine
  33. .global _PowerON_Reset ;;for backward compatibility
  34. .extern _PowerON_Reset_PC_Prg ;;external Power ON Reset main function in RESETPRG.C
  35. .extern _data
  36. .extern _mdata
  37. .extern _ebss
  38. .extern _bss
  39. .extern _edata
  40. .extern _istack
  41. .extern _exit
  42. _PowerON_Reset_PC :
  43. _PowerON_Reset :
  44. ;;initialise interrupt stack pointer
  45. mvtc #_istack,ISP
  46. ;;jump to Power ON Reset main function in RESETPRG.C
  47. bra _PowerON_Reset_PC_Prg
  48. ;;init section
  49. .global __INITSCT
  50. .type __INITSCT,@function
  51. __INITSCT:
  52. ;;load data section from ROM to RAM
  53. pushm r1-r3
  54. mov #_mdata,r2 ;;src ROM address of data section in R2
  55. mov #_data,r1 ;;dest start RAM address of data section in R1
  56. mov #_edata,r3 ;;end RAM address of data section in R3
  57. sub r1,r3 ;;size of data section in R3 (R3=R3-R1)
  58. smovf ;;block copy R3 bytes from R2 to R1
  59. ;;bss initialisation : zero out bss
  60. mov #00h,r2 ;;load R2 reg with zero
  61. mov #_ebss, r3 ;;store the end address of bss in R3
  62. mov #_bss, r1 ;;store the start address of bss in R1
  63. sub r1,r3 ;;size of bss section in R3 (R3=R3-R1)
  64. sstr.b
  65. popm r1-r3
  66. rts
  67. #ifdef CPPAPP
  68. ;;init global class object
  69. .global __CALL_INIT
  70. .type __CALL_INIT,@function
  71. __CALL_INIT:
  72. bra __rx_init
  73. .global _rx_run_preinit_array
  74. .type _rx_run_preinit_array,@function
  75. _rx_run_preinit_array:
  76. mov #__preinit_array_start,r1
  77. mov #__preinit_array_end,r2
  78. bra.a _rx_run_inilist
  79. .global _rx_run_init_array
  80. .type _rx_run_init_array,@function
  81. _rx_run_init_array:
  82. mov #__init_array_start,r1
  83. mov #__init_array_end,r2
  84. mov #4, r3
  85. bra.a _rx_run_inilist
  86. .global _rx_run_fini_array
  87. .type _rx_run_fini_array,@function
  88. _rx_run_fini_array:
  89. mov #__fini_array_start,r2
  90. mov #__fini_array_end,r1
  91. mov #-4, r3
  92. ;;fall through
  93. _rx_run_inilist:
  94. next_inilist:
  95. cmp r1,r2
  96. beq.b done_inilist
  97. mov.l [r1],r4
  98. cmp #-1, r4
  99. beq.b skip_inilist
  100. cmp #0, r4
  101. beq.b skip_inilist
  102. pushm r1-r3
  103. jsr r4
  104. popm r1-r3
  105. skip_inilist:
  106. add r3,r1
  107. bra.b next_inilist
  108. done_inilist:
  109. rts
  110. .section .init,"ax"
  111. .balign 4
  112. .global __rx_init
  113. __rx_init:
  114. .section .fini,"ax"
  115. .balign 4
  116. .global __rx_fini
  117. __rx_fini:
  118. bsr.a _rx_run_fini_array
  119. .section .sdata
  120. .balign 4
  121. .global __gp
  122. .weak __gp
  123. __gp:
  124. .section .data
  125. .global ___dso_handle
  126. .weak ___dso_handle
  127. ___dso_handle:
  128. .long 0
  129. .section .init,"ax"
  130. bsr.a _rx_run_preinit_array
  131. bsr.a _rx_run_init_array
  132. rts
  133. .global __rx_init_end
  134. __rx_init_end:
  135. .section .fini,"ax"
  136. rts
  137. .global __rx_fini_end
  138. __rx_fini_end:
  139. #endif
  140. ;;call to exit
  141. _exit:
  142. bra _loop_here
  143. _loop_here:
  144. bra _loop_here
  145. .text
  146. #endif
  147. .end