diff options
author | Alexander Graf <agraf@suse.de> | 2017-07-26 13:41:04 +0200 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2017-07-26 15:23:54 +0200 |
commit | d98cdf6a9212ab2727eedb6781a46acaf23f9786 (patch) | |
tree | 81e211209d0f54695a7d0c1f1aacf06ab421e659 /lib/efi_loader | |
parent | 3304990ba4d4a4347d19f3c10cfeb2c69eb5fa05 (diff) | |
download | u-boot-d98cdf6a9212ab2727eedb6781a46acaf23f9786.tar.gz u-boot-d98cdf6a9212ab2727eedb6781a46acaf23f9786.tar.xz u-boot-d98cdf6a9212ab2727eedb6781a46acaf23f9786.zip |
efi_loader: Improve install_configuration_table
The INSTALL_CONFIGURATION_TABLE callback also provides the ability to
remove table entries. This patch adds that functionality.
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 9a1a93fade..17c531a480 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -630,6 +630,17 @@ static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol, return EFI_EXIT(EFI_NOT_FOUND); } +/* Collapses configuration table entries, removing index i */ +static void efi_remove_configuration_table(int i) +{ + struct efi_configuration_table *this = &efi_conf_table[i]; + struct efi_configuration_table *next = &efi_conf_table[i+1]; + struct efi_configuration_table *end = &efi_conf_table[systab.nr_tables]; + + memmove(this, next, (ulong)end - (ulong)next); + systab.nr_tables--; +} + efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table) { int i; @@ -637,11 +648,17 @@ efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table /* Check for guid override */ for (i = 0; i < systab.nr_tables; i++) { if (!guidcmp(guid, &efi_conf_table[i].guid)) { - efi_conf_table[i].table = table; + if (table) + efi_conf_table[i].table = table; + else + efi_remove_configuration_table(i); return EFI_SUCCESS; } } + if (!table) + return EFI_NOT_FOUND; + /* No override, check for overflow */ if (i >= ARRAY_SIZE(efi_conf_table)) return EFI_OUT_OF_RESOURCES; |