From patchwork Mon Oct 6 23:21:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 534 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792987; bh=J4VmHo0NxZhSzXosqDYMVG5ubgYv4qqOoQXkOSLLvP4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=TaITnzhICSxKNQlqGihgHBYf9BLAcIGgTWzLtYY1/vZGzIP5/2bnLEVfLNoQqhYc+ +C/+j9ImqeKApRW96BjrmHQ8Am+IczMNviJraPu0Zd7cFTUpVH8hhBoJdvdnbynPWW fCWZJjUL+RTZkxoxQUsgpGtj3OkJyHPVF+DElpVR7S+ibcOrKM81Y74HbMDEgz3PpM qpAPBB0UpULWy/1VHLVkswdYTFj9jzhgPXBiCPexEQGppo5e3LP6ztFap2oQuVpGTQ pEZApAWh0+1rfoovZ/p1+fvx3+Pu7Ga3m2zJ++l6lAGrbwHp3LPCXVPPPjOo6Ke4Vt lD1DFljX/0o2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0119D67FB7 for ; Mon, 6 Oct 2025 17:23:07 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id MW8VgSlSMf9o for ; Mon, 6 Oct 2025 17:23:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792986; bh=J4VmHo0NxZhSzXosqDYMVG5ubgYv4qqOoQXkOSLLvP4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FeMxV43odLDMfMRyRzNWUwCwDgE4isFNvdI7A76TrLfrZ+UxKVGDq5ijPCPwz0hTX p7E9MRjtf7YkVgvNKTNCQ3qS4OW8LpXjO4GB0Hk/iLRDLENYuoEvtJkQf1Vpt2bAF0 +u02AhNkx32wJTxGjMsgLKlcD8Gmu9ISj4CS+xYSEFStfvt1d9cUr8Vh4by8yF6A8V vdm5NZAvEUdPGcHxP7zvGdPb02gHo3JQoE4VqmX1AloKeNZd1pRXlTKpKvwsYxGIM/ OmMbuuURJDmlo5bdo2CfLcFfj24WMqpo7K7Ur8mXWCYN4JVJzFvH5VNv69FLAje3Nr hdVIdU524CDdg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E2B7967DB4 for ; Mon, 6 Oct 2025 17:23:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792985; bh=8pkmpflqXjvr15QqhI7or71YphoFtEY8NLHkb/uvlKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKbMomKPWm0DHJYOK6lC9+jroT6loao2GhwnxO1G0H85r27yFpZ5nqKLuNpWaBa/8 EHAf1hmiAN9gy5GujyqTMfmiQtka0cFZi5/XhK4ycn7wiQMcXvKcnqCmINx9r/olZQ M8BUGug9dwel+I/uxpu640R778qomT/msfVrW83vLZGIpSp5q8zlGZ0BSKDG1LTskF Q6PIujCDy5AIaS2AAHNZa/FsK/4D5MqyMn7SHJA6y4oJ39tKio7sqHCuM1Ltz4jJO5 2T6ewO1IXKD8v8SoFbnN8DOUep65CYhL/51d2rFgTeA39m6bWCh79v1HygpKp1iR12 eCCcrhCIktITQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE6DA67F03; Mon, 6 Oct 2025 17:23:05 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id J03PNjGx6DWY; Mon, 6 Oct 2025 17:23:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792980; bh=kpowPWEOC5za33yQU/cQozQQ4RPbdg/lAr85bG2pZb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B3rQz25rc+OpScuYg5NrHYV3sFVHUwbzCZ69etsEfs5lc7rawImQFw2FlN2JdzzKV T6t79AN0kzdzTXhXf/5U0S3Gygz6czSiAAdDdAIrPNztrIxZ6JH8A2V+O6xfyv2aVK LKRHqbrHPxEDu7gCuqcGEHpFm/kIfPiSpDpzt8dbtLJVJirK1c4oPadBslSPu8Dr3a XzaYYvuoFcXrR6RATpxyIOMKOOSbH730rQuEVVXaPlSehzGitQ1PNmxEriV6ym+sa3 LEpMB7yqsh4efoqw1Nzg+jwIuWoGtTsmbgGfOc9HdbC9YkA42p9zKv+WctpB+/v4zt DWMgK4l/Y3/eg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 57AFF67F3F; Mon, 6 Oct 2025 17:23:00 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:45 -0600 Message-ID: <20251006232236.2091941-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MIJM3AXOUWMOXTMF5R4FE3ESNSD4AYHP X-Message-ID-Hash: MIJM3AXOUWMOXTMF5R4FE3ESNSD4AYHP X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/17] x86: qemu: Add EVT_BOOTCMD handler to get bootcmd from fw_cfg List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Implement an EVT_BOOTCMD event handler that reads the bootcmd from QEMU's fw_cfg interface using the "opt/u-boot/bootcmd" file. This allows QEMU to provide a custom boot command to U-Boot at runtime. Uses the newly exported qfw_locate_file() function to locate and read the bootcmd file. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/x86/cpu/qemu/qemu.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c index e846ccd44aa..24916d867ee 100644 --- a/arch/x86/cpu/qemu/qemu.c +++ b/arch/x86/cpu/qemu/qemu.c @@ -4,6 +4,9 @@ */ #include +#include +#include +#include #include #include #include @@ -150,3 +153,31 @@ int mp_determine_pci_dstirq(int bus, int dev, int func, int pirq) return irq; } #endif + +#if CONFIG_IS_ENABLED(EVENT) +static int qemu_get_bootcmd(void *ctx, struct event *event) +{ + struct event_bootcmd *bc = &event->data.bootcmd; + enum fw_cfg_selector select; + struct udevice *qfw_dev; + ulong size; + + if (qfw_get_dev(&qfw_dev)) + return 0; + + if (qfw_locate_file(qfw_dev, "opt/u-boot/bootcmd", &select, &size)) + return 0; + if (!size) + return 0; + + /* Check if the command fits in the provided buffer with terminator */ + if (size >= bc->size) + return -ENOSPC; + + qfw_read_entry(qfw_dev, select, size, bc->bootcmd); + bc->bootcmd[size] = '\0'; + + return 0; +} +EVENT_SPY_FULL(EVT_BOOTCMD, qemu_get_bootcmd); +#endif