[U-Boot] [PATCH] WIP: Example changes to build EFI stub for x86

Simon Glass sjg at chromium.org
Wed Apr 6 20:32:18 CEST 2016


Hi Nicolae,

On 6 April 2016 at 09:50, Nicolae Rosia <nicolae.rosia at gmail.com> wrote:
> Hi,
>
> On Wed, Apr 6, 2016 at 6:06 PM, Simon Glass <sjg at chromium.org> wrote:
>> Currently it is not possible to build the 64-bit EFI stub due to changes in
>> the build. To prevent future bit rot, we should add  target for building
>> qemu-x86 as an EFI stub (with U-Boot as a 32-bit payload).
>>
>> This patch provides some hints.
>>
>> Reported-by: Nicolae Rosia <nicolae.rosia at gmail.com>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>
>>  arch/x86/include/asm/types.h | 12 ++++++++----
>>  configs/qemu-x86_defconfig   |  3 +++
>>  include/efi.h                |  2 +-
>>  lib/efi/efi_stub.c           |  6 +++---
>>  4 files changed, 15 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
>> index 766617f..998d70a 100644
>> --- a/arch/x86/include/asm/types.h
>> +++ b/arch/x86/include/asm/types.h
>> @@ -44,11 +44,15 @@ typedef __INT64_TYPE__ s64;
>>  typedef __UINT64_TYPE__ u64;
>>  #endif
>>
>> -#ifdef CONFIG_EFI_STUB_64BIT
>> -#define BITS_PER_LONG 64
>> -#else
>> +/*
>> + * This should be defined only when compiling the stub - see the
>> + * ecmd_u-boot_payload build rule
>> + */
> Are you saying that I should take a look at cmd_u-boot_payload in Makefile?
> I've looked over it and I don't figure out what I should see.

Just the list of files that it builds there (efi.c and efi_stub.c).

>
>> +// #ifdef CONFIG_EFI_STUB_64BIT
>> +// #define BITS_PER_LONG 64
>> +// #else
>>  #define BITS_PER_LONG 32
>> -#endif
>> +// #endif
> This fixes the compilation warnings

Right, but a correct patch will obey the comment immediately above.

>
>>  /* Dma addresses are 32-bits wide.  */
>>
>>  typedef u32 dma_addr_t;
>> diff --git a/configs/qemu-x86_defconfig b/configs/qemu-x86_defconfig
>> index bb9c6cd..2a7087f 100644
>> --- a/configs/qemu-x86_defconfig
>> +++ b/configs/qemu-x86_defconfig
>> @@ -32,3 +32,6 @@ CONFIG_VIDEO_VESA=y
>>  CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
>>  CONFIG_FRAMEBUFFER_VESA_MODE_111=y
>>  CONFIG_USE_PRIVATE_LIBGCC=y
>> +CONFIG_EFI=y
>> +CONFIG_EFI_STUB=y
>> +CONFIG_EFI_STUB_64BIT=y
> Should we create an example defconfig for efi stub and not modify the
> qemu defconfig?

I suggest a new board config called qemu-x86-efi. It can copy qemu,
with the addition of the above three options.

>
>> diff --git a/include/efi.h b/include/efi.h
>> index 1dbc3b7..21921f1 100644
>> --- a/include/efi.h
>> +++ b/include/efi.h
>> @@ -278,7 +278,7 @@ struct efi_priv {
>>  extern char image_base[];
>>
>>  /* Start and end of U-Boot image (for payload) */
>> -extern char _binary_u_boot_dtb_bin_start[], _binary_u_boot_dtb_bin_end[];
>> +extern char _binary_u_boot_bin_start[], _binary_u_boot_bin_end[];
>>
>>  /**
>>   * efi_get_sys_table() - Get access to the main EFI system table
>> diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
>> index 8b4bb4e..1814960 100644
>> --- a/lib/efi/efi_stub.c
>> +++ b/lib/efi/efi_stub.c
>> @@ -354,9 +354,9 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
>>         /* The EFI UART won't work now, switch to a debug one */
>>         use_uart = true;
>>
>> -       memcpy((void *)CONFIG_SYS_TEXT_BASE, _binary_u_boot_dtb_bin_start,
>> -              (ulong)_binary_u_boot_dtb_bin_end -
>> -              (ulong)_binary_u_boot_dtb_bin_start);
>> +       memcpy((void *)CONFIG_SYS_TEXT_BASE, _binary_u_boot_bin_start,
>> +              (ulong)_binary_u_boot_bin_end -
>> +              (ulong)_binary_u_boot_bin_start);
>>
> Thanks, these fixes the compilation errors.
>
>>  #ifdef DEBUG
>>         puts("EFI table at ");
>> --
>> 2.8.0.rc3.226.g39d4020
>>
>
> I'll try to boot test.

OK, but it is still broken without the fix mentioned above.

>
> Best regards,
> Nicolae

Regards,
Simon


More information about the U-Boot mailing list