mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-29 02:20:21 +00:00
[libcpu/arm64] feat: Trimming General Context
This patch focuses on the ARM64 general context handling code. The modifications are aimed at enhancing performance by simplifying context save/restore operations. Changes include: - Adjusted stack alignment in `arch_set_thread_context` function. - Updated `lwp_gcc.S` to reset frame pointer and link register. - Refined `rt_hw_backtrace_frame_unwind` to handle user space address checks. - Added `GET_THREAD_SELF` macro in `asm-generic.h`. - Simplified context saving/restoring in `context_gcc.h` and related files. - Optimized `rt_hw_context_switch_interrupt` and related assembly routines. Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
@@ -106,18 +106,16 @@ int arch_set_thread_context(void (*exit)(void), void *new_thread_stack,
|
||||
struct rt_hw_exp_stack *ori_syscall = rt_thread_self()->user_ctx.ctx;
|
||||
RT_ASSERT(ori_syscall != RT_NULL);
|
||||
|
||||
thread_frame = (void *)((long)new_thread_stack - sizeof(struct rt_hw_exp_stack));
|
||||
syscall_frame = (void *)((long)new_thread_stack - 2 * sizeof(struct rt_hw_exp_stack));
|
||||
new_thread_stack = (rt_ubase_t*)RT_ALIGN_DOWN((rt_ubase_t)new_thread_stack, 16);
|
||||
|
||||
syscall_frame = (void *)((long)new_thread_stack - sizeof(struct rt_hw_exp_stack));
|
||||
memcpy(syscall_frame, ori_syscall, sizeof(*syscall_frame));
|
||||
syscall_frame->sp_el0 = (long)user_stack;
|
||||
syscall_frame->x0 = 0;
|
||||
|
||||
thread_frame->cpsr = ((3 << 6) | 0x4 | 0x1);
|
||||
thread_frame->pc = (long)exit;
|
||||
thread_frame->x0 = 0;
|
||||
thread_frame = (void *)rt_hw_stack_init(exit, RT_NULL, (void *)syscall_frame, RT_NULL);
|
||||
|
||||
*thread_sp = syscall_frame;
|
||||
*thread_sp = thread_frame;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -125,12 +125,15 @@ lwp_exec_user:
|
||||
* since this routine reset the SP, we take it as a start point
|
||||
*/
|
||||
START_POINT(SVC_Handler)
|
||||
mov fp, xzr
|
||||
mov lr, xzr
|
||||
|
||||
/* x0 is initial sp */
|
||||
mov sp, x0
|
||||
|
||||
msr daifclr, #3 /* enable interrupt */
|
||||
|
||||
bl rt_thread_self
|
||||
GET_THREAD_SELF x0
|
||||
bl lwp_user_setting_save
|
||||
|
||||
ldp x8, x9, [sp, #(CONTEXT_OFFSET_X8)]
|
||||
|
||||
Reference in New Issue
Block a user