x86: EFI runtime service support: EFI runtime services
[sfrench/cifs-2.6.git] / arch / x86 / kernel / reboot_64.c
index 368db2b9c5ac3977b0ec32edabe2aec9359df6de..d6bdf93ffca996a3e079c958e217d713a38c6e19 100644 (file)
@@ -9,14 +9,18 @@
 #include <linux/pm.h>
 #include <linux/kdebug.h>
 #include <linux/sched.h>
+#include <linux/efi.h>
+#include <acpi/reboot.h>
 #include <asm/io.h>
 #include <asm/delay.h>
+#include <asm/desc.h>
 #include <asm/hw_irq.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/apic.h>
-#include <asm/iommu.h>
+#include <asm/hpet.h>
+#include <asm/gart.h>
 
 /*
  * Power off function, if any
@@ -25,18 +29,17 @@ void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
 static long no_idt[3];
-static enum { 
-       BOOT_TRIPLE = 't',
-       BOOT_KBD = 'k'
-} reboot_type = BOOT_KBD;
+enum reboot_type reboot_type = BOOT_KBD;
 static int reboot_mode = 0;
 int reboot_force;
 
-/* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
+/* reboot=t[riple] | k[bd] | e[fi] [, [w]arm | [c]old]
    warm   Don't set the cold reboot flag
    cold   Set the cold reboot flag
    triple Force a triple fault (init)
    kbd    Use the keyboard controller. cold reset (default)
+   acpi   Use the RESET_REG in the FADT
+   efi    Use efi reset_system runtime service
    force  Avoid anything that could hang.
  */ 
 static int __init reboot_setup(char *str)
@@ -52,8 +55,10 @@ static int __init reboot_setup(char *str)
                        break;
 
                case 't':
+               case 'a':
                case 'b':
                case 'k':
+               case 'e':
                        reboot_type = *str;
                        break;
                case 'f':
@@ -112,6 +117,9 @@ void machine_shutdown(void)
 
        disable_IO_APIC();
 
+#ifdef CONFIG_HPET_TIMER
+       hpet_disable();
+#endif
        local_irq_restore(flags);
 
        pci_iommu_shutdown();
@@ -136,12 +144,24 @@ void machine_emergency_restart(void)
                }
 
                case BOOT_TRIPLE: 
-                       __asm__ __volatile__("lidt (%0)": :"r" (&no_idt));
+                       load_idt((const struct desc_ptr *)&no_idt);
                        __asm__ __volatile__("int3");
 
                        reboot_type = BOOT_KBD;
                        break;
-               }      
+
+               case BOOT_ACPI:
+                       acpi_reboot();
+                       reboot_type = BOOT_KBD;
+                       break;
+
+               case BOOT_EFI:
+                       if (efi_enabled)
+                               efi.reset_system(reboot_mode ? EFI_RESET_WARM : EFI_RESET_COLD,
+                                                EFI_SUCCESS, 0, NULL);
+                       reboot_type = BOOT_KBD;
+                       break;
+               }
        }      
 }