diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-20 22:34:41 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-20 22:34:41 +0100 |
commit | e4ce6aadac9e1de8d5ea625e9680d24cabce0e1a (patch) | |
tree | 63c0b00f6f2c8eac29d4a0354d402206bc61397a /sys/src/9/ppc/trap.c | |
parent | 08c1622b0d8de92c2650d7b0338d9abf20985827 (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/ppc/trap.c')
-rw-r--r-- | sys/src/9/ppc/trap.c | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/sys/src/9/ppc/trap.c b/sys/src/9/ppc/trap.c index b11b9fa0d..533f252b4 100644 --- a/sys/src/9/ppc/trap.c +++ b/sys/src/9/ppc/trap.c @@ -141,35 +141,16 @@ char *regname[]={ }; void -kexit(Ureg*) -{ - uvlong t; - Tos *tos; - - /* precise time accounting, kernel exit */ - tos = (Tos*)(USTKTOP-sizeof(Tos)); - cycles(&t); - tos->kcycles += t - up->kentry; - tos->pcycles = t + up->pcycles; - tos->pid = up->pid; -} - -void trap(Ureg *ureg) { int ecode, user; char buf[ERRMAX], *s; extern FPsave initfp; - ecode = (ureg->cause >> 8) & 0xff; - user = (ureg->srr1 & MSR_PR) != 0; - if(user){ - cycles(&up->kentry); - up->dbgreg = ureg; - } + user = kenter(ureg); if((ureg->status & MSR_RI) == 0) print("double fault?: ecode = %d\n", ecode); - + ecode = (ureg->cause >> 8) & 0xff; switch(ecode) { case CEI: m->intr++; @@ -495,22 +476,11 @@ dumpregs(Ureg *ur) delay(500); } -static void -linkproc(void) -{ - spllo(); - (*up->kpfun)(up->kparg); - pexit("", 0); -} - void -kprocchild(Proc *p, void (*func)(void*), void *arg) +kprocchild(Proc *p, void (*entry)(void)) { - p->sched.pc = (ulong)linkproc; + p->sched.pc = (ulong)entry; p->sched.sp = (ulong)p->kstack+KSTACK; - - p->kpfun = func; - p->kparg = arg; } /* @@ -618,7 +588,6 @@ syscall(Ureg* ureg) m->syscall++; up->insyscall = 1; up->pc = ureg->pc; - up->dbgreg = ureg; if (up->fpstate == FPactive && (ureg->srr1 & MSR_FP) == 0){ print("fpstate check, entry syscall\n"); |