- power_off ();
-}
-
-
-/* Reboots the machine we're running on. */
-void
-reboot (void)
-{
- int i;
-
- printf ("Rebooting...\n");
-
- /* based on reboot.c code by Osamu Tomita <tomita@cinet.co.jp>
- * See http://www.win.tue.nl/~aeb/linux/kbd/scancodes-11.html */
- for (i = 0; i < 100; i++) {
- int j;
-
- /* Poll keyboard controller's status byte until
- * 'input buffer empty' is reported, so it's ok to write */
- for (j = 0; j < 0x10000; j++)
- {
- if ((inb (0x64) & 0x02) == 0)
- break;
- timer_udelay (2);
- }
-
- timer_udelay (50);
-
- /* Pulse bit 0 of the output port P2 of the keyboard controller.
- * This will reset the CPU. */
- outb (0x64, 0xfe);
- timer_udelay (50);
- }
-}
-
-/* Powers down the machine we're running on,
- as long as we're running on Bochs or QEMU. */
-void
-power_off (void)
-{
- const char s[] = "Shutdown";
- const char *p;
-
-#ifdef FILESYS
- filesys_done ();
-#endif
-
- print_stats ();
-
- printf ("Powering off...\n");
- serial_flush ();
-
- for (p = s; *p != '\0'; p++)
- outb (0x8900, *p);
- asm volatile ("cli; hlt" : : : "memory");
- printf ("still running...\n");
- for (;;);
-}
-
-/* Print statistics about Pintos execution. */
-static void
-print_stats (void)
-{
- timer_print_stats ();
- thread_print_stats ();
-#ifdef FILESYS
- disk_print_stats ();
-#endif
- console_print_stats ();
- kbd_print_stats ();
-#ifdef USERPROG
- exception_print_stats ();
-#endif