ref: 7f224a8f6d343cf0aaf162cc9b9f7d4d62ac78ac
dir: /sys/src/9/omap4/arch.c/
#include "u.h" #include "ureg.h" #include "../port/lib.h" #include "../port/error.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "arm.h" #include "tos.h" void (*proctrace)(Proc *, int, vlong); uintptr userpc(void) { return dbgpc(up); } uintptr dbgpc(Proc *p) { Ureg *ureg; ureg = p->dbgreg; if(ureg == 0) return 0; return ureg->pc; } void setkernur(Ureg *ureg, Proc *p) { ureg->pc = p->sched.pc; ureg->sp = p->sched.sp+4; ureg->r14 = (ulong) sched; } void setregisters(Ureg *, char *, char *, int) { } void procsave(Proc *p) { uvlong t; cycles(&t); p->pcycles += t; } void procrestore(Proc *p) { uvlong t; cycles(&t); p->pcycles -= t; } void procfork(Proc *) { } void procsetup(Proc *p) { p->fpstate = FPinit; } static void linkproc(void) { spllo(); up->kpfun(up->kparg); pexit("kproc exiting", 0); } void kprocchild(Proc *p, void (*func)(void *), void *arg) { p->sched.pc = (ulong) linkproc; p->sched.sp = (ulong) p->kstack + KSTACK; p->kpfun = func; p->kparg = arg; } void forkchild(Proc *p, Ureg *ureg) { Ureg *cureg; p->sched.sp = (ulong) p->kstack + KSTACK - (sizeof(Ureg) + 8); p->sched.pc = (ulong) forkret; cureg = (Ureg*) (p->sched.sp + 8); memmove(cureg, ureg, sizeof(Ureg)); cureg->r0 = 0; p->psstate = 0; p->insyscall = 0; } uintptr execregs(uintptr entry, ulong ssize, ulong nargs) { ulong *sp; Ureg *ureg; sp = (ulong *) (USTKTOP - ssize); *--sp = nargs; ureg = up->dbgreg; memset(ureg, 0, sizeof *ureg); ureg->psr = PsrMusr; ureg->sp = (ulong) sp; ureg->pc = entry; return USTKTOP - sizeof(Tos); } void evenaddr(uintptr addr) { if(addr & 3){ postnote(up, 1, "sys: odd address", NDebug); error(Ebadarg); } } void _dumpstack(ulong sp, ulong pc) { int x; uintptr l, v, i, estack; x = 0; x += iprint("ktrace /arm/s9panda %#.8lux %#.8lux <<EOF\n", pc, sp); i = 0; if(up && (uintptr)&l >= (uintptr)up->kstack && (uintptr)&l <= (uintptr)up->kstack+KSTACK) estack = (uintptr)up->kstack+KSTACK; else if((uintptr)&l >= (uintptr)(KTZERO - BY2PG) && (uintptr)&l <= (uintptr)KTZERO) estack = (uintptr)KTZERO; else return; x += iprint("estackx %p\n", estack); for(l = (uintptr)&l; l < estack; l += sizeof(uintptr)){ v = *(uintptr*)l; if((KTZERO < v && v < (uintptr)etext) || estack-l < 32){ x += iprint("%.8p=%.8p ", l, v); i++; } if(i == 4){ i = 0; x += iprint("\n"); } } if(i) iprint("\n"); iprint("EOF\n"); } void printureg(Ureg *ureg) { print("R0 %.8ulx R1 %.8ulx R2 %.8ulx R3 %.8ulx\n", ureg->r0, ureg->r1, ureg->r2, ureg->r3); print("R4 %.8ulx R5 %.8ulx R6 %.8ulx R7 %.8ulx\n", ureg->r4, ureg->r5, ureg->r6, ureg->r7); print("R8 %.8ulx R9 %.8ulx R10 %.8ulx R11 %.8ulx\n", ureg->r8, ureg->r9, ureg->r10, ureg->r11); print("R12 %.8ulx R13 %.8ulx R14 %.8ulx R15 %.8ulx\n", ureg->r12, ureg->r13, ureg->r14, ureg->pc); print("PSR %.8ulx exception %ld\n", ureg->psr, ureg->type); }