From patchwork Mon Oct 6 23:21:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 532 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=1759792980; bh=vtxdoBpaHhT2/B0YuRdZ5VCq7Gb91oxMUYr0BuCgx0U=; 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=OM4Eoz5wUlop+sD6ypkCJbJnWztLrHejhqKkD1jjbb9j6A2cGWneYRU2w99ltkhdu GikIKXl19FWsf+OSNP0Ttg+WoNPHKrhlzWZ5LyfJlBeCa95h0PlGrY8pns/aQnMG4f c965VZOK/JpdLkE5qYL4Y82rYtwKWAmSexoJPCKnIYit0T97NszSEhBfDlsdivBRGD zip0zmsQy/0r7bJGyWV1fXkq5SuwCWDp5F3uDWksAK9plDU4nslgMdBNPcwLAw8IJe aVkSTUz+dkMOw4dHQAzYwEeUX6PjeitX2WYVamWbk7n2yasrr6lAoTZE+n7ybyQnnv GT2Ksu3bTlWpA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6B7AF67F03 for ; Mon, 6 Oct 2025 17:23:00 -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 IWgwIgMK9OrA for ; Mon, 6 Oct 2025 17:23:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792980; bh=vtxdoBpaHhT2/B0YuRdZ5VCq7Gb91oxMUYr0BuCgx0U=; 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=OM4Eoz5wUlop+sD6ypkCJbJnWztLrHejhqKkD1jjbb9j6A2cGWneYRU2w99ltkhdu GikIKXl19FWsf+OSNP0Ttg+WoNPHKrhlzWZ5LyfJlBeCa95h0PlGrY8pns/aQnMG4f c965VZOK/JpdLkE5qYL4Y82rYtwKWAmSexoJPCKnIYit0T97NszSEhBfDlsdivBRGD zip0zmsQy/0r7bJGyWV1fXkq5SuwCWDp5F3uDWksAK9plDU4nslgMdBNPcwLAw8IJe aVkSTUz+dkMOw4dHQAzYwEeUX6PjeitX2WYVamWbk7n2yasrr6lAoTZE+n7ybyQnnv GT2Ksu3bTlWpA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5A95A67F58 for ; Mon, 6 Oct 2025 17:23:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792978; bh=Qp9+0TLDVJjJNCcYwBE/bfngr7fr+Xx3nFE2VploI3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uq9HOHCU6ZQfS8WVOWtvaPJ1h67/gULuxjx7e6PUgnEuP3SN+NzS9/Cenn901dmeE aa7BNv7wHRSNfvUV/Q9xmY4t/07EcnWHVrN1GUzWPfjtZvTrJllz4ZZMqGme+2tvBC bIRc0hA0ACvmKynhH/Css9I7AaSY23+ougnVRydaBSBKtID72xDuM/9fSnWucw2xzU uqVdr26sXZR6xTt2DkNUDVdCa+ra5i7YGZPe+IsJnmz/eKojNJ3JHwF68bDnyz0T6/ 5Afn4VJJ316fwSN5v426NrO8HUDU6pRRGDDIA3n11B7G8xHC1MvhM2y9ulpDaog22O gR0zpk9GXQ/bQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C9AF67DB4; Mon, 6 Oct 2025 17:22:58 -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 y5rmqLSN4KDG; Mon, 6 Oct 2025 17:22:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792974; bh=hFbw5TkWyQ9YMbcBg+63pYswnepnELyvUCCM4f9paOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ILyRqJ17heiy/11/Q2v7JJZS6ojam+9utfF7eeGZBhROsrVV8vxqbVIsKA2v1UxMJ zGJUCR0de3+2ZpoWjcizmf4EbULOLIfMrsZcs0P8Mm5cQLPcouj8nVqjupwzlY2v00 lbnhwetHn8kRldtcBu1q89rCjwMueKY0cW/LhsSkOg2Fz0A+KsJxW09L3TXP9dCAhU GioeVq4FArFQjuJlKnjZ3xsTBG0lmLfagq9GfenkivQ54hgIlaqmLraZO4LLPZQxDj Y1msTLcaspiMdeSU7l404NaTr3px3uLsN+Hj9Ox1PYCZKBTSNI45jTATSzC3NhJeiQ gmsrS15uv4Tzg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A400D67FD0; Mon, 6 Oct 2025 17:22:53 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:43 -0600 Message-ID: <20251006232236.2091941-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2YRHMDDB3F5ABC6CU7CK5YLGH2JPBKJU X-Message-ID-Hash: 2YRHMDDB3F5ABC6CU7CK5YLGH2JPBKJU 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/17] qfw: Export qfw_locate_file() for external use 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 Export the qfw_locate_file() function to allow other modules to locate files in the QEMU firmware config without loading them into memory. Co-developed-by: Claude Signed-off-by: Simon Glass --- drivers/qfw/qfw.c | 4 ++-- include/qfw.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/qfw/qfw.c b/drivers/qfw/qfw.c index 6ac5b1cd625..2e260d60449 100644 --- a/drivers/qfw/qfw.c +++ b/drivers/qfw/qfw.c @@ -212,8 +212,8 @@ int qemu_fwcfg_setup_kernel(struct udevice *qfw_dev, ulong load_addr, return 0; } -static int qfw_locate_file(struct udevice *dev, const char *fname, - enum fw_cfg_selector *selectp, ulong *sizep) +int qfw_locate_file(struct udevice *dev, const char *fname, + enum fw_cfg_selector *selectp, ulong *sizep) { struct fw_file *file; int ret; diff --git a/include/qfw.h b/include/qfw.h index c1f558b6f87..75aada09206 100644 --- a/include/qfw.h +++ b/include/qfw.h @@ -464,6 +464,18 @@ int qfw_load_file(struct udevice *dev, const char *fname, ulong addr); */ int qfw_get_file(struct udevice *dev, const char *fname, struct abuf *loader); +/** + * qfw_locate_file() - Locate a file in the QEMU firmware config + * + * @dev: UCLASS_QFW device + * @fname: Filename to locate + * @selectp: Returns the selector for the file + * @sizep: Returns the size of the file + * Return: 0 on success, -EINVAL if firmware list cannot be read or file not found + */ +int qfw_locate_file(struct udevice *dev, const char *fname, + enum fw_cfg_selector *selectp, ulong *sizep); + /** * cmd_qfw_e820() - Execute the 'qfw e820' command for x86 * From patchwork Mon Oct 6 23:21:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 533 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=1759792983; bh=kh48lDFhq6G7xNwSofH+K0OKkSiwuofrYA2wFvhPrf0=; 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=SJQNEf20tx5tYcz1A6/ti8XB7ZiVUbxyXEHrxNwK5ocue/eZRr4SjQaRnGy587mH6 zK8zbtRMDLToTOAhThBP9Fz6wzK/AzHAwOLdgYJoiaO+zgMRJVl/fF5BI/ztZhH6Yp SzJiyoeRnHYSpm5J2KGumxQLT4QUU3BsfTnPSr4I7ISmBqDc9RFNbCTpQFoV/XvgmF +8YEk79zK5PNt+rneCBzSCBu9nNxqUXtE+smq6d6jweWeSrYJxLdjmc/dXAKCn8Lpp 9rMu2AlAg0qj8Nq0BtEokB/weRSee7XcL3M9YMdrFqRjTpJ95JDN4Eam7vdJTaLcOK uPTeqj+JDoAmw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1C45D67DB4 for ; Mon, 6 Oct 2025 17:23:03 -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 1hfqnijPtoJe for ; Mon, 6 Oct 2025 17:23:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792983; bh=kh48lDFhq6G7xNwSofH+K0OKkSiwuofrYA2wFvhPrf0=; 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=SJQNEf20tx5tYcz1A6/ti8XB7ZiVUbxyXEHrxNwK5ocue/eZRr4SjQaRnGy587mH6 zK8zbtRMDLToTOAhThBP9Fz6wzK/AzHAwOLdgYJoiaO+zgMRJVl/fF5BI/ztZhH6Yp SzJiyoeRnHYSpm5J2KGumxQLT4QUU3BsfTnPSr4I7ISmBqDc9RFNbCTpQFoV/XvgmF +8YEk79zK5PNt+rneCBzSCBu9nNxqUXtE+smq6d6jweWeSrYJxLdjmc/dXAKCn8Lpp 9rMu2AlAg0qj8Nq0BtEokB/weRSee7XcL3M9YMdrFqRjTpJ95JDN4Eam7vdJTaLcOK uPTeqj+JDoAmw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 092E467F03 for ; Mon, 6 Oct 2025 17:23:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792980; bh=qXhglvSEQgMlKx3y1OpFL75mw53j/Le/6sx8uw1PaA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WcwEsOcbBq/T6c7fxYiuS7yajV5SSVyWNmLK0x6iP1sNqrA34sLX41jZ/kx2jjrWE 7XWAw7Yim6CnsDXNAvHdHZzQ3iuEn6ujOTTbbMr3oTMVlDXZDV81/cpSjZWAhaP9qd jcMcDr/UkIsh6SnAbRHEv5fyjaJhIJ2fhC2Txcz69VQRpsGW9uZpq+f8RuweY44awO PG9fKLxnFB+O7V2lCjZm/RmzIXZlnOGpCAQg4iEkSr5HWLhJDSV1bFDts34+9QLEy4 eyNXLxa2zTo4E37DW0tY3tnrmBetaH/Vod69Nd8/Qf6JTsKx2rmk7rMQVoC65WF9tq QYc8nQZZyVUpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 130E167DB4; Mon, 6 Oct 2025 17:23:00 -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 WAWka-_VH12H; Mon, 6 Oct 2025 17:23:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792978; bh=arwzHrkvudjTR8eLaBbrvP/sck5HKn2WrHPNDTXxW2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xa3++9Z2ZUIq+KxvUY+kHcD/GAEiLi0xOqVpC+H3MWmbjrziTAtnkFSS9OV0j4tSF klGun61n+lS3is20kG0zh0syDl5pNTKNHOkXefrOvXoXXOJnm6IJiePpFRd4LFVGUl LM9OKaR6BIWVJtqyuTTtGX1nn4IlNj8tyV8CvQHD6JOMYZTaFgWPyMXRSoyUY7JZol rbwbov6DRDV6F56nSMAc0T1clUIaRhQs2v+yZIWg6uOMn3VjhK4lzXNNy9wF/0QGsR lN/6ckSOQpDJPL4tK7cjDapeLkxTCBQ9d3wksvUQQwS8AHfFkyTuWRctgN/E1NpZcq Bq/2S3xvYq8TA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 52A2E67F03; Mon, 6 Oct 2025 17:22:58 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:44 -0600 Message-ID: <20251006232236.2091941-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VYQ2RA26OKAF55UFLFA5YCFAZ5ID6VTY X-Message-ID-Hash: VYQ2RA26OKAF55UFLFA5YCFAZ5ID6VTY 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/17] event: Add EVT_BOOTCMD event for custom boot commands 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 Add a new event that is triggered in main_loop() before autoboot_command(). This allows platform code to provide a custom bootcmd string via the event system. The event uses struct event_bootcmd which provides a buffer for the bootcmd string and its size. Platform event handlers can write their custom bootcmd to this buffer. Co-developed-by: Claude Signed-off-by: Simon Glass --- common/event.c | 1 + common/main.c | 32 +++++++++++++++++++++++++++++++- include/event.h | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/common/event.c b/common/event.c index a48ca6c549d..44f32035775 100644 --- a/common/event.c +++ b/common/event.c @@ -49,6 +49,7 @@ const char *const type_name[] = { /* main loop events */ "main_loop", + "bootcmd", /* booting */ "boot_os_addr", diff --git a/common/main.c b/common/main.c index b0b6e74f5d3..06e5193ecb9 100644 --- a/common/main.c +++ b/common/main.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -38,10 +39,35 @@ static void run_preboot_environment_command(void) } } +static const char *get_autoboot_cmd(char *buf, int size) +{ + const char *s = NULL; + + if (IS_ENABLED(CONFIG_EVENT)) { + struct event_bootcmd event_bootcmd; + int ret; + + event_bootcmd.bootcmd = buf; + event_bootcmd.size = size; + buf[0] = '\0'; + + ret = event_notify(EVT_BOOTCMD, &event_bootcmd, + sizeof(event_bootcmd)); + if (ret) + return NULL; + + if (buf[0] != '\0') + s = buf; + } + + return s; +} + /* We come here after U-Boot is initialised and ready to process commands */ void main_loop(void) { const char *s; + char bootcmd_buf[CONFIG_SYS_CBSIZE]; bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); @@ -64,7 +90,11 @@ void main_loop(void) process_button_cmds(); - s = bootdelay_process(); + /* Allow platform code to provide bootcmd via event */ + s = get_autoboot_cmd(bootcmd_buf, sizeof(bootcmd_buf)); + if (!s) + s = bootdelay_process(); + if (cli_process_fdt(&s)) cli_secure_boot_cmd(s); diff --git a/include/event.h b/include/event.h index 5fecaa66e80..2f0eac61633 100644 --- a/include/event.h +++ b/include/event.h @@ -172,6 +172,16 @@ enum event_t { */ EVT_MAIN_LOOP, + /** + * @EVT_BOOTCMD: + * This event is triggered in main_loop() before autoboot_command(). + * It allows platform code to provide a custom bootcmd string. + * Its parameter is of type struct event_bootcmd. + * The event handler can write the bootcmd to the provided buffer. + * A non-zero return value causes the boot to fail. + */ + EVT_BOOTCMD, + /** * @EVT_BOOT_OS_ADDR: * Triggered immediately before the OS is loaded into its final address @@ -270,6 +280,18 @@ union event_data { struct event_bootm_final { enum bootm_final_t flags; } bootm_final; + + /** + * struct event_bootcmd - bootcmd override + * + * @bootcmd: Buffer for bootcmd string (provided by caller, must be an + * empty string on entry) + * @size: Size of bootcmd buffer + */ + struct event_bootcmd { + char *bootcmd; + int size; + } bootcmd; }; /** From patchwork Mon Oct 6 23:21:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 534 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=1759792987; bh=J4VmHo0NxZhSzXosqDYMVG5ubgYv4qqOoQXkOSLLvP4=; 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=TaITnzhICSxKNQlqGihgHBYf9BLAcIGgTWzLtYY1/vZGzIP5/2bnLEVfLNoQqhYc+ +C/+j9ImqeKApRW96BjrmHQ8Am+IczMNviJraPu0Zd7cFTUpVH8hhBoJdvdnbynPWW fCWZJjUL+RTZkxoxQUsgpGtj3OkJyHPVF+DElpVR7S+ibcOrKM81Y74HbMDEgz3PpM qpAPBB0UpULWy/1VHLVkswdYTFj9jzhgPXBiCPexEQGppo5e3LP6ztFap2oQuVpGTQ pEZApAWh0+1rfoovZ/p1+fvx3+Pu7Ga3m2zJ++l6lAGrbwHp3LPCXVPPPjOo6Ke4Vt lD1DFljX/0o2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0119D67FB7 for ; Mon, 6 Oct 2025 17:23:07 -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 MW8VgSlSMf9o for ; Mon, 6 Oct 2025 17:23:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792986; bh=J4VmHo0NxZhSzXosqDYMVG5ubgYv4qqOoQXkOSLLvP4=; 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=FeMxV43odLDMfMRyRzNWUwCwDgE4isFNvdI7A76TrLfrZ+UxKVGDq5ijPCPwz0hTX p7E9MRjtf7YkVgvNKTNCQ3qS4OW8LpXjO4GB0Hk/iLRDLENYuoEvtJkQf1Vpt2bAF0 +u02AhNkx32wJTxGjMsgLKlcD8Gmu9ISj4CS+xYSEFStfvt1d9cUr8Vh4by8yF6A8V vdm5NZAvEUdPGcHxP7zvGdPb02gHo3JQoE4VqmX1AloKeNZd1pRXlTKpKvwsYxGIM/ OmMbuuURJDmlo5bdo2CfLcFfj24WMqpo7K7Ur8mXWCYN4JVJzFvH5VNv69FLAje3Nr hdVIdU524CDdg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E2B7967DB4 for ; Mon, 6 Oct 2025 17:23:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792985; bh=8pkmpflqXjvr15QqhI7or71YphoFtEY8NLHkb/uvlKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKbMomKPWm0DHJYOK6lC9+jroT6loao2GhwnxO1G0H85r27yFpZ5nqKLuNpWaBa/8 EHAf1hmiAN9gy5GujyqTMfmiQtka0cFZi5/XhK4ycn7wiQMcXvKcnqCmINx9r/olZQ M8BUGug9dwel+I/uxpu640R778qomT/msfVrW83vLZGIpSp5q8zlGZ0BSKDG1LTskF Q6PIujCDy5AIaS2AAHNZa/FsK/4D5MqyMn7SHJA6y4oJ39tKio7sqHCuM1Ltz4jJO5 2T6ewO1IXKD8v8SoFbnN8DOUep65CYhL/51d2rFgTeA39m6bWCh79v1HygpKp1iR12 eCCcrhCIktITQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE6DA67F03; Mon, 6 Oct 2025 17:23:05 -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 J03PNjGx6DWY; Mon, 6 Oct 2025 17:23:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792980; bh=kpowPWEOC5za33yQU/cQozQQ4RPbdg/lAr85bG2pZb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B3rQz25rc+OpScuYg5NrHYV3sFVHUwbzCZ69etsEfs5lc7rawImQFw2FlN2JdzzKV T6t79AN0kzdzTXhXf/5U0S3Gygz6czSiAAdDdAIrPNztrIxZ6JH8A2V+O6xfyv2aVK LKRHqbrHPxEDu7gCuqcGEHpFm/kIfPiSpDpzt8dbtLJVJirK1c4oPadBslSPu8Dr3a XzaYYvuoFcXrR6RATpxyIOMKOOSbH730rQuEVVXaPlSehzGitQ1PNmxEriV6ym+sa3 LEpMB7yqsh4efoqw1Nzg+jwIuWoGtTsmbgGfOc9HdbC9YkA42p9zKv+WctpB+/v4zt DWMgK4l/Y3/eg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 57AFF67F3F; Mon, 6 Oct 2025 17:23:00 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:45 -0600 Message-ID: <20251006232236.2091941-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MIJM3AXOUWMOXTMF5R4FE3ESNSD4AYHP X-Message-ID-Hash: MIJM3AXOUWMOXTMF5R4FE3ESNSD4AYHP 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/17] x86: qemu: Add EVT_BOOTCMD handler to get bootcmd from fw_cfg 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 Implement an EVT_BOOTCMD event handler that reads the bootcmd from QEMU's fw_cfg interface using the "opt/u-boot/bootcmd" file. This allows QEMU to provide a custom boot command to U-Boot at runtime. Uses the newly exported qfw_locate_file() function to locate and read the bootcmd file. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/x86/cpu/qemu/qemu.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c index e846ccd44aa..24916d867ee 100644 --- a/arch/x86/cpu/qemu/qemu.c +++ b/arch/x86/cpu/qemu/qemu.c @@ -4,6 +4,9 @@ */ #include +#include +#include +#include #include #include #include @@ -150,3 +153,31 @@ int mp_determine_pci_dstirq(int bus, int dev, int func, int pirq) return irq; } #endif + +#if CONFIG_IS_ENABLED(EVENT) +static int qemu_get_bootcmd(void *ctx, struct event *event) +{ + struct event_bootcmd *bc = &event->data.bootcmd; + enum fw_cfg_selector select; + struct udevice *qfw_dev; + ulong size; + + if (qfw_get_dev(&qfw_dev)) + return 0; + + if (qfw_locate_file(qfw_dev, "opt/u-boot/bootcmd", &select, &size)) + return 0; + if (!size) + return 0; + + /* Check if the command fits in the provided buffer with terminator */ + if (size >= bc->size) + return -ENOSPC; + + qfw_read_entry(qfw_dev, select, size, bc->bootcmd); + bc->bootcmd[size] = '\0'; + + return 0; +} +EVENT_SPY_FULL(EVT_BOOTCMD, qemu_get_bootcmd); +#endif From patchwork Mon Oct 6 23:21:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 535 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=1759792989; bh=MEmPyj8iDv4Yu/oTpkKjn0GcxiOb90pBgqoE01TSj7k=; 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=uebqgwozfUKUfnrXxuoyjLGaxe5vyVgtJvOGBD7/gxFuNJqkJPpF4RIrRKfUU+I/G CFUGltsKRi7WNvL3wNGJ8V2+2eEcuaspjcqNsGmwaxPfEzJJhMXFtN3btA52/4rEJD s3quCKJj5MKJtmGpnsk47LWfG4CP3SwENnuZTu21j4KyQyqLHrSlLOWRF71Opd5BF+ 1Rsa9ivanqKnKOFKZ6yuYm3PPPM+AvPCNMhBUEi0lirkvTR4SRV9gLo6/GyKDLjNAR 7Ir+V9oxFw/WjegpFtQ2y1HfvFFXCOy+AklifGlt+XsLyu7aBIMZOOZWxFDwLEz//B +fBJ95tN3agoQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C7E567DB4 for ; Mon, 6 Oct 2025 17:23:09 -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 HJ2w31cAQTsL for ; Mon, 6 Oct 2025 17:23:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792988; bh=MEmPyj8iDv4Yu/oTpkKjn0GcxiOb90pBgqoE01TSj7k=; 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=fhpJpDa5cxpd9XJ2hcu4KWwwh2yc32OpiR9qYMGneMHW5bV6GP4DV/G7/vPsiZ1hT rweQ/HioJzSp4Wwe4C+ef8yhGPtn65IXADBboQljyiBGKX08qrJUunRfkAQSgX/rPB zQKAH5d0JdwDxEoy3zvHKkpuGmN5qAaUn4iCtPm+RnZY9i66liFpPX7jI3JtA6bmr9 UwWTG23D2FdZ0kuGXuXwReqhboD5RqngRIvy4UdsM2h1buhZ2d3t10EjwjhRMvdJdb +0/bm+gz3vIjqeiLRN3xpQaCMm/dzbX5CWUB+ioVA9pgipWuXCyVKndh8HV51B/lMr YBuoLnQ+aJP4A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 77A6967F3F for ; Mon, 6 Oct 2025 17:23:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792986; bh=Ba5osKn7uajNr9rzUc1spB4vwMJEGleuvbHYhp5Q4Po=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djA3YUGhoBl9m98ksW56x2woA+hpRAAvQCa7C4ByPRgn8DrHTaARerMSMCkLCG90I UjmKqWyB3yiDlIZ2pyfVrXB4wjNvjxrxUnq/o24FFah+V5VatpMRUoMY+jNi902nZC 5CsxyxWr/aEeDaWizO+t6Q5tm/UzeSCXlkGsTT9iUt2ByuONQpRhdmWiFJYgSCeRby bNBDiJ/N77mMK/1/0XGzMcnMMImnk7eD7FWkAfrEJD4XJUSQpjAxpJOknkghX/zvoV l0hlZ0ZAWXgOApNUJRDUu6pivuWpCo8yW4YJ+LINuM87eeLrdYNtdBaDUAYqsO0gST cZjCB+e3BX4HA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDA1867F3F; Mon, 6 Oct 2025 17:23:06 -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 Vd_I6mtCfYP0; Mon, 6 Oct 2025 17:23:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792985; bh=Nw17fOSInk82GsdjEbTBgc+LYRXAePAxSE78hPUti/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rZ5t7hSLKe7Meiih80zk87qIsXRR4KoymGzOQjkYeNJBRMY0Gj3+ZM7afYoOmANNl J0tGcY368lAKkI1o24avZkRdkY+LLnDePCUJBkMIIluwHYO+P1bJAeSoMT3JSUCqlK Wp1uWqOMYJemShQRo2Exgm/vyHTEoCdA380Zp4FdCWTH346zy4UANsaWV8840bRMVC SszYlIPkKr0/K9cNImeA1/gUR+dMq+T36Pj1VXDfG/gV6lcsp1Te0x67Ek2A9bJ69k hHDt7hV1YKh821xzZfSf2O7zu7tJGNGeJovgPw5agNeWaHeV2I8vPo7PGUQL/JTQwl 3WiCN6yR4npHQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 068CF67DB4; Mon, 6 Oct 2025 17:23:04 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:46 -0600 Message-ID: <20251006232236.2091941-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2FX6ZYF6BQ5NMVRVRPO625OVV2BBCJQU X-Message-ID-Hash: 2FX6ZYF6BQ5NMVRVRPO625OVV2BBCJQU 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/17] scripts: build-qemu: Add --bootcmd option to pass bootcmd via fw_cfg 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 Add a --bootcmd option to the build-qemu script that allows passing a boot command to QEMU via fw_cfg. The bootcmd is written to the "opt/u-boot/bootcmd" fw_cfg entry, which can be read by U-Boot's EVT_BOOTCMD handler. Co-developed-by: Claude Signed-off-by: Simon Glass --- doc/board/emulation/script.rst | 15 +++++++++++++++ scripts/build-qemu | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/doc/board/emulation/script.rst b/doc/board/emulation/script.rst index cf718ad41a7..239b1e1718d 100644 --- a/doc/board/emulation/script.rst +++ b/doc/board/emulation/script.rst @@ -64,6 +64,14 @@ Once configured, you can build and run QEMU for arm64 like this:: scripts/build-qemu -rsw +To pass a custom boot command to U-Boot via fw_cfg, use the `--bootcmd` +option:: + + scripts/build-qemu -rsw --bootcmd "echo Hello from QEMU; bootflow scan -lb" + +This will cause U-Boot to execute the specified command instead of the default +autoboot behavior. + Options ~~~~~~~ @@ -107,3 +115,10 @@ Options are available to control the script: -w Use word version (32-bit). By default, 64-bit is used + +--bootcmd BOOTCMD + U-Boot bootcmd to pass via fw_cfg. This allows passing a custom boot + command to U-Boot at runtime through QEMU's firmware configuration + interface. The bootcmd is written to the 'opt/u-boot/bootcmd' fw_cfg + entry and is read by U-Boot's EVT_BOOTCMD handler before the default + autoboot process runs. diff --git a/scripts/build-qemu b/scripts/build-qemu index 522325a8d57..ddaafc7587f 100755 --- a/scripts/build-qemu +++ b/scripts/build-qemu @@ -41,6 +41,8 @@ def parse_args(): description='Build and/or run U-Boot with QEMU', formatter_class=argparse.RawTextHelpFormatter) build_helper.add_common_args(parser) + parser.add_argument('--bootcmd', type=str, + help='U-Boot bootcmd to pass via fw_cfg') parser.add_argument('-e', '--sct-run', action='store_true', help='Run UEFI Self-Certification Test (SCT)') parser.add_argument('-E', '--use-tianocore', action='store_true', @@ -290,6 +292,11 @@ class BuildQemu: # Add other parameters gathered from options qemu_cmd.extend(self.qemu_extra) + # Add bootcmd via fw_cfg if specified + if self.args.bootcmd: + qemu_cmd.extend(['-fw_cfg', + f'name=opt/u-boot/bootcmd,string={self.args.bootcmd}']) + self.helper.setup_share(qemu_cmd) self.helper.run(qemu_cmd) From patchwork Mon Oct 6 23:21:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 536 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=1759792994; bh=ax+Dsvg0SYFiwgp8yL3bFkjcO+U0dN1Dt5PMZwxarXY=; 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=YNJjxoFkJTGKKzTPx/3XoKeDHCGU+M32cxGPEfKPDHZ5+z1Z8wYqo80Mrr0nMPz24 nIDuE8FTHhJzQgClZ/Rf2O43pN8WcXY4kR4vus9UI/ylcku6XSyUeOHaz+h/lYxl70 E7Vvg2UL8A+odjguViAPGdaoEA36G/hYoN4CQjenqMikoRjHuGxhxZJm844gSOUfyF bOqTq6fZPibpp3Rsarc0cVqVgMCQk5ZCMxpL+pP0DxiVkhUuc+0lnxyG2GyM71IZGu Npy8QFYL9ohetS7DL0MaI7/Ir18QmcJXvA3JGlQSbXkp/c3aVP8H6vUsjkWGyhD6lD wkP3ojtAH2brA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1301467FC6 for ; Mon, 6 Oct 2025 17:23:14 -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 kdWWwPMa3lOT for ; Mon, 6 Oct 2025 17:23:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792994; bh=ax+Dsvg0SYFiwgp8yL3bFkjcO+U0dN1Dt5PMZwxarXY=; 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=YNJjxoFkJTGKKzTPx/3XoKeDHCGU+M32cxGPEfKPDHZ5+z1Z8wYqo80Mrr0nMPz24 nIDuE8FTHhJzQgClZ/Rf2O43pN8WcXY4kR4vus9UI/ylcku6XSyUeOHaz+h/lYxl70 E7Vvg2UL8A+odjguViAPGdaoEA36G/hYoN4CQjenqMikoRjHuGxhxZJm844gSOUfyF bOqTq6fZPibpp3Rsarc0cVqVgMCQk5ZCMxpL+pP0DxiVkhUuc+0lnxyG2GyM71IZGu Npy8QFYL9ohetS7DL0MaI7/Ir18QmcJXvA3JGlQSbXkp/c3aVP8H6vUsjkWGyhD6lD wkP3ojtAH2brA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0337567F1D for ; Mon, 6 Oct 2025 17:23:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792991; bh=JAdAVzzwTmGfRffADrpU6A6AjORY1N4WPNUKz2Y/hR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AwwDBMmKopfdm7WQ1LZ4RgNHigKrN4nxgaqH5JCKJ9ylkpzfgm9xDf4ejqct3CIps txKqLuycgL00UxRjM1Zaj2o+MfNFl9uUWsYWp78VX6n1aKEMU+3M2fzL5br/DhCor4 /qpmuK/BzYgjy30mlSwHU+Z1ALDYuO36nWkyJj9Hw9uMMR8BNICpuQ40HejKMOnNSU D1LV13P6WCe2U+HVRW7dc398FbTGEWexOLF1GZe0dclA1R5akkPZE/ZJJCfUwDdKlW l5yynzUiRjzzI6JXhxetSeNKsZx4O7nAZCVApbWDMqxSN47ubnQjLufWNK0GRy5vUs CKwfperWZF9Jg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DC06F67DB4; Mon, 6 Oct 2025 17:23:11 -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 HvGpP2khfR2Q; Mon, 6 Oct 2025 17:23:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792987; bh=hpGXOz/BkZCfMUqtiYT+hf4+k9w8R4YJ0sy+cqMbdKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nm6VIhzbFrvPIMXMN5eem4eGp9m25jBNeM43iJZ+n0iVQzvY9eCWQKc0lF6BBVYLU nxsvCjk9YtvV1uDrgm/qIXwk/A7aaHP+tuFA0OYhBcHFbbS+csnh9EsCXjsD4LKMbQ CgFQUiliI7jmOODpVhNWAg6xu5rahrd6Fp4sZlVMLR0BkXNyjZW+XClrociNDmkndq ZEXO0bzuhxvjVi31oyCE2Xz6lrw4hBDUd1RX5RTpxAhTleXE8wa1Wpesed4jhOwERQ 3I8Iack6EcjoKgpjkB4RCiSe1X0Nk7rKh58efMfwAtHosC65mf0rd1QXxD+D8/mEeX kO07BA2Y5SbUA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1E72C67FC6; Mon, 6 Oct 2025 17:23:07 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:47 -0600 Message-ID: <20251006232236.2091941-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: K5EFZPT3YCOHPFEGCZOU7NV7WRFOKCOY X-Message-ID-Hash: K5EFZPT3YCOHPFEGCZOU7NV7WRFOKCOY 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 05/17] expo: Speed up polling the keyboard 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 The current algorithm spends 10ms or more looking for keyboard input. Since we expect the frame rate to be 50 or more, it should be OK to only check once. Handle the timeout by recording the timestamp of the last key and timing out the CLI entry after 10ms. This allows an 'Escape' key to work, rather than it just waiting forever for a terminal sequence that starts with escape. Signed-off-by: Simon Glass --- boot/expo.c | 16 ++++++++-------- include/expo.h | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/boot/expo.c b/boot/expo.c index ebe31059e87..5704dd9fecc 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ int expo_new(const char *name, void *priv, struct expo **expp) INIT_LIST_HEAD(&exp->str_head); exp->next_id = EXPOID_BASE_ID; cli_ch_init(&exp->cch); + exp->last_key_ms = get_timer(0); *expp = exp; @@ -488,21 +490,19 @@ static int poll_keys(struct expo *exp) ichar = cli_ch_process(&exp->cch, 0); if (!ichar) { - int i; - - for (i = 0; i < 10 && !ichar && !tstc(); i++) { - schedule(); - mdelay(2); - ichar = cli_ch_process(&exp->cch, -ETIMEDOUT); - } - while (!ichar && tstc()) { + /* Check once for available input */ + if (tstc()) { ichar = getchar(); ichar = cli_ch_process(&exp->cch, ichar); } + + if (!ichar && get_timer(exp->last_key_ms) >= 10) + ichar = cli_ch_process(&exp->cch, -ETIMEDOUT); } key = 0; if (ichar) { + exp->last_key_ms = get_timer(0); key = bootmenu_conv_key(ichar); if (key == BKEY_NONE || key >= BKEY_FIRST_EXTRA) key = ichar; diff --git a/include/expo.h b/include/expo.h index e9e71f4fe36..b51d946f367 100644 --- a/include/expo.h +++ b/include/expo.h @@ -146,6 +146,7 @@ struct expo_theme { * @scene_head: List of scenes * @str_head: list of strings * @cch: Keyboard context for input + * @last_key_ms: timestamp of the last key received */ struct expo { char *name; @@ -173,6 +174,7 @@ struct expo { struct list_head scene_head; struct list_head str_head; struct cli_ch_state cch; + ulong last_key_ms; }; /** From patchwork Mon Oct 6 23:21:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 537 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=1759792996; bh=ANJ4CU3BphfRx/UIx2mEwjCxOT/4jIPmn59QsV7TGmE=; 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=o7In8S4iBnUf9xtoRN16ludN44GyHRFDb8g83ImxoIXfshPpMmQKLL8eO+bBE+zxp 85NmAUkvi+IeySVDnl2hmW7yF5Ma3cRLDKJg+UcbTkR5haKy/vhZeLa/2W7hGCEz8t r3lM1f648Vmn+FmDm1zQicsQZvcRLb0N8RneCoqWFr1fs7Q89soSzR4kmcbDtolFIW CHd7fDqfisi68wZNtOh0sSzVCgCuckrjHQ7qwF18kiSmwYoe1ShUwVoRDevQ4AthdR vIDNoI65Jpwv0rBJDh4rXJ79SRs6yOXAaQHj0sDD4h3y9lQg+odiJYFEH+Hb2wZKkI mdEBCx68+5AJA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 75C0067DB4 for ; Mon, 6 Oct 2025 17:23:16 -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 gcHC795xInEU for ; Mon, 6 Oct 2025 17:23:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792994; bh=ANJ4CU3BphfRx/UIx2mEwjCxOT/4jIPmn59QsV7TGmE=; 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=Ax5mvq7Wh2Mcsw8ppJq4yJxRJjqZ0I1LPsla9EAmbthYIjD+aeUAaVSGd58XmzeJc qdxXfHmlqdILNcSTcHj4Ypl0qEYwm3Ar2bU78jkhUrdVkGcLmnSULDgRyevGyCg7xt SvFZFeqjSLH04VvSpYrLuYpXyk6VRxj8Pn18sXWGv7lymGpyG7zBeQFsPRzcA8QP0G /XkSnT20195BH4ykqTbigqDarI/6aY3Gie2gA0NIBngtyK6mBV+MGf+Ec+715k11da HHAJ+12f4a0faYOP7qkHTw8s0wT8AoC4fMj6TdL5y05FscCCELyCJ7j0YZVYQ/7Ueo Z//U86JhWa8Tg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D39B667FD5 for ; Mon, 6 Oct 2025 17:23:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792993; bh=OWTVWWyIWllE4wPPtcQRM64nUgc8Pb8ifRayX5/rds0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nKkp/iV+lGTHEQAMp+/n+S6+XxLQSF1Wi2JuspPxRpzT+6VR0s0SZmXa6zVszGwt0 z5pWWQp/XVTafLwAi9BrgwKfUYrgNrJUi+5IEuk/SOk5ZzGoN2V1Qcfc3NUiJXjrE9 70mj1+9S0BGXuwx0eHMt+OsoX6qXJJ0Cxwwsi1LpPWzJylt1FjCM6c/PeHc4Hm69u3 fAHRrJUJLKvNr/m3mF6SKPm7wL05/VAjRttnJ88PAtinpUlnjU9u0JdJSAAvNyEIfu 9/tBk+8mw5u/9jiMkiFykYRI7/jYHULCU1NusVOaOoARkGAlduAIn44DS8g7SCmJaI 5npsLxRDvN6BQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6856767F03; Mon, 6 Oct 2025 17:23:13 -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 uVdgwAjiTBAc; Mon, 6 Oct 2025 17:23:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792992; bh=DLyee2EVLkuNXxEqkSxYvFfjLhinq8YtreEZdgbSBCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BuBK6VJboCI8qTlGYeN8Ul+sMxgpt/zB5lSqtF9olIKZYu5SuEFbnfMRN6L3xAWin o1xMqonPvDJPs4uBz/hquA0JNqEzotqgp7RvTv6PPtWjLLe1nZvfxy+fLvrTg0TRsE Es3piwSt6+RhuGLA80x04HcrV0EZ33C1IfR4k3HvzrRqwTMJVY5fhuh7qUVFDDHWhO vHVTD+jdc07VV2E7QIN4bdvrlnNhzdWmwWD4Qd+yTSP0rhzzcoAgJ2PBpkiD7YEjQ9 jStwWJ3LkGHLn9LjXfCw2YOGY2znbzvWBcGrgsq5xX8AV+W2o9zz74s7Xc0tfq/20/ jWWF2kIo4685g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B08D567AF3; Mon, 6 Oct 2025 17:23:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:48 -0600 Message-ID: <20251006232236.2091941-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: J7BE7YIAPL6DA67IA5U2HTPB4RXC4GCS X-Message-ID-Hash: J7BE7YIAPL6DA67IA5U2HTPB4RXC4GCS 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 06/17] x86: efi: Avoid setting MTRRs in the app 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 The MTRRs have already been set by the previous phase so we should not set them when the U-Boot app starts. Add a condition to prevent it. Signed-off-by: Simon Glass --- arch/x86/lib/init_helpers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/lib/init_helpers.c b/arch/x86/lib/init_helpers.c index bd0efde00c1..4384c10f697 100644 --- a/arch/x86/lib/init_helpers.c +++ b/arch/x86/lib/init_helpers.c @@ -29,7 +29,8 @@ int init_cache_f_r(void) * the MTRRs here */ do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) && - !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER); + !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER) && + !IS_ENABLED(CONFIG_EFI_APP); if (do_mtrr) { ret = mtrr_commit(false); From patchwork Mon Oct 6 23:21:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 538 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=1759793000; bh=Zz5LIV4jR7F5+fGooP91J/hs+hm7fYj2SSh6L51TC4g=; 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=XJe/8XEryHI/Sg/Z2dHBeeQ9VaNsCaPTqDJA9JAvWHa17yb75D7v+cklQned/Hu30 Fvnu0u22o/smERg7/pc3+Ui61ryVF6FpXtJzgh6FjrHXidAa5W3z8DTw9fH5ARkUz2 LbVujxnSQAnBLxewbpjgQKMgALJnc+0JYnAxslPzB8fAJCkMEL67eFPWWVW2oUZ+A8 scd+mrykhrwJoJmxa22Qwxk+tlcquDcKMLpxSKyMVrkZvCTUH6LfnOZa02e3dCb6Zk U8QEEnSZhCn884hoMx/FRvPPEKpNB5SEw4okUJQ2SrVtDheOVlmP+R0cmJkOF1xIDP Jh2awGkGjDpdA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7BC5A67F03 for ; Mon, 6 Oct 2025 17:23:20 -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 wlH1gcvj7-KF for ; Mon, 6 Oct 2025 17:23:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793000; bh=Zz5LIV4jR7F5+fGooP91J/hs+hm7fYj2SSh6L51TC4g=; 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=XJe/8XEryHI/Sg/Z2dHBeeQ9VaNsCaPTqDJA9JAvWHa17yb75D7v+cklQned/Hu30 Fvnu0u22o/smERg7/pc3+Ui61ryVF6FpXtJzgh6FjrHXidAa5W3z8DTw9fH5ARkUz2 LbVujxnSQAnBLxewbpjgQKMgALJnc+0JYnAxslPzB8fAJCkMEL67eFPWWVW2oUZ+A8 scd+mrykhrwJoJmxa22Qwxk+tlcquDcKMLpxSKyMVrkZvCTUH6LfnOZa02e3dCb6Zk U8QEEnSZhCn884hoMx/FRvPPEKpNB5SEw4okUJQ2SrVtDheOVlmP+R0cmJkOF1xIDP Jh2awGkGjDpdA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A74C67F1D for ; Mon, 6 Oct 2025 17:23:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792998; bh=W2IWXKgYeduIOrq9oGtbT0xSDi+O40OHl+H+54pF4vI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e8RvLvCy2WD1XCTOBI3JWpF88VhxQ8sm3t/dP7/uuTu81l9bGnKvEIQ7BAXSP3DTS SqfGpWoC6PTlzuPcom0927I3aqZjg1TqNNbaV3Cw3uU9L8hRnHadSV1tdz/bvrV4oU /RdOOTNUwmdD4kkYXmXpfCuuWwhO3Ff1S9ksmT+HFVosXJNDk/NJGiRTKj7EPj3HQI x1jY3r3Nv29UTiY5ZMaxJNp+/HubESg6SVs8tHgIjK1k7udmgyDoOQ7iPJG1EEeLyQ QDXPCOfQhKqOBdv7qPIoZ107U5dqZ+HSHL3odYftXgthsHjCICh6WT2lhT0zD95pHo 8G2VNU62fHrbg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDF0367F03; Mon, 6 Oct 2025 17:23:18 -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 CYroyX9B0yU5; Mon, 6 Oct 2025 17:23:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792994; bh=8e/5scuqJT65+nYWBd5BvxwVwOWmZYjShfoEKtTIknA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=obpf937ptaUWN3ULbx6yl+OWLSA2KWRZS8Zt+9+uWzyXf9T/BN3oexsoY4+pVLzYd Grq/mnFwF5R/pyqHMOyVh5joprfHS7aSgYm9rFENbkQ1bBtARpFE45d+eKJ3d0SxhK bZaqDoTS4JSzZfQsGP0zI9rRFvWbK30pyPBOZv32S4c0Spg9jHZ19Grlo2fExjMDEk Syk93U+xx4VNGr45RzvrWywl9jRbOA5VuGJolbOfsH4v5urIPpEU9/6jUyQpvCtwEw UF8Cn5qp7v+ODFAkETd5lvXW1YABZ+xKBi/LGvT8KO0hOjTVQCxUaX1626k8p3Dj68 qPiIhsOMDmlqw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AE84467AF3; Mon, 6 Oct 2025 17:23:13 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:49 -0600 Message-ID: <20251006232236.2091941-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 53A7ANKTHABOXMNFJZQRC4M43LCS2XDL X-Message-ID-Hash: 53A7ANKTHABOXMNFJZQRC4M43LCS2XDL 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 07/17] x86: efi: Disable i8042 in the x86 app 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 We should not try to directly access the keyboard when running as an EFI app. Disable CONFIG_I8042_KEYB option to prevent that. Signed-off-by: Simon Glass --- drivers/input/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 6e19f6f7b3d..34eec07aac7 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -96,7 +96,7 @@ config TPL_CROS_EC_KEYB config I8042_KEYB bool "Enable Intel i8042 keyboard support" depends on DM_KEYBOARD - default X86 + default X86 && !EFI_APP help This adds a driver for the i8042 keyboard controller, allowing the keyboard to be used on devices which support this controller. The From patchwork Mon Oct 6 23:21:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 539 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=1759793002; bh=lfkC1J/ATxXUNvEudMggg7zKn/G27nUH7RXCfb/MEyc=; 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=c4R4CQQZpwp0Gx3pDVoiV62RZg2YgKgoFvyV+/J18g3xoMaxw6Id3jmKsMtlhICyD xmqX9+DUO+XaiyrZJU8c38SZUjGDClLZ3gAYDyTJIyCUACn8hQCA+Vu+K5OxEp7kup V4BnvKqpbmWPGUpUve0bz34LB7gG9xLfcPTCptO7t8xNJJQdryytU3zGsS9n6XFTkk GtXwa/F2rb/jbFEyg2YLeqxWD0h7PY6V5tsq9oRfFjdXPfiIvFyQf9viY9LKKKoilb HovnIbS+xy4PfbX+6HxzvhKgfWmn/bxMn0qhf79UiLuj5AOy0Zr8XX1SycXAKYMwoX Ccv9v79iINMXw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F2DA467FDE for ; Mon, 6 Oct 2025 17:23:22 -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 niDeLh_Qq-5H for ; Mon, 6 Oct 2025 17:23:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793002; bh=lfkC1J/ATxXUNvEudMggg7zKn/G27nUH7RXCfb/MEyc=; 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=c4R4CQQZpwp0Gx3pDVoiV62RZg2YgKgoFvyV+/J18g3xoMaxw6Id3jmKsMtlhICyD xmqX9+DUO+XaiyrZJU8c38SZUjGDClLZ3gAYDyTJIyCUACn8hQCA+Vu+K5OxEp7kup V4BnvKqpbmWPGUpUve0bz34LB7gG9xLfcPTCptO7t8xNJJQdryytU3zGsS9n6XFTkk GtXwa/F2rb/jbFEyg2YLeqxWD0h7PY6V5tsq9oRfFjdXPfiIvFyQf9viY9LKKKoilb HovnIbS+xy4PfbX+6HxzvhKgfWmn/bxMn0qhf79UiLuj5AOy0Zr8XX1SycXAKYMwoX Ccv9v79iINMXw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3529A67DB4 for ; Mon, 6 Oct 2025 17:23:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793000; bh=cf3tm/icY4oJ4coiaNN6NVRWOVyM0OWc6yFDfe+MqNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lNfwwQdRb2k+LY2xPRv3xDZM5tw4Ek5gVjZVwuYwqjN22dJlEKJw/F5OHi39SBlKu MZ3GQwsJZGY2si6hfPxb9YMfSzxYAppsL6onyYKBboMS4tpXjbkFmLOYP8Xf60xJXo BbBhT3VhBXbcfRLjrPX08J9JRqkHCDP/f0ZlxWSq3XBIgky91Qe2Ko3kT+CqX3TOOv CJLHiJlvBwW5QTBYwCiHMohQLDZorJPJIG0yRq6AshQdGgq6PhALDyMWhB3R1iUa85 XkLElMOHBO/jEhDQ+6TcMOwCY7o346SY4LxkZhn3Z9oom4T6l4V93W/g4DDO1RcJyX 12VKF7li0qgUQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26A6167AF3; Mon, 6 Oct 2025 17:23:20 -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 GpZ06tG7TnTP; Mon, 6 Oct 2025 17:23:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792998; bh=YpHUwS0ExShiI9v3AMgNjLGBspZfpU9Ew7OaLeSYS3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjnn02T1dAPzJOk4cSQxpX4pQ5wheaDiBbw5vvN5YebKhv/wUDUGc+xU0DTzHyJ6m 2ka/mo6uaV8+/OxXW5GyNspxE87sxmE7qQNNbZht6i94s8US1cLAAKXDOBaXdZ9g6+ eOh/3mE3ClxkgvSo2sEx/fNOVUQ+qXjcE4/sifsivakTCxekoMLvr/A+4gXUdYYouI 6XLWykxgyAPw7g2wvmGxasT0c9IW4fGu9o+H+jYgQ/EcpBkz6LonK+EnmNjL0HtBHm SFAf7cmxLtyTmGYf+B+El04sOMQ9wFR9LAdaUG1yRR20cPForm+FBGtKnm7nK9wneQ XSyHEaV7zdP4Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5D13C67DB4; Mon, 6 Oct 2025 17:23:18 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:50 -0600 Message-ID: <20251006232236.2091941-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6KT5EMEMAGJ5K7IB5ZUF2J33ZEQ7EG6W X-Message-ID-Hash: 6KT5EMEMAGJ5K7IB5ZUF2J33ZEQ7EG6W 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/17] efi: app: Support reading SMBIOS3 tables 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 Check for both GUIDs when looking for the SMBIOS tables. This allows both table versions to be detected when running from OVMF. Co-developed-by: Claude Signed-off-by: Simon Glass --- lib/efi_client/efi_app.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index c851173f1ae..00003c27ec5 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -164,7 +164,8 @@ static void free_memory(struct efi_priv *priv) static void scan_tables(struct efi_system_table *sys_table) { efi_guid_t acpi = EFI_ACPI_TABLE_GUID; - efi_guid_t smbios = SMBIOS3_TABLE_GUID; + efi_guid_t smbios = SMBIOS_TABLE_GUID; + efi_guid_t smbios3 = SMBIOS3_TABLE_GUID; uint i; for (i = 0; i < sys_table->nr_tables; i++) { @@ -172,8 +173,9 @@ static void scan_tables(struct efi_system_table *sys_table) if (!memcmp(&tab->guid, &acpi, sizeof(efi_guid_t))) gd_set_acpi_start(map_to_sysmem(tab->table)); - else if (!memcmp(&tab->guid, &smbios, sizeof(efi_guid_t))) - gd->arch.smbios_start = map_to_sysmem(tab->table); + else if (!memcmp(&tab->guid, &smbios, sizeof(efi_guid_t)) || + !memcmp(&tab->guid, &smbios3, sizeof(efi_guid_t))) + gd_set_smbios_start(map_to_sysmem(tab->table)); } } From patchwork Mon Oct 6 23:21:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 540 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=1759793007; bh=OVufrC9/UToOaNlCJvfKd31nWKSsOMszQQ7hXHaxivE=; 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=L9U6K92jXPhl2MB0cwH3rkbwSu+VLF7C6gDrV50M53HMizSCi0V1FohKhd6BCias6 rI6IQQm0S2xY9Oz9gXLphBtya0ohFHN8eExtnwEGYgMWhqLyF4RZFWK0s9onHzRC8O yol+YMpUdNJ9m03AQ4Tm8HE4vVA/bcQKPN9cM3CDdH6LjPPU4bGyXeGCyeVhsTIxZU DvReV4JuktivbxZOxCrRQXcdI+Uln0FmIbMD4R975T/yB9MjUWAeC2gfN/B9lC8jKS Y8hVY7nIWSgvZ9yPL9TlbD4hIjBX3SlOVF7qLBHBd9Hi4WnlmNUw7hWnr6WaG0OKe2 ZeIWcxVnptw1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C49CD67FC6 for ; Mon, 6 Oct 2025 17:23:27 -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 LGtR-5RBC0UX for ; Mon, 6 Oct 2025 17:23:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793007; bh=OVufrC9/UToOaNlCJvfKd31nWKSsOMszQQ7hXHaxivE=; 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=L9U6K92jXPhl2MB0cwH3rkbwSu+VLF7C6gDrV50M53HMizSCi0V1FohKhd6BCias6 rI6IQQm0S2xY9Oz9gXLphBtya0ohFHN8eExtnwEGYgMWhqLyF4RZFWK0s9onHzRC8O yol+YMpUdNJ9m03AQ4Tm8HE4vVA/bcQKPN9cM3CDdH6LjPPU4bGyXeGCyeVhsTIxZU DvReV4JuktivbxZOxCrRQXcdI+Uln0FmIbMD4R975T/yB9MjUWAeC2gfN/B9lC8jKS Y8hVY7nIWSgvZ9yPL9TlbD4hIjBX3SlOVF7qLBHBd9Hi4WnlmNUw7hWnr6WaG0OKe2 ZeIWcxVnptw1g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B32C667F5A for ; Mon, 6 Oct 2025 17:23:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793005; bh=rFPSV0HicL1aV2kjOT57GcPk5WsZ5VwRcElJ6XBRWhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FQUHx3veJUcrB7bCzGfy0g/CtWjxAvLI2HdMIbIVoTc0DiCGYFM6n2OnC/pjF6C+E PK5kdTc/2jEe3WsAL2EdPihXAEX20Mb9Z6oxbwfNhj0cjdVQB8FGr7mudutBpjHFtJ NjRmzK94iULd3Rtm3yK92Wm70grlYRGPBc9ite4rEd8Bdman3ouQuhd1ncZR37kAob y5ozN+JjuDsN19wOLfOztAjlth+oCOhFCuGfrABUoqpWhw9MRM7/eDjSWZhUORyIKh dpbRqdRvsvkbafqpCPQVALET8LvJVSR1Rybicw+B93e0baIr5u4wqwIyNfzxJ26Y5f Kler/YnQ0mRmw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 62A3267DB4; Mon, 6 Oct 2025 17:23:25 -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 jTMvNlZeVPzA; Mon, 6 Oct 2025 17:23:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793001; bh=kM9qe7jnLsSqj+hXsKu1RrOJn6z9xXzKmWyZClloKmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n54uyYCcbcMa1MjkZHHfS64D4zMADdKPTVk+y6ExYShh3AatwOXvb4ObV7NB1ZEpf +7NcgvtR4G/IFtdiTV7kKQoHPt8sVTEYOEdMhgZmJnaJg0dqzzuA9KaMVM1e9KO3qX O1lDcK5iUs488Amv2j5lP5E0UmU9ERZYuFNW78X4/rYidiBeTriWRgmoCe2sSAeKrH bXDxAKCOJ9O588mGgDw46iFnnnt6GLkzAIa96SMi3bAnEv+d0jLEnoNUxE015WbDnc oRIOpIoYpFbSMbf2+8K1Ij5T74Q9GUOKyFinDlzmipA9NQdvtd6JSfgKMwbDNbLgHc ljc+SyJpEkqMw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6C7F767F3F; Mon, 6 Oct 2025 17:23:20 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:51 -0600 Message-ID: <20251006232236.2091941-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WUA2SKV4REZRBLA7W3E37TKEUY7NHAHM X-Message-ID-Hash: WUA2SKV4REZRBLA7W3E37TKEUY7NHAHM 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/17] efi: app: Detect running under QEMU 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 When the app is running under QEMU we may wish to do some things differently. Add a flag for this and use the SMBIOS tables to detect it. Co-developed-by: Claude Signed-off-by: Simon Glass --- include/asm-generic/global_data.h | 6 ++++++ lib/efi_client/efi_app.c | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 8b59df66ec5..cff9066de53 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -764,6 +764,12 @@ enum gd_flags { * For now, this just avoids console output on startup */ GD_FLG_ULIB = 0x10000000, + /** + * @GD_FLG_EMUL: Running in an emulator (e.g. QEMU) + * + * Detected from SMBIOS or other platform information + */ + GD_FLG_EMUL = 0x20000000, }; #if CONFIG_IS_ENABLED(ULIB) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 00003c27ec5..1d5a88b4827 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -179,6 +180,27 @@ static void scan_tables(struct efi_system_table *sys_table) } } +static bool detect_emulator(void) +{ + struct smbios_info info; + struct smbios_type1 *t1; + const char *manufacturer; + + /* Check if running in QEMU by looking at SMBIOS manufacturer */ + if (!smbios_locate(gd_smbios_start(), &info)) { + t1 = (void *)smbios_get_header(&info, + SMBIOS_SYSTEM_INFORMATION); + if (t1) { + manufacturer = smbios_get_string(&t1->hdr, + t1->manufacturer); + if (manufacturer && !strcmp(manufacturer, "QEMU")) + return true; + } + } + + return false; +} + static void find_protocols(struct efi_priv *priv) { efi_guid_t guid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; @@ -415,7 +437,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, printf("starting\n"); - board_init_f(GD_FLG_SKIP_RELOC); + board_init_f(GD_FLG_SKIP_RELOC | + (detect_emulator() ? GD_FLG_EMUL : 0)); gd = gd->new_gd; board_init_r(NULL, 0); free_memory(priv); From patchwork Mon Oct 6 23:21:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 541 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=1759793015; bh=VtKObF0kiixMSOP4q/bkSwW/Sqw+H9U0fHz+COFU01I=; 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=vkp4n3L3IMws6TPORj+lGnCVjxJBiQoeRO5WPh2UjISrUabV/UyZ9R3jTqQzIiWXh hCwnUG/7SSP7Y6k9DOx4PqBjkHz7AOcu+IuRtTyuXPyQ31b47wZDgnyd6N/40fX6mk LZeBJdmKhUjWeI0ctsKFxzP6jWadPPR3L+q61852yw8IRAgqcsWI0emuLu0j6oMXNx ToDdKjuYZdPYLFZjxkCa6y+fjv1SpstLVM9xnCUA1I11zQZxRjINbTrW8QeZqK9fy5 iBzTvVAWA6lnRszgegnypE0Q3zWayu7Ln+bLLDmlv0My/CAxM1gTRfytzP3in4NDij TfBRRKoSuDRxg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2C13F67FC6 for ; Mon, 6 Oct 2025 17:23:35 -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 v10kHJ8sDMYY for ; Mon, 6 Oct 2025 17:23:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793015; bh=VtKObF0kiixMSOP4q/bkSwW/Sqw+H9U0fHz+COFU01I=; 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=vkp4n3L3IMws6TPORj+lGnCVjxJBiQoeRO5WPh2UjISrUabV/UyZ9R3jTqQzIiWXh hCwnUG/7SSP7Y6k9DOx4PqBjkHz7AOcu+IuRtTyuXPyQ31b47wZDgnyd6N/40fX6mk LZeBJdmKhUjWeI0ctsKFxzP6jWadPPR3L+q61852yw8IRAgqcsWI0emuLu0j6oMXNx ToDdKjuYZdPYLFZjxkCa6y+fjv1SpstLVM9xnCUA1I11zQZxRjINbTrW8QeZqK9fy5 iBzTvVAWA6lnRszgegnypE0Q3zWayu7Ln+bLLDmlv0My/CAxM1gTRfytzP3in4NDij TfBRRKoSuDRxg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 178D667F5A for ; Mon, 6 Oct 2025 17:23:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793012; bh=iYUAaFlPwrXp/2vWapmZLUA3dmKIqFJG5OYRIp4Lits=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j0F1vpSqB+SPsIRLC6eSaiWzPehtyD6mhZESqwleVK8q5MY6hObLkXWir0q+1a6Py rWwMVSgzqXlDJAoTu9OqYKna1Jck1VGNw3Il7YVkLZ03qSKG0mtuSc2v+SLPLJXrwJ L5HfuvYffgxVuoW90ZxLYu/pZEq0g3/wG+w/ihLH/YwokLdw2zTUuTqbuwcYFC6V3Q wtxVU+ijR9KyCHRLBNwXZImWYiUuoa9RIT+K5WZJ7uL61oIvUpmcxbgzKhSfz0Qu65 s5JiD2KQLGLJiB92VlcoTe2B07NdyZn6GRR+Wluibb3yBVwzNV6Gh7kQ4KvTAqa5uQ 3osFsd+ZNqKhw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A97D167F58; Mon, 6 Oct 2025 17:23:32 -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 kxA1djFfWLHk; Mon, 6 Oct 2025 17:23:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793007; bh=atIHsOMy5iKoaN/k3OvhNCuERYHffTW470pmAkWAbtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WXKLMtJ66p6yYZOkrZR5m7A9NzhKLle8zRBjITII5Y/esOUjwf9az8vvZTck+bLuN zP+AMXC5zo8AuoLzGtrWd3Gks68kazMDlUkU98Oy9P0GpdNtj3gCi/6ZjyGdNDm7li a9EJwo6HGoghqEq6zX5XlI2nwavGh4ZabZxKCvWZb5Cd94aRfl1sNtgmOSWeSqvZMO L4gI79wRFv0i3SXe45qkvp1lU1ZQG5ikUHVfsFFs7WwzC8mPDJ4EfOhCJ4wVJhlzDc V7dHytYEip+gr0zXL36G4EmnFE6pOjfSALyqeiZ95IBeE1O0a5fkBuQd1aPGus7aLu vfJOOx65QRB9Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6108567F3F; Mon, 6 Oct 2025 17:23:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:53 -0600 Message-ID: <20251006232236.2091941-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FYZR2243I7UAYNHL35V5EUKORDXQZMZA X-Message-ID-Hash: FYZR2243I7UAYNHL35V5EUKORDXQZMZA 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 11/17] efi: video: Add some more debugging for the modes 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 This driver can operate in various modes, e.g. with VIDEO_COPY and with different colour depths or in blit mode. Add some debugging to help debug problems on particular boards. Fix an errant blank line while we are here. Signed-off-by: Simon Glass --- drivers/video/efi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/video/efi.c b/drivers/video/efi.c index b5e472395e9..bfa367cc7ea 100644 --- a/drivers/video/efi.c +++ b/drivers/video/efi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -60,6 +61,10 @@ static int efi_video_sync(struct udevice *dev, uint flags) return -EIO; } } + /* + * When use_blit is false and CONFIG_VIDEO_COPY is enabled, + * video_manual_sync() handles copying to copy_fb + */ return 0; } @@ -252,7 +257,9 @@ static int efi_video_probe(struct udevice *dev) goto err; printf("Video: %dx%dx%d @ %lx\n", uc_priv->xsize, uc_priv->ysize, - vesa->bits_per_pixel, (ulong)priv->fb); + vesa->bits_per_pixel, (ulong)uc_priv->fb); + log_debug("use_blit %d, copy_base %lx, copy_fb %p\n", priv->use_blit, + (ulong)plat->copy_base, uc_priv->copy_fb); return 0; @@ -267,7 +274,6 @@ static int efi_video_bind(struct udevice *dev) { struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct efi_video_priv tmp_priv; - struct vesa_mode_info vesa; int ret; @@ -282,10 +288,13 @@ static int efi_video_bind(struct udevice *dev) /* this is not reached if the EFI call failed */ plat->copy_size = vesa.bytes_per_scanline * vesa.y_resolution; + log_debug("copy size %lx\n", plat->copy_size); } } - if (tmp_priv.use_blit) + if (tmp_priv.use_blit) { plat->size = vesa.bytes_per_scanline * vesa.y_resolution; + log_debug("plat size %x\n", plat->size); + } return 0; } From patchwork Mon Oct 6 23:21:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 542 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=1759793017; bh=1Yxea/gbF6Xer5RrAMGeTXf5CgLdBKE4c9VlbUFxe10=; 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=eKfwoUKwgRbDtS1sVOco3vilbwCKpbNTPqzHlecYrjRKIYpcXlJwrnVH0dXLkbQRO qKlfA+LaYU61vKMpsJv9bZ9VgLsMSjLFF38TTaarcLLOEmNq31gWK+q7iFsRuqrECP 1BescUdA+H6Y4UI678ZFmkr+Vx5rg1HXcjOBMwfd6YpInwHVfLczme3dQBddtjVs0a r97Tbzb/nxU1kC71tO4U7uvqQqzKqPS6wOWtnvFWIDPBye6XCLzVWwDy/doPbBcL4d g8fODYUpm9SQX785QuBlI03vcw6grdr45qLZrCTuCUKZlsT/eKdtCW1PF/PHFjTggs m6FxpCE7OkjmQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0DED67FB7 for ; Mon, 6 Oct 2025 17:23:37 -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 JC5vTKxQIyCb for ; Mon, 6 Oct 2025 17:23:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793015; bh=1Yxea/gbF6Xer5RrAMGeTXf5CgLdBKE4c9VlbUFxe10=; 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=s1VmsqI1Pgx4SaZE9yDJVwfhOeZT6TUpCY+fQprGqZaaADgVdwTAYUaZZ7ZPwFxLO TMgzyYfD/qmzB1dI4k8ym0dhQML7np5940saIYuTkLtZs0VN5ZtMD+z/YF7UTJOAb1 nObQLLruHCnXoEsO8jWjZj7T4xZuEFQOx8K3XBRp4ifQjN9ivsWD95TqxRk6URDz5p zIGBjbrYSykMjvGulEz6eRBj9u45XdpU/NuUaFnJW5O/e+xQVIuCrjKomKlWd9CK1L DQuoI9ef1J6XVOAxpSsbYKCqrwCTAonJrXaq7C+i3gWXqTwf6iHvO5BTlQiE+qwI80 sOoOYklQ5LJRg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B30CD67FE0 for ; Mon, 6 Oct 2025 17:23:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793013; bh=FcKQgZ1siJZwkz8PcgTYC6f7H2Df1iDq5J3SamBHMFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OR77fr+8UbgbJPP/IbzmNV6cvNV7/qiGJMiCsIMRbSemhJ06msnxu0x0nN2PGeHRO 9W4WkWOlpPVEJUQThyGEkm8b4zy6ytsH6RXAbz2B4UemN5stNxA4CA7Ibw8jVz+gHG w+X3iY5J/KLByeh3QLbJOnrzW5qH3fpeiGp8C4eU2gTFUC/2NREhv96kRfmIFOSyXG epsQ3ZaYJNVQT1CKbXtCDZG+0M+U5m737BCl2dw3VzCRVA10cJJ96IMESbIOgUqe8S gmx6W5aBZvnbSe6qDNyBf052xynWxmQbrwIMe76xVLhoUmqkCdv+IZda6blStXZfRi MBQgSx//5AHVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B628067EE4; Mon, 6 Oct 2025 17:23:33 -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 qbhcg4Y8s4J2; Mon, 6 Oct 2025 17:23:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793012; bh=crbD2YB8i9D+OT5fQqVHjyVtdtHhyvZaM+fdcIF74B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AICgPE4GNnMAjevllGxwFd4cwe4WwQNRPE2Sjd3lwybmSdPQ7lf6neuZPpqfZjBcq liCZkKZpQB2s9SYQe9Y/nrbz3GVbhWzK/ZnJPQ/841bfmP2FZ3WoLtipiglbiuzjTk j5HjFSh+PHeuUffBlGJeyRd/9M1hvdYJeAhZQY6/fa36CglnXmlxjZa+cNOaLet/wL xn/55V1Kuy7YHCYJPcDyxP3sHzcikikizaHLper2UTVkpTYhFkQsOCdm7BJ+zBmSzM ZWXtcVPKR5CxlTpcpwWruFVdtUTeGxUGKh0b4GXR22X2FstBZDGfbG+6kjygdiEdzv LRIPPbdKu6PJA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F08A367DB4; Mon, 6 Oct 2025 17:23:31 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:54 -0600 Message-ID: <20251006232236.2091941-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: V64Z3GL5W7P7LCULAG2ZLZ6TUKDYQD32 X-Message-ID-Hash: V64Z3GL5W7P7LCULAG2ZLZ6TUKDYQD32 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 12/17] efi: mouse: Move simple-pointer code into a function 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 In preparation for supporting an absolute pointer, move the setup of the simple pointer into its own function. Rename 'pointer' to simple and last_state to simple_last. Take this opportunity to add comments for struct efi_mouse_priv since it will be less obvious once the new support is added. Clean up some unnecessary cruft in the remove() path. Signed-off-by: Simon Glass --- drivers/input/efi_mouse.c | 103 +++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 41 deletions(-) diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c index 84347951f62..974c7e9fe1c 100644 --- a/drivers/input/efi_mouse.c +++ b/drivers/input/efi_mouse.c @@ -14,9 +14,24 @@ #include #include +/* Maximum coordinate value for mouse position */ +#define MOUSE_MAX_COORD 0xffff + +/** + * struct efi_mouse_priv - Private data for EFI mouse driver + * + * @simple: Simple pointer protocol (relative movement) + * @simple_last: Last simple pointer state + * @has_last_state: True if we have a previous state for delta calculation + * @x: Current X position + * @y: Current Y position + * @buttons: Current button state + * @old_buttons: Previous button state for detecting changes + * @timer_event: EFI timer event for periodic polling + */ struct efi_mouse_priv { - struct efi_simple_pointer_protocol *pointer; - struct efi_simple_pointer_state last_state; + struct efi_simple_pointer_protocol *simple; + struct efi_simple_pointer_state simple_last; bool has_last_state; int x, y; int buttons; @@ -30,7 +45,7 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) struct efi_simple_pointer_state state; efi_status_t ret; int new_buttons; - if (!priv->pointer) + if (!priv->simple) return -ENODEV; /* Use timer-based polling approach like EFI keyboard */ @@ -41,8 +56,8 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) efi_uintn_t num_events = 1; events[0] = priv->timer_event; - if (priv->pointer->wait_for_input) { - events[1] = priv->pointer->wait_for_input; + if (priv->simple->wait_for_input) { + events[1] = priv->simple->wait_for_input; num_events = 2; } @@ -52,7 +67,7 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) } /* Get current pointer state */ - ret = priv->pointer->get_state(priv->pointer, &state); + ret = priv->simple->get_state(priv->simple, &state); if (ret != EFI_SUCCESS) { if (ret == EFI_NOT_READY) return -EAGAIN; @@ -117,63 +132,74 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) return -EAGAIN; } -static int efi_mouse_probe(struct udevice *dev) +/** + * setup_simple_pointer() - Set up simple pointer protocol + * + * @priv: Private data + * Return: 0 if OK, -ve on error + */ +static int setup_simple_pointer(struct efi_mouse_priv *priv) { - struct efi_mouse_priv *priv = dev_get_priv(dev); struct efi_boot_services *boot = efi_get_boot(); - efi_status_t ret; efi_handle_t *handles; efi_uintn_t num_handles; + efi_status_t ret; - log_debug("EFI mouse probe\n"); - - /* Find Simple Pointer Protocol handles */ + log_debug("EFI simple-pointer mouse probe\n"); ret = boot->locate_handle_buffer(BY_PROTOCOL, &efi_guid_simple_pointer, NULL, &num_handles, &handles); - if (ret != EFI_SUCCESS) { - printf("EFI mouse: No EFI pointer devices found (ret=0x%lx)\n", ret); + if (ret) return -ENODEV; - } - log_debug("Found %zu EFI pointer device(s)\n", num_handles); + log_debug("Found %zu simple pointer device(s)\n", num_handles); - /* Use the first pointer device */ + /* Use the first simple pointer device */ ret = boot->open_protocol(handles[0], &efi_guid_simple_pointer, - (void **)&priv->pointer, efi_get_parent_image(), - NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (ret != EFI_SUCCESS) { - printf("EFI mouse: Failed to open EFI pointer protocol (ret=0x%lx)\n", ret); + (void **)&priv->simple, + efi_get_parent_image(), NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret) { + log_debug("Cannot open simple pointer protocol (ret=0x%lx)\n", + ret); efi_free_pool(handles); - return -ENODEV; + return -EIO; } + log_debug("Using simple pointer protocol\n"); efi_free_pool(handles); + return 0; +} + +static int efi_mouse_probe(struct udevice *dev) +{ + struct efi_mouse_priv *priv = dev_get_priv(dev); + struct efi_boot_services *boot = efi_get_boot(); + efi_status_t ret; + + if (setup_simple_pointer(priv)) + return -ENODEV; + /* Reset the pointer device */ - ret = priv->pointer->reset(priv->pointer, false); + ret = priv->simple->reset(priv->simple, false); if (ret != EFI_SUCCESS) { log_warning("Failed to reset EFI pointer device\n"); /* Continue anyway - some devices might not support reset */ } - priv->x = 0; - priv->y = 0; - priv->buttons = 0; - priv->old_buttons = 0; - priv->has_last_state = false; - /* Create a timer event for periodic checking */ ret = boot->create_event(EVT_TIMER, TPL_NOTIFY, NULL, NULL, &priv->timer_event); - if (ret != EFI_SUCCESS) { - printf("EFI mouse: Failed to create timer event (ret=0x%lx)\n", ret); + if (ret) { + log_debug("Failed to create timer event (ret=0x%lx)\n", ret); /* Continue without timer - fallback to direct polling */ priv->timer_event = NULL; } else { /* Set timer to trigger every 10ms (100000 x 100ns = 10ms) */ - ret = boot->set_timer(priv->timer_event, EFI_TIMER_PERIODIC, 10000); - if (ret != EFI_SUCCESS) { - printf("EFI mouse: Failed to set timer (ret=0x%lx)\n", ret); + ret = boot->set_timer(priv->timer_event, EFI_TIMER_PERIODIC, + 10000); + if (ret) { + log_debug("Failed to set timer (ret=0x%lx)\n", ret); boot->close_event(priv->timer_event); priv->timer_event = NULL; } @@ -188,15 +214,10 @@ static int efi_mouse_remove(struct udevice *dev) struct efi_mouse_priv *priv = dev_get_priv(dev); struct efi_boot_services *boot = efi_get_boot(); - if (priv->timer_event) { + if (priv->timer_event) boot->close_event(priv->timer_event); - priv->timer_event = NULL; - } - if (priv->pointer) { - /* Protocol will be automatically closed when the image is unloaded */ - priv->pointer = NULL; - } + /* Protocol will be automatically closed when the image is unloaded */ return 0; } From patchwork Mon Oct 6 23:21:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 543 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=1759793020; bh=WzKC1OyxCIgx+K7BsGQj7DO6fcHGu4XfXz6JijhIHP4=; 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=PIbld0EhN+Y59Y5EoZmxeBgbULr9v8h1O9cL8DMCOQ5uz1uxCJiIk/s0Ujv8iwvMR q2MPRU94Mb7qmde1yLGh8bgGb8zXb1Qg2DedS5YGHtFnWnuYUNxgnTNKZ93Dfbogyj /mAFiRT4hdJwOj4uFm+vxEk7Lsxb+RqpluD8Kac7CQ1yCZrBnR0M0JpUEoWKwfVdMN OdHxCwTBLDtcIAR1+A8qXfc157K8tfYlW5beGNJbMfdFl/OFatA0WhozRNn1xO6vgS gUOH1QgVe8gP9ptnH6bl7ZB7V0GaM0NfKK55N7ZBcMJFt1fVvMvD5YeVf+N4xSN4vu K+7Z/Zi89bq/A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A146C67F5A for ; Mon, 6 Oct 2025 17:23:40 -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 gBbzR9aAiECp for ; Mon, 6 Oct 2025 17:23:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793020; bh=WzKC1OyxCIgx+K7BsGQj7DO6fcHGu4XfXz6JijhIHP4=; 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=PIbld0EhN+Y59Y5EoZmxeBgbULr9v8h1O9cL8DMCOQ5uz1uxCJiIk/s0Ujv8iwvMR q2MPRU94Mb7qmde1yLGh8bgGb8zXb1Qg2DedS5YGHtFnWnuYUNxgnTNKZ93Dfbogyj /mAFiRT4hdJwOj4uFm+vxEk7Lsxb+RqpluD8Kac7CQ1yCZrBnR0M0JpUEoWKwfVdMN OdHxCwTBLDtcIAR1+A8qXfc157K8tfYlW5beGNJbMfdFl/OFatA0WhozRNn1xO6vgS gUOH1QgVe8gP9ptnH6bl7ZB7V0GaM0NfKK55N7ZBcMJFt1fVvMvD5YeVf+N4xSN4vu K+7Z/Zi89bq/A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 918BD67EE4 for ; Mon, 6 Oct 2025 17:23:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793019; bh=PoeJHgx2awLLeGclEJ3V6KiDsG2u7+ELAJ7QSmdZjyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZdI19xpPqu6+8tfdDu+UQT7TP1snyoOYr6w1fC+pTN6bHcmC4shtFFNBT7yKNpzNt bGYk22KfpoWR9r3kBlHpM66htPOn2JrfULtkDtj7jBt6ZUrC0kc+Gk7HHeFv5835L4 FR7DTVQpMeQEDD14MSOwVwkhkHVX0xBlnbbx/pGxoOCdlyxQTt1PMTNTYo49SR6oe/ WNM6shiNYAIs+q2uyGMT/uibz0dmG61ksL2InC4Ch9TJ8i/YclEtDWSPngKtgfv4Sp QykG2ubx8lSNeYVLZd2qSCPmw8Ye0+XvcxafOw1OX2G2ODtKdp0cqXlVVZzx0texxQ gaR3KTxdDQdOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EF89467E07; Mon, 6 Oct 2025 17:23:39 -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 VD1UDRGBVYl7; Mon, 6 Oct 2025 17:23:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793014; bh=C6iwmF2hEIS/4EBYRsWalpM3cwMO5MP4dsq5XGYf+Fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QKQ/9smKjP5Z70oqL6hH80MQG5AwoCc78xWDtiWiePx+TH+5rXoMDy8rqH+6feWLx JsvmOVNk7/0ZoU+7wTmZBmSqYCMlL5cqriem2Zz3FfyXQoFmoLPrgJ44JbK0iIIv7e VMNzJx4CZCTGL2ZbNVgJ8Cxli1f2dTAqvVN/hcPbuac1ZLrcgHwCbBoe6PeqN5U9s5 eXYmst1wy49bRI2LzVtl8WtWpEfdpzvVGKmXZYQmRkYJEKLPUTe1do6CvcDiTM5aOL Ypi7PIsAsam8EQd4eCgOfgnXqYeGwFFshsRhS/EMadmNLXxnehkXuXvoXTxYKjxmZ9 UAyzxZE0xvD6g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0661D67DB4; Mon, 6 Oct 2025 17:23:33 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:55 -0600 Message-ID: <20251006232236.2091941-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CZRJCVG6TQUER6MIQRUAH22VFHNHC5VG X-Message-ID-Hash: CZRJCVG6TQUER6MIQRUAH22VFHNHC5VG 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 13/17] efi: mouse: Move button handling into a function 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 Split out the code that handles button presses into its own function, since efi_mouse_get_event() is already quite long. Signed-off-by: Simon Glass --- drivers/input/efi_mouse.c | 62 ++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c index 974c7e9fe1c..3e9ec370a50 100644 --- a/drivers/input/efi_mouse.c +++ b/drivers/input/efi_mouse.c @@ -39,6 +39,44 @@ struct efi_mouse_priv { struct efi_event *timer_event; }; +/** + * get_button_event() - Check for button-change events + * + * @priv: Private data + * @new_buttons: New button state + * @event: Event to populate if button changed + * Return: 0 if button event found, -EAGAIN if no button change + */ +static int get_button_event(struct efi_mouse_priv *priv, int new_buttons, + struct mouse_event *event) +{ + struct mouse_button *but = &event->button; + int diff = new_buttons ^ priv->old_buttons; + int i; + + if (new_buttons == priv->old_buttons) + return -EAGAIN; + + event->type = MOUSE_EV_BUTTON; + /* Find first changed button */ + for (i = 0; i < 2; i++) { + u8 mask = 1 << i; + + if (!(diff & mask)) + continue; + + but->button = i; + but->press_state = (new_buttons & mask) ? 1 : 0; + but->clicks = 1; + but->x = priv->x; + but->y = priv->y; + priv->old_buttons ^= mask; + return 0; + } + + return -EAGAIN; +} + static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) { struct efi_mouse_priv *priv = dev_get_priv(dev); @@ -81,27 +119,9 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) new_buttons |= 1 << 0; if (state.right_button) new_buttons |= 1 << 1; - - if (new_buttons != priv->old_buttons) { - struct mouse_button *but = &event->button; - u8 diff = new_buttons ^ priv->old_buttons; - int i; - - event->type = MOUSE_EV_BUTTON; - /* Find first changed button */ - for (i = 0; i < 2; i++) { - u8 mask = 1 << i; - if (diff & mask) { - but->button = i; - but->press_state = (new_buttons & mask) ? 1 : 0; - but->clicks = 1; - but->x = priv->x; - but->y = priv->y; - priv->old_buttons ^= mask; - return 0; - } - } - } + ret = get_button_event(priv, new_buttons, event); + if (!ret) + return 0; /* Check for movement */ if (state.relative_movement_x || state.relative_movement_y) { From patchwork Mon Oct 6 23:21:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 544 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=1759793023; bh=QkH9JCqXHvcNMo++hYfXOD9ceK+OSRFxlDp9kaKDyzo=; 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=lcpUpOL7xDVnJfdafFUxk0qPGLY0z9TIr1GvqpXh7NdRv1Nll6uX8VeqUBLp2sgc7 Jxn0BxgL1DJ/aAu+i6W8UhBbfumVGSerA3nNvANK1Mat3wvyEx/ajTig1k0DtaZ98r 089Cc5/l57QIRfrdQi8o1a1hrej51gyYurzRpfVnU4mCSykLWF5roCGiH+zHIl7VZc OHOoR45hvkdH9PCKkskOI2Wy/u0zPyPpETAlpx6m46aP+yb1zlfp+ShwRIW43i8qtu YWEDvKKBljJ3XiT124uEN3oXmpGHeieFBM1RljcopN3HgqED1irUr1HAOlWGsxu4+d bo+fdqtCxG2Zw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 27D8867FE2 for ; Mon, 6 Oct 2025 17:23:43 -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 YvlBvGCaL7E2 for ; Mon, 6 Oct 2025 17:23:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793022; bh=QkH9JCqXHvcNMo++hYfXOD9ceK+OSRFxlDp9kaKDyzo=; 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=GPPkfjSh9MO429u1R7G/PAKgJR1e4wOYWRKIKjnSBd2e0giN6CxDcxkPBkJYOWA3u DcvOIgVIYdAKrjZGElb+pBG7SbmRWI7k1HaayUeMeX3rCSiiX3HmszdFaGuTfi8YiU xKH68XK22XuhBXxmS+Qu5K3FuiCElFEk5MSnJ7pBHdIddg/LXuaDue7rC4rFlLUMI8 2PzaRnMY2CLYC5TZTP0YtwBmM4YSbJs/sqQSX0uTFEX8VxMDzLgtDIUg2UCNh9mPD4 friVHIY1YrVuniovkPbY50blHgoxgCAraNDdXavkZm8abAGLUtkFRMm4FKkNAoY3y7 Tlt4w42wcQIGQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 28B2B67DB4 for ; Mon, 6 Oct 2025 17:23:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793020; bh=fKvY9IzEr90kgOn45mKUTppXdXFScn3ThgOPJu5RpP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dJvDaBRqytzV5S16Yhe9LWybu9LoZ6QV4ga1ffAUQf2J/WgoDw9LfUikvKG6Z1BWN KBlLn5LK50VwDFFG5+I3FwFRESJGadaBK64foNZWG0mpQXmIG3yj+l0aU+cFpID4fH HQRJQTwTMLe+dCSBJ1wLdV1ERP2g7YylZltiuEAYBLntHVIRholvy183mO5QkOCrqm qU+HjDKPZ/t00MkiZFlJqzpHq1OZjzAgj5KpGX5F0sxd0hyj9NiY0O/PG5I92WfTxg 020RcYqAvbxeyP3TEvolK9opRUrsIKC6+5/KagDzD+zXp7ntAraW8HX76kI5lj+hQr XRzUzJ8faPpPA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 64BB667DB4; Mon, 6 Oct 2025 17:23:40 -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 PwK7bP35xOVC; Mon, 6 Oct 2025 17:23:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793018; bh=rh0RYEtV5lJp3GcjrV/wx93Rcz4gZbU0vqAfS9n0ZA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QTSu3iUExv02WqF6qgIbGkBNJUIIWm1osvfyR+He5+ezQoz1lafVUyc8RBwb9rtmA KyxIqsjnNpT8VYMANRM+vO9A7m+oPePIK9QNZlLGWoij/FHEEpPL4KoN5aMhwhgG4c nrHeGk55I0AUpnusYoaoP93B7x5tqyxrX7sPw/p18JwwzYRG1BdeKlsKZsNzcTawcp AJVHQEWsaX4BNpVSvwAVU6Vyrz/OYSYMd/mCwY1bi3ibAviSoYjIOVLP7NJNYvnmQi 6yCyfTYiCxxg5mWpv+3KGTb4AXuFXMbv37p+3W4Cq95q63SVojPsrzwVs+22jTYC5x j3Tjuo1NYZBMg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 98E3E67AF3; Mon, 6 Oct 2025 17:23:38 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:56 -0600 Message-ID: <20251006232236.2091941-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: R2DFTIELJIFH4UNYVELH3GHIDN46BWO5 X-Message-ID-Hash: R2DFTIELJIFH4UNYVELH3GHIDN46BWO5 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 14/17] efi: mouse: Split out event handling further 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 Create a function which handles getting the pointer position using the simple-pointer protocol. Call this from efi_mouse_get_event() Return immediately if there is a button event. Otherwise return a motion event if motion is detected. Signed-off-by: Simon Glass --- drivers/input/efi_mouse.c | 162 +++++++++++++++++++++++++------------- 1 file changed, 106 insertions(+), 56 deletions(-) diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c index 3e9ec370a50..81c3fcb862e 100644 --- a/drivers/input/efi_mouse.c +++ b/drivers/input/efi_mouse.c @@ -39,6 +39,93 @@ struct efi_mouse_priv { struct efi_event *timer_event; }; +/** + * get_rel_pointer() - Handle relative pointer input + * + * @priv: Private data + * @rel_x: Returns relative X movement + * @rel_y: Returns relative Y movement + * @new_buttons: Returns button state + * Return: 0 if OK, -EAGAIN if no event, -ve on error + */ +static int get_rel_pointer(struct efi_mouse_priv *priv, int *rel_x, + int *rel_y, int *new_buttons) +{ + struct efi_simple_pointer_state state; + efi_status_t ret; + + /* Use timer-based polling approach like EFI keyboard */ + if (priv->timer_event) { + struct efi_boot_services *boot = efi_get_boot(); + efi_uintn_t index; + struct efi_event *events[2]; + efi_uintn_t num_events = 1; + + events[0] = priv->timer_event; + if (priv->simple->wait_for_input) { + events[1] = priv->simple->wait_for_input; + num_events = 2; + } + + ret = boot->wait_for_event(num_events, events, &index); + if (ret != EFI_SUCCESS) + return -EAGAIN; + } + + log_debug("rel: calling get_state\n"); + ret = priv->simple->get_state(priv->simple, &state); + log_debug("rel: get_state returned 0x%lx\n", ret); + if (ret == EFI_NOT_READY) + return -EAGAIN; + if (ret) { + log_debug("rel: get_state failed (ret=0x%lx)\n", ret); + return -EIO; + } + + log_debug("rel: RelX=%d RelY=%d LeftBtn=%d RightBtn=%d\n", + state.relative_movement_x, state.relative_movement_y, + state.left_button, state.right_button); + + /* + * Scale down large movement values that seem to be incorrectly + * reported + */ + *rel_x = state.relative_movement_x; + *rel_y = state.relative_movement_y; + + /* If movement values are very large, scale them down */ + if (abs(*rel_x) > 1000) { + *rel_x = *rel_x / 1000; + if (*rel_x == 0 && state.relative_movement_x != 0) + *rel_x = (state.relative_movement_x > 0) ? 1 : -1; + } + if (abs(*rel_y) > 1000) { + *rel_y = *rel_y / 1000; + if (*rel_y == 0 && state.relative_movement_y != 0) + *rel_y = (state.relative_movement_y > 0) ? 1 : -1; + } + + log_debug("rel: scaled RelX=%d RelY=%d\n", *rel_x, *rel_y); + + /* Update absolute position */ + priv->x += *rel_x; + priv->x = max(priv->x, 0); + priv->x = min(priv->x, MOUSE_MAX_COORD); + + priv->y += *rel_y; + priv->y = max(priv->y, 0); + priv->y = min(priv->y, MOUSE_MAX_COORD); + + /* Extract button state */ + *new_buttons = 0; + if (state.left_button) + *new_buttons |= 1 << 0; + if (state.right_button) + *new_buttons |= 1 << 1; + + return 0; +} + /** * get_button_event() - Check for button-change events * @@ -80,76 +167,39 @@ static int get_button_event(struct efi_mouse_priv *priv, int new_buttons, static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) { struct efi_mouse_priv *priv = dev_get_priv(dev); - struct efi_simple_pointer_state state; - efi_status_t ret; + struct mouse_motion *motion; int new_buttons; - if (!priv->simple) - return -ENODEV; - - /* Use timer-based polling approach like EFI keyboard */ - if (priv->timer_event) { - struct efi_boot_services *boot = efi_get_boot(); - efi_uintn_t index; - struct efi_event *events[2]; - efi_uintn_t num_events = 1; - - events[0] = priv->timer_event; - if (priv->simple->wait_for_input) { - events[1] = priv->simple->wait_for_input; - num_events = 2; - } - - ret = boot->wait_for_event(num_events, events, &index); - if (ret != EFI_SUCCESS) - return -EAGAIN; - } + int rel_x, rel_y; + int ret; /* Get current pointer state */ - ret = priv->simple->get_state(priv->simple, &state); - if (ret != EFI_SUCCESS) { - if (ret == EFI_NOT_READY) - return -EAGAIN; - printf("EFI mouse: get_state failed (ret=0x%lx)\n", ret); - return -EIO; - } + ret = get_rel_pointer(priv, &rel_x, &rel_y, &new_buttons); + if (ret) + return ret; + + priv->has_last_state = true; /* Check for button changes */ - new_buttons = 0; - if (state.left_button) - new_buttons |= 1 << 0; - if (state.right_button) - new_buttons |= 1 << 1; ret = get_button_event(priv, new_buttons, event); if (!ret) return 0; - /* Check for movement */ - if (state.relative_movement_x || state.relative_movement_y) { - struct mouse_motion *motion = &event->motion; - - /* Update absolute position */ - priv->x += state.relative_movement_x; - priv->x = max(priv->x, 0); - priv->x = min(priv->x, 0xffff); - - priv->y += state.relative_movement_y; - priv->y = max(priv->y, 0); - priv->y = min(priv->y, 0xffff); - - event->type = MOUSE_EV_MOTION; - motion->state = new_buttons; - motion->x = priv->x; - motion->y = priv->y; - motion->xrel = state.relative_movement_x; - motion->yrel = state.relative_movement_y; - + /* If there's no movement, nothing to do */ + if (!rel_x && !rel_y) { priv->buttons = new_buttons; - return 0; + return -EAGAIN; } + motion = &event->motion; + event->type = MOUSE_EV_MOTION; + motion->state = new_buttons; + motion->x = priv->x; + motion->y = priv->y; + motion->xrel = rel_x; + motion->yrel = rel_y; priv->buttons = new_buttons; - return -EAGAIN; + return 0; } /** From patchwork Mon Oct 6 23:21:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 545 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=1759793027; bh=+gH/+r3frUxCaFYp6w3XqmZRcXQoVmUwxwnzStA2HLk=; 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=caY/izLuDZcOn/l7hYb1dsmsqZuVbFQQYeCxJEm5Ag3hB5+8Jb88lKQMdIiCunKen WuVdY1lz9tGAjmYEF+jj8RJxnOySPmZyCwUXTYpxu8isU7WXr1Hcd2tLWrYLd3Ubxg AwMFfeYnp+PRAU4AMGdy9TvO8mI7zMnsW5nd7Wqy76jzb3lNy9ZUrzNc9NxFmD1hw2 tmxcmGd21Fzf3cxAolQ1w+oClZPxjRKtbLGLaJjbvEybRT6U5clDnUnv4gQV5qPaIe yJNfdzMOBFcGFsJd2m81/vl61Ir0Lo2TLbNcZrE15/wYfbOduZZBRJpM7glZV9cpa5 yFkr2htYJ4S8g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 32C2B67DB4 for ; Mon, 6 Oct 2025 17:23:47 -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 0E11bNX6w9sa for ; Mon, 6 Oct 2025 17:23:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793027; bh=+gH/+r3frUxCaFYp6w3XqmZRcXQoVmUwxwnzStA2HLk=; 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=caY/izLuDZcOn/l7hYb1dsmsqZuVbFQQYeCxJEm5Ag3hB5+8Jb88lKQMdIiCunKen WuVdY1lz9tGAjmYEF+jj8RJxnOySPmZyCwUXTYpxu8isU7WXr1Hcd2tLWrYLd3Ubxg AwMFfeYnp+PRAU4AMGdy9TvO8mI7zMnsW5nd7Wqy76jzb3lNy9ZUrzNc9NxFmD1hw2 tmxcmGd21Fzf3cxAolQ1w+oClZPxjRKtbLGLaJjbvEybRT6U5clDnUnv4gQV5qPaIe yJNfdzMOBFcGFsJd2m81/vl61Ir0Lo2TLbNcZrE15/wYfbOduZZBRJpM7glZV9cpa5 yFkr2htYJ4S8g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1B64E67EE4 for ; Mon, 6 Oct 2025 17:23:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793025; bh=I66q8FtB5r0xxRnpbgGRpDkOiBdyXXQ17E5aQLi83yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8m3kFXRNkUfDy/1fX5S94HBom68BM55lbR0rX7jdqXBhIn20ggFbMGCt9pvLPb7F YxQyI4c6G5PZlpGHhiPTAXzYfTTYywDLXdCqS1QSaHWvV3L4J+XZMcXnMXVcYN1GcV TZW0s2NmnUibj05gVln7pBc11lR69u4kPJTnzMSw9mtJoZ55i6Fzyx4pki1iBVbTDc XtVd4BYkj0NoOeoWa3oCM2fR7JeLLnMWxVfWcakxksaZ8sCRNavio02Knt54Jh5u0z u//f9NdBjgrU9Y02CXhfPiJBrnwmbjkSjdgc7oH5bG6QFB/wRwZft5D2On1EVLHXK1 BtMCpAPQbm40A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7DFB267DB4; Mon, 6 Oct 2025 17:23:45 -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 O-0vKhT1tX-x; Mon, 6 Oct 2025 17:23:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793021; bh=8vJf9gcH1QEM2W5WvYFWrQdOqcRyIRtHOuO6LZPNm6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fyBfDL92nhK3iexJtlu+fGiQ0AWHx7S3+tXnl+8vCjVpGSc46WJ2Yad8HY9laHSZR 4H5U538EgrlADr7RirF3NRGgKB9L1juWTkSxAzlubE2py0CCrNi54nYUOcMxqOYPkQ qqnO49mWSkT8hdTxs2oDDAblBSV/yh2QK/5z+MCEsj0UOtQUsuGBrTMKSau/g1eBTY tpMS8LQBg6R577dxyoTMqZBsmv9sYuU85rnO7kwhrgVRObIUEqk/1u2ESlbSg9Nnbj 112d4Q2f3DnFVScRGL3kpwkVhdPJ1/W4I9yI8boK5GGmMcv2uOO+LE3zt4gGR3KkXb Q0onoDM8x1mUA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id ADB3E67EE4; Mon, 6 Oct 2025 17:23:40 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:57 -0600 Message-ID: <20251006232236.2091941-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FIDGKPUNSHFRKLQRU5UYVVF7HVEEYI5S X-Message-ID-Hash: FIDGKPUNSHFRKLQRU5UYVVF7HVEEYI5S 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 15/17] efi: Add definitions for the absolute-pointer protocol 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 Add these definitions to the API so that we can make use of this feature in drivers, etc. Signed-off-by: Simon Glass --- include/efi.h | 1 + include/efi_api.h | 30 ++++++++++++++++++++++++++++++ lib/efi/device_path.c | 1 + 3 files changed, 32 insertions(+) diff --git a/include/efi.h b/include/efi.h index 3d983bd69a4..0bc7e0581f7 100644 --- a/include/efi.h +++ b/include/efi.h @@ -179,6 +179,7 @@ extern const efi_guid_t efi_guid_device_path; extern const efi_guid_t efi_simple_file_system_protocol_guid; extern const efi_guid_t efi_guid_simple_pointer; +extern const efi_guid_t efi_guid_absolute_pointer; /* Generic EFI table header */ struct efi_table_hdr { diff --git a/include/efi_api.h b/include/efi_api.h index 70e24cb5fc9..9e661913ecc 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -1006,6 +1006,36 @@ struct efi_simple_pointer_protocol { struct efi_simple_pointer_mode *mode; }; +#define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \ + EFI_GUID(0x8d59d32b, 0xc655, 0x4ae9, \ + 0x9b, 0x15, 0xf2, 0x59, 0x04, 0x99, 0x2a, 0x43) + +struct efi_absolute_pointer_state { + u64 current_x; + u64 current_y; + u64 current_z; + u32 active_buttons; +}; + +struct efi_absolute_pointer_mode { + u64 abs_min_x; + u64 abs_min_y; + u64 abs_min_z; + u64 abs_max_x; + u64 abs_max_y; + u64 abs_max_z; + u32 attributes; +}; + +struct efi_absolute_pointer_protocol { + efi_status_t (EFIAPI *reset)(struct efi_absolute_pointer_protocol *this, + bool extended_verification); + efi_status_t (EFIAPI *get_state)(struct efi_absolute_pointer_protocol *this, + struct efi_absolute_pointer_state *state); + struct efi_event *wait_for_input; + struct efi_absolute_pointer_mode *mode; +}; + #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ EFI_GUID(0x8b843e20, 0x8132, 0x4852, \ 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c) diff --git a/lib/efi/device_path.c b/lib/efi/device_path.c index 939bf5a0679..de7647e13d0 100644 --- a/lib/efi/device_path.c +++ b/lib/efi/device_path.c @@ -28,6 +28,7 @@ const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID; const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID; const efi_guid_t efi_guid_loaded_image = EFI_LOADED_IMAGE_PROTOCOL_GUID; const efi_guid_t efi_guid_simple_pointer = EFI_SIMPLE_POINTER_PROTOCOL_GUID; +const efi_guid_t efi_guid_absolute_pointer = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID; const efi_guid_t efi_guid_loaded_image_device_path = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID; const efi_guid_t efi_simple_file_system_protocol_guid = From patchwork Mon Oct 6 23:21:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 546 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=1759793029; bh=Dij1UJNZtN5XSsQTctH6OOfEycBFFfaCnxlULvvkAFc=; 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=uXHwzCRVerW+TpYKuWFDmABbpdM6k3+3bhFgyA44/JP1wUWOACU8Ez3PwJbpb0l6l sMOFFITkv8I2Jrnfl8ccospPSQHfSTYqgzjt31xvyH64tgNUPE2D1KZ2QZLDSJmdaZ uoezii+QVqTeh+Qsszo++7nL5jW9jNEEwk5lj0y+ciX/YYqByEPrRLgTWecGWEf5VQ tBPi9oT5NdacUClMpIdHRXdjbKKPaqUEqXtdcNgyo3jVoTsa5N4Sn7O/JZLUUfTgTf H1nPd8gHKoGr4oKXogr7b646W1mgp4B3+C4ufdeX58azOro3kbMnnvFlGqhhk4FMhv Z7Ke+vsrKm4Pw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BF67C67F03 for ; Mon, 6 Oct 2025 17:23: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 10024) with ESMTP id vpOwQ_ILcyT2 for ; Mon, 6 Oct 2025 17:23:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793028; bh=Dij1UJNZtN5XSsQTctH6OOfEycBFFfaCnxlULvvkAFc=; 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=gHKIVHAFgiS2uL7Dv3VgBO71t/EeqUYFDq8DJDfiBNDDZRSBQfQzEaCTijRSBsxKZ NRhZpN2rhwTPTkGTCyYUZsM88I8ckxFV14JA43qTOz6/Y3ESEi+e1W9a3yeN2a1x85 FjCElxukBaZ+d6MLRE97pEUnHCgJBIArN+q1QKmDwiIxy3EqJdTofyFVTsJ/WiEm0o wtXFNHHBt9HZmbAI9DKMGh5jqzlUOajmOptaaZsxGnnWi2yRTzWycGwRoFWfwt03wq WAOHQkvbWlDYDdf7eoIFwuPuxT6+65foG8Sy0fotWBUpyMZFqPVzBcnFwSfEjHZyAk i7ajRoe01bryw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B56CD67DB4 for ; Mon, 6 Oct 2025 17:23:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793027; bh=CsWMY8GgDDGgeu9PlErjEH2OV4I2ctDzzqDnFeCjmIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nhia/k83qzQ4TAS4RFHzH1wUVPK/FokpFXaGqY4NOwOL1KLJ3DCZgMs+d5PD5ly/r 8txlKWbBYE77hYB+Ph7LPf2xu2NqdMzkq010tD5zRtRTE70A5v86QaXeG4W/42zk80 IRq24My4MwVFtit6Q5qRPIgib4JGj9zQiZjq0igBbUNg+N/Q81wpCFQG9FTw4PV0hZ S/kpxUeg5oYkqfkZDx+43ifi8AP7qPLnYHZ17Z9hkYxdy7NxjlrbiS2D9JQfp1g7PL H9vBaphm0YtFrINOrmd7oQqEy3QXQr0WQuPH7g7GfKjrwrLtzOnmfuxIyIUxxN6W7c FFhk9QB74vvHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2182467F58; Mon, 6 Oct 2025 17:23:47 -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 pXMTGXyzMoyS; Mon, 6 Oct 2025 17:23:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793025; bh=p9dmF5P4O5H9NI9ORR6N/QT6VMtwo486LF6nlyf+vAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vUNXOLpOpW5G9vWTLTOc8ZLbQOApj9Ol/OAPiahMFWuM5WRbYsMicR7XCvz6E6PkK EolFpgxV4r2C+b4+0CvzFlH6I7wdObHV6Xy4VBTtox3Vb0sp+P2QDSW+eCDKKbdaTk 2aRRJS6frn+X6V5nypG4rGilgsqSJal78no4wlw4f/XQWN7QuVMuSpIiLKdSjFIqh+ r/5EYl5IRdn+sN9TbS9mM9dmCl2W+5T8pU3LPrIGSyg9pvSZq09VTb5GQKmN99dphz LOyv3ciwrKd7aXyyiLyt9/y4YqNFoONnHJSmQ3szF0q2NWM92qRyTIgUZhgIdsLtuw jTr6JeajTog/A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4E06367AF3; Mon, 6 Oct 2025 17:23:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:58 -0600 Message-ID: <20251006232236.2091941-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: Y5VNHXDSATVPIE3B6INFG3HJN7FQX3YI X-Message-ID-Hash: Y5VNHXDSATVPIE3B6INFG3HJN7FQX3YI 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 16/17] efi: mouse: Add support for an absolute pointer 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 The absolute-pointer protocol is useful particularly with QEMU since it allows the position to be consistent between the host and the guest. Add support for this new protocol and use it in preference to the simple one, when both are available. Signed-off-by: Simon Glass --- drivers/input/efi_mouse.c | 134 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 127 insertions(+), 7 deletions(-) diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c index 81c3fcb862e..53976bf9e22 100644 --- a/drivers/input/efi_mouse.c +++ b/drivers/input/efi_mouse.c @@ -21,8 +21,11 @@ * struct efi_mouse_priv - Private data for EFI mouse driver * * @simple: Simple pointer protocol (relative movement) + * @abs: Absolute pointer protocol (absolute position) * @simple_last: Last simple pointer state + * @abs_last: Last absolute pointer state * @has_last_state: True if we have a previous state for delta calculation + * @use_absolute: True to use absolute pointer, false for simple/relative * @x: Current X position * @y: Current Y position * @buttons: Current button state @@ -31,14 +34,64 @@ */ struct efi_mouse_priv { struct efi_simple_pointer_protocol *simple; + struct efi_absolute_pointer_protocol *abs; struct efi_simple_pointer_state simple_last; + struct efi_absolute_pointer_state abs_last; bool has_last_state; + bool use_absolute; int x, y; int buttons; int old_buttons; struct efi_event *timer_event; }; +/** + * get_abs_pointer() - Handle absolute pointer input + * + * @priv: Private data + * @rel_x: Returns relative X movement + * @rel_y: Returns relative Y movement + * @new_buttons: Returns button state + * Return: 0 if OK, -EAGAIN if no event, -ve on error + */ +static int get_abs_pointer(struct efi_mouse_priv *priv, int *rel_x, + int *rel_y, int *new_buttons) +{ + struct efi_absolute_pointer_state state; + efi_status_t ret; + + /* Debug: check structure size and alignment */ + log_debug("State struct size: %zu, address: %p\n", sizeof(state), + &state); + + ret = priv->abs->get_state(priv->abs, &state); + if (ret == EFI_NOT_READY) + return -EAGAIN; + if (ret) { + log_debug("abs: get_state failed (ret=0x%lx)\n", ret); + return -EIO; + } + + /* Always log the state values to see what we're getting */ + log_debug("abs: X=%llu Y=%llu Buttons=0x%x\n", state.current_x, + state.current_y, state.active_buttons); + + /* Calculate relative movement */ + if (priv->has_last_state) { + *rel_x = (int)(state.current_x - priv->abs_last.current_x); + *rel_y = (int)(state.current_y - priv->abs_last.current_y); + log_debug("abs: rel_x=%d, rel_y=%d\n", *rel_x, *rel_y); + } + priv->abs_last = state; + priv->x = state.current_x; + priv->y = state.current_y; + + /* Extract button state */ + *new_buttons = state.active_buttons & 0x3; /* Left and right buttons */ + + return 0; +} + /** * get_rel_pointer() - Handle relative pointer input * @@ -172,8 +225,14 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) int rel_x, rel_y; int ret; - /* Get current pointer state */ - ret = get_rel_pointer(priv, &rel_x, &rel_y, &new_buttons); + /* + * Get current pointer state. Under QEMU, EFI pointer-events are broken + * so we poll directly + */ + if (priv->use_absolute) + ret = get_abs_pointer(priv, &rel_x, &rel_y, &new_buttons); + else + ret = get_rel_pointer(priv, &rel_x, &rel_y, &new_buttons); if (ret) return ret; @@ -202,6 +261,47 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) return 0; } +/** + * setup_abs_pointer() - Set up absolute pointer protocol + * + * @priv: Private data + * Return: 0 if OK, -ve on error + */ +static int setup_abs_pointer(struct efi_mouse_priv *priv) +{ + struct efi_boot_services *boot = efi_get_boot(); + efi_handle_t *handles; + efi_uintn_t num_handles; + efi_status_t ret; + + ret = boot->locate_handle_buffer(BY_PROTOCOL, + &efi_guid_absolute_pointer, + NULL, &num_handles, &handles); + if (ret) + return -ENODEV; + + log_debug("Found %zu absolute pointer device(s) guid %pU\n", + num_handles, &efi_guid_absolute_pointer); + + /* Use the first absolute pointer device */ + ret = boot->open_protocol(handles[0], &efi_guid_absolute_pointer, + (void **)&priv->abs, + efi_get_parent_image(), NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret) { + log_debug("Cannot open absolute pointer protocol (ret=0x%lx)\n", + ret); + efi_free_pool(handles); + return -EIO; + } + + priv->use_absolute = true; + log_debug("Using absolute pointer protocol\n"); + efi_free_pool(handles); + + return 0; +} + /** * setup_simple_pointer() - Set up simple pointer protocol * @@ -235,6 +335,7 @@ static int setup_simple_pointer(struct efi_mouse_priv *priv) return -EIO; } + priv->use_absolute = false; log_debug("Using simple pointer protocol\n"); efi_free_pool(handles); @@ -247,13 +348,17 @@ static int efi_mouse_probe(struct udevice *dev) struct efi_boot_services *boot = efi_get_boot(); efi_status_t ret; - if (setup_simple_pointer(priv)) + /* Try absolute pointer first, then fall back to simple pointer */ + if (setup_abs_pointer(priv) && setup_simple_pointer(priv)) return -ENODEV; /* Reset the pointer device */ - ret = priv->simple->reset(priv->simple, false); - if (ret != EFI_SUCCESS) { - log_warning("Failed to reset EFI pointer device\n"); + if (priv->use_absolute) + ret = priv->abs->reset(priv->abs, true); + else + ret = priv->simple->reset(priv->simple, true); + if (ret) { + log_warning("Failed to reset device (err=0x%lx)\n", ret); /* Continue anyway - some devices might not support reset */ } @@ -275,7 +380,22 @@ static int efi_mouse_probe(struct udevice *dev) } } - log_info("EFI mouse initialized\n"); + /* Test protocol validity */ + if (priv->use_absolute && priv->abs->mode) { + struct efi_absolute_pointer_mode *mode = priv->abs->mode; + + log_debug("absolute mouse mode: x %llx-%llx y %llx-%llx\n", + mode->abs_min_x, mode->abs_max_x, + mode->abs_min_y, mode->abs_max_y); + log_debug("absolute mouse wait_for_input event: %p\n", + priv->abs->wait_for_input); + } else if (!priv->use_absolute && priv->simple) { + log_debug("simple mouse wait_for_input event: %p\n", + priv->simple->wait_for_input); + } + + log_debug("initialized (%s protocol)\n", + priv->use_absolute ? "absolute" : "simple"); return 0; } From patchwork Mon Oct 6 23:21:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 547 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=1759793033; bh=3zLv17Fiv5HL13CZxB2v4Pl6G9MW639ax91aqA4z/u8=; 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=rpK7CDLyrnluuMaDSQpniM1dOlt5/0Ua9LAihFQOSApQAYgF7KDBGzoP1QAB45tUE BFD7reGIqlLZyi8kpDpKsqFECcEZZjTHgKeli1fTks6uAG2aP6YbDq3zEdO0wfGvuI 9BZSr5O4Tp3LKurftqmcV8CR4r0bK56+/HOduHC8c17fJnwIDutdRq02VbRJed4lij KgHYRj/BCtg/A2hs+N7DXKsRU7bQ8PHM6SR+uupPWc1VtvKdC+yUVIr0ySmENo0FBC wQaSKgngQeBoX2FZyO2DN0hdYepZTXDiGFxA//D5xIX0Jzab8gYOYdydWSMKXuiBl6 YPCzNHgjhSRgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9727167FB7 for ; Mon, 6 Oct 2025 17:23:53 -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 OuOWtat51AlM for ; Mon, 6 Oct 2025 17:23:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793033; bh=3zLv17Fiv5HL13CZxB2v4Pl6G9MW639ax91aqA4z/u8=; 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=rpK7CDLyrnluuMaDSQpniM1dOlt5/0Ua9LAihFQOSApQAYgF7KDBGzoP1QAB45tUE BFD7reGIqlLZyi8kpDpKsqFECcEZZjTHgKeli1fTks6uAG2aP6YbDq3zEdO0wfGvuI 9BZSr5O4Tp3LKurftqmcV8CR4r0bK56+/HOduHC8c17fJnwIDutdRq02VbRJed4lij KgHYRj/BCtg/A2hs+N7DXKsRU7bQ8PHM6SR+uupPWc1VtvKdC+yUVIr0ySmENo0FBC wQaSKgngQeBoX2FZyO2DN0hdYepZTXDiGFxA//D5xIX0Jzab8gYOYdydWSMKXuiBl6 YPCzNHgjhSRgA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 863FC67F58 for ; Mon, 6 Oct 2025 17:23:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793032; bh=9Ld8RczQcWeYbnRj+coVOWkLmGEvckXvTKDE6aG8txA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rj1vkQ34BrFoSnUS9jsekRbB4yKU/v6Ix8LpQmvI6BgT5wvni0xuGl+zQbxCRVsnJ Y1YkO4K3I+K2MwKtQsXFOTZHwlZYlxHaDDO9mUz5cVSx3LZWfcV/+d3A9GGwitCwjX LVPLw7IzF9Rcu2CcCoeDePmWr/xPAYFNXFwK9itM63lr2qGeilFzuBVBwv51lyUwKZ jpjxrf7SJOEiupsqEor1iFu94ZDedyTWfupj0NioQi5pTY4FneVpqeCT00xUdxIqjH oXi1EFSoMgIS2UQ6Myo00zMcFFssqeeFR+VcjduqiHpqyTPbWAyPdEGuJQYeqZgUmz +YE3r+dS75Oxw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2A70467AF3; Mon, 6 Oct 2025 17:23:52 -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 nDypPmbX4cvp; Mon, 6 Oct 2025 17:23:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793027; bh=oLU6N0LraHADfnOSgZjJdO9qJmk7d8rkWgFO/gKz0EA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ll1jKutUW41InHdvXMwHvv4s7x2n9fOtKgCuTTDXws/5dgSEOL0kv8ELUFEVbDuTx gsbFscHpNv7PRPSB/npXM2L5ll4A7PGUPZcavMQR2LWalzxm8aQEVKkLsmZq440v4C HOn6Ek/hwDkGuxn73134BEeb0vMgqjXZDrP7QTOuEvvOk6GXZrxWRXFdQNC8bgVf2p v8UA2Tp0traaMvpdSTchg9rBe3a3wwRfi4dwIiWaNCQFpJQ7le45IjxXkEJ8p7Un7y si9kfAr96ln9m4RXR+LXYcPil7ghmDUGuBGMfa5PGCqgy3BR6oDOAC17pg6LvN1CJ6 LuwN+4kZKDQtg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5FC3867FE0; Mon, 6 Oct 2025 17:23:47 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:59 -0600 Message-ID: <20251006232236.2091941-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: P5OSHKVMV56T2M6NP5NGRBOIOCFI6M6K X-Message-ID-Hash: P5OSHKVMV56T2M6NP5NGRBOIOCFI6M6K 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 17/17] efi: mouse: Scale the pointer to the display 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 If a display is provided to the mouse uclass, use it to scale the coords returned by the absolute-pointer protocol. Signed-off-by: Simon Glass --- drivers/input/efi_mouse.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c index 53976bf9e22..e9870e119a0 100644 --- a/drivers/input/efi_mouse.c +++ b/drivers/input/efi_mouse.c @@ -13,6 +13,7 @@ #include #include #include +#include /* Maximum coordinate value for mouse position */ #define MOUSE_MAX_COORD 0xffff @@ -49,12 +50,14 @@ struct efi_mouse_priv { * get_abs_pointer() - Handle absolute pointer input * * @priv: Private data + * @uc_priv: Uclass-private data * @rel_x: Returns relative X movement * @rel_y: Returns relative Y movement * @new_buttons: Returns button state * Return: 0 if OK, -EAGAIN if no event, -ve on error */ -static int get_abs_pointer(struct efi_mouse_priv *priv, int *rel_x, +static int get_abs_pointer(struct efi_mouse_priv *priv, + struct mouse_uc_priv *uc_priv, int *rel_x, int *rel_y, int *new_buttons) { struct efi_absolute_pointer_state state; @@ -83,8 +86,28 @@ static int get_abs_pointer(struct efi_mouse_priv *priv, int *rel_x, log_debug("abs: rel_x=%d, rel_y=%d\n", *rel_x, *rel_y); } priv->abs_last = state; - priv->x = state.current_x; - priv->y = state.current_y; + + /* Update absolute position - scale to video display if available */ + if (uc_priv->video_dev && priv->abs->mode) { + struct efi_absolute_pointer_mode *mode = priv->abs->mode; + u64 x_range = mode->abs_max_x - mode->abs_min_x; + u64 y_range = mode->abs_max_y - mode->abs_min_y; + + if (x_range > 0 && y_range > 0) { + log_debug("abs: unscaled x=%llx y=%llx\n", + state.current_x, state.current_y); + priv->x = ((state.current_x - mode->abs_min_x) * + uc_priv->video_width) / x_range; + priv->y = ((state.current_y - mode->abs_min_y) * + uc_priv->video_height) / y_range; + } else { + priv->x = state.current_x; + priv->y = state.current_y; + } + } else { + priv->x = state.current_x; + priv->y = state.current_y; + } /* Extract button state */ *new_buttons = state.active_buttons & 0x3; /* Left and right buttons */ @@ -219,6 +242,7 @@ static int get_button_event(struct efi_mouse_priv *priv, int new_buttons, static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) { + struct mouse_uc_priv *uc_priv = dev_get_uclass_priv(dev); struct efi_mouse_priv *priv = dev_get_priv(dev); struct mouse_motion *motion; int new_buttons; @@ -230,7 +254,8 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) * so we poll directly */ if (priv->use_absolute) - ret = get_abs_pointer(priv, &rel_x, &rel_y, &new_buttons); + ret = get_abs_pointer(priv, uc_priv, &rel_x, &rel_y, + &new_buttons); else ret = get_rel_pointer(priv, &rel_x, &rel_y, &new_buttons); if (ret)