diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/efi_driver/efi_block_device.c | 6 | ||||
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 15 | ||||
-rw-r--r-- | lib/efi_loader/efi_device_path.c | 68 | ||||
-rw-r--r-- | lib/efi_loader/efi_tcg2.c | 8 |
4 files changed, 38 insertions, 59 deletions
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index add00eeebbe..e3abd90275c 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -124,10 +124,8 @@ efi_bl_create_block_device(efi_handle_t handle, void *interface) struct efi_block_io *io = interface; struct efi_blk_plat *plat; - devnum = blk_find_max_devnum(UCLASS_EFI_LOADER); - if (devnum == -ENODEV) - devnum = 0; - else if (devnum < 0) + devnum = blk_next_free_devnum(UCLASS_EFI_LOADER); + if (devnum < 0) return EFI_OUT_OF_RESOURCES; name = calloc(1, 18); /* strlen("efiblk#2147483648") + 1 */ diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 2ca7359f3e1..052fe481e47 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -575,9 +575,9 @@ efi_status_t efi_search_protocol(const efi_handle_t handle, * * Return: status code */ -efi_status_t efi_remove_protocol(const efi_handle_t handle, - const efi_guid_t *protocol, - void *protocol_interface) +static efi_status_t efi_remove_protocol(const efi_handle_t handle, + const efi_guid_t *protocol, + void *protocol_interface) { struct efi_handler *handler; efi_status_t ret; @@ -1357,18 +1357,11 @@ static efi_status_t efi_uninstall_protocol (efi_handle_t handle, const efi_guid_t *protocol, void *protocol_interface) { - struct efi_object *efiobj; struct efi_handler *handler; struct efi_open_protocol_info_item *item; struct efi_open_protocol_info_item *pos; efi_status_t r; - /* Check handle */ - efiobj = efi_search_obj(handle); - if (!efiobj) { - r = EFI_INVALID_PARAMETER; - goto out; - } /* Find the protocol on the handle */ r = efi_search_protocol(handle, protocol, &handler); if (r != EFI_SUCCESS) @@ -1376,7 +1369,7 @@ static efi_status_t efi_uninstall_protocol if (handler->protocol_interface != protocol_interface) return EFI_NOT_FOUND; /* Disconnect controllers */ - r = efi_disconnect_all_drivers(efiobj, protocol, NULL); + r = efi_disconnect_all_drivers(handle, protocol, NULL); if (r != EFI_SUCCESS) { r = EFI_ACCESS_DENIED; goto out; diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 04ebb449caa..19e8861ef49 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -10,6 +10,7 @@ #include <common.h> #include <blk.h> #include <dm.h> +#include <dm/root.h> #include <log.h> #include <net.h> #include <usb.h> @@ -38,16 +39,6 @@ const struct efi_device_path END = { .length = sizeof(END), }; -/* template ROOT node: */ -static const struct efi_device_path_vendor ROOT = { - .dp = { - .type = DEVICE_PATH_TYPE_HARDWARE_DEVICE, - .sub_type = DEVICE_PATH_SUB_TYPE_VENDOR, - .length = sizeof(ROOT), - }, - .guid = U_BOOT_GUID, -}; - #if defined(CONFIG_MMC) /* * Determine if an MMC device is an SD card. @@ -497,13 +488,12 @@ bool efi_dp_is_multi_instance(const struct efi_device_path *dp) __maybe_unused static unsigned int dp_size(struct udevice *dev) { if (!dev || !dev->driver) - return sizeof(ROOT); + return sizeof(struct efi_device_path_udevice); switch (device_get_uclass_id(dev)) { case UCLASS_ROOT: - case UCLASS_SIMPLE_BUS: /* stop traversing parents at this point: */ - return sizeof(ROOT); + return sizeof(struct efi_device_path_udevice); case UCLASS_ETH: return dp_size(dev->parent) + sizeof(struct efi_device_path_mac_addr); @@ -582,8 +572,8 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev) return dp_size(dev->parent) + sizeof(struct efi_device_path_usb); default: - /* just skip over unknown classes: */ - return dp_size(dev->parent); + return dp_size(dev->parent) + + sizeof(struct efi_device_path_udevice); } } @@ -600,13 +590,6 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) return buf; switch (device_get_uclass_id(dev)) { - case UCLASS_ROOT: - case UCLASS_SIMPLE_BUS: { - /* stop traversing parents at this point: */ - struct efi_device_path_vendor *vdp = buf; - *vdp = ROOT; - return &vdp[1]; - } #ifdef CONFIG_NETDEVICES case UCLASS_ETH: { struct efi_device_path_mac_addr *dp = @@ -631,9 +614,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) struct efi_device_path_vendor *dp; struct blk_desc *desc = dev_get_uclass_plat(dev); - dp_fill(buf, dev->parent); - dp = buf; - ++dp; + dp = dp_fill(buf, dev->parent); dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; dp->dp.length = sizeof(*dp) + 1; @@ -649,9 +630,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) struct efi_device_path_vendor *dp; struct blk_desc *desc = dev_get_uclass_plat(dev); - dp_fill(buf, dev->parent); - dp = buf; - ++dp; + dp = dp_fill(buf, dev->parent); dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; dp->dp.length = sizeof(*dp) + 1; @@ -666,9 +645,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) struct efi_device_path_vendor *dp; struct blk_desc *desc = dev_get_uclass_plat(dev); - dp_fill(buf, dev->parent); - dp = buf; - ++dp; + dp = dp_fill(buf, dev->parent); dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; dp->dp.length = sizeof(*dp) + 1; @@ -811,11 +788,24 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) return &udp[1]; } - default: - /* If the uclass driver is missing, this will show NULL */ - log_debug("unhandled device class: %s (%s)\n", dev->name, - dev_get_uclass_name(dev)); - return dp_fill(buf, dev->parent); + default: { + struct efi_device_path_udevice *vdp; + enum uclass_id uclass_id = device_get_uclass_id(dev); + + if (uclass_id == UCLASS_ROOT) + vdp = buf; + else + vdp = dp_fill(buf, dev->parent); + + vdp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; + vdp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; + vdp->dp.length = sizeof(*vdp); + memcpy(&vdp->guid, &efi_u_boot_guid, sizeof(efi_guid_t)); + vdp->uclass_id = uclass_id; + vdp->dev_number = dev->seq_; + + return &vdp[1]; + } } } @@ -1052,14 +1042,12 @@ struct efi_device_path *efi_dp_from_uart(void) { void *buf, *pos; struct efi_device_path_uart *uart; - size_t dpsize = sizeof(ROOT) + sizeof(*uart) + sizeof(END); + size_t dpsize = dp_size(dm_root()) + sizeof(*uart) + sizeof(END); buf = efi_alloc(dpsize); if (!buf) return NULL; - pos = buf; - memcpy(pos, &ROOT, sizeof(ROOT)); - pos += sizeof(ROOT); + pos = dp_fill(buf, dm_root()); uart = pos; uart->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; uart->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_UART; diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index a83ae7a46cf..49f8a5e77cb 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -1680,8 +1680,8 @@ void tcg2_uninit(void) if (!is_tcg2_protocol_installed()) return; - ret = efi_remove_protocol(efi_root, &efi_guid_tcg2_protocol, - (void *)&efi_tcg2_protocol); + ret = efi_uninstall_multiple_protocol_interfaces(efi_root, &efi_guid_tcg2_protocol, + &efi_tcg2_protocol, NULL); if (ret != EFI_SUCCESS) log_err("Failed to remove EFI TCG2 protocol\n"); } @@ -2507,8 +2507,8 @@ efi_status_t efi_tcg2_register(void) goto fail; } - ret = efi_add_protocol(efi_root, &efi_guid_tcg2_protocol, - (void *)&efi_tcg2_protocol); + ret = efi_install_multiple_protocol_interfaces(&efi_root, &efi_guid_tcg2_protocol, + &efi_tcg2_protocol, NULL); if (ret != EFI_SUCCESS) { tcg2_uninit(); goto fail; |