ia64/xen-unstable

changeset 10691:dab0a5650e6d

[IA64] Creates tools/libxc/ia64 directory.

Split and move xc_ia64_stubs.c into ia64/xc_ia64_hvm_build.c and
ia64/xc_ia64_stubs.c
Creates ia64/Makefile.
Clean up (static in const) in xc_ia64_hvm_build.c

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
[whitespace cleanups in new files]
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@xenbuild.aw
date Tue Jul 11 11:29:25 2006 -0600 (2006-07-11)
parents dc26ac2f7718
children 306d7857928c
files tools/libxc/Makefile tools/libxc/ia64/Makefile tools/libxc/ia64/xc_ia64_hvm_build.c tools/libxc/ia64/xc_ia64_stubs.c tools/libxc/xc_ia64_stubs.c tools/libxc/xc_private.c tools/libxc/xenctrl.h
line diff
     1.1 --- a/tools/libxc/Makefile	Mon Jul 10 14:14:11 2006 -0600
     1.2 +++ b/tools/libxc/Makefile	Tue Jul 11 11:29:25 2006 -0600
     1.3 @@ -30,10 +30,12 @@ GUEST_SRCS-y += xc_linux_build.c
     1.4  GUEST_SRCS-y += xc_load_bin.c
     1.5  GUEST_SRCS-y += xc_load_elf.c
     1.6  GUEST_SRCS-y += xg_private.c
     1.7 -GUEST_SRCS-$(CONFIG_IA64) += xc_ia64_stubs.c
     1.8  GUEST_SRCS-$(CONFIG_MIGRATE) += xc_linux_restore.c xc_linux_save.c
     1.9  GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c
    1.10  
    1.11 +# This Makefile only adds files if CONFIG_IA64 is y.
    1.12 +include ia64/Makefile
    1.13 +
    1.14  CFLAGS   += -Werror
    1.15  CFLAGS   += -fno-strict-aliasing
    1.16  CFLAGS   += $(INCLUDES) -I.
    1.17 @@ -98,6 +100,7 @@ TAGS:
    1.18  .PHONY: clean
    1.19  clean:
    1.20  	rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
    1.21 +	rm -rf ia64/*.o ia64/*.opic
    1.22  
    1.23  .PHONY: rpm
    1.24  rpm: build
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/libxc/ia64/Makefile	Tue Jul 11 11:29:25 2006 -0600
     2.3 @@ -0,0 +1,3 @@
     2.4 +CTRL_SRCS-$(CONFIG_IA64) += ia64/xc_ia64_stubs.c
     2.5 +
     2.6 +GUEST_SRCS-$(CONFIG_IA64) += ia64/xc_ia64_hvm_build.c
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c	Tue Jul 11 11:29:25 2006 -0600
     3.3 @@ -0,0 +1,673 @@
     3.4 +#include "xg_private.h"
     3.5 +#include "xenguest.h"
     3.6 +#include "xc_private.h"
     3.7 +#include "xc_elf.h"
     3.8 +#include <stdlib.h>
     3.9 +#include <zlib.h>
    3.10 +#include "xen/arch-ia64.h"
    3.11 +#include <xen/hvm/ioreq.h>
    3.12 +
    3.13 +static int
    3.14 +xc_ia64_copy_to_domain_pages(int xc_handle, uint32_t domid, void* src_page,
    3.15 +                             unsigned long dst_pfn, int nr_pages)
    3.16 +{
    3.17 +    // N.B. gva should be page aligned
    3.18 +
    3.19 +    xen_pfn_t *page_array = NULL;
    3.20 +    int i;
    3.21 +
    3.22 +    page_array = malloc(nr_pages * sizeof(xen_pfn_t));
    3.23 +    if (page_array == NULL) {
    3.24 +        PERROR("Could not allocate memory");
    3.25 +        goto error_out;
    3.26 +    }
    3.27 +    if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
    3.28 +                             dst_pfn, nr_pages) != nr_pages) {
    3.29 +        PERROR("Could not get the page frame list");
    3.30 +        goto error_out;
    3.31 +    }
    3.32 +
    3.33 +    for (i = 0; i < nr_pages; i++) {
    3.34 +        if (xc_copy_to_domain_page(xc_handle, domid, page_array[i],
    3.35 +                                   src_page + (i << PAGE_SHIFT)))
    3.36 +            goto error_out;
    3.37 +    }
    3.38 +    free(page_array);
    3.39 +    return 0;
    3.40 +
    3.41 +error_out:
    3.42 +    free(page_array);
    3.43 +    return -1;
    3.44 +}
    3.45 +
    3.46 +
    3.47 +#define HOB_SIGNATURE         0x3436474953424f48        // "HOBSIG64"
    3.48 +#define GFW_HOB_START         ((4UL<<30)-(14UL<<20))    // 4G - 14M
    3.49 +#define GFW_HOB_SIZE          (1UL<<20)                 // 1M
    3.50 +
    3.51 +typedef struct {
    3.52 +    unsigned long signature;
    3.53 +    unsigned int  type;
    3.54 +    unsigned int  length;
    3.55 +} HOB_GENERIC_HEADER;
    3.56 +
    3.57 +/*
    3.58 + * INFO HOB is the first data data in one HOB list
    3.59 + * it contains the control information of the HOB list
    3.60 + */
    3.61 +typedef struct {
    3.62 +    HOB_GENERIC_HEADER  header;
    3.63 +    unsigned long       length;    // current length of hob
    3.64 +    unsigned long       cur_pos;   // current poisiton of hob
    3.65 +    unsigned long       buf_size;  // size of hob buffer
    3.66 +} HOB_INFO;
    3.67 +
    3.68 +typedef struct{
    3.69 +    unsigned long start;
    3.70 +    unsigned long size;
    3.71 +} hob_mem_t;
    3.72 +
    3.73 +typedef enum {
    3.74 +    HOB_TYPE_INFO=0,
    3.75 +    HOB_TYPE_TERMINAL,
    3.76 +    HOB_TYPE_MEM,
    3.77 +    HOB_TYPE_PAL_BUS_GET_FEATURES_DATA,
    3.78 +    HOB_TYPE_PAL_CACHE_SUMMARY,
    3.79 +    HOB_TYPE_PAL_MEM_ATTRIB,
    3.80 +    HOB_TYPE_PAL_CACHE_INFO,
    3.81 +    HOB_TYPE_PAL_CACHE_PROT_INFO,
    3.82 +    HOB_TYPE_PAL_DEBUG_INFO,
    3.83 +    HOB_TYPE_PAL_FIXED_ADDR,
    3.84 +    HOB_TYPE_PAL_FREQ_BASE,
    3.85 +    HOB_TYPE_PAL_FREQ_RATIOS,
    3.86 +    HOB_TYPE_PAL_HALT_INFO,
    3.87 +    HOB_TYPE_PAL_PERF_MON_INFO,
    3.88 +    HOB_TYPE_PAL_PROC_GET_FEATURES,
    3.89 +    HOB_TYPE_PAL_PTCE_INFO,
    3.90 +    HOB_TYPE_PAL_REGISTER_INFO,
    3.91 +    HOB_TYPE_PAL_RSE_INFO,
    3.92 +    HOB_TYPE_PAL_TEST_INFO,
    3.93 +    HOB_TYPE_PAL_VM_SUMMARY,
    3.94 +    HOB_TYPE_PAL_VM_INFO,
    3.95 +    HOB_TYPE_PAL_VM_PAGE_SIZE,
    3.96 +    HOB_TYPE_NR_VCPU,
    3.97 +    HOB_TYPE_MAX
    3.98 +} hob_type_t;
    3.99 +
   3.100 +static int hob_init(void  *buffer ,unsigned long buf_size);
   3.101 +static int add_pal_hob(void* hob_buf);
   3.102 +static int add_mem_hob(void* hob_buf, unsigned long dom_mem_size);
   3.103 +static int add_vcpus_hob(void* hob_buf, unsigned long nr_vcpu);
   3.104 +static int build_hob(void* hob_buf, unsigned long hob_buf_size,
   3.105 +                     unsigned long dom_mem_size, unsigned long vcpus);
   3.106 +static int load_hob(int xc_handle,uint32_t dom, void *hob_buf,
   3.107 +                    unsigned long dom_mem_size);
   3.108 +
   3.109 +static int
   3.110 +xc_ia64_build_hob(int xc_handle, uint32_t dom,
   3.111 +                  unsigned long memsize, unsigned long vcpus)
   3.112 +{
   3.113 +    char   *hob_buf;
   3.114 +
   3.115 +    hob_buf = malloc(GFW_HOB_SIZE);
   3.116 +    if (hob_buf == NULL) {
   3.117 +        PERROR("Could not allocate hob");
   3.118 +        return -1;
   3.119 +    }
   3.120 +
   3.121 +    if (build_hob(hob_buf, GFW_HOB_SIZE, memsize, vcpus) < 0) {
   3.122 +        free(hob_buf);
   3.123 +        PERROR("Could not build hob");
   3.124 +        return -1;
   3.125 +    }
   3.126 +
   3.127 +    if (load_hob(xc_handle, dom, hob_buf, memsize) < 0) {
   3.128 +        free(hob_buf);
   3.129 +        PERROR("Could not load hob");
   3.130 +        return -1;
   3.131 +    }
   3.132 +    free(hob_buf);
   3.133 +    return 0;
   3.134 +
   3.135 +}
   3.136 +
   3.137 +static int
   3.138 +hob_init(void *buffer, unsigned long buf_size)
   3.139 +{
   3.140 +    HOB_INFO *phit;
   3.141 +    HOB_GENERIC_HEADER *terminal;
   3.142 +
   3.143 +    if (sizeof(HOB_INFO) + sizeof(HOB_GENERIC_HEADER) > buf_size) {
   3.144 +        // buffer too small
   3.145 +        return -1;
   3.146 +    }
   3.147 +
   3.148 +    phit = (HOB_INFO*)buffer;
   3.149 +    phit->header.signature = HOB_SIGNATURE;
   3.150 +    phit->header.type = HOB_TYPE_INFO;
   3.151 +    phit->header.length = sizeof(HOB_INFO);
   3.152 +    phit->length = sizeof(HOB_INFO) + sizeof(HOB_GENERIC_HEADER);
   3.153 +    phit->cur_pos = 0;
   3.154 +    phit->buf_size = buf_size;
   3.155 +
   3.156 +    terminal = (HOB_GENERIC_HEADER*)(buffer + sizeof(HOB_INFO));
   3.157 +    terminal->signature = HOB_SIGNATURE;
   3.158 +    terminal->type = HOB_TYPE_TERMINAL;
   3.159 +    terminal->length = sizeof(HOB_GENERIC_HEADER);
   3.160 +
   3.161 +    return 0;
   3.162 +}
   3.163 +
   3.164 +/*
   3.165 + *  Add a new HOB to the HOB List.
   3.166 + *
   3.167 + *  hob_start  -  start address of hob buffer
   3.168 + *  type       -  type of the hob to be added
   3.169 + *  data       -  data of the hob to be added
   3.170 + *  data_size  -  size of the data
   3.171 + */
   3.172 +static int
   3.173 +hob_add(void* hob_start, int type, void* data, int data_size)
   3.174 +{
   3.175 +    HOB_INFO *phit;
   3.176 +    HOB_GENERIC_HEADER *newhob, *tail;
   3.177 +
   3.178 +    phit = (HOB_INFO*)hob_start;
   3.179 +
   3.180 +    if (phit->length + data_size > phit->buf_size) {
   3.181 +        // no space for new hob
   3.182 +        return -1;
   3.183 +    }
   3.184 +
   3.185 +    //append new HOB
   3.186 +    newhob = (HOB_GENERIC_HEADER*)(hob_start + phit->length -
   3.187 +                                   sizeof(HOB_GENERIC_HEADER));
   3.188 +    newhob->signature = HOB_SIGNATURE;
   3.189 +    newhob->type = type;
   3.190 +    newhob->length = data_size + sizeof(HOB_GENERIC_HEADER);
   3.191 +    memcpy((void*)newhob + sizeof(HOB_GENERIC_HEADER), data, data_size);
   3.192 +
   3.193 +    // append terminal HOB
   3.194 +    tail = (HOB_GENERIC_HEADER*)(hob_start + phit->length + data_size);
   3.195 +    tail->signature = HOB_SIGNATURE;
   3.196 +    tail->type = HOB_TYPE_TERMINAL;
   3.197 +    tail->length = sizeof(HOB_GENERIC_HEADER);
   3.198 +
   3.199 +    // adjust HOB list length
   3.200 +    phit->length += sizeof(HOB_GENERIC_HEADER) + data_size;
   3.201 +
   3.202 +    return 0;
   3.203 +}
   3.204 +
   3.205 +static int
   3.206 +get_hob_size(void* hob_buf)
   3.207 +{
   3.208 +    HOB_INFO *phit = (HOB_INFO*)hob_buf;
   3.209 +
   3.210 +    if (phit->header.signature != HOB_SIGNATURE) {
   3.211 +        PERROR("xc_get_hob_size:Incorrect signature");
   3.212 +        return -1;
   3.213 +    }
   3.214 +    return phit->length;
   3.215 +}
   3.216 +
   3.217 +static int
   3.218 +build_hob(void* hob_buf, unsigned long hob_buf_size,
   3.219 +          unsigned long dom_mem_size, unsigned long vcpus)
   3.220 +{
   3.221 +    //Init HOB List
   3.222 +    if (hob_init(hob_buf, hob_buf_size) < 0) {
   3.223 +        PERROR("buffer too small");
   3.224 +        goto err_out;
   3.225 +    }
   3.226 +
   3.227 +    if (add_mem_hob(hob_buf,dom_mem_size) < 0) {
   3.228 +        PERROR("Add memory hob failed, buffer too small");
   3.229 +        goto err_out;
   3.230 +    }
   3.231 +
   3.232 +    if (add_vcpus_hob(hob_buf, vcpus) < 0) {
   3.233 +        PERROR("Add NR_VCPU hob failed, buffer too small");
   3.234 +        goto err_out;
   3.235 +    }
   3.236 +
   3.237 +    if (add_pal_hob( hob_buf ) < 0) {
   3.238 +        PERROR("Add PAL hob failed, buffer too small");
   3.239 +        goto err_out;
   3.240 +    }
   3.241 +
   3.242 +    return 0;
   3.243 +
   3.244 +err_out:
   3.245 +    return -1;
   3.246 +}
   3.247 +
   3.248 +static int
   3.249 +load_hob(int xc_handle, uint32_t dom, void *hob_buf,
   3.250 +         unsigned long dom_mem_size)
   3.251 +{
   3.252 +    // hob_buf should be page aligned
   3.253 +    int hob_size;
   3.254 +    int nr_pages;
   3.255 +
   3.256 +    hob_size = get_hob_size(hob_buf);
   3.257 +    if (hob_size < 0) {
   3.258 +        PERROR("Invalid hob data");
   3.259 +        return -1;
   3.260 +    }
   3.261 +
   3.262 +    if (hob_size > GFW_HOB_SIZE) {
   3.263 +        PERROR("No enough memory for hob data");
   3.264 +        return -1;
   3.265 +    }
   3.266 +
   3.267 +    nr_pages = (hob_size + PAGE_SIZE -1) >> PAGE_SHIFT;
   3.268 +
   3.269 +    return xc_ia64_copy_to_domain_pages(xc_handle, dom, hob_buf,
   3.270 +                                        GFW_HOB_START >> PAGE_SHIFT, nr_pages);
   3.271 +}
   3.272 +
   3.273 +#define MIN(x, y) ((x) < (y)) ? (x) : (y)
   3.274 +static int
   3.275 +add_mem_hob(void* hob_buf, unsigned long dom_mem_size)
   3.276 +{
   3.277 +    hob_mem_t memhob;
   3.278 +
   3.279 +    // less than 3G
   3.280 +    memhob.start = 0;
   3.281 +    memhob.size = MIN(dom_mem_size, 0xC0000000);
   3.282 +
   3.283 +    if (hob_add(hob_buf, HOB_TYPE_MEM, &memhob, sizeof(memhob)) < 0)
   3.284 +        return -1;
   3.285 +
   3.286 +    if (dom_mem_size > 0xC0000000) {
   3.287 +        // 4G ~ 4G+remain
   3.288 +        memhob.start = 0x100000000; //4G
   3.289 +        memhob.size = dom_mem_size - 0xC0000000;
   3.290 +        if (hob_add(hob_buf, HOB_TYPE_MEM, &memhob, sizeof(memhob)) < 0)
   3.291 +            return -1;
   3.292 +    }
   3.293 +    return 0;
   3.294 +}
   3.295 +
   3.296 +static int 
   3.297 +add_vcpus_hob(void* hob_buf, unsigned long vcpus)
   3.298 +{
   3.299 +    return hob_add(hob_buf, HOB_TYPE_NR_VCPU, &vcpus, sizeof(vcpus));
   3.300 +}
   3.301 +
   3.302 +static const unsigned char config_pal_bus_get_features_data[24] = {
   3.303 +    0, 0, 0, 32, 0, 0, 240, 189, 0, 0, 0, 0, 0, 0,
   3.304 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   3.305 +};
   3.306 +
   3.307 +static const unsigned char config_pal_cache_summary[16] = {
   3.308 +    3, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0
   3.309 +};
   3.310 +
   3.311 +static const unsigned char config_pal_mem_attrib[8] = {
   3.312 +    241, 0, 0, 0, 0, 0, 0, 0
   3.313 +};
   3.314 +
   3.315 +static const unsigned char config_pal_cache_info[152] = {
   3.316 +    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.317 +    6, 4, 6, 7, 255, 1, 0, 1, 0, 64, 0, 0, 12, 12,
   3.318 +    49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 0, 1,
   3.319 +    0, 1, 0, 64, 0, 0, 12, 12, 49, 0, 0, 0, 0, 0, 0,
   3.320 +    0, 0, 0, 6, 8, 7, 7, 255, 7, 0, 11, 0, 0, 16, 0,
   3.321 +    12, 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 7,
   3.322 +    7, 7, 5, 9, 11, 0, 0, 4, 0, 12, 15, 49, 0, 254, 255,
   3.323 +    255, 255, 255, 255, 255, 255, 2, 8, 7, 7, 7, 5, 9,
   3.324 +    11, 0, 0, 4, 0, 12, 15, 49, 0, 0, 0, 0, 0, 0, 0, 0,
   3.325 +    0, 3, 12, 7, 7, 7, 14, 1, 3, 0, 0, 192, 0, 12, 20, 49, 0
   3.326 +};
   3.327 +
   3.328 +static const unsigned char config_pal_cache_prot_info[200] = {
   3.329 +    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.330 +    45, 0, 16, 8, 0, 76, 12, 64, 0, 0, 0, 0, 0, 0, 0,
   3.331 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.332 +    8, 0, 16, 4, 0, 76, 44, 68, 0, 0, 0, 0, 0, 0, 0, 0,
   3.333 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32,
   3.334 +    0, 16, 8, 0, 81, 44, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.335 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0,
   3.336 +    112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.337 +    0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255,
   3.338 +    32, 0, 112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.339 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 160,
   3.340 +    12, 0, 84, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.341 +    0, 0, 0
   3.342 +};
   3.343 +
   3.344 +static const unsigned char config_pal_debug_info[16] = {
   3.345 +    2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0
   3.346 +};
   3.347 +
   3.348 +static const unsigned char config_pal_fixed_addr[8] = {
   3.349 +    0, 0, 0, 0, 0, 0, 0, 0
   3.350 +};
   3.351 +
   3.352 +static const unsigned char config_pal_freq_base[8] = {
   3.353 +    109, 219, 182, 13, 0, 0, 0, 0
   3.354 +};
   3.355 +
   3.356 +static const unsigned char config_pal_freq_ratios[24] = {
   3.357 +    11, 1, 0, 0, 77, 7, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 4,
   3.358 +    0, 0, 0, 7, 0, 0, 0
   3.359 +};
   3.360 +
   3.361 +static const unsigned char config_pal_halt_info[64] = {
   3.362 +    0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0,
   3.363 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.364 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.365 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   3.366 +};
   3.367 +
   3.368 +static const unsigned char config_pal_perf_mon_info[136] = {
   3.369 +    12, 47, 18, 8, 0, 0, 0, 0, 241, 255, 0, 0, 255, 7, 0, 0,
   3.370 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.371 +    0, 0, 0, 0, 0, 0, 0, 0, 241, 255, 0, 0, 223, 0, 255, 255,
   3.372 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.373 +    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0,
   3.374 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.375 +    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0,
   3.376 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.377 +    0, 0, 0, 0, 0, 0, 0, 0
   3.378 +};
   3.379 +
   3.380 +static const unsigned char config_pal_proc_get_features[104] = {
   3.381 +    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.382 +    0, 0, 0, 0, 64, 6, 64, 49, 0, 0, 0, 0, 64, 6, 0, 0,
   3.383 +    0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0,
   3.384 +    231, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, 0, 0, 0,
   3.385 +    0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0,
   3.386 +    63, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0,
   3.387 +    0, 0, 0, 0, 0, 0, 0, 0
   3.388 +};
   3.389 +
   3.390 +static const unsigned char config_pal_ptce_info[24] = {
   3.391 +    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
   3.392 +    0, 0, 0, 0, 0, 0, 0, 0
   3.393 +};
   3.394 +
   3.395 +static const unsigned char config_pal_register_info[64] = {
   3.396 +    255, 0, 47, 127, 17, 17, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0,
   3.397 +    255, 208, 128, 238, 238, 0, 0, 248, 255, 255, 255, 255, 255, 0, 0, 7, 3,
   3.398 +    251, 3, 0, 0, 0, 0, 255, 7, 3, 0, 0, 0, 0, 0, 248, 252, 4,
   3.399 +    252, 255, 255, 255, 255, 2, 248, 252, 255, 255, 255, 255, 255
   3.400 +};
   3.401 +
   3.402 +static const unsigned char config_pal_rse_info[16] = {
   3.403 +    96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   3.404 +};
   3.405 +
   3.406 +static const unsigned char config_pal_test_info[48] = {
   3.407 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.408 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.409 +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   3.410 +};
   3.411 +
   3.412 +static const unsigned char config_pal_vm_summary[16] = {
   3.413 +    101, 18, 15, 2, 7, 7, 4, 2, 59, 18, 0, 0, 0, 0, 0, 0
   3.414 +};
   3.415 +
   3.416 +static const unsigned char config_pal_vm_info[104] = {
   3.417 +    2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   3.418 +    32, 32, 0, 0, 0, 0, 0, 0, 112, 85, 21, 0, 0, 0, 0, 0, 0,
   3.419 +    0, 0, 0, 0, 0, 0, 1, 32, 32, 0, 0, 0, 0, 0, 0, 112, 85,
   3.420 +    21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 128, 128, 0,
   3.421 +    4, 0, 0, 0, 0, 112, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   3.422 +    0, 0, 0, 1, 128, 128, 0, 4, 0, 0, 0, 0, 112, 85, 0, 0, 0, 0, 0
   3.423 +};
   3.424 +
   3.425 +static const unsigned char config_pal_vm_page_size[16] = {
   3.426 +    0, 112, 85, 21, 0, 0, 0, 0, 0, 112, 85, 21, 0, 0, 0, 0
   3.427 +};
   3.428 +
   3.429 +typedef struct{
   3.430 +    hob_type_t type;
   3.431 +    void* data;
   3.432 +    unsigned long size;
   3.433 +} hob_batch_t;
   3.434 +
   3.435 +static const hob_batch_t hob_batch[]={
   3.436 +    {   HOB_TYPE_PAL_BUS_GET_FEATURES_DATA,
   3.437 +        &config_pal_bus_get_features_data,
   3.438 +        sizeof(config_pal_bus_get_features_data)
   3.439 +    },
   3.440 +    {   HOB_TYPE_PAL_CACHE_SUMMARY,
   3.441 +        &config_pal_cache_summary,
   3.442 +        sizeof(config_pal_cache_summary)
   3.443 +    },
   3.444 +    {   HOB_TYPE_PAL_MEM_ATTRIB,
   3.445 +        &config_pal_mem_attrib,
   3.446 +        sizeof(config_pal_mem_attrib)
   3.447 +    },
   3.448 +    {   HOB_TYPE_PAL_CACHE_INFO,
   3.449 +        &config_pal_cache_info,
   3.450 +        sizeof(config_pal_cache_info)
   3.451 +    },
   3.452 +    {   HOB_TYPE_PAL_CACHE_PROT_INFO,
   3.453 +        &config_pal_cache_prot_info,
   3.454 +        sizeof(config_pal_cache_prot_info)
   3.455 +    },
   3.456 +    {   HOB_TYPE_PAL_DEBUG_INFO,
   3.457 +        &config_pal_debug_info,
   3.458 +        sizeof(config_pal_debug_info)
   3.459 +    },
   3.460 +    {   HOB_TYPE_PAL_FIXED_ADDR,
   3.461 +        &config_pal_fixed_addr,
   3.462 +        sizeof(config_pal_fixed_addr)
   3.463 +    },
   3.464 +    {   HOB_TYPE_PAL_FREQ_BASE,
   3.465 +        &config_pal_freq_base,
   3.466 +        sizeof(config_pal_freq_base)
   3.467 +    },
   3.468 +    {   HOB_TYPE_PAL_FREQ_RATIOS,
   3.469 +        &config_pal_freq_ratios,
   3.470 +        sizeof(config_pal_freq_ratios)
   3.471 +    },
   3.472 +    {   HOB_TYPE_PAL_HALT_INFO,
   3.473 +        &config_pal_halt_info,
   3.474 +        sizeof(config_pal_halt_info)
   3.475 +    },
   3.476 +    {   HOB_TYPE_PAL_PERF_MON_INFO,
   3.477 +        &config_pal_perf_mon_info,
   3.478 +        sizeof(config_pal_perf_mon_info)
   3.479 +    },
   3.480 +    {   HOB_TYPE_PAL_PROC_GET_FEATURES,
   3.481 +        &config_pal_proc_get_features,
   3.482 +        sizeof(config_pal_proc_get_features)
   3.483 +    },
   3.484 +    {   HOB_TYPE_PAL_PTCE_INFO,
   3.485 +        &config_pal_ptce_info,
   3.486 +        sizeof(config_pal_ptce_info)
   3.487 +    },
   3.488 +    {   HOB_TYPE_PAL_REGISTER_INFO,
   3.489 +        &config_pal_register_info,
   3.490 +        sizeof(config_pal_register_info)
   3.491 +    },
   3.492 +    {   HOB_TYPE_PAL_RSE_INFO,
   3.493 +        &config_pal_rse_info,
   3.494 +        sizeof(config_pal_rse_info)
   3.495 +    },
   3.496 +    {   HOB_TYPE_PAL_TEST_INFO,
   3.497 +        &config_pal_test_info,
   3.498 +        sizeof(config_pal_test_info)
   3.499 +    },
   3.500 +    {   HOB_TYPE_PAL_VM_SUMMARY,
   3.501 +        &config_pal_vm_summary,
   3.502 +        sizeof(config_pal_vm_summary)
   3.503 +    },
   3.504 +    {   HOB_TYPE_PAL_VM_INFO,
   3.505 +        &config_pal_vm_info,
   3.506 +        sizeof(config_pal_vm_info)
   3.507 +    },
   3.508 +    {   HOB_TYPE_PAL_VM_PAGE_SIZE,
   3.509 +        &config_pal_vm_page_size,
   3.510 +        sizeof(config_pal_vm_page_size)
   3.511 +    },
   3.512 +};
   3.513 +
   3.514 +static int
   3.515 +add_pal_hob(void* hob_buf)
   3.516 +{
   3.517 +    int i;
   3.518 +    for (i = 0; i < sizeof(hob_batch)/sizeof(hob_batch_t); i++) {
   3.519 +        if (hob_add(hob_buf, hob_batch[i].type, hob_batch[i].data,
   3.520 +                    hob_batch[i].size) < 0)
   3.521 +            return -1;
   3.522 +    }
   3.523 +    return 0;
   3.524 +}
   3.525 +
   3.526 +static int
   3.527 +setup_guest(int xc_handle, uint32_t dom, unsigned long memsize,
   3.528 +            char *image, unsigned long image_size, uint32_t vcpus,
   3.529 +            unsigned int store_evtchn, unsigned long *store_mfn)
   3.530 +{
   3.531 +    unsigned long page_array[2];
   3.532 +    shared_iopage_t *sp;
   3.533 +    int i;
   3.534 +    unsigned long dom_memsize = (memsize << 20);
   3.535 +    DECLARE_DOM0_OP;
   3.536 +
   3.537 +    if ((image_size > 12 * MEM_M) || (image_size & (PAGE_SIZE - 1))) {
   3.538 +        PERROR("Guest firmware size is incorrect [%ld]?", image_size);
   3.539 +        return -1;
   3.540 +    }
   3.541 +
   3.542 +    /* This will creates the physmap.  */
   3.543 +    op.u.domain_setup.flags = XEN_DOMAINSETUP_hvm_guest;
   3.544 +    op.u.domain_setup.domain = (domid_t)dom;
   3.545 +    op.u.domain_setup.bp = 0;
   3.546 +    op.u.domain_setup.maxmem = 0;
   3.547 +    
   3.548 +    op.cmd = DOM0_DOMAIN_SETUP;
   3.549 +    if (xc_dom0_op(xc_handle, &op))
   3.550 +        goto error_out;
   3.551 +
   3.552 +    /* Load guest firmware */
   3.553 +    if (xc_ia64_copy_to_domain_pages(xc_handle, dom, image,
   3.554 +                            (GFW_START + GFW_SIZE - image_size) >> PAGE_SHIFT,
   3.555 +                            image_size >> PAGE_SHIFT)) {
   3.556 +        PERROR("Could not load guest firmware into domain");
   3.557 +        goto error_out;
   3.558 +    }
   3.559 +
   3.560 +    /* Hand-off state passed to guest firmware */
   3.561 +    if (xc_ia64_build_hob(xc_handle, dom, dom_memsize,
   3.562 +                          (unsigned long)vcpus) < 0) {
   3.563 +        PERROR("Could not build hob\n");
   3.564 +        goto error_out;
   3.565 +    }
   3.566 +
   3.567 +    /* Retrieve special pages like io, xenstore, etc. */
   3.568 +    if (xc_ia64_get_pfn_list(xc_handle, dom, page_array,
   3.569 +                             IO_PAGE_START>>PAGE_SHIFT, 2) != 2) {
   3.570 +        PERROR("Could not get the page frame list");
   3.571 +        goto error_out;
   3.572 +    }
   3.573 +
   3.574 +    *store_mfn = page_array[1];
   3.575 +    sp = (shared_iopage_t *)xc_map_foreign_range(xc_handle, dom,
   3.576 +                               PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[0]);
   3.577 +    if (sp == 0)
   3.578 +        goto error_out;
   3.579 +
   3.580 +    memset(sp, 0, PAGE_SIZE);
   3.581 +
   3.582 +    for (i = 0; i < vcpus; i++) {
   3.583 +        uint32_t vp_eport;
   3.584 +
   3.585 +        vp_eport = xc_evtchn_alloc_unbound(xc_handle, dom, 0);
   3.586 +        if (vp_eport < 0) {
   3.587 +            DPRINTF("Couldn't get unbound port from VMX guest.\n");
   3.588 +            goto error_out;
   3.589 +        }
   3.590 +        sp->vcpu_iodata[i].vp_eport = vp_eport;
   3.591 +    }
   3.592 +
   3.593 +    munmap(sp, PAGE_SIZE);
   3.594 +
   3.595 +    return 0;
   3.596 +
   3.597 +error_out:
   3.598 +    return -1;
   3.599 +}
   3.600 +
   3.601 +int
   3.602 +xc_hvm_build(int xc_handle, uint32_t domid, int memsize,
   3.603 +             const char *image_name, unsigned int vcpus, unsigned int pae,
   3.604 +             unsigned int acpi, unsigned int apic, unsigned int store_evtchn,
   3.605 +             unsigned long *store_mfn)
   3.606 +{
   3.607 +    dom0_op_t launch_op, op;
   3.608 +    int rc;
   3.609 +    vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
   3.610 +    char *image = NULL;
   3.611 +    unsigned long image_size;
   3.612 +    unsigned long nr_pages;
   3.613 +
   3.614 +    nr_pages = xc_get_max_pages(xc_handle, domid);
   3.615 +    if (nr_pages < 0) {
   3.616 +        PERROR("Could not find total pages for domain");
   3.617 +        goto error_out;
   3.618 +    }
   3.619 +
   3.620 +    image = xc_read_image(image_name, &image_size);
   3.621 +    if (image == NULL) {
   3.622 +        PERROR("Could not read guest firmware image %s", image_name);
   3.623 +        goto error_out;
   3.624 +    }
   3.625 +
   3.626 +    image_size = (image_size + PAGE_SIZE - 1) & PAGE_MASK;
   3.627 +
   3.628 +    if (mlock(&st_ctxt, sizeof(st_ctxt))) {
   3.629 +        PERROR("Unable to mlock ctxt");
   3.630 +        return 1;
   3.631 +    }
   3.632 +
   3.633 +    op.cmd = DOM0_GETDOMAININFO;
   3.634 +    op.u.getdomaininfo.domain = (domid_t)domid;
   3.635 +    if (do_dom0_op(xc_handle, &op) < 0 ||
   3.636 +        (uint16_t)op.u.getdomaininfo.domain != domid) {
   3.637 +        PERROR("Could not get info on domain");
   3.638 +        goto error_out;
   3.639 +    }
   3.640 +
   3.641 +    memset(ctxt, 0, sizeof(*ctxt));
   3.642 +
   3.643 +    if (setup_guest(xc_handle, domid, (unsigned long)memsize, image,
   3.644 +                    image_size, vcpus, store_evtchn, store_mfn) < 0) {
   3.645 +        ERROR("Error constructing guest OS");
   3.646 +        goto error_out;
   3.647 +    }
   3.648 +
   3.649 +    free(image);
   3.650 +
   3.651 +    ctxt->user_regs.cr_iip = 0x80000000ffffffb0UL;
   3.652 +
   3.653 +    memset(&launch_op, 0, sizeof(launch_op));
   3.654 +
   3.655 +    launch_op.u.setvcpucontext.domain = (domid_t)domid;
   3.656 +    launch_op.u.setvcpucontext.vcpu = 0;
   3.657 +    set_xen_guest_handle(launch_op.u.setvcpucontext.ctxt, ctxt);
   3.658 +
   3.659 +    launch_op.cmd = DOM0_SETVCPUCONTEXT;
   3.660 +    rc = do_dom0_op(xc_handle, &launch_op);
   3.661 +    return rc;
   3.662 +
   3.663 +error_out:
   3.664 +    free(image);
   3.665 +    return -1;
   3.666 +}
   3.667 +
   3.668 +/*
   3.669 + * Local variables:
   3.670 + * mode: C
   3.671 + * c-set-style: "BSD"
   3.672 + * c-basic-offset: 4
   3.673 + * tab-width: 4
   3.674 + * indent-tabs-mode: nil
   3.675 + * End:
   3.676 + */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/libxc/ia64/xc_ia64_stubs.c	Tue Jul 11 11:29:25 2006 -0600
     4.3 @@ -0,0 +1,124 @@
     4.4 +#include "xg_private.h"
     4.5 +#include "xenguest.h"
     4.6 +#include "xc_private.h"
     4.7 +#include "xc_elf.h"
     4.8 +#include <stdlib.h>
     4.9 +#include <zlib.h>
    4.10 +#include "xen/arch-ia64.h"
    4.11 +#include <xen/hvm/ioreq.h>
    4.12 +
    4.13 +/* this is a very ugly way of getting FPSR_DEFAULT.  struct ia64_fpreg is
    4.14 + * mysteriously declared in two places: /usr/include/asm/fpu.h and
    4.15 + * /usr/include/bits/sigcontext.h.  The former also defines FPSR_DEFAULT,
    4.16 + * the latter doesn't but is included (indirectly) by xg_private.h */
    4.17 +#define __ASSEMBLY__
    4.18 +#include <asm/fpu.h>
    4.19 +#undef __IA64_UL
    4.20 +#define __IA64_UL(x)           ((unsigned long)(x))
    4.21 +#undef __ASSEMBLY__
    4.22 +
    4.23 +unsigned long
    4.24 +xc_ia64_fpsr_default(void)
    4.25 +{
    4.26 +    return FPSR_DEFAULT;
    4.27 +}
    4.28 +
    4.29 +int
    4.30 +xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
    4.31 +              uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
    4.32 +              int (*suspend)(int domid))
    4.33 +{
    4.34 +    PERROR("xc_linux_save not implemented\n");
    4.35 +    return -1;
    4.36 +}
    4.37 +
    4.38 +int
    4.39 +xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, unsigned long nr_pfns,
    4.40 +                 unsigned int store_evtchn, unsigned long *store_mfn,
    4.41 +                 unsigned int console_evtchn, unsigned long *console_mfn)
    4.42 +{
    4.43 +    PERROR("xc_linux_restore not implemented\n");
    4.44 +    return -1;
    4.45 +}
    4.46 +
    4.47 +/*  
    4.48 +    VMM uses put_user to copy pfn_list to guest buffer, this maybe fail,
    4.49 +    VMM doesn't handle this now.
    4.50 +    This method will touch guest buffer to make sure the buffer's mapping
    4.51 +    is tracked by VMM,
    4.52 + */
    4.53 +int
    4.54 +xc_ia64_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
    4.55 +                     unsigned int start_page, unsigned int nr_pages)
    4.56 +{
    4.57 +    dom0_op_t op;
    4.58 +    int num_pfns,ret;
    4.59 +    unsigned int __start_page, __nr_pages;
    4.60 +    unsigned long max_pfns;
    4.61 +    xen_pfn_t *__pfn_buf;
    4.62 +
    4.63 +    __start_page = start_page;
    4.64 +    __nr_pages = nr_pages;
    4.65 +    __pfn_buf = pfn_buf;
    4.66 +  
    4.67 +    while (__nr_pages) {
    4.68 +        max_pfns = ((unsigned long)__start_page << 32) | __nr_pages;
    4.69 +        op.cmd = DOM0_GETMEMLIST;
    4.70 +        op.u.getmemlist.domain   = (domid_t)domid;
    4.71 +        op.u.getmemlist.max_pfns = max_pfns;
    4.72 +        op.u.getmemlist.num_pfns = 0;
    4.73 +        set_xen_guest_handle(op.u.getmemlist.buffer, __pfn_buf);
    4.74 +
    4.75 +        if ((max_pfns != -1UL)
    4.76 +            && mlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t)) != 0) {
    4.77 +            PERROR("Could not lock pfn list buffer");
    4.78 +            return -1;
    4.79 +        }
    4.80 +
    4.81 +        ret = do_dom0_op(xc_handle, &op);
    4.82 +
    4.83 +        if (max_pfns != -1UL)
    4.84 +            (void)munlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t));
    4.85 +
    4.86 +        if (max_pfns == -1UL)
    4.87 +            return 0;
    4.88 +        
    4.89 +        num_pfns = op.u.getmemlist.num_pfns;
    4.90 +        __start_page += num_pfns;
    4.91 +        __nr_pages -= num_pfns;
    4.92 +        __pfn_buf += num_pfns;
    4.93 +
    4.94 +        if (ret < 0)
    4.95 +            // dummy write to make sure this tlb mapping is tracked by VMM
    4.96 +            *__pfn_buf = 0;
    4.97 +        else
    4.98 +            return nr_pages;
    4.99 +    }
   4.100 +    return nr_pages;
   4.101 +}
   4.102 +
   4.103 +int
   4.104 +xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
   4.105 +                unsigned long max_pfns)
   4.106 +{
   4.107 +    return xc_ia64_get_pfn_list (xc_handle, domid, pfn_buf, 0, max_pfns);
   4.108 +}
   4.109 +
   4.110 +long
   4.111 +xc_get_max_pages(int xc_handle, uint32_t domid)
   4.112 +{
   4.113 +    dom0_op_t op;
   4.114 +    op.cmd = DOM0_GETDOMAININFO;
   4.115 +    op.u.getdomaininfo.domain = (domid_t)domid;
   4.116 +    return (do_dom0_op(xc_handle, &op) < 0) ? -1 : op.u.getdomaininfo.max_pages;
   4.117 +}
   4.118 +
   4.119 +/*
   4.120 + * Local variables:
   4.121 + * mode: C
   4.122 + * c-set-style: "BSD"
   4.123 + * c-basic-offset: 4
   4.124 + * tab-width: 4
   4.125 + * indent-tabs-mode: nil
   4.126 + * End:
   4.127 + */
     5.1 --- a/tools/libxc/xc_ia64_stubs.c	Mon Jul 10 14:14:11 2006 -0600
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,755 +0,0 @@
     5.4 -#include "xg_private.h"
     5.5 -#include "xenguest.h"
     5.6 -#include "xc_private.h"
     5.7 -#include "xc_elf.h"
     5.8 -#include <stdlib.h>
     5.9 -#include <zlib.h>
    5.10 -#include "xen/arch-ia64.h"
    5.11 -#include <xen/hvm/ioreq.h>
    5.12 -
    5.13 -/* this is a very ugly way of getting FPSR_DEFAULT.  struct ia64_fpreg is
    5.14 - * mysteriously declared in two places: /usr/include/asm/fpu.h and
    5.15 - * /usr/include/bits/sigcontext.h.  The former also defines FPSR_DEFAULT,
    5.16 - * the latter doesn't but is included (indirectly) by xg_private.h */
    5.17 -#define __ASSEMBLY__
    5.18 -#include <asm/fpu.h>
    5.19 -#undef __IA64_UL
    5.20 -#define __IA64_UL(x)           ((unsigned long)(x))
    5.21 -#undef __ASSEMBLY__
    5.22 -
    5.23 -unsigned long xc_ia64_fpsr_default(void)
    5.24 -{
    5.25 -        return FPSR_DEFAULT;
    5.26 -}
    5.27 -
    5.28 -int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
    5.29 -                  uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
    5.30 -                  int (*suspend)(int domid))
    5.31 -{
    5.32 -    PERROR("xc_linux_save not implemented\n");
    5.33 -    return -1;
    5.34 -}
    5.35 -
    5.36 -int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, unsigned long nr_pfns,
    5.37 -                     unsigned int store_evtchn, unsigned long *store_mfn,
    5.38 -                     unsigned int console_evtchn, unsigned long *console_mfn)
    5.39 -{
    5.40 -    PERROR("xc_linux_restore not implemented\n");
    5.41 -    return -1;
    5.42 -}
    5.43 -
    5.44 -/*  
    5.45 -    VMM uses put_user to copy pfn_list to guest buffer, this maybe fail,
    5.46 -    VMM doesn't handle this now.
    5.47 -    This method will touch guest buffer to make sure the buffer's mapping
    5.48 -    is tracked by VMM,
    5.49 - */
    5.50 -int xc_ia64_get_pfn_list(int xc_handle,
    5.51 -                         uint32_t domid,
    5.52 -                         xen_pfn_t *pfn_buf,
    5.53 -                         unsigned int start_page,
    5.54 -                         unsigned int nr_pages)
    5.55 -{
    5.56 -    dom0_op_t op;
    5.57 -    int num_pfns,ret;
    5.58 -    unsigned int __start_page, __nr_pages;
    5.59 -    unsigned long max_pfns;
    5.60 -    xen_pfn_t *__pfn_buf;
    5.61 -
    5.62 -    __start_page = start_page;
    5.63 -    __nr_pages = nr_pages;
    5.64 -    __pfn_buf = pfn_buf;
    5.65 -  
    5.66 -    while(__nr_pages){
    5.67 -        max_pfns = ((unsigned long)__start_page << 32) | __nr_pages;
    5.68 -        op.cmd = DOM0_GETMEMLIST;
    5.69 -        op.u.getmemlist.domain   = (domid_t)domid;
    5.70 -        op.u.getmemlist.max_pfns = max_pfns;
    5.71 -        op.u.getmemlist.num_pfns = 0;
    5.72 -        set_xen_guest_handle(op.u.getmemlist.buffer, __pfn_buf);
    5.73 -
    5.74 -        if ( (max_pfns != -1UL)
    5.75 -            && mlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t)) != 0 )
    5.76 -        {
    5.77 -            PERROR("Could not lock pfn list buffer");
    5.78 -            return -1;
    5.79 -        }
    5.80 -
    5.81 -        ret = do_dom0_op(xc_handle, &op);
    5.82 -
    5.83 -        if (max_pfns != -1UL)
    5.84 -            (void)munlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t));
    5.85 -
    5.86 -        if (max_pfns == -1UL)
    5.87 -            return 0;
    5.88 -        
    5.89 -        num_pfns = op.u.getmemlist.num_pfns;
    5.90 -        __start_page += num_pfns;
    5.91 -        __nr_pages -= num_pfns;
    5.92 -        __pfn_buf += num_pfns;
    5.93 -
    5.94 -        if (ret < 0)
    5.95 -            // dummy write to make sure this tlb mapping is tracked by VMM
    5.96 -            *__pfn_buf = 0;
    5.97 -        else
    5.98 -            return nr_pages;
    5.99 -    }
   5.100 -    return nr_pages;
   5.101 -}
   5.102 -
   5.103 -long xc_get_max_pages(int xc_handle, uint32_t domid)
   5.104 -{
   5.105 -    dom0_op_t op;
   5.106 -    op.cmd = DOM0_GETDOMAININFO;
   5.107 -    op.u.getdomaininfo.domain = (domid_t)domid;
   5.108 -    return (do_dom0_op(xc_handle, &op) < 0) ?
   5.109 -        -1 : op.u.getdomaininfo.max_pages;
   5.110 -}
   5.111 -
   5.112 -int xc_ia64_copy_to_domain_pages(int xc_handle, uint32_t domid,
   5.113 -        void* src_page, unsigned long dst_pfn, int nr_pages)
   5.114 -{
   5.115 -    // N.B. gva should be page aligned
   5.116 -
   5.117 -    xen_pfn_t *page_array = NULL;
   5.118 -    int i;
   5.119 -
   5.120 -    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL ){
   5.121 -        PERROR("Could not allocate memory");
   5.122 -        goto error_out;
   5.123 -    }
   5.124 -    if ( xc_ia64_get_pfn_list(xc_handle, domid, page_array,
   5.125 -                dst_pfn, nr_pages) != nr_pages ){
   5.126 -        PERROR("Could not get the page frame list");
   5.127 -        goto error_out;
   5.128 -    }
   5.129 -
   5.130 -    for ( i=0; i< nr_pages; i++ ){
   5.131 -        if (xc_copy_to_domain_page(xc_handle, domid, page_array[i],
   5.132 -                    src_page + (i << PAGE_SHIFT)))
   5.133 -            goto error_out;
   5.134 -    }
   5.135 -    free(page_array);
   5.136 -    return 0;
   5.137 -
   5.138 -error_out:
   5.139 -    free(page_array);
   5.140 -    return -1;
   5.141 -}
   5.142 -
   5.143 -
   5.144 -#define HOB_SIGNATURE         0x3436474953424f48        // "HOBSIG64"
   5.145 -#define GFW_HOB_START         ((4UL<<30)-(14UL<<20))    // 4G - 14M
   5.146 -#define GFW_HOB_SIZE          (1UL<<20)                 // 1M
   5.147 -
   5.148 -typedef struct {
   5.149 -    unsigned long signature;
   5.150 -    unsigned int  type;
   5.151 -    unsigned int  length;
   5.152 -} HOB_GENERIC_HEADER;
   5.153 -
   5.154 -/*
   5.155 - * INFO HOB is the first data data in one HOB list
   5.156 - * it contains the control information of the HOB list
   5.157 - */
   5.158 -typedef struct {
   5.159 -    HOB_GENERIC_HEADER  header;
   5.160 -    unsigned long       length;    // current length of hob
   5.161 -    unsigned long       cur_pos;   // current poisiton of hob
   5.162 -    unsigned long       buf_size;  // size of hob buffer
   5.163 -}HOB_INFO;
   5.164 -
   5.165 -typedef struct{
   5.166 -    unsigned long start;
   5.167 -    unsigned long size;
   5.168 -}hob_mem_t;
   5.169 -
   5.170 -typedef enum {
   5.171 -    HOB_TYPE_INFO=0,
   5.172 -    HOB_TYPE_TERMINAL,
   5.173 -    HOB_TYPE_MEM,
   5.174 -    HOB_TYPE_PAL_BUS_GET_FEATURES_DATA,
   5.175 -    HOB_TYPE_PAL_CACHE_SUMMARY,
   5.176 -    HOB_TYPE_PAL_MEM_ATTRIB,
   5.177 -    HOB_TYPE_PAL_CACHE_INFO,
   5.178 -    HOB_TYPE_PAL_CACHE_PROT_INFO,
   5.179 -    HOB_TYPE_PAL_DEBUG_INFO,
   5.180 -    HOB_TYPE_PAL_FIXED_ADDR,
   5.181 -    HOB_TYPE_PAL_FREQ_BASE,
   5.182 -    HOB_TYPE_PAL_FREQ_RATIOS,
   5.183 -    HOB_TYPE_PAL_HALT_INFO,
   5.184 -    HOB_TYPE_PAL_PERF_MON_INFO,
   5.185 -    HOB_TYPE_PAL_PROC_GET_FEATURES,
   5.186 -    HOB_TYPE_PAL_PTCE_INFO,
   5.187 -    HOB_TYPE_PAL_REGISTER_INFO,
   5.188 -    HOB_TYPE_PAL_RSE_INFO,
   5.189 -    HOB_TYPE_PAL_TEST_INFO,
   5.190 -    HOB_TYPE_PAL_VM_SUMMARY,
   5.191 -    HOB_TYPE_PAL_VM_INFO,
   5.192 -    HOB_TYPE_PAL_VM_PAGE_SIZE,
   5.193 -    HOB_TYPE_NR_VCPU,
   5.194 -    HOB_TYPE_MAX
   5.195 -}hob_type_t;
   5.196 -
   5.197 -static int hob_init( void  *buffer ,unsigned long buf_size);
   5.198 -static int add_pal_hob(void* hob_buf);
   5.199 -static int add_mem_hob(void* hob_buf, unsigned long dom_mem_size);
   5.200 -static int add_vcpus_hob(void* hob_buf, unsigned long nr_vcpu);
   5.201 -static int build_hob (void* hob_buf, unsigned long hob_buf_size,
   5.202 -                  unsigned long dom_mem_size, unsigned long vcpus);
   5.203 -static int load_hob(int xc_handle,uint32_t dom, void *hob_buf,
   5.204 -		unsigned long dom_mem_size);
   5.205 -
   5.206 -int xc_ia64_build_hob(int xc_handle, uint32_t dom, unsigned long memsize, 
   5.207 -                      unsigned long vcpus){
   5.208 -
   5.209 -    char   *hob_buf;
   5.210 -
   5.211 -    hob_buf = malloc (GFW_HOB_SIZE);
   5.212 -    if (hob_buf == NULL) {
   5.213 -        PERROR("Could not allocate hob");
   5.214 -        return -1;
   5.215 -    }
   5.216 -
   5.217 -    if ( build_hob( hob_buf, GFW_HOB_SIZE, memsize, vcpus) < 0){
   5.218 -        free (hob_buf);
   5.219 -        PERROR("Could not build hob");
   5.220 -        return -1;
   5.221 -    }
   5.222 -
   5.223 -    if ( load_hob( xc_handle, dom, hob_buf, memsize) < 0){
   5.224 -        free (hob_buf);
   5.225 -        PERROR("Could not load hob");
   5.226 -       return -1;
   5.227 -    }
   5.228 -    free (hob_buf);
   5.229 -    return 0;
   5.230 -
   5.231 -}
   5.232 -static int
   5.233 -hob_init( void  *buffer ,unsigned long buf_size)
   5.234 -{
   5.235 -    HOB_INFO *phit;
   5.236 -    HOB_GENERIC_HEADER     *terminal;
   5.237 -
   5.238 -    if (sizeof(HOB_INFO) + sizeof(HOB_GENERIC_HEADER) > buf_size){
   5.239 -        // buffer too small
   5.240 -        return -1;
   5.241 -    }
   5.242 -
   5.243 -    phit = (HOB_INFO*)buffer;
   5.244 -    phit->header.signature = HOB_SIGNATURE;
   5.245 -    phit->header.type = HOB_TYPE_INFO;
   5.246 -    phit->header.length = sizeof(HOB_INFO);
   5.247 -    phit->length = sizeof(HOB_INFO) + sizeof(HOB_GENERIC_HEADER);
   5.248 -    phit->cur_pos = 0;
   5.249 -    phit->buf_size = buf_size;
   5.250 -
   5.251 -    terminal = (HOB_GENERIC_HEADER*) (buffer + sizeof(HOB_INFO));
   5.252 -    terminal->signature= HOB_SIGNATURE;
   5.253 -    terminal->type = HOB_TYPE_TERMINAL;
   5.254 -    terminal->length = sizeof(HOB_GENERIC_HEADER);
   5.255 -
   5.256 -    return 0;
   5.257 -}
   5.258 -
   5.259 -/*
   5.260 - *  Add a new HOB to the HOB List.
   5.261 - *
   5.262 - *  hob_start  -  start address of hob buffer
   5.263 - *  type       -  type of the hob to be added
   5.264 - *  data       -  data of the hob to be added
   5.265 - *  data_size  -  size of the data
   5.266 - */
   5.267 -static int
   5.268 -hob_add(
   5.269 -     void*  hob_start,
   5.270 -     int    type,
   5.271 -     void*  data,
   5.272 -     int    data_size
   5.273 -)
   5.274 -{
   5.275 -    HOB_INFO *phit;
   5.276 -    HOB_GENERIC_HEADER     *newhob,*tail;
   5.277 -
   5.278 -    phit = (HOB_INFO*)hob_start;
   5.279 -
   5.280 -    if (phit->length + data_size > phit->buf_size){
   5.281 -        // no space for new hob
   5.282 -        return -1;
   5.283 -    }
   5.284 -
   5.285 -    //append new HOB
   5.286 -    newhob = (HOB_GENERIC_HEADER*)
   5.287 -        (hob_start + phit->length - sizeof(HOB_GENERIC_HEADER));
   5.288 -    newhob->signature = HOB_SIGNATURE;
   5.289 -    newhob->type = type;
   5.290 -    newhob->length = data_size + sizeof(HOB_GENERIC_HEADER);
   5.291 -    memcpy((void*)newhob + sizeof(HOB_GENERIC_HEADER), data, data_size);
   5.292 -
   5.293 -    // append terminal HOB
   5.294 -    tail = (HOB_GENERIC_HEADER*) ( hob_start + phit->length + data_size);
   5.295 -    tail->signature = HOB_SIGNATURE;
   5.296 -    tail->type = HOB_TYPE_TERMINAL;
   5.297 -    tail->length = sizeof(HOB_GENERIC_HEADER);
   5.298 -
   5.299 -    // adjust HOB list length
   5.300 -    phit->length += sizeof(HOB_GENERIC_HEADER)+ data_size;
   5.301 -
   5.302 -    return 0;
   5.303 -
   5.304 -}
   5.305 -
   5.306 -int get_hob_size(void* hob_buf){
   5.307 -
   5.308 -    HOB_INFO *phit = (HOB_INFO*)hob_buf;
   5.309 -
   5.310 -    if (phit->header.signature != HOB_SIGNATURE){
   5.311 -        PERROR("xc_get_hob_size:Incorrect signature");
   5.312 -        return -1;
   5.313 -    }
   5.314 -    return phit->length;
   5.315 -}
   5.316 -
   5.317 -int build_hob (void* hob_buf, unsigned long hob_buf_size,
   5.318 -                  unsigned long dom_mem_size, unsigned long vcpus)
   5.319 -{
   5.320 -    //Init HOB List
   5.321 -    if (hob_init (hob_buf, hob_buf_size)<0){
   5.322 -        PERROR("buffer too small");
   5.323 -        goto err_out;
   5.324 -    }
   5.325 -
   5.326 -    if ( add_mem_hob( hob_buf,dom_mem_size) < 0){
   5.327 -        PERROR("Add memory hob failed, buffer too small");
   5.328 -        goto err_out;
   5.329 -    }
   5.330 -
   5.331 -    if ( add_vcpus_hob(hob_buf, vcpus)<0){
   5.332 -        PERROR("Add NR_VCPU hob failed, buffer too small");
   5.333 -        goto err_out;
   5.334 -    }
   5.335 -
   5.336 -    if ( add_pal_hob( hob_buf ) < 0 ){
   5.337 -        PERROR("Add PAL hob failed, buffer too small");
   5.338 -        goto err_out;
   5.339 -    }
   5.340 -
   5.341 -    return 0;
   5.342 -
   5.343 -err_out:
   5.344 -    return -1;
   5.345 -}
   5.346 -
   5.347 -static int
   5.348 -load_hob(int xc_handle, uint32_t dom, void *hob_buf,
   5.349 -         unsigned long dom_mem_size)
   5.350 -{
   5.351 -    // hob_buf should be page aligned
   5.352 -    int hob_size;
   5.353 -    int nr_pages;
   5.354 -
   5.355 -    if ((hob_size = get_hob_size(hob_buf)) < 0){
   5.356 -        PERROR("Invalid hob data");
   5.357 -        return -1;
   5.358 -    }
   5.359 -
   5.360 -    if (hob_size > GFW_HOB_SIZE){
   5.361 -        PERROR("No enough memory for hob data");
   5.362 -        return -1;
   5.363 -    }
   5.364 -
   5.365 -    nr_pages = (hob_size + PAGE_SIZE -1) >> PAGE_SHIFT;
   5.366 -
   5.367 -    return xc_ia64_copy_to_domain_pages(xc_handle, dom,
   5.368 -            hob_buf, GFW_HOB_START>>PAGE_SHIFT, nr_pages );
   5.369 -}
   5.370 -
   5.371 -#define MIN(x, y) ((x) < (y)) ? (x) : (y)
   5.372 -static int
   5.373 -add_mem_hob(void* hob_buf, unsigned long dom_mem_size){
   5.374 -    hob_mem_t memhob;
   5.375 -
   5.376 -    // less than 3G
   5.377 -    memhob.start = 0;
   5.378 -    memhob.size = MIN(dom_mem_size, 0xC0000000);
   5.379 -
   5.380 -    if (hob_add(hob_buf, HOB_TYPE_MEM, &memhob, sizeof(memhob)) < 0){
   5.381 -        return -1;
   5.382 -    }
   5.383 -
   5.384 -    if (dom_mem_size > 0xC0000000) {
   5.385 -        // 4G ~ 4G+remain
   5.386 -        memhob.start = 0x100000000; //4G
   5.387 -        memhob.size = dom_mem_size - 0xC0000000;
   5.388 -        if (hob_add(hob_buf, HOB_TYPE_MEM, &memhob, sizeof(memhob)) < 0)
   5.389 -            return -1;
   5.390 -    }
   5.391 -    return 0;
   5.392 -}
   5.393 -
   5.394 -static int 
   5.395 -add_vcpus_hob(void* hob_buf, unsigned long vcpus)
   5.396 -{
   5.397 -    return hob_add(hob_buf, HOB_TYPE_NR_VCPU, &vcpus, sizeof(vcpus));
   5.398 -}
   5.399 -
   5.400 -unsigned char config_pal_bus_get_features_data[24] = {
   5.401 -    0, 0, 0, 32, 0, 0, 240, 189, 0, 0, 0, 0, 0, 0,
   5.402 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   5.403 -};
   5.404 -unsigned char config_pal_cache_summary[16] = {
   5.405 -    3, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0};
   5.406 -unsigned char config_pal_mem_attrib[8] =    {
   5.407 -    241, 0, 0, 0, 0, 0, 0, 0
   5.408 -};
   5.409 -unsigned char config_pal_cache_info[152] = {
   5.410 -    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.411 -    6, 4, 6, 7, 255, 1, 0, 1, 0, 64, 0, 0, 12, 12,
   5.412 -    49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 0, 1,
   5.413 -    0, 1, 0, 64, 0, 0, 12, 12, 49, 0, 0, 0, 0, 0, 0,
   5.414 -    0, 0, 0, 6, 8, 7, 7, 255, 7, 0, 11, 0, 0, 16, 0,
   5.415 -    12, 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 7,
   5.416 -    7, 7, 5, 9, 11, 0, 0, 4, 0, 12, 15, 49, 0, 254, 255,
   5.417 -    255, 255, 255, 255, 255, 255, 2, 8, 7, 7, 7, 5, 9,
   5.418 -    11, 0, 0, 4, 0, 12, 15, 49, 0, 0, 0, 0, 0, 0, 0, 0,
   5.419 -    0, 3, 12, 7, 7, 7, 14, 1, 3, 0, 0, 192, 0, 12, 20, 49, 0
   5.420 -};
   5.421 -unsigned char config_pal_cache_prot_info[200] = {
   5.422 -    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.423 -    45, 0, 16, 8, 0, 76, 12, 64, 0, 0, 0, 0, 0, 0, 0,
   5.424 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.425 -    8, 0, 16, 4, 0, 76, 44, 68, 0, 0, 0, 0, 0, 0, 0, 0,
   5.426 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32,
   5.427 -    0, 16, 8, 0, 81, 44, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.428 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0,
   5.429 -    112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.430 -    0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255,
   5.431 -    32, 0, 112, 12, 0, 79, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.432 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 160,
   5.433 -    12, 0, 84, 124, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.434 -    0, 0, 0
   5.435 -};
   5.436 -unsigned char config_pal_debug_info[16] = {
   5.437 -    2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0
   5.438 -};
   5.439 -unsigned char config_pal_fixed_addr[8] = {
   5.440 -    0, 0, 0, 0, 0, 0, 0, 0
   5.441 -};
   5.442 -unsigned char config_pal_freq_base[8] = {
   5.443 -    109, 219, 182, 13, 0, 0, 0, 0
   5.444 -};
   5.445 -unsigned char config_pal_freq_ratios[24] = {
   5.446 -    11, 1, 0, 0, 77, 7, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 4,
   5.447 -    0, 0, 0, 7, 0, 0, 0
   5.448 -};
   5.449 -unsigned char config_pal_halt_info[64] = {
   5.450 -    0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0,
   5.451 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.452 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.453 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   5.454 -};
   5.455 -unsigned char config_pal_perf_mon_info[136] = {
   5.456 -    12, 47, 18, 8, 0, 0, 0, 0, 241, 255, 0, 0, 255, 7, 0, 0,
   5.457 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.458 -    0, 0, 0, 0, 0, 0, 0, 0, 241, 255, 0, 0, 223, 0, 255, 255,
   5.459 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.460 -    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0,
   5.461 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.462 -    0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 0, 0, 0, 0, 0, 0,
   5.463 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.464 -    0, 0, 0, 0, 0, 0, 0, 0
   5.465 -};
   5.466 -unsigned char config_pal_proc_get_features[104] = {
   5.467 -    3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.468 -    0, 0, 0, 0, 64, 6, 64, 49, 0, 0, 0, 0, 64, 6, 0, 0,
   5.469 -    0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0,
   5.470 -    231, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, 0, 0, 0,
   5.471 -    0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0,
   5.472 -    63, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0,
   5.473 -    0, 0, 0, 0, 0, 0, 0, 0
   5.474 -};
   5.475 -unsigned char config_pal_ptce_info[24] = {
   5.476 -    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
   5.477 -    0, 0, 0, 0, 0, 0, 0, 0
   5.478 -};
   5.479 -unsigned char config_pal_register_info[64] = {
   5.480 -    255, 0, 47, 127, 17, 17, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0,
   5.481 -    255, 208, 128, 238, 238, 0, 0, 248, 255, 255, 255, 255, 255, 0, 0, 7, 3,
   5.482 -    251, 3, 0, 0, 0, 0, 255, 7, 3, 0, 0, 0, 0, 0, 248, 252, 4,
   5.483 -    252, 255, 255, 255, 255, 2, 248, 252, 255, 255, 255, 255, 255
   5.484 -};
   5.485 -unsigned char config_pal_rse_info[16] = {
   5.486 -    96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   5.487 -};
   5.488 -unsigned char config_pal_test_info[48] = {
   5.489 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.490 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.491 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   5.492 -};
   5.493 -unsigned char config_pal_vm_summary[16] = {
   5.494 -    101, 18, 15, 2, 7, 7, 4, 2, 59, 18, 0, 0, 0, 0, 0, 0
   5.495 -};
   5.496 -unsigned char config_pal_vm_info[104] = {
   5.497 -    2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   5.498 -    32, 32, 0, 0, 0, 0, 0, 0, 112, 85, 21, 0, 0, 0, 0, 0, 0,
   5.499 -    0, 0, 0, 0, 0, 0, 1, 32, 32, 0, 0, 0, 0, 0, 0, 112, 85,
   5.500 -    21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 128, 128, 0,
   5.501 -    4, 0, 0, 0, 0, 112, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   5.502 -    0, 0, 0, 1, 128, 128, 0, 4, 0, 0, 0, 0, 112, 85, 0, 0, 0, 0, 0
   5.503 -};
   5.504 -unsigned char config_pal_vm_page_size[16] = {
   5.505 -    0, 112, 85, 21, 0, 0, 0, 0, 0, 112, 85, 21, 0, 0, 0, 0
   5.506 -};
   5.507 -
   5.508 -typedef struct{
   5.509 -    hob_type_t type;
   5.510 -    void* data;
   5.511 -    unsigned long size;
   5.512 -}hob_batch_t;
   5.513 -
   5.514 -hob_batch_t hob_batch[]={
   5.515 -    {  HOB_TYPE_PAL_BUS_GET_FEATURES_DATA,
   5.516 -        &config_pal_bus_get_features_data,
   5.517 -        sizeof(config_pal_bus_get_features_data)
   5.518 -    },
   5.519 -    {  HOB_TYPE_PAL_CACHE_SUMMARY,
   5.520 -        &config_pal_cache_summary,
   5.521 -        sizeof(config_pal_cache_summary)
   5.522 -    },
   5.523 -    {  HOB_TYPE_PAL_MEM_ATTRIB,
   5.524 -        &config_pal_mem_attrib,
   5.525 -        sizeof(config_pal_mem_attrib)
   5.526 -    },
   5.527 -    {  HOB_TYPE_PAL_CACHE_INFO,
   5.528 -        &config_pal_cache_info,
   5.529 -        sizeof(config_pal_cache_info)
   5.530 -    },
   5.531 -    {  HOB_TYPE_PAL_CACHE_PROT_INFO,
   5.532 -        &config_pal_cache_prot_info,
   5.533 -        sizeof(config_pal_cache_prot_info)
   5.534 -    },
   5.535 -    {  HOB_TYPE_PAL_DEBUG_INFO,
   5.536 -        &config_pal_debug_info,
   5.537 -        sizeof(config_pal_debug_info)
   5.538 -    },
   5.539 -    {  HOB_TYPE_PAL_FIXED_ADDR,
   5.540 -        &config_pal_fixed_addr,
   5.541 -        sizeof(config_pal_fixed_addr)
   5.542 -    },
   5.543 -    {  HOB_TYPE_PAL_FREQ_BASE,
   5.544 -        &config_pal_freq_base,
   5.545 -        sizeof(config_pal_freq_base)
   5.546 -    },
   5.547 -    {  HOB_TYPE_PAL_FREQ_RATIOS,
   5.548 -        &config_pal_freq_ratios,
   5.549 -        sizeof(config_pal_freq_ratios)
   5.550 -    },
   5.551 -    {  HOB_TYPE_PAL_HALT_INFO,
   5.552 -        &config_pal_halt_info,
   5.553 -        sizeof(config_pal_halt_info)
   5.554 -    },
   5.555 -    {  HOB_TYPE_PAL_PERF_MON_INFO,
   5.556 -        &config_pal_perf_mon_info,
   5.557 -        sizeof(config_pal_perf_mon_info)
   5.558 -    },
   5.559 -    {  HOB_TYPE_PAL_PROC_GET_FEATURES,
   5.560 -        &config_pal_proc_get_features,
   5.561 -        sizeof(config_pal_proc_get_features)
   5.562 -    },
   5.563 -    {  HOB_TYPE_PAL_PTCE_INFO,
   5.564 -        &config_pal_ptce_info,
   5.565 -        sizeof(config_pal_ptce_info)
   5.566 -    },
   5.567 -    {  HOB_TYPE_PAL_REGISTER_INFO,
   5.568 -        &config_pal_register_info,
   5.569 -        sizeof(config_pal_register_info)
   5.570 -    },
   5.571 -    {  HOB_TYPE_PAL_RSE_INFO,
   5.572 -        &config_pal_rse_info,
   5.573 -        sizeof(config_pal_rse_info)
   5.574 -    },
   5.575 -    {  HOB_TYPE_PAL_TEST_INFO,
   5.576 -        &config_pal_test_info,
   5.577 -        sizeof(config_pal_test_info)
   5.578 -    },
   5.579 -    {  HOB_TYPE_PAL_VM_SUMMARY,
   5.580 -        &config_pal_vm_summary,
   5.581 -        sizeof(config_pal_vm_summary)
   5.582 -    },
   5.583 -    {  HOB_TYPE_PAL_VM_INFO,
   5.584 -        &config_pal_vm_info,
   5.585 -        sizeof(config_pal_vm_info)
   5.586 -    },
   5.587 -    {  HOB_TYPE_PAL_VM_PAGE_SIZE,
   5.588 -        &config_pal_vm_page_size,
   5.589 -        sizeof(config_pal_vm_page_size)
   5.590 -    },
   5.591 -};
   5.592 -
   5.593 -static int add_pal_hob(void* hob_buf){
   5.594 -    int i;
   5.595 -    for (i=0; i<sizeof(hob_batch)/sizeof(hob_batch_t); i++){
   5.596 -        if (hob_add(hob_buf, hob_batch[i].type,
   5.597 -                    hob_batch[i].data,
   5.598 -                    hob_batch[i].size)<0)
   5.599 -            return -1;
   5.600 -    }
   5.601 -    return 0;
   5.602 -}
   5.603 -
   5.604 -static int setup_guest(  int xc_handle,
   5.605 -                         uint32_t dom, unsigned long memsize,
   5.606 -                         char *image, unsigned long image_size,
   5.607 -                         uint32_t vcpus,
   5.608 -                         unsigned int store_evtchn,
   5.609 -                         unsigned long *store_mfn)
   5.610 -{
   5.611 -    unsigned long page_array[2];
   5.612 -    shared_iopage_t *sp;
   5.613 -    int i;
   5.614 -    unsigned long dom_memsize = (memsize << 20);
   5.615 -    DECLARE_DOM0_OP;
   5.616 -
   5.617 -    if ((image_size > 12 * MEM_M) || (image_size & (PAGE_SIZE - 1))) {
   5.618 -        PERROR("Guest firmware size is incorrect [%ld]?", image_size);
   5.619 -        return -1;
   5.620 -    }
   5.621 -
   5.622 -    /* This will creates the physmap.  */
   5.623 -    op.u.domain_setup.flags = XEN_DOMAINSETUP_hvm_guest;
   5.624 -    op.u.domain_setup.domain = (domid_t)dom;
   5.625 -    op.u.domain_setup.bp = 0;
   5.626 -    op.u.domain_setup.maxmem = 0;
   5.627 -    
   5.628 -    op.cmd = DOM0_DOMAIN_SETUP;
   5.629 -    if ( xc_dom0_op(xc_handle, &op) )
   5.630 -        goto error_out;
   5.631 -
   5.632 -    /* Load guest firmware */
   5.633 -    if( xc_ia64_copy_to_domain_pages(xc_handle, dom, image,
   5.634 -        (GFW_START+GFW_SIZE-image_size)>>PAGE_SHIFT, image_size>>PAGE_SHIFT)) {
   5.635 -        PERROR("Could not load guest firmware into domain");
   5.636 -        goto error_out;
   5.637 -    }
   5.638 -
   5.639 -    /* Hand-off state passed to guest firmware */
   5.640 -    if (xc_ia64_build_hob(xc_handle, dom, dom_memsize, (unsigned long)vcpus) < 0){
   5.641 -        PERROR("Could not build hob\n");
   5.642 -       goto error_out;
   5.643 -    }
   5.644 -
   5.645 -    /* Retrieve special pages like io, xenstore, etc. */
   5.646 -    if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array,
   5.647 -                              IO_PAGE_START>>PAGE_SHIFT, 2) != 2 )
   5.648 -    {
   5.649 -        PERROR("Could not get the page frame list");
   5.650 -        goto error_out;
   5.651 -    }
   5.652 -
   5.653 -    *store_mfn = page_array[1];
   5.654 -    if ((sp = (shared_iopage_t *) xc_map_foreign_range(
   5.655 -                    xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   5.656 -                    page_array[0])) == 0)
   5.657 -        goto error_out;
   5.658 -    memset(sp, 0, PAGE_SIZE);
   5.659 -
   5.660 -    for (i = 0; i < vcpus; i++) {
   5.661 -        uint32_t vp_eport;
   5.662 -
   5.663 -        vp_eport = xc_evtchn_alloc_unbound(xc_handle, dom, 0);
   5.664 -        if (vp_eport < 0) {
   5.665 -            DPRINTF("Couldn't get unbound port from VMX guest.\n");
   5.666 -            goto error_out;
   5.667 -        }
   5.668 -        sp->vcpu_iodata[i].vp_eport = vp_eport;
   5.669 -    }
   5.670 -
   5.671 -    munmap(sp, PAGE_SIZE);
   5.672 -
   5.673 -    return 0;
   5.674 -
   5.675 - error_out:
   5.676 -    return -1;
   5.677 -}
   5.678 -
   5.679 -int xc_hvm_build(int xc_handle,
   5.680 -                 uint32_t domid,
   5.681 -                 int memsize,
   5.682 -                 const char *image_name,
   5.683 -                 unsigned int vcpus,
   5.684 -                 unsigned int pae,
   5.685 -                 unsigned int acpi,
   5.686 -                 unsigned int apic,
   5.687 -                 unsigned int store_evtchn,
   5.688 -                 unsigned long *store_mfn)
   5.689 -{
   5.690 -    dom0_op_t launch_op, op;
   5.691 -    int rc ;
   5.692 -    vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
   5.693 -    char         *image = NULL;
   5.694 -    unsigned long image_size;
   5.695 -    unsigned long nr_pages;
   5.696 -
   5.697 -    if ( (nr_pages = xc_get_max_pages(xc_handle, domid)) < 0 )
   5.698 -    {
   5.699 -        PERROR("Could not find total pages for domain");
   5.700 -        goto error_out;
   5.701 -    }
   5.702 -
   5.703 -    if ( (image = xc_read_image(image_name, &image_size)) == NULL ){
   5.704 -        PERROR("Could not read guest firmware image %s",image_name);
   5.705 -        goto error_out;
   5.706 -    }
   5.707 -
   5.708 -    image_size = (image_size + PAGE_SIZE - 1) & PAGE_MASK;
   5.709 -
   5.710 -    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) ){
   5.711 -        PERROR("Unable to mlock ctxt");
   5.712 -        return 1;
   5.713 -    }
   5.714 -
   5.715 -    op.cmd = DOM0_GETDOMAININFO;
   5.716 -    op.u.getdomaininfo.domain = (domid_t)domid;
   5.717 -    if ( (do_dom0_op(xc_handle, &op) < 0) ||
   5.718 -         ((uint16_t)op.u.getdomaininfo.domain != domid) ) {
   5.719 -        PERROR("Could not get info on domain");
   5.720 -        goto error_out;
   5.721 -    }
   5.722 -
   5.723 -    memset(ctxt, 0, sizeof(*ctxt));
   5.724 -
   5.725 -    if ( setup_guest(xc_handle, domid, (unsigned long)memsize, image,
   5.726 -                     image_size, vcpus, store_evtchn, store_mfn ) < 0 ){
   5.727 -        ERROR("Error constructing guest OS");
   5.728 -        goto error_out;
   5.729 -    }
   5.730 -
   5.731 -    free(image);
   5.732 -
   5.733 -    ctxt->user_regs.cr_iip = 0x80000000ffffffb0UL;
   5.734 -
   5.735 -    memset( &launch_op, 0, sizeof(launch_op) );
   5.736 -
   5.737 -    launch_op.u.setvcpucontext.domain = (domid_t)domid;
   5.738 -    launch_op.u.setvcpucontext.vcpu   = 0;
   5.739 -    set_xen_guest_handle(launch_op.u.setvcpucontext.ctxt, ctxt);
   5.740 -
   5.741 -    launch_op.cmd = DOM0_SETVCPUCONTEXT;
   5.742 -    rc = do_dom0_op(xc_handle, &launch_op);
   5.743 -    return rc;
   5.744 -
   5.745 - error_out:
   5.746 -    free(image);
   5.747 -    return -1;
   5.748 -}
   5.749 -
   5.750 -/*
   5.751 - * Local variables:
   5.752 - * mode: C
   5.753 - * c-set-style: "BSD"
   5.754 - * c-basic-offset: 4
   5.755 - * tab-width: 4
   5.756 - * indent-tabs-mode: nil
   5.757 - * End:
   5.758 - */
     6.1 --- a/tools/libxc/xc_private.c	Mon Jul 10 14:14:11 2006 -0600
     6.2 +++ b/tools/libxc/xc_private.c	Tue Jul 11 11:29:25 2006 -0600
     6.3 @@ -262,6 +262,7 @@ long long xc_domain_get_cpu_usage( int x
     6.4  }
     6.5  
     6.6  
     6.7 +#ifndef __ia64__
     6.8  int xc_get_pfn_list(int xc_handle,
     6.9                      uint32_t domid,
    6.10                      xen_pfn_t *pfn_buf,
    6.11 @@ -305,6 +306,7 @@ int xc_get_pfn_list(int xc_handle,
    6.12  
    6.13      return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
    6.14  }
    6.15 +#endif
    6.16  
    6.17  long xc_get_tot_pages(int xc_handle, uint32_t domid)
    6.18  {
     7.1 --- a/tools/libxc/xenctrl.h	Mon Jul 10 14:14:11 2006 -0600
     7.2 +++ b/tools/libxc/xenctrl.h	Tue Jul 11 11:29:25 2006 -0600
     7.3 @@ -519,9 +519,6 @@ int xc_copy_to_domain_page(int xc_handle
     7.4  int xc_clear_domain_page(int xc_handle, uint32_t domid,
     7.5                           unsigned long dst_pfn);
     7.6  
     7.7 -int xc_ia64_copy_to_domain_pages(int xc_handle, uint32_t domid,
     7.8 -        void* src_page, unsigned long dst_pfn, int nr_pages);
     7.9 -
    7.10  long xc_get_max_pages(int xc_handle, uint32_t domid);
    7.11  
    7.12  int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,