direct-io.hg

changeset 10383:4e78528e3480

[IA64] merge efi_emul.c into fw_emul.c and clean up

Merge efi_emul.c into fw_emul.c
Clean up: replace some goto with return.
Declare translate_mpa_to_imva in mm.h and as void *.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Tue Jun 06 09:11:25 2006 -0600 (2006-06-06)
parents 6a49e02dc169
children 64b118cddb9a
files xen/arch/ia64/vmx/vmx_hypercall.c xen/arch/ia64/xen/Makefile xen/arch/ia64/xen/dom_fw.c xen/arch/ia64/xen/efi_emul.c xen/arch/ia64/xen/fw_emul.c xen/arch/ia64/xen/mm.c xen/include/asm-ia64/mm.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmx_hypercall.c	Tue Jun 06 09:06:19 2006 -0600
     1.2 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c	Tue Jun 06 09:11:25 2006 -0600
     1.3 @@ -36,7 +36,6 @@
     1.4  #include <xen/domain.h>
     1.5  
     1.6  extern long do_sched_op_compat(int cmd, unsigned long arg);
     1.7 -extern unsigned long domain_mpa_to_imva(struct domain *,unsigned long mpaddr);
     1.8  
     1.9  void hyper_not_support(void)
    1.10  {
     2.1 --- a/xen/arch/ia64/xen/Makefile	Tue Jun 06 09:06:19 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/Makefile	Tue Jun 06 09:11:25 2006 -0600
     2.3 @@ -2,7 +2,6 @@ obj-y += acpi.o
     2.4  obj-y += dom0_ops.o
     2.5  obj-y += domain.o
     2.6  obj-y += dom_fw.o
     2.7 -obj-y += efi_emul.o
     2.8  obj-y += fw_emul.o
     2.9  obj-y += hpsimserial.o
    2.10  obj-y += hypercall.o
     3.1 --- a/xen/arch/ia64/xen/dom_fw.c	Tue Jun 06 09:06:19 2006 -0600
     3.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Tue Jun 06 09:11:25 2006 -0600
     3.3 @@ -25,7 +25,6 @@
     3.4  #include <asm/dom_fw.h>
     3.5  
     3.6  static struct ia64_boot_param *dom_fw_init(struct domain *, const char *,int,char *,int);
     3.7 -extern unsigned long domain_mpa_to_imva(struct domain *,unsigned long mpaddr);
     3.8  extern struct domain *dom0;
     3.9  extern unsigned long dom0_start;
    3.10  
    3.11 @@ -77,8 +76,8 @@ static void dom_fpswa_hypercall_patch(st
    3.12  #endif
    3.13  	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, entry_paddr);
    3.14  	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, patch_paddr);
    3.15 -	entry_imva = (unsigned long *) domain_mpa_to_imva(d, entry_paddr);
    3.16 -	patch_imva = (unsigned long *) domain_mpa_to_imva(d, patch_paddr);
    3.17 +	entry_imva = domain_mpa_to_imva(d, entry_paddr);
    3.18 +	patch_imva = domain_mpa_to_imva(d, patch_paddr);
    3.19  
    3.20  	*entry_imva++ = patch_paddr;
    3.21  	*entry_imva   = 0;
    3.22 @@ -94,7 +93,7 @@ static void dom_efi_hypercall_patch(stru
    3.23  	if (d == dom0) paddr += dom0_start;
    3.24  #endif
    3.25  	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, paddr);
    3.26 -	imva = (unsigned long *) domain_mpa_to_imva(d, paddr);
    3.27 +	imva = domain_mpa_to_imva(d, paddr);
    3.28  	build_hypercall_bundle(imva, d->arch.breakimm, hypercall, 1);
    3.29  }
    3.30  
    3.31 @@ -104,7 +103,7 @@ static void dom_fw_hypercall_patch(struc
    3.32  	unsigned long *imva;
    3.33  
    3.34  	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, paddr);
    3.35 -	imva = (unsigned long *) domain_mpa_to_imva(d, paddr);
    3.36 +	imva = domain_mpa_to_imva(d, paddr);
    3.37  	build_hypercall_bundle(imva, d->arch.breakimm, hypercall, ret);
    3.38  }
    3.39  
    3.40 @@ -113,7 +112,7 @@ static void dom_fw_pal_hypercall_patch(s
    3.41  	unsigned long *imva;
    3.42  
    3.43  	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, paddr);
    3.44 -	imva = (unsigned long *) domain_mpa_to_imva(d, paddr);
    3.45 +	imva = domain_mpa_to_imva(d, paddr);
    3.46  	build_pal_hypercall_bundles(imva, d->arch.breakimm, FW_HYPERCALL_PAL_CALL);
    3.47  }
    3.48  
    3.49 @@ -130,7 +129,7 @@ unsigned long dom_fw_setup(struct domain
    3.50  	if (d == dom0) dom_fw_base_mpa += dom0_start;
    3.51  #endif
    3.52  	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, dom_fw_base_mpa);
    3.53 -	imva_fw_base = domain_mpa_to_imva(d, dom_fw_base_mpa);
    3.54 +	imva_fw_base = (unsigned long) domain_mpa_to_imva(d, dom_fw_base_mpa);
    3.55  	bp = dom_fw_init(d, args, arglen, (char *) imva_fw_base, PAGE_SIZE);
    3.56  	return dom_pa((unsigned long) bp);
    3.57  }
     4.1 --- a/xen/arch/ia64/xen/efi_emul.c	Tue Jun 06 09:06:19 2006 -0600
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,189 +0,0 @@
     4.4 -/*
     4.5 - * efi_emul.c:
     4.6 - *
     4.7 - * This program is free software; you can redistribute it and/or modify it
     4.8 - * under the terms and conditions of the GNU General Public License,
     4.9 - * version 2, as published by the Free Software Foundation.
    4.10 - *
    4.11 - * This program is distributed in the hope it will be useful, but WITHOUT
    4.12 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.13 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    4.14 - * more details.
    4.15 - *
    4.16 - * You should have received a copy of the GNU General Public License along with
    4.17 - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    4.18 - * Place - Suite 330, Boston, MA 02111-1307 USA.
    4.19 - *
    4.20 - */
    4.21 -
    4.22 -#include <xen/config.h>
    4.23 -#include <xen/compile.h>
    4.24 -#include <asm/pgalloc.h>
    4.25 -#include <asm/vcpu.h>
    4.26 -#include <asm/dom_fw.h>
    4.27 -#include <asm/fpswa.h>
    4.28 -#include <public/sched.h>
    4.29 -
    4.30 -extern unsigned long translate_domain_mpaddr(unsigned long);
    4.31 -extern unsigned long domain_mpa_to_imva(struct domain *,unsigned long mpaddr);
    4.32 -
    4.33 -// given a current domain (virtual or metaphysical) address, return the virtual address
    4.34 -static unsigned long
    4.35 -efi_translate_domain_addr(unsigned long domain_addr, IA64FAULT *fault)
    4.36 -{
    4.37 -	struct vcpu *v = current;
    4.38 -	unsigned long mpaddr = domain_addr;
    4.39 -	*fault = IA64_NO_FAULT;
    4.40 -
    4.41 -	if (v->domain->arch.efi_virt_mode) {
    4.42 -		*fault = vcpu_tpa(v, domain_addr, &mpaddr);
    4.43 -		if (*fault != IA64_NO_FAULT) return 0;
    4.44 -	}
    4.45 -
    4.46 -	return ((unsigned long) __va(translate_domain_mpaddr(mpaddr)));
    4.47 -}
    4.48 -
    4.49 -static efi_status_t
    4.50 -efi_emulate_get_time(
    4.51 -	unsigned long tv_addr, unsigned long tc_addr,
    4.52 -	IA64FAULT *fault)
    4.53 -{
    4.54 -	unsigned long tv = 0, tc = 0;
    4.55 -	efi_status_t status;
    4.56 -
    4.57 -	//printf("efi_get_time(%016lx,%016lx) called\n", tv_addr, tc_addr);
    4.58 -	tv = efi_translate_domain_addr(tv_addr, fault);
    4.59 -	if (*fault != IA64_NO_FAULT) return 0;
    4.60 -	if (tc_addr) {
    4.61 -		tc = efi_translate_domain_addr(tc_addr, fault);
    4.62 -		if (*fault != IA64_NO_FAULT) return 0;
    4.63 -	}
    4.64 -	//printf("efi_get_time(%016lx,%016lx) translated to xen virtual address\n", tv, tc);
    4.65 -	status = (*efi.get_time)((efi_time_t *) tv, (efi_time_cap_t *) tc);
    4.66 -	//printf("efi_get_time returns %lx\n", status);
    4.67 -	return status;
    4.68 -}
    4.69 -
    4.70 -static efi_status_t
    4.71 -efi_emulate_set_virtual_address_map(
    4.72 -	unsigned long memory_map_size, unsigned long descriptor_size,
    4.73 -	u32 descriptor_version, efi_memory_desc_t *virtual_map)
    4.74 -{
    4.75 -	void *efi_map_start, *efi_map_end, *p;
    4.76 -	efi_memory_desc_t entry, *md = &entry;
    4.77 -	u64 efi_desc_size;
    4.78 -
    4.79 -	unsigned long *vfn;
    4.80 -	struct domain *d = current->domain;
    4.81 -	efi_runtime_services_t *efi_runtime = d->arch.efi_runtime;
    4.82 -	fpswa_interface_t *fpswa_inf = d->arch.fpswa_inf;
    4.83 -
    4.84 -	if (descriptor_version != EFI_MEMDESC_VERSION) {
    4.85 -		printf ("efi_emulate_set_virtual_address_map: memory descriptor version unmatched\n");
    4.86 -		return EFI_INVALID_PARAMETER;
    4.87 -	}
    4.88 -
    4.89 -	if (descriptor_size != sizeof(efi_memory_desc_t)) {
    4.90 -		printf ("efi_emulate_set_virtual_address_map: memory descriptor size unmatched\n");
    4.91 -		return EFI_INVALID_PARAMETER;
    4.92 -	}
    4.93 -
    4.94 -	if (d->arch.efi_virt_mode) return EFI_UNSUPPORTED;
    4.95 -
    4.96 -	efi_map_start = virtual_map;
    4.97 -	efi_map_end   = efi_map_start + memory_map_size;
    4.98 -	efi_desc_size = sizeof(efi_memory_desc_t);
    4.99 -
   4.100 -	for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
   4.101 -		if (copy_from_user(&entry, p, sizeof(efi_memory_desc_t))) {
   4.102 -			printf ("efi_emulate_set_virtual_address_map: copy_from_user() fault. addr=0x%p\n", p);
   4.103 -			return EFI_UNSUPPORTED;
   4.104 -		}
   4.105 -
   4.106 -		/* skip over non-PAL_CODE memory descriptors; EFI_RUNTIME is included in PAL_CODE. */
   4.107 -                if (md->type != EFI_PAL_CODE)
   4.108 -                        continue;
   4.109 -
   4.110 -#define EFI_HYPERCALL_PATCH_TO_VIRT(tgt,call) \
   4.111 -	do { \
   4.112 -		vfn = (unsigned long *) domain_mpa_to_imva(d, tgt); \
   4.113 -		*vfn++ = FW_HYPERCALL_##call##_INDEX * 16UL + md->virt_addr; \
   4.114 -		*vfn++ = 0; \
   4.115 -	} while (0)
   4.116 -
   4.117 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_time,EFI_GET_TIME);
   4.118 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_time,EFI_SET_TIME);
   4.119 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_wakeup_time,EFI_GET_WAKEUP_TIME);
   4.120 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_wakeup_time,EFI_SET_WAKEUP_TIME);
   4.121 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_virtual_address_map,EFI_SET_VIRTUAL_ADDRESS_MAP);
   4.122 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_variable,EFI_GET_VARIABLE);
   4.123 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_next_variable,EFI_GET_NEXT_VARIABLE);
   4.124 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_variable,EFI_SET_VARIABLE);
   4.125 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_next_high_mono_count,EFI_GET_NEXT_HIGH_MONO_COUNT);
   4.126 -		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->reset_system,EFI_RESET_SYSTEM);
   4.127 -
   4.128 -		vfn = (unsigned long *) domain_mpa_to_imva(d, (unsigned long) fpswa_inf->fpswa);
   4.129 -		*vfn++ = FW_HYPERCALL_FPSWA_PATCH_INDEX * 16UL + md->virt_addr;
   4.130 -		*vfn   = 0;
   4.131 -		fpswa_inf->fpswa = (void *) (FW_HYPERCALL_FPSWA_ENTRY_INDEX * 16UL + md->virt_addr);
   4.132 -		break;
   4.133 -	}
   4.134 -
   4.135 -	/* The virtual address map has been applied. */
   4.136 -	d->arch.efi_virt_mode = 1;
   4.137 -
   4.138 -	return EFI_SUCCESS;
   4.139 -}
   4.140 -
   4.141 -efi_status_t
   4.142 -efi_emulator (struct pt_regs *regs, IA64FAULT *fault)
   4.143 -{
   4.144 -	struct vcpu *v = current;
   4.145 -	efi_status_t status;
   4.146 -
   4.147 -	*fault = IA64_NO_FAULT;
   4.148 -
   4.149 -	switch (regs->r2) {
   4.150 -	    case FW_HYPERCALL_EFI_RESET_SYSTEM:
   4.151 -		printf("efi.reset_system called ");
   4.152 -		if (current->domain == dom0) {
   4.153 -			printf("(by dom0)\n ");
   4.154 -			(*efi.reset_system)(EFI_RESET_WARM,0,0,NULL);
   4.155 -		} else {
   4.156 -			printf("\n");
   4.157 -			domain_shutdown (current->domain, SHUTDOWN_reboot);
   4.158 -		}
   4.159 -		status = EFI_UNSUPPORTED;
   4.160 -		break;
   4.161 -	    case FW_HYPERCALL_EFI_GET_TIME:
   4.162 -		status = efi_emulate_get_time (
   4.163 -				vcpu_get_gr(v,32),
   4.164 -				vcpu_get_gr(v,33),
   4.165 -				fault);
   4.166 -		break;
   4.167 -	    case FW_HYPERCALL_EFI_SET_VIRTUAL_ADDRESS_MAP:
   4.168 -		status = efi_emulate_set_virtual_address_map (
   4.169 -				vcpu_get_gr(v,32),
   4.170 -				vcpu_get_gr(v,33),
   4.171 - 				(u32) vcpu_get_gr(v,34),
   4.172 -				(efi_memory_desc_t *) vcpu_get_gr(v,35));
   4.173 -		break;
   4.174 -	    case FW_HYPERCALL_EFI_SET_TIME:
   4.175 -	    case FW_HYPERCALL_EFI_GET_WAKEUP_TIME:
   4.176 -	    case FW_HYPERCALL_EFI_SET_WAKEUP_TIME:
   4.177 -		// FIXME: need fixes in efi.h from 2.6.9
   4.178 -	    case FW_HYPERCALL_EFI_GET_VARIABLE:
   4.179 -		// FIXME: need fixes in efi.h from 2.6.9
   4.180 -	    case FW_HYPERCALL_EFI_GET_NEXT_VARIABLE:
   4.181 -	    case FW_HYPERCALL_EFI_SET_VARIABLE:
   4.182 -	    case FW_HYPERCALL_EFI_GET_NEXT_HIGH_MONO_COUNT:
   4.183 -		// FIXME: need fixes in efi.h from 2.6.9
   4.184 -		status = EFI_UNSUPPORTED;
   4.185 -		break;
   4.186 -	    default:
   4.187 -		printf("unknown ia64 fw hypercall %lx\n", regs->r2);
   4.188 -		status = EFI_UNSUPPORTED;
   4.189 -	}
   4.190 -
   4.191 -	return status;
   4.192 -}
     5.1 --- a/xen/arch/ia64/xen/fw_emul.c	Tue Jun 06 09:06:19 2006 -0600
     5.2 +++ b/xen/arch/ia64/xen/fw_emul.c	Tue Jun 06 09:11:25 2006 -0600
     5.3 @@ -1,3 +1,20 @@
     5.4 +/*
     5.5 + * fw_emul.c:
     5.6 + *
     5.7 + * This program is free software; you can redistribute it and/or modify it
     5.8 + * under the terms and conditions of the GNU General Public License,
     5.9 + * version 2, as published by the Free Software Foundation.
    5.10 + *
    5.11 + * This program is distributed in the hope it will be useful, but WITHOUT
    5.12 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.13 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    5.14 + * more details.
    5.15 + *
    5.16 + * You should have received a copy of the GNU General Public License along with
    5.17 + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    5.18 + * Place - Suite 330, Boston, MA 02111-1307 USA.
    5.19 + *
    5.20 + */
    5.21  #include <xen/config.h>
    5.22  #include <asm/system.h>
    5.23  #include <asm/pgalloc.h>
    5.24 @@ -340,6 +357,167 @@ xen_pal_emulator(unsigned long index, u6
    5.25  	return ((struct ia64_pal_retval) {status, r9, r10, r11});
    5.26  }
    5.27  
    5.28 +// given a current domain (virtual or metaphysical) address, return the virtual address
    5.29 +static unsigned long
    5.30 +efi_translate_domain_addr(unsigned long domain_addr, IA64FAULT *fault)
    5.31 +{
    5.32 +	struct vcpu *v = current;
    5.33 +	unsigned long mpaddr = domain_addr;
    5.34 +	*fault = IA64_NO_FAULT;
    5.35 +
    5.36 +	if (v->domain->arch.efi_virt_mode) {
    5.37 +		*fault = vcpu_tpa(v, domain_addr, &mpaddr);
    5.38 +		if (*fault != IA64_NO_FAULT) return 0;
    5.39 +	}
    5.40 +
    5.41 +	return ((unsigned long) __va(translate_domain_mpaddr(mpaddr)));
    5.42 +}
    5.43 +
    5.44 +static efi_status_t
    5.45 +efi_emulate_get_time(
    5.46 +	unsigned long tv_addr, unsigned long tc_addr,
    5.47 +	IA64FAULT *fault)
    5.48 +{
    5.49 +	unsigned long tv = 0, tc = 0;
    5.50 +	efi_status_t status;
    5.51 +
    5.52 +	//printf("efi_get_time(%016lx,%016lx) called\n", tv_addr, tc_addr);
    5.53 +	tv = efi_translate_domain_addr(tv_addr, fault);
    5.54 +	if (*fault != IA64_NO_FAULT) return 0;
    5.55 +	if (tc_addr) {
    5.56 +		tc = efi_translate_domain_addr(tc_addr, fault);
    5.57 +		if (*fault != IA64_NO_FAULT) return 0;
    5.58 +	}
    5.59 +	//printf("efi_get_time(%016lx,%016lx) translated to xen virtual address\n", tv, tc);
    5.60 +	status = (*efi.get_time)((efi_time_t *) tv, (efi_time_cap_t *) tc);
    5.61 +	//printf("efi_get_time returns %lx\n", status);
    5.62 +	return status;
    5.63 +}
    5.64 +
    5.65 +static efi_status_t
    5.66 +efi_emulate_set_virtual_address_map(
    5.67 +	unsigned long memory_map_size, unsigned long descriptor_size,
    5.68 +	u32 descriptor_version, efi_memory_desc_t *virtual_map)
    5.69 +{
    5.70 +	void *efi_map_start, *efi_map_end, *p;
    5.71 +	efi_memory_desc_t entry, *md = &entry;
    5.72 +	u64 efi_desc_size;
    5.73 +
    5.74 +	unsigned long *vfn;
    5.75 +	struct domain *d = current->domain;
    5.76 +	efi_runtime_services_t *efi_runtime = d->arch.efi_runtime;
    5.77 +	fpswa_interface_t *fpswa_inf = d->arch.fpswa_inf;
    5.78 +
    5.79 +	if (descriptor_version != EFI_MEMDESC_VERSION) {
    5.80 +		printf ("efi_emulate_set_virtual_address_map: memory descriptor version unmatched\n");
    5.81 +		return EFI_INVALID_PARAMETER;
    5.82 +	}
    5.83 +
    5.84 +	if (descriptor_size != sizeof(efi_memory_desc_t)) {
    5.85 +		printf ("efi_emulate_set_virtual_address_map: memory descriptor size unmatched\n");
    5.86 +		return EFI_INVALID_PARAMETER;
    5.87 +	}
    5.88 +
    5.89 +	if (d->arch.efi_virt_mode) return EFI_UNSUPPORTED;
    5.90 +
    5.91 +	efi_map_start = virtual_map;
    5.92 +	efi_map_end   = efi_map_start + memory_map_size;
    5.93 +	efi_desc_size = sizeof(efi_memory_desc_t);
    5.94 +
    5.95 +	for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
    5.96 +		if (copy_from_user(&entry, p, sizeof(efi_memory_desc_t))) {
    5.97 +			printf ("efi_emulate_set_virtual_address_map: copy_from_user() fault. addr=0x%p\n", p);
    5.98 +			return EFI_UNSUPPORTED;
    5.99 +		}
   5.100 +
   5.101 +		/* skip over non-PAL_CODE memory descriptors; EFI_RUNTIME is included in PAL_CODE. */
   5.102 +                if (md->type != EFI_PAL_CODE)
   5.103 +                        continue;
   5.104 +
   5.105 +#define EFI_HYPERCALL_PATCH_TO_VIRT(tgt,call) \
   5.106 +	do { \
   5.107 +		vfn = (unsigned long *) domain_mpa_to_imva(d, tgt); \
   5.108 +		*vfn++ = FW_HYPERCALL_##call##_INDEX * 16UL + md->virt_addr; \
   5.109 +		*vfn++ = 0; \
   5.110 +	} while (0)
   5.111 +
   5.112 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_time,EFI_GET_TIME);
   5.113 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_time,EFI_SET_TIME);
   5.114 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_wakeup_time,EFI_GET_WAKEUP_TIME);
   5.115 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_wakeup_time,EFI_SET_WAKEUP_TIME);
   5.116 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_virtual_address_map,EFI_SET_VIRTUAL_ADDRESS_MAP);
   5.117 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_variable,EFI_GET_VARIABLE);
   5.118 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_next_variable,EFI_GET_NEXT_VARIABLE);
   5.119 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->set_variable,EFI_SET_VARIABLE);
   5.120 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->get_next_high_mono_count,EFI_GET_NEXT_HIGH_MONO_COUNT);
   5.121 +		EFI_HYPERCALL_PATCH_TO_VIRT(efi_runtime->reset_system,EFI_RESET_SYSTEM);
   5.122 +
   5.123 +		vfn = (unsigned long *) domain_mpa_to_imva(d, (unsigned long) fpswa_inf->fpswa);
   5.124 +		*vfn++ = FW_HYPERCALL_FPSWA_PATCH_INDEX * 16UL + md->virt_addr;
   5.125 +		*vfn   = 0;
   5.126 +		fpswa_inf->fpswa = (void *) (FW_HYPERCALL_FPSWA_ENTRY_INDEX * 16UL + md->virt_addr);
   5.127 +		break;
   5.128 +	}
   5.129 +
   5.130 +	/* The virtual address map has been applied. */
   5.131 +	d->arch.efi_virt_mode = 1;
   5.132 +
   5.133 +	return EFI_SUCCESS;
   5.134 +}
   5.135 +
   5.136 +efi_status_t
   5.137 +efi_emulator (struct pt_regs *regs, IA64FAULT *fault)
   5.138 +{
   5.139 +	struct vcpu *v = current;
   5.140 +	efi_status_t status;
   5.141 +
   5.142 +	*fault = IA64_NO_FAULT;
   5.143 +
   5.144 +	switch (regs->r2) {
   5.145 +	    case FW_HYPERCALL_EFI_RESET_SYSTEM:
   5.146 +		printf("efi.reset_system called ");
   5.147 +		if (current->domain == dom0) {
   5.148 +			printf("(by dom0)\n ");
   5.149 +			(*efi.reset_system)(EFI_RESET_WARM,0,0,NULL);
   5.150 +		} else {
   5.151 +			printf("\n");
   5.152 +			domain_shutdown (current->domain, SHUTDOWN_reboot);
   5.153 +		}
   5.154 +		status = EFI_UNSUPPORTED;
   5.155 +		break;
   5.156 +	    case FW_HYPERCALL_EFI_GET_TIME:
   5.157 +		status = efi_emulate_get_time (
   5.158 +				vcpu_get_gr(v,32),
   5.159 +				vcpu_get_gr(v,33),
   5.160 +				fault);
   5.161 +		break;
   5.162 +	    case FW_HYPERCALL_EFI_SET_VIRTUAL_ADDRESS_MAP:
   5.163 +		status = efi_emulate_set_virtual_address_map (
   5.164 +				vcpu_get_gr(v,32),
   5.165 +				vcpu_get_gr(v,33),
   5.166 + 				(u32) vcpu_get_gr(v,34),
   5.167 +				(efi_memory_desc_t *) vcpu_get_gr(v,35));
   5.168 +		break;
   5.169 +	    case FW_HYPERCALL_EFI_SET_TIME:
   5.170 +	    case FW_HYPERCALL_EFI_GET_WAKEUP_TIME:
   5.171 +	    case FW_HYPERCALL_EFI_SET_WAKEUP_TIME:
   5.172 +		// FIXME: need fixes in efi.h from 2.6.9
   5.173 +	    case FW_HYPERCALL_EFI_GET_VARIABLE:
   5.174 +		// FIXME: need fixes in efi.h from 2.6.9
   5.175 +	    case FW_HYPERCALL_EFI_GET_NEXT_VARIABLE:
   5.176 +	    case FW_HYPERCALL_EFI_SET_VARIABLE:
   5.177 +	    case FW_HYPERCALL_EFI_GET_NEXT_HIGH_MONO_COUNT:
   5.178 +		// FIXME: need fixes in efi.h from 2.6.9
   5.179 +		status = EFI_UNSUPPORTED;
   5.180 +		break;
   5.181 +	    default:
   5.182 +		printf("unknown ia64 fw hypercall %lx\n", regs->r2);
   5.183 +		status = EFI_UNSUPPORTED;
   5.184 +	}
   5.185 +
   5.186 +	return status;
   5.187 +}
   5.188 +
   5.189  void
   5.190  do_ssc(unsigned long ssc, struct pt_regs *regs)
   5.191  {
     6.1 --- a/xen/arch/ia64/xen/mm.c	Tue Jun 06 09:06:19 2006 -0600
     6.2 +++ b/xen/arch/ia64/xen/mm.c	Tue Jun 06 09:11:25 2006 -0600
     6.3 @@ -296,7 +296,6 @@ u64 translate_domain_pte(u64 pteval, u64
     6.4  			printk("translate_domain_pte: out-of-bounds dom0 mpaddr 0x%lx! itc=%lx...\n",
     6.5  				mpaddr, ia64_get_itc());
     6.6  			*/
     6.7 -			tdpfoo();
     6.8  		}
     6.9  	}
    6.10  	else if ((mpaddr >> PAGE_SHIFT) > d->max_pages) {
    6.11 @@ -310,7 +309,6 @@ u64 translate_domain_pte(u64 pteval, u64
    6.12  			       "vadr=0x%lx,pteval=0x%lx,itir=0x%lx\n",
    6.13  			       mpaddr, (unsigned long)d->max_pages<<PAGE_SHIFT,
    6.14  			       address, pteval, itir.itir);
    6.15 -		tdpfoo();
    6.16  	}
    6.17  #endif
    6.18  	pteval2 = lookup_domain_mpa(d,mpaddr);
    6.19 @@ -345,7 +343,6 @@ unsigned long translate_domain_mpaddr(un
    6.20  		if (mpaddr < dom0_start || mpaddr >= dom0_start + dom0_size) {
    6.21  			printk("translate_domain_mpaddr: out-of-bounds dom0 mpaddr 0x%lx! continuing...\n",
    6.22  				mpaddr);
    6.23 -			tdpfoo();
    6.24  		}
    6.25  	}
    6.26  #endif
    6.27 @@ -393,20 +390,17 @@ lookup_noalloc_domain_pte(struct domain*
    6.28      BUG_ON(mm->pgd == NULL);
    6.29      pgd = pgd_offset(mm, mpaddr);
    6.30      if (!pgd_present(*pgd))
    6.31 -        goto not_present;
    6.32 +        return NULL;
    6.33  
    6.34      pud = pud_offset(pgd, mpaddr);
    6.35      if (!pud_present(*pud))
    6.36 -        goto not_present;
    6.37 +        return NULL;
    6.38  
    6.39      pmd = pmd_offset(pud, mpaddr);
    6.40      if (!pmd_present(*pmd))
    6.41 -        goto not_present;
    6.42 +        return NULL;
    6.43  
    6.44      return pte_offset_map(pmd, mpaddr);
    6.45 -
    6.46 -not_present:
    6.47 -    return NULL;
    6.48  }
    6.49  
    6.50  #ifdef CONFIG_XEN_IA64_DOM0_VP
    6.51 @@ -421,20 +415,17 @@ lookup_noalloc_domain_pte_none(struct do
    6.52      BUG_ON(mm->pgd == NULL);
    6.53      pgd = pgd_offset(mm, mpaddr);
    6.54      if (pgd_none(*pgd))
    6.55 -        goto not_present;
    6.56 +        return NULL;
    6.57  
    6.58      pud = pud_offset(pgd, mpaddr);
    6.59      if (pud_none(*pud))
    6.60 -        goto not_present;
    6.61 +        return NULL;
    6.62  
    6.63      pmd = pmd_offset(pud, mpaddr);
    6.64      if (pmd_none(*pmd))
    6.65 -        goto not_present;
    6.66 +        return NULL;
    6.67  
    6.68      return pte_offset_map(pmd, mpaddr);
    6.69 -
    6.70 -not_present:
    6.71 -    return NULL;
    6.72  }
    6.73  
    6.74  unsigned long
    6.75 @@ -444,14 +435,12 @@ unsigned long
    6.76  
    6.77      pte = lookup_noalloc_domain_pte(d, mpaddr);
    6.78      if (pte == NULL)
    6.79 -        goto not_present;
    6.80 +        return INVALID_MFN;
    6.81  
    6.82      if (pte_present(*pte))
    6.83          return (pte->pte & _PFN_MASK);
    6.84      else if (VMX_DOMAIN(d->vcpu[0]))
    6.85          return GPFN_INV_MASK;
    6.86 -
    6.87 -not_present:
    6.88      return INVALID_MFN;
    6.89  }
    6.90  
    6.91 @@ -470,13 +459,6 @@ unsigned long
    6.92  }
    6.93  #endif
    6.94  
    6.95 -void mpafoo(unsigned long mpaddr)
    6.96 -{
    6.97 -    extern unsigned long privop_trace;
    6.98 -    if (mpaddr == 0x3800)
    6.99 -        privop_trace = 1;
   6.100 -}
   6.101 -
   6.102  unsigned long lookup_domain_mpa(struct domain *d, unsigned long mpaddr)
   6.103  {
   6.104      pte_t *pte;
   6.105 @@ -487,7 +469,6 @@ unsigned long lookup_domain_mpa(struct d
   6.106          if (mpaddr < dom0_start || mpaddr >= dom0_start + dom0_size) {
   6.107              //printk("lookup_domain_mpa: bad dom0 mpaddr 0x%lx!\n",mpaddr);
   6.108              //printk("lookup_domain_mpa: start=0x%lx,end=0x%lx!\n",dom0_start,dom0_start+dom0_size);
   6.109 -            mpafoo(mpaddr);
   6.110          }
   6.111          pteval = pfn_pte(mpaddr >> PAGE_SHIFT,
   6.112              __pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX));
   6.113 @@ -511,7 +492,6 @@ unsigned long lookup_domain_mpa(struct d
   6.114      else
   6.115          printk("%s: bad mpa 0x%lx (=> 0x%lx)\n", __func__,
   6.116                 mpaddr, (unsigned long)d->max_pages << PAGE_SHIFT);
   6.117 -    mpafoo(mpaddr);
   6.118  
   6.119      //XXX This is a work around until the emulation memory access to a region
   6.120      //    where memory or device are attached is implemented.
   6.121 @@ -520,7 +500,7 @@ unsigned long lookup_domain_mpa(struct d
   6.122  
   6.123  // FIXME: ONLY USE FOR DOMAIN PAGE_SIZE == PAGE_SIZE
   6.124  #if 1
   6.125 -unsigned long domain_mpa_to_imva(struct domain *d, unsigned long mpaddr)
   6.126 +void *domain_mpa_to_imva(struct domain *d, unsigned long mpaddr)
   6.127  {
   6.128      unsigned long pte = lookup_domain_mpa(d,mpaddr);
   6.129      unsigned long imva;
   6.130 @@ -528,14 +508,14 @@ unsigned long domain_mpa_to_imva(struct 
   6.131      pte &= _PAGE_PPN_MASK;
   6.132      imva = (unsigned long) __va(pte);
   6.133      imva |= mpaddr & ~PAGE_MASK;
   6.134 -    return(imva);
   6.135 +    return (void*)imva;
   6.136  }
   6.137  #else
   6.138 -unsigned long domain_mpa_to_imva(struct domain *d, unsigned long mpaddr)
   6.139 +void *domain_mpa_to_imva(struct domain *d, unsigned long mpaddr)
   6.140  {
   6.141      unsigned long imva = __gpa_to_mpa(d, mpaddr);
   6.142  
   6.143 -    return __va(imva);
   6.144 +    return (void *)__va(imva);
   6.145  }
   6.146  #endif
   6.147  
   6.148 @@ -842,17 +822,13 @@ unsigned long
   6.149  dom0vp_zap_physmap(struct domain *d, unsigned long gpfn,
   6.150                     unsigned int extent_order)
   6.151  {
   6.152 -    unsigned long ret = 0;
   6.153      if (extent_order != 0) {
   6.154          //XXX
   6.155 -        ret = -ENOSYS;
   6.156 -        goto out;
   6.157 +        return -ENOSYS;
   6.158      }
   6.159  
   6.160      zap_domain_page_one(d, gpfn << PAGE_SHIFT, 1);
   6.161 -
   6.162 -out:
   6.163 -    return ret;
   6.164 +    return 0;
   6.165  }
   6.166  
   6.167  unsigned long
   6.168 @@ -875,8 +851,7 @@ dom0vp_add_physmap(struct domain* d, uns
   6.169              DPRINTK("d 0x%p domid %d "
   6.170                      "pgfn 0x%lx mfn 0x%lx flags 0x%lx domid %d\n",
   6.171                      d, d->domain_id, gpfn, mfn, flags, domid);
   6.172 -            error = -ESRCH;
   6.173 -            goto out0;
   6.174 +            return -ESRCH;
   6.175          }
   6.176          BUG_ON(rd == NULL);
   6.177          get_knownalive_domain(rd);
   6.178 @@ -895,7 +870,6 @@ dom0vp_add_physmap(struct domain* d, uns
   6.179      //don't update p2m table because this page belongs to rd, not d.
   6.180  out1:
   6.181      put_domain(rd);
   6.182 -out0:
   6.183      return error;
   6.184  }
   6.185  
     7.1 --- a/xen/include/asm-ia64/mm.h	Tue Jun 06 09:06:19 2006 -0600
     7.2 +++ b/xen/include/asm-ia64/mm.h	Tue Jun 06 09:11:25 2006 -0600
     7.3 @@ -429,6 +429,7 @@ extern void __assign_domain_page(struct 
     7.4  extern void assign_domain_page(struct domain *d, unsigned long mpaddr, unsigned long physaddr);
     7.5  extern void assign_domain_io_page(struct domain *d, unsigned long mpaddr, unsigned long flags);
     7.6  extern unsigned long lookup_domain_mpa(struct domain *d, unsigned long mpaddr);
     7.7 +extern void *domain_mpa_to_imva(struct domain *d, unsigned long mpaddr);
     7.8  
     7.9  #ifdef CONFIG_XEN_IA64_DOM0_VP
    7.10  extern unsigned long assign_domain_mmio_page(struct domain *d, unsigned long mpaddr, unsigned long size);