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/teg2 | |
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/teg2')
-rw-r--r-- | sys/src/9/teg2/arch.c | 49 | ||||
-rw-r--r-- | sys/src/9/teg2/archtegra.c | 1 | ||||
-rw-r--r-- | sys/src/9/teg2/fns.h | 2 | ||||
-rw-r--r-- | sys/src/9/teg2/syscall.c | 5 | ||||
-rw-r--r-- | sys/src/9/teg2/trap.c | 7 |
5 files changed, 5 insertions, 59 deletions
diff --git a/sys/src/9/teg2/arch.c b/sys/src/9/teg2/arch.c index e1ffa273c..d60944a50 100644 --- a/sys/src/9/teg2/arch.c +++ b/sys/src/9/teg2/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 = up->pcycles; - tos->cyclefreq = m->cpuhz; - tos->pid = up->pid; - - /* make visible immediately to user phase */ - l1cache->wbse(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; } /* @@ -134,11 +101,6 @@ procsetup(Proc* p) void procsave(Proc* p) { - uvlong t; - - cycles(&t); - p->pcycles += t; - fpuprocsave(p); l1cache->wbse(p, sizeof *p); /* is this needed? */ l1cache->wb(); /* is this needed? */ @@ -147,21 +109,14 @@ procsave(Proc* p) void procfork(Proc* p) { - p->kentry = up->kentry; - p->pcycles = -p->kentry; - fpuprocfork(p); } void procrestore(Proc* p) { - uvlong t; - if(p->kp) return; - cycles(&t); - p->pcycles -= t; wakewfi(); /* in case there's another runnable proc */ /* let it fault in at first use */ diff --git a/sys/src/9/teg2/archtegra.c b/sys/src/9/teg2/archtegra.c index 534ee8b2c..d8f4606c4 100644 --- a/sys/src/9/teg2/archtegra.c +++ b/sys/src/9/teg2/archtegra.c @@ -327,6 +327,7 @@ archconfinit(void) if (hz >= 100*Mhz && hz <= 3600UL*Mhz) m->cpuhz = hz; } + m->cyclefreq = m->cpuhz; m->delayloop = m->cpuhz/2000; /* initial estimate */ errata(); } diff --git a/sys/src/9/teg2/fns.h b/sys/src/9/teg2/fns.h index 0c8733a55..a425e301a 100644 --- a/sys/src/9/teg2/fns.h +++ b/sys/src/9/teg2/fns.h @@ -191,8 +191,6 @@ extern int userureg(Ureg*); void* vmap(uintptr, usize); void vunmap(void*, usize); -extern void kexit(Ureg*); - #define getpgcolor(a) 0 #define kmapinval() diff --git a/sys/src/9/teg2/syscall.c b/sys/src/9/teg2/syscall.c index 6f49ac4d5..d444e7971 100644 --- a/sys/src/9/teg2/syscall.c +++ b/sys/src/9/teg2/syscall.c @@ -194,16 +194,13 @@ syscall(Ureg* ureg) int i, scallnr; vlong startns, stopns; - if(!userureg(ureg)) + if(!kenter(ureg)) panic("syscall: from kernel: pc %#lux r14 %#lux psr %#lux", ureg->pc, ureg->r14, ureg->psr); - cycles(&up->kentry); - m->syscall++; up->insyscall = 1; up->pc = ureg->pc; - up->dbgreg = ureg; scallnr = ureg->r0; up->scallnr = scallnr; diff --git a/sys/src/9/teg2/trap.c b/sys/src/9/teg2/trap.c index dfd57b2a5..697a5ae3a 100644 --- a/sys/src/9/teg2/trap.c +++ b/sys/src/9/teg2/trap.c @@ -831,12 +831,7 @@ trap(Ureg *ureg) } m->perf.intrts = perfticks(); - user = (ureg->psr & PsrMask) == PsrMusr; - if(user){ - up->dbgreg = ureg; - cycles(&up->kentry); - } - + user = kenter(ureg); /* * All interrupts/exceptions should be resumed at ureg->pc-4, * except for Data Abort which resumes at ureg->pc-8. |