From: Godmar Back Date: Wed, 27 Aug 2008 11:50:49 +0000 (+0000) Subject: cleaned up comments for reboot code and adopted GNU coding standards X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=commitdiff_plain;h=d92d837ee458bff7687e4208607e98c5b8e017c2;ds=sidebyside cleaned up comments for reboot code and adopted GNU coding standards --- diff --git a/src/threads/init.c b/src/threads/init.c index ac94603..a831a80 100644 --- a/src/threads/init.c +++ b/src/threads/init.c @@ -376,35 +376,38 @@ usage (void) power_off (); } +/* Keyboard control register port. */ +#define CONTROL_REG 0x64 -/* Reboots the machine we're running on. */ +/* Reboots the machine via the keyboard controller. */ void reboot (void) { - int i; - - printf ("Rebooting...\n"); - - /* based on reboot.c code by Osamu Tomita - * 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); + int i; + + printf ("Rebooting...\n"); + + /* See [kbd] for details on how to program the keyboard + * controller. */ + for (i = 0; i < 100; i++) + { + int j; + + /* Poll keyboard controller's status byte until + * 'input buffer empty' is reported. */ + for (j = 0; j < 0x10000; j++) + { + if ((inb (CONTROL_REG) & 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 (CONTROL_REG, 0xfe); + timer_udelay (50); } }