From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:a17:504:17d6:b0:1be9:327d:8ee3 with SMTP id o22csp8125414njd; Wed, 9 Apr 2025 19:40:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbss580FoZ+hU2vWFyX6ONXOuD5ZzAZE5zTKpVRLY70z0GS3cc0BvpMUtHPHQtQYQVGdfSgFnC23JXwA==@linaro.org X-Google-Smtp-Source: AGHT+IG3+UQWJWrBPwOJo7CGkbFlX4kZQFFLymroQhvLnjLVmpJTRBx8genFpNKp06vqcGPFkc4B X-Received: by 2002:a05:620a:17a0:b0:7c5:4b37:ae49 with SMTP id af79cd13be357-7c7a81c03c6mr104001485a.48.1744252846522; Wed, 09 Apr 2025 19:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1744252846; cv=none; d=google.com; s=arc-20240605; b=EdU/F3ij959zhnHGvKS/kAyF1VIJBg2rhQG4VfR8KySM+3Ozc0LpJ8xKcFREAW/YbU LuLm+r6QBVZEX8FZs+jqVc89/G+ycIcEr9Ue9D5qhtcOCeOLNAE3ZP3984jfDQB3b7/P uR7EbqysPvlXTN0Nbxx9ouFHnPH+fslJphaVaJB3D2EfLUBnRFQywG79tO9JHI5WHUq6 /F5Rn7nM+SAcID7mmljLJb3aV2wW6oksijPfTv1t6U/Q7E5LRdRMntbOpWQ8LrXd3Vo3 u48dHTBDnWDsEawLmzeK4HMa8ctN2dG0BkACCFitKwyMSjn3u+pikuKiFnu0xT2TwJM3 uivg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:from:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to; bh=hZOaTi1KFurhNfs7Pt//Tt9ZUXJJVTNTCs/9DsiKHF4=; fh=9slMQvAVAaDbZF94sUZsatNqTIKawFKtbOHuc7HAk0w=; b=kDxiUGXc9Ud7NXXPdV5pLMsZTHzlENTkNECmgCteY27eMF45ce44Y270gIeWuxHwwz 3eF6Wx6RWuME4OcmxTVtpGWmpZmWvmh3HhM30MeZmRO8MAYgB9cqCr8hxKtOBfzBYHLG Nztlu0mV03hRSfO0MUKqIgxVBLOuJ8p/1KT1AYY/kVYtun7HWeV1kJhD4QsqtXc4gkWf BSYnXKi6M0jjFgEstitERPLg28H8KXBMqN2AK4kFcwPIQxTaZVrzoIYAIQD3M8I3Z6cl td8A+AJZ30Cyt/egH7UsFXmVVyPPG7wwBWTgMKasrOD7NGnRjFWdH6q8WNoLJdcKR7V2 6tcw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c7a8a0bf8dsi21952985a.382.2025.04.09.19.40.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Apr 2025 19:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u2hpO-0001md-AZ; Wed, 09 Apr 2025 22:39:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2hpE-0001fU-3J; Wed, 09 Apr 2025 22:39:33 -0400 Received: from mail.aspeedtech.com ([211.20.114.72] helo=TWMBX01.aspeed.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2hp7-00033O-UH; Wed, 09 Apr 2025 22:39:30 -0400 Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Thu, 10 Apr 2025 10:38:58 +0800 Received: from mail.aspeedtech.com (192.168.10.10) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Thu, 10 Apr 2025 10:38:58 +0800 To: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , Steven Lee , Troy Lee , Andrew Jeffery , "Joel Stanley" , "open list:All patches CC here" , "open list:ASPEED BMCs" CC: , , Subject: [PATCH v2 07/10] hw/arm/aspeed: Add support for loading vbootrom image via "-bios" Date: Thu, 10 Apr 2025 10:38:51 +0800 Message-ID: <20250410023856.500258-8-jamin_lin@aspeedtech.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250410023856.500258-1-jamin_lin@aspeedtech.com> References: <20250410023856.500258-1-jamin_lin@aspeedtech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Received-SPF: pass client-ip=211.20.114.72; envelope-from=jamin_lin@aspeedtech.com; helo=TWMBX01.aspeed.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_FAIL=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jamin Lin From: Jamin Lin via Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: di/IP1Pdf7dQ Introduce "aspeed_load_vbootrom()" to support loading a virtual boot ROM image into the vbootrom memory region, using the "-bios" command-line option. Signed-off-by: Jamin Lin --- hw/arm/aspeed.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index b70a120e62..2811868c1a 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -27,6 +27,7 @@ #include "system/reset.h" #include "hw/loader.h" #include "qemu/error-report.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "hw/qdev-clock.h" #include "system/system.h" @@ -305,6 +306,32 @@ static void aspeed_install_boot_rom(AspeedMachineState *bmc, BlockBackend *blk, rom_size, &error_abort); } +/* + * This function locates the vbootrom image file specified via the command line + * using the -bios option. It loads the specified image into the vbootrom + * memory region and handles errors if the file cannot be found or loaded. + */ +static void aspeed_load_vbootrom(MachineState *machine, uint64_t rom_size) +{ + AspeedMachineState *bmc = ASPEED_MACHINE(machine); + const char *bios_name = machine->firmware; + g_autofree char *filename = NULL; + AspeedSoCState *soc = bmc->soc; + int ret; + + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!filename) { + error_report("Could not find vbootrom image '%s'", bios_name); + exit(1); + } + + ret = load_image_mr(filename, &soc->vbootrom); + if (ret < 0) { + error_report("Failed to load vbootrom image '%s'", filename); + exit(1); + } +} + void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, unsigned int count, int unit0) { @@ -483,6 +510,11 @@ static void aspeed_machine_init(MachineState *machine) } } + if (amc->vbootrom) { + rom_size = memory_region_size(&bmc->soc->vbootrom); + aspeed_load_vbootrom(machine, rom_size); + } + arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo); } -- 2.43.0