From nobody Fri Dec 19 04:32:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549388109825917.2683186718125; Tue, 5 Feb 2019 09:35:09 -0800 (PST) Received: from localhost ([127.0.0.1]:35612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr4ch-0000U2-MN for importer@patchew.org; Tue, 05 Feb 2019 12:35:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr4AZ-0001zf-W7 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 12:06:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gr4AT-0000cJ-7u for qemu-devel@nongnu.org; Tue, 05 Feb 2019 12:05:59 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:55007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gr4AS-0000TV-OX for qemu-devel@nongnu.org; Tue, 05 Feb 2019 12:05:52 -0500 Received: by mail-wm1-x336.google.com with SMTP id a62so4449531wmh.4 for ; Tue, 05 Feb 2019 09:05:42 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id w13sm5583164wmf.5.2019.02.05.09.05.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 09:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xP5Vb42Qvz2Z9D5/Z8GqBAI9BSFPshBAy9apTqTJVpE=; b=RABjv4wDHQY8gzp4KP5a6/LzsPTgCNjvfwXbh+UZMdpDDOIilmIx9JhsB7gcbHXVvv Es5rSi435PhZSKtpuFEALjsd5AlOOpjH1p2TjlwpxGnqKMZaW+a4ZNJyWaFdYuz9J1xT Wdgk/911ziGHaAR2O8qkfVcJ1a2qgvQHuaoHve5HXEMo5Srhdi6z9b6IzlQc7VRg6fpR ggpcRtHqF3QhJwWJXNQmY/oN+QIK/Kopr3j+68zFxywstrg7hVQZlgUCzjvW0vnO4U0u u7r0ISSnQxHDQld6hIimMPb+UTQyXYvT3dunqI/ZkxeDy67BOTbSeU4cvWnRMVeBunhN TpHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xP5Vb42Qvz2Z9D5/Z8GqBAI9BSFPshBAy9apTqTJVpE=; b=T+L0CdmZP2wv9NZ1kRegOtP1FZ1wHwayraeXBUce44CeniNBWd15EVCVQLoLtLBrCl pPKe0ETvTcGM+mdZvZwT4Z7dobK/mezmGMxJSS/iTSU9UuPMfYab5ZapVVMeYH5GLJX3 al1kzBDmulplE51Kdki/IwRQcv2Lvccjzv8IvqVIZcXGTYYQ7UBYxymik+s0uqxixTmV 2rmSWJH/WkoqzEFveCuZaVKvfaXGDFMmiv12byqU543ln3NpqaVVB5Wlgt5gCA/Npk5t U8/Mxzz7gALspr8Y0MEpVzSqbsShyirwWaK7qKJcKwDOd/BUFLa6LJbrBl9gWCc1QrkK BJBQ== X-Gm-Message-State: AHQUAua6G7grafvnkXsqVGW2dV7EZL0xDoT0m0ZUFWpjr3i+noXYKlBM 5JvsgbKxrt/fKHJ6yJegyXav0ZvaajhOJA== X-Google-Smtp-Source: AHgI3IbExoh4BAUQhD229d2DzlbWv3DIH1kTczOI5xp2mDCe5HYwaU+11HcL91B9KvHShMy/e9Jc1w== X-Received: by 2002:a1c:a895:: with SMTP id r143mr4320106wme.95.1549386341239; Tue, 05 Feb 2019 09:05:41 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 17:05:07 +0000 Message-Id: <20190205170510.21984-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190205170510.21984-1-peter.maydell@linaro.org> References: <20190205170510.21984-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::336 Subject: [Qemu-devel] [PULL 19/22] hw/arm/boot: Factor out "set up firmware boot" code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Factor out the "boot via firmware" code path from arm_load_kernel() into its own function. This commit only moves code around; no semantic changes. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Igor Mammedov Message-id: 20190131112240.8395-4-peter.maydell@linaro.org --- hw/arm/boot.c | 92 +++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index cd7373a8da2..2d4f710395f 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -1138,6 +1138,54 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, } } =20 +static void arm_setup_firmware_boot(ARMCPU *cpu, struct arm_boot_info *inf= o) +{ + /* Set up for booting firmware (which might load a kernel via fw_cfg) = */ + + if (have_dtb(info)) { + /* + * If we have a device tree blob, but no kernel to supply it to (or + * the kernel is supposed to be loaded by the bootloader), copy the + * DTB to the base of RAM for the bootloader to pick up. + */ + info->dtb_start =3D info->loader_start; + } + + if (info->kernel_filename) { + FWCfgState *fw_cfg; + bool try_decompressing_kernel; + + fw_cfg =3D fw_cfg_find(); + try_decompressing_kernel =3D arm_feature(&cpu->env, + ARM_FEATURE_AARCH64); + + /* + * Expose the kernel, the command line, and the initrd in fw_cfg. + * We don't process them here at all, it's all left to the + * firmware. + */ + load_image_to_fw_cfg(fw_cfg, + FW_CFG_KERNEL_SIZE, FW_CFG_KERNEL_DATA, + info->kernel_filename, + try_decompressing_kernel); + load_image_to_fw_cfg(fw_cfg, + FW_CFG_INITRD_SIZE, FW_CFG_INITRD_DATA, + info->initrd_filename, false); + + if (info->kernel_cmdline) { + fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, + strlen(info->kernel_cmdline) + 1); + fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, + info->kernel_cmdline); + } + } + + /* + * We will start from address 0 (typically a boot ROM image) in the + * same way as hardware. + */ +} + void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) { CPUState *cs; @@ -1165,49 +1213,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_in= fo *info) =20 /* Load the kernel. */ if (!info->kernel_filename || info->firmware_loaded) { - - if (have_dtb(info)) { - /* - * If we have a device tree blob, but no kernel to supply it t= o (or - * the kernel is supposed to be loaded by the bootloader), cop= y the - * DTB to the base of RAM for the bootloader to pick up. - */ - info->dtb_start =3D info->loader_start; - } - - if (info->kernel_filename) { - FWCfgState *fw_cfg; - bool try_decompressing_kernel; - - fw_cfg =3D fw_cfg_find(); - try_decompressing_kernel =3D arm_feature(&cpu->env, - ARM_FEATURE_AARCH64); - - /* - * Expose the kernel, the command line, and the initrd in fw_c= fg. - * We don't process them here at all, it's all left to the - * firmware. - */ - load_image_to_fw_cfg(fw_cfg, - FW_CFG_KERNEL_SIZE, FW_CFG_KERNEL_DATA, - info->kernel_filename, - try_decompressing_kernel); - load_image_to_fw_cfg(fw_cfg, - FW_CFG_INITRD_SIZE, FW_CFG_INITRD_DATA, - info->initrd_filename, false); - - if (info->kernel_cmdline) { - fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, - strlen(info->kernel_cmdline) + 1); - fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, - info->kernel_cmdline); - } - } - - /* - * We will start from address 0 (typically a boot ROM image) in the - * same way as hardware. - */ + arm_setup_firmware_boot(cpu, info); return; } else { arm_setup_direct_kernel_boot(cpu, info); --=20 2.20.1