init.s 698 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. .globl rom_lib_init
  7. .extern __DATA_RAM_START__, __DATA_ROM_START__, __DATA_RAM_END__
  8. .extern memset, memcpy
  9. rom_lib_init:
  10. cmp w0, #1
  11. mov w0, #0
  12. b.le 1f
  13. ret
  14. 1: stp x29, x30, [sp, #-16]!
  15. adrp x0, __DATA_RAM_START__
  16. adrp x1, __DATA_ROM_START__
  17. add x1, x1, :lo12:__DATA_ROM_START__
  18. adrp x2, __DATA_RAM_END__
  19. add x2, x2, :lo12:__DATA_RAM_END__
  20. sub x2, x2, x0
  21. bl memcpy
  22. adrp x0,__BSS_START__
  23. add x0, x0, :lo12:__BSS_START__
  24. mov x1, #0
  25. adrp x2, __BSS_END__
  26. add x2, x2, :lo12:__BSS_END__
  27. sub x2, x2, x0
  28. bl memset
  29. ldp x29, x30, [sp], #16
  30. mov w0, #1
  31. ret