ia64/xen-unstable

changeset 11044:5becaaabd335

[IA64] efibootmgr support

This patch supports the efibootmgr on Domain-0.
This patch adds the following EFI runtime service emulations
for the efibootmgr support.
- GetVariable
- GetNextVariableName
- SetVariable

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author awilliam@xenbuild.aw
date Wed Aug 16 10:40:17 2006 -0600 (2006-08-16)
parents 45cd04201495
children 8c6bb45901e7
files xen/arch/ia64/xen/fw_emul.c
line diff
     1.1 --- a/xen/arch/ia64/xen/fw_emul.c	Wed Aug 16 10:21:13 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/fw_emul.c	Wed Aug 16 10:40:17 2006 -0600
     1.3 @@ -420,6 +420,141 @@ efi_emulate_get_time(
     1.4  }
     1.5  
     1.6  static efi_status_t
     1.7 +efi_emulate_get_variable(
     1.8 +	unsigned long name_addr, unsigned long vendor_addr,
     1.9 +	unsigned long attr_addr, unsigned long data_size_addr,
    1.10 +	unsigned long data_addr, IA64FAULT *fault)
    1.11 +{
    1.12 +	unsigned long name, vendor, attr, data_size, data;
    1.13 +	struct page_info *name_page = NULL, *vendor_page = NULL,
    1.14 +	                 *attr_page = NULL, *data_size_page = NULL,
    1.15 +	                 *data_page = NULL;
    1.16 +	efi_status_t status = 0;
    1.17 +
    1.18 +	if (current->domain != dom0)
    1.19 +		return EFI_UNSUPPORTED;
    1.20 +
    1.21 +	name = efi_translate_domain_addr(name_addr, fault, &name_page);
    1.22 +	if (*fault != IA64_NO_FAULT)
    1.23 +		goto errout;
    1.24 +	vendor = efi_translate_domain_addr(vendor_addr, fault, &vendor_page);
    1.25 +	if (*fault != IA64_NO_FAULT)
    1.26 +		goto errout;
    1.27 +	data_size = efi_translate_domain_addr(data_size_addr, fault,
    1.28 +	                                      &data_size_page);
    1.29 +	if (*fault != IA64_NO_FAULT)
    1.30 +		goto errout;
    1.31 +	data = efi_translate_domain_addr(data_addr, fault, &data_page);
    1.32 +	if (*fault != IA64_NO_FAULT)
    1.33 +		goto errout;
    1.34 +	if (attr_addr) {
    1.35 +		attr = efi_translate_domain_addr(attr_addr, fault, &attr_page);
    1.36 +		if (*fault != IA64_NO_FAULT)
    1.37 +			goto errout;
    1.38 +	}
    1.39 +
    1.40 +	status = (*efi.get_variable)((efi_char16_t *)name,
    1.41 +	                             (efi_guid_t *)vendor,
    1.42 +	                             (u32 *)attr,
    1.43 +	                             (unsigned long *)data_size,
    1.44 +	                             (void *)data);
    1.45 +
    1.46 +errout:
    1.47 +	if (name_page != NULL)
    1.48 +		put_page(name_page);
    1.49 +	if (vendor_page != NULL)
    1.50 +		put_page(vendor_page);
    1.51 +	if (attr_page != NULL)
    1.52 +		put_page(attr_page);
    1.53 +	if (data_size_page != NULL)
    1.54 +		put_page(data_size_page);
    1.55 +	if (data_page != NULL)
    1.56 +		put_page(data_page);
    1.57 +
    1.58 +	return status;
    1.59 +}
    1.60 +
    1.61 +static efi_status_t
    1.62 +efi_emulate_get_next_variable(
    1.63 +	unsigned long name_size_addr, unsigned long name_addr,
    1.64 +	unsigned long vendor_addr, IA64FAULT *fault)
    1.65 +{
    1.66 +	unsigned long name_size, name, vendor;
    1.67 +	struct page_info *name_size_page = NULL, *name_page = NULL,
    1.68 +	                 *vendor_page = NULL;
    1.69 +	efi_status_t status = 0;
    1.70 +
    1.71 +	if (current->domain != dom0)
    1.72 +		return EFI_UNSUPPORTED;
    1.73 +
    1.74 +	name_size = efi_translate_domain_addr(name_size_addr, fault,
    1.75 +	                                      &name_size_page);
    1.76 +	if (*fault != IA64_NO_FAULT)
    1.77 +		goto errout;
    1.78 +	name = efi_translate_domain_addr(name_addr, fault, &name_page);
    1.79 +	if (*fault != IA64_NO_FAULT)
    1.80 +		goto errout;
    1.81 +	vendor = efi_translate_domain_addr(vendor_addr, fault, &vendor_page);
    1.82 +	if (*fault != IA64_NO_FAULT)
    1.83 +		goto errout;
    1.84 +
    1.85 +	status = (*efi.get_next_variable)((unsigned long *)name_size,
    1.86 +	                                  (efi_char16_t *)name,
    1.87 +	                                  (efi_guid_t *)vendor);
    1.88 +
    1.89 +errout:
    1.90 +	if (name_size_page != NULL)
    1.91 +		put_page(name_size_page);
    1.92 +	if (name_page != NULL)
    1.93 +		put_page(name_page);
    1.94 +	if (vendor_page != NULL)
    1.95 +		put_page(vendor_page);
    1.96 +
    1.97 +	return status;
    1.98 +}
    1.99 +
   1.100 +static efi_status_t
   1.101 +efi_emulate_set_variable(
   1.102 +	unsigned long name_addr, unsigned long vendor_addr, 
   1.103 +	unsigned long attr, unsigned long data_size, 
   1.104 +	unsigned long data_addr, IA64FAULT *fault)
   1.105 +{
   1.106 +	unsigned long name, vendor, data;
   1.107 +	struct page_info *name_page = NULL, *vendor_page = NULL,
   1.108 +	                 *data_page = NULL;
   1.109 +	efi_status_t status = 0;
   1.110 +
   1.111 +	if (current->domain != dom0)
   1.112 +		return EFI_UNSUPPORTED;
   1.113 +
   1.114 +	name = efi_translate_domain_addr(name_addr, fault, &name_page);
   1.115 +	if (*fault != IA64_NO_FAULT)
   1.116 +		goto errout;
   1.117 +	vendor = efi_translate_domain_addr(vendor_addr, fault, &vendor_page);
   1.118 +	if (*fault != IA64_NO_FAULT)
   1.119 +		goto errout;
   1.120 +	data = efi_translate_domain_addr(data_addr, fault, &data_page);
   1.121 +	if (*fault != IA64_NO_FAULT)
   1.122 +		goto errout;
   1.123 +
   1.124 +	status = (*efi.set_variable)((efi_char16_t *)name,
   1.125 +	                             (efi_guid_t *)vendor,
   1.126 +	                             attr,
   1.127 +	                             data_size,
   1.128 +	                             (void *)data);
   1.129 +
   1.130 +errout:
   1.131 +	if (name_page != NULL)
   1.132 +		put_page(name_page);
   1.133 +	if (vendor_page != NULL)
   1.134 +		put_page(vendor_page);
   1.135 +	if (data_page != NULL)
   1.136 +		put_page(data_page);
   1.137 +
   1.138 +	return status;
   1.139 +}
   1.140 +
   1.141 +static efi_status_t
   1.142  efi_emulate_set_virtual_address_map(
   1.143  	unsigned long memory_map_size, unsigned long descriptor_size,
   1.144  	u32 descriptor_version, efi_memory_desc_t *virtual_map)
   1.145 @@ -527,6 +662,31 @@ efi_emulator (struct pt_regs *regs, IA64
   1.146  				vcpu_get_gr(v,33),
   1.147  				fault);
   1.148  		break;
   1.149 +	    case FW_HYPERCALL_EFI_GET_VARIABLE:
   1.150 +		status = efi_emulate_get_variable (
   1.151 +				vcpu_get_gr(v,32),
   1.152 +				vcpu_get_gr(v,33),
   1.153 +				vcpu_get_gr(v,34),
   1.154 +				vcpu_get_gr(v,35),
   1.155 +				vcpu_get_gr(v,36),
   1.156 +				fault);
   1.157 +		break;
   1.158 +	    case FW_HYPERCALL_EFI_GET_NEXT_VARIABLE:
   1.159 +		status = efi_emulate_get_next_variable (
   1.160 +				vcpu_get_gr(v,32),
   1.161 +				vcpu_get_gr(v,33),
   1.162 +				vcpu_get_gr(v,34),
   1.163 +				fault);
   1.164 +		break;
   1.165 +	    case FW_HYPERCALL_EFI_SET_VARIABLE:
   1.166 +		status = efi_emulate_set_variable (
   1.167 +				vcpu_get_gr(v,32),
   1.168 +				vcpu_get_gr(v,33),
   1.169 +				vcpu_get_gr(v,34),
   1.170 +				vcpu_get_gr(v,35),
   1.171 +				vcpu_get_gr(v,36),
   1.172 +				fault);
   1.173 +		break;
   1.174  	    case FW_HYPERCALL_EFI_SET_VIRTUAL_ADDRESS_MAP:
   1.175  		status = efi_emulate_set_virtual_address_map (
   1.176  				vcpu_get_gr(v,32),
   1.177 @@ -538,10 +698,6 @@ efi_emulator (struct pt_regs *regs, IA64
   1.178  	    case FW_HYPERCALL_EFI_GET_WAKEUP_TIME:
   1.179  	    case FW_HYPERCALL_EFI_SET_WAKEUP_TIME:
   1.180  		// FIXME: need fixes in efi.h from 2.6.9
   1.181 -	    case FW_HYPERCALL_EFI_GET_VARIABLE:
   1.182 -		// FIXME: need fixes in efi.h from 2.6.9
   1.183 -	    case FW_HYPERCALL_EFI_GET_NEXT_VARIABLE:
   1.184 -	    case FW_HYPERCALL_EFI_SET_VARIABLE:
   1.185  	    case FW_HYPERCALL_EFI_GET_NEXT_HIGH_MONO_COUNT:
   1.186  		// FIXME: need fixes in efi.h from 2.6.9
   1.187  		status = EFI_UNSUPPORTED;