E820: Add interface for accessing e820 table
authorGabriel L. Somlo <gsomlo@gmail.com>
Wed, 23 Apr 2014 13:42:36 +0000 (09:42 -0400)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 5 May 2014 10:29:39 +0000 (12:29 +0200)
Add the following two functions:

  - e820_get_num_entries() - query the size of the e820 table
  - e820_get_entry() - grab an entry matching a given set of criteria

This interface is currently necessary for creating type 19
(memory array mapped address) structures in smbios.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/i386/pc.c
include/hw/i386/pc.h

index 14f0d91f76d6c0daab898a0d0f4f9796a08bb84a..aefb31593b157333e2ea69eb50d6b4854d9e8b6e 100644 (file)
@@ -612,6 +612,21 @@ int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
     return e820_entries;
 }
 
+int e820_get_num_entries(void)
+{
+    return e820_entries;
+}
+
+bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length)
+{
+    if (idx < e820_entries && e820_table[idx].type == cpu_to_le32(type)) {
+        *address = le64_to_cpu(e820_table[idx].address);
+        *length = le64_to_cpu(e820_table[idx].length);
+        return true;
+    }
+    return false;
+}
+
 /* Calculates the limit to CPU APIC ID values
  *
  * This function returns the limit for the APIC ID value, so that all
index 9010246cb80d6ff90ae023216bb702468a949bc7..9f26e14bef54b26d2a317d0b30b233f8819726f3 100644 (file)
@@ -239,6 +239,8 @@ uint16_t pvpanic_port(void);
 #define E820_UNUSABLE   5
 
 int e820_add_entry(uint64_t, uint64_t, uint32_t);
+int e820_get_num_entries(void);
+bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_Q35_COMPAT_1_7 \
         PC_COMPAT_1_7, \