Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / arch / x86_64 / kernel / suspend.c
index ecbd34c..ea83a9f 100644 (file)
@@ -7,12 +7,15 @@
  * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
  */
 
-#include <linux/config.h>
 #include <linux/smp.h>
 #include <linux/suspend.h>
 #include <asm/proto.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
+#include <asm/mtrr.h>
+
+/* References to section boundaries */
+extern const void __nosave_begin, __nosave_end;
 
 struct saved_context saved_context;
 
@@ -34,7 +37,6 @@ void __save_processor_state(struct saved_context *ctxt)
        asm volatile ("str %0"  : "=m" (ctxt->tr));
 
        /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */
-       /* EFER should be constant for kernel version, no need to handle it. */
        /*
         * segment registers
         */
@@ -47,15 +49,17 @@ void __save_processor_state(struct saved_context *ctxt)
        rdmsrl(MSR_FS_BASE, ctxt->fs_base);
        rdmsrl(MSR_GS_BASE, ctxt->gs_base);
        rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base);
+       mtrr_save_fixed_ranges(NULL);
 
        /*
         * control registers 
         */
-       asm volatile ("movq %%cr0, %0" : "=r" (ctxt->cr0));
-       asm volatile ("movq %%cr2, %0" : "=r" (ctxt->cr2));
-       asm volatile ("movq %%cr3, %0" : "=r" (ctxt->cr3));
-       asm volatile ("movq %%cr4, %0" : "=r" (ctxt->cr4));
-       asm volatile ("movq %%cr8, %0" : "=r" (ctxt->cr8));
+       rdmsrl(MSR_EFER, ctxt->efer);
+       ctxt->cr0 = read_cr0();
+       ctxt->cr2 = read_cr2();
+       ctxt->cr3 = read_cr3();
+       ctxt->cr4 = read_cr4();
+       ctxt->cr8 = read_cr8();
 }
 
 void save_processor_state(void)
@@ -76,11 +80,12 @@ void __restore_processor_state(struct saved_context *ctxt)
        /*
         * control registers
         */
-       asm volatile ("movq %0, %%cr8" :: "r" (ctxt->cr8));
-       asm volatile ("movq %0, %%cr4" :: "r" (ctxt->cr4));
-       asm volatile ("movq %0, %%cr3" :: "r" (ctxt->cr3));
-       asm volatile ("movq %0, %%cr2" :: "r" (ctxt->cr2));
-       asm volatile ("movq %0, %%cr0" :: "r" (ctxt->cr0));
+       wrmsrl(MSR_EFER, ctxt->efer);
+       write_cr8(ctxt->cr8);
+       write_cr4(ctxt->cr4);
+       write_cr3(ctxt->cr3);
+       write_cr2(ctxt->cr2);
+       write_cr0(ctxt->cr0);
 
        /*
         * now restore the descriptor tables to their proper values
@@ -220,4 +225,15 @@ int swsusp_arch_resume(void)
        restore_image();
        return 0;
 }
+
+/*
+ *     pfn_is_nosave - check if given pfn is in the 'nosave' section
+ */
+
+int pfn_is_nosave(unsigned long pfn)
+{
+       unsigned long nosave_begin_pfn = __pa_symbol(&__nosave_begin) >> PAGE_SHIFT;
+       unsigned long nosave_end_pfn = PAGE_ALIGN(__pa_symbol(&__nosave_end)) >> PAGE_SHIFT;
+       return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn);
+}
 #endif /* CONFIG_SOFTWARE_SUSPEND */