Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/amd64/fpu.c
Show First 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static void | static void | ||||
fpuinitstate(void *arg __unused) | fpuinitstate(void *arg __unused) | ||||
{ | { | ||||
uint64_t *xstate_bv; | uint64_t *xstate_bv; | ||||
register_t saveintr; | register_t saveintr; | ||||
int cp[4], i, max_ext_n; | int cp[4], i, max_ext_n; | ||||
/* Do potentially blocking operations before disabling interrupts. */ | |||||
fpu_save_area_zone = uma_zcreate("FPU_save_area", | |||||
cpu_max_ext_state_size, NULL, NULL, NULL, NULL, | |||||
XSAVE_AREA_ALIGN - 1, 0); | |||||
fpu_initialstate = malloc(cpu_max_ext_state_size, M_DEVBUF, | fpu_initialstate = malloc(cpu_max_ext_state_size, M_DEVBUF, | ||||
M_WAITOK | M_ZERO); | M_WAITOK | M_ZERO); | ||||
if (use_xsave) { | |||||
max_ext_n = flsl(xsave_mask); | |||||
xsave_area_desc = malloc(max_ext_n * sizeof(struct | |||||
xsave_area_elm_descr), M_DEVBUF, M_WAITOK | M_ZERO); | |||||
} | |||||
saveintr = intr_disable(); | saveintr = intr_disable(); | ||||
stop_emulating(); | stop_emulating(); | ||||
fpusave_fxsave(fpu_initialstate); | fpusave_fxsave(fpu_initialstate); | ||||
if (fpu_initialstate->sv_env.en_mxcsr_mask) | if (fpu_initialstate->sv_env.en_mxcsr_mask) | ||||
cpu_mxcsr_mask = fpu_initialstate->sv_env.en_mxcsr_mask; | cpu_mxcsr_mask = fpu_initialstate->sv_env.en_mxcsr_mask; | ||||
else | else | ||||
cpu_mxcsr_mask = 0xFFBF; | cpu_mxcsr_mask = 0xFFBF; | ||||
Show All 13 Lines | fpuinitstate(void *arg __unused) | ||||
* Create a table describing the layout of the CPU Extended | * Create a table describing the layout of the CPU Extended | ||||
* Save Area. | * Save Area. | ||||
*/ | */ | ||||
if (use_xsave) { | if (use_xsave) { | ||||
xstate_bv = (uint64_t *)((char *)(fpu_initialstate + 1) + | xstate_bv = (uint64_t *)((char *)(fpu_initialstate + 1) + | ||||
offsetof(struct xstate_hdr, xstate_bv)); | offsetof(struct xstate_hdr, xstate_bv)); | ||||
*xstate_bv = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE; | *xstate_bv = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE; | ||||
max_ext_n = flsl(xsave_mask); | |||||
xsave_area_desc = malloc(max_ext_n * sizeof(struct | |||||
xsave_area_elm_descr), M_DEVBUF, M_WAITOK | M_ZERO); | |||||
/* x87 state */ | /* x87 state */ | ||||
xsave_area_desc[0].offset = 0; | xsave_area_desc[0].offset = 0; | ||||
xsave_area_desc[0].size = 160; | xsave_area_desc[0].size = 160; | ||||
/* XMM */ | /* XMM */ | ||||
xsave_area_desc[1].offset = 160; | xsave_area_desc[1].offset = 160; | ||||
xsave_area_desc[1].size = 288 - 160; | xsave_area_desc[1].size = 288 - 160; | ||||
for (i = 2; i < max_ext_n; i++) { | for (i = 2; i < max_ext_n; i++) { | ||||
cpuid_count(0xd, i, cp); | cpuid_count(0xd, i, cp); | ||||
xsave_area_desc[i].offset = cp[1]; | xsave_area_desc[i].offset = cp[1]; | ||||
xsave_area_desc[i].size = cp[0]; | xsave_area_desc[i].size = cp[0]; | ||||
} | } | ||||
} | } | ||||
fpu_save_area_zone = uma_zcreate("FPU_save_area", | |||||
cpu_max_ext_state_size, NULL, NULL, NULL, NULL, | |||||
XSAVE_AREA_ALIGN - 1, 0); | |||||
start_emulating(); | start_emulating(); | ||||
intr_restore(saveintr); | intr_restore(saveintr); | ||||
} | } | ||||
/* EFIRT needs this to be initialized before we can enter our EFI environment */ | /* EFIRT needs this to be initialized before we can enter our EFI environment */ | ||||
SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_FIRST, fpuinitstate, NULL); | SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_FIRST, fpuinitstate, NULL); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 779 Lines • Show Last 20 Lines |