X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=src%2Fdevices%2Fshutdown.c;h=42b67df57bc533b1681d1afb964dc1634e3b0930;hp=4c978f970216169d69b34d061ae7c1c3d746f857;hb=94618414d6e0e051cf95e900c63ed2835ed16a82;hpb=19becec31c5704572a3575336c57364d72fd572b diff --git a/src/devices/shutdown.c b/src/devices/shutdown.c index 4c978f9..42b67df 100644 --- a/src/devices/shutdown.c +++ b/src/devices/shutdown.c @@ -17,8 +17,41 @@ /* Keyboard control register port. */ #define CONTROL_REG 0x64 +/* How to shut down when shutdown() is called. */ +static enum shutdown_type how = SHUTDOWN_NONE; + static void print_stats (void); +/* Shuts down the machine in the way configured by + shutdown_configure(). If the shutdown type is SHUTDOWN_NONE + (which is the default), returns without doing anything. */ +void +shutdown (void) +{ + switch (how) + { + case SHUTDOWN_POWER_OFF: + shutdown_power_off (); + break; + + case SHUTDOWN_REBOOT: + shutdown_reboot (); + break; + + default: + /* Nothing to do. */ + break; + } +} + +/* Sets TYPE as the way that machine will shut down when Pintos + execution is complete. */ +void +shutdown_configure (enum shutdown_type type) +{ + how = type; +} + /* Reboots the machine via the keyboard controller. */ void shutdown_reboot (void)