aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorShannon Zhao <shannon.zhao@linaro.org>2016-04-07 08:03:31 -0400
committerDavid Vrabel <david.vrabel@citrix.com>2016-07-06 05:34:46 -0400
commita62ed500307bfaf4c1a818b69f7c1e7df1039a16 (patch)
treee79f674f505b06eead42de60ce46bda73d5376ed /drivers/xen
parent9d2f145fce926ac35f1f602ed87bc61547cc6da5 (diff)
XEN: EFI: Move x86 specific codes to architecture directory
Move x86 specific codes to architecture directory and export those EFI runtime service functions. This will be useful for initializing runtime service on ARM later. Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Tested-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/efi.c173
1 files changed, 34 insertions, 139 deletions
diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
index e9d2135445c1..22f71ffd3406 100644
--- a/drivers/xen/efi.c
+++ b/drivers/xen/efi.c
@@ -38,7 +38,7 @@
38 38
39#define efi_data(op) (op.u.efi_runtime_call) 39#define efi_data(op) (op.u.efi_runtime_call)
40 40
41static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) 41efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
42{ 42{
43 struct xen_platform_op op = INIT_EFI_OP(get_time); 43 struct xen_platform_op op = INIT_EFI_OP(get_time);
44 44
@@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
59 59
60 return efi_data(op).status; 60 return efi_data(op).status;
61} 61}
62EXPORT_SYMBOL_GPL(xen_efi_get_time);
62 63
63static efi_status_t xen_efi_set_time(efi_time_t *tm) 64efi_status_t xen_efi_set_time(efi_time_t *tm)
64{ 65{
65 struct xen_platform_op op = INIT_EFI_OP(set_time); 66 struct xen_platform_op op = INIT_EFI_OP(set_time);
66 67
@@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
72 73
73 return efi_data(op).status; 74 return efi_data(op).status;
74} 75}
76EXPORT_SYMBOL_GPL(xen_efi_set_time);
75 77
76static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, 78efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
77 efi_bool_t *pending, 79 efi_time_t *tm)
78 efi_time_t *tm)
79{ 80{
80 struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time); 81 struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
81 82
@@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
95 96
96 return efi_data(op).status; 97 return efi_data(op).status;
97} 98}
99EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
98 100
99static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) 101efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
100{ 102{
101 struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time); 103 struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
102 104
@@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
113 115
114 return efi_data(op).status; 116 return efi_data(op).status;
115} 117}
118EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
116 119
117static efi_status_t xen_efi_get_variable(efi_char16_t *name, 120efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
118 efi_guid_t *vendor, 121 u32 *attr, unsigned long *data_size,
119 u32 *attr, 122 void *data)
120 unsigned long *data_size,
121 void *data)
122{ 123{
123 struct xen_platform_op op = INIT_EFI_OP(get_variable); 124 struct xen_platform_op op = INIT_EFI_OP(get_variable);
124 125
@@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
138 139
139 return efi_data(op).status; 140 return efi_data(op).status;
140} 141}
142EXPORT_SYMBOL_GPL(xen_efi_get_variable);
141 143
142static efi_status_t xen_efi_get_next_variable(unsigned long *name_size, 144efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
143 efi_char16_t *name, 145 efi_char16_t *name,
144 efi_guid_t *vendor) 146 efi_guid_t *vendor)
145{ 147{
146 struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name); 148 struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
147 149
@@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
161 163
162 return efi_data(op).status; 164 return efi_data(op).status;
163} 165}
166EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
164 167
165static efi_status_t xen_efi_set_variable(efi_char16_t *name, 168efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
166 efi_guid_t *vendor, 169 u32 attr, unsigned long data_size,
167 u32 attr, 170 void *data)
168 unsigned long data_size,
169 void *data)
170{ 171{
171 struct xen_platform_op op = INIT_EFI_OP(set_variable); 172 struct xen_platform_op op = INIT_EFI_OP(set_variable);
172 173
@@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
183 184
184 return efi_data(op).status; 185 return efi_data(op).status;
185} 186}
187EXPORT_SYMBOL_GPL(xen_efi_set_variable);
186 188
187static efi_status_t xen_efi_query_variable_info(u32 attr, 189efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
188 u64 *storage_space, 190 u64 *remaining_space,
189 u64 *remaining_space, 191 u64 *max_variable_size)
190 u64 *max_variable_size)
191{ 192{
192 struct xen_platform_op op = INIT_EFI_OP(query_variable_info); 193 struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
193 194
@@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
205 206
206 return efi_data(op).status; 207 return efi_data(op).status;
207} 208}
209EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
208 210
209static efi_status_t xen_efi_get_next_high_mono_count(u32 *count) 211efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
210{ 212{
211 struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count); 213 struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
212 214
@@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
217 219
218 return efi_data(op).status; 220 return efi_data(op).status;
219} 221}
222EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
220 223
221static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules, 224efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
222 unsigned long count, 225 unsigned long count, unsigned long sg_list)
223 unsigned long sg_list)
224{ 226{
225 struct xen_platform_op op = INIT_EFI_OP(update_capsule); 227 struct xen_platform_op op = INIT_EFI_OP(update_capsule);
226 228
@@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
237 239
238 return efi_data(op).status; 240 return efi_data(op).status;
239} 241}
242EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
240 243
241static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules, 244efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
242 unsigned long count, 245 unsigned long count, u64 *max_size,
243 u64 *max_size, 246 int *reset_type)
244 int *reset_type)
245{ 247{
246 struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities); 248 struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
247 249
@@ -260,111 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
260 262
261 return efi_data(op).status; 263 return efi_data(op).status;
262} 264}
263 265EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
264static efi_char16_t vendor[100] __initdata;
265
266static efi_system_table_t efi_systab_xen __initdata = {
267 .hdr = {
268 .signature = EFI_SYSTEM_TABLE_SIGNATURE,
269 .revision = 0, /* Initialized later. */
270 .headersize = 0, /* Ignored by Linux Kernel. */
271 .crc32 = 0, /* Ignored by Linux Kernel. */
272 .reserved = 0
273 },
274 .fw_vendor = EFI_INVALID_TABLE_ADDR, /* Initialized later. */
275 .fw_revision = 0, /* Initialized later. */
276 .con_in_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
277 .con_in = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
278 .con_out_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
279 .con_out = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
280 .stderr_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
281 .stderr = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
282 .runtime = (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
283 /* Not used under Xen. */
284 .boottime = (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
285 /* Not used under Xen. */
286 .nr_tables = 0, /* Initialized later. */
287 .tables = EFI_INVALID_TABLE_ADDR /* Initialized later. */
288};
289
290static const struct efi efi_xen __initconst = {
291 .systab = NULL, /* Initialized later. */
292 .runtime_version = 0, /* Initialized later. */
293 .mps = EFI_INVALID_TABLE_ADDR,
294 .acpi = EFI_INVALID_TABLE_ADDR,
295 .acpi20 = EFI_INVALID_TABLE_ADDR,
296 .smbios = EFI_INVALID_TABLE_ADDR,
297 .smbios3 = EFI_INVALID_TABLE_ADDR,
298 .sal_systab = EFI_INVALID_TABLE_ADDR,
299 .boot_info = EFI_INVALID_TABLE_ADDR,
300 .hcdp = EFI_INVALID_TABLE_ADDR,
301 .uga = EFI_INVALID_TABLE_ADDR,
302 .uv_systab = EFI_INVALID_TABLE_ADDR,
303 .fw_vendor = EFI_INVALID_TABLE_ADDR,
304 .runtime = EFI_INVALID_TABLE_ADDR,
305 .config_table = EFI_INVALID_TABLE_ADDR,
306 .get_time = xen_efi_get_time,
307 .set_time = xen_efi_set_time,
308 .get_wakeup_time = xen_efi_get_wakeup_time,
309 .set_wakeup_time = xen_efi_set_wakeup_time,
310 .get_variable = xen_efi_get_variable,
311 .get_next_variable = xen_efi_get_next_variable,
312 .set_variable = xen_efi_set_variable,
313 .query_variable_info = xen_efi_query_variable_info,
314 .update_capsule = xen_efi_update_capsule,
315 .query_capsule_caps = xen_efi_query_capsule_caps,
316 .get_next_high_mono_count = xen_efi_get_next_high_mono_count,
317 .reset_system = NULL, /* Functionality provided by Xen. */
318 .set_virtual_address_map = NULL, /* Not used under Xen. */
319 .flags = 0 /* Initialized later. */
320};
321
322efi_system_table_t __init *xen_efi_probe(void)
323{
324 struct xen_platform_op op = {
325 .cmd = XENPF_firmware_info,
326 .u.firmware_info = {
327 .type = XEN_FW_EFI_INFO,
328 .index = XEN_FW_EFI_CONFIG_TABLE
329 }
330 };
331 union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
332
333 if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
334 return NULL;
335
336 /* Here we know that Xen runs on EFI platform. */
337
338 efi = efi_xen;
339
340 efi_systab_xen.tables = info->cfg.addr;
341 efi_systab_xen.nr_tables = info->cfg.nent;
342
343 op.cmd = XENPF_firmware_info;
344 op.u.firmware_info.type = XEN_FW_EFI_INFO;
345 op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
346 info->vendor.bufsz = sizeof(vendor);
347 set_xen_guest_handle(info->vendor.name, vendor);
348
349 if (HYPERVISOR_platform_op(&op) == 0) {
350 efi_systab_xen.fw_vendor = __pa_symbol(vendor);
351 efi_systab_xen.fw_revision = info->vendor.revision;
352 } else
353 efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
354
355 op.cmd = XENPF_firmware_info;
356 op.u.firmware_info.type = XEN_FW_EFI_INFO;
357 op.u.firmware_info.index = XEN_FW_EFI_VERSION;
358
359 if (HYPERVISOR_platform_op(&op) == 0)
360 efi_systab_xen.hdr.revision = info->version;
361
362 op.cmd = XENPF_firmware_info;
363 op.u.firmware_info.type = XEN_FW_EFI_INFO;
364 op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
365
366 if (HYPERVISOR_platform_op(&op) == 0)
367 efi.runtime_version = info->version;
368
369 return &efi_systab_xen;
370}