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/bcm/arch.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/bcm/arch.c')
-rw-r--r-- | sys/src/9/bcm/arch.c | 57 |
1 files changed, 2 insertions, 55 deletions
diff --git a/sys/src/9/bcm/arch.c b/sys/src/9/bcm/arch.c index da6bb2602..fb97a3ea9 100644 --- a/sys/src/9/bcm/arch.c +++ b/sys/src/9/bcm/arch.c @@ -39,25 +39,6 @@ evenaddr(uintptr addr) } } -/* go to user space */ -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->cyclefreq = m->cpuhz; - tos->pid = up->pid; - - /* make visible immediately to user proc */ - cachedwbinvse(tos, sizeof *tos); -} - /* * return the userpc the last exception happened at */ @@ -80,28 +61,14 @@ setregisters(Ureg* ureg, char* pureg, char* uva, int n) } /* - * this is the body for all kproc's - */ -static void -linkproc(void) -{ - spllo(); - up->kpfun(up->kparg); - pexit("kproc exiting", 0); -} - -/* * setup stack and initial PC for a new kernel proc. This is architecture * dependent because of the starting stack location */ 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; } /* @@ -126,17 +93,11 @@ void procsetup(Proc* p) { fpusysprocsetup(p); - - cycles(&p->kentry); - p->pcycles = -p->kentry; } void procfork(Proc* p) { - p->kentry = up->kentry; - p->pcycles = -p->kentry; - fpuprocfork(p); } @@ -146,12 +107,6 @@ procfork(Proc* p) void procsave(Proc* p) { - uvlong t; - - cycles(&t); - p->pcycles += t; - p->kentry -= t; - // TODO: save and restore VFPv3 FP state once 5[cal] know the new registers. fpuprocsave(p); @@ -173,14 +128,6 @@ procsave(Proc* p) void procrestore(Proc* p) { - uvlong t; - - if(p->kp) - return; - cycles(&t); - p->pcycles -= t; - p->kentry += t; - fpuprocrestore(p); } |