summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include/fpu.h
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-06-05 15:59:59 +0000
committerkib <kib@FreeBSD.org>2010-06-05 15:59:59 +0000
commit2d77212fe48ecc0a97a3c56ca4cb8dc37493a066 (patch)
treebcc333531405cbc8269cbb94116e1781440b2ed4 /sys/amd64/include/fpu.h
parentfbdcfea8cb5a809b733223e1c53a383040e1dc4b (diff)
downloadFreeBSD-src-2d77212fe48ecc0a97a3c56ca4cb8dc37493a066.zip
FreeBSD-src-2d77212fe48ecc0a97a3c56ca4cb8dc37493a066.tar.gz
Introduce the x86 kernel interfaces to allow kernel code to use
FPU/SSE hardware. Caller should provide a save area that is chained into the stack of the areas; pcb save_area for usermode FPU state is on top. The pcb now contains a pointer to the current FPU saved area, used during FPUDNA handling and context switches. There is also a facility to allow the kernel thread to use pcb save_area. Change the dreaded warnings "npxdna in kernel mode!" into the panics when FPU usage is not registered. KPI discussed with: fabient Tested by: pho, fabient Hardware provided by: Sentex Communications MFC after: 1 month
Diffstat (limited to 'sys/amd64/include/fpu.h')
-rw-r--r--sys/amd64/include/fpu.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/amd64/include/fpu.h b/sys/amd64/include/fpu.h
index 272f94a..ca0ac8f 100644
--- a/sys/amd64/include/fpu.h
+++ b/sys/amd64/include/fpu.h
@@ -73,6 +73,17 @@ struct savefpu {
u_char sv_pad[96];
} __aligned(16);
+#ifdef _KERNEL
+struct fpu_kern_ctx {
+ struct savefpu hwstate;
+ struct savefpu *prev;
+ uint32_t flags;
+};
+#define FPU_KERN_CTX_FPUINITDONE 0x01
+
+#define PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNFPU) == 0)
+#endif
+
/*
* The hardware default control word for i387's and later coprocessors is
* 0x37F, giving:
@@ -102,9 +113,22 @@ void fpudrop(void);
void fpuexit(struct thread *td);
int fpuformat(void);
int fpugetregs(struct thread *td, struct savefpu *addr);
+int fpugetuserregs(struct thread *td, struct savefpu *addr);
void fpuinit(void);
void fpusetregs(struct thread *td, struct savefpu *addr);
+void fpusetuserregs(struct thread *td, struct savefpu *addr);
int fputrap(void);
+int fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
+ u_int flags);
+int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
+int fpu_kern_thread(u_int flags);
+int is_fpu_kern_thread(u_int flags);
+
+/*
+ * Flags for fpu_kern_enter() and fpu_kern_thread().
+ */
+#define FPU_KERN_NORMAL 0x0000
+
#endif
#endif /* !_MACHINE_FPU_H_ */
OpenPOWER on IntegriCloud