From patchwork Thu Sep 24 07:35:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: chen huacai X-Patchwork-Id: 11796487 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 1E9F06CA for ; Thu, 24 Sep 2020 07:41:54 +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 C8ABB23741 for ; Thu, 24 Sep 2020 07:41:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="On4cnCpW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8ABB23741 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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]:53350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLLt2-0003n3-QY for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Sep 2020 03:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLLrj-000269-8p for qemu-devel@nongnu.org; Thu, 24 Sep 2020 03:40:31 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLLrh-0001Fn-8Z for qemu-devel@nongnu.org; Thu, 24 Sep 2020 03:40:30 -0400 Received: by mail-pg1-x544.google.com with SMTP id o25so1408873pgm.0 for ; Thu, 24 Sep 2020 00:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OY9FgndC5NCT/kJU4s296hBSZjcokEukKyx3eYnf/rg=; b=On4cnCpWAmrTEzs4VwxE7Nt96cC6ihwYKCh/s3DCkjNUJ8LbYJ9Puzf4S2CMs3WtyC D1RNky4WdrGmhQ4bil1CO3qaMxlGT5lV6udDzC6XxjOe9rHcad/zsKfVMl+qRc5CubWY EidPMtIJDYbtHBM07a5qJTeIkUpqRNUaZoJj0EJ9+/GCgHjU1ceoOywzN+t/dDcL91Qa lwcth9xzjkR+Nr4KunGwjOPHZ7ptRoBPTThOqCfQJmXasZFhhIUNVzxjquEtJL+VNrpu Soma8yQe38H6Kg2yuvLbcNjbbw8/PpijbWzLaaDLRFgKmVBGq0E+Hu6qcmUYxhNSgS+o cODg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OY9FgndC5NCT/kJU4s296hBSZjcokEukKyx3eYnf/rg=; b=O39tQ1PRKtsR3stUMfcuUZN1Oh9GKD0Z8YOu6+Mgl8DYBIznYgmskKmzEEAqQv8X57 jNP8+naCRzkNWoEFSDFi5ZCR69586idcTXcF7t20LRJxU5EBWxqdhf8ceNJdMjHC3ktK RmhemrxMwqRGbDZ9oJBH7UrPjuSeqQW4ErAWat7CPoIFsjdXvGBnYkNtRINSh4iRTfiN Yq7ViWXgokufh8rXfXZK9jy3kz2NT9vUVKJ43wEGMJP2rfAthDLsu4baMkuxJx8LITLP APPaFISvDEcNRmtFWnOGc/WveZunSEGnkYNXm+IvpmhziAFpn1Lrih7HqVJ606Ic9nTo i+wg== X-Gm-Message-State: AOAM533PpRQVh6dmSpoOInxhtq/LohzpDjIQIy8qUXERKe47x+Nm28nu n6v6E5HLrn3aHHv7+aBM0LQ= X-Google-Smtp-Source: ABdhPJzZYa3E9r2YTKNbp4Qx6b3mXt2zSSLG3zrzVxB9LJmyMdj2glXl154Wun3SUli8mU2Cw7ahQQ== X-Received: by 2002:a65:4689:: with SMTP id h9mr2888601pgr.50.1600933227918; Thu, 24 Sep 2020 00:40:27 -0700 (PDT) Received: from software.domain.org ([45.77.13.216]) by smtp.gmail.com with ESMTPSA id x13sm1777864pfj.199.2020.09.24.00.40.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2020 00:40:27 -0700 (PDT) From: Huacai Chen X-Google-Original-From: Huacai Chen To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic Subject: [PATCH V11 6/8] hw/mips: Implement fw_cfg_arch_key_name() Date: Thu, 24 Sep 2020 15:35:54 +0800 Message-Id: <1600932956-11642-7-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1600932956-11642-1-git-send-email-chenhc@lemote.com> References: <1600932956-11642-1-git-send-email-chenhc@lemote.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=zltjiangshi@gmail.com; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , Huacai Chen , qemu-devel@nongnu.org, Huacai Chen , Aurelien Jarno Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Implement fw_cfg_arch_key_name(), which returns the name of a mips-specific key. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Huacai Chen Co-developed-by: Jiaxun Yang --- hw/mips/fw_cfg.c | 35 +++++++++++++++++++++++++++++++++++ hw/mips/fw_cfg.h | 19 +++++++++++++++++++ hw/mips/meson.build | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 hw/mips/fw_cfg.c create mode 100644 hw/mips/fw_cfg.h diff --git a/hw/mips/fw_cfg.c b/hw/mips/fw_cfg.c new file mode 100644 index 0000000000..67c4a74f4b --- /dev/null +++ b/hw/mips/fw_cfg.c @@ -0,0 +1,35 @@ +/* + * QEMU fw_cfg helpers (MIPS specific) + * + * Copyright (c) 2020 Lemote, Inc. + * + * Author: + * Huacai Chen (chenhc@lemote.com) + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/mips/fw_cfg.h" +#include "hw/nvram/fw_cfg.h" + +const char *fw_cfg_arch_key_name(uint16_t key) +{ + static const struct { + uint16_t key; + const char *name; + } fw_cfg_arch_wellknown_keys[] = { + {FW_CFG_MACHINE_VERSION, "machine_version"}, + {FW_CFG_CPU_FREQ, "cpu_frequency"}, + }; + + for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) { + if (fw_cfg_arch_wellknown_keys[i].key == key) { + return fw_cfg_arch_wellknown_keys[i].name; + } + } + return NULL; +} diff --git a/hw/mips/fw_cfg.h b/hw/mips/fw_cfg.h new file mode 100644 index 0000000000..e317d5b9a3 --- /dev/null +++ b/hw/mips/fw_cfg.h @@ -0,0 +1,19 @@ +/* + * QEMU fw_cfg helpers (MIPS specific) + * + * Copyright (c) 2020 Huacai Chen + * + * SPDX-License-Identifier: MIT + */ + +#ifndef HW_MIPS_FW_CFG_H +#define HW_MIPS_FW_CFG_H + +#include "hw/boards.h" +#include "hw/nvram/fw_cfg.h" + +/* Data for BIOS to identify machine */ +#define FW_CFG_MACHINE_VERSION (FW_CFG_ARCH_LOCAL + 0) +#define FW_CFG_CPU_FREQ (FW_CFG_ARCH_LOCAL + 1) + +#endif diff --git a/hw/mips/meson.build b/hw/mips/meson.build index 46294b7382..c98391ce99 100644 --- a/hw/mips/meson.build +++ b/hw/mips/meson.build @@ -1,5 +1,5 @@ mips_ss = ss.source_set() -mips_ss.add(files('addr.c', 'mips_int.c')) +mips_ss.add(files('addr.c', 'mips_int.c', 'fw_cfg.c')) mips_ss.add(when: 'CONFIG_FULOONG', if_true: files('fuloong2e.c')) mips_ss.add(when: 'CONFIG_JAZZ', if_true: files('jazz.c')) mips_ss.add(when: 'CONFIG_MALTA', if_true: files('gt64xxx_pci.c', 'malta.c'))