aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/lib/semihosting.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/lib/semihosting.S')
-rw-r--r--arch/arm/lib/semihosting.S31
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/arm/lib/semihosting.S b/arch/arm/lib/semihosting.S
new file mode 100644
index 0000000000..393aade94a
--- /dev/null
+++ b/arch/arm/lib/semihosting.S
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) 2022 Arm Ltd.
+ */
+
+#include <config.h>
+#include <asm/macro.h>
+#include <linux/linkage.h>
+
+.pushsection .text.smh_trap, "ax"
+/* long smh_trap(unsigned int sysnum, void *addr); */
+ENTRY(smh_trap)
+
+#if defined(CONFIG_ARM64)
+ hlt #0xf000
+#elif defined(CONFIG_CPU_V7M)
+ bkpt #0xab
+#elif defined(CONFIG_SYS_THUMB_BUILD)
+ svc #0xab
+#else
+ svc #0x123456
+#endif
+
+#if defined(CONFIG_ARM64)
+ ret
+#else
+ bx lr
+#endif
+
+ENDPROC(smh_trap)
+.popsection