if (apm_standbys || apm_suspends) DPRINTF(("damn fool BIOS did not wait for answer\n")); if (apm_record_event(sc, regs->bx)) { (void) apm_set_powstate(APM_DEV_ALLDEVS, APM_LASTREQ_INPROG);
if (apm_standbys || apm_suspends) { DPRINTF(("premature suspend\n")); apm_error++; } if (apm_record_event(sc, regs->bx))
apm_event_handle(sc, regs)	struct apm_softc *sc;	struct apmregs *regs;{	int error;	struct apmregs nregs;	switch(regs->bx) {	case APM_USER_STANDBY_REQ:		DPRINTF(("user wants STANDBY--fat chance\n"));		(void) apm_set_powstate(APM_DEV_ALLDEVS, APM_LASTREQ_REJECTED);		if (apm_record_event(sc, regs->bx))			apm_userstandbys++;		break;	case APM_STANDBY_REQ:		DPRINTF(("standby requested\n"));		if (apm_standbys || apm_suspends)			DPRINTF(("damn fool BIOS did not wait for answer\n"));		if (apm_record_event(sc, regs->bx)) {			(void) apm_set_powstate(APM_DEV_ALLDEVS,			    APM_LASTREQ_INPROG);			apm_standbys++;		} else			(void) apm_set_powstate(APM_DEV_ALLDEVS,			    APM_LASTREQ_REJECTED);		break;	case APM_USER_SUSPEND_REQ:		DPRINTF(("user wants suspend--fat chance!\n"));		(void) apm_set_powstate(APM_DEV_ALLDEVS, APM_LASTREQ_REJECTED);		if (apm_record_event(sc, regs->bx))			apm_suspends++;		break;	case APM_SUSPEND_REQ:		DPRINTF(("suspend requested\n"));		if (apm_standbys || apm_suspends)			DPRINTF(("damn fool BIOS did not wait for answer\n"));		if (apm_record_event(sc, regs->bx)) {			(void) apm_set_powstate(APM_DEV_ALLDEVS,			    APM_LASTREQ_INPROG);			apm_suspends++;		} else			(void) apm_set_powstate(APM_DEV_ALLDEVS,			    APM_LASTREQ_REJECTED);		break;	case APM_POWER_CHANGE:		DPRINTF(("power status change\n"));		error = apm_get_powstat(nregs);		if (error == 0 &&		    BATT_LIFE(&nregs) != APM_BATT_LIFE_UNKNOWN &&		    BATT_LIFE(&nregs) < cpu_apmwarn &&		    (sc->sc_flags & SCFLAG_PRINT) != SCFLAG_NOPRINT &&		    ((sc->sc_flags & SCFLAG_PRINT) != SCFLAG_PCTPRINT ||		     sc->batt_life != BATT_LIFE(&nregs)))			apm_power_print(sc, &nregs);		apm_record_event(sc, regs->bx);		break;	case APM_NORMAL_RESUME:		DPRINTF(("system resumed\n"));		apm_resume(sc, regs);		break;	case APM_CRIT_RESUME:		DPRINTF(("system resumed without us!\n"));		apm_resume(sc, regs);		break;	case APM_SYS_STANDBY_RESUME:		DPRINTF(("system standby resume\n"));		apm_resume(sc, regs);		break;	case APM_UPDATE_TIME:		DPRINTF(("update time, please\n"));		apm_resume(sc, regs);		break;	case APM_CRIT_SUSPEND_REQ:		DPRINTF(("suspend required immediately\n"));		apm_record_event(sc, regs->bx);		apm_suspend();		break;	case APM_BATTERY_LOW:		DPRINTF(("Battery low!\n"));		apm_battlow++;		apm_record_event(sc, regs->bx);		break;	default:		printf("APM nonstandard event code %x\n", regs->bx);	}}