]> err.no Git - linux-2.6/blobdiff - arch/i386/kernel/e820.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[linux-2.6] / arch / i386 / kernel / e820.c
index 829beec9247ea9736f246e64c0c545f95223c72b..e60cddbc4cfbc39380c751f0d5793851ff25c96b 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/efi.h>
 #include <linux/pfn.h>
 #include <linux/uaccess.h>
+#include <linux/suspend.h>
 
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -320,6 +321,37 @@ static int __init request_standard_resources(void)
 
 subsys_initcall(request_standard_resources);
 
+#if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND)
+/**
+ * e820_mark_nosave_regions - Find the ranges of physical addresses that do not
+ * correspond to e820 RAM areas and mark the corresponding pages as nosave for
+ * hibernation.
+ *
+ * This function requires the e820 map to be sorted and without any
+ * overlapping entries and assumes the first e820 area to be RAM.
+ */
+void __init e820_mark_nosave_regions(void)
+{
+       int i;
+       unsigned long pfn;
+
+       pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size);
+       for (i = 1; i < e820.nr_map; i++) {
+               struct e820entry *ei = &e820.map[i];
+
+               if (pfn < PFN_UP(ei->addr))
+                       register_nosave_region(pfn, PFN_UP(ei->addr));
+
+               pfn = PFN_DOWN(ei->addr + ei->size);
+               if (ei->type != E820_RAM)
+                       register_nosave_region(PFN_UP(ei->addr), pfn);
+
+               if (pfn >= max_low_pfn)
+                       break;
+       }
+}
+#endif
+
 void __init add_memory_region(unsigned long long start,
                              unsigned long long size, int type)
 {
@@ -393,10 +425,8 @@ int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
                   ____________________33__
                   ______________________4_
        */
-       printk("sanitize start\n");
        /* if there's only one memory region, don't bother */
        if (*pnr_map < 2) {
-               printk("sanitize bail 0\n");
                return -1;
        }
 
@@ -405,7 +435,6 @@ int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
        /* bail out if we find any unreasonable addresses in bios map */
        for (i=0; i<old_nr; i++)
                if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr) {
-                       printk("sanitize bail 1\n");
                        return -1;
                }
 
@@ -501,7 +530,6 @@ int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
        memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
        *pnr_map = new_nr;
 
-       printk("sanitize end\n");
        return 0;
 }
 
@@ -532,7 +560,6 @@ int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
                unsigned long long size = biosmap->size;
                unsigned long long end = start + size;
                unsigned long type = biosmap->type;
-               printk("copy_e820_map() start: %016Lx size: %016Lx end: %016Lx type: %ld\n", start, size, end, type);
 
                /* Overflow in 64 bits? Ignore the memory map. */
                if (start > end)
@@ -543,17 +570,11 @@ int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
                 * Not right. Fix it up.
                 */
                if (type == E820_RAM) {
-                       printk("copy_e820_map() type is E820_RAM\n");
                        if (start < 0x100000ULL && end > 0xA0000ULL) {
-                               printk("copy_e820_map() lies in range...\n");
-                               if (start < 0xA0000ULL) {
-                                       printk("copy_e820_map() start < 0xA0000ULL\n");
+                               if (start < 0xA0000ULL)
                                        add_memory_region(start, 0xA0000ULL-start, type);
-                               }
-                               if (end <= 0x100000ULL) {
-                                       printk("copy_e820_map() end <= 0x100000ULL\n");
+                               if (end <= 0x100000ULL)
                                        continue;
-                               }
                                start = 0x100000ULL;
                                size = end - start;
                        }
@@ -745,7 +766,7 @@ void __init print_memory_map(char *who)
                case E820_NVS:
                                printk("(ACPI NVS)\n");
                                break;
-               default:        printk("type %lu\n", e820.map[i].type);
+               default:        printk("type %u\n", e820.map[i].type);
                                break;
                }
        }