2022-12-03 12:07:44 +08:00
|
|
|
/*
|
2023-07-20 00:02:41 +08:00
|
|
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
2022-12-03 12:07:44 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2023-07-20 00:02:41 +08:00
|
|
|
* 2022-09-30 RT-Thread the general porting API for lwp
|
|
|
|
* 2023-07-18 Shell New signal arch API arch_thread_signal_enter
|
2022-12-03 12:07:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LWP_ARCH_COMM__
|
|
|
|
#define __LWP_ARCH_COMM__
|
|
|
|
|
2023-01-09 10:08:55 +08:00
|
|
|
#include <mm_aspace.h>
|
2022-12-03 12:07:44 +08:00
|
|
|
#include <rtthread.h>
|
2023-01-09 10:08:55 +08:00
|
|
|
#include <mmu.h>
|
2022-12-03 12:07:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* APIs that must port to all architectures
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* syscall handlers */
|
|
|
|
void arch_clone_exit(void);
|
|
|
|
void arch_fork_exit(void);
|
2024-02-21 11:45:04 +08:00
|
|
|
void arch_syscall_exit(void);
|
|
|
|
void arch_ret_to_user(void);
|
2022-12-03 12:07:44 +08:00
|
|
|
|
|
|
|
/* ELF relocation */
|
2022-12-16 18:38:28 +08:00
|
|
|
#ifdef ARCH_MM_MMU
|
2023-01-09 10:08:55 +08:00
|
|
|
|
|
|
|
struct rt_lwp;
|
|
|
|
void arch_elf_reloc(rt_aspace_t aspace, void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, void *dynsym);
|
2022-12-03 12:07:44 +08:00
|
|
|
#else
|
|
|
|
void arch_elf_reloc(void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, void *dynsym);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* User entry. enter user program code for the first time */
|
|
|
|
void arch_crt_start_umode(void *args, const void *text, void *ustack, void *user_stack);
|
|
|
|
void arch_start_umode(void *args, const void *text, void *ustack, void *k_stack);
|
|
|
|
|
|
|
|
/* lwp create and setup */
|
|
|
|
int arch_set_thread_context(void (*exit)(void), void *new_thread_stack,
|
|
|
|
void *user_stack, void **thread_sp);
|
|
|
|
void *arch_get_user_sp(void);
|
|
|
|
|
|
|
|
/* user space setup and control */
|
|
|
|
int arch_user_space_init(struct rt_lwp *lwp);
|
2023-03-09 10:49:25 +08:00
|
|
|
void arch_user_space_free(struct rt_lwp *lwp);
|
2022-12-03 12:07:44 +08:00
|
|
|
void *arch_kernel_mmu_table_get(void);
|
2023-01-09 10:08:55 +08:00
|
|
|
void arch_kuser_init(rt_aspace_t aspace, void *vectors);
|
2022-12-03 12:07:44 +08:00
|
|
|
int arch_expand_user_stack(void *addr);
|
|
|
|
|
|
|
|
/* thread id register */
|
|
|
|
void arch_set_thread_area(void *p);
|
|
|
|
void* arch_get_tidr(void);
|
|
|
|
void arch_set_tidr(void *p);
|
|
|
|
|
2023-07-20 00:02:41 +08:00
|
|
|
/** entry point of architecture signal handling */
|
|
|
|
rt_noreturn void arch_thread_signal_enter(int signo, siginfo_t *psiginfo,
|
|
|
|
void *exp_frame, void *entry_uaddr,
|
|
|
|
lwp_sigset_t *save_sig_mask);
|
|
|
|
|
2024-03-28 23:42:56 +08:00
|
|
|
void arch_signal_check_erestart(void *eframe, void *ksp);
|
|
|
|
|
|
|
|
void arch_syscall_set_errno(void *eframe, int expected, int code);
|
|
|
|
|
2023-10-21 20:14:45 +08:00
|
|
|
int arch_backtrace_uthread(rt_thread_t thread);
|
|
|
|
|
2022-12-03 12:07:44 +08:00
|
|
|
#endif /* __LWP_ARCH_COMM__ */
|