summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-05-30 23:26:21 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-05-30 23:26:21 +0200
commitd94ffb4808670993b2c434d612d432548c693832 (patch)
treeded3f05af0c1c46b5c8a7e5bfae405fe76b34ad2
parent9652f5bec54d946775892249c83059c9ca0c6440 (diff)
kernel: do all fp state fork from procfork() (like pc kernel)
this simplifies the arm ports and keeps all the stuff in one place instead of spreading it thru notify(), trap() and syscall() functions and prevents useless fp state copying for kernel procs. also make sure to save fp in notify while still splhi().
-rw-r--r--sys/src/9/alphapc/trap.c14
-rw-r--r--sys/src/9/bcm/fns.h3
-rw-r--r--sys/src/9/bcm/vfp3.c49
-rw-r--r--sys/src/9/kw/fns.h2
-rw-r--r--sys/src/9/kw/softfpu.c21
-rw-r--r--sys/src/9/kw/syscall.c4
-rw-r--r--sys/src/9/omap/arch.c2
-rw-r--r--sys/src/9/omap/fns.h3
-rw-r--r--sys/src/9/omap/softfpu.c30
-rw-r--r--sys/src/9/omap/syscall.c4
-rw-r--r--sys/src/9/ppc/trap.c16
-rw-r--r--sys/src/9/teg2/fns.h2
-rw-r--r--sys/src/9/teg2/softfpu.c21
-rw-r--r--sys/src/9/teg2/syscall.c4
-rw-r--r--sys/src/9/teg2/vfp3.c27
15 files changed, 45 insertions, 157 deletions
diff --git a/sys/src/9/alphapc/trap.c b/sys/src/9/alphapc/trap.c
index 4767c802a..556b0bb13 100644
--- a/sys/src/9/alphapc/trap.c
+++ b/sys/src/9/alphapc/trap.c
@@ -523,16 +523,16 @@ notify(Ureg *ur)
if(up->nnote == 0)
return 0;
- spllo();
- qlock(&up->debug);
- up->notepending = 0;
-
if(up->fpstate == FPactive){
savefpregs(&up->fpsave);
up->fpstate = FPinactive;
}
up->fpstate |= FPillegal;
+ spllo();
+ qlock(&up->debug);
+ up->notepending = 0;
+
n = &up->note[0];
if(strncmp(n->msg, "sys:", 4) == 0) {
l = strlen(n->msg);
@@ -712,12 +712,6 @@ syscall(Ureg *aur)
scallnr = ur->r0;
up->scallnr = ur->r0;
-
- if(scallnr == RFORK && up->fpstate == FPactive){
- savefpregs(&up->fpsave);
- up->fpstate = FPinactive;
-//print("SR=%lux+", up->fpsave.fpstatus);
- }
spllo();
sp = ur->sp;
diff --git a/sys/src/9/bcm/fns.h b/sys/src/9/bcm/fns.h
index 1c480cc14..cca55de35 100644
--- a/sys/src/9/bcm/fns.h
+++ b/sys/src/9/bcm/fns.h
@@ -82,9 +82,8 @@ extern void fpunoted(void);
extern void fpunotify(Ureg*);
extern void fpuprocrestore(Proc*);
extern void fpuprocsave(Proc*);
+extern void fpuprocfork(Proc*);
extern void fpusysprocsetup(Proc*);
-extern void fpusysrfork(Ureg*);
-extern void fpusysrforkchild(Proc*, Ureg*, Proc*);
extern int fpuemu(Ureg*);
/*
* Things called from port.
diff --git a/sys/src/9/bcm/vfp3.c b/sys/src/9/bcm/vfp3.c
index e87cf1d32..77070ba1c 100644
--- a/sys/src/9/bcm/vfp3.c
+++ b/sys/src/9/bcm/vfp3.c
@@ -239,33 +239,6 @@ fpunoted(void)
up->fpstate &= ~FPillegal;
}
-/*
- * Called early in the non-interruptible path of
- * sysrfork() via the machine-dependent syscall() routine.
- * Save the state so that it can be easily copied
- * to the child process later.
- */
-void
-fpusysrfork(Ureg*)
-{
- if(up->fpstate == FPactive){
- fpsave(&up->fpsave);
- up->fpstate = FPinactive;
- }
-}
-
-/*
- * Called later in sysrfork() via the machine-dependent
- * sysrforkchild() routine.
- * Copy the parent FPU state to the child.
- */
-void
-fpusysrforkchild(Proc *p, Ureg *, Proc *up)
-{
- /* don't penalize the child, it hasn't done FP in a note handler. */
- p->fpstate = up->fpstate & ~FPillegal;
-}
-
/* should only be called if p->fpstate == FPactive */
void
fpsave(FPsave *fps)
@@ -333,6 +306,28 @@ fpuprocrestore(Proc *)
}
/*
+ * The current process has been forked,
+ * save and copy neccesary state to child.
+ */
+void
+fpuprocfork(Proc *p)
+{
+ int s;
+
+ s = splhi();
+ switch(up->fpstate & ~FPillegal){
+ case FPactive:
+ fpsave(&up->fpsave);
+ up->fpstate = FPinactive;
+ /* no break */
+ case FPinactive:
+ p->fpsave = up->fpsave;
+ p->fpstate = FPinactive;
+ }
+ splx(s);
+}
+
+/*
* Disable the FPU.
* Called from sysexec() via sysprocsetup() to
* set the FPU for the new process.
diff --git a/sys/src/9/kw/fns.h b/sys/src/9/kw/fns.h
index 8fdfb46b4..b2f4d0f99 100644
--- a/sys/src/9/kw/fns.h
+++ b/sys/src/9/kw/fns.h
@@ -99,8 +99,6 @@ extern void fpunotify(Ureg*);
extern void fpuprocrestore(Proc*);
extern void fpuprocsave(Proc*);
extern void fpusysprocsetup(Proc*);
-extern void fpusysrfork(Ureg*);
-extern void fpusysrforkchild(Proc*, Ureg *, Proc*);
extern int fpuemu(Ureg*);
/*
diff --git a/sys/src/9/kw/softfpu.c b/sys/src/9/kw/softfpu.c
index b412a6bf1..229c7e1a1 100644
--- a/sys/src/9/kw/softfpu.c
+++ b/sys/src/9/kw/softfpu.c
@@ -42,27 +42,6 @@ fpunoted(void)
}
void
-fpusysrfork(Ureg*)
-{
- /*
- * Called early in the non-interruptible path of
- * sysrfork() via the machine-dependent syscall() routine.
- * Save the state so that it can be easily copied
- * to the child process later.
- */
-}
-
-void
-fpusysrforkchild(Proc*, Ureg*, Proc*)
-{
- /*
- * Called later in sysrfork() via the machine-dependent
- * sysrforkchild() routine.
- * Copy the parent FPU state to the child.
- */
-}
-
-void
fpuprocsave(Proc*)
{
/*
diff --git a/sys/src/9/kw/syscall.c b/sys/src/9/kw/syscall.c
index 6aaba6db2..4853cfd83 100644
--- a/sys/src/9/kw/syscall.c
+++ b/sys/src/9/kw/syscall.c
@@ -201,8 +201,6 @@ syscall(Ureg* ureg)
scallnr = ureg->r0;
up->scallnr = scallnr;
- if(scallnr == RFORK)
- fpusysrfork(ureg);
spllo();
sp = ureg->sp;
@@ -332,6 +330,4 @@ forkchild(Proc *p, Ureg *ureg)
/* Things from bottom of syscall which were never executed */
p->psstate = 0;
p->insyscall = 0;
-
- fpusysrforkchild(p, cureg, up);
}
diff --git a/sys/src/9/omap/arch.c b/sys/src/9/omap/arch.c
index 4714168b0..0563ca543 100644
--- a/sys/src/9/omap/arch.c
+++ b/sys/src/9/omap/arch.c
@@ -134,6 +134,8 @@ procfork(Proc* p)
{
p->kentry = up->kentry;
p->pcycles = -p->kentry;
+
+ fpuprocfork(p);
}
/*
diff --git a/sys/src/9/omap/fns.h b/sys/src/9/omap/fns.h
index a1e486dda..6735ae2d8 100644
--- a/sys/src/9/omap/fns.h
+++ b/sys/src/9/omap/fns.h
@@ -114,8 +114,7 @@ extern void fpunotify(Ureg*);
extern void fpuprocrestore(Proc*);
extern void fpuprocsave(Proc*);
extern void fpusysprocsetup(Proc*);
-extern void fpusysrfork(Ureg*);
-extern void fpusysrforkchild(Proc*, Ureg*, Proc*);
+extern void fpuprocfork(Proc*);
extern int fpuemu(Ureg*);
/*
diff --git a/sys/src/9/omap/softfpu.c b/sys/src/9/omap/softfpu.c
index 7f01446c0..817b502db 100644
--- a/sys/src/9/omap/softfpu.c
+++ b/sys/src/9/omap/softfpu.c
@@ -42,27 +42,6 @@ fpunoted(void)
}
void
-fpusysrfork(Ureg*)
-{
- /*
- * Called early in the non-interruptible path of
- * sysrfork() via the machine-dependent syscall() routine.
- * Save the state so that it can be easily copied
- * to the child process later.
- */
-}
-
-void
-fpusysrforkchild(Proc*, Ureg *, Proc*)
-{
- /*
- * Called later in sysrfork() via the machine-dependent
- * sysrforkchild() routine.
- * Copy the parent FPU state to the child.
- */
-}
-
-void
fpuprocsave(Proc*)
{
/*
@@ -86,6 +65,15 @@ fpuprocrestore(Proc*)
}
void
+fpuprocfork(Proc*)
+{
+ /*
+ * The current process has been forked, save and copy neccesary
+ * state to child. Nothing to do here, child proc starts with FPinit.
+ */
+}
+
+void
fpusysprocsetup(Proc*)
{
/*
diff --git a/sys/src/9/omap/syscall.c b/sys/src/9/omap/syscall.c
index f9f390e2b..e40a82174 100644
--- a/sys/src/9/omap/syscall.c
+++ b/sys/src/9/omap/syscall.c
@@ -205,8 +205,6 @@ syscall(Ureg* ureg)
scallnr = ureg->r0;
up->scallnr = scallnr;
- if(scallnr == RFORK)
- fpusysrfork(ureg);
spllo();
sp = ureg->sp;
@@ -328,6 +326,4 @@ forkchild(Proc *p, Ureg *ureg)
/* Things from bottom of syscall which were never executed */
p->psstate = 0;
p->insyscall = 0;
-
- fpusysrforkchild(p, cureg, up);
}
diff --git a/sys/src/9/ppc/trap.c b/sys/src/9/ppc/trap.c
index ab3e713a4..eaf1f2a52 100644
--- a/sys/src/9/ppc/trap.c
+++ b/sys/src/9/ppc/trap.c
@@ -633,10 +633,6 @@ syscall(Ureg* ureg)
scallnr = ureg->r3;
up->scallnr = ureg->r3;
- if(scallnr == RFORK && up->fpstate == FPactive){
- fpsave(&up->fpsave);
- up->fpstate = FPinactive;
- }
spllo();
sp = ureg->usp;
@@ -714,6 +710,12 @@ notify(Ureg* ur)
if(up->nnote == 0)
return 0;
+ if(up->fpstate == FPactive){
+ fpsave(&up->fpsave);
+ up->fpstate = FPinactive;
+ }
+ up->fpstate |= FPillegal;
+
s = spllo();
qlock(&up->debug);
up->notepending = 0;
@@ -743,12 +745,6 @@ notify(Ureg* ur)
pexit(n->msg, n->flag!=NDebug);
}
- if(up->fpstate == FPactive){
- fpsave(&up->fpsave);
- up->fpstate = FPinactive;
- }
- up->fpstate |= FPillegal;
-
sp = ur->usp & ~(BY2V-1);
sp -= sizeof(Ureg);
diff --git a/sys/src/9/teg2/fns.h b/sys/src/9/teg2/fns.h
index 1e2e55fe5..5e740176c 100644
--- a/sys/src/9/teg2/fns.h
+++ b/sys/src/9/teg2/fns.h
@@ -172,8 +172,6 @@ extern void fpunotify(Ureg*);
extern void fpuprocrestore(Proc*);
extern void fpuprocsave(Proc*);
extern void fpusysprocsetup(Proc*);
-extern void fpusysrfork(Ureg*);
-extern void fpusysrforkchild(Proc*, Ureg*, Proc*);
extern int fpuemu(Ureg*);
/*
diff --git a/sys/src/9/teg2/softfpu.c b/sys/src/9/teg2/softfpu.c
index 752391f2c..0966bc18a 100644
--- a/sys/src/9/teg2/softfpu.c
+++ b/sys/src/9/teg2/softfpu.c
@@ -42,27 +42,6 @@ fpunoted(void)
}
void
-fpusysrfork(Ureg*)
-{
- /*
- * Called early in the non-interruptible path of
- * sysrfork() via the machine-dependent syscall() routine.
- * Save the state so that it can be easily copied
- * to the child process later.
- */
-}
-
-void
-fpusysrforkchild(Proc*, Ureg *, Proc*)
-{
- /*
- * Called later in sysrfork() via the machine-dependent
- * sysrforkchild() routine.
- * Copy the parent FPU state to the child.
- */
-}
-
-void
fpuprocsave(Proc*)
{
/*
diff --git a/sys/src/9/teg2/syscall.c b/sys/src/9/teg2/syscall.c
index adaa39962..4cf83093a 100644
--- a/sys/src/9/teg2/syscall.c
+++ b/sys/src/9/teg2/syscall.c
@@ -209,8 +209,6 @@ syscall(Ureg* ureg)
scallnr = ureg->r0;
up->scallnr = scallnr;
- if(scallnr == RFORK)
- fpusysrfork(ureg);
spllo();
sp = ureg->sp;
@@ -361,6 +359,4 @@ forkchild(Proc *p, Ureg *ureg)
/* Things from bottom of syscall which were never executed */
p->psstate = 0;
p->insyscall = 0;
-
- fpusysrforkchild(p, cureg, up);
}
diff --git a/sys/src/9/teg2/vfp3.c b/sys/src/9/teg2/vfp3.c
index 16d45490e..6d14f34cf 100644
--- a/sys/src/9/teg2/vfp3.c
+++ b/sys/src/9/teg2/vfp3.c
@@ -239,33 +239,6 @@ fpunoted(void)
up->fpstate &= ~FPillegal;
}
-/*
- * Called early in the non-interruptible path of
- * sysrfork() via the machine-dependent syscall() routine.
- * Save the state so that it can be easily copied
- * to the child process later.
- */
-void
-fpusysrfork(Ureg*)
-{
- if(up->fpstate == FPactive){
- fpsave(&up->fpsave);
- up->fpstate = FPinactive;
- }
-}
-
-/*
- * Called later in sysrfork() via the machine-dependent
- * sysrforkchild() routine.
- * Copy the parent FPU state to the child.
- */
-void
-fpusysrforkchild(Proc *p, Ureg *, Proc *up)
-{
- /* don't penalize the child, it hasn't done FP in a note handler. */
- p->fpstate = up->fpstate & ~FPillegal;
-}
-
/* should only be called if p->fpstate == FPactive */
void
fpsave(FPsave *fps)