summaryrefslogtreecommitdiff
path: root/libcpu/arm
diff options
context:
space:
mode:
authorShell <[email protected]>2023-05-14 23:48:16 +0800
committerGitHub <[email protected]>2023-05-14 23:48:16 +0800
commitb7554a70d21582cab97028477941fb692ef248b8 (patch)
tree31fde2a378142f21ceeb4593c0bb21422d5a4651 /libcpu/arm
parentf7337f9db6314723d6a46b1eb72c937cd1e66537 (diff)
[libcpu][component][debug] add debug info for gdb (#7033)
Diffstat (limited to 'libcpu/arm')
-rw-r--r--libcpu/arm/cortex-a/asm-generic.h25
-rw-r--r--libcpu/arm/cortex-a/cpuport.h2
-rw-r--r--libcpu/arm/cortex-a/stack.c6
-rw-r--r--libcpu/arm/cortex-a/start_gcc.S9
4 files changed, 39 insertions, 3 deletions
diff --git a/libcpu/arm/cortex-a/asm-generic.h b/libcpu/arm/cortex-a/asm-generic.h
new file mode 100644
index 0000000000..c106f9c1c8
--- /dev/null
+++ b/libcpu/arm/cortex-a/asm-generic.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2006-2023 RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2023-03-12 WangXiaoyao the first version
+ */
+#ifndef __ASM_GENERIC_H__
+#define __ASM_GENERIC_H__
+
+#define START_POINT(funcname) \
+ .type funcname, %function; \
+ .global funcname; \
+ funcname: \
+ .cfi_sections .debug_frame, .eh_frame; \
+ .cfi_startproc; \
+ .cfi_undefined lr
+
+#define START_POINT_END(name) \
+ .cfi_endproc; \
+ .size name, .-name;
+
+#endif /* __ASM_GENERIC_H__ */
diff --git a/libcpu/arm/cortex-a/cpuport.h b/libcpu/arm/cortex-a/cpuport.h
index e881da9147..2cb80f0d33 100644
--- a/libcpu/arm/cortex-a/cpuport.h
+++ b/libcpu/arm/cortex-a/cpuport.h
@@ -97,4 +97,6 @@ rt_inline void rt_hw_dsb(void)
__asm volatile ("dsb":::"memory");
}
+void _thread_start(void);
+
#endif /*CPUPORT_H__*/
diff --git a/libcpu/arm/cortex-a/stack.c b/libcpu/arm/cortex-a/stack.c
index ec2a51a8e8..4c955677f8 100644
--- a/libcpu/arm/cortex-a/stack.c
+++ b/libcpu/arm/cortex-a/stack.c
@@ -35,7 +35,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
stack_addr += sizeof(rt_uint32_t);
stack_addr = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stack_addr, 8);
stk = (rt_uint32_t *)stack_addr;
- *(--stk) = (rt_uint32_t)tentry; /* entry point */
+ *(--stk) = (rt_uint32_t)_thread_start; /* entry point */
*(--stk) = (rt_uint32_t)texit; /* lr */
*(--stk) = 0xdeadbeef; /* r12 */
*(--stk) = 0xdeadbeef; /* r11 */
@@ -48,8 +48,8 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
*(--stk) = 0xdeadbeef; /* r4 */
*(--stk) = 0xdeadbeef; /* r3 */
*(--stk) = 0xdeadbeef; /* r2 */
- *(--stk) = 0xdeadbeef; /* r1 */
- *(--stk) = (rt_uint32_t)parameter; /* r0 : argument */
+ *(--stk) = (rt_uint32_t)tentry; /* r1 : argument 2 for trampoline */
+ *(--stk) = (rt_uint32_t)parameter; /* r0 : argument 1 */
/* cpsr */
if ((rt_uint32_t)tentry & 0x01)
*(--stk) = SVCMODE | 0x20; /* thumb mode */
diff --git a/libcpu/arm/cortex-a/start_gcc.S b/libcpu/arm/cortex-a/start_gcc.S
index 1283686439..d79ffd2f6a 100644
--- a/libcpu/arm/cortex-a/start_gcc.S
+++ b/libcpu/arm/cortex-a/start_gcc.S
@@ -673,6 +673,15 @@ rt_hw_clz:
#define RT_CPUS_NR 1
#endif
+#include "asm-generic.h"
+
+START_POINT(_thread_start)
+ mov r10, lr
+ blx r1
+ blx r10
+ b . /* never here */
+START_POINT_END(_thread_start)
+
.bss
.align 3 /* align to 2~3=8 */
svc_stack_n: