Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
18
19#ifndef ZEPHYR_INCLUDE_ARCH_RISCV_THREAD_H_
20#define ZEPHYR_INCLUDE_ARCH_RISCV_THREAD_H_
21
22#ifndef _ASMLANGUAGE
23#include <stdbool.h>
24#include <zephyr/types.h>
25
26/*
27 * The following structure defines the list of registers that need to be
28 * saved/restored when a context switch occurs.
29 */
30struct _callee_saved {
31 unsigned long sp; /* Stack pointer, (x2 register) */
32 unsigned long ra; /* return address */
33
34 unsigned long s0; /* saved register/frame pointer */
35 unsigned long s1; /* saved register */
36#if !defined(CONFIG_RISCV_ISA_RV32E)
37 unsigned long s2; /* saved register */
38 unsigned long s3; /* saved register */
39 unsigned long s4; /* saved register */
40 unsigned long s5; /* saved register */
41 unsigned long s6; /* saved register */
42 unsigned long s7; /* saved register */
43 unsigned long s8; /* saved register */
44 unsigned long s9; /* saved register */
45 unsigned long s10; /* saved register */
46 unsigned long s11; /* saved register */
47#endif
48};
49typedef struct _callee_saved _callee_saved_t;
50
51#if !defined(RV_FP_TYPE)
52#ifdef CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION
53#define RV_FP_TYPE uint64_t
54#else
55#define RV_FP_TYPE uint32_t
56#endif
57#endif
58
59struct z_riscv_fp_context {
60 RV_FP_TYPE fa0, fa1, fa2, fa3, fa4, fa5, fa6, fa7;
61 RV_FP_TYPE ft0, ft1, ft2, ft3, ft4, ft5, ft6, ft7, ft8, ft9, ft10, ft11;
62 RV_FP_TYPE fs0, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10, fs11;
63 uint32_t fcsr;
64};
65typedef struct z_riscv_fp_context z_riscv_fp_context_t;
66
67struct _thread_arch {
68#ifdef CONFIG_FPU_SHARING
69 struct z_riscv_fp_context saved_fp_context;
70 bool fpu_recently_used;
71 uint8_t exception_depth;
72#endif
73#ifdef CONFIG_USERSPACE
74 unsigned long priv_stack_start;
75 unsigned long u_mode_pmpaddr_regs[CONFIG_PMP_SLOTS];
76 unsigned long u_mode_pmpcfg_regs[CONFIG_PMP_SLOTS / (__riscv_xlen / 8)];
77 unsigned int u_mode_pmp_domain_offset;
78 unsigned int u_mode_pmp_end_index;
79 unsigned int u_mode_pmp_update_nr;
80#endif
81#ifdef CONFIG_PMP_KERNEL_MODE_DYNAMIC
82 unsigned int m_mode_pmp_end_index;
83 unsigned long m_mode_pmpaddr_regs[CONFIG_PMP_SLOTS];
84 unsigned long m_mode_pmpcfg_regs[CONFIG_PMP_SLOTS / (__riscv_xlen / 8)];
85#endif
86#if defined(CONFIG_CPP) && !defined(CONFIG_FPU_SHARING) && !defined(CONFIG_USERSPACE) && \
87 !defined(CONFIG_PMP_STACK_GUARD)
88 /* Empty struct has size 0 in C, size 1 in C++. Force them to be the same. */
89 uint8_t unused_cpp_size_compatibility;
90#endif
91};
92
93#if defined(CONFIG_CPP)
94BUILD_ASSERT(sizeof(struct _thread_arch) >= 1);
95#endif
96
97typedef struct _thread_arch _thread_arch_t;
98
99#ifdef CONFIG_USERSPACE
100/* Exported accessor for the per-thread user-mode flag, used by
101 * arch_is_user_context() so loadable extensions can resolve it.
102 */
103extern bool z_riscv_thread_is_user_mode(void);
104#endif
105
106#endif /* _ASMLANGUAGE */
107
108#endif /* ZEPHYR_INCLUDE_ARCH_RISCV_THREAD_H_ */
#define RV_FP_TYPE
Definition thread.h:55
#define BUILD_ASSERT(EXPR, MSG...)
Definition llvm.h:51
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88