2 #include "../port/lib.h"
6 #include "../port/error.h"
14 * A lot of this stuff doesn't belong here
15 * but this is a convenient dumping ground for
16 * later sorting into the appropriate buckets.
19 /* Give enough context in the ureg to produce a kernel stack for
23 setkernur(Ureg* ureg, Proc* p)
25 ureg->pc = p->sched.pc;
26 ureg->sp = p->sched.sp+4;
27 ureg->r14 = PTR2UINT(sched);
34 evenaddr(uintptr addr)
37 postnote(up, 1, "sys: odd address", NDebug);
42 /* go to user space */
49 /* precise time accounting, kernel exit */
50 tos = (Tos*)(USTKTOP-sizeof(Tos));
52 tos->kcycles += t - up->kentry;
53 tos->pcycles = t + up->pcycles;
54 tos->cyclefreq = Frequency;
57 /* make visible immediately to user proc */
58 cachedwbinvse(tos, sizeof *tos);
62 * return the userpc the last exception happened at
67 Ureg *ureg = up->dbgreg;
71 /* This routine must save the values of registers the user is not permitted
72 * to write from devproc and then restore the saved values before returning.
75 setregisters(Ureg* ureg, char* pureg, char* uva, int n)
77 USED(ureg, pureg, uva, n);
81 * this is the body for all kproc's
88 pexit("kproc exiting", 0);
92 * setup stack and initial PC for a new kernel proc. This is architecture
93 * dependent because of the starting stack location
96 kprocchild(Proc *p, void (*func)(void*), void *arg)
98 p->sched.pc = PTR2UINT(linkproc);
99 p->sched.sp = PTR2UINT(p->kstack+KSTACK);
106 * pc output by dumpaproc
121 * set mach dependent process state for a new process
129 p->pcycles = -p->kentry;
135 p->kentry = up->kentry;
136 p->pcycles = -p->kentry;
140 * Save the mach dependent part of the process state.
172 return (ureg->psr & PsrMask) == PsrMusr;
177 * make sure that we don't drag in the C library versions
224 cas32(void* addr, u32int old, u32int new)
229 if(r = (*(u32int*)addr == old))
230 *(u32int*)addr = new;