From patchwork Tue Sep 10 19:04:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 11140611 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B9D816B1 for ; Wed, 11 Sep 2019 08:34:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0BEE42168B for ; Wed, 11 Sep 2019 08:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BEE42168B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7y58-00010k-Np for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Sep 2019 04:34:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57094) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7xvm-0007VR-W6 for qemu-devel@nongnu.org; Wed, 11 Sep 2019 04:24:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7xvl-0006SM-Sw for qemu-devel@nongnu.org; Wed, 11 Sep 2019 04:24:50 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46309) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i7xvl-0006S1-NE for qemu-devel@nongnu.org; Wed, 11 Sep 2019 04:24:49 -0400 Received: by mail-wr1-f68.google.com with SMTP id d17so10677559wrq.13 for ; Wed, 11 Sep 2019 01:24:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=4YRrInDZ0nZMnqkxeYbaNMMDWGEYLAY0VfYbuezaFh4=; b=NdgX08xvlfXtmG66MRv20BfDr5vvnjAfuTfDYapZZnOQj4SYisAxVYEk7sFCDn3prd OYrYUyVXF0dLUeyR/FrBdGfhxzT4BAzOKQqL1wiUBK4anw4PrD6enMMMALFmvO0Zs4Jf 2PRPTX717cZyDqpwgcjP2CB9AuYFz4w7h8r2p+EY5BTFXxSHe8R2D2kJLGHlDvDr3pSO fkWn8n74VHRF1/zcwKf2pcQwpDScjMjhtmGJ+EPB2P8+d4/1MtcS6WQnafJ/Uq7taYj2 UnfjNPDs7b9+jP7WVsQFyExNq53XjLUV36N+lgOBOIrsmJG8srOPYIguv9/xCxcfL9JG rhOA== X-Gm-Message-State: APjAAAUvFE6xwM5OBgpVFBtaYljY8ll8gTE6S4ELAuAtSua+rQSs1Qnx dVYpQrLIFXkxPW81peU5B27JNg== X-Google-Smtp-Source: APXvYqxv0C4mt0fovfgKEk29/h6jDH0gnmoSegp+CN/TXUs3DZpXOUpI3znU1rNs9l9j3hPClu01EQ== X-Received: by 2002:adf:dfc5:: with SMTP id q5mr31264999wrn.142.1568190288501; Wed, 11 Sep 2019 01:24:48 -0700 (PDT) Received: from localhost ([148.69.85.38]) by smtp.gmail.com with ESMTPSA id z21sm2012852wmf.30.2019.09.11.01.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 01:24:48 -0700 (PDT) Date: Tue, 10 Sep 2019 12:04:36 -0700 Message-Id: <20190910190513.21160-11-palmer@sifive.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190910190513.21160-1-palmer@sifive.com> References: <20190910190513.21160-1-palmer@sifive.com> MIME-Version: 1.0 From: Palmer Dabbelt To: Peter Maydell X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.68 Subject: [Qemu-devel] [PULL 10/47] riscv: Add a helper routine for finding firmware X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , Bin Meng , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Palmer Dabbelt Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This adds a helper routine for finding firmware. It is currently used only for "-bios default" case. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Signed-off-by: Palmer Dabbelt --- hw/riscv/boot.c | 22 +++++++++++++++------- include/hw/riscv/boot.h | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 4c63b5cf8a..10f7991490 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -69,13 +69,7 @@ void riscv_find_and_load_firmware(MachineState *machine, * so then in the future we can make "-bios default" the default option * if no -bios option is set without breaking anything. */ - firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, - default_machine_firmware); - if (firmware_filename == NULL) { - error_report("Unable to load the default RISC-V firmware \"%s\"", - default_machine_firmware); - exit(1); - } + firmware_filename = riscv_find_firmware(default_machine_firmware); } else { firmware_filename = machine->firmware; } @@ -90,6 +84,20 @@ void riscv_find_and_load_firmware(MachineState *machine, } } +char *riscv_find_firmware(const char *firmware_filename) +{ + char *filename; + + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware_filename); + if (filename == NULL) { + error_report("Unable to load the RISC-V firmware \"%s\"", + firmware_filename); + exit(1); + } + + return filename; +} + target_ulong riscv_load_firmware(const char *firmware_filename, hwaddr firmware_load_addr) { diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h index 1f21c2bef1..66075d0e57 100644 --- a/include/hw/riscv/boot.h +++ b/include/hw/riscv/boot.h @@ -25,6 +25,7 @@ void riscv_find_and_load_firmware(MachineState *machine, const char *default_machine_firmware, hwaddr firmware_load_addr); +char *riscv_find_firmware(const char *firmware_filename); target_ulong riscv_load_firmware(const char *firmware_filename, hwaddr firmware_load_addr); target_ulong riscv_load_kernel(const char *kernel_filename);