if (apm_set_powstate(APM_DEV_DISK(0xff), APM_SYS_OFF) == 0) {
rv = apm_set_powstate(APM_DEV_DISK(0xff), APM_SYS_OFF); if (rv == 0 || rv == ENXIO) {
boot(howto)	int howto;{	extern int cold;	if (cold) {		howto |= RB_HALT;		goto haltsys;	}	boothowto = howto;	if ((howto & RB_NOSYNC) == 0 && waittime < 0) {		extern struct proc proc0;		/* protect against curproc->p_stats.foo refs in sync()   XXX */		if (curproc == NULL)			curproc = &proc0;		waittime = 0;		vfs_shutdown();		/*		 * If we've been adjusting the clock, the todr		 * will be out of synch; adjust it now.		 */		if ((howto & RB_TIMEBAD) == 0) {			resettodr();		} else {			printf("WARNING: not updating battery clock\n");		}	}	/* Disable interrupts. */	splhigh();	/* Do a dump if requested. */	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP) {		/* Save registers. */		savectx(&dumppcb);				dumpsys();	}haltsys:	doshutdownhooks();	if (howto & RB_HALT) {#if NAPM > 0		if (howto & RB_POWERDOWN) {			printf("\nAttempting to power down...\n");			/*			 * Turn off, if we can.  But try to turn disk off and		 	 * wait a bit first--some disk drives are slow to			 * clean up and users have reported disk corruption.			 *			 * If apm_set_powstate() fails the first time, don't			 * try to turn the system off.		 	 */			delay(500000);			if (apm_set_powstate(APM_DEV_DISK(0xff),					     APM_SYS_OFF) == 0) {				delay(500000);				(void) apm_set_powstate(APM_DEV_ALLDEVS,							APM_SYS_OFF);			}		}#endif		printf("\n");		printf("The operating system has halted.\n");		printf("Please press any key to reboot.\n\n");		cngetc();	}	printf("rebooting...\n");	cpu_reset();	for(;;) ;	/*NOTREACHED*/}