x86: efi: Fixes and enhancements to application and payload support
Subsystems (2)
v2 cover x86: efi: Fixes and enhancements to application and payload support
Unfortunately the EFI x86 application and payload support have been broken for quite a while. This series addresses various bug fixes, plus several enhancements like toolchain compatibility (eg: kernel.org i386-linux-gcc), introduction of generic EFI payload which can run on any x86 board, and a EFI framebuffer driver for the payload.
This series is available at u-boot-x86/efi-working for testing.
Changes in v2:
- update the x86 doc to reference also README.uefi
- new patch to "change __kernel_size_t conditionals to use compiler provided defines"
- update README.u-boot_on_efi to reflect directory changes
- update README.u-boot_on_efi to mention generic EFI payload support
- update QEMU MAINTAINERS file to remove defconfig files
- update README.u-boot_on_efi to use efi-x86_app
- drop patches that were already applied to u-boot-x86
Alexander Graf (1):
efi.h: Do not use config options
Bin Meng (12):
x86: doc: Fix reference to EFI doc in U-Boot
x86: Change __kernel_size_t conditionals to use compiler provided
defines
x86: efi: Refactor the directory of EFI app and payload support
x86: efi: payload: Add arch_cpu_init()
x86: Add generic EFI payload support
x86: Drop QEMU-specific EFI payload support
x86: baytrail: Drop EFI-specific test logics
efi: stub: Pass EFI GOP information to U-Boot payload
dm: video: Add an EFI framebuffer driver
x86: efi: payload: Add EFI framebuffer driver support
x86: Rename efi-x86 target to efi-x86_app
x86: efi: app: Display correct CPU info during boot
arch/x86/Kconfig | 3 +-
arch/x86/cpu/Makefile | 2 +-
arch/x86/cpu/baytrail/Kconfig | 6 +-
arch/x86/cpu/baytrail/valleyview.c | 3 -
arch/x86/{lib => cpu}/efi/Kconfig | 0
arch/x86/cpu/efi/Makefile | 9 +-
arch/x86/cpu/efi/{efi.c => app.c} | 2 +-
arch/x86/{lib => cpu}/efi/car.S | 0
arch/x86/{lib/efi/efi.c => cpu/efi/payload.c} | 11 +-
arch/x86/cpu/intel_common/Makefile | 2 +-
arch/x86/cpu/qemu/Makefile | 2 -
arch/x86/cpu/qemu/qemu.c | 4 -
arch/x86/dts/Makefile | 3 +-
arch/x86/dts/{efi.dts => efi-x86_app.dts} | 4 +-
arch/x86/dts/efi-x86_payload.dts | 40 ++++++
arch/x86/include/asm/posix_types.h | 2 +-
arch/x86/lib/Makefile | 1 -
arch/x86/lib/efi/Makefile | 7 -
board/advantech/som-db5800-som-6867/Kconfig | 5 +-
board/congatec/conga-qeval20-qa3-e3845/Kconfig | 5 +-
board/dfi/dfi-bt700/Kconfig | 5 +-
board/efi/Kconfig | 15 ++-
board/efi/{efi-x86 => efi-x86_app}/Kconfig | 6 +-
board/efi/{efi-x86 => efi-x86_app}/MAINTAINERS | 0
board/efi/{efi-x86 => efi-x86_app}/Makefile | 2 +-
board/efi/{efi-x86/efi.c => efi-x86_app/app.c} | 0
board/efi/efi-x86_payload/Kconfig | 39 ++++++
board/efi/efi-x86_payload/MAINTAINERS | 7 +
board/efi/efi-x86_payload/Makefile | 5 +
board/efi/efi-x86_payload/start.S | 8 ++
board/emulation/qemu-x86/Kconfig | 6 +-
board/emulation/qemu-x86/MAINTAINERS | 2 -
board/intel/minnowmax/Kconfig | 5 +-
.../{efi-x86_defconfig => efi-x86_app_defconfig} | 4 +-
...oad32_defconfig => efi-x86_payload32_defconfig} | 24 +---
...oad64_defconfig => efi-x86_payload64_defconfig} | 24 +---
doc/README.u-boot_on_efi | 33 ++---
doc/README.x86 | 14 +-
drivers/video/Kconfig | 9 ++
drivers/video/Makefile | 1 +
drivers/video/efi.c | 146 +++++++++++++++++++++
include/configs/{efi-x86.h => efi-x86_app.h} | 0
include/configs/efi-x86_payload.h | 32 +++++
include/efi.h | 52 ++++++--
lib/efi/Makefile | 4 +-
lib/efi/efi_stub.c | 15 +++
46 files changed, 433 insertions(+), 136 deletions(-)
rename arch/x86/{lib => cpu}/efi/Kconfig (100%)
rename arch/x86/cpu/efi/{efi.c => app.c} (92%)
rename arch/x86/{lib => cpu}/efi/car.S (100%)
rename arch/x86/{lib/efi/efi.c => cpu/efi/payload.c} (97%)
rename arch/x86/dts/{efi.dts => efi-x86_app.dts} (82%)
create mode 100644 arch/x86/dts/efi-x86_payload.dts
delete mode 100644 arch/x86/lib/efi/Makefile
rename board/efi/{efi-x86 => efi-x86_app}/Kconfig (64%)
rename board/efi/{efi-x86 => efi-x86_app}/MAINTAINERS (100%)
rename board/efi/{efi-x86 => efi-x86_app}/Makefile (82%)
rename board/efi/{efi-x86/efi.c => efi-x86_app/app.c} (100%)
create mode 100644 board/efi/efi-x86_payload/Kconfig
create mode 100644 board/efi/efi-x86_payload/MAINTAINERS
create mode 100644 board/efi/efi-x86_payload/Makefile
create mode 100644 board/efi/efi-x86_payload/start.S
rename configs/{efi-x86_defconfig => efi-x86_app_defconfig} (92%)
rename configs/{qemu-x86_efi_payload32_defconfig => efi-x86_payload32_defconfig} (61%)
rename configs/{qemu-x86_efi_payload64_defconfig => efi-x86_payload64_defconfig} (62%)
create mode 100644 drivers/video/efi.c
rename include/configs/{efi-x86.h => efi-x86_app.h} (100%)
create mode 100644 include/configs/efi-x86_payload.hSignature · 1 line
2.7.4
PATCH v2 1/13 x86: doc: Fix reference to EFI doc in U-Boot
Since commit f3b5056c4e72 ("efi_loader: split README.efi into two separate documents"), the original README.efi was renamed to README.u-boot_on_efi, but x86 doc still refers to the old one.
This updates the x86 doc to reference both README.u-boot_on_efi and README.uefi.
---
Changes in v2:
- update the x86 doc to reference also README.uefi
doc/README.x86 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
doc/README.x86 +7 -7
@@ -1134,18 +1134,18 @@ the "Power" submenu from the Windows start menu. EFI Support ----------- U-Boot supports booting as a 32-bit or 64-bit EFI payload, e.g. with UEFI. -This is enabled with CONFIG_EFI_STUB. U-Boot can also run as an EFI -application, with CONFIG_EFI_APP. The CONFIG_EFI_LOADER option, where U-Booot -provides an EFI environment to the kernel (i.e. replaces UEFI completely but -provides the same EFI run-time services) is not currently supported on x86. +This is enabled with CONFIG_EFI_STUB to boot from both 32-bit and 64-bit +UEFI BIOS. U-Boot can also run as an EFI application, with CONFIG_EFI_APP. +The CONFIG_EFI_LOADER option, where U-Booot provides an EFI environment to +the kernel (i.e. replaces UEFI completely but provides the same EFI run-time +services) is not currently supported on x86. -See README.efi for details of EFI support in U-Boot. +See README.u-boot_on_efi and README.uefi for details of EFI support in U-Boot. 64-bit Support -------------- U-Boot supports booting a 64-bit kernel directly and is able to change to -64-bit mode to do so. It also supports (with CONFIG_EFI_STUB) booting from -both 32-bit and 64-bit UEFI. However, U-Boot itself is currently always built +64-bit mode to do so. However, U-Boot itself is currently always built in 32-bit mode. Some access to the full memory range is provided with arch_phys_memset().
Signature · 1 line
2.7.4
PATCH v2 1/13 x86: doc: Fix reference to EFI doc in U-Boot
Quoted 23 lines · Bin Meng
Since commit
f3b5056c4e72("efi_loader: split README.efi into two separate documents"), the original README.efi was renamed to README.u-boot_on_efi, but x86 doc still refers to the old one.This updates the x86 doc to reference both README.u-boot_on_efi and README.uefi.
Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update the x86 doc to reference also README.uefidoc/README.x86 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)doc/README.x86 +0
-0@@ -1134,18 +1134,18 @@ the "Power" submenu from the Windows start menu. EFI Support -----------
doc/README.x86 the "Power" submenu from the Windows start menu. · line 1141
Quoted 10 lines
doc/README.x86 +5
-4U-Boot supports booting as a 32-bit or 64-bit EFI payload, e.g. with UEFI. -This is enabled with CONFIG_EFI_STUB. U-Boot can also run as an EFI -application, with CONFIG_EFI_APP. The CONFIG_EFI_LOADER option, where U-Booot -provides an EFI environment to the kernel (i.e. replaces UEFI completely but -provides the same EFI run-time services) is not currently supported on x86. +This is enabled with CONFIG_EFI_STUB to boot from both 32-bit and 64-bit +UEFI BIOS. U-Boot can also run as an EFI application, with CONFIG_EFI_APP. +The CONFIG_EFI_LOADER option, where U-Booot provides an EFI environment to +the kernel (i.e. replaces UEFI completely but provides the same EFI run-time +services) is not currently supported on x86.
Do you mean
"is not currently supported on x86 in conjunction with EFI_STUB" or do you mean
"still has bugs on x86"?
On qemu-x86_defconfig I can start EFI applications like the helloworld.efi and ipxe. It is only the Linux kernel that has a problem with memory setup. That is of cause a bug that needs further attention.
Best regards
Heinrich
Quoted 14 lines
doc/README.x86 +2
-3-See README.efi for details of EFI support in U-Boot. +See README.u-boot_on_efi and README.uefi for details of EFI support in U-Boot. 64-bit Support -------------- U-Boot supports booting a 64-bit kernel directly and is able to change to -64-bit mode to do so. It also supports (with CONFIG_EFI_STUB) booting from -both 32-bit and 64-bit UEFI. However, U-Boot itself is currently always built +64-bit mode to do so. However, U-Boot itself is currently always built in 32-bit mode. Some access to the full memory range is provided with arch_phys_memset().
PATCH v2 1/13 x86: doc: Fix reference to EFI doc in U-Boot
Hi Heinrich,
Quoted 40 lines · Heinrich Schuchardt
Quoted 23 lines · Bin Meng
Since commit
f3b5056c4e72("efi_loader: split README.efi into two separate documents"), the original README.efi was renamed to README.u-boot_on_efi, but x86 doc still refers to the old one.This updates the x86 doc to reference both README.u-boot_on_efi and README.uefi.
Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update the x86 doc to reference also README.uefidoc/README.x86 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)doc/README.x86 +0
-0@@ -1134,18 +1134,18 @@ the "Power" submenu from the Windows start menu. EFI Support -----------doc/README.x86 the "Power" submenu from the Windows start menu. · line 1141
Quoted 10 lines
doc/README.x86 +5
-4U-Boot supports booting as a 32-bit or 64-bit EFI payload, e.g. with UEFI. -This is enabled with CONFIG_EFI_STUB. U-Boot can also run as an EFI -application, with CONFIG_EFI_APP. The CONFIG_EFI_LOADER option, where U-Booot -provides an EFI environment to the kernel (i.e. replaces UEFI completely but -provides the same EFI run-time services) is not currently supported on x86. +This is enabled with CONFIG_EFI_STUB to boot from both 32-bit and 64-bit +UEFI BIOS. U-Boot can also run as an EFI application, with CONFIG_EFI_APP. +The CONFIG_EFI_LOADER option, where U-Booot provides an EFI environment to +the kernel (i.e. replaces UEFI completely but provides the same EFI run-time +services) is not currently supported on x86.Do you mean
"is not currently supported on x86 in conjunction withEFI_STUB" or do you mean
"still has bugs on x86"?
Quoted 4 lines
On qemu-x86_defconfig I can start EFI applications like the helloworld.efi and ipxe. It is only the Linux kernel that has a problem with memory setup. That is of cause a bug that needs further attention.
I did not touch this when I updated the doc. I believe the doc means CONFIG_EFI_LOADER is not currently supported. As you mentioned, there are still some issues to work out. Maybe after you address all the remaining issues, we can update the doc for its support :)
Regards,
Bin
PATCH v2 1/13 x86: doc: Fix reference to EFI doc in U-Boot
Hi Heinrich,
Quoted 49 lines · Bin Meng
Hi Heinrich,
Quoted 40 lines · Heinrich Schuchardt
Quoted 23 lines · Bin Meng
Since commit
f3b5056c4e72("efi_loader: split README.efi into two separate documents"), the original README.efi was renamed to README.u-boot_on_efi, but x86 doc still refers to the old one.This updates the x86 doc to reference both README.u-boot_on_efi and README.uefi.
Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update the x86 doc to reference also README.uefidoc/README.x86 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)doc/README.x86 +0
-0@@ -1134,18 +1134,18 @@ the "Power" submenu from the Windows start menu. EFI Support -----------doc/README.x86 the "Power" submenu from the Windows start menu. · line 1141
Quoted 10 lines
doc/README.x86 +5
-4U-Boot supports booting as a 32-bit or 64-bit EFI payload, e.g. with UEFI. -This is enabled with CONFIG_EFI_STUB. U-Boot can also run as an EFI -application, with CONFIG_EFI_APP. The CONFIG_EFI_LOADER option, where U-Booot -provides an EFI environment to the kernel (i.e. replaces UEFI completely but -provides the same EFI run-time services) is not currently supported on x86. +This is enabled with CONFIG_EFI_STUB to boot from both 32-bit and 64-bit +UEFI BIOS. U-Boot can also run as an EFI application, with CONFIG_EFI_APP. +The CONFIG_EFI_LOADER option, where U-Booot provides an EFI environment to +the kernel (i.e. replaces UEFI completely but provides the same EFI run-time +services) is not currently supported on x86.Do you mean
"is not currently supported on x86 in conjunction withEFI_STUB" or do you mean
"still has bugs on x86"?Quoted 4 lines
On qemu-x86_defconfig I can start EFI applications like the helloworld.efi and ipxe. It is only the Linux kernel that has a problem with memory setup. That is of cause a bug that needs further attention.
Quoted 4 lines
I did not touch this when I updated the doc. I believe the doc means
CONFIG_EFI_LOADERis not currently supported. As you mentioned, there are still some issues to work out. Maybe after you address all the remaining issues, we can update the doc for its support :)
I tested CONFIG_EFI_LOADER today, with U-Boot loads EFI application and EFI payload, on 32-bit QEMU. Here is the log:
=> load ide 0 1000000 u-boot-app.efi
683843 bytes read in 105 ms (6.2 MiB/s)
=> bootefi 1000000
Scanning disk ide.blk#0...
Found 2 disks
WARNING: booting without device tree
## Starting EFI application at 01000000 ...
U-Boot EFI App starting
U-Boot 2018.07-rc1-00097-gc5eea16 (Jun 12 2018 - 23:02:03 +0800)
CPU: x86_64, vendor AMD, device 663h DRAM: 32 MiB Model: EFI x86 Application Hit any key to stop autoboot: 0
=>
=> reset
resetting ...
U-Boot EFI exiting
## Application terminated, r = 0
=>
=>
=> load ide 0 1000000 u-boot-payload.efi
486203 bytes read in 94 ms (4.9 MiB/s)
=> bootefi 1000000
WARNING: booting without device tree
## Starting EFI application at 01000000 ...
U-Boot EFI Payload
U-Boot 2018.07-rc1-00097-gc5eea16 (Jun 12 2018 - 23:01:24 +0800)
CPU: x86_64, vendor AMD, device 663h
DRAM: 108.2 MiB
MMC:
Video: 1024x768x32 Model: EFI x86 Payload Net: No ethernet found. IDE: Bus 0: OK Bus 1: OK
Device 0: Model: QEMU HARDDISK Firm: 2.5+ Ser#: QM00001
Type: Hard Disk
Supports 48-bit addressing
Capacity: 504.0 MB = 0.4 GB (1032192 x 512)
Device 1: not available
Device 2: Model: QEMU Firm: 2.5+ Ser#: QEMU DVD-ROM
Type: Removable CD ROM
Capacity: not available
Device 3: not available
Hit any key to stop autoboot: 0
=>
=>
I can update the documentation to change CONFIG_EFI_LOADER support status, but that is a separate patch.
Regards,
Bin
PATCH v2 1/13 x86: doc: Fix reference to EFI doc in U-Boot
In reply to Bin MengQuoted 7 lines · Bin Meng
Since commit
f3b5056c4e72("efi_loader: split README.efi into two separate documents"), the original README.efi was renamed to README.u-boot_on_efi, but x86 doc still refers to the old one.This updates the x86 doc to reference both README.u-boot_on_efi and README.uefi.
Quoted 9 lines
Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update the x86 doc to reference also README.uefidoc/README.x86 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
applied to u-boot-x86, thanks!
PATCH v2 2/13 efi.h: Do not use config options
In reply to Bin MengFrom: Alexander Graf <[email protected]>
Currently efi.h determines a few bits of its environment according to config options. This falls apart with the efi stub support which may result in efi.h getting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.
This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
---
Changes in v2: None
include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-)
include/efi.h +4 -13
@@ -19,12 +19,12 @@#include <linux/string.h> #include <linux/types.h> -#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ struct efi_device_path ;
@@ -32,16 +32,7 @@ typedef struct {u8 b[16 ]; } efi_guid_t; -#define EFI_BITS_PER_LONG BITS_PER_LONG - -/* -* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set -* in lib/efi/Makefile, when building the stub. -*/ -#if defined(CONFIG_EFI_STUB_64BIT ) && defined(EFI_STUB ) -#undef EFI_BITS_PER_LONG -#define EFI_BITS_PER_LONG 64 -#endif +#define EFI_BITS_PER_LONG (sizeof(long) * 8)/* Bit mask for EFI status code with error */ #define EFI_ERROR_MASK (1UL << (EFI_BITS_PER_LONG - 1))
lib/efi/Makefile +2 -2
@@ -7,11 +7,11 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB \ +CFLAGS_efi_stub.o := -fpic -fshort-wchar \ $(if $(CONFIG_EFI_STUB_64BIT),-m64) CFLAGS_REMOVE_efi.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB \ +CFLAGS_efi.o := -fpic -fshort-wchar \ $(if $(CONFIG_EFI_STUB_64BIT),-m64) extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
Signature · 1 line
2.7.4
PATCH v2 2/13 efi.h: Do not use config options
Hi Bin, Alex,
Quoted 30 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v2: None
include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-)include/efi.h +0
-0@@ -19,12 +19,12 @@#include <linux/string.h> #include <linux/types.h>
include/efi.h line 27
Quoted 10 lines
include/efi.h +3
-3-#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */
I made the same comment in another patch. This is becoming too ad-hoc where making EFI builds work is distributed and hidden in such a way that no one will be able to know whether a change causes problems or not.
I feel that build config should be deterministic given the CONFIG options provided by the board. Any checks of compiler predefines should be done in one place (efi.h?) and bugs in that stuff should there all be in one place too, and easier to debug and fix.
Regards,
Simon
PATCH v2 2/13 efi.h: Do not use config options
Quoted 49 lines · Simon Glass
Hi Bin, Alex,
Quoted 30 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v2: None
include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-)include/efi.h +0
-0@@ -19,12 +19,12 @@#include <linux/string.h> #include <linux/types.h> include/efi.h line 27
Quoted 10 lines
include/efi.h +3
-3-#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ I made the same comment in another patch. This is becoming too ad-hoc where making EFI builds work is distributed and hidden in such a way that no one will be able to know whether a change causes problems or not.
Quoted 4 lines
I feel that build config should be deterministic given the CONFIG options provided by the board. Any checks of compiler predefines should be done in one place (
efi.h?) and bugs in that stuff should there all be in one place too, and easier to debug and fix.
I actually think the opposite is true. We should get rid of any #ifdef CONFIG_ARCH checks throughout the code base that are not meant to actually check for the "target" (sandbox for example), but instead really only want to know the architecture the code is building against.
We can easily trust the compiler to emit correct defines for the target architecture it's building against. That's what every other piece of C code on earth depends on. Why be different?
Alex
PATCH v2 2/13 efi.h: Do not use config options
Hi Alex,
Quoted 57 lines · Alexander Graf
Quoted 49 lines · Simon Glass
Hi Bin, Alex,
Quoted 30 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v2: None
include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-)include/efi.h +0
-0@@ -19,12 +19,12 @@#include <linux/string.h> #include <linux/types.h> include/efi.h line 27
Quoted 10 lines
include/efi.h +3
-3-#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ I made the same comment in another patch. This is becoming too ad-hoc where making EFI builds work is distributed and hidden in such a way that no one will be able to know whether a change causes problems or not.
Quoted 4 lines
I feel that build config should be deterministic given the CONFIG options provided by the board. Any checks of compiler predefines should be done in one place (
efi.h?) and bugs in that stuff should there all be in one place too, and easier to debug and fix.
Quoted 8 lines
I actually think the opposite is true. We should get rid of any #ifdef
CONFIG_ARCHchecks throughout the code base that are not meant to actually check for the "target" (sandbox for example), but instead really only want to know the architecture the code is building against.We can easily trust the compiler to emit correct defines for the target architecture it's building against. That's what every other piece of C code on earth depends on. Why be different?
By this logic we would check for __x86_64__ everywhere instead of CONFIG_X86. I can't think of a better way to explain this without repeating myself.
Bin, do you understand what I am getting at? Are my concerns unwarranted?
Regards,
Simon
PATCH v2 2/13 efi.h: Do not use config options
Quoted 62 lines · Simon Glass
Hi Alex,
Quoted 59 lines · Alexander Graf
Quoted 48 lines · Simon Glass
Hi Bin, Alex,
Quoted 30 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v2: None
include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-)include/efi.h +0
-0@@ -19,12 +19,12 @@#include <linux/string.h> #include <linux/types.h> include/efi.h line 27
Quoted 10 lines
include/efi.h +3
-3-#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ I made the same comment in another patch. This is becoming too ad-hoc where making EFI builds work is distributed and hidden in such a way that no one will be able to know whether a change causes problems or not.
Quoted 4 lines
I feel that build config should be deterministic given the CONFIG options provided by the board. Any checks of compiler predefines should be done in one place (
efi.h?) and bugs in that stuff should there all be in one place too, and easier to debug and fix.I actually think the opposite is true. We should get rid of any #ifdef
CONFIG_ARCHchecks throughout the code base that are not meant to actually check for the "target" (sandbox for example), but instead really only want to know the architecture the code is building against.
Quoted 6 lines
Quoted 3 lines
We can easily trust the compiler to emit correct defines for the target architecture it's building against. That's what every other piece of C code on earth depends on. Why be different?
By this logic we would check for
__x86_64__everywhere instead ofCONFIG_X86. I can't think of a better way to explain this without repeating myself.
That's my point. I think most cases that check for CONFIG_X86 are just plain wrong.
Alex
PATCH v2 2/13 efi.h: Do not use config options
In reply to Simon GlassHi Simon,
Quoted 69 lines · Simon Glass
Hi Alex,
Quoted 57 lines · Alexander Graf
Quoted 49 lines · Simon Glass
Hi Bin, Alex,
Quoted 30 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v2: None
include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-)include/efi.h +0
-0@@ -19,12 +19,12 @@#include <linux/string.h> #include <linux/types.h> include/efi.h line 27
Quoted 10 lines
include/efi.h +3
-3-#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ I made the same comment in another patch. This is becoming too ad-hoc where making EFI builds work is distributed and hidden in such a way that no one will be able to know whether a change causes problems or not.
Quoted 4 lines
I feel that build config should be deterministic given the CONFIG options provided by the board. Any checks of compiler predefines should be done in one place (
efi.h?) and bugs in that stuff should there all be in one place too, and easier to debug and fix.Quoted 8 lines
I actually think the opposite is true. We should get rid of any #ifdef
CONFIG_ARCHchecks throughout the code base that are not meant to actually check for the "target" (sandbox for example), but instead really only want to know the architecture the code is building against.We can easily trust the compiler to emit correct defines for the target architecture it's building against. That's what every other piece of C code on earth depends on. Why be different?
Quoted 5 lines
By this logic we would check for
__x86_64__everywhere instead ofCONFIG_X86. I can't think of a better way to explain this without repeating myself.Bin, do you understand what I am getting at? Are my concerns unwarranted?
I got what you are concerned about. I guess you wanted to say "By this logic we would check __x86_64__ everywhere instead of *CONFIG_X86_64*" As when CONFIG_X86_64 is defined, the "-m64" flag is passed to compiler, and __x86_64__ takes effect. But I think this can only be applied in source codes. In makefiles, we still need CONFIG_X86_64.
For the bug we are trying to address here, I believe current patch to test __x86_64__ is the simplest way compared to a bunch of config options checks. In fact, __x86_64__ contains enough information to fix the problem, and the config options checks look superfluous.
How about we add some comments to the changes above to explain some more details? Does that look better?
Regards,
Bin
PATCH v2 2/13 efi.h: Do not use config options
Hi Bin,
Quoted 84 lines · Bin Meng
Hi Simon,
Quoted 69 lines · Simon Glass
Hi Alex,
Quoted 57 lines · Alexander Graf
Quoted 49 lines · Simon Glass
Hi Bin, Alex,
Quoted 30 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v2: None
include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-)include/efi.h +0
-0@@ -19,12 +19,12 @@#include <linux/string.h> #include <linux/types.h> include/efi.h line 27
Quoted 10 lines
include/efi.h +3
-3-#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ I made the same comment in another patch. This is becoming too ad-hoc where making EFI builds work is distributed and hidden in such a way that no one will be able to know whether a change causes problems or not.
Quoted 4 lines
I feel that build config should be deterministic given the CONFIG options provided by the board. Any checks of compiler predefines should be done in one place (
efi.h?) and bugs in that stuff should there all be in one place too, and easier to debug and fix.Quoted 8 lines
I actually think the opposite is true. We should get rid of any #ifdef
CONFIG_ARCHchecks throughout the code base that are not meant to actually check for the "target" (sandbox for example), but instead really only want to know the architecture the code is building against.We can easily trust the compiler to emit correct defines for the target architecture it's building against. That's what every other piece of C code on earth depends on. Why be different?
Quoted 5 lines
By this logic we would check for
__x86_64__everywhere instead ofCONFIG_X86. I can't think of a better way to explain this without repeating myself.Bin, do you understand what I am getting at? Are my concerns unwarranted?
I got what you are concerned about. I guess you wanted to say "By this logic we would check
__x86_64__everywhere instead of *CONFIG_X86_64*" As whenCONFIG_X86_64is defined, the "-m64" flag is passed to compiler, and__x86_64__takes effect. But I think this can only be applied in source codes. In makefiles, we still needCONFIG_X86_64.
Quoted 7 lines
For the bug we are trying to address here, I believe current patch to test
__x86_64__is the simplest way compared to a bunch of config options checks. In fact,__x86_64__contains enough information to fix the problem, and the config options checks look superfluous.How about we add some comments to the changes above to explain some more details? Does that look better?
Thanks for looking at this.
Yes comments would really help, thanks.
Regards,
Simon
PATCH v2 3/13 x86: Change __kernel_size_t conditionals to use compiler provided defines
In reply to Bin MengSince commit bb0bb91cf0aa ("efi_stub: Use efi_uintn_t"), EFI x86 64-bit payload does not work anymore. The call to GetMemoryMap() in efi_stub.c fails with return code EFI_INVALID_PARAMETER. Since the payload itself is still 32-bit U-Boot, efi_uintn_t gets wrongly interpreted as int, but it should actually be long in a 64-bit EFI environment.
This changes the x86 __kernel_size_t conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
---
Changes in v2:
- new patch to "change __kernel_size_t conditionals to use compiler provided defines"
arch/x86/include/asm/posix_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/posix_types.h +1 -1
@@ -16,7 +16,7 @@ typedef int __kernel_pid_t;typedef unsigned short __kernel_ipc_pid_t ;typedef unsigned short __kernel_uid_t ;typedef unsigned short __kernel_gid_t ; -#if CONFIG_IS_ENABLED (X86_64 ) +#if defined __x86_64__typedef unsigned long __kernel_size_t ;typedef long __kernel_ssize_t ;#else
Signature · 1 line
2.7.4
PATCH v2 3/13 x86: Change __kernel_size_t conditionals to use compiler provided defines
Quoted 7 lines · Bin Meng
Since commit
bb0bb91cf0aa("efi_stub: Useefi_uintn_t"), EFI x86 64-bit payload does not work anymore. The call toGetMemoryMap()inefi_stub.cfails with return codeEFI_INVALID_PARAMETER. Since the payload itself is still 32-bit U-Boot,efi_uintn_tgets wrongly interpreted as int, but it should actually be long in a 64-bit EFI environment.
Quoted 6 lines
This changes the x86
__kernel_size_tconditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.Fixes bb0bb91cf0aa ("efi_stub: Use efi_uintn_t")Signed-off-by Bin Meng <[email protected]>
Alex
Quoted 24 lines
---
Changes in v2:
- new patch to "change__kernel_size_tconditionals to use compiler provided defines"arch/x86/include/asm/posix_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/asm/posix_types.h +1
-1@@ -16,7 +16,7 @@ typedef int __kernel_pid_t;typedef unsigned short __kernel_ipc_pid_t ;typedef unsigned short __kernel_uid_t ;typedef unsigned short __kernel_gid_t ; -#if CONFIG_IS_ENABLED (X86_64 ) +#if defined __x86_64__typedef unsigned long __kernel_size_t ;typedef long __kernel_ssize_t ;#else
PATCH v2 3/13 x86: Change __kernel_size_t conditionals to use compiler provided defines
In reply to Bin MengHi Bin,
Quoted 28 lines · Bin Meng
Since commit
bb0bb91cf0aa("efi_stub: Useefi_uintn_t"), EFI x86 64-bit payload does not work anymore. The call toGetMemoryMap()inefi_stub.cfails with return codeEFI_INVALID_PARAMETER. Since the payload itself is still 32-bit U-Boot,efi_uintn_tgets wrongly interpreted as int, but it should actually be long in a 64-bit EFI environment.This changes the x86
__kernel_size_tconditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.Fixes bb0bb91cf0aa ("efi_stub: Use efi_uintn_t")Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- new patch to "change__kernel_size_tconditionals to use compiler provided defines"arch/x86/include/asm/posix_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/asm/posix_types.h +0
-0
arch/x86/include/asm/posix_types.h typedef int __kernel_pid_t; · line 19
Quoted 5 lines
arch/x86/include/asm/posix_types.h +1
-1@@ -16,7 +16,7 @@ typedef int __kernel_pid_t;typedef unsigned short __kernel_ipc_pid_t ;typedef unsigned short __kernel_uid_t ;typedef unsigned short __kernel_gid_t ; -#if CONFIG_IS_ENABLED (X86_64 ) +#if defined __x86_64__
Ick.
I worry that this is hiding an EFI peculiarity in generic code.
We have a lot of occurrences of '-#if CONFIG_IS_ENABLED(X86_64)' and it is not obvious why this one is wrong and the others are correct. A change to posix_types will presumably affect other things too.
I'm not sure of the best way to solve this,
Is it possible /sensible to introduce a new CONFIG which selects int or long for these types? I am not even sure what it could be called, but then it could normally be set according to the X86_64 setting (in U-Boot or SPL) but changed by EFI.
Or is this not a config setting, but a modulation of a config setting? If so, then perhaps we can have:
#if CONFIG_IS_ENABLED(X86_64)
# if <some EFI condition> #define USE_LONG_FOR_64BIT #else #define USE_INT_FOR_64BIT #else #define USE_LONG_FOR_64BIT #endif
But in any case I think we need something explicit for the particular '64-bit int' needed by this particular build of EFI.
I suppose another possibility is that efi_stub.c should not use efi_uintn_t and we should just revert that patch? At present the 64-bit stub is quite clearly differentiated from the rest of U-Boot. Are we just going to end up with a spiderweb of problems here?
Quoted 6 lines
arch/x86/include/asm/posix_types.h +0
-1typedef unsigned long __kernel_size_t ;typedef long __kernel_ssize_t ;#else --2.7.4
Regards,
Simon
PATCH v2 4/13 x86: efi: Refactor the directory of EFI app and payload support
In reply to Bin MengAt present the EFI application and payload support codes in the x86 directory is distributed in a hybrid way. For example, the Kconfig options for both app and payload are in arch/x86/lib/efi/Kconfig, but the source codes in the same directory get built only for CONFIG_EFI_STUB.
This refactors the codes by consolidating all the EFI support codes into arch/x86/cpu/efi, just like other x86 targets.
---
Changes in v2:
- update README.u-boot_on_efi to reflect directory changes
arch/x86/Kconfig | 3 +--
arch/x86/cpu/Makefile | 2 +-
arch/x86/{lib => cpu}/efi/Kconfig | 0
arch/x86/cpu/efi/Makefile | 7 +++++++
arch/x86/{lib => cpu}/efi/car.S | 0
arch/x86/{lib/efi/efi.c => cpu/efi/payload.c} | 0
arch/x86/lib/Makefile | 1 -
arch/x86/lib/efi/Makefile | 7 -------
doc/README.u-boot_on_efi | 6 +-----
9 files changed, 10 insertions(+), 16 deletions(-)
rename arch/x86/{lib => cpu}/efi/Kconfig (100%)
rename arch/x86/{lib => cpu}/efi/car.S (100%)
rename arch/x86/{lib/efi/efi.c => cpu/efi/payload.c} (100%)
delete mode 100644 arch/x86/lib/efi/Makefilearch/x86/Kconfig +1 -2
@@ -112,6 +112,7 @@ source "arch/x86/cpu/braswell/Kconfig" source "arch/x86/cpu/broadwell/Kconfig" source "arch/x86/cpu/coreboot/Kconfig" source "arch/x86/cpu/ivybridge/Kconfig" +source "arch/x86/cpu/efi/Kconfig" source "arch/x86/cpu/qemu/Kconfig" source "arch/x86/cpu/quark/Kconfig" source "arch/x86/cpu/queensbay/Kconfig"
@@ -772,6 +773,4 @@ config HIGH_TABLE_SIZE Increse it if the default size does not fit the board's needs. This is most likely due to a large ACPI DSDT table is used. -source "arch/x86/lib/efi/Kconfig" - endmenu
arch/x86/cpu/Makefile +1 -1
@@ -29,7 +29,7 @@ obj-$(CONFIG_INTEL_BAYTRAIL) += baytrail/ obj-$(CONFIG_INTEL_BRASWELL) += braswell/ obj-$(CONFIG_INTEL_BROADWELL) += broadwell/ obj-$(CONFIG_SYS_COREBOOT) += coreboot/ -obj-$(CONFIG_EFI_APP) += efi/ +obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_QEMU) += qemu/ obj-$(CONFIG_NORTHBRIDGE_INTEL_IVYBRIDGE) += ivybridge/ obj-$(CONFIG_INTEL_QUARK) += quark/
arch/x86/cpu/efi/Kconfig renamed from arch/x86/lib/efi/Kconfig +0 -0
arch/x86/cpu/efi/Makefile +7 -0
@@ -2,5 +2,12 @@ # # Copyright (c) 2015 Google, Inc +ifdef CONFIG_EFI_APP obj-y += efi.o obj-y += sdram.o +endif + +ifdef CONFIG_EFI_STUB +obj-y += car.o +obj-y += payload.o +endif
arch/x86/cpu/efi/car.S renamed from arch/x86/lib/efi/car.S +0 -0
arch/x86/cpu/efi/payload.c renamed from arch/x86/lib/efi/efi.c +0 -0
arch/x86/lib/Makefile +0 -1
@@ -14,7 +14,6 @@ endif obj-y += cmd_boot.o obj-$(CONFIG_SEABIOS) += coreboot_table.o obj-y += early_cmos.o -obj-$(CONFIG_EFI) += efi/ obj-y += e820.o obj-y += init_helpers.o obj-y += interrupts.o
arch/x86/lib/efi/Makefile deleted +0 -7
@@ -1,7 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0+ -# -# (C) Copyright 2002-2006 -# Wolfgang Denk, DENX Software Engineering, wd at denx.de. - -obj-$(CONFIG_EFI_STUB) += car.o -obj-$(CONFIG_EFI_STUB) += efi.o
doc/README.u-boot_on_efi +1 -5
@@ -235,12 +235,8 @@ Where is the code? lib/efi payload stub, application, support code. Mostly arch-neutral -arch/x86/lib/efi - helper functions for the fake DRAM init, etc. These can be used by - any board that runs as a payload. - arch/x86/cpu/efi - x86 support code for running as an EFI application + x86 support code for running as an EFI application and payload board/efi/efi-x86/efi.c x86 board code for running as an EFI application
Signature · 1 line
2.7.4
PATCH v2 4/13 x86: efi: Refactor the directory of EFI app and payload support
Quoted 17 lines · Bin Meng
At present the EFI application and payload support codes in the x86 directory is distributed in a hybrid way. For example, the
Kconfigoptions for both app and payload are inarch/x86/lib/efi/Kconfig, but the source codes in the same directory get built only forCONFIG_EFI_STUB.This refactors the codes by consolidating all the EFI support codes into
arch/x86/cpu/efi, just like other x86 targets.Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v2:
- update README.u-boot_on_efi to reflect directory changes
Quoted 15 lines
arch/x86/Kconfig | 3 +--
arch/x86/cpu/Makefile | 2 +-
arch/x86/{lib => cpu}/efi/Kconfig | 0
arch/x86/cpu/efi/Makefile | 7 +++++++
arch/x86/{lib => cpu}/efi/car.S | 0
arch/x86/{lib/efi/efi.c => cpu/efi/payload.c} | 0
arch/x86/lib/Makefile | 1 -
arch/x86/lib/efi/Makefile | 7 -------
doc/README.u-boot_on_efi | 6 +-----
9 files changed, 10 insertions(+), 16 deletions(-)
rename arch/x86/{lib => cpu}/efi/Kconfig (100%)
rename arch/x86/{lib => cpu}/efi/car.S (100%)
rename arch/x86/{lib/efi/efi.c => cpu/efi/payload.c} (100%)
delete mode 100644 arch/x86/lib/efi/Makefileapplied to u-boot-x86, thanks!
PATCH v2 5/13 x86: efi: payload: Add arch_cpu_init()
In reply to Bin MengThis adds arch_cpu_init() to the payload codes, in preparation for supporting a generic efi payload.
---
Changes in v2: None
arch/x86/cpu/efi/payload.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/cpu/efi/payload.c +8 -3
@@ -5,11 +5,9 @@*/ #include <common.h> -#include <debug_uart.h> #include <efi.h> #include <errno.h> -#include <linux/err.h> -#include <linux/types.h> +#include <asm/post.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -126,6 +124,13 @@ int dram_init_banksize(void)return 0 ; } +int arch_cpu_init (void ) +{ +post_code (POST_CPU_INIT ); + +return x86_cpu_init_f (); +} +int checkcpu (void ) {return 0 ;
Signature · 1 line
2.7.4
PATCH v2 5/13 x86: efi: payload: Add arch_cpu_init()
Quoted 12 lines · Bin Meng
This adds
arch_cpu_init()to the payload codes, in preparation for supporting a generic efi payload.Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v2: None
arch/x86/cpu/efi/payload.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
applied to u-boot-x86, thanks!
PATCH v2 6/13 x86: Add generic EFI payload support
In reply to Bin MengIt is possible to create a generic EFI payload for all x86 boards. The payload is configured to include as many generic drivers as possible. All stuff that touches low-level initialization are not allowed as such is the EFI BIOS's responsibility. Platform specific drivers (like gpio, spi, etc) are not included.
---
Changes in v2:
- update README.u-boot_on_efi to mention generic EFI payload support
arch/x86/dts/Makefile | 1 + arch/x86/dts/efi-x86_payload.dts | 36 +++++++++++++++++++++++++++++++++ board/efi/Kconfig | 9 +++++++++ board/efi/efi-x86_payload/Kconfig | 38 +++++++++++++++++++++++++++++++++++ board/efi/efi-x86_payload/MAINTAINERS | 7 +++++++ board/efi/efi-x86_payload/Makefile | 5 +++++ board/efi/efi-x86_payload/start.S | 8 ++++++++ configs/efi-x86_payload32_defconfig | 35 ++++++++++++++++++++++++++++++++ configs/efi-x86_payload64_defconfig | 36 +++++++++++++++++++++++++++++++++ doc/README.u-boot_on_efi | 19 +++++++++--------- include/configs/efi-x86_payload.h | 32 +++++++++++++++++++++++++++++ 11 files changed, 216 insertions(+), 10 deletions(-) create mode 100644 arch/x86/dts/efi-x86_payload.dts create mode 100644 board/efi/efi-x86_payload/Kconfig create mode 100644 board/efi/efi-x86_payload/MAINTAINERS create mode 100644 board/efi/efi-x86_payload/Makefile create mode 100644 board/efi/efi-x86_payload/start.S create mode 100644 configs/efi-x86_payload32_defconfig create mode 100644 configs/efi-x86_payload64_defconfig create mode 100644 include/configs/efi-x86_payload.h
arch/x86/dts/Makefile +1 -0
@@ -11,6 +11,7 @@ dtb-y += bayleybay.dtb \ dfi-bt700-q7x-151.dtb \ edison.dtb \ efi.dtb \ + efi-x86_payload.dtb \ galileo.dtb \ minnowmax.dtb \ qemu-x86_i440fx.dtb \
arch/x86/dts/efi-x86_payload.dts new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018, Bin Meng <[email protected]> + * + * Generic EFI payload device tree for x86 targets + */ + +/dts-v1/; + +/include/ "skeleton.dtsi" +/include/ "serial.dtsi" +/include/ "keyboard.dtsi" +/include/ "rtc.dtsi" +/include/ "tsc_timer.dtsi" + +/ { + model = "EFI x86 Payload"; + compatible = "efi,x86-payload"; + + aliases { + serial0 = &serial; + }; + + config { + silent_console = <0>; + }; + + chosen { + stdout-path = "/serial"; + }; + + pci { + compatible = "pci-x86"; + u-boot,dm-pre-reloc; + }; +};
board/efi/Kconfig +9 -0
@@ -12,8 +12,17 @@ config TARGET_EFI takes over once the RAM, video and CPU are fully running. U-Boot is loaded as an application from EFI. +config TARGET_EFI_PAYLOAD + bool "efi payload" + help + This target is used for running U-Boot on top of EFI. In + this case EFI does the early initialisation, and U-Boot + takes over once the RAM, video and CPU are fully running. + U-Boot is loaded as a payload from EFI. + endchoice source "board/efi/efi-x86/Kconfig" +source "board/efi/efi-x86_payload/Kconfig" endif
board/efi/efi-x86_payload/Kconfig new file +38 -0
@@ -0,0 +1,38 @@ +if TARGET_EFI_PAYLOAD + +config SYS_BOARD + default "efi-x86_payload" + +config SYS_VENDOR + default "efi" + +config SYS_SOC + default "efi" + +config SYS_CONFIG_NAME + default "efi-x86_payload" + +config SYS_TEXT_BASE + default 0x00200000 + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + imply SYS_NS16550 + imply SCSI + imply SCSI_AHCI + imply AHCI_PCI + imply MMC + imply MMC_PCI + imply MMC_SDHCI + imply MMC_SDHCI_SDMA + imply USB + imply USB_EHCI_HCD + imply USB_XHCI_HCD + imply USB_STORAGE + imply USB_KEYBOARD + imply E1000 + imply ETH_DESIGNWARE + imply PCH_GBE + imply RTL8169 + +endif
board/efi/efi-x86_payload/MAINTAINERS new file +7 -0
@@ -0,0 +1,7 @@ +EFI-X86_PAYLOAD BOARD +M: Bin Meng <[email protected]> +S: Maintained +F: board/efi/efi-x86_payload/ +F: include/configs/efi-x86_payload.h +F: configs/efi-x86_payload32_defconfig +F: configs/efi-x86_payload64_defconfig
board/efi/efi-x86_payload/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018, Bin Meng <[email protected]> + +obj-y += start.o
board/efi/efi-x86_payload/start.S new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2018, Bin Meng <[email protected]> + */ + +.globl early_board_init +early_board_init: + jmp early_board_init_ret
configs/efi-x86_payload32_defconfig new file +35 -0
@@ -0,0 +1,35 @@ +CONFIG_X86=y +CONFIG_VENDOR_EFI=y +CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" +CONFIG_TARGET_EFI_PAYLOAD=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_SYS_CONSOLE_INFO_QUIET=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_LAST_STAGE_INIT=y +CONFIG_HUSH_PARSER=y +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_IDE=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PART=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +# CONFIG_CMD_NFS is not set +CONFIG_CMD_PING=y +CONFIG_CMD_TIME=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_MAC_PARTITION=y +CONFIG_ISO_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y +# CONFIG_PCI_PNP is not set +CONFIG_EFI=y +CONFIG_EFI_STUB=y
configs/efi-x86_payload64_defconfig new file +36 -0
@@ -0,0 +1,36 @@ +CONFIG_X86=y +CONFIG_VENDOR_EFI=y +CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" +CONFIG_TARGET_EFI_PAYLOAD=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_SYS_CONSOLE_INFO_QUIET=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_LAST_STAGE_INIT=y +CONFIG_HUSH_PARSER=y +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_IDE=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PART=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +# CONFIG_CMD_NFS is not set +CONFIG_CMD_PING=y +CONFIG_CMD_TIME=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_MAC_PARTITION=y +CONFIG_ISO_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y +# CONFIG_PCI_PNP is not set +CONFIG_EFI=y +CONFIG_EFI_STUB=y +CONFIG_EFI_STUB_64BIT=y
doc/README.u-boot_on_efi +9 -10
@@ -71,12 +71,13 @@ Just build U-Boot as normal, e.g. make efi-x86_defconfig make -To build U-Boot as an EFI payload (32-bit or 64-bit EFI can be used), adjust an -existing config (like qemu-x86_defconfig) to enable CONFIG_EFI, CONFIG_EFI_STUB -and either CONFIG_EFI_STUB_32BIT or CONFIG_EFI_STUB_64BIT. All of these are -boolean Kconfig options. Then build U-Boot as normal, e.g. +To build U-Boot as an EFI payload (32-bit or 64-bit EFI can be used), enable +CONFIG_EFI, CONFIG_EFI_STUB, and select either CONFIG_EFI_STUB_32BIT or +CONFIG_EFI_STUB_64BIT. The efi-x86_payload configs (efi-x86_payload32_defconfig +and efi-x86_payload32_defconfig) are set up for this. Then build U-Boot as +normal, e.g. - make qemu-x86_defconfig + make efi-x86_payload32_defconfig (or efi-x86_payload64_defconfig) make You will end up with one of these files depending on what you build for:
@@ -211,11 +212,6 @@ Future work ----------- This work could be extended in a number of ways: -- Add a generic x86 EFI payload configuration. At present you need to modify -an existing one, but mostly the low-level x86 code is disabled when booting -on EFI anyway, so a generic 'EFI' board could be created with a suitable set -of drivers enabled. - - Add ARM support - Add 64-bit application support
@@ -241,6 +237,9 @@ arch/x86/cpu/efi board/efi/efi-x86/efi.c x86 board code for running as an EFI application +board/efi/efi-x86_payload + generic x86 EFI payload board support code + common/cmd_efi.c the 'efi' command
include/configs/efi-x86_payload.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2018, Bin Meng <[email protected]> +*/ + +/* +* board/config.h - configuration options, board specific +*/ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#include <configs/x86-common.h> + +#define CONFIG_SYS_MONITOR_LEN (1 << 20) + +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,i8042-kbd\0" \ + "stdout=serial,vidconsole\0" \ + "stderr=serial,vidconsole\0" + +/* ATA/IDE support */ +#define CONFIG_SYS_IDE_MAXBUS 2 +#define CONFIG_SYS_IDE_MAXDEVICE 4 +#define CONFIG_SYS_ATA_BASE_ADDR 0 +#define CONFIG_SYS_ATA_DATA_OFFSET 0 +#define CONFIG_SYS_ATA_REG_OFFSET 0 +#define CONFIG_SYS_ATA_ALT_OFFSET 0 +#define CONFIG_SYS_ATA_IDE0_OFFSET 0x1f0 +#define CONFIG_SYS_ATA_IDE1_OFFSET 0x170 +#define CONFIG_ATAPI + +#endif /* __CONFIG_H */
Signature · 1 line
2.7.4
PATCH v2 6/13 x86: Add generic EFI payload support
Quoted 26 lines · Bin Meng
It is possible to create a generic EFI payload for all x86 boards. The payload is configured to include as many generic drivers as possible. All stuff that touches low-level initialization are not allowed as such is the EFI BIOS's responsibility. Platform specific drivers (like gpio, spi, etc) are not included.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v2:
- update README.u-boot_on_efi to mention generic EFI payload supportarch/x86/dts/Makefile | 1 + arch/x86/dts/efi-x86_payload.dts | 36 +++++++++++++++++++++++++++++++++ board/efi/Kconfig | 9 +++++++++ board/efi/efi-x86_payload/Kconfig | 38 +++++++++++++++++++++++++++++++++++ board/efi/efi-x86_payload/MAINTAINERS | 7 +++++++ board/efi/efi-x86_payload/Makefile | 5 +++++ board/efi/efi-x86_payload/start.S | 8 ++++++++ configs/efi-x86_payload32_defconfig | 35 ++++++++++++++++++++++++++++++++ configs/efi-x86_payload64_defconfig | 36 +++++++++++++++++++++++++++++++++ doc/README.u-boot_on_efi | 19 +++++++++--------- include/configs/efi-x86_payload.h | 32 +++++++++++++++++++++++++++++ 11 files changed, 216 insertions(+), 10 deletions(-)
Quoted 9 lines
create mode 100644 arch/x86/dts/efi-x86_payload.dts create mode 100644 board/efi/efi-x86_payload/Kconfig create mode 100644 board/efi/efi-x86_payload/MAINTAINERS create mode 100644 board/efi/efi-x86_payload/Makefile create mode 100644 board/efi/efi-x86_payload/start.S create mode 100644 configs/efi-x86_payload32_defconfig create mode 100644 configs/efi-x86_payload64_defconfig create mode 100644 include/configs/efi-x86_payload.h
applied to u-boot-x86, thanks!
PATCH v2 7/13 x86: Drop QEMU-specific EFI payload support
In reply to Bin MengNow that we have generic EFI payload support for all x86 boards, drop the QEMU-specific one.
---
Changes in v2:
- update QEMU MAINTAINERS file to remove defconfig files
arch/x86/cpu/qemu/Makefile | 2 -- arch/x86/cpu/qemu/qemu.c | 4 --- board/emulation/qemu-x86/Kconfig | 6 ++-- board/emulation/qemu-x86/MAINTAINERS | 2 -- configs/qemu-x86_efi_payload32_defconfig | 47 ------------------------------- configs/qemu-x86_efi_payload64_defconfig | 48 -------------------------------- 6 files changed, 3 insertions(+), 106 deletions(-) delete mode 100644 configs/qemu-x86_efi_payload32_defconfig delete mode 100644 configs/qemu-x86_efi_payload64_defconfig
arch/x86/cpu/qemu/Makefile +0 -2
@@ -2,8 +2,6 @@ # # Copyright (C) 2015, Bin Meng <[email protected]> -ifndef CONFIG_EFI_STUB obj-y += car.o dram.o -endif obj-y += qemu.o obj-$(CONFIG_QFW) += cpu.o e820.o
arch/x86/cpu/qemu/qemu.c +0 -4
@@ -143,10 +143,6 @@ int arch_cpu_init(void)return x86_cpu_init_f (); } -#endif - -#if !CONFIG_IS_ENABLED (EFI_STUB ) && \ - !CONFIG_IS_ENABLED (SPL_X86_32BIT_INIT )int checkcpu (void ) {
board/emulation/qemu-x86/Kconfig +3 -3
@@ -13,12 +13,12 @@ config SYS_CONFIG_NAME default "qemu-x86" config SYS_TEXT_BASE - default 0xfff00000 if !EFI_STUB && !SUPPORT_SPL - default 0x01110000 if EFI_STUB || SUPPORT_SPL + default 0xfff00000 if !SUPPORT_SPL + default 0x01110000 if SUPPORT_SPL config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select X86_RESET_VECTOR if !EFI_STUB + select X86_RESET_VECTOR select QEMU select BOARD_ROMSIZE_KB_1024
board/emulation/qemu-x86/MAINTAINERS +0 -2
@@ -4,8 +4,6 @@ S: Maintained F: board/emulation/qemu-x86/ F: include/configs/qemu-x86.h F: configs/qemu-x86_defconfig -F: configs/qemu-x86_efi_payload32_defconfig -F: configs/qemu-x86_efi_payload64_defconfig QEMU X86 64-bit BOARD M: Bin Meng <[email protected]>
configs/qemu-x86_efi_payload32_defconfig deleted +0 -47
47 lines not on this page · raw message
configs/qemu-x86_efi_payload64_defconfig deleted +0 -48
48 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 7/13 x86: Drop QEMU-specific EFI payload support
Quoted 11 lines · Bin Meng
Now that we have generic EFI payload support for all x86 boards, drop the QEMU-specific one.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v2:
- update QEMUMAINTAINERSfile to remove defconfig files
Quoted 10 lines
arch/x86/cpu/qemu/Makefile | 2 -- arch/x86/cpu/qemu/qemu.c | 4 --- board/emulation/qemu-x86/Kconfig | 6 ++-- board/emulation/qemu-x86/MAINTAINERS | 2 -- configs/qemu-x86_efi_payload32_defconfig | 47 ------------------------------- configs/qemu-x86_efi_payload64_defconfig | 48 -------------------------------- 6 files changed, 3 insertions(+), 106 deletions(-) delete mode 100644 configs/qemu-x86_efi_payload32_defconfig delete mode 100644 configs/qemu-x86_efi_payload64_defconfig
applied to u-boot-x86, thanks!
PATCH v2 8/13 x86: baytrail: Drop EFI-specific test logics
In reply to Bin MengNow that we have generic EFI payload support, drop EFI-specific test logics in BayTrail Kconfig and codes, and all BayTrail boards too.
---
Changes in v2: None
arch/x86/cpu/baytrail/Kconfig | 6 +++--- arch/x86/cpu/baytrail/valleyview.c | 3 --- board/advantech/som-db5800-som-6867/Kconfig | 5 ++--- board/congatec/conga-qeval20-qa3-e3845/Kconfig | 5 ++--- board/dfi/dfi-bt700/Kconfig | 5 ++--- board/intel/minnowmax/Kconfig | 5 ++--- 6 files changed, 11 insertions(+), 18 deletions(-)
arch/x86/cpu/baytrail/Kconfig +3 -3
@@ -4,10 +4,10 @@ config INTEL_BAYTRAIL bool - select HAVE_FSP if !EFI - select ARCH_MISC_INIT if !EFI + select HAVE_FSP + select ARCH_MISC_INIT select CPU_INTEL_TURBO_NOT_PACKAGE_SCOPED - imply HAVE_INTEL_ME if !EFI + imply HAVE_INTEL_ME imply ENABLE_MRC_CACHE imply AHCI_PCI imply ICH_SPI
arch/x86/cpu/baytrail/valleyview.c +0 -3
@@ -17,7 +17,6 @@#define BYT_TRIG_LVL BIT(24)#define BYT_TRIG_POS BIT(25) -#ifndef CONFIG_EFI_APP int arch_cpu_init (void ) {post_code (POST_CPU_INIT );
@@ -57,8 +56,6 @@ int arch_misc_init(void)return 0 ; } -#endif -void reset_cpu (ulong addr) {/* cold reset */
board/advantech/som-db5800-som-6867/Kconfig +2 -3
@@ -13,12 +13,11 @@ config SYS_CONFIG_NAME default "som-db5800-som-6867" config SYS_TEXT_BASE - default 0xfff00000 if !EFI_STUB - default 0x01110000 if EFI_STUB + default 0xfff00000 config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select X86_RESET_VECTOR if !EFI_STUB + select X86_RESET_VECTOR select INTEL_BAYTRAIL select BOARD_ROMSIZE_KB_8192 select BOARD_EARLY_INIT_F
board/congatec/conga-qeval20-qa3-e3845/Kconfig +2 -3
@@ -12,12 +12,11 @@ config SYS_CONFIG_NAME default "theadorable-x86-conga-qa3-e3845" if TARGET_THEADORABLE_X86_CONGA_QA3_E3845 config SYS_TEXT_BASE - default 0xfff00000 if !EFI_STUB - default 0x01110000 if EFI_STUB + default 0xfff00000 config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select X86_RESET_VECTOR if !EFI_STUB + select X86_RESET_VECTOR select INTEL_BAYTRAIL select BOARD_ROMSIZE_KB_8192 select BOARD_EARLY_INIT_F
board/dfi/dfi-bt700/Kconfig +2 -3
@@ -12,12 +12,11 @@ config SYS_CONFIG_NAME default "theadorable-x86-dfi-bt700" if TARGET_THEADORABLE_X86_DFI_BT700 config SYS_TEXT_BASE - default 0xfff00000 if !EFI_STUB - default 0x01110000 if EFI_STUB + default 0xfff00000 config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select X86_RESET_VECTOR if !EFI_STUB + select X86_RESET_VECTOR select INTEL_BAYTRAIL select BOARD_ROMSIZE_KB_8192 select BOARD_EARLY_INIT_F
board/intel/minnowmax/Kconfig +2 -3
@@ -13,12 +13,11 @@ config SYS_CONFIG_NAME default "minnowmax" config SYS_TEXT_BASE - default 0xfff00000 if !EFI_STUB - default 0x01110000 if EFI_STUB + default 0xfff00000 config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select X86_RESET_VECTOR if !EFI_STUB + select X86_RESET_VECTOR select INTEL_BAYTRAIL select BOARD_ROMSIZE_KB_8192 select SPI_FLASH_STMICRO
Signature · 1 line
2.7.4
PATCH v2 8/13 x86: baytrail: Drop EFI-specific test logics
Quoted 9 lines · Bin Meng
Now that we have generic EFI payload support, drop EFI-specific test logics in BayTrail
Kconfigand codes, and all BayTrail boards too.Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v2: None
Quoted 8 lines
arch/x86/cpu/baytrail/Kconfig | 6 +++--- arch/x86/cpu/baytrail/valleyview.c | 3 --- board/advantech/som-db5800-som-6867/Kconfig | 5 ++--- board/congatec/conga-qeval20-qa3-e3845/Kconfig | 5 ++--- board/dfi/dfi-bt700/Kconfig | 5 ++--- board/intel/minnowmax/Kconfig | 5 ++--- 6 files changed, 11 insertions(+), 18 deletions(-)
applied to u-boot-x86, thanks!
PATCH v2 9/13 efi: stub: Pass EFI GOP information to U-Boot payload
In reply to Bin MengIf UEFI BIOS has the graphics output protocol (GOP), let's pass its information to U-Boot payload so that U-Boot can utilize it (eg:
an EFI framebuffer driver).
---
Changes in v2: None
include/efi.h | 35 +++++++++++++++++++++++++++++++++++ lib/efi/efi_stub.c | 15 +++++++++++++++ 2 files changed, 50 insertions(+)
include/efi.h +35 -0
@@ -233,6 +233,7 @@ struct efi_open_protocol_info_entry {enum efi_entry_t {EFIET_END ,/* Signals this is the last (empty) entry */ EFIET_MEMORY_MAP , +EFIET_GOP_MODE ,/* Number of entries */ EFIET_MEMORY_COUNT ,
@@ -289,6 +290,40 @@ struct efi_entry_memmap {struct efi_mem_desc desc[]; }; +/** +* struct efi_entry_gopmode - a GOP mode table passed to U-Boot +* +* @fb_base: EFI's framebuffer base address +* @fb_size: EFI's framebuffer size +* @info_size: GOP mode info structure size +* @info: Start address of the GOP mode info structure +*/ +struct efi_entry_gopmode { +efi_physical_addr_t fb_base; +/* +* Not like the ones in 'struct efi_gop_mode' which are 'unsigned +* long', @fb_size and @info_size have to be 'u64' here. As the EFI +* stub codes may have different bit size from the U-Boot payload, +* using 'long' will cause mismatch between the producer (stub) and +* the consumer (payload). +*/ +u64 fb_size; +u64 info_size; +/* +* We cannot directly use 'struct efi_gop_mode_info info[]' here as +* it causes compiler to complain: array type has incomplete element +* type 'struct efi_gop_mode_info'. +*/ +struct /* efi_gop_mode_info */ { +u32 version; +u32 width; +u32 height; +u32 pixel_format; +u32 pixel_bitmask[4 ]; +u32 pixels_per_scanline; + } info[]; +}; +static inline struct efi_mem_desc *efi_get_next_mem_desc (struct efi_entry_memmap *map,struct efi_mem_desc *desc) {
lib/efi/efi_stub.c +15 -0
@@ -274,6 +274,9 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)struct efi_boot_services *boot = sys_table->boottime;struct efi_mem_desc *desc;struct efi_entry_memmap map; +struct efi_gop *gop; +struct efi_entry_gopmode mode; +efi_guid_t efi_gop_guid =EFI_GOP_GUID ;efi_uintn_t key, desc_size, size;efi_status_t ret;u32 version;
@@ -312,6 +315,18 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)if (ret)return ret; + ret = boot->locate_protocol (&efi_gop_guid,NULL , (void **)&gop); +if (ret) { +puts (" GOP unavailable\n" ); + }else { + mode.fb_base = gop->mode->fb_base; + mode.fb_size = gop->mode->fb_size; + mode.info_size = gop->mode->info_size; +add_entry_addr (priv,EFIET_GOP_MODE , &mode,sizeof (mode), + gop->mode->info, +sizeof (struct efi_gop_mode_info )); + } + ret = boot->get_memory_map (&size, desc, &key, &desc_size, &version);if (ret) {printhex2 (ret);
Signature · 1 line
2.7.4
PATCH v2 9/13 efi: stub: Pass EFI GOP information to U-Boot payload
Quoted 6 lines · Bin Meng
If UEFI BIOS has the graphics output protocol (GOP), let's pass its information to U-Boot payload so that U-Boot can utilize it (eg:
an EFI framebuffer driver).Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 8 lines
---
Changes in v2: None
include/efi.h | 35 +++++++++++++++++++++++++++++++++++ lib/efi/efi_stub.c | 15 +++++++++++++++ 2 files changed, 50 insertions(+)
applied to u-boot-x86, thanks!
PATCH v2 10/13 dm: video: Add an EFI framebuffer driver
In reply to Bin MengThis adds a DM video driver for U-Boot as the EFI payload. The driver makes use of all necessary information from the passed EFI GOP info to create a linear framebuffer device, as if it were initialized by U-Boot itself.
---
Changes in v2: None
drivers/video/Kconfig | 9 +++ drivers/video/Makefile | 1 + drivers/video/efi.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 drivers/video/efi.c
drivers/video/Kconfig +9 -0
@@ -156,6 +156,15 @@ config VIDEO_COREBOOT coreboot already. This can in principle be used with any platform that coreboot supports. +config VIDEO_EFI + bool "Enable EFI framebuffer driver support" + depends on EFI_STUB + help + Turn on this option to enable a framebuffeer driver when U-Boot is + loaded as a payload (see README.u-boot_on_efi) by an EFI BIOS where + the graphics device is configured by the EFI BIOS already. This can + in principle be used with any platform that has an EFI BIOS. + config VIDEO_VESA bool "Enable VESA video driver support" default n
drivers/video/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_LD9040) += ld9040.o obj-$(CONFIG_VIDEO_BCM2835) += bcm2835.o obj-$(CONFIG_VIDEO_COREBOOT) += coreboot.o obj-$(CONFIG_VIDEO_DA8XX) += da8xx-fb.o videomodes.o +obj-$(CONFIG_VIDEO_EFI) += efi.o obj-$(CONFIG_VIDEO_LCD_ANX9804) += anx9804.o obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
drivers/video/efi.c new file +146 -0
146 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 10/13 dm: video: Add an EFI framebuffer driver
Quoted 9 lines · Bin Meng
This adds a DM video driver for U-Boot as the EFI payload. The driver makes use of all necessary information from the passed EFI GOP info to create a linear framebuffer device, as if it were initialized by U-Boot itself.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Anatolij Gustschin <[email protected]>---
Quoted 8 lines
Changes in v2: None
drivers/video/Kconfig | 9 +++ drivers/video/Makefile | 1 + drivers/video/efi.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 drivers/video/efi.c
applied to u-boot-x86, thanks!
PATCH v2 11/13 x86: efi: payload: Add EFI framebuffer driver support
In reply to Bin MengThis turns on the EFI framebuffer driver support so that a graphics console can be of additional help.
---
Changes in v2: None
arch/x86/dts/efi-x86_payload.dts | 4 ++++ board/efi/efi-x86_payload/Kconfig | 1 + 2 files changed, 5 insertions(+)
arch/x86/dts/efi-x86_payload.dts +4 -0
@@ -33,4 +33,8 @@ compatible = "pci-x86"; u-boot,dm-pre-reloc; }; + + efi-fb { + compatible = "efi-fb"; + }; };
board/efi/efi-x86_payload/Kconfig +1 -0
@@ -30,6 +30,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply USB_XHCI_HCD imply USB_STORAGE imply USB_KEYBOARD + imply VIDEO_EFI imply E1000 imply ETH_DESIGNWARE imply PCH_GBE
Signature · 1 line
2.7.4
PATCH v2 11/13 x86: efi: payload: Add EFI framebuffer driver support
Quoted 5 lines · Bin Meng
This turns on the EFI framebuffer driver support so that a graphics console can be of additional help.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 8 lines
---
Changes in v2: None
arch/x86/dts/efi-x86_payload.dts | 4 ++++ board/efi/efi-x86_payload/Kconfig | 1 + 2 files changed, 5 insertions(+)
applied to u-boot-x86, thanks!
PATCH v2 12/13 x86: Rename efi-x86 target to efi-x86_app
In reply to Bin MengTo avoid confusion, let's rename the efi-x86 target to efi-x86_app.
---
Changes in v2:
- update README.u-boot_on_efi to use efi-x86_app
arch/x86/cpu/efi/Makefile | 2 +-
arch/x86/cpu/efi/{efi.c => app.c} | 0
arch/x86/cpu/intel_common/Makefile | 2 +-
arch/x86/dts/Makefile | 2 +-
arch/x86/dts/{efi.dts => efi-x86_app.dts} | 4 ++--
board/efi/Kconfig | 6 +++---
board/efi/{efi-x86 => efi-x86_app}/Kconfig | 6 +++---
board/efi/{efi-x86 => efi-x86_app}/MAINTAINERS | 0
board/efi/{efi-x86 => efi-x86_app}/Makefile | 2 +-
board/efi/{efi-x86/efi.c => efi-x86_app/app.c} | 0
configs/{efi-x86_defconfig => efi-x86_app_defconfig} | 4 ++--
doc/README.u-boot_on_efi | 8 ++++----
include/configs/{efi-x86.h => efi-x86_app.h} | 0
13 files changed, 18 insertions(+), 18 deletions(-)
rename arch/x86/cpu/efi/{efi.c => app.c} (100%)
rename arch/x86/dts/{efi.dts => efi-x86_app.dts} (82%)
rename board/efi/{efi-x86 => efi-x86_app}/Kconfig (64%)
rename board/efi/{efi-x86 => efi-x86_app}/MAINTAINERS (100%)
rename board/efi/{efi-x86 => efi-x86_app}/Makefile (82%)
rename board/efi/{efi-x86/efi.c => efi-x86_app/app.c} (100%)
rename configs/{efi-x86_defconfig => efi-x86_app_defconfig} (92%)
rename include/configs/{efi-x86.h => efi-x86_app.h} (100%)arch/x86/cpu/efi/Makefile +1 -1
@@ -3,7 +3,7 @@ # Copyright (c) 2015 Google, Inc ifdef CONFIG_EFI_APP -obj-y += efi.o +obj-y += app.o obj-y += sdram.o endif
arch/x86/cpu/efi/app.c renamed from arch/x86/cpu/efi/efi.c +0 -0
arch/x86/cpu/intel_common/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += mrc.o endif obj-y += cpu.o obj-y += lpc.o -ifndef CONFIG_TARGET_EFI +ifndef CONFIG_TARGET_EFI_APP obj-y += microcode.o endif obj-y += pch.o
arch/x86/dts/Makefile +1 -1
@@ -10,7 +10,7 @@ dtb-y += bayleybay.dtb \ crownbay.dtb \ dfi-bt700-q7x-151.dtb \ edison.dtb \ - efi.dtb \ + efi-x86_app.dtb \ efi-x86_payload.dtb \ galileo.dtb \ minnowmax.dtb \
arch/x86/dts/efi-x86_app.dts renamed from arch/x86/dts/efi.dts +2 -2
@@ -9,8 +9,8 @@ /include/ "tsc_timer.dtsi" / { - model = "EFI"; - compatible = "efi,app"; + model = "EFI x86 Application"; + compatible = "efi,x86-app"; chosen { stdout-path = &serial;
board/efi/Kconfig +3 -3
@@ -4,8 +4,8 @@ choice prompt "Mainboard model" optional -config TARGET_EFI - bool "efi" +config TARGET_EFI_APP + bool "efi application" help This target is used for running U-Boot on top of EFI. In this case EFI does the early initialisation, and U-Boot
@@ -22,7 +22,7 @@ config TARGET_EFI_PAYLOAD endchoice -source "board/efi/efi-x86/Kconfig" +source "board/efi/efi-x86_app/Kconfig" source "board/efi/efi-x86_payload/Kconfig" endif
board/efi/efi-x86_app/Kconfig renamed from board/efi/efi-x86/Kconfig +3 -3
@@ -1,7 +1,7 @@ -if TARGET_EFI +if TARGET_EFI_APP config SYS_BOARD - default "efi-x86" + default "efi-x86_app" config SYS_VENDOR default "efi"
@@ -10,6 +10,6 @@ config SYS_SOC default "efi" config SYS_CONFIG_NAME - default "efi-x86" + default "efi-x86_app" endif
board/efi/efi-x86_app/MAINTAINERS renamed from board/efi/efi-x86/MAINTAINERS +0 -0
board/efi/efi-x86_app/Makefile renamed from board/efi/efi-x86/Makefile +1 -1
@@ -2,4 +2,4 @@ # # Copyright (c) 2015 Google, Inc -obj-y += efi.o +obj-y += app.o
board/efi/efi-x86_app/app.c renamed from board/efi/efi-x86/efi.c +0 -0
configs/efi-x86_app_defconfig renamed from configs/efi-x86_defconfig +2 -2
@@ -2,8 +2,8 @@ CONFIG_X86=y CONFIG_DEBUG_UART_BASE=0 CONFIG_DEBUG_UART_CLOCK=0 CONFIG_VENDOR_EFI=y -CONFIG_DEFAULT_DEVICE_TREE="efi" -CONFIG_TARGET_EFI=y +CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" +CONFIG_TARGET_EFI_APP=y CONFIG_DEBUG_UART=y CONFIG_FIT=y CONFIG_USE_BOOTARGS=y
doc/README.u-boot_on_efi +4 -4
@@ -65,10 +65,10 @@ for that board. It will be either 32-bit or 64-bit. Alternatively, you can opt for using QEMU [1] and the OVMF [2], as detailed below. To build U-Boot as an EFI application (32-bit EFI required), enable CONFIG_EFI -and CONFIG_EFI_APP. The efi-x86 config (efi-x86_defconfig) is set up for this. -Just build U-Boot as normal, e.g. +and CONFIG_EFI_APP. The efi-x86_app config (efi-x86_app_defconfig) is set up +for this. Just build U-Boot as normal, e.g. - make efi-x86_defconfig + make efi-x86_app_defconfig make To build U-Boot as an EFI payload (32-bit or 64-bit EFI can be used), enable
@@ -234,7 +234,7 @@ lib/efi arch/x86/cpu/efi x86 support code for running as an EFI application and payload -board/efi/efi-x86/efi.c +board/efi/efi-x86_app/efi.c x86 board code for running as an EFI application board/efi/efi-x86_payload
include/configs/efi-x86_app.h renamed from include/configs/efi-x86.h +0 -0
Signature · 1 line
2.7.4
PATCH v2 12/13 x86: Rename efi-x86 target to efi-x86_app
Quoted 24 lines · Bin Meng
To avoid confusion, let's rename the efi-x86 target to efi-x86_app.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v2:
- update README.u-boot_on_efi to use efi-x86_apparch/x86/cpu/efi/Makefile | 2 +- arch/x86/cpu/efi/{efi.c => app.c} | 0 arch/x86/cpu/intel_common/Makefile | 2 +- arch/x86/dts/Makefile | 2 +- arch/x86/dts/{efi.dts => efi-x86_app.dts} | 4 ++-- board/efi/Kconfig | 6 +++--- board/efi/{efi-x86 => efi-x86_app}/Kconfig | 6 +++--- board/efi/{efi-x86 => efi-x86_app}/MAINTAINERS | 0 board/efi/{efi-x86 => efi-x86_app}/Makefile | 2 +- board/efi/{efi-x86/efi.c => efi-x86_app/app.c} | 0 configs/{efi-x86_defconfig => efi-x86_app_defconfig} | 4 ++-- doc/README.u-boot_on_efi | 8 ++++---- include/configs/{efi-x86.h => efi-x86_app.h} | 0 13 files changed, 18 insertions(+), 18 deletions(-)
Quoted 9 lines
rename arch/x86/cpu/efi/{efi.c => app.c} (100%)
rename arch/x86/dts/{efi.dts => efi-x86_app.dts} (82%)
rename board/efi/{efi-x86 => efi-x86_app}/Kconfig (64%)
rename board/efi/{efi-x86 => efi-x86_app}/MAINTAINERS (100%)
rename board/efi/{efi-x86 => efi-x86_app}/Makefile (82%)
rename board/efi/{efi-x86/efi.c => efi-x86_app/app.c} (100%)
rename configs/{efi-x86_defconfig => efi-x86_app_defconfig} (92%)
rename include/configs/{efi-x86.h => efi-x86_app.h} (100%)applied to u-boot-x86, thanks!
PATCH v2 13/13 x86: efi: app: Display correct CPU info during boot
In reply to Bin MengCurrently when EFI application boots, it says:
CPU: x86_64, vendor <invalid cpu vendor>, device 0h
Fix this by calling x86_cpu_init_f() in arch_cpu_init().
---
Changes in v2:
- drop patches that were already applied to u-boot-x86
arch/x86/cpu/efi/app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/cpu/efi/app.c +1 -1
@@ -9,7 +9,7 @@int arch_cpu_init (void ) { -return 0 ; +return x86_cpu_init_f (); }int checkcpu (void )
Signature · 1 line
2.7.4
PATCH v2 13/13 x86: efi: app: Display correct CPU info during boot
Quoted 9 lines · Bin Meng
Currently when EFI application boots, it says:
CPU:
x86_64, vendor <invalid cpu vendor>, device 0hFix this by calling
x86_cpu_init_f()inarch_cpu_init().Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 8 lines
---
Changes in v2:
- drop patches that were already applied to u-boot-x86arch/x86/cpu/efi/app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
applied to u-boot-x86, thanks!