From patchwork Mon Sep 22 18:01:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 407 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564170; bh=5deuFto6HiEMAPTBrBCPT7gMwXFIcxf/oTqw7ixKlRk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cX9GDHjleUC0wpsN0T/yeJh6ROpZ3s/9Y4Y8RLJFfZa4zKJ/cc/8kFmQVzhzurI+C RQRIySNRl8AdRybsZGa8wtKswfo9PAupWZuAKv2Mk2RA0dD73dY31jZh9NCGIbclUx ALLdQZ5TlTpCm+3uMSZfIRGQxXcQVnlr9jz8vh6I2oozp1xrUBCWn98ENF5AVXeu+B jLGI01lexuRm64ch9tju9DibyeXrQmCr+yFwbbpcdQtrERxflp9deM0sW7xND8cbfN L6XXX7hpYHhGTP7CweiKMWWgFLSAg4oIlaVCq/mGmpUkmQLVbEJeIcdyl9cetUcXPR OVOhQ00Wwap8w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B0D2867CA9 for ; Mon, 22 Sep 2025 12:02:50 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id X5QiN9k1CIxS for ; Mon, 22 Sep 2025 12:02:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564170; bh=5deuFto6HiEMAPTBrBCPT7gMwXFIcxf/oTqw7ixKlRk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cX9GDHjleUC0wpsN0T/yeJh6ROpZ3s/9Y4Y8RLJFfZa4zKJ/cc/8kFmQVzhzurI+C RQRIySNRl8AdRybsZGa8wtKswfo9PAupWZuAKv2Mk2RA0dD73dY31jZh9NCGIbclUx ALLdQZ5TlTpCm+3uMSZfIRGQxXcQVnlr9jz8vh6I2oozp1xrUBCWn98ENF5AVXeu+B jLGI01lexuRm64ch9tju9DibyeXrQmCr+yFwbbpcdQtrERxflp9deM0sW7xND8cbfN L6XXX7hpYHhGTP7CweiKMWWgFLSAg4oIlaVCq/mGmpUkmQLVbEJeIcdyl9cetUcXPR OVOhQ00Wwap8w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9C6D167C96 for ; Mon, 22 Sep 2025 12:02:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564169; bh=axOM1/UmfCzq+i+Hq3d5bKbzgCdixg53evjxdU0b2Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ClyoOqAtbBcXz/W4ijhZs5gVLCXjr2Qm0WDNOOt9GiqIHrXbUGb4icmam2E/efFB5 QS82ute+qXvR3I0FnotwpLuYnR6PjGn2+nZ1o4PMciFRnUI4Yz3iDihbM0ru1kyw9Z qE/Z4WDGIv/KrKGwWpsPCZ7l89taASSL9ed73v3i+MuOKb/QAkNoVvkybJBfRcKky4 2FUGP3j6cNG77Aw85VZKE5PFv+zLcOdAuFeDtCeViFwV9puLtYXdqLLsAcUub3D01G Y4rTSLIZGTYpUt62XIQCkykCen8Sy62Vs3COV3rLBc1v1vwyVRZGzOF7d0wwwf0bGs JXRGo3RJJqi9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3FE2C67B36; Mon, 22 Sep 2025 12:02:49 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Yzsyji2Mj9qm; Mon, 22 Sep 2025 12:02:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758564164; bh=yyMi59vXso6VQG3BJNEQ7esrsL9DiIu5Sl4nRGrRic8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K46NBvSm1W2mo/3iLI7vz3xvs938RbOJx633qiteIfeKkR6UtmQil7G9P/iA8aA/A k++PKA7KwQv1rcvB/KNRaXXEuZmlZBGngTvrIAVrN2YV+jXIwgcJfq9a0VfNXXTAfb J+gdPjq0TAQ/4Zh93kk8F2Uj/JZOihsLOYKNeWJIcDP80HCttBxk5+5r50muY0DBj3 OTfrGwMd7ot+W9D4lMMnF/Tq2cjlkKSMhG4tO3roe+/aRRoJeaeunn9+IQe06PplSs LCZszFb57SCA42QC3YRwRO2ntOx3pof9JbIi/t1M0xjFZphIN7/ypABoJNxGLGWfOX 6pYu3hRHW6dFQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CBF6D5FE1A; Mon, 22 Sep 2025 12:02:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Sep 2025 12:01:07 -0600 Message-ID: <20250922180116.3088502-24-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250922180116.3088502-1-sjg@u-boot.org> References: <20250922180116.3088502-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: A4U5PJZSCN3FF6N37VYHCF57F2XIEL7C X-Message-ID-Hash: A4U5PJZSCN3FF6N37VYHCF57F2XIEL7C X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 23/24] efi: app: Move efi_main() to the bottom of the file List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass It is common for the main program to be at the bottom, but with recent changes it has crept up a bit. Move it back to the bottom. Signed-off-by: Simon Glass --- lib/efi_client/efi_app.c | 114 +++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index b99de578fac..c851173f1ae 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -193,63 +193,6 @@ static void efi_exit(void) priv->boot->exit(priv->parent_image, EFI_SUCCESS, 0, NULL); } -/** - * efi_main() - Start an EFI image - * - * This function is called by our EFI start-up code. It handles running - * U-Boot. If it returns, EFI will continue. Another way to get back to EFI - * is via reset_cpu(). - */ -efi_status_t EFIAPI efi_main(efi_handle_t image, - struct efi_system_table *sys_table) -{ - struct efi_priv local_priv, *priv = &local_priv; - efi_status_t ret; - - /* Set up access to EFI data structures */ - ret = efi_init(priv, "App", image, sys_table); - if (ret) { - printf("Failed to set up U-Boot: err=%lx\n", ret); - return ret; - } - efi_set_priv(priv); - - /* - * Set up the EFI debug UART so that printf() works. This is - * implemented in the EFI serial driver, serial_efi.c. The application - * can use printf() freely. - */ - debug_uart_init(); - - ret = setup_memory(priv); - if (ret) { - printf("Failed to set up memory: ret=%lx\n", ret); - return ret; - } - - scan_tables(priv->sys_table); - find_protocols(priv); - - /* - * We could store the EFI memory map here, but it changes all the time, - * so this is only useful for debugging. - * - * ret = efi_store_memory_map(priv); - * if (ret) - * return ret; - */ - - printf("starting\n"); - - board_init_f(GD_FLG_SKIP_RELOC); - gd = gd->new_gd; - board_init_r(NULL, 0); - free_memory(priv); - efi_exit(); - - return EFI_SUCCESS; -} - static int efi_sysreset_request(struct udevice *dev, enum sysreset_t type) { struct efi_priv *priv = efi_get_priv(); @@ -421,3 +364,60 @@ U_BOOT_DRIVER(efi_sysreset) = { .of_match = efi_sysreset_ids, .ops = &efi_sysreset_ops, }; + +/** + * efi_main() - Start an EFI image + * + * This function is called by our EFI start-up code. It handles running + * U-Boot. If it returns, EFI will continue. Another way to get back to EFI + * is via reset_cpu(). + */ +efi_status_t EFIAPI efi_main(efi_handle_t image, + struct efi_system_table *sys_table) +{ + struct efi_priv local_priv, *priv = &local_priv; + efi_status_t ret; + + /* Set up access to EFI data structures */ + ret = efi_init(priv, "App", image, sys_table); + if (ret) { + printf("Failed to set up U-Boot: err=%lx\n", ret); + return ret; + } + efi_set_priv(priv); + + /* + * Set up the EFI debug UART so that printf() works. This is + * implemented in the EFI serial driver, serial_efi.c. The application + * can use printf() freely. + */ + debug_uart_init(); + + ret = setup_memory(priv); + if (ret) { + printf("Failed to set up memory: ret=%lx\n", ret); + return ret; + } + + scan_tables(priv->sys_table); + find_protocols(priv); + + /* + * We could store the EFI memory map here, but it changes all the time, + * so this is only useful for debugging. + * + * ret = efi_store_memory_map(priv); + * if (ret) + * return ret; + */ + + printf("starting\n"); + + board_init_f(GD_FLG_SKIP_RELOC); + gd = gd->new_gd; + board_init_r(NULL, 0); + free_memory(priv); + efi_exit(); + + return EFI_SUCCESS; +}