|Do not wait for the available memory if the request could not be satisfied without sleep.|
|0||No special handling is required.|
The function returns the allocated context area, or NULL if the allocation failed.
The fpu_kern_free_ctx function frees the context previously allocated by fpu_kern_alloc_ctx.
The fpu_kern_enter function designates the start of the region of kernel code where the use of the FPU is allowed. Its arguments are:
|td||Currently must be curthread.|
|ctx||The context save area previously allocated by fpu_kern_alloc_ctx and not currently in use by another call to fpu_kern_enter.|
|flags||This argument currently accepts the following flags:|
|Indicates that the caller intends to access the full FPU state. Must be specified currently.|
|FPU_KERN_KTHR||Indicates that no saving of the current FPU state should be performed, if the thread called fpu_kern_thread(9) function. This is intended to minimize code duplication in callers which could be used from both kernel thread and syscall contexts. The fpu_kern_leave function correctly handles such contexts.|
The function does not sleep or block. It could cause the Device Not Available exception during execution, and on the first FPU access after the function returns, as well as after each context switch (see Intel Software Developer Manual for the reference). Currently, no errors are defined which can be returned by fpu_kern_enter to the caller.
The fpu_kern_leave function ends the region started by fpu_kern_enter. The uses of FPU in the kernel after the call to fpu_kern_leave are erronous until the next call to fpu_kern_enter is performed. The function takes the td thread argument, which currently must be curthread, and the ctx context pointer, previously passed to fpu_kern_enter. After the function returns, the context may be freed or reused by other invocation of fpu_kern_enter. There are no errors defined for the function, it always returns 0.
The fpu_kern_thread function provides an optimization for threads which never leave to the usermode. Such thread can reuse the usermode save area for the FPU state, which is allowed by the function call. There is no flags defined for the function, and no error states that the function returns.
The is_fpu_kern_thread function returns the boolean indicating whether the current thread entered the mode enabled by fpu_kern_thread. There is currently no flags defined for the function, the return value is true if the current thread have the permanent FPU save area, and false otherwise.
The fpu_kern is currently implemented only for the i386 and amd64 architectures.
There is no way to handle floating point exceptions raised from kernel mode.
The unused flags arguments to the fpu_kern functions are to be extended to allow specification of the set of the FPU hardware state used by the code region. This would allow optimizations of saving and restoring the state.
The fpu_kern facitily and this manual page were written by
.An Konstantin Belousov Aq Mt kib@FreeBSD.org .