void zapm_poweroff(void) { struct pxa2x0_apm_softc *sc; int s; KASSERT(apm_cd.cd_ndevs > 0 && apm_cd.cd_devs[0] != NULL); sc = apm_cd.cd_devs[0]; #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif /* NWSDISPLAY > 0 */ s = splhigh(); config_suspend_all(DVACT_SUSPEND); suspend_randomness(); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; config_suspend_all(DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; /* XXX enable charging during suspend */ /* XXX keep power LED state during suspend */ /* XXX do the same thing for GPIO 43 (BTTXD) */ /* XXX scoop power down */ /* XXX set PGSRn and GPDRn */ pxa2x0_wakeup_config(PXA2X0_WAKEUP_ALL, 1); do { pxa2x0_apm_sleep(sc); } while (!zapm_resume(sc)); zapm_restart(); /* NOTREACHED */ config_suspend_all(DVACT_RESUME); splx(s); resume_randomness(NULL, 0); /* force RNG upper level reseed */ bufq_restart(); config_suspend_all(DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif /* NWSDISPLAY > 0 */ }
void apm_suspend(int state) { extern int perflevel; int s; #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif /* NWSDISPLAY > 0 */ stop_periodic_resettodr(); config_suspend_all(DVACT_QUIESCE); bufq_quiesce(); s = splhigh(); intr_disable(); cold = 2; config_suspend_all(DVACT_SUSPEND); suspend_randomness(); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; config_suspend_all(DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; /* Send machine to sleep */ apm_set_powstate(APM_DEV_ALLDEVS, state); /* Wake up */ /* They say that some machines may require reinitializing the clocks */ i8254_startclock(); if (initclock_func == i8254_initclocks) rtcstart(); /* in i8254 mode, rtc is profclock */ inittodr(time_second); config_suspend_all(DVACT_RESUME); cold = 0; intr_enable(); splx(s); resume_randomness(NULL, 0); /* force RNG upper level reseed */ bufq_restart(); config_suspend_all(DVACT_WAKEUP); start_periodic_resettodr(); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif /* NWSDISPLAY > 0 */ /* restore hw.setperf */ if (cpu_setperf != NULL) cpu_setperf(perflevel); }
__dead void boot(int howto) { if (cold) { if ((howto & RB_USERREQ) == 0) howto |= RB_HALT; goto haltsys; } /* * If RB_NOSYNC was not specified sync the discs. * Note: Unless cold is set to 1 here, syslogd will die during the * unmount. It looks like syslogd is getting woken up only to find * that it cannot page part of the binary in as the filesystem has * been unmounted. */ if ((howto & RB_NOSYNC) == 0) bootsync(howto); if_downall(); uvm_shutdown(); splhigh(); cold = 1; if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP) dumpsys(); haltsys: config_suspend_all(DVACT_POWERDOWN); /* Make sure IRQ's are disabled */ IRQdisable; if ((howto & RB_HALT) != 0) { if ((howto & RB_POWERDOWN) != 0) { board_powerdown(); printf("WARNING: powerdown failed!\n"); } printf("The operating system has halted.\n"); printf("Please press any key to reboot.\n\n"); cnpollc(1); cngetc(); cnpollc(0); } printf("rebooting...\n"); board_reset(); cpu_reset(); printf("reboot failed; spinning\n"); for (;;) ; /* NOTREACHED */ }
__dead void boot(int howto) { if (curproc && curproc->p_addr) savectx(curpcb); if (cold) { if ((howto & RB_USERREQ) == 0) howto |= RB_HALT; goto haltsys; } boothowto = howto; if ((howto & RB_NOSYNC) == 0) { vfs_shutdown(); if ((howto & RB_TIMEBAD) == 0) { resettodr(); } else { printf("WARNING: not updating battery clock\n"); } } if_downall(); uvm_shutdown(); splhigh(); cold = 1; if ((howto & RB_DUMP) != 0) dumpsys(); haltsys: config_suspend_all(DVACT_POWERDOWN); if ((howto & RB_HALT) != 0) { printf("System halted.\n\n"); bootstack(); cmmu_shutdown(); scm_halt(); } doboot(); for (;;) ; /* NOTREACHED */ }
/* * Called before suspending when all ca_activate functions are done. */ void zapm_suspend(struct pxa2x0_apm_softc *pxa_sc) { struct zapm_softc *sc = (struct zapm_softc *)pxa_sc; config_suspend_all(DVACT_QUIESCE); bufq_quiesce(); /* Poll in suspended mode and forget the discharge timeout. */ sc->sc_suspended = 1; timeout_del(&sc->sc_poll); /* Make sure charging is enabled and RTC alarm is set. */ timerclear(&sc->sc_lastbattchk); zapm_poll(sc); #if 0 pxa2x0_rtc_setalarm(pxa2x0_rtc_getsecs() + 5); #endif pxa2x0_wakeup_config(PXA2X0_WAKEUP_ALL, 1); }
int apm_suspend(int state) { int rv; int s; #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif resettodr(); config_suspend_all(DVACT_QUIESCE); bufq_quiesce(); s = splhigh(); (void)disableintr(); cold = 1; rv = config_suspend_all(DVACT_SUSPEND); suspend_randomness(); #ifdef HIBERNATE if (state == APM_IOC_HIBERNATE) { uvm_pmr_zero_everything(); if (hibernate_suspend()) { printf("apm: hibernate_suspend failed"); hibernate_free(); uvm_pmr_dirty_everything(); return (ECANCELED); } } #endif /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; config_suspend_all(DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; if (rv == 0) { rv = sys_platform->suspend(); if (rv == 0) rv = sys_platform->resume(); } inittodr(time_second); /* Move the clock forward */ config_suspend_all(DVACT_RESUME); cold = 0; (void)enableintr(); splx(s); resume_randomness(NULL, 0); /* force RNG upper level reseed */ bufq_restart(); config_suspend_all(DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif return rv; }