Commit 29018abb09a6ad638df38d6df5ab089ef1115e3c

Authored by Heinrich Schuchardt
1 parent 24a238f763

efi_loader: let the variable driver patch out the runtime

Our variable services are only provided at boottime. Therefore when
leaving boottime the variable function are replaced by dummy functions
returning EFI_UNSUPPORTED. Move this patching of the runtime table to the
variable services implementation. Executed it in ExitBootServices().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Showing 4 changed files with 48 additions and 10 deletions Side-by-side Diff

include/efi_loader.h
... ... @@ -327,6 +327,8 @@
327 327 efi_status_t efi_init_obj_list(void);
328 328 /* Initialize variable services */
329 329 efi_status_t efi_init_variables(void);
  330 +/* Notify ExitBootServices() is called */
  331 +void efi_variables_boot_exit_notify(void);
330 332 /* Called by bootefi to initialize root node */
331 333 efi_status_t efi_root_node_register(void);
332 334 /* Called by bootefi to initialize runtime */
lib/efi_loader/efi_boottime.c
... ... @@ -1968,7 +1968,8 @@
1968 1968 /* Make sure that notification functions are not called anymore */
1969 1969 efi_tpl = TPL_HIGH_LEVEL;
1970 1970  
1971   - /* TODO: Should persist EFI variables here */
  1971 + /* Notify variable services */
  1972 + efi_variables_boot_exit_notify();
1972 1973  
1973 1974 board_quiesce_devices();
1974 1975  
lib/efi_loader/efi_runtime.c
... ... @@ -408,15 +408,6 @@
408 408 }, {
409 409 .ptr = &efi_runtime_services.set_time,
410 410 .patchto = &efi_set_time,
411   - }, {
412   - .ptr = &efi_runtime_services.get_variable,
413   - .patchto = &efi_device_error,
414   - }, {
415   - .ptr = &efi_runtime_services.get_next_variable_name,
416   - .patchto = &efi_device_error,
417   - }, {
418   - .ptr = &efi_runtime_services.set_variable,
419   - .patchto = &efi_device_error,
420 411 }
421 412 };
422 413  
lib/efi_loader/efi_variable.c
... ... @@ -549,6 +549,50 @@
549 549 }
550 550  
551 551 /**
  552 + * efi_get_variable_runtime() - runtime implementation of GetVariable()
  553 + */
  554 +static efi_status_t __efi_runtime EFIAPI
  555 +efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
  556 + u32 *attributes, efi_uintn_t *data_size, void *data)
  557 +{
  558 + return EFI_UNSUPPORTED;
  559 +}
  560 +
  561 +/**
  562 + * efi_get_next_variable_name_runtime() - runtime implementation of
  563 + * GetNextVariable()
  564 + */
  565 +static efi_status_t __efi_runtime EFIAPI
  566 +efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
  567 + u16 *variable_name, const efi_guid_t *vendor)
  568 +{
  569 + return EFI_UNSUPPORTED;
  570 +}
  571 +
  572 +/**
  573 + * efi_set_variable_runtime() - runtime implementation of SetVariable()
  574 + */
  575 +static efi_status_t __efi_runtime EFIAPI
  576 +efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
  577 + u32 attributes, efi_uintn_t data_size,
  578 + const void *data)
  579 +{
  580 + return EFI_UNSUPPORTED;
  581 +}
  582 +
  583 +/**
  584 + * efi_variables_boot_exit_notify() - notify ExitBootServices() is called
  585 + */
  586 +void efi_variables_boot_exit_notify(void)
  587 +{
  588 + efi_runtime_services.get_variable = efi_get_variable_runtime;
  589 + efi_runtime_services.get_next_variable_name =
  590 + efi_get_next_variable_name_runtime;
  591 + efi_runtime_services.set_variable = efi_set_variable_runtime;
  592 + efi_update_table_header_crc32(&efi_runtime_services.hdr);
  593 +}
  594 +
  595 +/**
552 596 * efi_init_variables() - initialize variable services
553 597 *
554 598 * Return: status code