# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302611777 -3600
# Node ID 846f435915a2c71fee6e652f831eebf53a422ffe
# Parent c8e3c66deb7bde711ca3c5a2222fd35e9a8b7a7d
tools: hvmloader: split e820 support into its own code module.
Pass the table address as a paramter to the build function and cause
it to return the number of entries. Pass both base and offset as
parameters to the dump function.
This adds a duplicated e820.h header to ROMBIOS. Since the e820 data
structure is well defined by existing BIOS implementations I think
this is OK and simplifies the cross talk between hvmloader and
ROMBIOS.
Reduces the cross talk between ROMBIOS and hvmloader.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
---
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 13:36:17 2011 +0100
@@ -30,6 +30,7 @@
SRCS = hvmloader.c mp_tables.c util.c smbios.c
SRCS += 32bitbios_support.c smp.c cacheattr.c xenbus.c
+SRCS += e820.c
ifeq ($(debug),y)
SRCS += tests.c
endif
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Tue Apr 12 13:36:17 2011 +0100
@@ -1,6 +1,8 @@
#ifndef __HVMLOADER_CONFIG_H__
#define __HVMLOADER_CONFIG_H__
+#include <stdint.h>
+
#define PAGE_SHIFT 12
#define PAGE_SIZE (1ul << PAGE_SHIFT)
@@ -28,6 +30,7 @@
#define ROMBIOS_MAXOFFSET 0x0000FFFF
#define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE)
+#include "e820.h"
#include "../rombios/config.h"
#define VGABIOS_PHYSICAL_ADDRESS 0x000C0000
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/e820.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/e820.c Tue Apr 12 13:36:17 2011 +0100
@@ -0,0 +1,141 @@
+/*
+ * HVM e820 support.
+ *
+ * Leendert van Doorn, leendert@xxxxxxxxxxxxxx
+ * Copyright (c) 2005, International Business Machines Corporation.
+ * Copyright (c) 2006, Keir Fraser, XenSource Inc.
+ * Copyright (c) 2011, Citrix Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "config.h"
+#include "util.h"
+
+void dump_e820_table(struct e820entry *e820, unsigned int nr)
+{
+ uint64_t last_end = 0, start, end;
+ int i;
+
+ printf("E820 table:\n");
+
+ for ( i = 0; i < nr; i++ )
+ {
+ start = e820[i].addr;
+ end = e820[i].addr + e820[i].size;
+
+ if ( start < last_end )
+ printf(" OVERLAP!!\n");
+ else if ( start > last_end )
+ printf(" HOLE: %08x:%08x - %08x:%08x\n",
+ (uint32_t)(last_end >> 32), (uint32_t)last_end,
+ (uint32_t)(start >> 32), (uint32_t)start);
+
+ printf(" [%02d]: %08x:%08x - %08x:%08x: ", i,
+ (uint32_t)(start >> 32), (uint32_t)start,
+ (uint32_t)(end >> 32), (uint32_t)end);
+ switch ( e820[i].type )
+ {
+ case E820_RAM:
+ printf("RAM\n");
+ break;
+ case E820_RESERVED:
+ printf("RESERVED\n");
+ break;
+ case E820_ACPI:
+ printf("ACPI\n");
+ break;
+ case E820_NVS:
+ printf("NVS\n");
+ break;
+ default:
+ printf("UNKNOWN (%08x)\n", e820[i].type);
+ break;
+ }
+
+ last_end = end;
+ }
+}
+
+/* Create an E820 table based on memory parameters provided in hvm_info. */
+int build_e820_table(struct e820entry *e820)
+{
+ unsigned int nr = 0;
+
+ /* 0x0-0x9E000: Ordinary RAM. */
+ /* (Must be at least 512K to keep Windows happy) */
+ e820[nr].addr = 0x00000;
+ e820[nr].size = 0x9E000;
+ e820[nr].type = E820_RAM;
+ nr++;
+
+ /* 0x9E000-0x9FC00: Reserved for internal use. */
+ e820[nr].addr = 0x9E000;
+ e820[nr].size = 0x01C00;
+ e820[nr].type = E820_RESERVED;
+ nr++;
+
+ /* 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA). */
+ e820[nr].addr = 0x9FC00;
+ e820[nr].size = 0x400;
+ e820[nr].type = E820_RESERVED;
+ nr++;
+
+ /*
+ * Following regions are standard regions of the PC memory map.
+ * They are not covered by e820 regions. OSes will not use as RAM.
+ * 0xA0000-0xC0000: VGA memory-mapped I/O. Not covered by E820.
+ * 0xC0000-0xE0000: 16-bit devices, expansion ROMs (inc. vgabios).
+ * TODO: free pages which turn out to be unused.
+ */
+
+ /*
+ * 0xE0000-0x0F0000: PC-specific area. We place various tables here.
+ * 0xF0000-0x100000: System BIOS.
+ * TODO: free pages which turn out to be unused.
+ */
+ e820[nr].addr = 0xE0000;
+ e820[nr].size = 0x20000;
+ e820[nr].type = E820_RESERVED;
+ nr++;
+
+ /* Low RAM goes here. Reserve space for special pages. */
+ BUG_ON((hvm_info->low_mem_pgend << PAGE_SHIFT) < (2u << 20));
+ e820[nr].addr = 0x100000;
+ e820[nr].size = (hvm_info->low_mem_pgend << PAGE_SHIFT) - e820[nr].addr;
+ e820[nr].type = E820_RAM;
+ nr++;
+
+ /*
+ * Explicitly reserve space for special pages.
+ * This space starts at RESERVED_MEMBASE an extends to cover various
+ * fixed hardware mappings (e.g., LAPIC, IOAPIC, default SVGA framebuffer).
+ */
+ e820[nr].addr = RESERVED_MEMBASE;
+ e820[nr].size = (uint32_t)-e820[nr].addr;
+ e820[nr].type = E820_RESERVED;
+ nr++;
+
+ if ( hvm_info->high_mem_pgend )
+ {
+ e820[nr].addr = ((uint64_t)1 << 32);
+ e820[nr].size =
+ ((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - e820[nr].addr;
+ e820[nr].type = E820_RAM;
+ nr++;
+ }
+
+ return nr;
+}
+
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/e820.h
--- a/tools/firmware/hvmloader/e820.h Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/hvmloader/e820.h Tue Apr 12 13:36:17 2011 +0100
@@ -1,8 +1,6 @@
#ifndef __HVMLOADER_E820_H__
#define __HVMLOADER_E820_H__
-#include <xen/hvm/e820.h>
-
/*
* PC BIOS standard E820 types and structure.
*/
@@ -17,7 +15,4 @@
uint32_t type;
} __attribute__((packed));
-#define E820_NR ((uint16_t *)(E820_PHYSICAL_ADDRESS + E820_NR_OFFSET))
-#define E820 ((struct e820entry *)(E820_PHYSICAL_ADDRESS + E820_OFFSET))
-
#endif /* __HVMLOADER_E820_H__ */
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 13:36:17 2011 +0100
@@ -27,7 +27,6 @@
#include "config.h"
#include "apic_regs.h"
#include "pci_regs.h"
-#include "e820.h"
#include "option_rom.h"
#include <xen/version.h>
#include <xen/hvm/params.h>
@@ -578,125 +577,6 @@
printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
}
-static void dump_e820_table(void)
-{
- struct e820entry *e820 = E820;
- unsigned int nr = *E820_NR;
- uint64_t last_end = 0, start, end;
- int i;
-
- printf("E820 table:\n");
-
- for ( i = 0; i < nr; i++ )
- {
- start = e820[i].addr;
- end = e820[i].addr + e820[i].size;
-
- if ( start < last_end )
- printf(" OVERLAP!!\n");
- else if ( start > last_end )
- printf(" HOLE: %08x:%08x - %08x:%08x\n",
- (uint32_t)(last_end >> 32), (uint32_t)last_end,
- (uint32_t)(start >> 32), (uint32_t)start);
-
- printf(" [%02d]: %08x:%08x - %08x:%08x: ", i,
- (uint32_t)(start >> 32), (uint32_t)start,
- (uint32_t)(end >> 32), (uint32_t)end);
- switch ( e820[i].type )
- {
- case E820_RAM:
- printf("RAM\n");
- break;
- case E820_RESERVED:
- printf("RESERVED\n");
- break;
- case E820_ACPI:
- printf("ACPI\n");
- break;
- case E820_NVS:
- printf("NVS\n");
- break;
- default:
- printf("UNKNOWN (%08x)\n", e820[i].type);
- break;
- }
-
- last_end = end;
- }
-}
-
-/* Create an E820 table based on memory parameters provided in hvm_info. */
-static void build_e820_table(void)
-{
- struct e820entry *e820 = E820;
- unsigned int nr = 0;
-
- /* 0x0-0x9E000: Ordinary RAM. */
- /* (Must be at least 512K to keep Windows happy) */
- e820[nr].addr = 0x00000;
- e820[nr].size = 0x9E000;
- e820[nr].type = E820_RAM;
- nr++;
-
- /* 0x9E000-0x9FC00: Reserved for internal use. */
- e820[nr].addr = 0x9E000;
- e820[nr].size = 0x01C00;
- e820[nr].type = E820_RESERVED;
- nr++;
-
- /* 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA). */
- e820[nr].addr = 0x9FC00;
- e820[nr].size = 0x400;
- e820[nr].type = E820_RESERVED;
- nr++;
-
- /*
- * Following regions are standard regions of the PC memory map.
- * They are not covered by e820 regions. OSes will not use as RAM.
- * 0xA0000-0xC0000: VGA memory-mapped I/O. Not covered by E820.
- * 0xC0000-0xE0000: 16-bit devices, expansion ROMs (inc. vgabios).
- * TODO: free pages which turn out to be unused.
- */
-
- /*
- * 0xE0000-0x0F0000: PC-specific area. We place various tables here.
- * 0xF0000-0x100000: System BIOS.
- * TODO: free pages which turn out to be unused.
- */
- e820[nr].addr = 0xE0000;
- e820[nr].size = 0x20000;
- e820[nr].type = E820_RESERVED;
- nr++;
-
- /* Low RAM goes here. Reserve space for special pages. */
- BUG_ON((hvm_info->low_mem_pgend << PAGE_SHIFT) < (2u << 20));
- e820[nr].addr = 0x100000;
- e820[nr].size = (hvm_info->low_mem_pgend << PAGE_SHIFT) - e820[nr].addr;
- e820[nr].type = E820_RAM;
- nr++;
-
- /*
- * Explicitly reserve space for special pages.
- * This space starts at RESERVED_MEMBASE an extends to cover various
- * fixed hardware mappings (e.g., LAPIC, IOAPIC, default SVGA framebuffer).
- */
- e820[nr].addr = RESERVED_MEMBASE;
- e820[nr].size = (uint32_t)-e820[nr].addr;
- e820[nr].type = E820_RESERVED;
- nr++;
-
- if ( hvm_info->high_mem_pgend )
- {
- e820[nr].addr = ((uint64_t)1 << 32);
- e820[nr].size =
- ((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - e820[nr].addr;
- e820[nr].type = E820_RAM;
- nr++;
- }
-
- *E820_NR = nr;
-}
-
int main(void)
{
int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0;
@@ -802,8 +682,8 @@
ROMBIOS_PHYSICAL_ADDRESS,
ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1);
- build_e820_table();
- dump_e820_table();
+ *E820_NR = build_e820_table(E820);
+ dump_e820_table(E820, *E820_NR);
bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
memset(bios_info, 0, sizeof(*bios_info));
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/smbios.c
--- a/tools/firmware/hvmloader/smbios.c Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/hvmloader/smbios.c Tue Apr 12 13:36:17 2011 +0100
@@ -26,7 +26,6 @@
#include "smbios_types.h"
#include "util.h"
#include "hypercall.h"
-#include "e820.h"
static int
write_smbios_tables(void *start,
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/hvmloader/util.c Tue Apr 12 13:36:17 2011 +0100
@@ -20,7 +20,6 @@
#include "util.h"
#include "config.h"
-#include "e820.h"
#include "hypercall.h"
#include <stdint.h>
#include <xen/xen.h>
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/hvmloader/util.h Tue Apr 12 13:36:17 2011 +0100
@@ -189,6 +189,10 @@
int hvm_write_smbios_tables(void);
void smp_initialise(void);
+#include "e820.h"
+int build_e820_table(struct e820entry *e820);
+void dump_e820_table(struct e820entry *e820, unsigned int nr);
+
#ifndef NDEBUG
void perform_tests(void);
#else
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/rombios/32bit/pmm.c
--- a/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 13:36:17 2011 +0100
@@ -66,7 +66,7 @@
#include <stdint.h>
#include <stddef.h>
#include "config.h"
-#include <../hvmloader/e820.h>
+#include "e820.h"
#include "util.h"
#define DEBUG_PMM 0
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/rombios/config.h
--- a/tools/firmware/rombios/config.h Tue Apr 12 13:34:30 2011 +0100
+++ b/tools/firmware/rombios/config.h Tue Apr 12 13:36:17 2011 +0100
@@ -18,6 +18,9 @@
#define E820_NR_OFFSET 0x0
#define E820_OFFSET 0x8
+#define E820_NR ((uint16_t *)(E820_PHYSICAL_ADDRESS + E820_NR_OFFSET))
+#define E820 ((struct e820entry *)(E820_PHYSICAL_ADDRESS + E820_OFFSET))
+
/* Xen Platform Device */
#define XEN_PF_IOBASE 0x10
#define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
diff -r c8e3c66deb7b -r 846f435915a2 tools/firmware/rombios/e820.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/rombios/e820.h Tue Apr 12 13:36:17 2011 +0100
@@ -0,0 +1,18 @@
+#ifndef __ROMBIOS_E820_H__
+#define __ROMBIOS_E820_H__
+
+/*
+ * PC BIOS standard E820 types and structure.
+ */
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+#define E820_NVS 4
+
+struct e820entry {
+ uint64_t addr;
+ uint64_t size;
+ uint32_t type;
+} __attribute__((packed));
+
+#endif /* __ROMBIOS_E820_H__ */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|