MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / handle_user

Function handle_user

libcpu/risc-v/common64/trap.c:157–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155#ifdef RT_USING_SMART
156#include "lwp.h"
157void handle_user(rt_ubase_t scause, rt_ubase_t stval, rt_ubase_t sepc,
158 struct rt_hw_stack_frame *sp)
159{
160 rt_ubase_t id = __MASKVALUE(scause, __MASK(63UL));
161 struct rt_lwp *lwp;
162
163 /* user page fault */
164 enum rt_mm_fault_op fault_op;
165 enum rt_mm_fault_type fault_type;
166 switch (id)
167 {
168 case EP_LOAD_PAGE_FAULT:
169 fault_op = MM_FAULT_OP_READ;
170 fault_type = MM_FAULT_TYPE_GENERIC_MMU;
171 break;
172 case EP_LOAD_ACCESS_FAULT:
173 fault_op = MM_FAULT_OP_READ;
174 fault_type = MM_FAULT_TYPE_BUS_ERROR;
175 break;
176 case EP_LOAD_ADDRESS_MISALIGNED:
177 fault_op = MM_FAULT_OP_READ;
178 fault_type = MM_FAULT_TYPE_BUS_ERROR;
179 break;
180 case EP_STORE_PAGE_FAULT:
181 fault_op = MM_FAULT_OP_WRITE;
182 fault_type = MM_FAULT_TYPE_GENERIC_MMU;
183 break;
184 case EP_STORE_ACCESS_FAULT:
185 fault_op = MM_FAULT_OP_WRITE;
186 fault_type = MM_FAULT_TYPE_BUS_ERROR;
187 break;
188 case EP_STORE_ADDRESS_MISALIGNED:
189 fault_op = MM_FAULT_OP_WRITE;
190 fault_type = MM_FAULT_TYPE_BUS_ERROR;
191 break;
192 case EP_INSTRUCTION_PAGE_FAULT:
193 fault_op = MM_FAULT_OP_EXECUTE;
194 fault_type = MM_FAULT_TYPE_GENERIC_MMU;
195 break;
196 case EP_INSTRUCTION_ACCESS_FAULT:
197 fault_op = MM_FAULT_OP_EXECUTE;
198 fault_type = MM_FAULT_TYPE_BUS_ERROR;
199 break;
200 case EP_INSTRUCTION_ADDRESS_MISALIGNED:
201 fault_op = MM_FAULT_OP_EXECUTE;
202 fault_type = MM_FAULT_TYPE_BUS_ERROR;
203 break;
204 default:
205 fault_op = 0;
206 }
207
208 if (fault_op)
209 {
210 rt_base_t saved_stat;
211 lwp = lwp_self();
212 struct rt_aspace_fault_msg msg = {
213 .fault_op = fault_op,
214 .fault_type = fault_type,

Callers 1

handle_trapFunction · 0.85

Calls 8

lwp_selfFunction · 0.85
rt_aspace_fault_try_fixFunction · 0.85
get_exception_msgFunction · 0.85
dump_regsFunction · 0.85
rt_thread_selfFunction · 0.85
rt_kprintfFunction · 0.85
lwp_backtrace_frameFunction · 0.85
sys_exit_groupFunction · 0.85

Tested by

no test coverage detected