/* * set any of the following * - time in nsec * - nsec trim applied over some seconds * - clock frequency */ static int writebintime(char *buf, int n) { uint8_t *p; int64_t delta; int32_t period; n--; p = (uint8_t*)buf + 1; switch(*buf){ case 'n': if(n < sizeof(int64_t)) error(Ebadtimectl); le2int64_t(&delta, p); todset(delta, 0, 0); break; case 'd': if(n < sizeof(int64_t)+sizeof(int32_t)) error(Ebadtimectl); p = le2int64_t(&delta, p); le2long(&period, p); todset(-1, delta, period); break; case 'f': if(n < sizeof(uint64_t)) error(Ebadtimectl); le2int64_t(&fasthz, p); todsetfreq(fasthz); break; } return n; }
/* * set any of the following * - time in nsec * - nsec trim applied over some seconds * - clock frequency */ static int writebintime(char *buf, int n) { uchar *p; vlong delta; long period; n--; p = (uchar*)buf + 1; switch(*buf){ case 'n': if(n < sizeof(vlong)) error(Ebadtimectl); le2vlong(&delta, p); todset(delta, 0, 0); break; case 'd': if(n < sizeof(vlong)+sizeof(long)) error(Ebadtimectl); p = le2vlong(&delta, p); le2long(&period, p); todset(-1, delta, period); break; case 'f': if(n < sizeof(uvlong)) error(Ebadtimectl); le2vlong(&fasthz, p); if(fasthz <= 0) error(Ebadtimectl); todsetfreq(fasthz); break; } return n; }
/* * set any of the following * - time in nsec * - nsec trim applied over some seconds * - clock frequency */ static int writebintime(char *buf, int n) { uint8_t *p; int64_t delta = 0; long period = 0; n--; p = (uint8_t *) buf + 1; switch (*buf) { case 'n': if (n < sizeof(int64_t)) error(EINVAL, ERROR_FIXME); le2int64_t(&delta, p); #if 0 todset(delta, 0, 0); #endif break; case 'd': if (n < sizeof(int64_t) + sizeof(long)) error(EINVAL, ERROR_FIXME); p = le2int64_t(&delta, p); le2long(&period, p); #if 0 todset(-1, delta, period); #endif break; case 'f': if (n < sizeof(uint64_t)) error(EINVAL, ERROR_FIXME); le2int64_t(&fasthz, p); if (fasthz <= 0) error(EINVAL, ERROR_FIXME); #if 0 todsetfreq(fasthz); #endif break; } return n; }
/* * set the time in seconds */ static int writetime(char *buf, int n) { char b[13]; int32_t i; int64_t now; if(n >= sizeof(b)) error(Ebadtimectl); strncpy(b, buf, n); b[n] = 0; i = strtol(b, 0, 0); if(i <= 0) error(Ebadtimectl); now = i*1000000000LL; todset(now, 0, 0); return n; }
/* * set the time in seconds */ static int writetime(char *buf, int n) { char b[13]; long i; int64_t now; if (n >= sizeof(b)) error(EINVAL, "bad size in writetime"); strncpy(b, buf, n); b[n] = 0; i = strtol(b, 0, 0); if (i <= 0) error(EINVAL, "Bad time in write"); now = i * 1000000000LL; #if 0 todset(now, 0, 0); #endif return n; }
void deepsleep(void) { static int power_pl; ulong xsp, xlink; // ulong mecr; ulong clkd; vlong savedtod; extern void power_resume(void); power_pl = splhi(); xlink = getcallerpc(&xlink); /* Power down */ pcmciapower(0); irpower(0); audiopower(0); screenpower(0); µcpower(0); iprint("entering suspend mode, sp = %#p, pc = 0x%lux, psw = 0x%ux\n", &xsp, xlink, power_pl); // dumpitall(); delay(1000); uartpower(0); rs232power(0); clockpower(0); gpiosave(&savedgpioregs, gpioregs); intrcpy(&savedintrregs, intrregs); cacheflush(); delay(50); if(setpowerlabel()){ /* return here with mmu back on */ trapresume(); gpiorestore(gpioregs, &savedgpioregs); delay(50); intrcpy(intrregs, &savedintrregs); if(intrregs->icip & (1<<IRQgpio0)){ // don't want to sleep now. clear on/off irq. gpioregs->edgestatus = (1<<IRQgpio0); intrregs->icip = (1<<IRQgpio0); } clkd = clockpower(1); gpclkregs->r0 = 1<<0; todset(savedtod + clkd * TODFREQ, 0LL, 0); resetsuspendtimer(); rs232power(1); uartpower(1); delay(100); xlink = getcallerpc(&xlink); iprint("\nresuming execution, sp = %#p, pc = 0x%lux, psw = 0x%ux\n", &xsp, xlink, splhi()); // dumpitall(); delay(1000); // irpower(1); audiopower(1); µcpower(1); screenpower(1); pcmciapower(1); splx(power_pl); return; } cacheflush(); delay(100); savedtod = todget(nil); power_down(); /* no return */ }