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 = (uintptr)sched;
34 evenaddr(uintptr addr)
37 postnote(up, 1, "sys: odd address", NDebug);
43 * return the userpc the last exception happened at
48 Ureg *ureg = up->dbgreg;
52 /* This routine must save the values of registers the user is not permitted
53 * to write from devproc and then restore the saved values before returning.
56 setregisters(Ureg* ureg, char* pureg, char* uva, int n)
59 memmove(pureg, uva, n);
60 ureg->psr = ureg->psr & ~(PsrMask|PsrDfiq|PsrDirq) | v & (PsrMask|PsrDfiq|PsrDirq);
64 * setup stack and initial PC for a new kernel proc. This is architecture
65 * dependent because of the starting stack location
68 kprocchild(Proc *p, void (*entry)(void))
70 p->sched.pc = (uintptr)entry;
71 p->sched.sp = (uintptr)p->kstack+KSTACK;
75 * pc output by dumpaproc
90 * set mach dependent process state for a new process
105 * Save the mach dependent part of the process state.
110 // TODO: save and restore VFPv3 FP state once 5[cal] know the new registers.
123 return (ureg->psr & PsrMask) == PsrMusr;
127 cas32(void* addr, u32int old, u32int new)
132 if(r = (*(u32int*)addr == old))
133 *(u32int*)addr = new;