[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 27/30] hw/loongarch: Add LoongArch smbios support
From: |
Xiaojuan Yang |
Subject: |
[RFC PATCH v2 27/30] hw/loongarch: Add LoongArch smbios support |
Date: |
Thu, 11 Nov 2021 09:35:25 +0800 |
Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
hw/loongarch/Kconfig | 1 +
hw/loongarch/ls3a5000_virt.c | 41 ++++++++++++++++++++++++++++++++
include/hw/loongarch/loongarch.h | 2 ++
3 files changed, 44 insertions(+)
diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig
index b59cd98a7a..595c19ad83 100644
--- a/hw/loongarch/Kconfig
+++ b/hw/loongarch/Kconfig
@@ -14,6 +14,7 @@ config LOONGSON_3A5000
select LOONGARCH_EXTIOI
select LS7A_RTC
select FW_CFG_LOONGARCH
+ select SMBIOS
config FW_CFG_LOONGARCH
bool
diff --git a/hw/loongarch/ls3a5000_virt.c b/hw/loongarch/ls3a5000_virt.c
index 902a0c7630..bfe8dd4757 100644
--- a/hw/loongarch/ls3a5000_virt.c
+++ b/hw/loongarch/ls3a5000_virt.c
@@ -26,6 +26,7 @@
#include "hw/pci-host/ls7a.h"
#include "hw/misc/unimp.h"
#include "hw/loongarch/fw_cfg.h"
+#include "hw/firmware/smbios.h"
#define LOONGSON3_BIOSNAME "loongarch_bios.bin"
@@ -101,6 +102,43 @@ static void fw_cfg_add_kernel_info(FWCfgState *fw_cfg)
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, (const char *)cmdline_buf);
}
+static void loongarch_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";
+ ms->smp.cores = 4;
+
+ if (!lams->fw_cfg) {
+ return;
+ }
+
+ product = "LoongArch-3A5K-7A1000-TCG";
+
+ smbios_set_defaults("QEMU", product, mc->name, false,
+ true, SMBIOS_ENTRY_POINT_30);
+
+ 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 loongarch_machine_done(Notifier *notifier, void *data)
+{
+ LoongArchMachineState *lams = container_of(notifier,
+ LoongArchMachineState, machine_done);
+ loongarch_build_smbios(lams);
+}
+
static void main_cpu_reset(void *opaque)
{
LoongArchCPU *cpu = opaque;
@@ -377,6 +415,9 @@ static void ls3a5000_virt_init(MachineState *machine)
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), LA_BIOS_BASE, bios);
+ lams->machine_done.notify = loongarch_machine_done;
+ qemu_add_machine_init_done_notifier(&lams->machine_done);
+
/* Add PM mmio memory for reboot and shutdown*/
iomem = g_new(MemoryRegion, 1);
memory_region_init_io(iomem, NULL, &loongarch_pm_ops, NULL,
diff --git a/include/hw/loongarch/loongarch.h b/include/hw/loongarch/loongarch.h
index dc7617ab64..b165b4fd07 100644
--- a/include/hw/loongarch/loongarch.h
+++ b/include/hw/loongarch/loongarch.h
@@ -49,6 +49,8 @@ typedef struct LoongArchMachineState {
AddressSpace *address_space_iocsr;
MemoryRegion *system_iocsr;
+ /* State for other subsystems/APIs: */
+ Notifier machine_done;
gipiState *gipi;
qemu_irq *pch_irq;
FWCfgState *fw_cfg;
--
2.27.0
- [RFC PATCH v2 20/30] hw/intc: Add LoongArch ls7a msi interrupt controller support(PCH-MSI), (continued)
- [RFC PATCH v2 20/30] hw/intc: Add LoongArch ls7a msi interrupt controller support(PCH-MSI), Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 14/30] target/loongarch: Implement privilege instructions disassembly, Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 17/30] hw/loongarch: Add LoongArch cpu interrupt support(CPUINTC), Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 19/30] hw/intc: Add LoongArch ls7a interrupt controller support(PCH-PIC), Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 22/30] hw/loongarch: Add irq hierarchy for the system, Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 23/30] hw/loongarch: Add some devices support for 3A5000., Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 24/30] hw/loongarch: Add LoongArch ls7a rtc device support, Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 27/30] hw/loongarch: Add LoongArch smbios support,
Xiaojuan Yang <=
- [RFC PATCH v2 25/30] hw/loongarch: Add default bios startup support., Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 28/30] hw/loongarch: Add LoongArch acpi support, Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 29/30] hw/loongarch: Add machine->possible_cpus, Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 26/30] hw/loongarch: Add -kernel and -initrd options support, Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 30/30] hw/loongarch: Add Numa support., Xiaojuan Yang, 2021/11/10
- [RFC PATCH v2 21/30] hw/intc: Add LoongArch extioi interrupt controller(EIOINTC), Xiaojuan Yang, 2021/11/10
- Re: [RFC PATCH v2 00/30] Add Loongarch softmmu support., Mark Cave-Ayland, 2021/11/11