direct-io.hg

changeset 11348:6bf652c677c8

[IA64] separate hypercalls, acpi and EFI tables

Put hypercalls, acpi and EFI tables on three separate 4KB pages.
This was a stopper to use 4KB pages.
Comments added and simplifications.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Mon Aug 28 16:09:28 2006 -0600 (2006-08-28)
parents f74c9368f6ff
children 896fcdd49c7f
files xen/arch/ia64/linux-xen/efi.c xen/arch/ia64/xen/dom_fw.c xen/arch/ia64/xen/hypercall.c xen/include/asm-ia64/dom_fw.h xen/include/asm-ia64/domain.h xen/include/asm-ia64/linux-xen/linux/efi.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/efi.c	Mon Aug 28 14:09:31 2006 -0600
     1.2 +++ b/xen/arch/ia64/linux-xen/efi.c	Mon Aug 28 16:09:28 2006 -0600
     1.3 @@ -292,28 +292,6 @@ efi_memmap_walk_uc (efi_freemem_callback
     1.4  	walk(callback, arg, EFI_MEMORY_UC);
     1.5  }
     1.6  
     1.7 -#ifdef XEN
     1.8 -void
     1.9 -efi_memmap_walk_type(u32 type, efi_walk_type_callback_t callback, void *arg)
    1.10 -{
    1.11 -	void *efi_map_start, *efi_map_end, *p;
    1.12 -	efi_memory_desc_t *md;
    1.13 -	u64 efi_desc_size;
    1.14 -
    1.15 -	efi_map_start = __va(ia64_boot_param->efi_memmap);
    1.16 -	efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
    1.17 -	efi_desc_size = ia64_boot_param->efi_memdesc_size;
    1.18 -
    1.19 -	for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
    1.20 -		md = p;
    1.21 -		if (md->type == type) {
    1.22 -			if ((*callback)(md, arg) < 0)
    1.23 -				return;
    1.24 -		}
    1.25 -	}
    1.26 -}
    1.27 -#endif
    1.28 -
    1.29  /*
    1.30   * Look for the PAL_CODE region reported by EFI and maps it using an
    1.31   * ITR to enable safe PAL calls in virtual mode.  See IA-64 Processor
     2.1 --- a/xen/arch/ia64/xen/dom_fw.c	Mon Aug 28 14:09:31 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Mon Aug 28 16:09:28 2006 -0600
     2.3 @@ -30,13 +30,6 @@
     2.4  
     2.5  extern unsigned long running_on_sim;
     2.6  
     2.7 -/* Base of FW tables.  */
     2.8 -static const unsigned long dom_fw_base_mpa = FW_HYPERCALL_END_PADDR;
     2.9 -static unsigned long dom_fw_end_mpa;
    2.10 -
    2.11 -/* Note: two domains cannot be created simulteanously!  */
    2.12 -static unsigned long imva_fw_base = -1;
    2.13 -
    2.14  #define FW_VENDOR "X\0e\0n\0/\0i\0a\0\066\0\064\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
    2.15  
    2.16  #define MAKE_MD(typ, attr, start, end) 					\
    2.17 @@ -53,29 +46,15 @@ static unsigned long imva_fw_base = -1;
    2.18  #define EFI_HYPERCALL_PATCH(tgt, call)					\
    2.19  	do {								\
    2.20  		dom_efi_hypercall_patch(d, FW_HYPERCALL_##call##_PADDR,	\
    2.21 -		                        FW_HYPERCALL_##call);		\
    2.22 -		tables->efi_runtime.tgt = dom_pa((unsigned long) pfn);  \
    2.23 -		*pfn++ = FW_HYPERCALL_##call##_PADDR;			\
    2.24 -		*pfn++ = 0;						\
    2.25 +		                 FW_HYPERCALL_##call, hypercalls_imva);	\
    2.26 +		/* Descriptor address.  */                              \
    2.27 +		tables->efi_runtime.tgt =                               \
    2.28 +		                    FW_FIELD_MPA(func_ptrs) + 8 * pfn;  \
    2.29 +		/* Descriptor.  */                                      \
    2.30 +		tables->func_ptrs[pfn++] = FW_HYPERCALL_##call##_PADDR;	\
    2.31 +		tables->func_ptrs[pfn++] = 0;                     	\
    2.32  	} while (0)
    2.33  
    2.34 -// return domain (meta)physical address for a given imva
    2.35 -// this function is a call-back from dom_fw_init
    2.36 -static unsigned long
    2.37 -dom_pa(unsigned long imva)
    2.38 -{
    2.39 -	if (imva_fw_base == -1) {
    2.40 -		printf("dom_pa: uninitialized! (spinning...)\n");
    2.41 -		while(1);
    2.42 -	}
    2.43 -	if (imva - imva_fw_base > PAGE_SIZE) {
    2.44 -		printf("dom_pa: bad offset! imva=0x%lx, imva_fw_base=0x%lx (spinning...)\n",
    2.45 -			imva, imva_fw_base);
    2.46 -		while(1);
    2.47 -	}
    2.48 -	return dom_fw_base_mpa + (imva - imva_fw_base);
    2.49 -}
    2.50 -
    2.51  // allocate a page for fw
    2.52  // build_physmap_table() which is called by new_thread()
    2.53  // does for domU.
    2.54 @@ -90,7 +69,8 @@ assign_new_domain_page_if_dom0(struct do
    2.55  Hypercall bundle creation
    2.56  **************************************************************************/
    2.57  
    2.58 -static void build_hypercall_bundle(UINT64 *imva, UINT64 brkimm, UINT64 hypnum, UINT64 ret)
    2.59 +static void
    2.60 +build_hypercall_bundle(u64 *imva, u64 brkimm, u64 hypnum, u64 ret)
    2.61  {
    2.62  	INST64_A5 slot0;
    2.63  	INST64_I19 slot1;
    2.64 @@ -127,7 +107,8 @@ static void build_hypercall_bundle(UINT6
    2.65  	ia64_fc(imva + 1);
    2.66  }
    2.67  
    2.68 -static void build_pal_hypercall_bundles(UINT64 *imva, UINT64 brkimm, UINT64 hypnum)
    2.69 +static void
    2.70 +build_pal_hypercall_bundles(u64 *imva, u64 brkimm, u64 hypnum)
    2.71  {
    2.72  	extern unsigned long pal_call_stub[];
    2.73  	IA64_BUNDLE bundle;
    2.74 @@ -164,55 +145,54 @@ static void build_pal_hypercall_bundles(
    2.75  }
    2.76  
    2.77  // builds a hypercall bundle at domain physical address
    2.78 -static void dom_fpswa_hypercall_patch(struct domain *d)
    2.79 +static void
    2.80 +dom_fpswa_hypercall_patch(struct domain *d, unsigned long imva)
    2.81  {
    2.82  	unsigned long *entry_imva, *patch_imva;
    2.83 -	unsigned long entry_paddr = FW_HYPERCALL_FPSWA_ENTRY_PADDR;
    2.84 -	unsigned long patch_paddr = FW_HYPERCALL_FPSWA_PATCH_PADDR;
    2.85 +	const unsigned long entry_paddr = FW_HYPERCALL_FPSWA_ENTRY_PADDR;
    2.86 +	const unsigned long patch_paddr = FW_HYPERCALL_FPSWA_PATCH_PADDR;
    2.87  
    2.88 -	assign_new_domain_page_if_dom0(d, entry_paddr);
    2.89 -	assign_new_domain_page_if_dom0(d, patch_paddr);
    2.90 -	entry_imva = domain_mpa_to_imva(d, entry_paddr);
    2.91 -	patch_imva = domain_mpa_to_imva(d, patch_paddr);
    2.92 +	entry_imva = (unsigned long *)(imva + entry_paddr -
    2.93 +	                               FW_HYPERCALL_BASE_PADDR);
    2.94 +	patch_imva = (unsigned long *)(imva + patch_paddr -
    2.95 +	                               FW_HYPERCALL_BASE_PADDR);
    2.96  
    2.97 +	/* Descriptor.  */
    2.98  	*entry_imva++ = patch_paddr;
    2.99  	*entry_imva   = 0;
   2.100 +
   2.101  	build_hypercall_bundle(patch_imva, d->arch.breakimm,
   2.102  	                       FW_HYPERCALL_FPSWA, 1);
   2.103  }
   2.104  
   2.105  // builds a hypercall bundle at domain physical address
   2.106 -static void dom_efi_hypercall_patch(struct domain *d, unsigned long paddr, unsigned long hypercall)
   2.107 +static void
   2.108 +dom_efi_hypercall_patch(struct domain *d, unsigned long paddr,
   2.109 +                        unsigned long hypercall, unsigned long imva)
   2.110  {
   2.111 -	unsigned long *imva;
   2.112 -
   2.113 -	assign_new_domain_page_if_dom0(d, paddr);
   2.114 -	imva = domain_mpa_to_imva(d, paddr);
   2.115 -	build_hypercall_bundle(imva, d->arch.breakimm, hypercall, 1);
   2.116 +	build_hypercall_bundle((u64 *)(imva + paddr - FW_HYPERCALL_BASE_PADDR),
   2.117 +	                       d->arch.breakimm, hypercall, 1);
   2.118  }
   2.119  
   2.120  // builds a hypercall bundle at domain physical address
   2.121 -static void dom_fw_hypercall_patch(struct domain *d, unsigned long paddr, unsigned long hypercall,unsigned long ret)
   2.122 +static void
   2.123 +dom_fw_hypercall_patch(struct domain *d, unsigned long paddr,
   2.124 +                       unsigned long hypercall,unsigned long ret,
   2.125 +                       unsigned long imva)
   2.126  {
   2.127 -	unsigned long *imva;
   2.128 -
   2.129 -	assign_new_domain_page_if_dom0(d, paddr);
   2.130 -	imva = domain_mpa_to_imva(d, paddr);
   2.131 -	build_hypercall_bundle(imva, d->arch.breakimm, hypercall, ret);
   2.132 +	build_hypercall_bundle((u64 *)(imva + paddr - FW_HYPERCALL_BASE_PADDR),
   2.133 +	                       d->arch.breakimm, hypercall, ret);
   2.134  }
   2.135  
   2.136 -static void dom_fw_pal_hypercall_patch(struct domain *d, unsigned long paddr)
   2.137 +static void
   2.138 +dom_fw_pal_hypercall_patch(struct domain *d, unsigned long paddr,
   2.139 +                           unsigned long imva)
   2.140  {
   2.141 -	unsigned long *imva;
   2.142 -
   2.143 -	assign_new_domain_page_if_dom0(d, paddr);
   2.144 -	imva = domain_mpa_to_imva(d, paddr);
   2.145 -	build_pal_hypercall_bundles(imva, d->arch.breakimm,
   2.146 -	                            FW_HYPERCALL_PAL_CALL);
   2.147 +	build_pal_hypercall_bundles((u64*)(imva + paddr -
   2.148 +	                            FW_HYPERCALL_BASE_PADDR),
   2.149 +	                            d->arch.breakimm, FW_HYPERCALL_PAL_CALL);
   2.150  }
   2.151  
   2.152 -/* the following heavily leveraged from linux/arch/ia64/hp/sim/fw-emu.c */
   2.153 -
   2.154  static inline void
   2.155  print_md(efi_memory_desc_t *md)
   2.156  {
   2.157 @@ -311,6 +291,8 @@ struct fake_acpi_tables {
   2.158  	u8 pm1a_cnt_blk[1];
   2.159  	u8 pm_tmr_blk[4];
   2.160  };
   2.161 +#define ACPI_TABLE_MPA(field) \
   2.162 +  FW_ACPI_BASE_PADDR + offsetof(struct fake_acpi_tables, field);
   2.163  
   2.164  /* Create enough of an ACPI structure to make the guest OS ACPI happy. */
   2.165  static void
   2.166 @@ -340,8 +322,8 @@ dom_fw_fake_acpi(struct domain *d, struc
   2.167  	xsdt->asl_compiler_revision = (xen_major_version() << 16) |
   2.168  		xen_minor_version();
   2.169  
   2.170 -	xsdt->table_offset_entry[0] = dom_pa((unsigned long) fadt);
   2.171 -	tables->madt_ptr = dom_pa((unsigned long) madt);
   2.172 +	xsdt->table_offset_entry[0] = ACPI_TABLE_MPA(fadt);
   2.173 +	tables->madt_ptr = ACPI_TABLE_MPA(madt);
   2.174  
   2.175  	xsdt->checksum = generate_acpi_checksum(xsdt, xsdt->length);
   2.176  
   2.177 @@ -359,8 +341,8 @@ dom_fw_fake_acpi(struct domain *d, struc
   2.178  	facs->version = 1;
   2.179  	facs->length = sizeof(struct facs_descriptor_rev2);
   2.180  
   2.181 -	fadt->xfirmware_ctrl = dom_pa((unsigned long) facs);
   2.182 -	fadt->Xdsdt = dom_pa((unsigned long) dsdt);
   2.183 +	fadt->xfirmware_ctrl = ACPI_TABLE_MPA(facs);
   2.184 +	fadt->Xdsdt = ACPI_TABLE_MPA(dsdt);
   2.185  
   2.186  	/*
   2.187  	 * All of the below FADT entries are filled it to prevent warnings
   2.188 @@ -370,15 +352,15 @@ dom_fw_fake_acpi(struct domain *d, struc
   2.189  	fadt->pm1_evt_len = 4;
   2.190  	fadt->xpm1a_evt_blk.address_space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
   2.191  	fadt->xpm1a_evt_blk.register_bit_width = 8;
   2.192 -	fadt->xpm1a_evt_blk.address = dom_pa((unsigned long) &tables->pm1a_evt_blk);
   2.193 +	fadt->xpm1a_evt_blk.address = ACPI_TABLE_MPA(pm1a_evt_blk);
   2.194  	fadt->pm1_cnt_len = 1;
   2.195  	fadt->xpm1a_cnt_blk.address_space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
   2.196  	fadt->xpm1a_cnt_blk.register_bit_width = 8;
   2.197 -	fadt->xpm1a_cnt_blk.address = dom_pa((unsigned long) &tables->pm1a_cnt_blk);
   2.198 +	fadt->xpm1a_cnt_blk.address = ACPI_TABLE_MPA(pm1a_cnt_blk);
   2.199  	fadt->pm_tm_len = 4;
   2.200  	fadt->xpm_tmr_blk.address_space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
   2.201  	fadt->xpm_tmr_blk.register_bit_width = 8;
   2.202 -	fadt->xpm_tmr_blk.address = dom_pa((unsigned long) &tables->pm_tmr_blk);
   2.203 +	fadt->xpm_tmr_blk.address = ACPI_TABLE_MPA(pm_tmr_blk);
   2.204  
   2.205  	fadt->checksum = generate_acpi_checksum(fadt, fadt->length);
   2.206  
   2.207 @@ -387,7 +369,7 @@ dom_fw_fake_acpi(struct domain *d, struc
   2.208  	strcpy(rsdp->oem_id, "XEN");
   2.209  	rsdp->revision = 2; /* ACPI 2.0 includes XSDT */
   2.210  	rsdp->length = sizeof(struct acpi20_table_rsdp);
   2.211 -	rsdp->xsdt_address = dom_pa((unsigned long) xsdt);
   2.212 +	rsdp->xsdt_address = ACPI_TABLE_MPA(xsdt);
   2.213  
   2.214  	rsdp->checksum = generate_acpi_checksum(rsdp,
   2.215  	                                        ACPI_RSDP_CHECKSUM_LENGTH);
   2.216 @@ -462,89 +444,6 @@ dom_fw_fake_acpi(struct domain *d, struc
   2.217  	return;
   2.218  }
   2.219  
   2.220 -struct dom0_passthrough_arg {
   2.221 -    struct domain*      d;
   2.222 -    int                 flags;
   2.223 -    efi_memory_desc_t *md;
   2.224 -    int*                i;
   2.225 -};
   2.226 -
   2.227 -static int
   2.228 -dom_fw_dom0_passthrough(efi_memory_desc_t *md, void *arg__)
   2.229 -{
   2.230 -    struct dom0_passthrough_arg* arg = (struct dom0_passthrough_arg*)arg__;
   2.231 -    unsigned long paddr;
   2.232 -    struct domain* d = arg->d;
   2.233 -    u64 start = md->phys_addr;
   2.234 -    u64 size = md->num_pages << EFI_PAGE_SHIFT;
   2.235 -
   2.236 -    if (md->type == EFI_MEMORY_MAPPED_IO ||
   2.237 -        md->type == EFI_MEMORY_MAPPED_IO_PORT_SPACE) {
   2.238 -
   2.239 -        //XXX some machine has large mmio area whose size is about several TB.
   2.240 -        //    It requires impractical memory to map such a huge region
   2.241 -        //    to a domain.
   2.242 -        //    For now we don't map it, but later we must fix this.
   2.243 -        if (md->type == EFI_MEMORY_MAPPED_IO && (size > 0x100000000UL))
   2.244 -            return 0;
   2.245 -
   2.246 -        paddr = assign_domain_mmio_page(d, start, size);
   2.247 -    } else
   2.248 -        paddr = assign_domain_mach_page(d, start, size, arg->flags);
   2.249 -
   2.250 -    BUG_ON(md->type != EFI_RUNTIME_SERVICES_CODE &&
   2.251 -           md->type != EFI_RUNTIME_SERVICES_DATA &&
   2.252 -           md->type != EFI_ACPI_RECLAIM_MEMORY &&
   2.253 -           md->type != EFI_ACPI_MEMORY_NVS &&
   2.254 -           md->type != EFI_RESERVED_TYPE &&
   2.255 -           md->type != EFI_MEMORY_MAPPED_IO &&
   2.256 -           md->type != EFI_MEMORY_MAPPED_IO_PORT_SPACE);
   2.257 -
   2.258 -    arg->md->type = md->type;
   2.259 -    arg->md->pad = 0;
   2.260 -    arg->md->phys_addr = paddr;
   2.261 -    arg->md->virt_addr = 0;
   2.262 -    arg->md->num_pages = md->num_pages;
   2.263 -    arg->md->attribute = md->attribute;
   2.264 -
   2.265 -    (*arg->i)++;
   2.266 -    arg->md++;
   2.267 -    return 0;
   2.268 -}
   2.269 -
   2.270 -/*
   2.271 - * Create dom0 MDT entries for conventional memory below 1MB.  Without
   2.272 - * this Linux will assume VGA is present because 0xA0000 will always
   2.273 - * be either a hole in the MDT or an I/O region via the passthrough.
   2.274 - */
   2.275 -static int
   2.276 -dom_fw_dom0_lowmem(efi_memory_desc_t *md, void *arg__)
   2.277 -{
   2.278 -    struct dom0_passthrough_arg* arg = (struct dom0_passthrough_arg*)arg__;
   2.279 -    u64 end = min(ONE_MB, md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT));
   2.280 -
   2.281 -    BUG_ON(md->type != EFI_CONVENTIONAL_MEMORY);
   2.282 -
   2.283 -    /* Avoid firmware and hypercall area.
   2.284 -       We know they are 0-based.  */
   2.285 -    if (end < dom_fw_end_mpa || md->phys_addr >= ONE_MB)
   2.286 -	return 0;
   2.287 -    if (md->phys_addr < dom_fw_end_mpa)
   2.288 -        md->phys_addr = dom_fw_end_mpa;
   2.289 -
   2.290 -    arg->md->type = md->type;
   2.291 -    arg->md->pad = 0;
   2.292 -    arg->md->phys_addr = md->phys_addr;
   2.293 -    arg->md->virt_addr = 0;
   2.294 -    arg->md->num_pages = (end - md->phys_addr) >> EFI_PAGE_SHIFT;
   2.295 -    arg->md->attribute = md->attribute;
   2.296 -
   2.297 -    (*arg->i)++;
   2.298 -    arg->md++;
   2.299 -
   2.300 -    return 0;
   2.301 -}
   2.302 -
   2.303  static int
   2.304  efi_mdt_cmp(const void *a, const void *b)
   2.305  {
   2.306 @@ -583,18 +482,204 @@ struct fw_tables {
   2.307  	unsigned long func_ptrs[2*NFUNCPTRS];
   2.308   	struct xen_sal_data sal_data;
   2.309  	unsigned char fw_vendor[sizeof(FW_VENDOR)];
   2.310 +};
   2.311 +#define FW_FIELD_MPA(field) \
   2.312 +   FW_TABLES_BASE_PADDR + offsetof(struct fw_tables, field)
   2.313  
   2.314 -	struct fake_acpi_tables acpi_tables;
   2.315 -};
   2.316 +/* Complete the dom0 memmap.  */
   2.317 +static int
   2.318 +complete_dom0_memmap(struct domain *d,
   2.319 +                     struct fw_tables *tables,
   2.320 +                     unsigned long maxmem,
   2.321 +                     int num_mds)
   2.322 +{
   2.323 +	efi_memory_desc_t *md;
   2.324 +	u64 addr;
   2.325 +	int j;
   2.326 +	void *efi_map_start, *efi_map_end, *p;
   2.327 +	u64 efi_desc_size;
   2.328 +	int i;
   2.329 +
   2.330 +	/* Walk through all MDT entries.
   2.331 +	   Copy all interesting entries.  */
   2.332 +	efi_map_start = __va(ia64_boot_param->efi_memmap);
   2.333 +	efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
   2.334 +	efi_desc_size = ia64_boot_param->efi_memdesc_size;
   2.335 +
   2.336 +	for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
   2.337 +		const efi_memory_desc_t *md = p;
   2.338 +		efi_memory_desc_t *dom_md = &tables->efi_memmap[num_mds];
   2.339 +		u64 start = md->phys_addr;
   2.340 +		u64 size = md->num_pages << EFI_PAGE_SHIFT;
   2.341 +		u64 end = start + size;
   2.342 +
   2.343 +		switch (md->type) {
   2.344 +		case EFI_RUNTIME_SERVICES_CODE:
   2.345 +		case EFI_RUNTIME_SERVICES_DATA:
   2.346 +		case EFI_ACPI_RECLAIM_MEMORY:
   2.347 +		case EFI_ACPI_MEMORY_NVS:
   2.348 +		case EFI_RESERVED_TYPE:
   2.349 +			/* Map into dom0 - All these are writable.  */
   2.350 +			assign_domain_mach_page(d, start, size,
   2.351 +			                        ASSIGN_writable);
   2.352 +			/* Fall-through.  */
   2.353 +		case EFI_MEMORY_MAPPED_IO:
   2.354 +			/* Will be mapped with ioremap.  */
   2.355 +			/* Copy descriptor.  */
   2.356 +			*dom_md = *md;
   2.357 +			dom_md->virt_addr = 0;
   2.358 +			num_mds++;
   2.359 +			break;
   2.360 +
   2.361 +		case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
   2.362 +			/* Map into dom0.  */
   2.363 +			assign_domain_mmio_page(d, start, size);
   2.364 +			/* Copy descriptor.  */
   2.365 +			*dom_md = *md;
   2.366 +			dom_md->virt_addr = 0;
   2.367 +			num_mds++;
   2.368 +			break;
   2.369 +
   2.370 +		case EFI_CONVENTIONAL_MEMORY:
   2.371 +		case EFI_LOADER_CODE:
   2.372 +		case EFI_LOADER_DATA:
   2.373 +		case EFI_BOOT_SERVICES_CODE:
   2.374 +		case EFI_BOOT_SERVICES_DATA:
   2.375 +			/* Create dom0 MDT entries for conventional memory
   2.376 +			   below 1MB.  Without this Linux will assume VGA is
   2.377 +			   present because 0xA0000 will always be either a hole
   2.378 +			   in the MDT or an I/O region via the passthrough.  */
   2.379 +
   2.380 +			end = min(ONE_MB, end);
   2.381 +
   2.382 +			/* Avoid firmware and hypercall area.
   2.383 +			   We know they are 0-based.  */
   2.384 +			if (end < FW_END_PADDR || start >= ONE_MB)
   2.385 +				break;
   2.386 +			if (start < FW_END_PADDR)
   2.387 +				start = FW_END_PADDR;
   2.388 +			
   2.389 +			dom_md->type = EFI_CONVENTIONAL_MEMORY;
   2.390 +			dom_md->phys_addr = start;
   2.391 +			dom_md->virt_addr = 0;
   2.392 +			dom_md->num_pages = (end - start) >> EFI_PAGE_SHIFT;
   2.393 +			dom_md->attribute = md->attribute;
   2.394 +			num_mds++;
   2.395 +			break;
   2.396 +
   2.397 +		case EFI_UNUSABLE_MEMORY:
   2.398 +		case EFI_PAL_CODE:
   2.399 +			/* Discard.  */
   2.400 +			break;
   2.401 +
   2.402 +		default:
   2.403 +			/* Print a warning but continue.  */
   2.404 +			printf("complete_dom0_memmap: warning: "
   2.405 +			       "unhandled MDT entry type %u\n", md->type);
   2.406 +		}
   2.407 +	}
   2.408 +	BUG_ON(num_mds > NUM_MEM_DESCS);
   2.409 +	
   2.410 +	sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   2.411 +	     efi_mdt_cmp, NULL);
   2.412 +
   2.413 +	/* find gaps and fill them with conventional memory */
   2.414 +	i = num_mds;
   2.415 +	for (j = 0; j < num_mds; j++) {
   2.416 +		unsigned long end;
   2.417 +		unsigned long next_start;
   2.418 +		
   2.419 +		md = &tables->efi_memmap[j];
   2.420 +		end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
   2.421 +		
   2.422 +		if (j + 1 < num_mds) {
   2.423 +			efi_memory_desc_t* next_md;
   2.424 +			next_md = &tables->efi_memmap[j + 1];
   2.425 +			next_start = next_md->phys_addr;
   2.426 +			
   2.427 +			/* Have just been sorted.  */
   2.428 +			BUG_ON(end > next_start);
   2.429 +			
   2.430 +			/* No room for memory!  */
   2.431 +			if (end == next_start)
   2.432 +				continue;
   2.433 +			
   2.434 +			if (next_start > maxmem)
   2.435 +				next_start = maxmem;
   2.436 +		}
   2.437 +		else
   2.438 +			next_start = maxmem;
   2.439 +		
   2.440 +		/* Avoid "legacy" low memory addresses 
   2.441 +		   and the HYPERCALL area.  */
   2.442 +		if (end < ONE_MB)
   2.443 +			end = ONE_MB;
   2.444 +						      
   2.445 +		// clip the range and align to PAGE_SIZE
   2.446 +		next_start = next_start & PAGE_MASK;
   2.447 +		end = PAGE_ALIGN(end);
   2.448 +		
   2.449 +		/* No room for memory.  */
   2.450 +		if (end >= next_start)
   2.451 +			continue;
   2.452 +		
   2.453 +		MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
   2.454 +		        end, next_start);
   2.455 +
   2.456 +		if (next_start >= maxmem)
   2.457 +			break;
   2.458 +	}
   2.459 +	num_mds = i;
   2.460 +	BUG_ON(num_mds > NUM_MEM_DESCS);
   2.461 +	sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   2.462 +	     efi_mdt_cmp, NULL);
   2.463 +
   2.464 +	// dom0 doesn't need build_physmap_table()
   2.465 +	// see arch_set_info_guest()
   2.466 +	// instead we allocate pages manually.
   2.467 +	for (i = 0; i < num_mds; i++) {
   2.468 +		md = &tables->efi_memmap[i];
   2.469 +		if (md->phys_addr > maxmem)
   2.470 +			break;
   2.471 +		
   2.472 +		if (md->type == EFI_LOADER_DATA ||
   2.473 +		    md->type == EFI_PAL_CODE ||
   2.474 +		    md->type == EFI_CONVENTIONAL_MEMORY) {
   2.475 +			unsigned long start = md->phys_addr & PAGE_MASK;
   2.476 +			unsigned long end = md->phys_addr +
   2.477 +				(md->num_pages << EFI_PAGE_SHIFT);
   2.478 +
   2.479 +			if (end == start) {
   2.480 +				/* md->num_pages = 0 is allowed. */
   2.481 +				continue;
   2.482 +			}
   2.483 +			if (end > (max_page << PAGE_SHIFT))
   2.484 +				end = (max_page << PAGE_SHIFT);
   2.485 +			
   2.486 +			for (addr = start; addr < end; addr += PAGE_SIZE)
   2.487 +				assign_new_domain0_page(d, addr);
   2.488 +		}
   2.489 +	}
   2.490 +	// Map low-memory holes & unmapped MMIO for legacy drivers
   2.491 +	for (addr = 0; addr < ONE_MB; addr += PAGE_SIZE) {
   2.492 +		if (domain_page_mapped(d, addr))
   2.493 +			continue;
   2.494 +		
   2.495 +		if (efi_mmio(addr, PAGE_SIZE))
   2.496 +			assign_domain_mmio_page(d, addr, PAGE_SIZE);
   2.497 +	}
   2.498 +	return num_mds;
   2.499 +}
   2.500  	
   2.501  static void
   2.502  dom_fw_init(struct domain *d,
   2.503              struct ia64_boot_param *bp,
   2.504              struct fw_tables *tables,
   2.505 +            unsigned long hypercalls_imva,
   2.506              unsigned long maxmem)
   2.507  {
   2.508  	efi_memory_desc_t *md;
   2.509 -	unsigned long *pfn;
   2.510 +	unsigned long pfn;
   2.511  	unsigned char checksum;
   2.512  	char *cp;
   2.513  	int num_mds, i;
   2.514 @@ -612,20 +697,18 @@ dom_fw_init(struct domain *d,
   2.515  	tables->efi_systab.hdr.headersize = sizeof(tables->efi_systab.hdr);
   2.516  
   2.517  	memcpy(tables->fw_vendor,FW_VENDOR,sizeof(FW_VENDOR));
   2.518 -	tables->efi_systab.fw_vendor =
   2.519 -	                             dom_pa((unsigned long)tables->fw_vendor);
   2.520 +	tables->efi_systab.fw_vendor = FW_FIELD_MPA(fw_vendor);
   2.521  	tables->efi_systab.fw_revision = 1;
   2.522 -	tables->efi_systab.runtime =
   2.523 -	                 (void *)dom_pa((unsigned long)&tables->efi_runtime);
   2.524 +	tables->efi_systab.runtime = (void *)FW_FIELD_MPA(efi_runtime);
   2.525  	tables->efi_systab.nr_tables = NUM_EFI_SYS_TABLES;
   2.526 -	tables->efi_systab.tables = dom_pa((unsigned long)tables->efi_tables);
   2.527 +	tables->efi_systab.tables = FW_FIELD_MPA(efi_tables);
   2.528  
   2.529  	/* EFI runtime.  */
   2.530  	tables->efi_runtime.hdr.signature = EFI_RUNTIME_SERVICES_SIGNATURE;
   2.531  	tables->efi_runtime.hdr.revision = EFI_RUNTIME_SERVICES_REVISION;
   2.532  	tables->efi_runtime.hdr.headersize = sizeof(tables->efi_runtime.hdr);
   2.533  
   2.534 -	pfn = tables->func_ptrs;
   2.535 +	pfn = 0;
   2.536  	EFI_HYPERCALL_PATCH(get_time,EFI_GET_TIME);
   2.537  	EFI_HYPERCALL_PATCH(set_time,EFI_SET_TIME);
   2.538  	EFI_HYPERCALL_PATCH(get_wakeup_time,EFI_GET_WAKEUP_TIME);
   2.539 @@ -641,14 +724,16 @@ dom_fw_init(struct domain *d,
   2.540  
   2.541  	/* System tables.  */
   2.542  	tables->efi_tables[0].guid = SAL_SYSTEM_TABLE_GUID;
   2.543 -	tables->efi_tables[0].table =
   2.544 -	                           dom_pa((unsigned long)&tables->sal_systab);
   2.545 +	tables->efi_tables[0].table = FW_FIELD_MPA(sal_systab);
   2.546  	for (i = 1; i < NUM_EFI_SYS_TABLES; i++) {
   2.547  		tables->efi_tables[i].guid = NULL_GUID;
   2.548  		tables->efi_tables[i].table = 0;
   2.549  	}
   2.550  	i = 1;
   2.551  	if (d == dom0) {
   2.552 +		/* Write messages to the console.  */
   2.553 +		touch_acpi_table();
   2.554 +
   2.555  		printf("Domain0 EFI passthrough:");
   2.556  		if (efi.mps) {
   2.557  			tables->efi_tables[i].guid = MPS_TABLE_GUID;
   2.558 @@ -657,8 +742,6 @@ dom_fw_init(struct domain *d,
   2.559  			i++;
   2.560  		}
   2.561  
   2.562 -		touch_acpi_table();
   2.563 -
   2.564  		if (efi.acpi20) {
   2.565  			tables->efi_tables[i].guid = ACPI_20_TABLE_GUID;
   2.566  			tables->efi_tables[i].table = __pa(efi.acpi20);
   2.567 @@ -687,11 +770,8 @@ dom_fw_init(struct domain *d,
   2.568  	} else {
   2.569  		printf("DomainU EFI build up:");
   2.570  
   2.571 -		dom_fw_fake_acpi(d, &tables->acpi_tables);
   2.572 -
   2.573  		tables->efi_tables[i].guid = ACPI_20_TABLE_GUID;
   2.574 -		tables->efi_tables[i].table =
   2.575 -		                  dom_pa((unsigned long) &tables->acpi_tables);
   2.576 +		tables->efi_tables[i].table = FW_ACPI_BASE_PADDR;
   2.577  		printf(" ACPI 2.0=0x%lx",tables->efi_tables[i].table);
   2.578  		i++;
   2.579  		printf("\n");
   2.580 @@ -707,13 +787,15 @@ dom_fw_init(struct domain *d,
   2.581  	strcpy((char *)tables->sal_systab.oem_id, "Xen/ia64");
   2.582  	strcpy((char *)tables->sal_systab.product_id, "Xen/ia64");
   2.583  
   2.584 -	/* fill in an entry point: */
   2.585 +	/* PAL entry point: */
   2.586  	tables->sal_ed.type = SAL_DESC_ENTRY_POINT;
   2.587  	tables->sal_ed.pal_proc = FW_HYPERCALL_PAL_CALL_PADDR;
   2.588 -	dom_fw_pal_hypercall_patch(d, tables->sal_ed.pal_proc);
   2.589 +	dom_fw_pal_hypercall_patch(d, tables->sal_ed.pal_proc, 
   2.590 +	                           hypercalls_imva);
   2.591 +	/* SAL entry point.  */
   2.592  	tables->sal_ed.sal_proc = FW_HYPERCALL_SAL_CALL_PADDR;
   2.593  	dom_fw_hypercall_patch(d, tables->sal_ed.sal_proc,
   2.594 -	                       FW_HYPERCALL_SAL_CALL, 1);
   2.595 +	                       FW_HYPERCALL_SAL_CALL, 1, hypercalls_imva);
   2.596  	tables->sal_ed.gp = 0;  /* will be ignored */
   2.597  
   2.598  	/* Fill an AP wakeup descriptor.  */
   2.599 @@ -730,13 +812,12 @@ dom_fw_init(struct domain *d,
   2.600  	tables->sal_systab.checksum = -checksum;
   2.601  
   2.602  	/* SAL return point.  */
   2.603 -	d->arch.sal_return_addr = FW_HYPERCALL_SAL_RETURN_PADDR;
   2.604 -	dom_fw_hypercall_patch (d, d->arch.sal_return_addr,
   2.605 -				FW_HYPERCALL_SAL_RETURN, 0);
   2.606 +	dom_fw_hypercall_patch(d, FW_HYPERCALL_SAL_RETURN_PADDR,
   2.607 +	                       FW_HYPERCALL_SAL_RETURN, 0, hypercalls_imva);
   2.608  
   2.609  	/* Fill in the FPSWA interface: */
   2.610  	tables->fpswa_inf.revision = fpswa_interface->revision;
   2.611 -	dom_fpswa_hypercall_patch(d);
   2.612 +	dom_fpswa_hypercall_patch(d, hypercalls_imva);
   2.613  	tables->fpswa_inf.fpswa = (void *)FW_HYPERCALL_FPSWA_ENTRY_PADDR;
   2.614  
   2.615  	i = 0; /* Used by MAKE_MD */
   2.616 @@ -745,14 +826,18 @@ dom_fw_init(struct domain *d,
   2.617  	MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB|EFI_MEMORY_RUNTIME,
   2.618  	        FW_HYPERCALL_BASE_PADDR, FW_HYPERCALL_END_PADDR);
   2.619  
   2.620 -	/* Create dom0/domu md entry for fw tables area */
   2.621 +	/* Create dom0/domu md entry for fw and cpi tables area.  */
   2.622 +	MAKE_MD(EFI_ACPI_MEMORY_NVS, EFI_MEMORY_WB | EFI_MEMORY_RUNTIME,
   2.623 +	        FW_ACPI_BASE_PADDR, FW_ACPI_END_PADDR);
   2.624  	MAKE_MD(EFI_RUNTIME_SERVICES_DATA, EFI_MEMORY_WB | EFI_MEMORY_RUNTIME,
   2.625 -	        dom_fw_base_mpa, dom_fw_end_mpa);
   2.626 +	        FW_TABLES_BASE_PADDR, FW_TABLES_END_PADDR);
   2.627  
   2.628  	if (d != dom0 || running_on_sim) {
   2.629 +		/* DomU (or hp-ski).
   2.630 +		   Create a continuous memory area.  */
   2.631  		/* Memory.  */
   2.632  		MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
   2.633 -		        dom_fw_end_mpa, maxmem);
   2.634 +		        FW_END_PADDR, maxmem);
   2.635  		
   2.636  		/* Create an entry for IO ports.  */
   2.637  		MAKE_MD(EFI_MEMORY_MAPPED_IO_PORT_SPACE, EFI_MEMORY_UC,
   2.638 @@ -761,128 +846,10 @@ dom_fw_init(struct domain *d,
   2.639  		num_mds = i;
   2.640  	}
   2.641  	else {
   2.642 -		/* pass through the I/O port space */
   2.643 -		struct dom0_passthrough_arg arg;
   2.644 -		u64 addr;
   2.645 -		int j;
   2.646 -
   2.647 -		/* Fill from real entries.  */
   2.648 -		arg.md = &tables->efi_memmap[i];
   2.649 -		arg.i = &i;
   2.650 -		arg.d = d;
   2.651 -		arg.flags = ASSIGN_writable;
   2.652 -		//XXX Is this needed?
   2.653 -		efi_memmap_walk_type(EFI_RUNTIME_SERVICES_CODE,
   2.654 -		                     dom_fw_dom0_passthrough, &arg);
   2.655 -		// for ACPI table.
   2.656 -		arg.flags = ASSIGN_readonly;
   2.657 -		efi_memmap_walk_type(EFI_RUNTIME_SERVICES_DATA,
   2.658 -		                     dom_fw_dom0_passthrough, &arg);
   2.659 -		arg.flags = ASSIGN_writable;
   2.660 -		efi_memmap_walk_type(EFI_ACPI_RECLAIM_MEMORY,
   2.661 -		                     dom_fw_dom0_passthrough, &arg);
   2.662 -		efi_memmap_walk_type(EFI_ACPI_MEMORY_NVS,
   2.663 -		                     dom_fw_dom0_passthrough, &arg);
   2.664 -		efi_memmap_walk_type(EFI_RESERVED_TYPE,
   2.665 -		                     dom_fw_dom0_passthrough, &arg);
   2.666 -		efi_memmap_walk_type(EFI_MEMORY_MAPPED_IO,
   2.667 -		                     dom_fw_dom0_passthrough, &arg);
   2.668 -		efi_memmap_walk_type(EFI_MEMORY_MAPPED_IO_PORT_SPACE,
   2.669 -		                     dom_fw_dom0_passthrough, &arg);
   2.670 -		efi_memmap_walk_type(EFI_CONVENTIONAL_MEMORY,
   2.671 -		                     dom_fw_dom0_lowmem, &arg);
   2.672 -		num_mds = i;
   2.673 -
   2.674 -		sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   2.675 -		     efi_mdt_cmp, NULL);
   2.676 -
   2.677 -		// find gaps and fill them with conventional memory
   2.678 -		for (j = 0; j < num_mds; j++) {
   2.679 -			unsigned long end;
   2.680 -			unsigned long next_start;
   2.681 -
   2.682 -			md = &tables->efi_memmap[j];
   2.683 -			end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
   2.684 -
   2.685 -			if (j + 1 < num_mds) {
   2.686 -				efi_memory_desc_t* next_md;
   2.687 -				next_md = &tables->efi_memmap[j+1];
   2.688 -				next_start = next_md->phys_addr;
   2.689 -				
   2.690 -				/* Have just been sorted.  */
   2.691 -				BUG_ON(end > next_start);
   2.692 -				
   2.693 -				/* No room for memory!  */
   2.694 -				if (end == next_start)
   2.695 -					continue;
   2.696 -				
   2.697 -				if (next_start > maxmem)
   2.698 -					next_start = maxmem;
   2.699 -			}
   2.700 -			else
   2.701 -				next_start = maxmem;
   2.702 -			
   2.703 -			/* Avoid "legacy" low memory addresses and
   2.704 -			   the HYPERCALL area.  */
   2.705 -			if (end < ONE_MB)
   2.706 -				end = ONE_MB;
   2.707 -						      
   2.708 -			// clip the range and align to PAGE_SIZE
   2.709 -			next_start = next_start & PAGE_MASK;
   2.710 -			end = PAGE_ALIGN(end);
   2.711 -			
   2.712 -			/* No room for memory.  */
   2.713 -			if (end >= next_start)
   2.714 -				continue;
   2.715 -
   2.716 -			MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
   2.717 -			        end, next_start);
   2.718 -
   2.719 -			if (next_start >= maxmem)
   2.720 -				break;
   2.721 -		}
   2.722 -		num_mds = i;
   2.723 -		BUG_ON(num_mds > NUM_MEM_DESCS);
   2.724 -		sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   2.725 -		     efi_mdt_cmp, NULL);
   2.726 -
   2.727 -		// dom0 doesn't need build_physmap_table()
   2.728 -		// see arch_set_info_guest()
   2.729 -		// instead we allocate pages manually.
   2.730 -		for (i = 0; i < num_mds; i++) {
   2.731 -			md = &tables->efi_memmap[i];
   2.732 -			if (md->phys_addr > maxmem)
   2.733 -				break;
   2.734 -
   2.735 -			if (md->type == EFI_LOADER_DATA ||
   2.736 -			    md->type == EFI_PAL_CODE ||
   2.737 -			    md->type == EFI_CONVENTIONAL_MEMORY) {
   2.738 -				unsigned long start = md->phys_addr & PAGE_MASK;
   2.739 -				unsigned long end = md->phys_addr +
   2.740 -				              (md->num_pages << EFI_PAGE_SHIFT);
   2.741 -
   2.742 -				if (end == start) {
   2.743 -					// md->num_pages = 0 is allowed.
   2.744 -					continue;
   2.745 -				}
   2.746 -				if (end > (max_page << PAGE_SHIFT))
   2.747 -					end = (max_page << PAGE_SHIFT);
   2.748 -
   2.749 -				for (addr = start;
   2.750 -				     addr < end;
   2.751 -				     addr += PAGE_SIZE) {
   2.752 -					assign_new_domain0_page(d, addr);
   2.753 -				}
   2.754 -			}
   2.755 -		}
   2.756 -		// Map low-memory holes & unmapped MMIO for legacy drivers
   2.757 -		for (addr = 0; addr < ONE_MB; addr += PAGE_SIZE) {
   2.758 -			if (domain_page_mapped(d, addr))
   2.759 -				continue;
   2.760 -					
   2.761 -			if (efi_mmio(addr, PAGE_SIZE))
   2.762 -				assign_domain_mmio_page(d, addr, PAGE_SIZE);
   2.763 -		}
   2.764 +		/* Dom0.
   2.765 +		   We must preserve ACPI data from real machine,
   2.766 +		   as well as IO areas.  */
   2.767 +		num_mds = complete_dom0_memmap(d, tables, maxmem, i);
   2.768  	}
   2.769  
   2.770  	/* Display memmap.  */
   2.771 @@ -890,8 +857,8 @@ dom_fw_init(struct domain *d,
   2.772  		print_md(&tables->efi_memmap[i]);
   2.773  
   2.774  	/* Fill boot_param  */
   2.775 -	bp->efi_systab = dom_pa((unsigned long)&tables->efi_systab);
   2.776 -	bp->efi_memmap = dom_pa((unsigned long)tables->efi_memmap);
   2.777 +	bp->efi_systab = FW_FIELD_MPA(efi_systab);
   2.778 +	bp->efi_memmap = FW_FIELD_MPA(efi_memmap);
   2.779  	bp->efi_memmap_size = num_mds * sizeof(efi_memory_desc_t);
   2.780  	bp->efi_memdesc_size = sizeof(efi_memory_desc_t);
   2.781  	bp->efi_memdesc_version = EFI_MEMDESC_VERSION;
   2.782 @@ -900,25 +867,44 @@ dom_fw_init(struct domain *d,
   2.783  	bp->console_info.num_rows = 25;
   2.784  	bp->console_info.orig_x = 0;
   2.785  	bp->console_info.orig_y = 24;
   2.786 -	bp->fpswa = dom_pa((unsigned long) &tables->fpswa_inf);
   2.787 +	bp->fpswa = FW_FIELD_MPA(fpswa_inf);
   2.788  }
   2.789  
   2.790  void dom_fw_setup(struct domain *d, unsigned long bp_mpa, unsigned long maxmem)
   2.791  {
   2.792  	struct ia64_boot_param *bp;
   2.793 +	unsigned long imva_tables_base;
   2.794 +	unsigned long imva_hypercall_base;
   2.795  
   2.796 -	/* Note: 4KB < size < 8KB.  */
   2.797 -	BUILD_BUG_ON(sizeof(struct fw_tables) > PAGE_SIZE);
   2.798 +	BUILD_BUG_ON(sizeof(struct fw_tables) >
   2.799 +	             (FW_TABLES_END_PADDR - FW_TABLES_BASE_PADDR));
   2.800  
   2.801 -	dom_fw_end_mpa = PAGE_ALIGN(dom_fw_base_mpa + sizeof(struct fw_tables));
   2.802 +	BUILD_BUG_ON(sizeof(struct fake_acpi_tables) >
   2.803 +	             (FW_ACPI_END_PADDR - FW_ACPI_BASE_PADDR));
   2.804  
   2.805  	/* Create page for hypercalls.  */
   2.806 -	assign_new_domain_page_if_dom0(d, dom_fw_base_mpa);
   2.807 -	imva_fw_base = (unsigned long)domain_mpa_to_imva(d, dom_fw_base_mpa);
   2.808 +	assign_new_domain_page_if_dom0(d, FW_HYPERCALL_BASE_PADDR);
   2.809 +	imva_hypercall_base = (unsigned long)domain_mpa_to_imva
   2.810 +	                                     (d, FW_HYPERCALL_BASE_PADDR);
   2.811 +
   2.812 +	/* Create page for acpi tables.  */
   2.813 +	if (d != dom0) {
   2.814 +		void *imva;
   2.815 +
   2.816 +		assign_new_domain_page_if_dom0(d, FW_ACPI_BASE_PADDR);
   2.817 +		imva = domain_mpa_to_imva (d, FW_ACPI_BASE_PADDR);
   2.818 +		dom_fw_fake_acpi(d, (struct fake_acpi_tables *)imva);
   2.819 +	}
   2.820 +
   2.821 +	/* Create page for FW tables.  */
   2.822 +	assign_new_domain_page_if_dom0(d, FW_TABLES_BASE_PADDR);
   2.823 +	imva_tables_base = (unsigned long)domain_mpa_to_imva
   2.824 +	                                  (d, FW_TABLES_BASE_PADDR);
   2.825  
   2.826  	/* Create page for boot_param.  */
   2.827  	assign_new_domain_page_if_dom0(d, bp_mpa);
   2.828  	bp = domain_mpa_to_imva(d, bp_mpa);
   2.829  
   2.830 -	dom_fw_init(d, bp, (struct fw_tables *)imva_fw_base, maxmem);
   2.831 +	dom_fw_init(d, bp, (struct fw_tables *)imva_tables_base,
   2.832 +	            imva_hypercall_base, maxmem);
   2.833  }
     3.1 --- a/xen/arch/ia64/xen/hypercall.c	Mon Aug 28 14:09:31 2006 -0600
     3.2 +++ b/xen/arch/ia64/xen/hypercall.c	Mon Aug 28 16:09:28 2006 -0600
     3.3 @@ -172,7 +172,7 @@ fw_hypercall_ipi (struct pt_regs *regs)
     3.4  		vcpu_init_regs (targ);
     3.5  		vcpu_regs (targ)->cr_iip = d->arch.sal_data->boot_rdv_ip;
     3.6  		vcpu_regs (targ)->r1 = d->arch.sal_data->boot_rdv_r1;
     3.7 -		vcpu_regs (targ)->b0 = d->arch.sal_return_addr;
     3.8 +		vcpu_regs (targ)->b0 = FW_HYPERCALL_SAL_RETURN_PADDR;
     3.9  
    3.10  		if (test_and_clear_bit(_VCPUF_down,
    3.11  				       &targ->vcpu_flags)) {
     4.1 --- a/xen/include/asm-ia64/dom_fw.h	Mon Aug 28 14:09:31 2006 -0600
     4.2 +++ b/xen/include/asm-ia64/dom_fw.h	Mon Aug 28 16:09:28 2006 -0600
     4.3 @@ -7,6 +7,11 @@
     4.4  
     4.5  #include <linux/efi.h>
     4.6  
     4.7 +/* Portion of guest physical memory space reserved for PAL/SAL/EFI/ACPI
     4.8 +   data and code.  */
     4.9 +#define FW_BASE_PADDR		0x0000UL
    4.10 +#define FW_END_PADDR		0x3000UL
    4.11 +
    4.12  /* This is used to determined the portion of a domain's metaphysical memory
    4.13     space reserved for the hypercall patch table. */
    4.14  /* Map:
    4.15 @@ -20,6 +25,15 @@
    4.16  #define	FW_HYPERCALL_END_PADDR  0X1000UL
    4.17  #define	FW_HYPERCALL_PADDR(index) (FW_HYPERCALL_BASE_PADDR + (16UL * index))
    4.18  
    4.19 +/* Base and end guest physical address of ACPI tables.  */
    4.20 +#define FW_ACPI_BASE_PADDR	0x1000UL
    4.21 +#define FW_ACPI_END_PADDR	0x2000UL
    4.22 +
    4.23 +/* Base and end guest physical address of EFI and SAL (non-ACPI) tables.  */
    4.24 +#define FW_TABLES_BASE_PADDR	0x2000UL
    4.25 +#define FW_TABLES_END_PADDR	0x3000UL
    4.26 +
    4.27 +
    4.28  /* Hypercalls number have a low part and a high part.
    4.29     The high part is the class (xen/pal/sal/efi).  */
    4.30  #define FW_HYPERCALL_NUM_MASK_HIGH	~0xffUL
     5.1 --- a/xen/include/asm-ia64/domain.h	Mon Aug 28 14:09:31 2006 -0600
     5.2 +++ b/xen/include/asm-ia64/domain.h	Mon Aug 28 16:09:28 2006 -0600
     5.3 @@ -118,8 +118,6 @@ struct arch_domain {
     5.4   
     5.5      /* Address of SAL emulator data  */
     5.6      struct xen_sal_data *sal_data;
     5.7 -    /* SAL return point.  */
     5.8 -    unsigned long sal_return_addr;
     5.9  
    5.10      /* Address of efi_runtime_services_t (placed in domain memory)  */
    5.11      void *efi_runtime;
     6.1 --- a/xen/include/asm-ia64/linux-xen/linux/efi.h	Mon Aug 28 14:09:31 2006 -0600
     6.2 +++ b/xen/include/asm-ia64/linux-xen/linux/efi.h	Mon Aug 28 16:09:28 2006 -0600
     6.3 @@ -293,10 +293,6 @@ extern void *efi_get_pal_addr (void);
     6.4  extern void efi_map_pal_code (void);
     6.5  extern void efi_map_memmap(void);
     6.6  extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
     6.7 -#ifdef XEN
     6.8 -typedef int (*efi_walk_type_callback_t)(efi_memory_desc_t *md, void *arg);
     6.9 -extern void efi_memmap_walk_type(u32 type, efi_walk_type_callback_t callback, void *arg);
    6.10 -#endif
    6.11  extern void efi_gettimeofday (struct timespec *ts);
    6.12  extern void efi_enter_virtual_mode (void);	/* switch EFI to virtual mode, if possible */
    6.13  extern u64 efi_get_iobase (void);