@@ -45,6 +45,7 @@
#include <mini-os/xmalloc.h>
#include <mini-os/e820.h>
#include <xen/memory.h>
+#include <xen/arch-x86/hvm/start_info.h>
#ifdef MM_DEBUG
#define DEBUG(_f, _a...) \
@@ -108,6 +109,11 @@ void arch_mm_preinit(void *p)
{
long ret;
domid_t domid = DOMID_SELF;
+ struct hvm_start_info *hsi = p;
+
+ if ( hsi->version >= 1 && hsi->memmap_entries > 0 )
+ e820_init_memmap((struct hvm_memmap_table_entry *)(unsigned long)
+ hsi->memmap_paddr, hsi->memmap_entries);
pt_base = page_table_base;
first_free_pfn = PFN_UP(to_phys(&_end));
@@ -54,6 +54,7 @@ static char *e820_types[E820_TYPES] = {
[E820_ACPI] = "ACPI",
[E820_NVS] = "NVS",
[E820_UNUSABLE] = "Unusable",
+ [E820_DISABLED] = "Disabled",
[E820_PMEM] = "PMEM"
};
@@ -259,6 +260,30 @@ static void e820_get_memmap(void)
e820_sanitize();
}
+void e820_init_memmap(struct hvm_memmap_table_entry *entry, unsigned int num)
+{
+ unsigned int i;
+
+ BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_RAM != E820_RAM);
+ BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_RESERVED != E820_RESERVED);
+ BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_ACPI != E820_ACPI);
+ BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_NVS != E820_NVS);
+ BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_UNUSABLE != E820_UNUSABLE);
+ BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_DISABLED != E820_DISABLED);
+ BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_PMEM != E820_PMEM);
+
+ for ( i = 0; i < num; i++ )
+ {
+ e820_map[i].addr = entry[i].addr;
+ e820_map[i].size = entry[i].size;
+ e820_map[i].type = entry[i].type;
+ }
+
+ e820_entries = num;
+
+ e820_sanitize();
+}
+
void arch_print_memmap(void)
{
int i;
@@ -26,6 +26,8 @@
#if defined(__arm__) || defined(__aarch64__) || defined(CONFIG_PARAVIRT)
#define CONFIG_E820_TRIVIAL
+#else
+#include <xen/arch-x86/hvm/start_info.h>
#endif
/* PC BIOS standard E820 types and structure. */
@@ -34,6 +36,7 @@
#define E820_ACPI 3
#define E820_NVS 4
#define E820_UNUSABLE 5
+#define E820_DISABLED 6
#define E820_PMEM 7
#define E820_TYPES 8
@@ -54,6 +57,7 @@ unsigned long e820_get_max_contig_pages(unsigned long pfn, unsigned long pages);
#ifndef CONFIG_E820_TRIVIAL
unsigned long e820_get_reserved_pfns(int pages);
void e820_put_reserved_pfns(unsigned long start_pfn, int pages);
+void e820_init_memmap(struct hvm_memmap_table_entry *entry, unsigned int num);
#endif
#endif /*__E820_HEADER*/