]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - arch/x86/kernel/e820.c
x86/boot/e820: Add support to determine the E820 type of an address
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / kernel / e820.c
index 532da61d605ccc2271067fdf67bac83c454616aa..71c11ad5643e80059d4f262002fc9620044b594b 100644 (file)
@@ -96,7 +96,8 @@ EXPORT_SYMBOL_GPL(e820__mapped_any);
  * Note: this function only works correctly once the E820 table is sorted and
  * not-overlapping (at least for the range specified), which is the case normally.
  */
-bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type)
+static struct e820_entry *__e820__mapped_all(u64 start, u64 end,
+                                            enum e820_type type)
 {
        int i;
 
@@ -122,9 +123,28 @@ bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type)
                 * coverage of the desired range exists:
                 */
                if (start >= end)
-                       return 1;
+                       return entry;
        }
-       return 0;
+
+       return NULL;
+}
+
+/*
+ * This function checks if the entire range <start,end> is mapped with type.
+ */
+bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type)
+{
+       return __e820__mapped_all(start, end, type);
+}
+
+/*
+ * This function returns the type associated with the range <start,end>.
+ */
+int e820__get_entry_type(u64 start, u64 end)
+{
+       struct e820_entry *entry = __e820__mapped_all(start, end, 0);
+
+       return entry ? entry->type : -EINVAL;
 }
 
 /*