summaryrefslogtreecommitdiffstats
path: root/lib/romlib/init.s
diff options
context:
space:
mode:
Diffstat (limited to 'lib/romlib/init.s')
-rw-r--r--lib/romlib/init.s36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/romlib/init.s b/lib/romlib/init.s
new file mode 100644
index 0000000..7d97e4d
--- /dev/null
+++ b/lib/romlib/init.s
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+ .globl rom_lib_init
+ .extern __DATA_RAM_START__, __DATA_ROM_START__, __DATA_RAM_END__
+ .extern memset, memcpy
+
+rom_lib_init:
+ cmp w0, #1
+ mov w0, #0
+ b.le 1f
+ ret
+
+1: stp x29, x30, [sp, #-16]!
+ adrp x0, __DATA_RAM_START__
+ adrp x1, __DATA_ROM_START__
+ add x1, x1, :lo12:__DATA_ROM_START__
+ adrp x2, __DATA_RAM_END__
+ add x2, x2, :lo12:__DATA_RAM_END__
+ sub x2, x2, x0
+ bl memcpy
+
+ adrp x0,__BSS_START__
+ add x0, x0, :lo12:__BSS_START__
+ mov x1, #0
+ adrp x2, __BSS_END__
+ add x2, x2, :lo12:__BSS_END__
+ sub x2, x2, x0
+ bl memset
+ ldp x29, x30, [sp], #16
+
+ mov w0, #1
+ ret