From patchwork Tue Oct 7 17:05:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 548 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=1759856780; bh=pWZ3cUPHaWweZtRsmpP9p8aOHEMXcq/0Osto4+fHNdE=; 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=HHCCowozLfOGa7Z7BOiD6hBQyQlPyZcFFdbXHhg0x5BswSiuE186Io4rNttnxFBxv Hs+RoPN1dhlpSQ5G0nmnUYWJ+UgcKHtgfmX3qbBr8J/zuRCdWGilA4VLGKQa1/RMC2 P9AavAaZR6Ft6k0D+QN6tyjyDf277OKFJgxNzafFJPpsfJqOzJ404DBbAdupuX7SLk 1nGec2D6mjfDMD3qM6lFEqyzokmmVBabToHdB/VT4XdN8MZlB+KXI8zuPMCpKXiGLu wxdUo1G3Ik8DgHkItgF+POPDsC7DzzmZppvlc6L0azR2P5N/5Bgdszxor/45uG38u5 TR3u1CnQv6fSw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0C5767FF8 for ; Tue, 7 Oct 2025 11:06: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 bgQpkWdnfT9D for ; Tue, 7 Oct 2025 11:06:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856780; bh=pWZ3cUPHaWweZtRsmpP9p8aOHEMXcq/0Osto4+fHNdE=; 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=HHCCowozLfOGa7Z7BOiD6hBQyQlPyZcFFdbXHhg0x5BswSiuE186Io4rNttnxFBxv Hs+RoPN1dhlpSQ5G0nmnUYWJ+UgcKHtgfmX3qbBr8J/zuRCdWGilA4VLGKQa1/RMC2 P9AavAaZR6Ft6k0D+QN6tyjyDf277OKFJgxNzafFJPpsfJqOzJ404DBbAdupuX7SLk 1nGec2D6mjfDMD3qM6lFEqyzokmmVBabToHdB/VT4XdN8MZlB+KXI8zuPMCpKXiGLu wxdUo1G3Ik8DgHkItgF+POPDsC7DzzmZppvlc6L0azR2P5N/5Bgdszxor/45uG38u5 TR3u1CnQv6fSw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 839D567FF9 for ; Tue, 7 Oct 2025 11:06:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856776; bh=pQDNBMeF5f0R1P0EgpWpCp7oMqsmtN0fHyRoZ5TKvn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ArS/5efpGPdxnLGbkXGQh222SBmsnVH+owSTXgKOugU1xqY/B65YhH7pp2cxC1tl7 FSTswg+74AkFQwWWD6OMdWTO1dcWVTu3rsy1Luz97HgLjfcSbgvuf+kXu/SY6Uss3m rmyvGU3aOGaNg8kzuZ4hfsGlMtFWZSL6m1Yg1Yru4m5yn0RUvDuFrJ3UEodeatZKSc oFvGGvWUJ8PlFkPZM2lttrOuKeuaEgol7zXcYfgbBJPVWkF/Q6GWVGIKgtpiFYSfKD 3OMkFJgkOAyqp//b72SheDIMpnVVKQrxgyGVytMFY2ltQnR2zN7aA2aAK1UTvnoWml JvuITKOcEEmEA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C70AA67FF9; Tue, 7 Oct 2025 11:06: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 10026) with ESMTP id a9GQZGmknuzz; Tue, 7 Oct 2025 11:06:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856772; bh=q52XV1YUyxeE7OPh1plvwrJJ7+yEx4AMuPAalER0mEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quAwZ/Z8DMZuwlJnPJwytCTcB5oo1pg1ZrfHumhN9jXS8c4IJ5TGffPpCXAhNeYr7 5x6nuVYFobhSTWaCOKfVOpR3Mhzf/yyAlwNSnHEan0JiGB1JVODVd3dmOYwXfqBBWb eBfxCnjnsz7aSa+z8TLINnzUDDFM04wAFs1d9MgxzzBgMG/RPAjZIODbbr7SjC77gg hsp0XTqJ9WWPuRq2Lw5ul0GWP5EgdfMi/VTqx3Ubb4uK/ExRH8cy77gV0/Oz3QtLYU cgdT6st/sgYv4sFwUOV9Aez7IJ8deEO4jsFtoUB4b0b7P0DYOnN23nFCTuzNr5mkD4 N5Hu3NEIF6NJQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F34E867F6C; Tue, 7 Oct 2025 11:06:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:15 -0600 Message-ID: <20251007170549.541981-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MRLNLXFH5RNI2SABUKPRERAEFFG5N4EW X-Message-ID-Hash: MRLNLXFH5RNI2SABUKPRERAEFFG5N4EW 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 v2 01/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 549 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=1759856783; bh=Jyup7fKnUi6lnBdkiIY+IigHLngggxPJjE15EScI6fg=; 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=HxMBXnQkyy8v5ieOw15Co19mgySMuaByG+schx9InGOLKqRgfub7izd8JBObm324x Z+GjJtKGgGhiCkZvXJqEGxr0IUVKxmcc0YKugYZZXKdm8VUIeA2/ucZu1pDMG07VpU ciO3IDgOqrSH3WExYuim27g/zJ6vOik2fELGJ4/CfEv82jb0fIyR0HOSXiAy8y1aTD SHNHHyqRlr5UwuoIbzp87eyG+hm6cDsNS33kOKy1vDBA+GEGTQE/1moiccqK+ryC7a 75z1hrXr2kMLURXjCCZfrGQvmuvYccNml+eoz3o+lSqyhUsu0x7cbGtBzAtv+sixGO 77bs9U2KEm+pw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 18B9F68000 for ; Tue, 7 Oct 2025 11:06:23 -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 cqnKWTLYeIqh for ; Tue, 7 Oct 2025 11:06:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856781; bh=Jyup7fKnUi6lnBdkiIY+IigHLngggxPJjE15EScI6fg=; 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=KOz2f4A/iuqrr2TlXo1Ot3gfvQAGgaSNpqe9bjg61L0RDmFJvFO38GVYJ/GARoTou Nj5slNlJXACQysJ/Z5IEuFRvagvqi1jA2pGy6mK3CiWrjpxZVMhfxOo19XQk0sgzw5 RCoNlnKa9NM/wprTtUPZd8NPnFURHoPxvWlLBe1f+sG2+dcjkQRVqIGyzojl8gPYBv Xz9JRqL7Qq6xH9I7WSB1yIzczq0MFZ+g5SXQ9f3syivWuK4/pjIeq4IbSbz9m5NtHg zj5/khRIdBwre783L+JawyDHfvUi2c9BDYNdpuR5BGs1D2T9ulqBp5dxSzzoflf/sJ eBVPbceMV00Cw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 78B5967FF8 for ; Tue, 7 Oct 2025 11:06:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856778; bh=UR0zhdgbF0J4e7XfgR/tGFsUuqk/zthUY7oBKjv8zkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AyHt9V8ICLR5oMmZfNoNIOWt6hT63I1r2LmhOmunllIR5lASAUt2U4Vh3GCDx5G1A VSoZDEl5jkZt/DOgx784WeWhm6AqUMMfhrdOkzGdwgKBG7S6b7borD01nUtybGe2F0 ouhwxcS2svbCH9sik+xZ9i29nhOsrUyew2wBB8ezDCCszazUcNOSJhMqNSrHVdyEvL qhD0OD5SDV06z6UR/6XPncev8CvbsljCY6xVd5I+YGFfsn9MiA6lvLOUUttDieA7Tz 55dYdwuGAustt6H+g/siZXgV9d5XNT//EBvvyAX62qkjg6ZKQIycQUunoAVV3oQa69 /m3Q/yQ8K+OuA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B51CC67F1E; Tue, 7 Oct 2025 11:06: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 SMAxOLHm6vYd; Tue, 7 Oct 2025 11:06:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856777; bh=8+7tYhZC9W5m5jS3LjmHqa19UpyKWqAUt734pxSpqX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KJf31NmUrNnK8mdgltQdFK52cM0lU2a4U6mzwx2gRnsYyzCwnggJPGtJpXH+mSYVh y5fVXJuiwx0OdqnWIWXnMuLKcf8VpoCyihpXhRz25MQ199MSPoa9UKSpZKBtPHdB5Q lPh754WTVd4ZToYNhwWfQO5fuZVGA8N0r3Pt8++k9UF+PkadshIHjRW+eI6gZ1vPjn u4qv9o1cWeyhY7vIexBQ+rPU3gOl8VZs4wXGkTNbmNe2lT0eiK0StkGYiikhuZfs4v 5vhMEVZ3GsYkyFZWG+2j28FVXd553V5q/MFcAUNa++Myx2Oz7jbbHqn58lC1I5IrlV 0a9nLvHDCLejg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BDA8667FF7; Tue, 7 Oct 2025 11:06:16 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:16 -0600 Message-ID: <20251007170549.541981-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: POTXHJFVWZY4R7TTZKCSNHL6ODEN7NQT X-Message-ID-Hash: POTXHJFVWZY4R7TTZKCSNHL6ODEN7NQT 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 v2 02/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 550 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=1759856787; bh=18tp0kU6RsJQpTFbnsVPprOHSdXwrUkcF40Oj1gQIoQ=; 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=w9bAlUa8ENjn/cItVVJ0R3i+qitoXyfNnB5bzwT3MAC/8JYLjeOhCDr5eTCkCHlH3 YEbCR9BjGsVd9/kJ9IJPeA2I6R4yD3s7pWg8t+h9jcSlPfV/M8AHSidkw6LAufHB/c 56XfKrR1YJUILcQ6j3xLKHwF9Uux3z3ngj7IL/1SGEK6nuqciI+Yhc/3qx4JmEYmU7 cg+YFD13ju9jMK+30keysOWWSxGo4otsvFbKYQKI3HW0SANGhxOwb2wkOaphvzGLDz Gpujkue9/KCuTE4DiNoT2gPcz+xYxS1GehZ9O/47H6T2sIbdKLh5tsP+1sOKwdgrc0 B8vytFn/00fvg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1C88767FF9 for ; Tue, 7 Oct 2025 11:06: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 Gi1Wj5mKmT_5 for ; Tue, 7 Oct 2025 11:06:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856787; bh=18tp0kU6RsJQpTFbnsVPprOHSdXwrUkcF40Oj1gQIoQ=; 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=w9bAlUa8ENjn/cItVVJ0R3i+qitoXyfNnB5bzwT3MAC/8JYLjeOhCDr5eTCkCHlH3 YEbCR9BjGsVd9/kJ9IJPeA2I6R4yD3s7pWg8t+h9jcSlPfV/M8AHSidkw6LAufHB/c 56XfKrR1YJUILcQ6j3xLKHwF9Uux3z3ngj7IL/1SGEK6nuqciI+Yhc/3qx4JmEYmU7 cg+YFD13ju9jMK+30keysOWWSxGo4otsvFbKYQKI3HW0SANGhxOwb2wkOaphvzGLDz Gpujkue9/KCuTE4DiNoT2gPcz+xYxS1GehZ9O/47H6T2sIbdKLh5tsP+1sOKwdgrc0 B8vytFn/00fvg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0BFEC67F6C for ; Tue, 7 Oct 2025 11:06:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856785; bh=5jeKvgf5PUNC9L0EfN0+xCoOGq9l4g3auQGMI8TaRLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HD3fE0/utXA4dY3ZjKGzJXB2ZLnXSqgLE5c89LGhDMIXx6rhYUvr4Fskl1ubc3DkQ f4uynOyPlPdx7ZAG3TkEuI0grmIyT8L77IM6tj1BCVnSsEDm116GCmpUiqCggrYtPJ /7EqT7l1VJa03kZb90Ozha9nPdI+4QhoB27Y3yrHubhAcBbRylyd/wYk1pHkinRre/ xCPBTTj4i/8a7Ank3McCIraAhrT/yHu5NFegS19RwgJuchR7OqkFtIaMGNbWCpTdfO kPXN6iuIdKABlS18KZVm2dOQ39EOvJyMuqwOBpxm6HTazXRL558L5jqdl/bMc/Azij CbQmOUGSqSu2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 674EF67DD0; Tue, 7 Oct 2025 11:06: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 kKeHcmxdAFLj; Tue, 7 Oct 2025 11:06:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856779; bh=JlAHgr+iZNoOXlHesTtHQe1+sga2wvCh0abwa7it1Ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n2eXvdTQDpoYuQKyq0BBQ+Bz3ZBoEW1QxlHydksJ6gnTbfnc4G1Iqb+mg8UR/64U6 BjDVFYO5PHy7XpNqS42wGk91mHA2CrC8e3CRUqGrJoybAunRamiPL/niSdxOYDnJgE aolYAnFB16LgnO8ZWqvz7bfGsrc8U49OhKfu9QO874pWWG0CrWHOGPDc6oycMCCv3y TXzkv+znogMGhoc1qbpWKdlTdzdO9WTY6Hn8SqmAUM+AnzCj3lchSW6s17mMR5dZCa feL9vrT/81vscH+Tz+aO5pNvzSdIgD0rpALFt45RdZOcR1dETGGqWIhDourlYefiIx K2Ddr6fdKOwdA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 00ED567EE5; Tue, 7 Oct 2025 11:06:18 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:17 -0600 Message-ID: <20251007170549.541981-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WY7WR5F4RHMVU5VG743RQSQXUN7E3KLW X-Message-ID-Hash: WY7WR5F4RHMVU5VG743RQSQXUN7E3KLW 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 v2 03/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 551 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=1759856789; bh=I2FXSFVGxigy85JmSWOEqctv8+kFPKxRBTOZxy3lGvg=; 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=gV5BhQiTWc+NoVJw2w+/HIJQi/elOBZZmtsHSqker9s6lpRa+HhMd7cimpxiBMMig AkXaxTRmlO8xLzukZjBtd2UKOty4VYKUL0KKABU8ck4oqOme8qxMSefW4lI7aj7XaT r7A8hiaUT5qdziX7tQy/z92rNzuAzJuaAiaoxks5QaopNISlM37vxkKtpQF23RRdr2 657A/JwdvsFTsNkl7SHP9ofhn1hubpotgjBAsRsAa53xdGizyCUy/Oz8BGR1G79L6e 1txASWilR1XMPyUP6yn+M+yj8QNYGLLVtQfP/B7L1mQm9PN46+LP8Oawavs8e8O3TD fdR9ca1CBu0UA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 81B7367FF8 for ; Tue, 7 Oct 2025 11:06:29 -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 VFz0rJjhs64t for ; Tue, 7 Oct 2025 11:06:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856788; bh=I2FXSFVGxigy85JmSWOEqctv8+kFPKxRBTOZxy3lGvg=; 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=E8lxb0HFxa3prFvJOVkQm51sy2r7dKT79GE9DjmFmntQhbqV5Sre9dAWIOPpH2+Ol WVGLorE1hH8Ph+/adlXTE91yyf1L3jrt/voKE29Lk7hENL8ThX1ji18KVBAwn/0adB IsRI6ShvB5rHjqEVG2rThUdlVpEfuhEpVXbfhNwA+AaN1A6pgwDyv99VGQcP5FH44X PT41KKA5Sz9d35/XhjlJ6iIQbDpe1RgTN0dFhV+4iRUQfSYDiOqhW9bZ6k7eF7u2qq qCBN4BdOBgT+5xIAkctIYl4zlvBzbxnieHDG6ue0XlsOrF3ZH2O9Ctpqd09xDOtXDG inSGdx9BJv1ug== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2419767FF9 for ; Tue, 7 Oct 2025 11:06:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856785; bh=3zR8OEGrKLcr1oge2ul/k7Jnz6pe8nKn5QZyelZt//I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZFwIUAiARJOJHNxhcpGGyqJnKXYDsfzWMGBieUDrkinNfbJx/MwL9B2mAhtlzCY+D L2nqnoDywfByJRHSWsAKGucrCEszfUfHPleY9zoUjxYudBID39C/kn2l+T0eKg4gpv UuQAIC7ZllW04Lw3JGxjhiTbn6OEmSgDAqoJAkQxJpqgknsJqm1kxiN+h2Wpw78uGK dJkjTw7rrEOYCTmaI1OrXuG2/CmNMpnAubI1jZ0zEiTDlKoIgTTSrJ6vU7U10lgjQ4 yDm4JdIgyZ5Cob8UIHJaslpkwtG/iljlR70wwmJ0o/7/26wcZF0XJwvfrFSQc6w9Q0 eUBXIQi14OryQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A2FE67F1E; Tue, 7 Oct 2025 11:06: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 sOMHMod4RoLf; Tue, 7 Oct 2025 11:06:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856783; bh=9flUfFAockmK0lJrw+QcOlsAXxYHQOHXrnwff+zjeb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GoJzTTf5dNEtN4tte++p3KTYmfYONFd7XVnrrH4mz9mTzJax1B7U9C2jFNoVv8Qc4 jHIJ8ORhRWZJbDfDw2PvS8tfrFs8K9qN6E6xCfavZ+DjsaoEGCDtQWL/kIK8AwRvv1 oYPE92+WNGcDUA8u52/OisYz/TNz4go4uZnWsbeZEk9AF767vAh/aOcdI/h+CijGAA IYrbuOyFTiYZrUfo71ppQdrtSZVUKXATRvOPC3v8LC3GPZ2/Mt4mQhG8JoeAVBKobB un3FOqrih6ntqK1EIJcO40cUzBMolp5kLS2WfQtHoONwiFo+Ft5qbCKfd22L/wdk36 KsSxZMaDqSjSw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9CEF667F74; Tue, 7 Oct 2025 11:06:23 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:18 -0600 Message-ID: <20251007170549.541981-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YUAWW6NLL7Z5IDD4VJVUJCJ2VWKQJ5L4 X-Message-ID-Hash: YUAWW6NLL7Z5IDD4VJVUJCJ2VWKQJ5L4 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 v2 04/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 552 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=1759856793; bh=fyUsW/om7+SbFWcfrjTLbO4laS1KjC8MfRuYOoJ4FeY=; 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=KXCZYFg20x4pfmD3DeN80oyx/GQJdIbGQLiOe13uhvuL2Ek/ozWc4KbOkLbTRFbhP Rx/siFgX9PWaE/RmeAmXyh2lGb+XunW0nypkBABtnxfKu2Tw1NnpatUM7Q/4zHj5Hu DMaPyhj5r4N+VSLfxLVax32M2plD1kaW7bdelX4kunEsYMe9E8AvImHdJe6P24oLF1 7UI01nffkJFRp5uojtkjzFRB58qA6Hg4sEPBeFDuci4/daykE35iRY9EymA97xWA+G M+UNB3e6b517fYJ8lM18tew0bpmN+wyLx7f4jA0VuQHnJZii207JoMdRgrE4hwyTkR +iD82cE5ZCjIg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BEB1C68000 for ; Tue, 7 Oct 2025 11:06: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 10024) with ESMTP id QY0IV2ZNRLhz for ; Tue, 7 Oct 2025 11:06:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856793; bh=fyUsW/om7+SbFWcfrjTLbO4laS1KjC8MfRuYOoJ4FeY=; 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=KXCZYFg20x4pfmD3DeN80oyx/GQJdIbGQLiOe13uhvuL2Ek/ozWc4KbOkLbTRFbhP Rx/siFgX9PWaE/RmeAmXyh2lGb+XunW0nypkBABtnxfKu2Tw1NnpatUM7Q/4zHj5Hu DMaPyhj5r4N+VSLfxLVax32M2plD1kaW7bdelX4kunEsYMe9E8AvImHdJe6P24oLF1 7UI01nffkJFRp5uojtkjzFRB58qA6Hg4sEPBeFDuci4/daykE35iRY9EymA97xWA+G M+UNB3e6b517fYJ8lM18tew0bpmN+wyLx7f4jA0VuQHnJZii207JoMdRgrE4hwyTkR +iD82cE5ZCjIg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE1E267EE5 for ; Tue, 7 Oct 2025 11:06:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856791; bh=ROyNTlPe5YyZ3zfpkr236873CWANqSvm87WLkDKsE/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9504q5nV2Tu3/+boptgj5MZehlWmuW2epDkoqrPskInW1h7ceeymXjL71PmX9ReT DxPht2Vfp6/5OMZPGhzz4ft8rj0N/0vRY38nkKQ8RlRpTiL16mcAtaXRWJiYEYwS++ xTszvyihwRACPa7+QdrAiYoqqZg5b+1zcevy1sqk4sAuFBaCSgndqrmxlTtaUoc4cO 5jSDNj0Qyt/sxRVXodoV2izD3gR+jPLy0qy1C3d8gA/4n0YvRzuzHUqpmjn0dyJwf5 wL/RaiDF4/UMEPNo3TqNcF/MKUrta2Aj6xhfngU8/tKMTrpHiX0e0OwIC7lCyuJ8/K KlvOm+eDMXPRQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D00E067F72; Tue, 7 Oct 2025 11:06:31 -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 UJYW_sZrv35V; Tue, 7 Oct 2025 11:06:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856786; bh=8JW+FVPY6t1Nl/H5E+NDMil/DV0dJ3h1z7YwFsZ9HXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sirWEhd8wwF55QzG8R5zT4ID9GJ4oo5RR3f2/BtY1KoL86Qawaa9/HI6wdF0aSItb MSCTH/7g4gC9r9yEMrjPvF89G5YH6jWX+tpmSvR84EZtSHl1l3Aa13SELbcyvQreDJ XNIo6E1RfyYS6OsJQMy2FzgElWs4a1AuSS4AZhbzNalpUXHynYLyH0xSP/v/3rKyDX clprQHE/aLi040fRlEuVB96Y2EaSgU2SppJcxDRt9r8DZVdd7WyndE8dWGcIxV59w0 QL6dqHT2fQOfyLbnQJiqIEZ1VmKPf/SrnSctpeQih55Z8+7SXGqgGX/jbzevHgyutf OSeZ/NdpQcXBw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id ACBF967EE5; Tue, 7 Oct 2025 11:06:25 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:19 -0600 Message-ID: <20251007170549.541981-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TX5MVTCO5T2X7LSNLEDXN7JA6I26LAKK X-Message-ID-Hash: TX5MVTCO5T2X7LSNLEDXN7JA6I26LAKK 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 v2 05/20] mouse: Replace mouse_press_state_t enum with bool 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 Replace the mouse_press_state_t enum with a simpler bool left_pressed field in mouse_uc_priv. Convert BUTTON_PRESSED/BUTTON_RELEASED to defines since they're still used in the mouse_event button structure. This simplifies the code by directly tracking whether the left button is pressed rather than using an enum to represent a binary state. Clarify the comment to struct mouse_uc_priv while here. Co-developed-by: Claude Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to replace mouse_press_state_t enum with bool drivers/input/mouse-uclass.c | 7 +++---- include/mouse.h | 12 +++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c index 4ade394d68a..43b6514f926 100644 --- a/drivers/input/mouse-uclass.c +++ b/drivers/input/mouse-uclass.c @@ -51,19 +51,18 @@ int mouse_get_click(struct udevice *dev, struct vid_pos *pos) /* Only process button events for left button */ if (event.type == MOUSE_EV_BUTTON && event.button.button == BUTTON_LEFT) { - enum mouse_press_state_t new_state = event.button.press_state; + bool pressed = event.button.press_state == BUTTON_PRESSED; bool pending = false; /* Detect press->release transition (click) */ - if (uc_priv->left_button_state == BUTTON_PRESSED && - new_state == BUTTON_RELEASED) { + if (uc_priv->left_pressed && !pressed) { pending = true; uc_priv->click_pos.x = event.button.x; uc_priv->click_pos.y = event.button.y; } /* Update button state */ - uc_priv->left_button_state = new_state; + uc_priv->left_pressed = pressed; /* If we just detected a click, return it */ if (pending) { diff --git a/include/mouse.h b/include/mouse.h index 560c7d14587..96b75ae1fa6 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -27,15 +27,13 @@ enum mouse_state_t { BUTTON_SCROLL_MINUS = 1 << 4, }; -enum mouse_press_state_t { - BUTTON_RELEASED = 0, - BUTTON_PRESSED, -}; +#define BUTTON_RELEASED 0 +#define BUTTON_PRESSED 1 /** - * struct mouse_uc_priv - private data for mouse uclass + * struct mouse_uc_priv - pre-device private data for mouse uclass * - * @left_button_state: Current state of left button (BUTTON_PRESSED/BUTTON_RELEASED) + * @left_pressed: True if left button is currently pressed * @click_pos: Position where the click occurred * @last_pos: Last position received from mouse * @video_dev: Video device for coordinate scaling @@ -43,7 +41,7 @@ enum mouse_press_state_t { * @video_height: Height of video display */ struct mouse_uc_priv { - enum mouse_press_state_t left_button_state; + bool left_pressed; struct vid_pos click_pos; struct vid_pos last_pos; struct udevice *video_dev; From patchwork Tue Oct 7 17:05:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 553 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=1759856796; bh=0sM7vOELE8GbqccpwYHpZ8QDxQ45Cg+c5vTW65s36tM=; 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=NER6L5teq7omozJV7OMqMgYe6MQtwXEWZYr0WwzuHHRvMmux4ZZQu+emAljR1UAuE 8IdGdB8uyZNZnQAHblXodn8guvBfMHpks3J097A4rXG8B6ppcRZVSoBHG1KTeUGD3i gK1Yj3MiJp5bFHMqSTFXtXAAslUFaf4YLoUJKa8SXw6llKILT63uzN7HZPDDbCOOe0 bqOEjN8vvwRDSSfiKUKJnTR0Sqy7DlI2SWYnXfFlbS+wgmD0zcub79sRdB8QkmXanR MtSs8hf3gQuObSRsqttRZdCSeNQ2ZoCYuSGh1pTUrq4FA2EUUIXiQrHqOxu+Ue97T7 aBnf5wUyzMaOw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3A92368006 for ; Tue, 7 Oct 2025 11:06:36 -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 EFrF4ckXCABQ for ; Tue, 7 Oct 2025 11:06:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856794; bh=0sM7vOELE8GbqccpwYHpZ8QDxQ45Cg+c5vTW65s36tM=; 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=H6YV6MVUtOyt17sbhTeW04FO/ie6xTM9sxEP1KryL6Xt5P+nIvCPF8RzkqP/m0QrC oerZt0/uM6Ka2FkQU1f2Xq7NEKuI+6iWnZvYTxKzd0iKTTsEP635+65rqCwHN6BWw7 oWMI91mSZYI9MnNFWPtIiZ0bmj55GK5FAKs/yZ/zXbiGksxdIoEhgm9O6B0SJ3/jiK SUBz1hYl9Sj53V+Gddoque8cAQ5XYkOwqo/MOd/yb8VUdCX74cXcJc/Lt+2GSYGTck FQZnwDZgG3Vk10jcgNty8v/2DHtfGziltP2Iidp8syq4BVdiBixgc4TuLOhoJk7fmN 76MoZk+MVGOsg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DE44568008 for ; Tue, 7 Oct 2025 11:06:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856791; bh=p6K2CM8xbsUduO93FIxH9YaCW95skBzH3+88J8fDs6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tTldsSFX6QdLz2DM2qeEulU8wPzgBb9AvhC4Mv88GAJr4zdes2md9TX6MTiG/J232 EIAtbOSpOjTGVBRAhtu0a25bk4Sz9i3JMGOeZhGv+HBhNkfhj1c3IdHUANOzf0ILET UL/NVFijqPW2NG4CuxAnQyCAmxBRvJ8EGiFbqSH04KeYTWLc+dRX4a9il27VB8eSqj C/x+ji9YqsIhpt0YA2DAAU0Tndg5qh/3pJcKOGS3wYDmUrd22MqUU7ZbpkglF6pDzu YlA8DQ580wlBhoq3GygYnILrBh79MpmZAv/shrLQLDWeGIvWjCq3BJmg6QDGmnlvK8 nGiQ2c+sdwFpg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D978C67EE5; Tue, 7 Oct 2025 11:06:31 -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 TtTPPlCmyIMV; Tue, 7 Oct 2025 11:06:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856790; bh=9dLIAmbUkSf1Pc4Awx6uqhQfzuGLrNedlzl6RPj7rFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VdqheEIK2UWF6P/yBsRRNT+v5gBc0s0vIquBZi5+r4zviS90FW4tx50ByL25UL12m Y0LIJyrPSuoWIPV+zvnQrQpdj0m1R/CH/mvKI+8BYL26xBFHg+NPkcs/58gElokp+s fgDQFx+fB933LToK9U+dmukqYAKQfgouuUqXg/QjB/FUFe8x1cUGYS1NkCbxtl/ToO K1W0N302KgQzRpZawOrOQCDbG36r6v4c+a75ZEzZBe8b3GrDB4Hm5RLZl5wKAkEoLk 12JPnHTXASnVxO6KOmmw0iOmgqU1j0r1Gp8GJ8CX9SFbq7Tj3JyCaREp0ZnYGO/f6i KWp/blQit7HHQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 537B567DD0; Tue, 7 Oct 2025 11:06:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:20 -0600 Message-ID: <20251007170549.541981-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VOLLTPVHZBZIYVRKT4LGKASGAYEZ56X5 X-Message-ID-Hash: VOLLTPVHZBZIYVRKT4LGKASGAYEZ56X5 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 v2 06/20] mouse: Replace press_state with bool pressed 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 Change the mouse_button structure to use a bool pressed field instead of an unsigned char press_state. This simplifies the API by using a natural boolean type for a binary state. Remove the BUTTON_PRESSED/BUTTON_RELEASED defines as they're no longer needed. Update all mouse drivers, tests, and the mouse command to use the new field name and type. Co-developed-by: Claude Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to replace press_state with bool pressed arch/sandbox/cpu/sdl.c | 4 +--- cmd/mouse.c | 2 +- drivers/input/efi_mouse.c | 2 +- drivers/input/mouse-uclass.c | 5 ++--- drivers/input/usb_mouse.c | 2 +- include/mouse.h | 7 ++----- test/dm/mouse.c | 16 ++++++++-------- 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index c3745fa660e..dd2589c64e2 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -110,9 +110,7 @@ static void sandbox_sdl_poll_events(void) m->button.button = BUTTON_MIDDLE; else if (event.button.button == SDL_BUTTON_RIGHT) m->button.button = BUTTON_RIGHT; - m->button.press_state = event.type == - SDL_MOUSEBUTTONDOWN ? - BUTTON_PRESSED : BUTTON_RELEASED; + m->button.pressed = event.type == SDL_MOUSEBUTTONDOWN; m->button.x = event.button.x; m->button.y = event.motion.y; break; diff --git a/cmd/mouse.c b/cmd/mouse.c index 60210b9f868..ebf496307b9 100644 --- a/cmd/mouse.c +++ b/cmd/mouse.c @@ -35,7 +35,7 @@ static int do_mouse_dump(struct cmd_tbl *cmdtp, int flag, int argc, struct mouse_button *but = &evt.button; printf("button: button==%d, press=%d, clicks=%d, X=%d, Y=%d\n", - but->button, but->press_state, + but->button, but->pressed, but->clicks, but->x, but->y); break; } diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c index 84347951f62..077e2148da9 100644 --- a/drivers/input/efi_mouse.c +++ b/drivers/input/efi_mouse.c @@ -78,7 +78,7 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) u8 mask = 1 << i; if (diff & mask) { but->button = i; - but->press_state = (new_buttons & mask) ? 1 : 0; + but->pressed = (new_buttons & mask) ? true : false; but->clicks = 1; but->x = priv->x; but->y = priv->y; diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c index 43b6514f926..6bfce915e2b 100644 --- a/drivers/input/mouse-uclass.c +++ b/drivers/input/mouse-uclass.c @@ -51,18 +51,17 @@ int mouse_get_click(struct udevice *dev, struct vid_pos *pos) /* Only process button events for left button */ if (event.type == MOUSE_EV_BUTTON && event.button.button == BUTTON_LEFT) { - bool pressed = event.button.press_state == BUTTON_PRESSED; bool pending = false; /* Detect press->release transition (click) */ - if (uc_priv->left_pressed && !pressed) { + if (uc_priv->left_pressed && !event.button.pressed) { pending = true; uc_priv->click_pos.x = event.button.x; uc_priv->click_pos.y = event.button.y; } /* Update button state */ - uc_priv->left_pressed = pressed; + uc_priv->left_pressed = event.button.pressed; /* If we just detected a click, return it */ if (pending) { diff --git a/drivers/input/usb_mouse.c b/drivers/input/usb_mouse.c index 74f093a4b5a..456d84d5e39 100644 --- a/drivers/input/usb_mouse.c +++ b/drivers/input/usb_mouse.c @@ -142,7 +142,7 @@ static int usb_mouse_get_event(struct udevice *dev, struct mouse_event *event) if (diff && mask) { but->button = i; - but->press_state = priv->buttons & mask; + but->pressed = priv->buttons & mask; but->clicks = 1; but->x = priv->x; but->y = priv->y; diff --git a/include/mouse.h b/include/mouse.h index 96b75ae1fa6..62cabf24769 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -27,9 +27,6 @@ enum mouse_state_t { BUTTON_SCROLL_MINUS = 1 << 4, }; -#define BUTTON_RELEASED 0 -#define BUTTON_PRESSED 1 - /** * struct mouse_uc_priv - pre-device private data for mouse uclass * @@ -74,14 +71,14 @@ struct mouse_event { /** * @button: Button number that was pressed/released (BUTTON_...) - * @state: BUTTON_PRESSED / BUTTON_RELEASED + * @pressed: True if button was pressed, false if released * @clicks: number of clicks (normally 1; 2 = double-click) * @x: X position of mouse * @y: Y position of mouse */ struct mouse_button { unsigned char button; - unsigned char press_state; + bool pressed; unsigned char clicks; unsigned short x; unsigned short y; diff --git a/test/dm/mouse.c b/test/dm/mouse.c index c22cd026cb2..893644005cc 100644 --- a/test/dm/mouse.c +++ b/test/dm/mouse.c @@ -75,7 +75,7 @@ static int dm_test_mouse_button(struct unit_test_state *uts) /* inject a button press event */ inject.type = MOUSE_EV_BUTTON; inject.button.button = BUTTON_LEFT; - inject.button.press_state = BUTTON_PRESSED; + inject.button.pressed = true; inject.button.clicks = 1; inject.button.x = 150; inject.button.y = 250; @@ -86,7 +86,7 @@ static int dm_test_mouse_button(struct unit_test_state *uts) ut_assertok(mouse_get_event(dev, &event)); ut_asserteq(MOUSE_EV_BUTTON, event.type); ut_asserteq(BUTTON_LEFT, event.button.button); - ut_asserteq(BUTTON_PRESSED, event.button.press_state); + ut_asserteq(true, event.button.pressed); ut_asserteq(1, event.button.clicks); ut_asserteq(150, event.button.x); ut_asserteq(250, event.button.y); @@ -112,7 +112,7 @@ static int dm_test_mouse_click(struct unit_test_state *uts) /* inject a left button press */ inject.type = MOUSE_EV_BUTTON; inject.button.button = BUTTON_LEFT; - inject.button.press_state = BUTTON_PRESSED; + inject.button.pressed = true; inject.button.clicks = 1; inject.button.x = 300; inject.button.y = 400; @@ -128,7 +128,7 @@ static int dm_test_mouse_click(struct unit_test_state *uts) /* inject a left button release */ inject.type = MOUSE_EV_BUTTON; inject.button.button = BUTTON_LEFT; - inject.button.press_state = BUTTON_RELEASED; + inject.button.pressed = false; inject.button.clicks = 1; inject.button.x = 300; inject.button.y = 400; @@ -161,7 +161,7 @@ static int dm_test_mouse_click_no_coordinates(struct unit_test_state *uts) /* inject press and release to create a click */ inject.type = MOUSE_EV_BUTTON; inject.button.button = BUTTON_LEFT; - inject.button.press_state = BUTTON_PRESSED; + inject.button.pressed = true; inject.button.clicks = 1; inject.button.x = 500; inject.button.y = 600; @@ -170,7 +170,7 @@ static int dm_test_mouse_click_no_coordinates(struct unit_test_state *uts) /* process the press event */ ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); - inject.button.press_state = BUTTON_RELEASED; + inject.button.pressed = false; sandbox_mouse_inject(dev, &inject); /* now test that click is detected (coordinates are ignored) */ @@ -197,7 +197,7 @@ static int dm_test_mouse_right_button(struct unit_test_state *uts) */ inject.type = MOUSE_EV_BUTTON; inject.button.button = BUTTON_RIGHT; - inject.button.press_state = BUTTON_PRESSED; + inject.button.pressed = true; inject.button.clicks = 1; inject.button.x = 100; inject.button.y = 200; @@ -205,7 +205,7 @@ static int dm_test_mouse_right_button(struct unit_test_state *uts) ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); - inject.button.press_state = BUTTON_RELEASED; + inject.button.pressed = false; sandbox_mouse_inject(dev, &inject); /* still no click detected since it was right button */ From patchwork Tue Oct 7 17:05:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 554 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=1759856796; bh=aPMqsABCVTkGUM1GzbQ4PanJqGFkzGnoamdLZkyaysw=; 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=mdlK3ZA+qqrA97eSEhoiqi4GKoNdx6ayqIFsM2lwY1TGIwUTS0hBsgB+egQSVvEiX 5g4PklcX8KepZZFg8r/K0hWU864Xw4X0n2KrrQRWUuk4NoxXy5d9sN4ZIUuzUmPYLr x7A8xHh2OSj9EG7epyZqwziHBlK21tC4kD4hVGz97szRnCFd3RS4A+mfklvaNhV1TX OiKltfhPfTjwsBXdszXUndtLw/fiu4MBQUunOAiyhvJoP7EJv86f/OcuyhPP/+n2mA zUttmr4Nq4+X3Wc7EDk3QEZ3omi2T7E9jg2oriqvDQCiddnfOoSTK2J752POONAP/G VouZM+j0UccGA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D3C268013 for ; Tue, 7 Oct 2025 11:06:36 -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 47zrrgB0fZm5 for ; Tue, 7 Oct 2025 11:06:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856795; bh=aPMqsABCVTkGUM1GzbQ4PanJqGFkzGnoamdLZkyaysw=; 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=hGFLDb6VXALPyJZ7wk5cQtJHbTUNbtCauQakfytZnxhMWDTdaAMcVRcYlYXNJhJ9j sua46GJLtxsRTaR+s+/jTsoc8pguLufocUtjFqip/zGciVoHtASDJuNkA13VeWm9ZQ XYyWb1sokYcRBxf66jGx0hgRD7XZrD/ROUsAGCKHnGXv/Z8s1xgyvnREAAwIoOCWBy /SPfZIC5OALCTACz6V3KVj1R1zQ2OWJCKPcdHgnycB2G4p3Z9aYyQjzHRb5YrUKh4J 8912MgMezwLVUgiIWCp6soaRI9JC/qewgIABJjdIa2svvV9TvUSLfCb4wW6HrdNU03 3s7l4e7DMR95Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 78AD468015 for ; Tue, 7 Oct 2025 11:06:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856792; bh=pMzt9Vo5WtPY5L3v4fYD00daHsB98QLlQ4csaVriFPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p5Vmkp9itnnL6LFrjBLZaGlZ8/27Qn4Dz1GGtCEO4jZdkBfwDQxzkOU9sT9ArK1Wz xFCjSs7Xchmzmm/lO5UbX/MlyM5LbMaI6EZdhcHu4q4HyXU3aLWSXiDFFEMvqHKfi6 OqBSfdL8vltvU8q0sheXE1T4w9vDPebbVxx3MPQIiYw8LRgD8MIt00DcEppkqasJYK UsDiFs1m7F2cOYTifXu9iop098JoXROYf/taGPbdPoXNfC/IXtvGtIoj6B6471MAcW WYthj4tLa/L8GX6nnGinIlgR95NUSi4/XCCGXhLU/CeC9rMZ5pOmLbqW1vxZ5cAAnV L5k0EgKEO7BCA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 89E7267DD0; Tue, 7 Oct 2025 11:06: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 Gl4f6TJBD6bt; Tue, 7 Oct 2025 11:06:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856791; bh=C+gAp1jw6qKoF/XK5px/Z968DCqQaT0T6NRj/GI+V/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXnQLhcYVN2lvudf18bhdCqHObfO/GhCs2pLjK+eatkLK/D5nPdgm1vbY+Nx8fbJv y0nJlNgJibrmmZUqLvGsExGYULSMHJlcXWAVrna0GNYS3zH+0mqP1iUOtc1Aoyg+nS 9V2nAiK9r6DOOhV6dLuSeDpsMAYnAI0jyjZfCXfdG3/46qPkbcVuVYa0FDjdXqYkmi AzHvSYN/LuZLMXrBVaOkIzTAMqwGJh+juPVbQu/lv24vns3xOVFmNsfisk4T2ujNp3 bBwmDpGy0jelEhTfO2Glh9p7fX8kJrn3xggIJhsiMP7fowv6zDVm/Z9bngx7phPNKw LFekgUC8g02Xg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 98A9A67F1E; Tue, 7 Oct 2025 11:06:31 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:21 -0600 Message-ID: <20251007170549.541981-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: REH4CKH5X4IU5PO5VLN6UQCYBL2SEDEG X-Message-ID-Hash: REH4CKH5X4IU5PO5VLN6UQCYBL2SEDEG 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 v2 07/20] mouse: Move click detection into mouse_get_event() 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 Currently mouse_get_click() processes events by calling mouse_get_event() and tracking the press->release transition. But if other code calls mouse_get_event() directly, those button events are consumed and mouse_get_click() never sees them. Fix this by moving the click detection logic into mouse_get_event() itself. Add a click_pending flag to track when a click has been detected, and simplify mouse_get_click() to just check and clear this flag. This ensures clicks are properly registered regardless of whether callers use mouse_get_event() or mouse_get_click(). Co-developed-by: Claude Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to move click detection into mouse_get_event() drivers/input/mouse-uclass.c | 48 +++++++++++++++++------------------- include/mouse.h | 2 ++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c index 6bfce915e2b..7cbe961af35 100644 --- a/drivers/input/mouse-uclass.c +++ b/drivers/input/mouse-uclass.c @@ -28,10 +28,23 @@ int mouse_get_event(struct udevice *dev, struct mouse_event *evt) uc_priv->last_pos.y = evt->motion.y; } - /* Update last position for button events */ + /* Update last position for button events and detect clicks */ if (evt->type == MOUSE_EV_BUTTON) { uc_priv->last_pos.x = evt->button.x; uc_priv->last_pos.y = evt->button.y; + + /* Process left-button clicks */ + if (evt->button.button == BUTTON_LEFT) { + /* Detect press->release transition (click) */ + if (uc_priv->left_pressed && !evt->button.pressed) { + uc_priv->click_pending = true; + uc_priv->click_pos.x = evt->button.x; + uc_priv->click_pos.y = evt->button.y; + } + + /* Update button state */ + uc_priv->left_pressed = evt->button.pressed; + } } return 0; @@ -41,36 +54,21 @@ int mouse_get_click(struct udevice *dev, struct vid_pos *pos) { struct mouse_uc_priv *uc_priv = dev_get_uclass_priv(dev); struct mouse_event event; - int ret; - /* Get one mouse event */ - ret = mouse_get_event(dev, &event); - if (ret) - return -EAGAIN; /* No event available */ - - /* Only process button events for left button */ - if (event.type == MOUSE_EV_BUTTON && - event.button.button == BUTTON_LEFT) { - bool pending = false; - - /* Detect press->release transition (click) */ - if (uc_priv->left_pressed && !event.button.pressed) { - pending = true; - uc_priv->click_pos.x = event.button.x; - uc_priv->click_pos.y = event.button.y; - } - - /* Update button state */ - uc_priv->left_pressed = event.button.pressed; + /* Process all available events until we find a click */ + while (true) { + if (mouse_get_event(dev, &event)) + return -EAGAIN; /* No more events */ - /* If we just detected a click, return it */ - if (pending) { + /* Check if this event resulted in a click */ + if (uc_priv->click_pending) { *pos = uc_priv->click_pos; - return 0; + uc_priv->click_pending = false; + break; } } - return -EAGAIN; + return 0; } int mouse_get_pos(struct udevice *dev, struct vid_pos *pos) diff --git a/include/mouse.h b/include/mouse.h index 62cabf24769..1a3a93801e2 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -31,6 +31,7 @@ enum mouse_state_t { * struct mouse_uc_priv - pre-device private data for mouse uclass * * @left_pressed: True if left button is currently pressed + * @click_pending: True if a click has occurred but not yet retrieved * @click_pos: Position where the click occurred * @last_pos: Last position received from mouse * @video_dev: Video device for coordinate scaling @@ -39,6 +40,7 @@ enum mouse_state_t { */ struct mouse_uc_priv { bool left_pressed; + bool click_pending; struct vid_pos click_pos; struct vid_pos last_pos; struct udevice *video_dev; From patchwork Tue Oct 7 17:05:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 555 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=1759856798; bh=Vl+vcAwRVnxUzPXmo3tJmEI5dUNo1RwzEYdspQv0XeA=; 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=Aj+JHK6bojO/ObwVz/BeaBrz/wq8uX+j7nMAE2ZXtGI/vL4sXQwdcQ+XBD0K+8cBX SmTbCskEeXZrYRxxXB/pb3Rn+qbEt8ljwyy6zt5stLrVYFI16ad8H3i20bJ/EIVP2a VwgxfjLMUuNLoMkvwAt9PuoNuUmx/By6D/gaCI5wrq0i1C6TiAKdcrDu82fycPHc9F NXWU/k1dVspwTVgwejrD3NLxKZD2CfpXN1P41S9Dqx1aWBFf+xchc0jJny2KeCE+TX HlJbkqGW4WUR2sNMAwvnVrEl9BpnAhkIB9ISTnVV0vShe5CMNpF2n7tQ8/AS46JxgC t+lNWnS6t/gGw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EDD2967EE5 for ; Tue, 7 Oct 2025 11:06:38 -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 u8w86EUwQAEB for ; Tue, 7 Oct 2025 11:06:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856797; bh=Vl+vcAwRVnxUzPXmo3tJmEI5dUNo1RwzEYdspQv0XeA=; 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=hl8BM7VSUmFJ71X1sSAB+Uf9l+EEtiXLc+hE6VeJo2PsSe6UwxadmSi3OGGbMkSGh CtSxCdq7ZbrmZSCGVnJUEzTsbtquHR+VDr1MGYlcxCgHw2fug0fHlp3w8KrWPHz/EZ AxbA5uKS1J/fynUST+AUYIoAGJP7rDrJrSzKl6+dlyh9DuOKYB9o6zOrR9dJcr7wvu ZGOkaR26eJG5DK2lMbTV2BVHa1S+gRP4if+ymMpBjtEYbcZqZRdpsf31oPqenea2ds FIcd9AEhLUEGQxTg08ooYIpQAnihrf1/TodZOQOsZnnKjm84M/i7MNKyF5mFXaglSx wy0/hBbEfaoFA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 49E7A67F1E for ; Tue, 7 Oct 2025 11:06:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856795; bh=9y/RFK9Xxmn3CypdcSHMz6nvPGH3UFO6UXxX9x1wzok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZiZNI7ZW9wnOXyoZtErOdHm43ReSqMQwQ3wG6C3RW1vUbONom2xbN/froUl2crk/ aq/1+yjufQJHJUr/6Xec6e85dHVM71V0PB4/r7iGu5b+pyBfqbiOaKFwXBwDy9VJ14 B7w6L8tJQPHGmV/Vw/8jE9MOWJoK9f7llaGAE/DuVdtSO4zpA1Ow/11fyXlVuMcXQT ROv7syhYhcICm9MQpiaMs4AKyrrtJEqOjc+AwqKCEpqHgAP5uvlL5Pdq6nQKdj5rnq r1CohcV20E4tUR455Z+wg21+ubGkvuRuPQzpZYoqyM6XT/qlZD7cEhIzA2jJKN/+wD 296rr5zhqR7Vw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E543D67F72; Tue, 7 Oct 2025 11:06: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 10026) with ESMTP id wCn1mFcp5-PF; Tue, 7 Oct 2025 11:06:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856793; bh=Jm7L6PMvDeappSLVVeQkylLoWAh7rp5+cekUV/hLRr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RFH7rfTmHqlyoI+IMLtYWwrzH42plyCqzTzM0m0sxHKlVU3dBUY3NMhdTYggI4dbu L9xK1qbxU4aA71io4C+bq5uQYxCwtc/6meDF3alOA1koWzQZeBdhIw1Ourhvcy1x9o 7xnKMjETB9A/e/o6wbuVj2TyW1kI1GVKZon0IfaiW2BNVcws3e/mESQtygZDBBOcf8 26LBo/gyW02Uf3HjS2iHTxjVPdwdHje2nDAmcbceD5XqUqJoJL6TU4H5WCH/AhKSt8 zMcYq/Smw/DHUll3+jKdlXc6+JIz3ZIhFUuqTKZD+cHLIGJme0Ve0HRf2vKiRjicfD 3SUKkhfj2bbOw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D9BA367F1E; Tue, 7 Oct 2025 11:06:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:22 -0600 Message-ID: <20251007170549.541981-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BUZIKCG44UT2U776Y6HFF3U3PTPZYNLZ X-Message-ID-Hash: BUZIKCG44UT2U776Y6HFF3U3PTPZYNLZ 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 v2 08/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 556 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=1759856802; bh=MUr7AqRUgUcZoE9sYXo4I4o+Rluf6fkmsttmZS2lgws=; 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=PO75wZFUx8iaPEa5UbF38+cuvx8icLXJV9CLioLr3/dkxH7PfT7Crmhzksbif5ktY 3GtfGzPTyd61RqXb7ykQ09dQ48emp3Jop2NFZiyQIjd8P+RPOKSza9ZtS/Kr1VwAYr cSu02x/nEXF56Ny3ZKW3RupOgA3WgkLBRGUKFzHVO/+MXCTrOThPTZvrBRgPEc/aYN HFfhjrF1/QOtXqaiyDmleP7QeEMFHme/2WZmwVYdzycAMJsbWQNoiUDGQzqeZe4/LH fx7G4tcTzha2lxOuglCL+fH8DxLjLcaAx/tKaKmT19JPHdPDMr59Nh2pIeU1eEDM7V NCtuBOGrkBTjg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E924467FF8 for ; Tue, 7 Oct 2025 11:06:42 -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 ueLDwDAiAFld for ; Tue, 7 Oct 2025 11:06:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856802; bh=MUr7AqRUgUcZoE9sYXo4I4o+Rluf6fkmsttmZS2lgws=; 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=PO75wZFUx8iaPEa5UbF38+cuvx8icLXJV9CLioLr3/dkxH7PfT7Crmhzksbif5ktY 3GtfGzPTyd61RqXb7ykQ09dQ48emp3Jop2NFZiyQIjd8P+RPOKSza9ZtS/Kr1VwAYr cSu02x/nEXF56Ny3ZKW3RupOgA3WgkLBRGUKFzHVO/+MXCTrOThPTZvrBRgPEc/aYN HFfhjrF1/QOtXqaiyDmleP7QeEMFHme/2WZmwVYdzycAMJsbWQNoiUDGQzqeZe4/LH fx7G4tcTzha2lxOuglCL+fH8DxLjLcaAx/tKaKmT19JPHdPDMr59Nh2pIeU1eEDM7V NCtuBOGrkBTjg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D666367F72 for ; Tue, 7 Oct 2025 11:06:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856801; bh=AJ/Diq6yaE1ngj1rdd/bWSjC/KR7LGFFGhqg8t/fy+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eU2+cV2qJBuJfboC4VfIn9JRNLhjvJFLr1N4Eac7SsdbNTEm6uxATbqij8dGXVQ/c fFmoon7Shjepmu/QzrlgJm0eX5YSypWR/6FujmKwKTc+jNT8O5pLfzdDT6qo3XUJgy ZheEB9giGrjdnXIUIneahwnRHPefyFxy2LK19O9L4SHv7yp7S/dbOUJ179UJPTg2pY 29rArnz1S2gU82tCGfAilWYs4w7Amk1RXpNt9/jHRYxaTn6rPcv3BImqvo0TKBnEL7 LYWTarZSGsyx5xPkGsCpy+LQQcq3YiHyrZFlvqzdIUZ2fkHrCe2Il2nmcAxdsJH9/B sptu8ja/LUzpQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 41D3367DD0; Tue, 7 Oct 2025 11:06:41 -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 roPzEJh3ulnU; Tue, 7 Oct 2025 11:06:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856794; bh=b0+jJCiMZluhtnuqlqHB6m59c+oHf88p49zUcWzZqhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WKklUIkEBrIUwP16ayKKGAvFkG2ciDF2VYt8jKymVv/w45i9kVffxtiBlm87k8QiO EYa1GbRJSvJWQ2HVHIZkwRMYNA6l0hG1niL8a1BmNjcC2hesLFJoe4uZPMw0DR2D2P 6LFJP7e+oQM5/CBstYm7P/8DYCAoDFrTZCoFPIjyvrP2EF9RYclCa11J/+BnRWF+EI 0IeSxxN4BUE9QBnu+RTQITZV3jrvLfSCsplT8tHXd2rbG9YwuglyURQw3JzJ1Oadkf gFuHnKgpH0mlZO4lranyl8eQDnP902luEuxI2zfkES0Qu5Dj+WER1ZFFCihN3ZgpQQ odjBwgHhrL2Lg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9469567FF8; Tue, 7 Oct 2025 11:06:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:23 -0600 Message-ID: <20251007170549.541981-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YQC6YBNPXVKMIM5EQC2CHHBY5ASNUQKP X-Message-ID-Hash: YQC6YBNPXVKMIM5EQC2CHHBY5ASNUQKP 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 v2 09/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 557 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=1759856805; bh=bkCnU8ErqibzsiZK4KUk3wO100En4sdRN01hIyJ7p7E=; 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=OtjPPWO5CWtZ0O9vaotnEbu3VBy3yTAFnZGwsKJYVoeagC5IxyMRKHdTKujMKRwbw wAU1l1ek4W3iDOtuQyH6K+0B+lCZ26GW+dAZcBHDNuYRWxzXu86s0JIj1CS7kqJAW6 y2OUyHsvkB3CpCSaxbH99IAadMv5uq4MOPioQw+oC79GToNm6UZUVhWYbOGPbP3r/E k/qCKF/StpWd31IFXggyC6FVBkHAJ2Gtw99RtY6IMPIoewSSK6mCesA5oLhd80ZRvG i8yB324Km6X0dinMqGGvaUGlAvN004vzQF/gPh3G7G9PC1oWjVjf5cziwBMsixago/ OLVyJTo1qZmfg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6D10B68006 for ; Tue, 7 Oct 2025 11:06: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 10024) with ESMTP id ltDSiDwLL2Bc for ; Tue, 7 Oct 2025 11:06:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856803; bh=bkCnU8ErqibzsiZK4KUk3wO100En4sdRN01hIyJ7p7E=; 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=UWr2g3WhVLJPhCLP3R5MZIMMdGxNYgTvcVIqf3Cw0mfuWovcyTiqlsUe2pcDwoyXs 4JWHImCGMsr5TfggTtiHE+nj+0GBfBppHnqeUQMnCJqP2lHjq+bH96me05a0zRcDcv bJfPvV4xmENrSujx9UapsSyvmdXOA+xLQ3bCGsTj80rHFzpJGz6zGPKoAt8d/1Owl5 IHY3YgIazv12PX6KfSVU/cbhMaX/YEPpPCuYYbtJGrfKUaW7DHQV6pmDY7HwMUrfv4 pmzfbq8zV+gKEaGiLZpuD2qo79lFBvfZc3XiIFkl6a4gZE9G51p42EsMkOZQs6nZIy qVp4kgwmc1Bgw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7E6DB68000 for ; Tue, 7 Oct 2025 11:06:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856801; bh=WEk+IlCdhJmDCkhvHHjBzLLgsb7Y0Q7/pK/B+orjlRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cpTEG6ljTZRh8iqLGXSGhh+H+g87ZHRjZzTgT9wqo+2I+uovueZPi3nSukRHf62se tK2nP3weXHfsDdjWmsmAHXf9tKSF0TyS+SrksixHLVKouTn3i88vNqFGwzaYVXgFpR Cej6wBdHGSPgH40xce8ov42YrQMurD2/BxnVYlj5R5CqcUIQXNOJO0kVRyxzGE/aDu RkMPWIRpIX1xRgICiVMKb+A6zp6cGoF3RZQFrIEujUMMuAf0o/YxlLvLEK2uIMaQkn Fj9CTxBOSNjtZKj9wbTgopAhQXhdrX8vQIOH8DhqgFEHpTwnDAe6+F4sNGl4QHp6zC 571hgIL72Gf+Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4AF3167EE5; Tue, 7 Oct 2025 11:06:41 -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 0m6hlWjcWm2y; Tue, 7 Oct 2025 11:06:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856799; bh=9VitpfWa3wFcBYJmIQ998Gu84JXFyNL0SvXpwq4p4ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=veTsoMxlu8s4OxYPjY2Tw6fpwsShVYYrebEBkMNvOgLLbCHZW3K6MItbs1cWQsDSN ZgSmeu5xbsZ7pa2Kj9ahx7G9JOgVkAQWJoRSY0HVspvQClzgLf9bmHB4H8k4LjIAYk iDHDwxSBZXHX8uI02y9odJSCkr8jaQKeq8cBnqDSMPP9ee601WqUyo5CdICcTWYaEC uov3sZWfvudzBIcnFSs6gAA2Y3DfyXCkNBjTb4rK75wPPu1iCuKL7Jay6f9nvyJFS2 ZbuOmKk/cGZeUvvuPtNdFCdNdm5LDEuKSxOGlV5wzh2upLFoyhB5g6zhK8NXLudokq 0R96X4qs8KIuw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 32F0E6800A; Tue, 7 Oct 2025 11:06:39 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:24 -0600 Message-ID: <20251007170549.541981-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SJDXZDYWCPLRLW4KRK7TCZADAXPAZAKJ X-Message-ID-Hash: SJDXZDYWCPLRLW4KRK7TCZADAXPAZAKJ 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 v2 10/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 558 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=1759856805; bh=8OFeqHPt/d7g9BV1m/lJTUcioDMTVTERE0Dcut4OLL4=; 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=s3OBoMDANxDmKBCqZPaY8eI+BNBGolViKtxvgnzbVpzsJYEq7cjms3GS36EAZ+7Q6 egNJR/0oec34Ovv4OGYqUju2Ow/5UrmdzSGdwdUD+zGUpbfLC+HDNUfr5rslappGdj jzuQVrxgogDudsA87lAUW3w4dPvl54NglEr9lGbWbjTXphSVGsaidjFNuLcLi/hRdK h+SWEpTwycCL9zAp4P4g1qhBsuB7B10xPHPFvXAHcdADdDfyQC4WiqCVLQBPhoEGJf SEo2u/l7sRCKCbvurJNf7S5iqjaWyu6Y34m92IoXELXEwJjqHJhfb2m7Pc3nUpqrTq nAPAWQQCbgmhw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C6FF268014 for ; Tue, 7 Oct 2025 11:06: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 10024) with ESMTP id VULgSY4eplKo for ; Tue, 7 Oct 2025 11:06:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856804; bh=8OFeqHPt/d7g9BV1m/lJTUcioDMTVTERE0Dcut4OLL4=; 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=cBP3ZUNdHNjL/R1+oucTw1AdeiByMZZn1+cN4v/81aTuiJoi7B/8+4pwfYGnes7W7 fudcq4moKr0S3x//B+vnPc8YT9wtND5JVseIyPdkLIxOXU5Ivmca7bzIVuytCyk8Dl cyPh5vETi2Sseb2ZJTcLRuZ7Ontwdo3X6KWWefrju4h8FgaNTUMjquTkVpRUjTvx0q jGVdG8OhLDUwi/DKmNrHDEfElnve5C+37Oyjcson2AOFfpB8aRMsFrlROpKaXz5OZj sri9Z6SOIrN98bmrFMTQomYSBkuLQ20qaY6wMlqr/yIdkpsnZP2crbUNQcM4W2WudM 0+9EpBfL5mRHw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5E1FE68016 for ; Tue, 7 Oct 2025 11:06:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856801; bh=Gj6cPPElmO0mYOIJjryH+c0nLixeyWuF1eXTA0sQd2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k4hfmPK4cQsmPbvHrbFtmZpWRoQof5amNlw3A+hGrT50C7ScC5TibM5Ppa6IwGI1K uiYY1xQJVXuEaz7KvGv6rLH/HY6pWnVpKbwxcCBgIzQu84iBSHIOeYTY9yyvCxXNeQ 9QUBvVuKmt4lBd5wWbjBashWKtg7FMdpunG/NrwXaoRXcG0ZbDoXRXN8ahOE7p+z9k Qa/BICum6/zklmmuB6PCUeLi5Xctlt0kPTeeVj4opfj2oiRnw53hi8iOxvrkmdnBiI BK4fVrFAznMFfzgrMEq+PmcYnLa12NcFUBIYfyzafIxd/LdHMOCi1MTNSfaYbO40Oy 0sV41YgcxbmYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D735067F1E; Tue, 7 Oct 2025 11:06:41 -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 72vhNPpp_TZd; Tue, 7 Oct 2025 11:06:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856801; bh=kuEKHPPw/FwGyIRP0dtTtAs2T50wpYqzuEQxoHApJUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMSlJYRRMaP0f8SNQ4butT0UvuDuC+L5BL9LEu8tcKasUmtVp8xkXzxOACuWHCL38 WFAPyfivWVO3+G64JSrd4mx9DIkDFXIe43wVYSP995kHDq6CtTL5qKoVr9GhAj+P5I He3hpvrjkM/oU7y2wmCQDVRr3vpMcLLsOvgbgeYLWJCr33f1vnrPOREg4YNITB7QeJ Gl56qf5QWrX8+2oKgeO6n6mqjMI2v+Q1cRG86vSDjWkTjl9A2BBeNYl7ecYTh3MvHI oh/rByuBXWpfMlwRDGQzTDpQgXvl9EvUPXEypPpTj5224mu5HNQpY6yRxfawqXmkqM AeC0muZWCdQRw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 444E467ECE; Tue, 7 Oct 2025 11:06:41 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:25 -0600 Message-ID: <20251007170549.541981-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DCINBZA7N2VFCUZ7OALURFBGEMP3J2VU X-Message-ID-Hash: DCINBZA7N2VFCUZ7OALURFBGEMP3J2VU 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 v2 11/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 559 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=1759856809; bh=zjAwPyQAyG8UiswvLy/3B4KkBzYtZR9+AUPCixGY/SI=; 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=WkZgcNPQQx777O0a82utG9wo/Epf37GCA5AdNsm5zOZmMP6ZN2Hp4nLUl0V/562la qgARUSXMKFL5Fdr9/+dfCXHdejmLnyBCGtk8WrJ1lXyvvIo5zq0750akAQ3T2y39wR KA6TVIaJwarFte0lZLjs9HLa/v66jIp5+JKpRsx24D7evEbykHoEhzcQ7JoOXXROEN 01f3mGXMIKVmRDgwvUqYDWoLVQ2qK8zI+zepgfSwlItBRT43Wt0JYkqUQhyGVIOYnW k86hRYWVrAaIJP3UFCNvnskCeatnS/EC/t3yHf/Pp3SuVXWtBC7j8C5ak8NhLVePtu 4PNddOj42uQ0A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0664467F72 for ; Tue, 7 Oct 2025 11:06: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 NtldiW2FaUWw for ; Tue, 7 Oct 2025 11:06:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856808; bh=zjAwPyQAyG8UiswvLy/3B4KkBzYtZR9+AUPCixGY/SI=; 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=ElJ0lbJadKQy4hTt/jentEUYbn3wdcAcQ6JkhpNyEjW842Hhs0t3CywWHq2zSd6H5 pMSrAARJS8fGOjCio6Eo+zQH6Sn+L8F/+bliXmUta22OfNMHweUH1c8CoPNDH65tN5 4AEud2x3BUwD0h8fcnjZ9G2uJLmQ5ee4M+3gp34Jt1ZhAKUXQhf2HKTpVO613qbN9S mBkrDYf+AmWvEsmJViI7en4IcKsjFOZ1AIPN7DL/t/jbM5wMtk9zID96VC6VLO550B FTsI18BuTka6mDwUcvxSope2lWqJCAiPQP8DKo9QLUMtJSNucEl45//4p7N0xAtDyH V6YEnIO2KY1kw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA41A67DD0 for ; Tue, 7 Oct 2025 11:06:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856807; bh=AINa3BI9+CGpKiHjMZU04wSCqwcLtC0TqbW2RI8ryNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drvewIcE8iB3DXvHaTWpnoMq4X7dAYrbeEBIRSgIv8TzIE16Q6efKNxuWcTqJYbje FBjt9//VPJLjgTX4vs3Xlx2/K9p8Fu7rFhEOvX2bEdYKidj7ZJai1AL5NN4gID0h7p iopUVZncE6rDmG7Rq/1/FyXHlV0ggKqfd4Nk2vL8o5kcFDSyYXQGRu1zj5muLYko9l Q+881vm3F+bBellRjhK//Acyv/5xobTBtrJmofbLWaC8Cn6kXbW4HIWDCgot3XuUAX fKM4l7vfDWkjL+3Pcqmf51De1I5X2U38WYR7m4eZONIgimXdpLEHgCXtwPNYhz+xC+ hnZBHzYACNAEA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1D19E67F1E; Tue, 7 Oct 2025 11:06: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 mMYRKAf_idLa; Tue, 7 Oct 2025 11:06:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856802; bh=pfPIL9XEqgO2zCFwqufgxqaHE0S3xupuPdT2MtLNpYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MvFl5N8AQm8xM6Xdk9Uz+pfMBbldJGbI8C0e4ueUY+GyWag79LndtPNIXC8VnWIw1 +igryzBY3fJenVLL/Ke+kuPopaznQSf+RcYbPOqY8bdJwa95QucpTjfYwQpOMqvbhh DnoB2KQ1CjwFIZHsUs1bdtNNa9IldQiQJRXo6g7f1WxtmsEjJ12oQhZMwjioiK8TMI H3zPAgH/VBufknDlIEEcZE5zBpsDVjVCNw5pUaX83gkZZF2CpSR5WK2ibJG0Z6FB+g lQ+2tM7Gw7/I/Trj/GkAHE/1JqfdVs5WJ9qgxBq3iKHtFuptiWueOm//eOcsWsj38d UpJlfNcPs+PQA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2426B67ECE; Tue, 7 Oct 2025 11:06:42 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:26 -0600 Message-ID: <20251007170549.541981-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VA5TP3TPGANEJ43C2EPURXNN6FDZPFHM X-Message-ID-Hash: VA5TP3TPGANEJ43C2EPURXNN6FDZPFHM 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 v2 12/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 560 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=1759856816; bh=IvGo6+1itjbg4zwb4TLuK8vJLjn5yEujf/QurPa6qpg=; 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=TLpriWWqA5Dol6xHPVpCyYEyRW+rD7bCMb4AO0w94DvD85zwPudoBAfGuqookSEH5 q4cTGTAG53gpVB+ABLe6SVfnWEmjs1T/bWbBsAWxqZGBHvIteFzrjWlaY6kYA2FtgM aT4iT+O/uNDM95jqAHdfo6g4k8iO3cO3sMZ06D4AMd+0UjvXGTycUUKDopg7jcL8/S u75H9C8AYq1oY8Hn+bX+qneXnABsAH9NJGh1Pp4WAYaWOGQ2OzaQZ1Frmrdvovshlj ikvhbKy8OdRSGOImHo4dY+1RENcWSdI31jZxRCWl4dMIeFn87CHuqW42YPJUYjJaVK s0tk37/5V5kpg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6AA5F67FF9 for ; Tue, 7 Oct 2025 11:06:56 -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 OQn-WSUDKT5m for ; Tue, 7 Oct 2025 11:06:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856816; bh=IvGo6+1itjbg4zwb4TLuK8vJLjn5yEujf/QurPa6qpg=; 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=TLpriWWqA5Dol6xHPVpCyYEyRW+rD7bCMb4AO0w94DvD85zwPudoBAfGuqookSEH5 q4cTGTAG53gpVB+ABLe6SVfnWEmjs1T/bWbBsAWxqZGBHvIteFzrjWlaY6kYA2FtgM aT4iT+O/uNDM95jqAHdfo6g4k8iO3cO3sMZ06D4AMd+0UjvXGTycUUKDopg7jcL8/S u75H9C8AYq1oY8Hn+bX+qneXnABsAH9NJGh1Pp4WAYaWOGQ2OzaQZ1Frmrdvovshlj ikvhbKy8OdRSGOImHo4dY+1RENcWSdI31jZxRCWl4dMIeFn87CHuqW42YPJUYjJaVK s0tk37/5V5kpg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 586DE67F6C for ; Tue, 7 Oct 2025 11:06:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856813; bh=qnAyHJ5NSEzvoV5kpiMc0RZOmdCWxM4h4jZSdkS9xAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIyJxhr1z4+i5HUoa8baj/DsTQEdPMnErUwZaov8OZSBd1aqBAMPAT0yVUfs8VwQE nRxIHOYQFH7spkFPNID89KgQG040uF7M02rjwNb/Ek9dFIOoxBM4VbMFbeBSWmFjz1 0Ag6z9qTJ43Qk5pPleav80DhSHQpR2mwn0uqnaPkN9fi+bmVJh2jC0HeBfaMBHl9iM E0WyEVDYCIyW/0ZcBekIAurM8kHtu0v2e3wA8mPDe1gIcpZBIIUEGKJPTg7AGgJ0qS Pzrzs2q6xB/nyQjyU64GRztTb7GH4VuOA/zsA+2FE3xbIeaADBWIU4Y8ww7tJyAbFM hmmWvensfnKWQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C19C767F6C; Tue, 7 Oct 2025 11:06: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 10026) with ESMTP id vqQD7gwTp1lW; Tue, 7 Oct 2025 11:06:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856809; bh=kR98mObumL/pt2cVITUuzMEuzmj54I7PQtYm/MMIyy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vj5DuAgNW6GNgh4JK4tTMFSoxRpNnzWYmB5lKP2vz2GvPoQKxLXyJOAe6IAjTMgc5 iHefFj7hQ/nPwinPSgOfT7gSPnC0PC4z4UTfQHi79uaMlHv1w4aGhmRhFiU9ug7mih nDjlXiHibO+Zou5Uqj4zKQsVnIe/SUxlqyaiQ5QyWNAZ9tOKw2UoQuVfT+GE81hJo2 5pWnZhEjvnCFaitxHprGOgUoWemj+ginQj979wUmb96wVyNReA60lw5QPNCnq/xMwL h9c5n9lmtz4JIkYjbqb9zo3LTFY4p5yh6ky+DQeYRQnivtdceSdzdanY5wHrCknHmv k/w31TzM/YoGw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D907367EE5; Tue, 7 Oct 2025 11:06:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:28 -0600 Message-ID: <20251007170549.541981-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: RSKNQZ35WCXXNLUIVOI62QBH72FH7GRY X-Message-ID-Hash: RSKNQZ35WCXXNLUIVOI62QBH72FH7GRY 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 v2 14/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 561 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=1759856818; bh=LquCRvmJ36LAIO4VdS6odX+duYUvtADKcHWLFLxwI38=; 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=MQsMOZY7y/WO5ZYEiXVj+RNQPwEhgS3HiddKqMbJrsv3l6rufDs2MQie4ewGH6xn5 2d9MxRLkiU6RiT0oa8eZ5l1Glav9i/Rvx4SKfJUs9m6Uec1wxmpCnFuTPXvxY6a0Nz mGBboEafPuAXWxuEsfweB6qepCIunautseAUid07SdXEkX4Tgaqgb/f++iWO0NvNdR jBJ3IwzNIIbR23QnUdXWvumBt+e086vjwXSOO/Ut7XQi7gzWh+zGDf5y03e6RmY8oL l19ASmvKpWMGGOEdv+iN5KqtM5C0ZLr8Rn9Kuwh6PBwASBAYAOg8fPjtrbOHgQl0/B M3Jh0fHJ+kmSA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EAF8667F6C for ; Tue, 7 Oct 2025 11:06: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 10024) with ESMTP id l258R3nQrWWj for ; Tue, 7 Oct 2025 11:06:58 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856817; bh=LquCRvmJ36LAIO4VdS6odX+duYUvtADKcHWLFLxwI38=; 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=NU12JiWZWfIjrGNxJCcGvWyD84jcg5yUafwfi/2pdmsr8rNXopVX8qNt+P6zvp3XI JCaW5dLRQdriN9JX6KEnCgXT/VkdjB712S7EN9VGxJGP5N7Tlijr//Z2Wjoyyh4eiu zEhkc5Kxa817CicWTR3l6LX9U/vY680waFPsu3U8Osz9aldFtVrwx+kuSL6pJWzdm3 MRZ6ZUk298gKVU2ePAc5J9TagYDoSo2busWCPGmVraxsxVY5JKMwgq6QQog4Uyrob1 sSrzLG84En2TzXYNyvbv/bfY3F7HBSZtfqTZ4zuTxSNJTHRNjR9Q9jPm2Lkry/MUmg whcCiFO7lbzMA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1CBF167FF8 for ; Tue, 7 Oct 2025 11:06:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856815; bh=NCZLOex5b5PRsntdMuElUqwOSME6Dh7N+EQAeEG4Nrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cva6qhfCFiBEWYLQCHJhDHJMHsbzv8jRhCOuIZE/PbN3zcNW7KN0zd86Wv60+ubUz 0VWpUScJOa1b1yEeBnnjN62oaeUR4QKmIQlgfS71fgmjuVJnlNQ+o5etNonUtubOul E5IlmP2rNfq2lQjH3a94dwdrFu3yWv+IY5pvZsM4BBCehr40X5merKAYjz7/rFudPo 2gui7d6qpF3q7LhXi8mesbh/F1MpT6+oY2AyeSQODvu3FCCuExll7hvnmtwlRCvyY0 gHngPVfhKYu9xf6DlNmW+ymx1ZqF8D+tE0IHh+lWCJCDVdb8cHN6cP9rAt9bDAd1fN PCH7cTr+ZVpzg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9380667EE5; Tue, 7 Oct 2025 11:06:55 -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 kj_2qxydjUOo; Tue, 7 Oct 2025 11:06:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856813; bh=NqIAjw24q51NWywgsWfP8KTyN+2xkB2UC1OSskwRLM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZ2LLbxkhXi5IMzYrhs48ddFNXAop3JwQrigQ1NTO1w04PXYr8bGf6b0BYCHpCxlt +37E3NZJ5kGLHysi8ncp4gJu89VZBBuMz7EcYQHzJSC1WvshTvnLpCoIZkeTAEu1mn M6XQQf+Plq84mfNTJEeQ9FBKJMjxcaV0kW2EWT9chzCOJK3PpkU26HIa9DjIiS/viC Qsh3tMIPQ2WipXzNW3K6beyfz/H9jb4UkH3kPztl8+G2NU4LxaKNk6/iVk0Jne8CmM cicQQj0BjTchVTImFUffoTNcLvCGFMyr2VvfMJ2EaWhEk3EP3e8sSyETk9No//sL/P ugDrfhqBecr0A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 75C5A67F1E; Tue, 7 Oct 2025 11:06:53 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:29 -0600 Message-ID: <20251007170549.541981-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YNZRQL6LYHQINJQ6VBCKJNLUEKR4NXVG X-Message-ID-Hash: YNZRQL6LYHQINJQ6VBCKJNLUEKR4NXVG 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 v2 15/20] 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 --- (no changes since v1) 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 077e2148da9..5fdf6979b8f 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 Tue Oct 7 17:05:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 562 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=1759856824; bh=ryocBSIfR3GgyA3+WTiPI9J+QySYHNnoqLDzLH2rLHI=; 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=VFQQaOIhbEUZbleKuEhhY2cJfKt3ZNW6VFlNNQCWX9N+M0P/atysXusCouaMJkXfx K4m/0fbwbY4mwB3Q/R+JKt4gDFb+IQJhUdtykYQGSPJEsxXFEf7lzoy7VMlLuw3Pp1 Q0LNTkmyRgoNq8j4gUYMAjwbpJEK1NclPz+tSBfX65embm1THGz6n1FYr6CBsU9W1j vuUCS9An4kockEimkxs4LYCdA0zyjYhxiIcRCGQF1NfjH6Tl19a9HmJo/3rvTE9E1f 9PI3cmbiBFMuHMRyaw5uEHOtGn9UDUJi4vqswEx6ytsXaxf1g/pwU26pEBLRP1mJEI S/PMOl7XGTWlw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0F4FE67F74 for ; Tue, 7 Oct 2025 11:07:04 -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 qaX5YxtGxsaJ for ; Tue, 7 Oct 2025 11:07:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856823; bh=ryocBSIfR3GgyA3+WTiPI9J+QySYHNnoqLDzLH2rLHI=; 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=qSLZCeK+JusAoih31LNVi5FZJt8QdbPe8vKwsZLl+V7vNdUyNICaa9lESn2YTTXmy 747S+chbvCvYp2Vk68EnzH9ePhoC83Z/WatXzofp8gRw82E0tCEk2E/gblOh7aZMyY C8Ek/ExqkvQHd7IyrPqV/Vw3xRarTaRhJHvWdeKLUlpjLcmhNuFBI1O4XSiaXFsahA x+aF00k4uD9ExykbyCuVMiD/rrocLKaNWMkMRcZ4ezNX9IYV10baRVsSmZzDch82N6 pQcITQ5k9mJHLbz+NhDapi1IZfnNk/OwknkCqCYT1aa+2fRd5XbKm0cX1ocgbd1UJI vIWFz/P8xDm9Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EFC7367F71 for ; Tue, 7 Oct 2025 11:07:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856821; bh=ARGxfD14pHuHHxBBg3P/uIioFJFRTsYMyxcXyv1Lceg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BOpZ7tenC81W2pGItWV1YdpSU8S8MpcWoGBSo9RavNuWTs2JSa9Wu5Zk4YILXfk28 jrq1MlonEABFXqaaijU7dfwxKZnGSAebIkArAPKUzxpsuWNyG6fdnVafn57cCEzf5h ALuFRwpqVCVoEdcCLREDLx3eFc0gBMqqbMO3P1uxXctn2aelGSbkCv1CEoJgGu4SiA E7RfCH/j0dQp9bkfJTsVtwLMxkvMto2Bx3uIy1DMu965guY/lLCtbvshuFDzSYtWZs 5Mkre646wh9JrDTs2wiMgX7aC/IEK6blosNkcwOiQs+Rvzb0wutNFM+JWfmhjy6Dh5 JMtcoljWjx9Cw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 40ED567DD0; Tue, 7 Oct 2025 11:07:01 -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 9tPB7nXuzwNS; Tue, 7 Oct 2025 11:07:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856816; bh=JMMrVggy6+1aiOr9e2jaGtZ+hJvJmJGo3gvRLah9YkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXQJStQ4DOBOEqKOQ5W038KFyOPEkEinVw7R+US7foFmP0BfBn9vradI0nhgu6QWV 2GYfTJSDIR7fZkz4DKmVJC8pJM0Rg7EvOv+dDW2/WX7yx77/v6P6CnssQdbUfhORy7 g4thi5DfXsMEmguJ/npNboxWkwnjh08Leak0ZDK11ITIF+x11/XQ9r/CcMUuKZ9+qI yhnsa2HRmOCJZ2sOXAyQosDTbN79o2VjR8r834W+fGXgno0CDEahrO3v0MDZkATTaY f5BeOdVyjS+8za5qGoNO7PJeCU6GvtTTL0nGfJgjEre9j1m5B8BMudsQxcfELsNp57 6U+x1g4ulOaAA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D13A867F1E; Tue, 7 Oct 2025 11:06:55 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:30 -0600 Message-ID: <20251007170549.541981-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TJVQ5IO2CAJTJAFRLXPDAAHTUITEZ4NG X-Message-ID-Hash: TJVQ5IO2CAJTJAFRLXPDAAHTUITEZ4NG 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 v2 16/20] 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 --- (no changes since v1) 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 5fdf6979b8f..5badbfab066 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->pressed = (new_buttons & mask) ? true : false; + 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->pressed = (new_buttons & mask) ? true : false; - 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 Tue Oct 7 17:05:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 563 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=1759856826; bh=Kwbwq4FNGX582H6j8tqoBdnMglEZHW1VNV36heV/LYs=; 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=Dgt/oV2UaExXx7Zr3y/v7Njsa9I+65jSQJmGtZjCKXViGgu+McCm3A3E4AOZxFbAo U1q9oesy4upqR6Y4oLcYPrsUShKmXTzBJ5tdG9etQR1rtyYEcC6BmzEirUEve/mkfj xbfRX3lDIDWw92StjkAqVDPKQJsezou1FZkD65cQHhQrLpr00wbT3FeRzLGFTsUffR eSXIdHclXxwg0xO+BzXob90tm2lixTXDoxf+Z87Oa52SmEcUwKciZJl4qX1eUv6NVj eTAx8SP/l7Z6SCJGG/+nselqNmPrBEC+iwc4vQw4iNLAkwa//YPnthtv/geSY0QmA0 osR8rbuiiQPKw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 911B667FF9 for ; Tue, 7 Oct 2025 11:07: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 10024) with ESMTP id Deuh6Hex2Eda for ; Tue, 7 Oct 2025 11:07:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856824; bh=Kwbwq4FNGX582H6j8tqoBdnMglEZHW1VNV36heV/LYs=; 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=RfjlrsW5u7GLjE71yQO+4Dn07mKYO3CxhP8oTaQCexsib5W8FCrmouj7kXQenE8Jc auDuaYJfRBgbSYldORlJTaLuxs7MCVdPNsPuLznj4+PKQtoGb8SPWS0MqOYt0asLxK F4FM7goYc8ZnlZo4QVNvQv7bameQoZRAgYfCOSrnulf/RBigjlM18ACYrA06sAiV6D Q2DE8o5rgx/Ou5zEHM6BxzTWJNoQSlfsCcP7llCqTBgSc3M5ZHLpaxLko1kDhPzg+8 i/KCwxkQv6FqJsh8EIrWsfV7VgIEiDD4DZL9fa+oc0RP3AD1Y5WlpnE0U84VgPPzI9 wIiOCf45QouZg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A255468006 for ; Tue, 7 Oct 2025 11:07:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856821; bh=c1+SYBp+oxXPJGxHP/SajHhr8HrAV3n2SLmGoiFliXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mU7OVH0xz0AHJZhYXrWB6JuV4Q04vZl1jUoJ3W1vjqFC+m3lYx5hago0g3OutIDVi BTpoHoiqPUFc5FdlDtVemwdshGnfBrpw74nR4Ev8f8FwthenoLOtEB3ZZcCgWlK0Nz HGEGGOSaNhsseUDPXxV4If8z96+cJYD9k6h5smJpHINtG6QfEVUyV9Y4N+AXskuinB qw5VRNMpuG4+8gD5Nf4QCg8GrLtKLtiEEOw+YEo+Qo+B3QSoMRojHf7gTK1WU/2w1V vz+uwuG/Lxop56uboKtCOVBROrctl76v8zebcFqSnvi//A83QbApTRejpRvD2uA9W1 LmjNwB8/8ePLA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4BA9667F1E; Tue, 7 Oct 2025 11:07:01 -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 8lloGKK24Jjr; Tue, 7 Oct 2025 11:07:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856820; bh=5HxFarTkzuelFw6PPWNmyam1yz6Od+3lKrYHaUnJOQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BjTRa1rh559fdtxjjFg3/ueckgoFKc5tj/gMviKUiRaJrurfhfdLD3Og8Ki8dirmK NtjzBkb5Jq9IoQoecc5oN5rcKWMUzY3a0i+Ad1PJOWG37Sjj0M8Z5tlu7nMptKx9Yt eoZhbltXNQwh1Y+LSSqzZ/H+8FL+ZXa2BurfMar10yla05XYypWYGorvqLvfbP/nXq cQlxasEWn3CzkcL4htQu+pR1vIoX8M4EMjEOB+atKrOjLewQygZPel0UYLz3llCHAs RbVZZWb3mY5TX04XgWS5RaTRpBguAJPKyizWjQDIoF+oUmGMa340ObqzzmwOZz1op9 QBWl+czB4llvg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6DCFF67EE5; Tue, 7 Oct 2025 11:07:00 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:31 -0600 Message-ID: <20251007170549.541981-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HJW2UYCDTAC4SZZMICW3PBA3JRVWFA2E X-Message-ID-Hash: HJW2UYCDTAC4SZZMICW3PBA3JRVWFA2E 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 v2 17/20] 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 --- (no changes since v1) 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 5badbfab066..ced8672085c 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 Tue Oct 7 17:05:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 564 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=1759856830; bh=Dr5GRmEP6rT7iQIWFEN4/6RXJd2F3pqkegxQ/1Fw3kY=; 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=Jrtp9ShwOr+FMAZ5xTDjSFqZQHiKY77PkRJXK7jC8RSDuPRijyzJ6hJ8CQlwHpCpz N1vnIP/j3kdhBiBwg7e+UNcjsgW5kVsRMoiRNWASAe6hb2nLgzvA2W2+vgv9VAyx+X daxdoYNkVUn5731rTzA0cCVDbzm7/vbJc4cJkX/XE6atQJBq0E73ChwIZNTi2SL1j1 ywKWhwiAJP1oyiae4z8zvOKFbHcoSG+VPkuhIoOnMraLPCUfbNBgrJltfXGxyQbnDl ylkupT/kBcsb7fyDWSFICQvDcwkyxxIqDYpa+A8N8nFZtauxkxPiOk5ldgLKAzw/3z ELrg1yLxQ5j6w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4CCC567F1E for ; Tue, 7 Oct 2025 11:07:10 -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 Q8nkjdbgXyeu for ; Tue, 7 Oct 2025 11:07:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856830; bh=Dr5GRmEP6rT7iQIWFEN4/6RXJd2F3pqkegxQ/1Fw3kY=; 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=Jrtp9ShwOr+FMAZ5xTDjSFqZQHiKY77PkRJXK7jC8RSDuPRijyzJ6hJ8CQlwHpCpz N1vnIP/j3kdhBiBwg7e+UNcjsgW5kVsRMoiRNWASAe6hb2nLgzvA2W2+vgv9VAyx+X daxdoYNkVUn5731rTzA0cCVDbzm7/vbJc4cJkX/XE6atQJBq0E73ChwIZNTi2SL1j1 ywKWhwiAJP1oyiae4z8zvOKFbHcoSG+VPkuhIoOnMraLPCUfbNBgrJltfXGxyQbnDl ylkupT/kBcsb7fyDWSFICQvDcwkyxxIqDYpa+A8N8nFZtauxkxPiOk5ldgLKAzw/3z ELrg1yLxQ5j6w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3D30267EE5 for ; Tue, 7 Oct 2025 11:07:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856828; bh=Gt9MCrXj6XoEKXsTNTKcl687qkTp4h9tVPQVMCsGST0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qjcJX5ZZNqptaV/ohiePflrklFHfrHkCIuGn2434X8v6yigHw7jQ1BQgq+WKZp/tT G3rX5dn6/ctnjMvSMeij6BjL3wpGSc59Pyl/sudD+41YjCbCCUBuOjh8EoZkAT4wa5 0e1rxvc5SX4Ga8slPsL4N0R6SRu6MSujk5vykCXJ+8/hnYjIb4dTsKwq0Gpoxu1FN9 jvYrXKv81MAW63RFXIRqoHLTWCFqxQjg/iUSyGTN9OL+9e/kHpN6UpXaIIspblz8WA Yl3ZMOgAt2QEI4v4bech11hTfS9toIiyNiXDyYuLu1dGVksX3BnZN6yr0iePdfHUKZ TpOUmCM48ZKCQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D984867ECE; Tue, 7 Oct 2025 11:07:08 -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 usPUyZdFDG-Z; Tue, 7 Oct 2025 11:07:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856821; bh=rzXrLUqTewrRbHXi2jC5zvo8vEhJ3HeRAsYAxNv0YZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iEjN2KXcwWvWRbU1WnZD7ByvZ9wu+s33nUx6LnRFXKg2NTVH8cnVbzpSffC7o9Byn hhGtB+t2ahUskkjD0OkXLpmuAaHS3jXbjw21YK9G6VzgKdML0suRdcAG49OB0ixCTx PiLTRVUgV2JajVDmZA9pPdiCZsF0RbBwB8Jd1cxA89G2g741q3nKtNx2BsyzBf+U70 z0DR8lfRNKPF+gDaALglWXJdtLkZE8ZaLQVPzYXfwwYgNFK8XdYruGRC3bPhttTXqQ reeOZA1DwOUaFph9XH4MA0WT8YPjgnBowVz42JALlGSPwdl/5oFTejZLIQPhsFL1g1 zfxnnImSJ0+mw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 582EF67EE5; Tue, 7 Oct 2025 11:07:01 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:32 -0600 Message-ID: <20251007170549.541981-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7WOHVFHJPC4QSUOZR5JI6WIQNA5EPU4A X-Message-ID-Hash: 7WOHVFHJPC4QSUOZR5JI6WIQNA5EPU4A 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 v2 18/20] 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 --- (no changes since v1) 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 Tue Oct 7 17:05:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 565 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=1759856832; bh=CfU92ZuDPd40ZzSNRM0wZ09S45ewO+3cELRCDcUGg54=; 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=HfnK1e8aIa5Ea1S1f+HGgd+ovemwuujcWMEC8d55R/1fwvVa3l3lT4tEDtzmvUmpr jdvwjbkeNLOYSmmBcnggGGknIWiMtds2JnTJOWMZeLxiwdSHX+xTYVOGERZpWgJaiv 3zwVbJgTxurh/6qF05iGy4uq7aSg/+RnHcoJxDiyye3GaNSkWUOTSPnuhXdMGFVuXU nHvUQ9CVttEOrUS7E/SO8h+vTXTQablWZoIaY1gLmD73BwJRxq2oBJ+M7uMg1J+uJ7 mbDZZuCTnhmnm7bSpUKRpvRSlcCoysapoPZTNCRvcRb63PO9ko5AUqF638qELscwJL VOk32F84Dzl9w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D40AC67ECE for ; Tue, 7 Oct 2025 11:07:12 -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 epC6RgTZg4WR for ; Tue, 7 Oct 2025 11:07:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856830; bh=CfU92ZuDPd40ZzSNRM0wZ09S45ewO+3cELRCDcUGg54=; 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=d7BDEiZFDj4HD+i81ERB/zzH9CtWvndouB5+gLzRDCfN0CuTZcpe0fhiYzQgeRlTD 9LVAb8VhPRGmdI/5EJn7pq6ran6Ko2eT0Fj+QBqHsYmS+8NOCuA+dQOqSAgShO16LQ y18HK7CHjVUd72/C8db4cInR2msA1l15uhhWzokExM7PgF47ZxT0Ikk4klFBNHUyZg LGK5vAx3rnjiwAbfIXzUym9GH4GgQl86iV5xIzOa0cOUJWfGn1BcRtbOfr9oPinf5v 4haJwwgzvhUzS1LdO7bwTvRQnX4KeF1X1PsZYWoQOdBKcUyVZpObQLZEjrcUhfY544 uDu468x0L5s7g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CB60467FF9 for ; Tue, 7 Oct 2025 11:07:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856828; bh=wk7Jztn04Mo72YoNYoYaoYqv3zY1ZQowbeBwOoI8V/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XO4N5Z1P5znW9nWtS3CRf2gVAoqTz0GACZ6j4+7zqPW3V18h1og0l2Q3sxAmrP5pK WmxsRCDw+hfLtRl6fMWiATcRuzsh/mo2wxrd4GM3ct+7GFK79ZB7SGmEIvVVD2YEAG nzEa8YfIdo+kh08+DRgsX0m9hR/b9eIdNWZhmub46hG6iBeH+BZhm/OdkOiHQ9c+lL LLJWyqQ00HOnfhtP7nK01Y5UoimDkLKfANfETne/u6QhPBtb0cbA74aMYSUHOmII0y 2txreaqwdpqn/rwVEWxccHPKWJX6movk8E+ktql2nz/vUTG/CIw3Xe/YK1IfKif+1m E/Xmo0kv73bUg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DB83967F71; Tue, 7 Oct 2025 11:07:08 -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 4T78eoelDYB3; Tue, 7 Oct 2025 11:07:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856826; bh=RhCdNd/ZvvSbau5uXX4k1RpXkFHBB766fOa4bxMSA+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4+9zRsMLpIISy/uJP8rlAyzlydDgcndlfvQBG/Eryia8NkGBtyG60ChG4OOjowU9 OOywLRpWhSBOAUt/ZxfQo2wbymlL7i06pPc5pLO51i2WD3iqjm1RUh7xMPU20bMaIc OfxpMJ9Oos9VuA3Zm6OjRECOhEuN4B9SyWXfZtKi/oLfgf7JmbmE+uYd1Vo4+mENCt xXNpuQWGT/cBN+jsGR4cgC7U/P7jMBfeNbzZuZDYmxIQqaqLMDL7R//9kdct5SjQlD n7xPzT9sPoFYw5EI98zVvsoJF2NywyIzuevk0NNFBIqn+g5KWNI+5I0OqxnrxrxRrl o+Ms2kdbAq8JQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E6A8767F1E; Tue, 7 Oct 2025 11:07:05 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:33 -0600 Message-ID: <20251007170549.541981-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZBHQXXL2HNSQ2YPAAM3VXVGCAIMSFWUN X-Message-ID-Hash: ZBHQXXL2HNSQ2YPAAM3VXVGCAIMSFWUN 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 v2 19/20] 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 --- (no changes since v1) 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 ced8672085c..b82a26c9885 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 Tue Oct 7 17:05:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 566 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=1759856837; bh=diFoa6jyzyoq/ZNRt9QrruAXrZVKyRtddZkzxKVT6lk=; 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=A8GTIgqEDl5SScQ09Kqyp2+SnYF9l0OODhppnQO7xaniT8jt1gg1iBOyKVfKH7T94 gDPRf2QEct1wkuqvY0XW/DLR6eQIyN+wONMSFv9jMMEPTtt1adm/zQMGvADCHDuIK2 W5xcQJHj4pntRShxfHsm2Xpd57300VA2l2JdbgFh95ZRRlnBlAkPClVLa834lJWQSW 3gg4NKdZNUayxuvthNZSHqw2gkhDZWdjzfBIW2nsgPLGP0HoffA+gU85w8u/7nOAb3 9AeqWVg2SABDMpdGeRXwW5o5qnS7dMQ0hPKcN0BWFWtUINU2cEnTymxvbmbRzSrKw0 X8AC7BfnDWkpA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E446367F6C for ; Tue, 7 Oct 2025 11:07:17 -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 S0wms7F49czq for ; Tue, 7 Oct 2025 11:07:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856837; bh=diFoa6jyzyoq/ZNRt9QrruAXrZVKyRtddZkzxKVT6lk=; 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=A8GTIgqEDl5SScQ09Kqyp2+SnYF9l0OODhppnQO7xaniT8jt1gg1iBOyKVfKH7T94 gDPRf2QEct1wkuqvY0XW/DLR6eQIyN+wONMSFv9jMMEPTtt1adm/zQMGvADCHDuIK2 W5xcQJHj4pntRShxfHsm2Xpd57300VA2l2JdbgFh95ZRRlnBlAkPClVLa834lJWQSW 3gg4NKdZNUayxuvthNZSHqw2gkhDZWdjzfBIW2nsgPLGP0HoffA+gU85w8u/7nOAb3 9AeqWVg2SABDMpdGeRXwW5o5qnS7dMQ0hPKcN0BWFWtUINU2cEnTymxvbmbRzSrKw0 X8AC7BfnDWkpA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D3BC267F1E for ; Tue, 7 Oct 2025 11:07:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856835; bh=Kq5Toz9QMv8umKDP7MP+9XAk/FdHRo2KmadlSKbJuT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePYTLezjImQP2zRaMePeBnCZbHzoiRUbxKKKT60keLVOJMoaTtCFeLeAQa+DXdZpX HTTof+y7F8hdlmOJF0f8nSIZj047LJlsq3x9wz/BHiFep+HIZzqGL6R3Jb6djrJJLf twvR1wmpRC1QrOgbj3fM60mx5sQHNUY9Zw2/fwUXLutDnDM8NAPFtRysXx//fgUl8x YMfxSccafBjhjGaN/fX0FuQOS8/uXfy++G6n6pFfKnQXkX2R75iXnd2+Z/aRZigIf1 TbrN0q2dX9ollvv1n9yDTFD6ckw/TTuQ63BllT6aCjJJCuzwH4zczwieuu688XfGXS yCPpIFgyC9G8w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2BE6267ECE; Tue, 7 Oct 2025 11:07:15 -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 C8cvcTGFQsFR; Tue, 7 Oct 2025 11:07:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856828; bh=xYdXOFwsy/yiBANZHFiKJfJ6mSfaUpeik4PNKp5yRwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dHZYNiXOXSNcc8CSblbpW0S2BWiZQFgoSa64SJZJ/dkU3whKryJ5p9nNWTqaVC4Ru OlRtlzFHSoSMc0jV3nIiVDR53E9LlMnA9uh72wo2Lmn7/jaGP5JVWWu7Cttdd7vDWn AGLSXkJ/hBUNQFKW0tTKdebw0CAOJV83UGpLHNfmpUqOIce4oGAnfgiBJURLHKNIZj nqA33jOanaayhbeaveccqrAAfR1ioYfB0z+pizuAIMa4stUp5U4gNaZOusWpNGspIu cTOceRac5lac0jJqfz4YSlE/4EYhzf0dPrxNbC9Gc4V/mUJLSIyJOFvPjza6wZNTZk OGgVpJcZtq0+g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0CE4867DD0; Tue, 7 Oct 2025 11:07:07 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:34 -0600 Message-ID: <20251007170549.541981-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ABUMUXA5TQGGDNUYXANMND4MTYP4AZCY X-Message-ID-Hash: ABUMUXA5TQGGDNUYXANMND4MTYP4AZCY 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 v2 20/20] 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 --- (no changes since v1) 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 b82a26c9885..087d135f675 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)