efi_loader: move udevice pointer into struct efi_object
This is a preparation patch to provide the unified method to access udevice pointer associated with the EFI handle by adding udevice pointer into struct efi_object. The patch also introduces a helper function efi_link_dev() to link the udevice and EFI handle. The EFI handles of both EFI block io driver implemented in lib/efi_loader/efi_disk.c and EFI block io driver implemented as EFI payload can access the udevice pointer in the struct efi_object. We can use this udevice pointer to get the U-Boot friendly block device name(e.g. mmc 0:1, nvme 0:1) through EFI handle. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
e7496e57a0
commit
ee57666294
4 changed files with 24 additions and 11 deletions
|
@ -375,6 +375,7 @@ enum efi_object_type {
|
|||
* @protocols: linked list with the protocol interfaces installed on this
|
||||
* handle
|
||||
* @type: image type if the handle relates to an image
|
||||
* @dev: pointer to the DM device which is associated with this EFI handle
|
||||
*
|
||||
* UEFI offers a flexible and expandable object model. The objects in the UEFI
|
||||
* API are devices, drivers, and loaded images. struct efi_object is our storage
|
||||
|
@ -392,6 +393,7 @@ struct efi_object {
|
|||
/* The list of protocols */
|
||||
struct list_head protocols;
|
||||
enum efi_object_type type;
|
||||
struct udevice *dev;
|
||||
};
|
||||
|
||||
enum efi_image_auth_status {
|
||||
|
@ -690,6 +692,8 @@ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t guid);
|
|||
const char *guid_to_sha_str(const efi_guid_t *guid);
|
||||
int algo_to_len(const char *algo);
|
||||
|
||||
int efi_link_dev(efi_handle_t handle, struct udevice *dev);
|
||||
|
||||
/**
|
||||
* efi_size_in_pages() - convert size in bytes to size in pages
|
||||
*
|
||||
|
|
|
@ -158,8 +158,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
|
|||
* FIXME: necessary because we won't do almost nothing in
|
||||
* efi_disk_create() when called from device_probe().
|
||||
*/
|
||||
ret = dev_tag_set_ptr(bdev, DM_TAG_EFI, handle);
|
||||
if (ret)
|
||||
if (efi_link_dev(handle, bdev))
|
||||
/* FIXME: cleanup for bdev */
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ struct efi_disk_obj {
|
|||
struct efi_device_path *dp;
|
||||
unsigned int part;
|
||||
struct efi_simple_file_system_protocol *volume;
|
||||
struct udevice *dev; /* TODO: move it to efi_object */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -124,16 +123,16 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this,
|
|||
return EFI_BAD_BUFFER_SIZE;
|
||||
|
||||
if (CONFIG_IS_ENABLED(PARTITIONS) &&
|
||||
device_get_uclass_id(diskobj->dev) == UCLASS_PARTITION) {
|
||||
device_get_uclass_id(diskobj->header.dev) == UCLASS_PARTITION) {
|
||||
if (direction == EFI_DISK_READ)
|
||||
n = dev_read(diskobj->dev, lba, blocks, buffer);
|
||||
n = dev_read(diskobj->header.dev, lba, blocks, buffer);
|
||||
else
|
||||
n = dev_write(diskobj->dev, lba, blocks, buffer);
|
||||
n = dev_write(diskobj->header.dev, lba, blocks, buffer);
|
||||
} else {
|
||||
/* dev is a block device (UCLASS_BLK) */
|
||||
struct blk_desc *desc;
|
||||
|
||||
desc = dev_get_uclass_plat(diskobj->dev);
|
||||
desc = dev_get_uclass_plat(diskobj->header.dev);
|
||||
if (direction == EFI_DISK_READ)
|
||||
n = blk_dread(desc, lba, blocks, buffer);
|
||||
else
|
||||
|
@ -552,8 +551,7 @@ static int efi_disk_create_raw(struct udevice *dev)
|
|||
|
||||
return -1;
|
||||
}
|
||||
disk->dev = dev;
|
||||
if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) {
|
||||
if (efi_link_dev(&disk->header, dev)) {
|
||||
efi_free_pool(disk->dp);
|
||||
efi_delete_handle(&disk->header);
|
||||
|
||||
|
@ -609,8 +607,7 @@ static int efi_disk_create_part(struct udevice *dev)
|
|||
log_err("Adding partition for %s failed\n", dev->name);
|
||||
return -1;
|
||||
}
|
||||
disk->dev = dev;
|
||||
if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) {
|
||||
if (efi_link_dev(&disk->header, dev)) {
|
||||
efi_free_pool(disk->dp);
|
||||
efi_delete_handle(&disk->header);
|
||||
|
||||
|
|
|
@ -158,3 +158,16 @@ int algo_to_len(const char *algo)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** efi_link_dev - link the efi_handle_t and udevice
|
||||
*
|
||||
* @handle: efi handle to associate with udevice
|
||||
* @dev: udevice to associate with efi handle
|
||||
*
|
||||
* Return: 0 on success, negative on failure
|
||||
*/
|
||||
int efi_link_dev(efi_handle_t handle, struct udevice *dev)
|
||||
{
|
||||
handle->dev = dev;
|
||||
return dev_tag_set_ptr(dev, DM_TAG_EFI, handle);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue