# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1181501384 -3600
# Node ID 7eeddd787d2f8fb3cc27680d0358fe88eeaf342c
# Parent ac9d3bcc7a78e78ad724bbf57f25def28508f8e5
hvm: e820 public header cleanup.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
tools/firmware/hvmloader/e820.h | 23 +++++++++++++++++++++++
tools/firmware/hvmloader/hvmloader.c | 5 +++--
tools/firmware/hvmloader/smbios.c | 5 +++--
tools/firmware/hvmloader/util.c | 19 ++++++++++---------
tools/firmware/hvmloader/util.h | 5 -----
tools/firmware/vmxassist/setup.c | 6 +++---
tools/firmware/vmxassist/util.h | 6 ++----
tools/ioemu/target-i386-dm/exec-dm.c | 2 --
tools/ioemu/vl.h | 1 -
tools/libxc/xc_dom_x86.c | 1 -
tools/libxc/xc_domain.c | 2 +-
tools/libxc/xc_domain_save.c | 2 +-
tools/libxc/xc_e820.h | 20 ++++++++++++++++++++
tools/libxc/xc_hvm_build.c | 8 ++++----
xen/arch/x86/domctl.c | 1 -
xen/include/asm-x86/e820.h | 14 +++++++++++++-
xen/include/public/hvm/e820.h | 19 +++----------------
17 files changed, 86 insertions(+), 53 deletions(-)
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/firmware/hvmloader/e820.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/e820.h Sun Jun 10 19:49:44 2007 +0100
@@ -0,0 +1,23 @@
+#ifndef __HVMLOADER_E820_H__
+#define __HVMLOADER_E820_H__
+
+#include <xen/hvm/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));
+
+#define HVM_E820_NR ((unsigned char *)HVM_E820_PAGE + HVM_E820_NR_OFFSET)
+#define HVM_E820 ((struct e820entry *)(HVM_E820_PAGE + HVM_E820_OFFSET))
+
+#endif /* __HVMLOADER_E820_H__ */
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c Sun Jun 10 19:49:44 2007 +0100
@@ -27,6 +27,7 @@
#include "config.h"
#include "apic_regs.h"
#include "pci_regs.h"
+#include "e820.h"
#include <xen/version.h>
#include <xen/hvm/params.h>
@@ -311,8 +312,8 @@ static int must_load_nic(void)
/* Replace possibly erroneous memory-size CMOS fields with correct values. */
static void cmos_write_memory_size(void)
{
- struct e820entry *map = E820_MAP;
- int i, nr = *E820_MAP_NR;
+ struct e820entry *map = HVM_E820;
+ int i, nr = *HVM_E820_NR;
uint32_t base_mem = 640, ext_mem = 0, alt_mem = 0;
for ( i = 0; i < nr; i++ )
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/firmware/hvmloader/smbios.c
--- a/tools/firmware/hvmloader/smbios.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/firmware/hvmloader/smbios.c Sun Jun 10 19:49:44 2007 +0100
@@ -25,6 +25,7 @@
#include "smbios_types.h"
#include "util.h"
#include "hypercall.h"
+#include "e820.h"
static int
write_smbios_tables(void *start,
@@ -131,8 +132,8 @@ static uint64_t
static uint64_t
get_memsize(void)
{
- struct e820entry *map = E820_MAP;
- uint8_t num_entries = *E820_MAP_NR;
+ struct e820entry *map = HVM_E820;
+ uint8_t num_entries = *HVM_E820_NR;
uint64_t memsize = 0;
int i;
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/firmware/hvmloader/util.c Sun Jun 10 19:49:44 2007 +0100
@@ -20,6 +20,7 @@
#include "util.h"
#include "config.h"
+#include "e820.h"
#include <stdint.h>
#include <xenctrl.h>
#include <xen/hvm/hvm_info_table.h>
@@ -286,16 +287,16 @@ static void e820_collapse(void)
static void e820_collapse(void)
{
int i = 0;
- struct e820entry *ent = (struct e820entry *)E820_MAP;
-
- while ( i < (*E820_MAP_NR-1) )
+ struct e820entry *ent = (struct e820entry *)HVM_E820;
+
+ while ( i < (*HVM_E820_NR-1) )
{
if ( (ent[i].type == ent[i+1].type) &&
((ent[i].addr + ent[i].size) == ent[i+1].addr) )
{
ent[i].size += ent[i+1].size;
- memcpy(&ent[i+1], &ent[i+2], (*E820_MAP_NR-i-2) * sizeof(*ent));
- (*E820_MAP_NR)--;
+ memcpy(&ent[i+1], &ent[i+2], (*HVM_E820_NR-i-2) * sizeof(*ent));
+ (*HVM_E820_NR)--;
}
else
{
@@ -308,12 +309,12 @@ uint32_t e820_malloc(uint32_t size)
{
uint32_t addr;
int i;
- struct e820entry *ent = (struct e820entry *)E820_MAP;
+ struct e820entry *ent = (struct e820entry *)HVM_E820;
/* Align allocation request to a reasonable boundary (1kB). */
size = (size + 1023) & ~1023;
- for ( i = *E820_MAP_NR - 1; i >= 0; i-- )
+ for ( i = *HVM_E820_NR - 1; i >= 0; i-- )
{
addr = ent[i].addr;
if ( (ent[i].type != E820_RAM) || /* not ram? */
@@ -324,8 +325,8 @@ uint32_t e820_malloc(uint32_t size)
if ( ent[i].size != size )
{
- memmove(&ent[i+1], &ent[i], (*E820_MAP_NR-i) * sizeof(*ent));
- (*E820_MAP_NR)++;
+ memmove(&ent[i+1], &ent[i], (*HVM_E820_NR-i) * sizeof(*ent));
+ (*HVM_E820_NR)++;
ent[i].size -= size;
addr += ent[i].size;
i++;
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/firmware/hvmloader/util.h Sun Jun 10 19:49:44 2007 +0100
@@ -84,11 +84,6 @@ int vprintf(const char *fmt, va_list ap)
/* Reserve a RAM region in the e820 table. */
uint32_t e820_malloc(uint32_t size);
-/* General e820 access. */
-#include <xen/hvm/e820.h>
-#define E820_MAP_NR ((unsigned char *)E820_MAP_PAGE + E820_MAP_NR_OFFSET)
-#define E820_MAP ((struct e820entry *)(E820_MAP_PAGE + E820_MAP_OFFSET))
-
/* Prepare the 32bit BIOS */
void highbios_setup(void);
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/firmware/vmxassist/setup.c
--- a/tools/firmware/vmxassist/setup.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/firmware/vmxassist/setup.c Sun Jun 10 19:49:44 2007 +0100
@@ -91,13 +91,13 @@ banner(void)
e820map[6].addr = memory_size;
e820map[7].addr += memory_size;
- *E820_MAP_NR = sizeof(e820map)/sizeof(e820map[0]);
- memcpy(E820_MAP, e820map, sizeof(e820map));
+ *HVM_E820_NR = sizeof(e820map)/sizeof(e820map[0]);
+ memcpy(HVM_E820, e820map, sizeof(e820map));
#endif
printf("Memory size %ld MB\n", memory_size >> 20);
printf("E820 map:\n");
- print_e820_map(E820_MAP, *E820_MAP_NR);
+ print_e820_map(HVM_E820, *HVM_E820_NR);
printf("\n");
}
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/firmware/vmxassist/util.h
--- a/tools/firmware/vmxassist/util.h Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/firmware/vmxassist/util.h Sun Jun 10 19:49:44 2007 +0100
@@ -23,13 +23,11 @@
#include <stdarg.h>
#include <vm86.h>
-#include <xen/hvm/e820.h>
-#define E820_MAP_NR ((unsigned char *)E820_MAP_PAGE + E820_MAP_NR_OFFSET)
-#define E820_MAP ((struct e820entry *)(E820_MAP_PAGE + E820_MAP_OFFSET))
-
#define offsetof(type, member) ((unsigned) &((type *)0)->member)
struct vmx_assist_context;
+
+#include "../hvmloader/e820.h"
extern void cpuid_addr_value(uint64_t addr, uint64_t *value);
extern void hexdump(unsigned char *, int);
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/ioemu/target-i386-dm/exec-dm.c Sun Jun 10 19:49:44 2007 +0100
@@ -31,8 +31,6 @@
#include <errno.h>
#include <unistd.h>
#include <inttypes.h>
-
-#include <xen/hvm/e820.h>
#include "cpu.h"
#include "exec-all.h"
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/ioemu/vl.h
--- a/tools/ioemu/vl.h Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/ioemu/vl.h Sun Jun 10 19:49:44 2007 +0100
@@ -39,7 +39,6 @@
#include <sys/stat.h>
#include "xenctrl.h"
#include "xs.h"
-#include <xen/hvm/e820.h>
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/libxc/xc_dom_x86.c
--- a/tools/libxc/xc_dom_x86.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/libxc/xc_dom_x86.c Sun Jun 10 19:49:44 2007 +0100
@@ -18,7 +18,6 @@
#include <xen/foreign/x86_32.h>
#include <xen/foreign/x86_64.h>
#include <xen/hvm/hvm_info_table.h>
-#include <xen/hvm/e820.h>
#include <xen/io/protocols.h>
#include "xg_private.h"
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/libxc/xc_domain.c Sun Jun 10 19:49:44 2007 +0100
@@ -372,7 +372,7 @@ int xc_domain_setmaxmem(int xc_handle,
}
#if defined(__i386__) || defined(__x86_64__)
-#include <xen/hvm/e820.h>
+#include "xc_e820.h"
int xc_domain_set_memmap_limit(int xc_handle,
uint32_t domid,
unsigned long map_limitkb)
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/libxc/xc_domain_save.c Sun Jun 10 19:49:44 2007 +0100
@@ -18,7 +18,7 @@
#include "xg_save_restore.h"
#include <xen/hvm/params.h>
-#include <xen/hvm/e820.h>
+#include "xc_e820.h"
/*
** Default values for important tuning parameters. Can override by passing
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/libxc/xc_e820.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxc/xc_e820.h Sun Jun 10 19:49:44 2007 +0100
@@ -0,0 +1,20 @@
+#ifndef __XC_E820_H__
+#define __XC_E820_H__
+
+#include <xen/hvm/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 /* __XC_E820_H__ */
diff -r ac9d3bcc7a78 -r 7eeddd787d2f tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c Sun Jun 10 19:29:32 2007 +0100
+++ b/tools/libxc/xc_hvm_build.c Sun Jun 10 19:49:44 2007 +0100
@@ -15,7 +15,7 @@
#include <xen/foreign/x86_64.h>
#include <xen/hvm/hvm_info_table.h>
#include <xen/hvm/params.h>
-#include <xen/hvm/e820.h>
+#include "xc_e820.h"
#include <xen/libelf.h>
@@ -32,7 +32,7 @@ static void build_e820map(void *e820_pag
static void build_e820map(void *e820_page, unsigned long long mem_size)
{
struct e820entry *e820entry =
- (struct e820entry *)(((unsigned char *)e820_page) + E820_MAP_OFFSET);
+ (struct e820entry *)(((unsigned char *)e820_page) + HVM_E820_OFFSET);
unsigned long long extra_mem_size = 0;
unsigned char nr_map = 0;
@@ -105,7 +105,7 @@ static void build_e820map(void *e820_pag
nr_map++;
}
- *(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map;
+ *(((unsigned char *)e820_page) + HVM_E820_NR_OFFSET) = nr_map;
}
static int loadelfimage(
@@ -226,7 +226,7 @@ static int setup_guest(int xc_handle,
if ( (e820_page = xc_map_foreign_range(
xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
- E820_MAP_PAGE >> PAGE_SHIFT)) == NULL )
+ HVM_E820_PAGE >> PAGE_SHIFT)) == NULL )
goto error_out;
memset(e820_page, 0, PAGE_SIZE);
build_e820map(e820_page, v_end);
diff -r ac9d3bcc7a78 -r 7eeddd787d2f xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c Sun Jun 10 19:29:32 2007 +0100
+++ b/xen/arch/x86/domctl.c Sun Jun 10 19:49:44 2007 +0100
@@ -24,7 +24,6 @@
#include <asm/hvm/hvm.h>
#include <asm/hvm/support.h>
#include <asm/processor.h>
-#include <public/hvm/e820.h>
long arch_do_domctl(
struct xen_domctl *domctl,
diff -r ac9d3bcc7a78 -r 7eeddd787d2f xen/include/asm-x86/e820.h
--- a/xen/include/asm-x86/e820.h Sun Jun 10 19:29:32 2007 +0100
+++ b/xen/include/asm-x86/e820.h Sun Jun 10 19:49:44 2007 +0100
@@ -1,7 +1,19 @@
#ifndef __E820_HEADER
#define __E820_HEADER
-#include <public/hvm/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));
#define E820MAX 128
diff -r ac9d3bcc7a78 -r 7eeddd787d2f xen/include/public/hvm/e820.h
--- a/xen/include/public/hvm/e820.h Sun Jun 10 19:29:32 2007 +0100
+++ b/xen/include/public/hvm/e820.h Sun Jun 10 19:49:44 2007 +0100
@@ -22,25 +22,12 @@
#ifndef __XEN_PUBLIC_HVM_E820_H__
#define __XEN_PUBLIC_HVM_E820_H__
-/* PC BIOS standard E820 types. */
-#define E820_RAM 1
-#define E820_RESERVED 2
-#define E820_ACPI 3
-#define E820_NVS 4
-
/* E820 location in HVM virtual address space. */
-#define E820_MAP_PAGE 0x00090000
-#define E820_MAP_NR_OFFSET 0x000001E8
-#define E820_MAP_OFFSET 0x000002D0
-
-struct e820entry {
- uint64_t addr;
- uint64_t size;
- uint32_t type;
-} __attribute__((packed));
+#define HVM_E820_PAGE 0x00090000
+#define HVM_E820_NR_OFFSET 0x000001E8
+#define HVM_E820_OFFSET 0x000002D0
#define HVM_BELOW_4G_RAM_END 0xF0000000
-
#define HVM_BELOW_4G_MMIO_START HVM_BELOW_4G_RAM_END
#define HVM_BELOW_4G_MMIO_LENGTH ((1ULL << 32) - HVM_BELOW_4G_MMIO_START)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|