summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/fpu.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-12-21 15:04:48 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2020-12-21 15:04:48 +0100
commit5a059477f8066f25ece1ba2b8c49ab8ea24d19de (patch)
tree98307032821f8c3fcc6858eafbd4852ba207b64a /sys/src/9/pc/fpu.c
parent932995bb27fa517192cb4130d3e79593a8904763 (diff)
pc, xen: move fpu setup/fork/save/restore handlers to pc/fpu.c
Diffstat (limited to 'sys/src/9/pc/fpu.c')
-rw-r--r--sys/src/9/pc/fpu.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/src/9/pc/fpu.c b/sys/src/9/pc/fpu.c
index e9467fc52..66812009e 100644
--- a/sys/src/9/pc/fpu.c
+++ b/sys/src/9/pc/fpu.c
@@ -307,3 +307,54 @@ fpuinit(void)
fprestore = fpx87restore;
}
}
+
+void
+fpuprocsetup(Proc *p)
+{
+ p->fpstate = FPinit;
+ fpoff();
+}
+
+void
+fpuprocfork(Proc *p)
+{
+ int s;
+
+ s = splhi();
+ switch(up->fpstate & ~FPillegal){
+ case FPactive:
+ fpsave(up->fpsave);
+ up->fpstate = FPinactive;
+ case FPinactive:
+ while(p->fpsave == nil)
+ p->fpsave = mallocalign(sizeof(FPsave), FPalign, 0, 0);
+ memmove(p->fpsave, up->fpsave, sizeof(FPsave));
+ p->fpstate = FPinactive;
+ }
+ splx(s);
+}
+
+void
+fpuprocsave(Proc *p)
+{
+ if(p->fpstate == FPactive){
+ if(p->state == Moribund)
+ fpclear();
+ else{
+ /*
+ * Fpsave() stores without handling pending
+ * unmasked exeptions. Postnote() can't be called
+ * so the handling of pending exceptions is delayed
+ * until the process runs again and generates an
+ * emulation fault to activate the FPU.
+ */
+ fpsave(p->fpsave);
+ }
+ p->fpstate = FPinactive;
+ }
+}
+
+void
+fpuprocrestore(Proc*)
+{
+}