/* * reboot() system call. * * Note: this is here because it's directly related to the code above, * not because this is where system call code should go. Other syscall * code should probably live in the "syscall" directory. */ int sys_reboot(int code) { switch (code) { case RB_REBOOT: case RB_HALT: case RB_POWEROFF: break; default: return EINVAL; } shutdown(); switch (code) { case RB_HALT: kprintf("The system is halted.\n"); mainbus_halt(); break; case RB_REBOOT: kprintf("Rebooting...\n"); mainbus_reboot(); break; case RB_POWEROFF: kprintf("The system is halted.\n"); mainbus_poweroff(); break; } panic("reboot operation failed\n"); return 0; }
/* * Reboot the system. */ void mainbus_reboot(void) { /* * The MIPS doesn't appear to have any on-chip reset. * LAMEbus doesn't have a reset control, so we just * power off instead of rebooting. This would not be * so great in a real system, but it's fine for what * we're doing. */ kprintf("Cannot reboot - powering off instead, sorry.\n"); mainbus_poweroff(); }
/* * Called to reset the system from panic(). * * By the time we get here, the system may well be sufficiently hosed * as to panic recursively if we do much of anything. So just power off. * (We'd reboot, but System/161 doesn't do that.) */ void mainbus_panic(void) { mainbus_poweroff(); }