[U-Boot] [PATCH v3 02/21] efi: Update efi_smbios_register() to return error code
Heinrich Schuchardt
xypron.glpk at gmx.de
Mon Feb 19 19:27:58 UTC 2018
On 02/19/2018 04:48 PM, Simon Glass wrote:
> This function can fail but gives no indication of failure. Update it to
> return an error when something goes wrong.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v3:
> - Return error value of efi_allocate_pages()
> - Update function comment for write_smbios_table()
> - Add comments on aligment
>
> Changes in v2:
> - Update return type of efi_smbios_register() to efi_status_t
> - Use return value of efi_install_configuration_table
>
> include/efi_loader.h | 9 ++++++++-
> include/smbios.h | 5 +++--
> lib/efi_loader/efi_smbios.c | 18 +++++++++++++-----
> 3 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 07730c3f39..831883287f 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -185,7 +185,14 @@ int efi_net_register(void);
> /* Called by bootefi to make the watchdog available */
> int efi_watchdog_register(void);
> /* Called by bootefi to make SMBIOS tables available */
> -void efi_smbios_register(void);
> +/**
> + * efi_smbios_register() - write out SMBIOS tables
> + *
> + * Called by bootefi to make SMBIOS tables available
> + *
> + * @return 0 if OK, -ENOMEM if no memory is available for the tables
> + */
> +efi_status_t efi_smbios_register(void);
>
> struct efi_simple_file_system_protocol *
> efi_fs_from_path(struct efi_device_path *fp);
> diff --git a/include/smbios.h b/include/smbios.h
> index c24d00e38d..a94dbbd78b 100644
> --- a/include/smbios.h
> +++ b/include/smbios.h
> @@ -232,8 +232,9 @@ typedef int (*smbios_write_type)(ulong *addr, int handle);
> *
> * This writes SMBIOS table at a given address.
> *
> - * @addr: start address to write SMBIOS table
> - * @return: end address of SMBIOS table
> + * @addr: start address to write SMBIOS table. If this is not
> + * 16-byte-aligned then it will be aligned before the table is written
> + * @return: end address of SMBIOS table (and start address for next entry)
> */
> ulong write_smbios_table(ulong addr);
>
> diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
> index ac412e7362..754ae9a5c3 100644
> --- a/lib/efi_loader/efi_smbios.c
> +++ b/lib/efi_loader/efi_smbios.c
> @@ -13,20 +13,28 @@
>
> static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
>
> -void efi_smbios_register(void)
> +efi_status_t efi_smbios_register(void)
> {
> /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
> uint64_t dmi = 0xffffffff;
> /* Reserve 4kb for SMBIOS */
> uint64_t pages = 1;
> int memtype = EFI_RUNTIME_SERVICES_DATA;
> + efi_status_t ret;
>
> - if (efi_allocate_pages(1, memtype, pages, &dmi) != EFI_SUCCESS)
> - return;
Please, use the predefined constant EFI_ALLOCATE_MAX_ADDRESS and not "1".
Your patch is duplicate to
https://lists.denx.de/pipermail/u-boot/2018-February/320488.html
Best regards
Heinrich
> + ret = efi_allocate_pages(1, memtype, pages, &dmi);
> + if (ret)
> + return ret;
>
> - /* Generate SMBIOS tables */
> + /*
> + * Generate SMBIOS tables - we know that efi_allocate_pages() returns
> + * a 4k-aligned address, so it is safe to assume that
> + * write_smbios_table() will write the table at that address.
> + */
> + assert(!(dmi & 0xf));
> write_smbios_table(dmi);
>
> /* And expose them to our EFI payload */
> - efi_install_configuration_table(&smbios_guid, (void*)(uintptr_t)dmi);
> + return efi_install_configuration_table(&smbios_guid,
> + (void *)(uintptr_t)dmi);
> }
>
More information about the U-Boot
mailing list