ia64/xen-unstable

changeset 3606:281346e5fc97

bitkeeper revision 1.1159.212.67 (42001d370Zk3jsfUjyC3iV9vgEJAlA)

Create the e820 map dynamically. This makes it easy to run VMX guests
of different memory sizes (no need to manually edit the e820 map).

Signed-off-by: Xin B Li <xin.b.li@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
Signed-off-by: ian.pratt@cl.cam.ac.uk
author iap10@labyrinth.cl.cam.ac.uk
date Wed Feb 02 00:22:15 2005 +0000 (2005-02-02)
parents a920f0ced90f
children fd1dd0663b09
files tools/libxc/linux_boot_params.h tools/libxc/xc_vmx_build.c
line diff
     1.1 --- a/tools/libxc/linux_boot_params.h	Wed Feb 02 00:14:39 2005 +0000
     1.2 +++ b/tools/libxc/linux_boot_params.h	Wed Feb 02 00:22:15 2005 +0000
     1.3 @@ -15,6 +15,8 @@ struct mem_map {
     1.4  #define E820_RESERVED   2
     1.5  #define E820_ACPI       3 /* usable as RAM once ACPI tables have been read */
     1.6  #define E820_NVS        4
     1.7 +#define E820_IO         16
     1.8 +#define E820_SHARED     17
     1.9  
    1.10          unsigned long caching_attr;    /* used by hypervisor */
    1.11  #define MEMMAP_UC	0
     2.1 --- a/tools/libxc/xc_vmx_build.c	Wed Feb 02 00:14:39 2005 +0000
     2.2 +++ b/tools/libxc/xc_vmx_build.c	Wed Feb 02 00:22:15 2005 +0000
     2.3 @@ -46,6 +46,68 @@ loadelfsymtab(
     2.4      char *elfbase, int xch, u32 dom, unsigned long *parray,
     2.5      struct domain_setup_info *dsi);
     2.6  
     2.7 +static void build_e820map(struct mem_map *mem_mapp, unsigned long mem_size)
     2.8 +{
     2.9 +    int nr_map = 0;
    2.10 +
    2.11 +    /* XXX: Doesn't work for > 4GB yet */
    2.12 +    mem_mapp->map[0].addr = 0x0;
    2.13 +    mem_mapp->map[0].size = 0x9F800;
    2.14 +    mem_mapp->map[0].type = E820_RAM;
    2.15 +    mem_mapp->map[0].caching_attr = MEMMAP_WB;
    2.16 +    nr_map++;
    2.17 +
    2.18 +    mem_mapp->map[1].addr = 0x9F800;
    2.19 +    mem_mapp->map[1].size = 0x800;
    2.20 +    mem_mapp->map[1].type = E820_RESERVED;
    2.21 +    mem_mapp->map[1].caching_attr = MEMMAP_UC;
    2.22 +    nr_map++;
    2.23 +
    2.24 +    mem_mapp->map[2].addr = 0xA0000;
    2.25 +    mem_mapp->map[2].size = 0x20000;
    2.26 +    mem_mapp->map[2].type = E820_IO;
    2.27 +    mem_mapp->map[2].caching_attr = MEMMAP_UC;
    2.28 +    nr_map++;
    2.29 +
    2.30 +    mem_mapp->map[3].addr = 0xF0000;
    2.31 +    mem_mapp->map[3].size = 0x10000;
    2.32 +    mem_mapp->map[3].type = E820_RESERVED;
    2.33 +    mem_mapp->map[3].caching_attr = MEMMAP_UC;
    2.34 +    nr_map++;
    2.35 +
    2.36 +    mem_mapp->map[4].addr = 0x100000;
    2.37 +    mem_mapp->map[4].size = mem_size - 0x100000 - PAGE_SIZE;
    2.38 +    mem_mapp->map[4].type = E820_RAM;
    2.39 +    mem_mapp->map[4].caching_attr = MEMMAP_WB;
    2.40 +    nr_map++;
    2.41 +
    2.42 +    mem_mapp->map[5].addr = mem_size - PAGE_SIZE;
    2.43 +    mem_mapp->map[5].size = PAGE_SIZE;
    2.44 +    mem_mapp->map[5].type = E820_SHARED;
    2.45 +    mem_mapp->map[5].caching_attr = MEMMAP_WB;
    2.46 +    nr_map++;
    2.47 +
    2.48 +    mem_mapp->map[6].addr = mem_size;
    2.49 +    mem_mapp->map[6].size = 0x3 * PAGE_SIZE;
    2.50 +    mem_mapp->map[6].type = E820_NVS;
    2.51 +    mem_mapp->map[6].caching_attr = MEMMAP_UC;
    2.52 +    nr_map++;
    2.53 +
    2.54 +    mem_mapp->map[7].addr = mem_size + 0x3 * PAGE_SIZE;
    2.55 +    mem_mapp->map[7].size = 0xA * PAGE_SIZE;
    2.56 +    mem_mapp->map[7].type = E820_ACPI;
    2.57 +    mem_mapp->map[7].caching_attr = MEMMAP_WB;
    2.58 +    nr_map++;
    2.59 +
    2.60 +    mem_mapp->map[8].addr = 0xFEC00000;
    2.61 +    mem_mapp->map[8].size = 0x1400000;
    2.62 +    mem_mapp->map[8].type = E820_IO;
    2.63 +    mem_mapp->map[8].caching_attr = MEMMAP_UC;
    2.64 +    nr_map++;
    2.65 +
    2.66 +    mem_mapp->nr_map = nr_map;
    2.67 +}
    2.68 +
    2.69  static int setup_guestos(int xc_handle,
    2.70                           u32 dom, int memsize,
    2.71                           char *image, unsigned long image_size,
    2.72 @@ -115,6 +177,7 @@ static int setup_guestos(int xc_handle,
    2.73      vboot_gdt_start    = vboot_params_end;
    2.74      vboot_gdt_end      = vboot_gdt_start + PAGE_SIZE;
    2.75  
    2.76 +    /* memsize is in megabytes */
    2.77      v_end              = memsize << 20;
    2.78      vinitrd_end        = v_end - PAGE_SIZE; /* leaving the top 4k untouched for IO requests page use */
    2.79      vinitrd_start      = vinitrd_end - initrd_len;
    2.80 @@ -290,6 +353,8 @@ static int setup_guestos(int xc_handle,
    2.81      boot_paramsp->drive_info.dummy[2] = 4;
    2.82      boot_paramsp->drive_info.dummy[14] = 32;
    2.83  
    2.84 +    /* memsize is in megabytes */
    2.85 +    build_e820map(mem_mapp, memsize << 20);
    2.86      boot_paramsp->e820_map_nr = mem_mapp->nr_map;
    2.87      for (i=0; i<mem_mapp->nr_map; i++) {
    2.88          boot_paramsp->e820_map[i].addr = mem_mapp->map[i].addr;