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