Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/amd64/fpu.c
Show All 32 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/domainset.h> | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
▲ Show 20 Lines • Show All 976 Lines • ▼ Show 20 Lines | |||||
#define FPU_KERN_CTX_INUSE 0x04 | #define FPU_KERN_CTX_INUSE 0x04 | ||||
struct fpu_kern_ctx { | struct fpu_kern_ctx { | ||||
struct savefpu *prev; | struct savefpu *prev; | ||||
uint32_t flags; | uint32_t flags; | ||||
char hwstate1[]; | char hwstate1[]; | ||||
}; | }; | ||||
static inline size_t __pure2 | |||||
fpu_kern_alloc_sz(u_int max_est) | |||||
{ | |||||
return (sizeof(struct fpu_kern_ctx) + XSAVE_AREA_ALIGN + max_est); | |||||
} | |||||
static inline int __pure2 | |||||
fpu_kern_malloc_flags(u_int fpflags) | |||||
{ | |||||
return (((fpflags & FPU_KERN_NOWAIT) ? M_NOWAIT : M_WAITOK) | M_ZERO); | |||||
} | |||||
struct fpu_kern_ctx * | struct fpu_kern_ctx * | ||||
fpu_kern_alloc_ctx(u_int flags) | fpu_kern_alloc_ctx_domain(int domain, u_int flags) | ||||
{ | { | ||||
struct fpu_kern_ctx *res; | return (malloc_domainset(fpu_kern_alloc_sz(cpu_max_ext_state_size), | ||||
size_t sz; | M_FPUKERN_CTX, DOMAINSET_PREF(domain), | ||||
fpu_kern_malloc_flags(flags))); | |||||
} | |||||
sz = sizeof(struct fpu_kern_ctx) + XSAVE_AREA_ALIGN + | struct fpu_kern_ctx * | ||||
cpu_max_ext_state_size; | fpu_kern_alloc_ctx(u_int flags) | ||||
res = malloc(sz, M_FPUKERN_CTX, ((flags & FPU_KERN_NOWAIT) ? | { | ||||
M_NOWAIT : M_WAITOK) | M_ZERO); | return (malloc(fpu_kern_alloc_sz(cpu_max_ext_state_size), | ||||
return (res); | M_FPUKERN_CTX, fpu_kern_malloc_flags(flags))); | ||||
} | } | ||||
void | void | ||||
fpu_kern_free_ctx(struct fpu_kern_ctx *ctx) | fpu_kern_free_ctx(struct fpu_kern_ctx *ctx) | ||||
{ | { | ||||
KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("free'ing inuse ctx")); | KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("free'ing inuse ctx")); | ||||
/* XXXKIB clear the memory ? */ | /* XXXKIB clear the memory ? */ | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |