Main Page | Directories | File List | Globals

machine.c

Go to the documentation of this file.
00001 /*
00002  * kernel_arch/i386/kernel/machine.c
00003  *
00004  * Copyright (c) 2003-2004 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2004/01
00008  * Author:      Lukasz Dembinski
00009  * Info:        machine.c core file
00010  * Contact:     mailto: <dembol@nasa.com.pl>
00011  *
00012  */
00013 
00014 #include <agnix/agnix.h> 
00015 #include <agnix/bios/apm.h>
00016 #include <agnix/console.h>
00017 #include <agnix/irq.h> 
00018 
00019 #define MOD_NAME        "MACHINE: "
00020 
00021 /*
00022  * address = 0x00000000
00023  * limit   = 0
00024  */
00025 u32 dummy_idt[2];
00026 extern int apm_enabled;
00027 
00028 void do_machine_real_mode_reboot(void)
00029 {
00030     /* todo */
00031 }
00032 
00033 /*
00034  * triple fault:
00035  * 1. int 0
00036  * 2. double fault
00037  * 3. tripple fault and reset
00038  */
00039 void do_machine_hard_reboot(void)
00040 {
00041     printk(MOD_NAME "Machine hard reboot... ");
00042 
00043     __asm__ __volatile__ ("lidt %0\n\t"
00044                           "int $0"
00045                           :
00046                           :"m"(dummy_idt));
00047                           
00048     printk("failed\n");
00049 }
00050 
00051 void do_machine_reboot(void)
00052 {
00053     printk(MOD_NAME "Machine rebooting...\n");
00054         
00055     do_machine_hard_reboot();
00056     do_machine_real_mode_reboot();
00057     
00058     printk(MOD_NAME "Machine reboot failed\n");
00059     
00060     for(;;) {
00061         __asm__ __volatile__ ("hlt");
00062     }    
00063 }
00064 
00065 void do_machine_powerdown(void)
00066 {
00067     printk(MOD_NAME "Machine poweroff\n");
00068 
00069 #ifdef CONFIG_BIOS_APM
00070     if (apm_enabled) {
00071         apm_set_power_state(APM_ALL_DEVICES, APM_POWER_STATE_OFF);
00072 
00073         printk(MOD_NAME "Machine poweroff failed\n");
00074     } else {
00075         printk(MOD_NAME "APM disabled, halting machine\n");
00076     }
00077 #endif
00078 
00079     cli();      
00080     for(;;) {
00081         __asm__ __volatile__ ("hlt");
00082     }    
00083 }
00084 
00085 void do_machine_halt(void)
00086 {
00087     printk(MOD_NAME "Machine halt\n");
00088 
00089     for(;;) {
00090         __asm__ __volatile__ ("hlt");
00091     }    
00092 }
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix