|
AquilaOS documentation
How it works, and its code
|
aarch64: the FP/SIMD registers, switched lazily, as x86's FPU is (see docs/kernel/processes.md). More...
#include <core/system.h>#include <core/arch.h>#include <core/string.h>#include <cpu/cpu.h>#include <sys/proc.h>#include <sys/sched.h>#include <sys/signal.h>Go to the source code of this file.
Macros | |
| #define | CPACR_FPEN_EL0_TRAP (1UL << 20) |
| #define | CPACR_FPEN_NONE (3UL << 20) |
| #define | fp_thread (curcpu()->arch.fp_thread) |
Functions | |
| void | aarch64_fpsimd_save (void *state) |
| void | aarch64_fpsimd_load (const void *state) |
| static void | fpen (uint64_t v) |
| Sets CPACR_EL1.FPEN: whether user mode's use traps. | |
| void | aarch64_fpsimd_switch (struct thread *thread) |
| Gets the registers ready for a thread that is about to run: its use of them traps, unless the registers already hold its values. | |
| void * | aarch64_fpsimd_current (struct thread *thread) |
| Returns a thread's FP/SIMD state as it is now, saving it from the registers first if they hold it. | |
| int | aarch64_fpsimd_trap (void) |
| Handles the trap of user mode's use of the registers: they get the running thread's values, and its use stops trapping. | |
| void | aarch64_fpsimd_drop (struct thread *thread) |
| Throws away a thread's FP/SIMD state, when it goes or execs a new program, and the registers' values if they're the thread's. | |
| int | aarch64_fpsimd_fork (struct thread *parent, struct aarch64_thread *child) |
| Gives a child of fork() a copy of its parent's FP/SIMD state, if the parent has one. | |
| void | aarch64_fpsimd_restore (struct thread *thread, const void *state) |
| Gives a thread back the FP/SIMD state that a signal frame kept, for sigreturn(). | |
aarch64: the FP/SIMD registers, switched lazily, as x86's FPU is (see docs/kernel/processes.md).
User mode's use of the registers traps (CPACR_EL1.FPEN = 0b01: EL0's accesses trap, EL1's don't, and the kernel uses none), unless the CPU's registers already hold the running thread's values. At the trap, the thread whose values they hold (the CPU's fp_thread) gets them saved, the running thread's are loaded (zeros, the first time), and its use stops trapping.
References: [1] - Arm Architecture Reference Manual for A-profile, D19.2 (CPACR_EL1.FPEN) and the exception class 0x07
Definition in file fpsimd.c.
| #define CPACR_FPEN_EL0_TRAP (1UL << 20) |
Definition at line 28 of file fpsimd.c.
Referenced by aarch64_fpsimd_drop(), aarch64_fpsimd_restore(), and aarch64_fpsimd_switch().
| #define CPACR_FPEN_NONE (3UL << 20) |
Definition at line 29 of file fpsimd.c.
Referenced by aarch64_fpsimd_switch(), and aarch64_fpsimd_trap().
| #define fp_thread (curcpu()->arch.fp_thread) |
Definition at line 37 of file fpsimd.c.
Referenced by aarch64_fpsimd_current(), aarch64_fpsimd_drop(), aarch64_fpsimd_restore(), aarch64_fpsimd_switch(), and aarch64_fpsimd_trap().
| void * aarch64_fpsimd_current | ( | struct thread * | thread | ) |
Returns a thread's FP/SIMD state as it is now, saving it from the registers first if they hold it.
| thread | the thread |
Definition at line 64 of file fpsimd.c.
References aarch64_fpsimd_current(), aarch64_fpsimd_save(), thread::arch, fp_thread, and aarch64_thread::fpsimd.
Referenced by aarch64_fpsimd_current(), aarch64_fpsimd_fork(), and deliver().
| void aarch64_fpsimd_drop | ( | struct thread * | thread | ) |
Throws away a thread's FP/SIMD state, when it goes or execs a new program, and the registers' values if they're the thread's.
| thread | the thread |
Definition at line 106 of file fpsimd.c.
References aarch64_fpsimd_drop(), thread::arch, CPACR_FPEN_EL0_TRAP, fp_thread, fpen(), aarch64_thread::fpsimd, kfree(), and NULL.
Referenced by aarch64_fpsimd_drop(), arch_exec_start(), and arch_thread_kill().
| int aarch64_fpsimd_fork | ( | struct thread * | parent, |
| struct aarch64_thread * | child ) |
Gives a child of fork() a copy of its parent's FP/SIMD state, if the parent has one.
| parent | the thread that forked |
| child | the child's aarch64 state |
Definition at line 129 of file fpsimd.c.
References aarch64_fpsimd_current(), aarch64_fpsimd_fork(), aarch64_thread::fpsimd, FPSIMD_STATE_SIZE, kmalloc(), and memcpy().
Referenced by aarch64_fpsimd_fork(), and arch_proc_fork().
| void aarch64_fpsimd_load | ( | const void * | state | ) |
References aarch64_fpsimd_load().
Referenced by aarch64_fpsimd_load(), and aarch64_fpsimd_trap().
| void aarch64_fpsimd_restore | ( | struct thread * | thread, |
| const void * | state ) |
Gives a thread back the FP/SIMD state that a signal frame kept, for sigreturn().
The registers are loaded with it at their next use.
| thread | the thread |
| state | the state the frame kept, or NULL if it had none (the registers are then zeros) |
Definition at line 151 of file fpsimd.c.
References aarch64_fpsimd_restore(), thread::arch, CPACR_FPEN_EL0_TRAP, fp_thread, fpen(), aarch64_thread::fpsimd, FPSIMD_STATE_SIZE, memcpy(), memset(), and NULL.
Referenced by aarch64_fpsimd_restore(), and arch_sigreturn().
| void aarch64_fpsimd_save | ( | void * | state | ) |
References aarch64_fpsimd_save().
Referenced by aarch64_fpsimd_current(), aarch64_fpsimd_save(), and aarch64_fpsimd_trap().
| void aarch64_fpsimd_switch | ( | struct thread * | thread | ) |
Gets the registers ready for a thread that is about to run: its use of them traps, unless the registers already hold its values.
| thread | the thread about to run, or NULL |
Definition at line 52 of file fpsimd.c.
References aarch64_fpsimd_switch(), CPACR_FPEN_EL0_TRAP, CPACR_FPEN_NONE, fp_thread, and fpen().
Referenced by aarch64_fpsimd_switch(), arch_thread_spawn(), and arch_thread_switch().
| int aarch64_fpsimd_trap | ( | void | ) |
Handles the trap of user mode's use of the registers: they get the running thread's values, and its use stops trapping.
Definition at line 80 of file fpsimd.c.
References aarch64_fpsimd_load(), aarch64_fpsimd_save(), aarch64_fpsimd_trap(), thread::arch, CPACR_FPEN_NONE, curthread, fp_thread, fpen(), aarch64_thread::fpsimd, FPSIMD_STATE_SIZE, kmalloc(), and M_ZERO.
Referenced by aarch64_fpsimd_trap(), and sync_dispatch().
|
static |
Sets CPACR_EL1.FPEN: whether user mode's use traps.
Definition at line 40 of file fpsimd.c.
References fpen(), isb, and write_sysreg.
Referenced by aarch64_fpsimd_drop(), aarch64_fpsimd_restore(), aarch64_fpsimd_switch(), aarch64_fpsimd_trap(), and fpen().