summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/fwu.h11
-rw-r--r--lib/fwu_updates/fwu.c33
2 files changed, 44 insertions, 0 deletions
diff --git a/include/fwu.h b/include/fwu.h
index 9cee8fb085c..68a51fb4296 100644
--- a/include/fwu.h
+++ b/include/fwu.h
@@ -397,6 +397,17 @@ void fwu_populate_mdata_image_info(struct fwu_data *data);
int fwu_get_mdata_size(uint32_t *mdata_size);
/**
+ * fwu_mdata_get_image_guid() - Get image GUID for a type and bank
+ * @image_guid: Pointer to be filled with the found image GUID
+ * @image_type_guid: Pointer to the image type GUID to search for
+ * @bank_index: Index of the bank
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int fwu_mdata_get_image_guid(efi_guid_t *image_guid,
+ const efi_guid_t *image_type_guid, u32 bank_index);
+
+/**
* fwu_state_machine_updates() - Update FWU state of the platform
* @state: FWU bank state
* @update_index: Bank number to which images have been updated
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index e82600a29a4..2b11e5da061 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -244,6 +244,39 @@ int fwu_sync_mdata(struct fwu_mdata *mdata, int part)
}
/**
+ * fwu_mdata_get_image_guid() - Get image GUID for a type and bank
+ * @image_guid: Pointer to be filled with the found image GUID
+ * @image_type_guid: Pointer to the image type GUID to search for
+ * @bank_index: Index of the bank
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int fwu_mdata_get_image_guid(efi_guid_t *image_guid,
+ const efi_guid_t *image_type_guid, u32 bank_index)
+{
+ struct fwu_data *data = &g_fwu_data;
+ struct fwu_image_entry *image;
+ int i;
+
+ if (bank_index >= data->num_banks)
+ return -EINVAL;
+
+ for (i = 0; i < data->num_images; i++) {
+ image = &data->fwu_images[i];
+
+ if (!guidcmp(image_type_guid, &image->image_type_guid)) {
+ struct fwu_image_bank_info *bank;
+
+ bank = &image->img_bank_info[bank_index];
+ guidcpy(image_guid, &bank->image_guid);
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
+/**
* fwu_mdata_copies_allocate() - Allocate memory for metadata
* @mdata_size: Size of the metadata structure
*