/* * exit kernel either on a panic or user request */ void exit(int) { cpushutdown(); splfhi(); archreboot(); }
static void filock(Lock *l) { int x; x = splfhi(); ilock(l); l->sr = x; }
static int chanwait(Ep *ep, Ctlr *ctlr, Hostchan *hc, int mask) { int intr, n, x, ointr; ulong start, now; Dwcregs *r; r = ctlr->regs; n = hc - r->hchan; for(;;){ restart: x = splfhi(); r->haintmsk |= 1<<n; hc->hcintmsk = mask; sleep(&ctlr->chanintr[n], chandone, hc); hc->hcintmsk = 0; splx(x); intr = hc->hcint; if(intr & Chhltd) return intr; start = fastticks(0); ointr = intr; now = start; do{ intr = hc->hcint; if(intr & Chhltd){ if((ointr != Ack && ointr != (Ack|Xfercomp)) || intr != (Ack|Chhltd|Xfercomp) || (now - start) > 60) dprint("await %x after %ld %x -> %x\n", mask, now - start, ointr, intr); return intr; } if((intr & mask) == 0){ dprint("ep%d.%d await %x intr %x -> %x\n", ep->dev->nb, ep->nb, mask, ointr, intr); goto restart; } now = fastticks(0); }while(now - start < 100); dprint("ep%d.%d halting channel %8.8ux hcchar %8.8ux " "grxstsr %8.8ux gnptxsts %8.8ux hptxsts %8.8ux\n", ep->dev->nb, ep->nb, intr, hc->hcchar, r->grxstsr, r->gnptxsts, r->hptxsts); mask = Chhltd; hc->hcchar |= Chdis; start = m->ticks; while(hc->hcchar & Chen){ if(m->ticks - start >= 100){ print("ep%d.%d channel won't halt hcchar %8.8ux\n", ep->dev->nb, ep->nb, hc->hcchar); break; } } logdump(ep); } }
void installprof(void (*pf)(Ureg *, int)) { int s; s = splfhi(); prof_fcn = pf; timerenable( 2, HZ+1, profintr, 0); timer_incr[2] = timer_incr[0]+63; /* fine tuning */ splx(s); }
void powersuspend(void) { extern void suspenditall(void); GpioReg *g; ulong back = 0x43219990; /* check that the stack's right */ ulong pwer, gplr; ulong *rp; int i, s; s = splfhi(); archpowerdown(); /* sets PMGR and PPC appropriately */ if(DEBUG) dumpitall(); blankscreen(1); chandevpower(0); gplr = GPIOREG->gplr; for(i=0; (rp = coreregs[i]) != nil; i++) corestate[i] = *rp; pwer = PMGRREG->pwer; if(pwer == 0) pwer = 1<<0; g = GPIOREG; g->grer &= pwer; /* just the ones archpowerdown requested */ g->gfer &= pwer; g->gedr = g->gedr; RESETREG->rcsr = 0xF; /* reset all status */ minidcflush(); if(DEBUG) iprint("suspenditall...\n"); suspenditall(); /* keep us in suspense */ PMGRREG->pspr = 0; archpowerup(); trapstacks(); /* set output latches before gpdr restored */ GPIOREG->gpsr = gplr; GPIOREG->gpcr = ~gplr; for(i=0; (rp = coreregs[i]) != nil; i++) *rp = corestate[i]; GPIOREG->gedr = GPIOREG->gedr; /* reset GPIO interrupts (should we?) */ PMGRREG->pssr = PSSR_ph; /* cancel peripheral hold */ chandevpower(1); if(back != 0x43219990){ iprint("back %8.8lux\n", back); panic("powersuspend"); } blankscreen(0); if(DEBUG) dumpitall(); splx(s); }
void uartputs(char *data, int len) { int x; clockpoll(); x = splfhi(); while (len--){ if(*data == '\n') uartputc('\r'); uartputc(*data++); } splx(x); }
static void sofwait(Ctlr *ctlr, int n) { Dwcregs *r; int x; r = ctlr->regs; do{ r->gintsts = Sofintr; x = splfhi(); ctlr->sofchan |= 1<<n; r->gintmsk |= Sofintr; sleep(&ctlr->chanintr[n], sofdone, r); splx(x); }while((r->hfnum & 7) == 6); }