
From: Simon Glass <sjg@chromium.org> The x86 and ARM implementations use a different variable for the same thing, just inverted. Invent a third name for this, adjust both files to use it and store it in the common stub.c file. Signed-off-by: Simon Glass <sjg@chromium.org> --- include/efi_stub.h | 3 +++ lib/efi_client/stub.c | 9 +++++++++ lib/efi_client/stub_arm64.c | 8 +++----- lib/efi_client/stub_x86.c | 6 ++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/efi_stub.h b/include/efi_stub.h index eb2da6a76d3..d788ce4984e 100644 --- a/include/efi_stub.h +++ b/include/efi_stub.h @@ -100,4 +100,7 @@ int setup_info_table(struct efi_priv *priv, int size); void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type, void *ptr1, int size1, void *ptr2, int size2); +/* true if we must use the hardware UART directory (EFI not available) */ +extern bool use_hw_uart; + #endif /* _EFI_STUB_H */ diff --git a/lib/efi_client/stub.c b/lib/efi_client/stub.c index cf0314ba6a6..fad669cb64d 100644 --- a/lib/efi_client/stub.c +++ b/lib/efi_client/stub.c @@ -13,6 +13,15 @@ #include <efi_api.h> #include <efi_stub.h> +/* + * true if we must use the hardware UART directory (EFI not available). This + * is normally false, meaning that character output is sent to the efi_putc() + * routine. Once exit-boot-services is called, we must either not use character + * output at all, or use a hardware UART directly, if there is a driver + * available. + */ +bool use_hw_uart; + int efi_stub_exit_boot_services(void) { struct efi_priv *priv = efi_get_priv(); diff --git a/lib/efi_client/stub_arm64.c b/lib/efi_client/stub_arm64.c index 22c5f23865d..b8f6d6e73c0 100644 --- a/lib/efi_client/stub_arm64.c +++ b/lib/efi_client/stub_arm64.c @@ -18,8 +18,6 @@ #include <linux/err.h> #include <linux/types.h> -static bool ebs_called; - void _debug_uart_putc(int ch) { struct efi_priv *priv = efi_get_priv(); @@ -31,7 +29,7 @@ void _debug_uart_putc(int ch) * NOTE: for development it is possible to re-implement * your boards debug uart here like in efi_stub.c for x86. */ - if (!ebs_called) + if (!use_hw_uart) efi_putc(priv, ch); } @@ -68,7 +66,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; efi_status_t ret; - ebs_called = false; + use_hw_uart = false; ret = efi_init(priv, "Payload", image, sys_table); if (ret) { @@ -117,7 +115,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, return ret; /* The EFI console won't work now :( */ - ebs_called = true; + use_hw_uart = true; map.version = priv->memmap_version; map.desc_size = priv->memmap_desc_size; diff --git a/lib/efi_client/stub_x86.c b/lib/efi_client/stub_x86.c index a7b48eb7c09..e9276ee825d 100644 --- a/lib/efi_client/stub_x86.c +++ b/lib/efi_client/stub_x86.c @@ -31,8 +31,6 @@ #error "This file needs to be ported for use on architectures" #endif -static bool use_uart; - struct __packed desctab_info { uint16_t limit; uint64_t addr; @@ -67,7 +65,7 @@ void putc(const char ch) if (ch == '\n') putc('\r'); - if (use_uart) { + if (use_hw_uart) { struct ns16550 *com_port = (struct ns16550 *)0x3f8; while ((inb((ulong)&com_port->lsr) & UART_LSR_THRE) == 0) @@ -262,7 +260,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, return ret; /* The EFI UART won't work now, switch to a debug one */ - use_uart = true; + use_hw_uart = true; map.version = priv->memmap_version; map.desc_size = priv->memmap_desc_size; -- 2.43.0