diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/efi_driver/efi_uclass.c | 30 | ||||
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 90 | ||||
-rw-r--r-- | lib/efi_loader/efi_capsule.c | 14 | ||||
-rw-r--r-- | lib/efi_loader/efi_disk.c | 23 | ||||
-rw-r--r-- | lib/efi_loader/efi_load_options.c | 13 | ||||
-rw-r--r-- | lib/efi_loader/efi_tcg2.c | 10 |
6 files changed, 98 insertions, 82 deletions
diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 2193f8493f..45f9351988 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -97,10 +97,9 @@ static efi_status_t EFIAPI efi_uc_supported( ret = check_node_type(controller_handle); - r = EFI_CALL(systab.boottime->close_protocol( - controller_handle, bp->ops->protocol, - this->driver_binding_handle, - controller_handle)); + r = efi_close_protocol(controller_handle, bp->ops->protocol, + this->driver_binding_handle, + controller_handle); if (r != EFI_SUCCESS) ret = EFI_UNSUPPORTED; out: @@ -151,10 +150,9 @@ static efi_status_t EFIAPI efi_uc_start( goto out; err: - r = EFI_CALL(systab.boottime->close_protocol( - controller_handle, bp->ops->protocol, - this->driver_binding_handle, - controller_handle)); + r = efi_close_protocol(controller_handle, bp->ops->protocol, + this->driver_binding_handle, + controller_handle); if (r != EFI_SUCCESS) EFI_PRINT("Failure to close handle\n"); @@ -177,9 +175,8 @@ static efi_status_t disconnect_child(efi_handle_t controller_handle, efi_guid_t *guid_controller = NULL; efi_guid_t *guid_child_controller = NULL; - ret = EFI_CALL(systab.boottime->close_protocol( - controller_handle, guid_controller, - child_handle, child_handle)); + ret = efi_close_protocol(controller_handle, guid_controller, + child_handle, child_handle); if (ret != EFI_SUCCESS) { EFI_PRINT("Cannot close protocol\n"); return ret; @@ -225,9 +222,10 @@ static efi_status_t EFIAPI efi_uc_stop( ret = disconnect_child(controller_handle, child_handle_buffer[i]); if (ret != EFI_SUCCESS) - return ret; + goto out; } - return EFI_SUCCESS; + ret = EFI_SUCCESS; + goto out; } /* Destroy all children */ @@ -251,9 +249,9 @@ static efi_status_t EFIAPI efi_uc_stop( log_err("Cannot free EFI memory pool\n"); /* Detach driver from controller */ - ret = EFI_CALL(systab.boottime->close_protocol( - controller_handle, bp->ops->protocol, - this->driver_binding_handle, controller_handle)); + ret = efi_close_protocol(controller_handle, bp->ops->protocol, + this->driver_binding_handle, + controller_handle); out: return EFI_EXIT(ret); } diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index e776d25830..a56021559b 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1993,7 +1993,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy, if (ret != EFI_SUCCESS) efi_free_pages(addr, pages); out: - EFI_CALL(efi_close_protocol(device, guid, efi_root, NULL)); + efi_close_protocol(device, guid, efi_root, NULL); if (ret == EFI_SUCCESS) { *buffer = (void *)(uintptr_t)addr; *size = buffer_size; @@ -2290,45 +2290,70 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, * @agent_handle: handle of the driver * @controller_handle: handle of the controller * - * This function implements the CloseProtocol service. + * This is the function implementing the CloseProtocol service is for internal + * usage in U-Boot. For API usage wrapper efi_close_protocol_ext() is provided. * * See the Unified Extensible Firmware Interface (UEFI) specification for * details. * * Return: status code */ -efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle, - const efi_guid_t *protocol, - efi_handle_t agent_handle, - efi_handle_t controller_handle) +efi_status_t efi_close_protocol(efi_handle_t handle, const efi_guid_t *protocol, + efi_handle_t agent_handle, + efi_handle_t controller_handle) { struct efi_handler *handler; struct efi_open_protocol_info_item *item; struct efi_open_protocol_info_item *pos; - efi_status_t r; - - EFI_ENTRY("%p, %pUs, %p, %p", handle, protocol, agent_handle, - controller_handle); + efi_status_t ret; if (!efi_search_obj(agent_handle) || - (controller_handle && !efi_search_obj(controller_handle))) { - r = EFI_INVALID_PARAMETER; - goto out; - } - r = efi_search_protocol(handle, protocol, &handler); - if (r != EFI_SUCCESS) - goto out; + (controller_handle && !efi_search_obj(controller_handle))) + return EFI_INVALID_PARAMETER; + ret = efi_search_protocol(handle, protocol, &handler); + if (ret != EFI_SUCCESS) + return ret; - r = EFI_NOT_FOUND; + ret = EFI_NOT_FOUND; list_for_each_entry_safe(item, pos, &handler->open_infos, link) { if (item->info.agent_handle == agent_handle && item->info.controller_handle == controller_handle) { efi_delete_open_info(item); - r = EFI_SUCCESS; + ret = EFI_SUCCESS; } } -out: - return EFI_EXIT(r); + + return ret; +} + +/** + * efi_close_protocol_ext() - close a protocol + * @handle: handle on which the protocol shall be closed + * @protocol: GUID of the protocol to close + * @agent_handle: handle of the driver + * @controller_handle: handle of the controller + * + * This function implements the CloseProtocol service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * Return: status code + */ +static efi_status_t EFIAPI +efi_close_protocol_ext(efi_handle_t handle, const efi_guid_t *protocol, + efi_handle_t agent_handle, + efi_handle_t controller_handle) +{ + efi_status_t ret; + + EFI_ENTRY("%p, %pUs, %p, %p", handle, protocol, agent_handle, + controller_handle); + + ret = efi_close_protocol(handle, protocol, + agent_handle, controller_handle); + + return EFI_EXIT(ret); } /** @@ -3213,11 +3238,10 @@ close_next: if (info->info.agent_handle != (efi_handle_t)image_obj) continue; - r = EFI_CALL(efi_close_protocol - (efiobj, &protocol->guid, - info->info.agent_handle, - info->info.controller_handle - )); + r = efi_close_protocol( + efiobj, &protocol->guid, + info->info.agent_handle, + info->info.controller_handle); if (r != EFI_SUCCESS) ret = r; /* @@ -3481,9 +3505,9 @@ static efi_status_t efi_bind_controller( r = EFI_CALL(binding_protocol->start(binding_protocol, controller_handle, remain_device_path)); - EFI_CALL(efi_close_protocol(driver_image_handle, - &efi_guid_driver_binding_protocol, - driver_image_handle, NULL)); + efi_close_protocol(driver_image_handle, + &efi_guid_driver_binding_protocol, + driver_image_handle, NULL); return r; } @@ -3834,9 +3858,9 @@ static efi_status_t EFIAPI efi_disconnect_controller( goto out; } } - EFI_CALL(efi_close_protocol(driver_image_handle, - &efi_guid_driver_binding_protocol, - driver_image_handle, NULL)); + efi_close_protocol(driver_image_handle, + &efi_guid_driver_binding_protocol, + driver_image_handle, NULL); r = EFI_SUCCESS; out: if (!child_handle) @@ -3883,7 +3907,7 @@ static struct efi_boot_services efi_boot_services = { .connect_controller = efi_connect_controller, .disconnect_controller = efi_disconnect_controller, .open_protocol = efi_open_protocol, - .close_protocol = efi_close_protocol, + .close_protocol = efi_close_protocol_ext, .open_protocol_information = efi_open_protocol_information, .protocols_per_handle = efi_protocols_per_handle, .locate_handle_buffer = efi_locate_handle_buffer, diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index b6bd2d6af8..397e393a18 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -159,12 +159,14 @@ efi_fmp_find(efi_guid_t *image_type, u8 image_index, u64 instance, efi_status_t ret; for (i = 0, handle = handles; i < no_handles; i++, handle++) { - ret = EFI_CALL(efi_handle_protocol( - *handle, - &efi_guid_firmware_management_protocol, - (void **)&fmp)); + struct efi_handler *fmp_handler; + + ret = efi_search_protocol( + *handle, &efi_guid_firmware_management_protocol, + &fmp_handler); if (ret != EFI_SUCCESS) continue; + fmp = fmp_handler->protocol_interface; /* get device's image info */ info_size = 0; @@ -215,10 +217,6 @@ efi_fmp_find(efi_guid_t *image_type, u8 image_index, u64 instance, skip: efi_free_pool(package_version_name); free(image_info); - EFI_CALL(efi_close_protocol( - (efi_handle_t)fmp, - &efi_guid_firmware_management_protocol, - NULL, NULL)); if (found) return fmp; } diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index e6a356b589..cef4e45124 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -395,7 +395,7 @@ static efi_status_t efi_disk_add_dev( { struct efi_disk_obj *diskobj; struct efi_object *handle; - const efi_guid_t *guid = NULL; + const efi_guid_t *esp_guid = NULL; efi_status_t ret; /* Don't add empty devices */ @@ -439,7 +439,7 @@ static efi_status_t efi_disk_add_dev( efi_free_pool(node); diskobj->media.last_block = part_info->size - 1; if (part_info->bootable & PART_EFI_SYSTEM_PARTITION) - guid = &efi_system_partition_guid; + esp_guid = &efi_system_partition_guid; } else { diskobj->dp = efi_dp_from_part(desc, part); diskobj->media.last_block = desc->lba - 1; @@ -454,12 +454,16 @@ static efi_status_t efi_disk_add_dev( * in this case. */ handle = &diskobj->header; - ret = efi_install_multiple_protocol_interfaces(&handle, - &efi_guid_device_path, - diskobj->dp, - &efi_block_io_guid, - &diskobj->ops, guid, - NULL, NULL); + ret = efi_install_multiple_protocol_interfaces( + &handle, + &efi_guid_device_path, diskobj->dp, + &efi_block_io_guid, &diskobj->ops, + /* + * esp_guid must be last entry as it + * can be NULL. Its interface is NULL. + */ + esp_guid, NULL, + NULL); if (ret != EFI_SUCCESS) goto error; @@ -786,7 +790,8 @@ efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int if (is_partition) { part_data = dev_get_uclass_plat(dev); part = part_data->partnum; - count = snprintf(buf, size, "%s %d:%d", if_typename, diskid, part); + count = snprintf(buf, size, "%s %d:%u", if_typename, diskid, + part); } else { count = snprintf(buf, size, "%s %d", if_typename, diskid); } diff --git a/lib/efi_loader/efi_load_options.c b/lib/efi_loader/efi_load_options.c index 71454f0fc6..3cfddee014 100644 --- a/lib/efi_loader/efi_load_options.c +++ b/lib/efi_loader/efi_load_options.c @@ -27,23 +27,18 @@ efi_status_t efi_set_load_options(efi_handle_t handle, void *load_options) { struct efi_loaded_image *loaded_image_info; + struct efi_handler *handler; efi_status_t ret; - ret = EFI_CALL(systab.boottime->open_protocol( - handle, - &efi_guid_loaded_image, - (void **)&loaded_image_info, - efi_root, NULL, - EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL)); + ret = efi_search_protocol(handle, &efi_guid_loaded_image, &handler); + loaded_image_info = handler->protocol_interface; if (ret != EFI_SUCCESS) return EFI_INVALID_PARAMETER; loaded_image_info->load_options = load_options; loaded_image_info->load_options_size = load_options_size; - return EFI_CALL(systab.boottime->close_protocol(handle, - &efi_guid_loaded_image, - efi_root, NULL)); + return EFI_SUCCESS; } /** diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 99ec3a5486..a525ebf75b 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -2053,7 +2053,7 @@ tcg2_measure_gpt_data(struct udevice *dev, { efi_status_t ret; efi_handle_t handle; - struct efi_handler *dp_handler; + struct efi_handler *dp_handler, *io_handler; struct efi_device_path *orig_device_path; struct efi_device_path *device_path; struct efi_device_path *dp; @@ -2098,10 +2098,10 @@ tcg2_measure_gpt_data(struct udevice *dev, if (ret != EFI_SUCCESS) goto out1; - ret = EFI_CALL(efi_handle_protocol(handle, - &efi_block_io_guid, (void **)&block_io)); + ret = efi_search_protocol(handle, &efi_block_io_guid, &io_handler); if (ret != EFI_SUCCESS) goto out1; + block_io = io_handler->protocol_interface; gpt_h = memalign(block_io->media->io_align, block_io->media->block_size); if (!gpt_h) { @@ -2164,12 +2164,8 @@ tcg2_measure_gpt_data(struct udevice *dev, } ret = tcg2_measure_event(dev, 5, EV_EFI_GPT_EVENT, event_size, (u8 *)event); - if (ret != EFI_SUCCESS) - goto out2; out2: - EFI_CALL(efi_close_protocol((efi_handle_t)block_io, &efi_block_io_guid, - NULL, NULL)); free(gpt_h); free(entry); free(event); |