diff options
author | jhb <jhb@FreeBSD.org> | 2014-09-22 20:34:36 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2014-09-22 20:34:36 +0000 |
commit | 09bff45095d2101db8b3ff94ac79129598b7cfe7 (patch) | |
tree | 9aca44b47e0ae8505d550d52451704b9bce3514e /sys/i386/isa | |
parent | 33a793a3e6389b4322cbb2871185706462c9cc55 (diff) | |
download | FreeBSD-src-09bff45095d2101db8b3ff94ac79129598b7cfe7.zip FreeBSD-src-09bff45095d2101db8b3ff94ac79129598b7cfe7.tar.gz |
MFC 270850,271053,271192,271717:
Save and restore FPU state across suspend and resume on i386.
- Create a separate structure for per-CPU state saved across suspend and
resume that is a superset of a pcb.
- Store the FPU state for suspend and resume in the new structure
(for amd64, this moves it out of the PCB)
- On both i386 and amd64, all of the FPU suspend/resume handling is now
done in C.
Approved by: re (hrs)
Diffstat (limited to 'sys/i386/isa')
-rw-r--r-- | sys/i386/isa/npx.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index dec7366..dd8403a 100644 --- a/sys/i386/isa/npx.c +++ b/sys/i386/isa/npx.c @@ -761,6 +761,43 @@ npxsave(addr) PCPU_SET(fpcurthread, NULL); } +/* + * Unconditionally save the current co-processor state across suspend and + * resume. + */ +void +npxsuspend(union savefpu *addr) +{ + register_t cr0; + + if (!hw_float) + return; + if (PCPU_GET(fpcurthread) == NULL) { + *addr = npx_initialstate; + return; + } + cr0 = rcr0(); + clts(); + fpusave(addr); + load_cr0(cr0); +} + +void +npxresume(union savefpu *addr) +{ + register_t cr0; + + if (!hw_float) + return; + + cr0 = rcr0(); + clts(); + npxinit(); + stop_emulating(); + fpurstor(addr); + load_cr0(cr0); +} + void npxdrop() { |