Exemplo n.º 1
0
Arquivo: apm.c Projeto: bluhm/sys
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);
}
Exemplo n.º 2
0
/*
 * 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);
}
Exemplo n.º 3
0
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;
}