* @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
/* The list of protocols */
struct list_head protocols;
enum efi_object_type type;
+ struct udevice *dev;
};
enum efi_image_auth_status {
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
*
struct efi_device_path *dp;
unsigned int part;
struct efi_simple_file_system_protocol *volume;
- struct udevice *dev; /* TODO: move it to efi_object */
};
/**
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
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);
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);
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);
+}