direct-io.hg

changeset 15248:7eeddd787d2f

hvm: e820 public header cleanup.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Sun Jun 10 19:49:44 2007 +0100 (2007-06-10)
parents ac9d3bcc7a78
children 93f77a5a8437
files tools/firmware/hvmloader/e820.h tools/firmware/hvmloader/hvmloader.c tools/firmware/hvmloader/smbios.c tools/firmware/hvmloader/util.c tools/firmware/hvmloader/util.h tools/firmware/vmxassist/setup.c tools/firmware/vmxassist/util.h tools/ioemu/target-i386-dm/exec-dm.c tools/ioemu/vl.h tools/libxc/xc_dom_x86.c tools/libxc/xc_domain.c tools/libxc/xc_domain_save.c tools/libxc/xc_e820.h tools/libxc/xc_hvm_build.c xen/arch/x86/domctl.c xen/include/asm-x86/e820.h xen/include/public/hvm/e820.h
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/firmware/hvmloader/e820.h	Sun Jun 10 19:49:44 2007 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +#ifndef __HVMLOADER_E820_H__
     1.5 +#define __HVMLOADER_E820_H__
     1.6 +
     1.7 +#include <xen/hvm/e820.h>
     1.8 +
     1.9 +/*
    1.10 + * PC BIOS standard E820 types and structure.
    1.11 + */
    1.12 +#define E820_RAM          1
    1.13 +#define E820_RESERVED     2
    1.14 +#define E820_ACPI         3
    1.15 +#define E820_NVS          4
    1.16 +
    1.17 +struct e820entry {
    1.18 +    uint64_t addr;
    1.19 +    uint64_t size;
    1.20 +    uint32_t type;
    1.21 +} __attribute__((packed));
    1.22 +
    1.23 +#define HVM_E820_NR ((unsigned char *)HVM_E820_PAGE + HVM_E820_NR_OFFSET)
    1.24 +#define HVM_E820    ((struct e820entry *)(HVM_E820_PAGE + HVM_E820_OFFSET))
    1.25 +
    1.26 +#endif /* __HVMLOADER_E820_H__ */
     2.1 --- a/tools/firmware/hvmloader/hvmloader.c	Sun Jun 10 19:29:32 2007 +0100
     2.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Sun Jun 10 19:49:44 2007 +0100
     2.3 @@ -27,6 +27,7 @@
     2.4  #include "config.h"
     2.5  #include "apic_regs.h"
     2.6  #include "pci_regs.h"
     2.7 +#include "e820.h"
     2.8  #include <xen/version.h>
     2.9  #include <xen/hvm/params.h>
    2.10  
    2.11 @@ -311,8 +312,8 @@ static int must_load_nic(void)
    2.12  /* Replace possibly erroneous memory-size CMOS fields with correct values. */
    2.13  static void cmos_write_memory_size(void)
    2.14  {
    2.15 -    struct e820entry *map = E820_MAP;
    2.16 -    int i, nr = *E820_MAP_NR;
    2.17 +    struct e820entry *map = HVM_E820;
    2.18 +    int i, nr = *HVM_E820_NR;
    2.19      uint32_t base_mem = 640, ext_mem = 0, alt_mem = 0;
    2.20  
    2.21      for ( i = 0; i < nr; i++ )
     3.1 --- a/tools/firmware/hvmloader/smbios.c	Sun Jun 10 19:29:32 2007 +0100
     3.2 +++ b/tools/firmware/hvmloader/smbios.c	Sun Jun 10 19:49:44 2007 +0100
     3.3 @@ -25,6 +25,7 @@
     3.4  #include "smbios_types.h"
     3.5  #include "util.h"
     3.6  #include "hypercall.h"
     3.7 +#include "e820.h"
     3.8  
     3.9  static int
    3.10  write_smbios_tables(void *start,
    3.11 @@ -131,8 +132,8 @@ write_smbios_tables(void *start,
    3.12  static uint64_t
    3.13  get_memsize(void)
    3.14  {
    3.15 -    struct e820entry *map = E820_MAP;
    3.16 -    uint8_t num_entries = *E820_MAP_NR;
    3.17 +    struct e820entry *map = HVM_E820;
    3.18 +    uint8_t num_entries = *HVM_E820_NR;
    3.19      uint64_t memsize = 0;
    3.20      int i;
    3.21  
     4.1 --- a/tools/firmware/hvmloader/util.c	Sun Jun 10 19:29:32 2007 +0100
     4.2 +++ b/tools/firmware/hvmloader/util.c	Sun Jun 10 19:49:44 2007 +0100
     4.3 @@ -20,6 +20,7 @@
     4.4  
     4.5  #include "util.h"
     4.6  #include "config.h"
     4.7 +#include "e820.h"
     4.8  #include <stdint.h>
     4.9  #include <xenctrl.h>
    4.10  #include <xen/hvm/hvm_info_table.h>
    4.11 @@ -286,16 +287,16 @@ uuid_to_string(char *dest, uint8_t *uuid
    4.12  static void e820_collapse(void)
    4.13  {
    4.14      int i = 0;
    4.15 -    struct e820entry *ent = (struct e820entry *)E820_MAP;
    4.16 +    struct e820entry *ent = (struct e820entry *)HVM_E820;
    4.17  
    4.18 -    while ( i < (*E820_MAP_NR-1) )
    4.19 +    while ( i < (*HVM_E820_NR-1) )
    4.20      {
    4.21          if ( (ent[i].type == ent[i+1].type) &&
    4.22               ((ent[i].addr + ent[i].size) == ent[i+1].addr) )
    4.23          {
    4.24              ent[i].size += ent[i+1].size;
    4.25 -            memcpy(&ent[i+1], &ent[i+2], (*E820_MAP_NR-i-2) * sizeof(*ent));
    4.26 -            (*E820_MAP_NR)--;
    4.27 +            memcpy(&ent[i+1], &ent[i+2], (*HVM_E820_NR-i-2) * sizeof(*ent));
    4.28 +            (*HVM_E820_NR)--;
    4.29          }
    4.30          else
    4.31          {
    4.32 @@ -308,12 +309,12 @@ uint32_t e820_malloc(uint32_t size)
    4.33  {
    4.34      uint32_t addr;
    4.35      int i;
    4.36 -    struct e820entry *ent = (struct e820entry *)E820_MAP;
    4.37 +    struct e820entry *ent = (struct e820entry *)HVM_E820;
    4.38  
    4.39      /* Align allocation request to a reasonable boundary (1kB). */
    4.40      size = (size + 1023) & ~1023;
    4.41  
    4.42 -    for ( i = *E820_MAP_NR - 1; i >= 0; i-- )
    4.43 +    for ( i = *HVM_E820_NR - 1; i >= 0; i-- )
    4.44      {
    4.45          addr = ent[i].addr;
    4.46          if ( (ent[i].type != E820_RAM) || /* not ram? */
    4.47 @@ -324,8 +325,8 @@ uint32_t e820_malloc(uint32_t size)
    4.48  
    4.49          if ( ent[i].size != size )
    4.50          {
    4.51 -            memmove(&ent[i+1], &ent[i], (*E820_MAP_NR-i) * sizeof(*ent));
    4.52 -            (*E820_MAP_NR)++;
    4.53 +            memmove(&ent[i+1], &ent[i], (*HVM_E820_NR-i) * sizeof(*ent));
    4.54 +            (*HVM_E820_NR)++;
    4.55              ent[i].size -= size;
    4.56              addr += ent[i].size;
    4.57              i++;
     5.1 --- a/tools/firmware/hvmloader/util.h	Sun Jun 10 19:29:32 2007 +0100
     5.2 +++ b/tools/firmware/hvmloader/util.h	Sun Jun 10 19:49:44 2007 +0100
     5.3 @@ -84,11 +84,6 @@ int vprintf(const char *fmt, va_list ap)
     5.4  /* Reserve a RAM region in the e820 table. */
     5.5  uint32_t e820_malloc(uint32_t size);
     5.6  
     5.7 -/* General e820 access. */
     5.8 -#include <xen/hvm/e820.h>
     5.9 -#define E820_MAP_NR ((unsigned char *)E820_MAP_PAGE + E820_MAP_NR_OFFSET)
    5.10 -#define E820_MAP    ((struct e820entry *)(E820_MAP_PAGE + E820_MAP_OFFSET))
    5.11 -
    5.12  /* Prepare the 32bit BIOS */
    5.13  void highbios_setup(void);
    5.14  
     6.1 --- a/tools/firmware/vmxassist/setup.c	Sun Jun 10 19:29:32 2007 +0100
     6.2 +++ b/tools/firmware/vmxassist/setup.c	Sun Jun 10 19:49:44 2007 +0100
     6.3 @@ -91,13 +91,13 @@ banner(void)
     6.4  	e820map[6].addr = memory_size;
     6.5  	e820map[7].addr += memory_size;
     6.6  
     6.7 -	*E820_MAP_NR = sizeof(e820map)/sizeof(e820map[0]);
     6.8 -	memcpy(E820_MAP, e820map, sizeof(e820map));
     6.9 +	*HVM_E820_NR = sizeof(e820map)/sizeof(e820map[0]);
    6.10 +	memcpy(HVM_E820, e820map, sizeof(e820map));
    6.11  #endif
    6.12  
    6.13  	printf("Memory size %ld MB\n", memory_size >> 20);
    6.14  	printf("E820 map:\n");
    6.15 -	print_e820_map(E820_MAP, *E820_MAP_NR);
    6.16 +	print_e820_map(HVM_E820, *HVM_E820_NR);
    6.17  	printf("\n");
    6.18  }
    6.19  
     7.1 --- a/tools/firmware/vmxassist/util.h	Sun Jun 10 19:29:32 2007 +0100
     7.2 +++ b/tools/firmware/vmxassist/util.h	Sun Jun 10 19:49:44 2007 +0100
     7.3 @@ -23,14 +23,12 @@
     7.4  #include <stdarg.h>
     7.5  #include <vm86.h>
     7.6  
     7.7 -#include <xen/hvm/e820.h>
     7.8 -#define E820_MAP_NR ((unsigned char *)E820_MAP_PAGE + E820_MAP_NR_OFFSET)
     7.9 -#define E820_MAP    ((struct e820entry *)(E820_MAP_PAGE + E820_MAP_OFFSET))
    7.10 -
    7.11  #define	offsetof(type, member)	((unsigned) &((type *)0)->member)
    7.12  
    7.13  struct vmx_assist_context;
    7.14  
    7.15 +#include "../hvmloader/e820.h"
    7.16 +
    7.17  extern void cpuid_addr_value(uint64_t addr, uint64_t *value);
    7.18  extern void hexdump(unsigned char *, int);
    7.19  extern void dump_regs(struct regs *);
     8.1 --- a/tools/ioemu/target-i386-dm/exec-dm.c	Sun Jun 10 19:29:32 2007 +0100
     8.2 +++ b/tools/ioemu/target-i386-dm/exec-dm.c	Sun Jun 10 19:49:44 2007 +0100
     8.3 @@ -32,8 +32,6 @@
     8.4  #include <unistd.h>
     8.5  #include <inttypes.h>
     8.6  
     8.7 -#include <xen/hvm/e820.h>
     8.8 -
     8.9  #include "cpu.h"
    8.10  #include "exec-all.h"
    8.11  #include "vl.h"
     9.1 --- a/tools/ioemu/vl.h	Sun Jun 10 19:29:32 2007 +0100
     9.2 +++ b/tools/ioemu/vl.h	Sun Jun 10 19:49:44 2007 +0100
     9.3 @@ -39,7 +39,6 @@
     9.4  #include <sys/stat.h>
     9.5  #include "xenctrl.h"
     9.6  #include "xs.h"
     9.7 -#include <xen/hvm/e820.h>
     9.8  
     9.9  #ifndef O_LARGEFILE
    9.10  #define O_LARGEFILE 0
    10.1 --- a/tools/libxc/xc_dom_x86.c	Sun Jun 10 19:29:32 2007 +0100
    10.2 +++ b/tools/libxc/xc_dom_x86.c	Sun Jun 10 19:49:44 2007 +0100
    10.3 @@ -18,7 +18,6 @@
    10.4  #include <xen/foreign/x86_32.h>
    10.5  #include <xen/foreign/x86_64.h>
    10.6  #include <xen/hvm/hvm_info_table.h>
    10.7 -#include <xen/hvm/e820.h>
    10.8  #include <xen/io/protocols.h>
    10.9  
   10.10  #include "xg_private.h"
    11.1 --- a/tools/libxc/xc_domain.c	Sun Jun 10 19:29:32 2007 +0100
    11.2 +++ b/tools/libxc/xc_domain.c	Sun Jun 10 19:49:44 2007 +0100
    11.3 @@ -372,7 +372,7 @@ int xc_domain_setmaxmem(int xc_handle,
    11.4  }
    11.5  
    11.6  #if defined(__i386__) || defined(__x86_64__)
    11.7 -#include <xen/hvm/e820.h>
    11.8 +#include "xc_e820.h"
    11.9  int xc_domain_set_memmap_limit(int xc_handle,
   11.10                                 uint32_t domid,
   11.11                                 unsigned long map_limitkb)
    12.1 --- a/tools/libxc/xc_domain_save.c	Sun Jun 10 19:29:32 2007 +0100
    12.2 +++ b/tools/libxc/xc_domain_save.c	Sun Jun 10 19:49:44 2007 +0100
    12.3 @@ -18,7 +18,7 @@
    12.4  #include "xg_save_restore.h"
    12.5  
    12.6  #include <xen/hvm/params.h>
    12.7 -#include <xen/hvm/e820.h>
    12.8 +#include "xc_e820.h"
    12.9  
   12.10  /*
   12.11  ** Default values for important tuning parameters. Can override by passing
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/tools/libxc/xc_e820.h	Sun Jun 10 19:49:44 2007 +0100
    13.3 @@ -0,0 +1,20 @@
    13.4 +#ifndef __XC_E820_H__
    13.5 +#define __XC_E820_H__
    13.6 +
    13.7 +#include <xen/hvm/e820.h>
    13.8 +
    13.9 +/*
   13.10 + * PC BIOS standard E820 types and structure.
   13.11 + */
   13.12 +#define E820_RAM          1
   13.13 +#define E820_RESERVED     2
   13.14 +#define E820_ACPI         3
   13.15 +#define E820_NVS          4
   13.16 +
   13.17 +struct e820entry {
   13.18 +    uint64_t addr;
   13.19 +    uint64_t size;
   13.20 +    uint32_t type;
   13.21 +} __attribute__((packed));
   13.22 +
   13.23 +#endif /* __XC_E820_H__ */
    14.1 --- a/tools/libxc/xc_hvm_build.c	Sun Jun 10 19:29:32 2007 +0100
    14.2 +++ b/tools/libxc/xc_hvm_build.c	Sun Jun 10 19:49:44 2007 +0100
    14.3 @@ -15,7 +15,7 @@
    14.4  #include <xen/foreign/x86_64.h>
    14.5  #include <xen/hvm/hvm_info_table.h>
    14.6  #include <xen/hvm/params.h>
    14.7 -#include <xen/hvm/e820.h>
    14.8 +#include "xc_e820.h"
    14.9  
   14.10  #include <xen/libelf.h>
   14.11  
   14.12 @@ -32,7 +32,7 @@ typedef union
   14.13  static void build_e820map(void *e820_page, unsigned long long mem_size)
   14.14  {
   14.15      struct e820entry *e820entry =
   14.16 -        (struct e820entry *)(((unsigned char *)e820_page) + E820_MAP_OFFSET);
   14.17 +        (struct e820entry *)(((unsigned char *)e820_page) + HVM_E820_OFFSET);
   14.18      unsigned long long extra_mem_size = 0;
   14.19      unsigned char nr_map = 0;
   14.20  
   14.21 @@ -105,7 +105,7 @@ static void build_e820map(void *e820_pag
   14.22          nr_map++;
   14.23      }
   14.24  
   14.25 -    *(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map;
   14.26 +    *(((unsigned char *)e820_page) + HVM_E820_NR_OFFSET) = nr_map;
   14.27  }
   14.28  
   14.29  static int loadelfimage(
   14.30 @@ -226,7 +226,7 @@ static int setup_guest(int xc_handle,
   14.31  
   14.32      if ( (e820_page = xc_map_foreign_range(
   14.33                xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
   14.34 -              E820_MAP_PAGE >> PAGE_SHIFT)) == NULL )
   14.35 +              HVM_E820_PAGE >> PAGE_SHIFT)) == NULL )
   14.36          goto error_out;
   14.37      memset(e820_page, 0, PAGE_SIZE);
   14.38      build_e820map(e820_page, v_end);
    15.1 --- a/xen/arch/x86/domctl.c	Sun Jun 10 19:29:32 2007 +0100
    15.2 +++ b/xen/arch/x86/domctl.c	Sun Jun 10 19:49:44 2007 +0100
    15.3 @@ -24,7 +24,6 @@
    15.4  #include <asm/hvm/hvm.h>
    15.5  #include <asm/hvm/support.h>
    15.6  #include <asm/processor.h>
    15.7 -#include <public/hvm/e820.h>
    15.8  
    15.9  long arch_do_domctl(
   15.10      struct xen_domctl *domctl,
    16.1 --- a/xen/include/asm-x86/e820.h	Sun Jun 10 19:29:32 2007 +0100
    16.2 +++ b/xen/include/asm-x86/e820.h	Sun Jun 10 19:49:44 2007 +0100
    16.3 @@ -1,7 +1,19 @@
    16.4  #ifndef __E820_HEADER
    16.5  #define __E820_HEADER
    16.6  
    16.7 -#include <public/hvm/e820.h>
    16.8 +/*
    16.9 + * PC BIOS standard E820 types and structure.
   16.10 + */
   16.11 +#define E820_RAM          1
   16.12 +#define E820_RESERVED     2
   16.13 +#define E820_ACPI         3
   16.14 +#define E820_NVS          4
   16.15 +
   16.16 +struct e820entry {
   16.17 +    uint64_t addr;
   16.18 +    uint64_t size;
   16.19 +    uint32_t type;
   16.20 +} __attribute__((packed));
   16.21  
   16.22  #define E820MAX	128
   16.23  
    17.1 --- a/xen/include/public/hvm/e820.h	Sun Jun 10 19:29:32 2007 +0100
    17.2 +++ b/xen/include/public/hvm/e820.h	Sun Jun 10 19:49:44 2007 +0100
    17.3 @@ -22,25 +22,12 @@
    17.4  #ifndef __XEN_PUBLIC_HVM_E820_H__
    17.5  #define __XEN_PUBLIC_HVM_E820_H__
    17.6  
    17.7 -/* PC BIOS standard E820 types. */
    17.8 -#define E820_RAM          1
    17.9 -#define E820_RESERVED     2
   17.10 -#define E820_ACPI         3
   17.11 -#define E820_NVS          4
   17.12 -
   17.13  /* E820 location in HVM virtual address space. */
   17.14 -#define E820_MAP_PAGE        0x00090000
   17.15 -#define E820_MAP_NR_OFFSET   0x000001E8
   17.16 -#define E820_MAP_OFFSET      0x000002D0
   17.17 -
   17.18 -struct e820entry {
   17.19 -    uint64_t addr;
   17.20 -    uint64_t size;
   17.21 -    uint32_t type;
   17.22 -} __attribute__((packed));
   17.23 +#define HVM_E820_PAGE        0x00090000
   17.24 +#define HVM_E820_NR_OFFSET   0x000001E8
   17.25 +#define HVM_E820_OFFSET      0x000002D0
   17.26  
   17.27  #define HVM_BELOW_4G_RAM_END        0xF0000000
   17.28 -
   17.29  #define HVM_BELOW_4G_MMIO_START     HVM_BELOW_4G_RAM_END
   17.30  #define HVM_BELOW_4G_MMIO_LENGTH    ((1ULL << 32) - HVM_BELOW_4G_MMIO_START)
   17.31