Zephyr Project API  3.1.0
A Scalable Open Source RTOS
exp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Jean-Paul Etienne <fractalclone@gmail.com>
3 * Copyright (c) 2018 Foundries.io Ltd
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
15#ifndef ZEPHYR_INCLUDE_ARCH_RISCV_EXP_H_
16#define ZEPHYR_INCLUDE_ARCH_RISCV_EXP_H_
17
18#ifndef _ASMLANGUAGE
19#include <zephyr/types.h>
20#include <zephyr/toolchain.h>
21
22#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
23#include <soc_context.h>
24#endif
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*
31 * The name of the structure which contains soc-specific state, if
32 * any, as well as the soc_esf_t typedef below, are part of the RISC-V
33 * arch API.
34 *
35 * The contents of the struct are provided by a SOC-specific
36 * definition in soc_context.h.
37 */
38#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
39struct soc_esf {
40 SOC_ESF_MEMBERS;
41};
42#endif
43
44#if !defined(RV_FP_TYPE) && defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
45#ifdef CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION
46#define RV_FP_TYPE uint64_t
47#else
48#define RV_FP_TYPE uint32_t
49#endif
50#endif
51
52struct __esf {
53 ulong_t ra; /* return address */
54
55 ulong_t t0; /* Caller-saved temporary register */
56 ulong_t t1; /* Caller-saved temporary register */
57 ulong_t t2; /* Caller-saved temporary register */
58 ulong_t t3; /* Caller-saved temporary register */
59 ulong_t t4; /* Caller-saved temporary register */
60 ulong_t t5; /* Caller-saved temporary register */
61 ulong_t t6; /* Caller-saved temporary register */
62
63 ulong_t a0; /* function argument/return value */
64 ulong_t a1; /* function argument */
65 ulong_t a2; /* function argument */
66 ulong_t a3; /* function argument */
67 ulong_t a4; /* function argument */
68 ulong_t a5; /* function argument */
69 ulong_t a6; /* function argument */
70 ulong_t a7; /* function argument */
71
72 ulong_t mepc; /* machine exception program counter */
73 ulong_t mstatus; /* machine status register */
74
75 ulong_t s0; /* callee-saved s0 */
76
77 ulong_t tp; /* thread pointer */
78#ifdef CONFIG_USERSPACE
79 ulong_t sp; /* preserved (user or kernel) stack pointer */
80#endif
81
82#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
83 RV_FP_TYPE ft0; /* Caller-saved temporary floating register */
84 RV_FP_TYPE ft1; /* Caller-saved temporary floating register */
85 RV_FP_TYPE ft2; /* Caller-saved temporary floating register */
86 RV_FP_TYPE ft3; /* Caller-saved temporary floating register */
87 RV_FP_TYPE ft4; /* Caller-saved temporary floating register */
88 RV_FP_TYPE ft5; /* Caller-saved temporary floating register */
89 RV_FP_TYPE ft6; /* Caller-saved temporary floating register */
90 RV_FP_TYPE ft7; /* Caller-saved temporary floating register */
91 RV_FP_TYPE ft8; /* Caller-saved temporary floating register */
92 RV_FP_TYPE ft9; /* Caller-saved temporary floating register */
93 RV_FP_TYPE ft10; /* Caller-saved temporary floating register */
94 RV_FP_TYPE ft11; /* Caller-saved temporary floating register */
95 RV_FP_TYPE fa0; /* function argument/return value */
96 RV_FP_TYPE fa1; /* function argument/return value */
97 RV_FP_TYPE fa2; /* function argument */
98 RV_FP_TYPE fa3; /* function argument */
99 RV_FP_TYPE fa4; /* function argument */
100 RV_FP_TYPE fa5; /* function argument */
101 RV_FP_TYPE fa6; /* function argument */
102 RV_FP_TYPE fa7; /* function argument */
103#endif
104
105#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
106 struct soc_esf soc_context;
107#endif
108} __aligned(16);
109
110typedef struct __esf z_arch_esf_t;
111#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
112typedef struct soc_esf soc_esf_t;
113#endif
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif /* _ASMLANGUAGE */
120
121#endif /* ZEPHYR_INCLUDE_ARCH_RISCV_EXP_H_ */
unsigned long ulong_t
Definition: types.h:18
#define RV_FP_TYPE
Definition: exp.h:48
struct k_thread t2
Definition: main.c:27
static ZTEST_DMEM int tp
Definition: main.c:62
Macros to abstract toolchain specific capabilities.