From patchwork Fri Aug 16 13:09:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11097685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CAE513A0 for ; Fri, 16 Aug 2019 13:10:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CE7F2887E for ; Fri, 16 Aug 2019 13:10:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71724288A9; Fri, 16 Aug 2019 13:10:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D27E2888E for ; Fri, 16 Aug 2019 13:10:42 +0000 (UTC) Received: from localhost ([::1]:55654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyc09-0000NX-8M for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Aug 2019 09:10:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34231) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hybzF-0007iu-Og for qemu-devel@nongnu.org; Fri, 16 Aug 2019 09:09:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hybzE-00007Y-OF for qemu-devel@nongnu.org; Fri, 16 Aug 2019 09:09:45 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:36647) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hybzE-000072-Iy; Fri, 16 Aug 2019 09:09:44 -0400 Received: by mail-pl1-x642.google.com with SMTP id g4so2452660plo.3; Fri, 16 Aug 2019 06:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=yuaXKmmLPWfovkIgluBK48pRtWPxELyUrBylOTt4Png=; b=KwlypChBtTjRMWOA27Qq29c/ToSklS6i+kJe+d8qDlmmJ5gvOHp+J3V2XHcg0m47tV gLhR32m0Am6pgP9DP1cCfO/ys9NmjMUcPnaKRpKTEcTDyh0X9xFua3Wq7iC16jl7ogzQ FAx2qLU7PtBjk44Vd6oyfWaE9s/y6KbpaH2jCVvu7lwiddzr6ZZU/NvJfsNMUuOMpA5/ hQNB19tos9RKsXyWOH71vhwwMqw2ybYlwRx5yE7i/p205lm6jfjBMF/hzubX+9MV/nGu oGeXbwtyg0//MzY6+Iv2RYBZThH6VWUwptYOzhSWFgcNVN2UXNDB6yLrlgJoh10vANZ5 uwPA== 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; bh=yuaXKmmLPWfovkIgluBK48pRtWPxELyUrBylOTt4Png=; b=XkSBCCwO5WVzYG3FjkMEchPa9FPs6Gn+uCp8+MUwebtCJ8yGtt1j6DSTcRHSoqnhOC kY7549E7xFEJ425FbHqlbKmZVdRAYcVe0gsr7hCNs+QbwV13ggl3T7Vvvh47J4c9yvRZ 8hsUe8+HNr0vkx1aBavtJBs9kEScoDyQV+CSaKh27u39QRZHsOPti/6Swx8nGk3O6FkS 6XnA3A2v2Xl8lmMrx1PNOe7sGihf/IrBCJr14GhkNERtEimfLlPVMoBk/i9dqaLszidD k+jkWAkkDEKwgxqJYnKSo0othsWwne2yaoDyugEgXuQ2CXz4BIkWwHK/t6NAjn2GtkRP 1sJw== X-Gm-Message-State: APjAAAVvL6YM30eZSLwcpRzv8jWov1FFdFKLW9p2ZxoJ0yDe8gQUKHew MMiXvjBMLKkhEXEgNs69B88IxQ4N X-Google-Smtp-Source: APXvYqyw0mjtn7hcDhNeS0gixQT4mlj6BYEUuFZrWIx0zqHUx7CQVaAD+E6vz8h+nSC6m9OizNU6fw== X-Received: by 2002:a17:902:b698:: with SMTP id c24mr9292930pls.28.1565960983750; Fri, 16 Aug 2019 06:09:43 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id t7sm6122743pfh.101.2019.08.16.06.09.42 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 16 Aug 2019 06:09:43 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Fri, 16 Aug 2019 06:09:35 -0700 Message-Id: <1565960976-6693-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1565960976-6693-1-git-send-email-bmeng.cn@gmail.com> References: <1565960976-6693-1-git-send-email-bmeng.cn@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH 1/2] 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This adds a helper routine for finding firmware. It is currently used only for "-bios default" case. Signed-off-by: Bin Meng --- 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 6b7d322..a122846 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 d56f2ae..1718a8f 100644 --- a/include/hw/riscv/boot.h +++ b/include/hw/riscv/boot.h @@ -23,6 +23,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); From patchwork Fri Aug 16 13:09:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11097687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8F0913A0 for ; Fri, 16 Aug 2019 13:11:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9873C289EF for ; Fri, 16 Aug 2019 13:11:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CE5C28A04; Fri, 16 Aug 2019 13:11:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3FC43289EF for ; Fri, 16 Aug 2019 13:11:59 +0000 (UTC) Received: from localhost ([::1]:55674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyc1O-0002Fp-90 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Aug 2019 09:11:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34247) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hybzG-0007j2-Pd for qemu-devel@nongnu.org; Fri, 16 Aug 2019 09:09:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hybzF-00008J-Rj for qemu-devel@nongnu.org; Fri, 16 Aug 2019 09:09:46 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:41114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hybzF-00007g-Me; Fri, 16 Aug 2019 09:09:45 -0400 Received: by mail-pf1-x442.google.com with SMTP id 196so3111965pfz.8; Fri, 16 Aug 2019 06:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=KggTVOC8yADf6NdFItK5nRQaRea4jdHEMeQcbzejC6g=; b=mA0k//C+V6lA5g/zaeyDjmiVv3EG0VEz3PpqUUkRTyYnrq5xSbLK+z0H88X9Q92II9 QcEDfmAC+NWae31DDqugwMix4jBYJCeAOOpDEo0sQu7lPIkhT0LNo7cAXKPrkxF/bpj+ 54LnlbGSu5P5wftd+5uGTRxVR19tXbYEiHk6pFvRwzzy137B/wATJtxz1ns20ROnPL1I yGs65lGthgbCwRtq5dwkhUswQ/XKsHpKwuDSEPN+DPlzU+8zUDpn3kamwsBJxHX+8Y5k ZI5bVs7pXThtunp1SwJeoSMpmoDhl4BCbrxjFdk4Pnk6rzWsxUxot+GkRhcTpFv9qmAn 1iSg== 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; bh=KggTVOC8yADf6NdFItK5nRQaRea4jdHEMeQcbzejC6g=; b=E7bP1G/fPb5q6DiEk557D1/+79j3xQ7Nt5Dsaq5tNBw4f3pL/sYH0e9e/v49G3wi82 JWjNHL9s8aHGSLfyLhhm6yBbHQfP3QLBq2dRMv1P3IaDy5AzPpbVDn7XPVDlwyM8ly5b 5KciNKqF7n6G6bJieHN/c/TsbEVYNYjnqVr3vHH97y0d+I4Flr5Dj15QVnmBHWgdhUA3 Ym4Dl/UXyxf7Ezzf7dJ4Ne8RJwKRxqRPT30WnEpyX9yX9rDAR87Mg5Wc2vnBg3y7+5Cp rjFJC91MKMsejPisYX5oLxbwrnqzYPvbaFwW6jy+9VkU9pPL2ggpeym3ohMgHUpTo2Zz XFMA== X-Gm-Message-State: APjAAAVcwxkM6ii2On2tltdU3bNzYp7yPmeqeSXbZet2LBt1+LhdRoYL Ydjp+lYAQNeZicl7uMuxgXtev2z0 X-Google-Smtp-Source: APXvYqz6CBpoTac2OQPKIaEBQs+OXPrgxtfACU+3Zi93xIhcpMyVhViY8f4qF/1Am56ixAUQdjm7bQ== X-Received: by 2002:a17:90a:374a:: with SMTP id u68mr7159655pjb.4.1565960984792; Fri, 16 Aug 2019 06:09:44 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id t7sm6122743pfh.101.2019.08.16.06.09.43 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 16 Aug 2019 06:09:44 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Fri, 16 Aug 2019 06:09:36 -0700 Message-Id: <1565960976-6693-3-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1565960976-6693-1-git-send-email-bmeng.cn@gmail.com> References: <1565960976-6693-1-git-send-email-bmeng.cn@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH 2/2] riscv: Resolve full path of the given bios image 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP At present when "-bios image" is supplied, we just use the straight path without searching for the configured data directories. Like "-bios default", we add the same logic so that "-L" actually works. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- hw/riscv/boot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index a122846..15002d3 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -72,14 +72,14 @@ void riscv_find_and_load_firmware(MachineState *machine, firmware_filename = riscv_find_firmware(default_machine_firmware); } else { firmware_filename = machine->firmware; + if (strcmp(firmware_filename, "none")) { + firmware_filename = riscv_find_firmware(firmware_filename); + } } if (strcmp(firmware_filename, "none")) { /* If not "none" load the firmware */ riscv_load_firmware(firmware_filename, firmware_load_addr); - } - - if (!strcmp(machine->firmware, "default")) { g_free(firmware_filename); } }