From patchwork Tue Jul 19 17:59:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 591670 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp4215410max; Tue, 19 Jul 2022 11:11:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vZTMYdmEh/hBdjqr6wVg3fbul0hgtzx0jXvU0JcrABMKvyEE0GSV3N1PIzEyYUiNEXKScB X-Received: by 2002:ac8:7dd2:0:b0:31e:f857:a8ab with SMTP id c18-20020ac87dd2000000b0031ef857a8abmr5347385qte.346.1658254260495; Tue, 19 Jul 2022 11:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658254260; cv=none; d=google.com; s=arc-20160816; b=z6/dA/0UHuHWZd3j2NEZdyYEJ35sxY/yF3pk+FLmdlL90Rmlpw1LVxYbotJZAUNpW9 yLmPj6bbrudcAxHnAS7hCE6hGJ0LtwJmQycraCvqvYd8ukeiYgJ6T2swloWQmfFm98LS fh5uTFRtDBw8JLf2cqYi5tyBxAnccAoTG+4VJoZwRZg89TkT9QahG396y91Bc7dawUjA RpGWDa0zk6DOiMzFhJNOUlJ0GeJekxrF48zDIr6P9lZZUF7SBD8tHsrrt0A49RzY5ZSa 3ZLauDZMFhUD3w3K1UWJwdO7n2f0b8NsCQxqRFocBd40hSHq+5tw5HD3FAqCW7g8aI/i sZeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MwT6lAxq0oWE+Pulu76+OAU+DA1mJYbR9ucIFpn3LTM=; b=wgxacQWQXqvepTPSltDlLPu7TOc0hXnmqAUd8gKI1LZhxHlRCfxJUrurp7+bFieI6g wJdZ6P4nPdWC8L1UDCtQ93L5TRDmuw1AVSk8ZC8XRCNSoQdhgQiHhcdlEWzBCFMWDXMT lImmDgWMhPFNuZjVRfzDpneW3Dvvc90ndcxbbLjvsdvkpD8/qyG64VvKgxmMGYD4EZmo Uf9awAsKiH4/y/bWjPeiZchsJJ7Q2p4bUi6jCSwt0zTPssAPvkD9U2DYlViEAQlD3s9b jQcjiRlwhemNSDrFNFP48UPeRaG8qbypc4FdSVHZzC8XlA2HajBb+S3Bqxw5bee2VPOr TXMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jexCdY1U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bq44-20020a05620a46ac00b006b5e45ff36fsi3725434qkb.749.2022.07.19.11.11.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Jul 2022 11:11:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jexCdY1U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDrgR-0007Sh-WF for patch@linaro.org; Tue, 19 Jul 2022 14:11:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDrXK-0007y3-Sp for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:01:34 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]:36711) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDrXJ-0006IE-1c for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:01:34 -0400 Received: by mail-oi1-x22b.google.com with SMTP id u76so7655002oie.3 for ; Tue, 19 Jul 2022 11:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MwT6lAxq0oWE+Pulu76+OAU+DA1mJYbR9ucIFpn3LTM=; b=jexCdY1UR8DhJVwTht2ePzGHiM/dzn5Rb0b1K7BCIksEg68qAguWLHPDEfVCY6v2n2 uxm/Ik+0j6YF4yiqkn5rhVZJ+AAYvXuu9NNphfidNfj/YcA5el3Dml/TyL0EJ5iHLfb2 GrAjNU0joA0Ejbh9jshvdofJE7lTs21I0aDxMYb37URlvaAXUMm47MoFrcdKSkcwuFxi m5MX87uKVpPZ4yrD5lhacXHgTzAmYdcmBTCiwByX4fwwrgWkkATWGhGGULzMQ6eNwCmk 8UHwNaaEHSyermECFAhqFiPoAh12dMByNweryKge7M0bCrwyI/wkE/yKxAquZegFiNUZ WP6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MwT6lAxq0oWE+Pulu76+OAU+DA1mJYbR9ucIFpn3LTM=; b=4Dj0O+yQfJapJqLlOJCuCDPPa5plpgY4ECproengCgNv8krKC6kyTeiaP7uk34VLQb cataSW04Rl1W2b24hTKsaSxKO2yzmqRQD3h9Vw+mSch1KCyOlL4MT0DIFqh6XjR9+ikm l8vaeHq4d8PGh64r+MYyUadUuaQQgQ2pOMvLAk7tUX+bv6x5FDQ7IxIikQ1/xWjUHE8Q BBG/79HtTG8rvbxvG8liXmBW3Ccbo9WGV/KNJUHNQli++J/MzLzbeRD+VsCDWaohZ26n 1Bjr4ND5ckk9RVjniKrgbdZpptBedE7R8AYj42Ey9j4yov6XM8/JLqow5Rtxmv8s1JAL WbHg== X-Gm-Message-State: AJIora+GOsB7VFTxD25kzLloPHF5QCyUKNkvV2SRbuVFZsPW9RtizZlj ke4einvWtqOOXd3nfvgTxp6rH5gE2wuDZi+5 X-Received: by 2002:a05:6808:169e:b0:331:522a:4521 with SMTP id bb30-20020a056808169e00b00331522a4521mr307938oib.293.1658253692353; Tue, 19 Jul 2022 11:01:32 -0700 (PDT) Received: from stoup.. ([172.58.110.182]) by smtp.gmail.com with ESMTPSA id c25-20020a4ae259000000b0035eb4e5a6cesm6286747oot.36.2022.07.19.11.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 11:01:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Xiaojuan Yang Subject: [PULL 19/21] hw/loongarch: Add smbios support Date: Tue, 19 Jul 2022 23:29:58 +0530 Message-Id: <20220719180000.378186-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220719180000.378186-1-richard.henderson@linaro.org> References: <20220719180000.378186-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Xiaojuan Yang Add smbios support for loongarch virt machine, and put them into fw_cfg table so that bios can parse them quickly. The weblink of smbios spec: https://www.dmtf.org/dsp/DSP0134, the version is 3.6.0. Acked-by: Richard Henderson Signed-off-by: Xiaojuan Yang Message-Id: <20220712083206.4187715-5-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson --- include/hw/loongarch/virt.h | 1 + hw/loongarch/loongson3.c | 36 ++++++++++++++++++++++++++++++++++++ hw/loongarch/Kconfig | 1 + 3 files changed, 38 insertions(+) diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h index ec37d86e44..9b7cdfae78 100644 --- a/include/hw/loongarch/virt.h +++ b/include/hw/loongarch/virt.h @@ -33,6 +33,7 @@ struct LoongArchMachineState { bool bios_loaded; /* State for other subsystems/APIs: */ FWCfgState *fw_cfg; + Notifier machine_done; }; #define TYPE_LOONGARCH_MACHINE MACHINE_TYPE_NAME("virt") diff --git a/hw/loongarch/loongson3.c b/hw/loongarch/loongson3.c index 88e38ce17e..205894d343 100644 --- a/hw/loongarch/loongson3.c +++ b/hw/loongarch/loongson3.c @@ -30,11 +30,45 @@ #include "hw/misc/unimp.h" #include "hw/loongarch/fw_cfg.h" #include "target/loongarch/cpu.h" +#include "hw/firmware/smbios.h" #define PM_BASE 0x10080000 #define PM_SIZE 0x100 #define PM_CTRL 0x10 +static void virt_build_smbios(LoongArchMachineState *lams) +{ + MachineState *ms = MACHINE(lams); + MachineClass *mc = MACHINE_GET_CLASS(lams); + uint8_t *smbios_tables, *smbios_anchor; + size_t smbios_tables_len, smbios_anchor_len; + const char *product = "QEMU Virtual Machine"; + + if (!lams->fw_cfg) { + return; + } + + smbios_set_defaults("QEMU", product, mc->name, false, + true, SMBIOS_ENTRY_POINT_TYPE_64); + + smbios_get_tables(ms, NULL, 0, &smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len, &error_fatal); + + if (smbios_anchor) { + fw_cfg_add_file(lams->fw_cfg, "etc/smbios/smbios-tables", + smbios_tables, smbios_tables_len); + fw_cfg_add_file(lams->fw_cfg, "etc/smbios/smbios-anchor", + smbios_anchor, smbios_anchor_len); + } +} + +static void virt_machine_done(Notifier *notifier, void *data) +{ + LoongArchMachineState *lams = container_of(notifier, + LoongArchMachineState, machine_done); + virt_build_smbios(lams); +} + struct memmap_entry { uint64_t address; uint64_t length; @@ -512,6 +546,8 @@ static void loongarch_init(MachineState *machine) } /* Initialize the IO interrupt subsystem */ loongarch_irq_init(lams); + lams->machine_done.notify = virt_machine_done; + qemu_add_machine_init_done_notifier(&lams->machine_done); } static void loongarch_class_init(ObjectClass *oc, void *data) diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig index 35b6680772..610552e522 100644 --- a/hw/loongarch/Kconfig +++ b/hw/loongarch/Kconfig @@ -14,3 +14,4 @@ config LOONGARCH_VIRT select LOONGARCH_PCH_MSI select LOONGARCH_EXTIOI select LS7A_RTC + select SMBIOS