From patchwork Wed Sep 18 14:56:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 11150773 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 ADF441745 for ; Wed, 18 Sep 2019 16:42:27 +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 8E88C218AF for ; Wed, 18 Sep 2019 16:42:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E88C218AF 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]:60878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAd2A-0003Bi-7M for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 12:42:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52055) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAc2F-0007x9-IB for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAc2D-0005Z8-LW for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:38:27 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44537) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iAc2D-0005YP-Fd for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:38:25 -0400 Received: by mail-pg1-f194.google.com with SMTP id i18so41614pgl.11 for ; Wed, 18 Sep 2019 08:38:24 -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=EftzDBbXr9x1YUi04c6awZhBAUvksvoO6uHOz2GLInzjw9MiKn0Yh9dnyt8Xg98/dH h8EuU8+Rj/DNG89Q5/i6pjm3CLkM1ML4QfR8lfMMOte4j3o8xFeKLpV80FfVEy6nsdfi 60A3roMb1tgOQg6dc7+a4CDCcb+NyoSrXagibVk6c0Yq+4lWw5KA1AIHwltjX0EQGiF9 d8puMNqdIxWOLI9Evn/ZfyOqEESjn/jaz9xX4VNeP+IhCMzK/rfiIQJtQURZPivIZ7kM PpEcgSa/7kCqPPHQrCTS/uSvX1LjHTAVb8tps+XOHTtjzvg0zwAhOcU33ZKpYM5Xm+On CSGQ== X-Gm-Message-State: APjAAAU1tJ48cz6sc0CeKAn/h0Cas3YqZuNbnzZPrdIqqQUXjaCQ2EnA o8eBkym7TZWygJJYI9vUvG2EnQ== X-Google-Smtp-Source: APXvYqwui2dNepizw4JatJ8OKBdbMKN9XD15Ux8yJmucytEK+b2+zMMFOYapC67K7LSMCR+Z+hICSg== X-Received: by 2002:a63:925d:: with SMTP id s29mr4631021pgn.144.1568821103000; Wed, 18 Sep 2019 08:38:23 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id e189sm6644475pgc.15.2019.09.18.08.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2019 08:38:22 -0700 (PDT) Date: Wed, 18 Sep 2019 07:56:02 -0700 Message-Id: <20190918145640.17349-11-palmer@sifive.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190918145640.17349-1-palmer@sifive.com> References: <20190918145640.17349-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.215.194 Subject: [Qemu-devel] [PULL 10/48] 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);