[U-Boot] [PATCH v2 3/6] efi: hii: add guid package support
AKASHI Takahiro
takahiro.akashi at linaro.org
Fri Nov 16 01:18:34 UTC 2018
Allow for handling GUID package in HII database protocol.
Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
include/efi_api.h | 9 ++++++++
lib/efi_loader/efi_hii.c | 48 +++++++++++++++++++++++++++++++++++-----
2 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/include/efi_api.h b/include/efi_api.h
index 427bbba59aed..f3a0b4396b5a 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -835,6 +835,15 @@ efi_hii_sibt_string_ucs2_block_next(struct efi_hii_sibt_string_ucs2_block *blk)
(u16_strlen(blk->string_text) + 1) * 2;
}
+/*
+ * Guid package
+ */
+struct efi_hii_guid_package {
+ struct efi_hii_package_header header;
+ efi_guid_t guid;
+ char data[];
+} __packed;
+
typedef void *efi_hii_handle_t;
struct efi_hii_database_protocol {
diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c
index 40034c27473d..036aa8eac956 100644
--- a/lib/efi_loader/efi_hii.c
+++ b/lib/efi_loader/efi_hii.c
@@ -25,6 +25,7 @@ struct efi_hii_packagelist {
efi_handle_t driver_handle;
u32 max_string_id;
struct list_head string_tables; /* list of efi_string_table */
+ struct list_head guid_list;
/* we could also track fonts, images, etc */
};
@@ -47,6 +48,11 @@ struct efi_string_table {
struct efi_string_info *strings;
};
+struct efi_guid_data {
+ struct list_head link;
+ struct efi_hii_guid_package package;
+};
+
static void free_strings_table(struct efi_string_table *stbl)
{
int i;
@@ -178,6 +184,35 @@ error:
return ret;
}
+static void remove_guid_package(struct efi_hii_packagelist *hii)
+{
+ struct efi_guid_data *data;
+
+ while (!list_empty(&hii->guid_list)) {
+ data = list_first_entry(&hii->guid_list,
+ struct efi_guid_data, link);
+ list_del(&data->link);
+ free(data);
+ }
+}
+
+static efi_status_t
+add_guid_package(struct efi_hii_packagelist *hii,
+ struct efi_hii_guid_package *package)
+{
+ struct efi_guid_data *data;
+
+ data = calloc(sizeof(*data), 1);
+ if (!data)
+ return EFI_OUT_OF_RESOURCES;
+
+ /* TODO: we don't know any about data field */
+ memcpy(&data->package, package, sizeof(*package));
+ list_add_tail(&data->link, &hii->guid_list);
+
+ return EFI_SUCCESS;
+}
+
static struct efi_hii_packagelist *new_packagelist(void)
{
struct efi_hii_packagelist *hii;
@@ -186,6 +221,7 @@ static struct efi_hii_packagelist *new_packagelist(void)
hii->signature = hii_package_signature;
hii->max_string_id = 0;
INIT_LIST_HEAD(&hii->string_tables);
+ INIT_LIST_HEAD(&hii->guid_list);
return hii;
}
@@ -193,6 +229,7 @@ static struct efi_hii_packagelist *new_packagelist(void)
static void free_packagelist(struct efi_hii_packagelist *hii)
{
remove_strings_package(hii);
+ remove_guid_package(hii);
list_del(&hii->link);
free(hii);
@@ -219,8 +256,8 @@ add_packages(struct efi_hii_packagelist *hii,
switch (efi_hii_package_type(package)) {
case EFI_HII_PACKAGE_TYPE_GUID:
- printf("\tGuid package not supported\n");
- ret = EFI_INVALID_PARAMETER;
+ ret = add_guid_package(hii,
+ (struct efi_hii_guid_package *)package);
break;
case EFI_HII_PACKAGE_FORMS:
printf("\tForm package not supported\n");
@@ -355,8 +392,7 @@ update_package_list(const struct efi_hii_database_protocol *this,
switch (efi_hii_package_type(package)) {
case EFI_HII_PACKAGE_TYPE_GUID:
- printf("\tGuid package not supported\n");
- ret = EFI_INVALID_PARAMETER;
+ remove_guid_package(hii);
break;
case EFI_HII_PACKAGE_FORMS:
printf("\tForm package not supported\n");
@@ -442,8 +478,8 @@ list_package_lists(const struct efi_hii_database_protocol *this,
case EFI_HII_PACKAGE_TYPE_ALL:
break;
case EFI_HII_PACKAGE_TYPE_GUID:
- printf("\tGuid package not supported\n");
- ret = EFI_INVALID_PARAMETER;
+ if (!list_empty(&hii->guid_list))
+ break;
continue;
case EFI_HII_PACKAGE_FORMS:
printf("\tForm package not supported\n");
--
2.19.0
More information about the U-Boot
mailing list