summaryrefslogtreecommitdiff
path: root/components/lwp/arch/aarch64/cortex-a/lwp_arch.h
blob: 191f8e1bdc575fcb71b86810654a68bf9f08acf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-05-18     Jesven       first version
 */

#ifndef  LWP_ARCH_H__
#define  LWP_ARCH_H__

#include <rtconfig.h>

#ifdef ARCH_MM_MMU

#define USER_VADDR_TOP    0x0001000000000000UL
#define USER_HEAP_VADDR   (0x0000ffff40000000UL)
#define USER_HEAP_VEND    USER_STACK_VSTART
#define USER_STACK_VSTART 0x0000ffff70000000UL
#define USER_STACK_VEND   (USER_STACK_VSTART + 0x10000000)
#define USER_ARG_VADDR    USER_STACK_VEND
#define LDSO_LOAD_VADDR   0x60000000UL
#define USER_VADDR_START  0x00200000UL
#define USER_LOAD_VADDR   USER_VADDR_START

#define UCTX_ABI_OFFSET_TO_SI 16

#ifndef __ASSEMBLY__

#include <lwp.h>
#include <lwp_arch_comm.h>

#ifdef __cplusplus
extern "C" {
#endif

unsigned long rt_hw_ffz(unsigned long x);

rt_inline void icache_invalid_all(void)
{
    __asm__ volatile ("ic ialluis\n\tisb sy":::"memory");
}

/**
 * @brief Save signal-related context to user stack
 *
 * @param user_sp the current sp of user
 * @param exp_frame exception frame to resume former execution
 * @param psiginfo pointer to the siginfo
 * @param elr pc of former execution
 * @param spsr program status of former execution
 * @return void* the new user sp
 */
void *arch_signal_ucontext_save(rt_base_t user_sp, siginfo_t *psiginfo,
                                struct rt_hw_exp_stack *exp_frame,
                                lwp_sigset_t *save_sig_mask);

/**
 * @brief Restore the signal mask after return
 *
 * @param user_sp sp of user
 * @return void*
 */
void *arch_signal_ucontext_restore(rt_base_t user_sp, rt_base_t kernel_sp);
void arch_syscall_restart(void *sp, void *ksp);

#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */

#endif /* ARCH_MM_MMU */

#endif  /*LWP_ARCH_H__*/