[U-Boot] [PATCH v2 19/47] efi: Add start-up library code

Bin Meng bmeng.cn at gmail.com
Sun Aug 2 17:00:28 CEST 2015


Hi Simon,

On Fri, Jul 31, 2015 at 11:31 PM, Simon Glass <sjg at chromium.org> wrote:
> When running as an EFI application, U-Boot must request memory from EFI,
> and provide access to the boot services U-Boot needs.
>
> Add library code to perform these tasks. This includes efi_main() which is
> the entry point from EFI. U-Boot is built as a shared library.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>

But please see nits below.

>
> Changes in v2:
> - Add a comment as to why we only allocate pages below 4GB
> - Add a comment as to why we use global_data_ptr
> - Add comments as to why we need efi_memset(), efi_putc(), efi_puts()
> - Avoid useless u64 cast on EFI_RUNTIME_SERVICES_SIGNATURE
> - Drop __packed from struct efi_device_path
> - Explain in a comment how the debug UART is implemented for the EFI app
> - Fix 'command problem' typo - it should say 'command prompt'
> - Fix 'withU-Boot.' typo
> - Fix a few comment typos
> - Fix efi_mem_desc_VERSION typo
> - Fix mention of CHAR16 which should be wchar_t
> - Fix missing struct comments
> - Move the 64-bit payload code to a later patch
> - Rename CONFIG_ARCH_EFI to CONFIG_EFI_APP
> - Reword the efi_putc() unicode comment to make more sense
> - Use image_base instead of ImageBase
> - Use one-line comments when appropriate
> - Use reserved instead of __reserved in struct efi_boot_services
>
>  arch/x86/include/asm/fsp/fsp_hob.h |  59 +-----
>  include/efi.h                      | 357 +++++++++++++++++++++++++++++++++++++
>  include/efi_api.h                  | 244 +++++++++++++++++++++++++
>  include/part_efi.h                 |   9 +-
>  lib/Kconfig                        |   2 +
>  lib/Makefile                       |   1 +
>  lib/efi/Kconfig                    |  33 ++++
>  lib/efi/Makefile                   |   7 +
>  lib/efi/efi.c                      | 101 +++++++++++
>  lib/efi/efi_app.c                  | 139 +++++++++++++++
>  10 files changed, 888 insertions(+), 64 deletions(-)
>  create mode 100644 include/efi.h
>  create mode 100644 include/efi_api.h
>  create mode 100644 lib/efi/Kconfig
>  create mode 100644 lib/efi/Makefile
>  create mode 100644 lib/efi/efi.c
>  create mode 100644 lib/efi/efi_app.c
>

[snip]

> +/**
> + * struct efi_entry_hdr - Header for a table entry
> + *
> + * @type:      enum eft_entry_t
> + * @size       size of entry bytes excluding header and padding
> + * @addr:      address of this entry (0 if it follows the header )
> + * @link:      size of entry including header and padding
> + * @spare1:    Spare space for expansion
> + * @spare2:    Spare space for expansion
> + * @

Nits: please remove this @

> + */
> +struct efi_entry_hdr {
> +       u32 type;
> +       u32 size;
> +       u64 addr;
> +       u32 link;
> +       u32 spare1;
> +       u64 spare2;
> +};

[snip]

> diff --git a/lib/efi/efi.c b/lib/efi/efi.c
> new file mode 100644
> index 0000000..c6454ea
> --- /dev/null
> +++ b/lib/efi/efi.c
> @@ -0,0 +1,101 @@
> +/*
> + * Copyright (c) 2015 Google, Inc
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + *
> + * EFI information obtained here:
> + * http://wiki.phoenix.com/wiki/index.php/EFI_BOOT_SERVICES
> + *
> + * Common EFI functions
> + */
> +
> +#include <common.h>
> +#include <debug_uart.h>
> +#include <errno.h>
> +#include <linux/err.h>
> +#include <linux/types.h>
> +#include <efi.h>
> +#include <efi_api.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/*
> + * Unfortunately we cannot access any code outside what be build especially

Nits: what is built?

> + * for the stub. lib/string.c is already being built for the U-Boot payload
> + * so it using the wrong compiler flags. Add our own memset() here.

Nits: using -> uses?

> + */
> +static void efi_memset(void *ptr, int ch, int size)
> +{
> +       char *dest = ptr;
> +
> +       while (size-- > 0)
> +               *dest++ = ch;
> +}

[snip]

Regards,
Bin


More information about the U-Boot mailing list