summaryrefslogtreecommitdiff
path: root/sys/src/9/zynq/trap.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-12-20 22:34:41 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2020-12-20 22:34:41 +0100
commite4ce6aadac9e1de8d5ea625e9680d24cabce0e1a (patch)
tree63c0b00f6f2c8eac29d4a0354d402206bc61397a /sys/src/9/zynq/trap.c
parent08c1622b0d8de92c2650d7b0338d9abf20985827 (diff)
kernel: handle tos and per process pcycle counters in port/
we might as well handle the per process cycle counter in the portable part instead of duplicating the code in every arch and have inconsistent implementations. we now have a portable kenter() and kexit() function, that is ment to be used in trap/syscall from user, which updates the counters. some kernels missed initializing Mach.cyclefreq.
Diffstat (limited to 'sys/src/9/zynq/trap.c')
-rw-r--r--sys/src/9/zynq/trap.c42
1 files changed, 4 insertions, 38 deletions
diff --git a/sys/src/9/zynq/trap.c b/sys/src/9/zynq/trap.c
index fbd55e74a..92bdd4107 100644
--- a/sys/src/9/zynq/trap.c
+++ b/sys/src/9/zynq/trap.c
@@ -150,13 +150,7 @@ trap(Ureg *ureg)
int user;
ulong opc, cp;
- user = userureg(ureg);
- if(user){
- if(up == nil)
- panic("user trap: up=nil");
- up->dbgreg = ureg;
- cycles(&up->kentry);
- }
+ user = kenter(ureg);
switch(ureg->type){
case PsrMund:
ureg->pc -= 4;
@@ -213,15 +207,12 @@ syscall(Ureg *ureg)
ulong scallnr;
vlong startns, stopns;
- if(!userureg(ureg))
+ if(!kenter(ureg))
panic("syscall: pc=%#.8lux", ureg->pc);
- cycles(&up->kentry);
-
m->syscall++;
up->insyscall = 1;
up->pc = ureg->pc;
- up->dbgreg = ureg;
sp = ureg->sp;
up->scallnr = scallnr = ureg->r0;
@@ -511,8 +502,6 @@ dbgpc(Proc *)
void
procsave(Proc *p)
{
- uvlong t;
-
if(p->fpstate == FPactive){
if(p->state == Moribund)
fpclear();
@@ -520,42 +509,19 @@ procsave(Proc *p)
fpsave(p->fpsave);
p->fpstate = FPinactive;
}
- cycles(&t);
- p->kentry -= t;
- p->pcycles += t;
-
l1switch(&m->l1, 0);
}
void
procrestore(Proc *p)
{
- uvlong t;
-
- if(p->kp)
- return;
-
- cycles(&t);
- p->kentry += t;
- p->pcycles -= t;
-}
-
-static void
-linkproc(void)
-{
- spllo();
- up->kpfun(up->kparg);
- pexit("kproc dying", 0);
}
void
-kprocchild(Proc* p, void (*func)(void*), void* arg)
+kprocchild(Proc *p, void (*entry)(void))
{
- p->sched.pc = (uintptr) linkproc;
+ p->sched.pc = (uintptr) entry;
p->sched.sp = (uintptr) p->kstack + KSTACK;
-
- p->kpfun = func;
- p->kparg = arg;
}
void