1 /* 2 * Copyright (c) 2016 Jean-Paul Etienne <fractalclone@gmail.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief RISCV32 kernel structure member offset definition file 10 * 11 * This module is responsible for the generation of the absolute symbols whose 12 * value represents the member offsets for various RISCV32 kernel 13 * structures. 14 */ 15 16 #include <zephyr/arch/exception.h> 17 #include <zephyr/kernel.h> 18 #include <kernel_arch_data.h> 19 #include <gen_offset.h> 20 21 #ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE 22 #include <soc_context.h> 23 #endif 24 #ifdef CONFIG_RISCV_SOC_OFFSETS 25 #include <soc_offsets.h> 26 #endif 27 28 #include <kernel_offsets.h> 29 30 /* struct _callee_saved member offsets */ 31 GEN_OFFSET_SYM(_callee_saved_t, sp); 32 GEN_OFFSET_SYM(_callee_saved_t, ra); 33 GEN_OFFSET_SYM(_callee_saved_t, s0); 34 GEN_OFFSET_SYM(_callee_saved_t, s1); 35 #if !defined(CONFIG_RISCV_ISA_RV32E) 36 GEN_OFFSET_SYM(_callee_saved_t, s2); 37 GEN_OFFSET_SYM(_callee_saved_t, s3); 38 GEN_OFFSET_SYM(_callee_saved_t, s4); 39 GEN_OFFSET_SYM(_callee_saved_t, s5); 40 GEN_OFFSET_SYM(_callee_saved_t, s6); 41 GEN_OFFSET_SYM(_callee_saved_t, s7); 42 GEN_OFFSET_SYM(_callee_saved_t, s8); 43 GEN_OFFSET_SYM(_callee_saved_t, s9); 44 GEN_OFFSET_SYM(_callee_saved_t, s10); 45 GEN_OFFSET_SYM(_callee_saved_t, s11); 46 #endif /* !CONFIG_RISCV_ISA_RV32E */ 47 48 #if defined(CONFIG_FPU_SHARING) 49 50 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa0); 51 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa1); 52 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa2); 53 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa3); 54 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa4); 55 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa5); 56 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa6); 57 GEN_OFFSET_SYM(z_riscv_fp_context_t, fa7); 58 59 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft0); 60 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft1); 61 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft2); 62 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft3); 63 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft4); 64 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft5); 65 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft6); 66 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft7); 67 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft8); 68 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft9); 69 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft10); 70 GEN_OFFSET_SYM(z_riscv_fp_context_t, ft11); 71 72 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs0); 73 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs1); 74 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs2); 75 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs3); 76 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs4); 77 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs5); 78 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs6); 79 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs7); 80 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs8); 81 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs9); 82 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs10); 83 GEN_OFFSET_SYM(z_riscv_fp_context_t, fs11); 84 85 GEN_OFFSET_SYM(z_riscv_fp_context_t, fcsr); 86 87 GEN_OFFSET_SYM(_thread_arch_t, exception_depth); 88 89 #endif /* CONFIG_FPU_SHARING */ 90 91 /* esf member offsets */ 92 GEN_OFFSET_STRUCT(arch_esf, ra); 93 GEN_OFFSET_STRUCT(arch_esf, t0); 94 GEN_OFFSET_STRUCT(arch_esf, t1); 95 GEN_OFFSET_STRUCT(arch_esf, t2); 96 GEN_OFFSET_STRUCT(arch_esf, a0); 97 GEN_OFFSET_STRUCT(arch_esf, a1); 98 GEN_OFFSET_STRUCT(arch_esf, a2); 99 GEN_OFFSET_STRUCT(arch_esf, a3); 100 GEN_OFFSET_STRUCT(arch_esf, a4); 101 GEN_OFFSET_STRUCT(arch_esf, a5); 102 103 #if !defined(CONFIG_RISCV_ISA_RV32E) 104 GEN_OFFSET_STRUCT(arch_esf, t3); 105 GEN_OFFSET_STRUCT(arch_esf, t4); 106 GEN_OFFSET_STRUCT(arch_esf, t5); 107 GEN_OFFSET_STRUCT(arch_esf, t6); 108 GEN_OFFSET_STRUCT(arch_esf, a6); 109 GEN_OFFSET_STRUCT(arch_esf, a7); 110 #endif /* !CONFIG_RISCV_ISA_RV32E */ 111 112 GEN_OFFSET_STRUCT(arch_esf, mepc); 113 GEN_OFFSET_STRUCT(arch_esf, mstatus); 114 115 #ifdef CONFIG_CLIC_SUPPORT_INTERRUPT_LEVEL 116 GEN_OFFSET_STRUCT(arch_esf, mcause); 117 #endif /* CONFIG_CLIC_SUPPORT_INTERRUPT_LEVEL */ 118 119 GEN_OFFSET_STRUCT(arch_esf, s0); 120 121 #ifdef CONFIG_USERSPACE 122 GEN_OFFSET_STRUCT(arch_esf, sp); 123 #endif 124 125 #ifdef CONFIG_EXTRA_EXCEPTION_INFO 126 GEN_OFFSET_STRUCT(arch_esf, csf); 127 #endif /* CONFIG_EXTRA_EXCEPTION_INFO */ 128 129 #if defined(CONFIG_RISCV_SOC_CONTEXT_SAVE) 130 GEN_OFFSET_STRUCT(arch_esf, soc_context); 131 #endif 132 #if defined(CONFIG_RISCV_SOC_OFFSETS) 133 GEN_SOC_OFFSET_SYMS(); 134 #endif 135 136 GEN_ABSOLUTE_SYM(__struct_arch_esf_SIZEOF, sizeof(struct arch_esf)); 137 138 #ifdef CONFIG_EXCEPTION_DEBUG 139 GEN_ABSOLUTE_SYM(__callee_saved_t_SIZEOF, ROUND_UP(sizeof(_callee_saved_t), ARCH_STACK_PTR_ALIGN)); 140 #endif /* CONFIG_EXCEPTION_DEBUG */ 141 142 #ifdef CONFIG_USERSPACE 143 GEN_OFFSET_SYM(_cpu_arch_t, user_exc_sp); 144 GEN_OFFSET_SYM(_cpu_arch_t, user_exc_tmp0); 145 GEN_OFFSET_SYM(_cpu_arch_t, user_exc_tmp1); 146 #endif 147 148 GEN_ABS_SYM_END 149