MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fpu_kern_enter

Function fpu_kern_enter

freebsd/arm64/arm64/vfp.c:270–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void
271fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
272{
273 struct pcb *pcb;
274
275 pcb = td->td_pcb;
276 KASSERT((flags & FPU_KERN_NOCTX) != 0 || ctx != NULL,
277 ("ctx is required when !FPU_KERN_NOCTX"));
278 KASSERT(ctx == NULL || (ctx->flags & FPU_KERN_CTX_INUSE) == 0,
279 ("using inuse ctx"));
280 KASSERT((pcb->pcb_fpflags & PCB_FP_NOSAVE) == 0,
281 ("recursive fpu_kern_enter while in PCB_FP_NOSAVE state"));
282
283 if ((flags & FPU_KERN_NOCTX) != 0) {
284 critical_enter();
285 if (curthread == PCPU_GET(fpcurthread)) {
286 vfp_save_state(curthread, pcb);
287 }
288 PCPU_SET(fpcurthread, NULL);
289
290 vfp_enable();
291 pcb->pcb_fpflags |= PCB_FP_KERN | PCB_FP_NOSAVE |
292 PCB_FP_STARTED;
293 return;
294 }
295
296 if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
297 ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
298 return;
299 }
300 /*
301 * Check either we are already using the VFP in the kernel, or
302 * the the saved state points to the default user space.
303 */
304 KASSERT((pcb->pcb_fpflags & PCB_FP_KERN) != 0 ||
305 pcb->pcb_fpusaved == &pcb->pcb_fpustate,
306 ("Mangled pcb_fpusaved %x %p %p", pcb->pcb_fpflags, pcb->pcb_fpusaved, &pcb->pcb_fpustate));
307 ctx->flags = FPU_KERN_CTX_INUSE;
308 vfp_save_state(curthread, pcb);
309 ctx->prev = pcb->pcb_fpusaved;
310 pcb->pcb_fpusaved = &ctx->state;
311 pcb->pcb_fpflags |= PCB_FP_KERN;
312 pcb->pcb_fpflags &= ~PCB_FP_STARTED;
313
314 return;
315}
316
317int
318fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx)

Callers

nothing calls this directly

Calls 4

vfp_save_stateFunction · 0.85
vfp_enableFunction · 0.85
is_fpu_kern_threadFunction · 0.70
critical_enterFunction · 0.50

Tested by

no test coverage detected