[U-Boot,v4,02/16] efi: Update some comments related to smbios tables

Message ID 20180516154233.21457-3-sjg@chromium.org
State Accepted
Delegated to: Alexander Graf
Headers show
Series
  • efi: Enable basic sandbox support for EFI loader
Related show

Commit Message

Simon Glass May 16, 2018, 3:42 p.m.
Clarify the operation of this code with some additional comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v4:
- Remove code already applied
- Update subject

Changes in v3:
- Add comments on aligment
- Return error value of efi_allocate_pages()
- Update function comment for write_smbios_table()

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        | 7 +++++++
 include/smbios.h            | 5 +++--
 lib/efi_loader/efi_smbios.c | 7 ++++++-
 3 files changed, 16 insertions(+), 3 deletions(-)

Comments

Heinrich Schuchardt May 16, 2018, 4:30 p.m. | #1
On 05/16/2018 05:42 PM, Simon Glass wrote:
> Clarify the operation of this code with some additional comments.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
> 
> Changes in v4:
> - Remove code already applied
> - Update subject
> 
> Changes in v3:
> - Add comments on aligment
> - Return error value of efi_allocate_pages()
> - Update function comment for write_smbios_table()
> 
> 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        | 7 +++++++
>  include/smbios.h            | 5 +++--
>  lib/efi_loader/efi_smbios.c | 7 ++++++-
>  3 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 2868ca25abb..2519a7c33a7 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -207,6 +207,13 @@ efi_status_t efi_net_register(void);
>  /* Called by bootefi to make the watchdog available */
>  efi_status_t efi_watchdog_register(void);
>  /* Called by bootefi to make SMBIOS tables available */
> +/**
> + * 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 *
> diff --git a/include/smbios.h b/include/smbios.h
> index 79880ef5b5c..97b9ddce237 100644
> --- a/include/smbios.h
> +++ b/include/smbios.h
> @@ -231,8 +231,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 482436e2adb..7c3fc8af0b2 100644
> --- a/lib/efi_loader/efi_smbios.c
> +++ b/lib/efi_loader/efi_smbios.c
> @@ -29,7 +29,12 @@ efi_status_t efi_smbios_register(void)
>  	if (ret != EFI_SUCCESS)
>  		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 */
>
Alexander Graf May 24, 2018, 12:44 p.m. | #2
> Clarify the operation of this code with some additional comments.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Thanks, applied to efi-next

Alex

Patch

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2868ca25abb..2519a7c33a7 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -207,6 +207,13 @@  efi_status_t efi_net_register(void);
 /* Called by bootefi to make the watchdog available */
 efi_status_t efi_watchdog_register(void);
 /* Called by bootefi to make SMBIOS tables available */
+/**
+ * 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 *
diff --git a/include/smbios.h b/include/smbios.h
index 79880ef5b5c..97b9ddce237 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -231,8 +231,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 482436e2adb..7c3fc8af0b2 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -29,7 +29,12 @@  efi_status_t efi_smbios_register(void)
 	if (ret != EFI_SUCCESS)
 		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 */