summaryrefslogtreecommitdiff
path: root/sys/src/9/teg2/arch.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/teg2/arch.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/teg2/arch.c')
-rw-r--r--sys/src/9/teg2/arch.c49
1 files changed, 2 insertions, 47 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 */