Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

kernel.c

Go to the documentation of this file.
00001 /*!     \file kernel/kernel.c
00002  *      \brief Generic routines for kernel.
00003  *      \author Andrea Righi <drizzt@inwind.it>
00004  *      \date Last update: 2003-08-23
00005  *      \note Copyright (&copy;) 2003 Andrea Righi
00006  */
00007 
00008 #include <const.h>
00009 
00010 #include <arch/i386.h>
00011 
00012 #include <kernel/clock.h>
00013 #include <kernel/console.h>
00014 #include <kernel/keyboard.h>
00015 #include <kernel/speaker.h>
00016 #include <kernel/task.h>
00017 
00018 #include <kernel/kernel.h>
00019 
00020 //! \brief Report a critical error to the console.
00021 //! \param msg The message you want to display.
00022 //! \warning
00023 //!     If this routine is invoked by a task it will be killed.
00024 //! \warning
00025 //!     PANIC: if this routine is invoked by the kernel
00026 //!     the system will be halted!!!
00027 void error(const byte *msg)
00028 {
00029         disable();
00030         beep();
00031         set_color(LIGHT_RED);
00032         kprintf("\n\rERROR: %s", msg);
00033         set_color(DEFAULT_COLOR);
00034         kprintf("\n\rTask [%s] (%i) killed!", get_pname(), get_pid());
00035 
00036         sched_leave_critical_region();
00037 
00038         // If the kernel has generated this error HALT the system!      //
00039         if (get_pid())
00040                 auto_kill( 1 );
00041         else
00042                 halt();
00043 }
00044 
00045 //! \brief Reboot the system using the keyboard CPU reset line.
00046 //! \warning
00047 //!     If it cannot reboot, the system will be halted.
00048 void reboot()
00049 {
00050         // Disable all interrupts                                       //
00051         disable();
00052 
00053         beep();
00054 
00055         set_color(DEFAULT_COLOR);
00056         kprintf("\n\r");
00057 
00058         // Reset system clock                                           //
00059         kprintf("Reset system clock...");
00060         stop_clock();
00061         set_color(GREEN);
00062         kprintf("\n                                     [ OK ]\n\r");
00063         set_color(DEFAULT_COLOR);
00064 
00065         kprintf("\n\rRebooting system...");
00066 
00067         // Pulse the CPU reset line                                     //
00068         keyb_wait();
00069         outportb(0x64, 0xFE);
00070 
00071         // If doesn't reboot => halt the system!                        //
00072         halt();
00073 }

Generated on Fri Feb 20 15:32:16 2004 for Minirighi by doxygen1.2.18