[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v6 26/29] hw/loongarch: Add LoongArch smbios support
From: |
Xiaojuan Yang |
Subject: |
[RFC PATCH v6 26/29] hw/loongarch: Add LoongArch smbios support |
Date: |
Fri, 25 Feb 2022 03:03:05 -0500 |
Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
hw/loongarch/Kconfig | 1 +
hw/loongarch/loongson3.c | 43 ++++++++++++++++++++++++++++++++
include/hw/loongarch/loongarch.h | 1 +
3 files changed, 45 insertions(+)
diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig
index 33a9066586..26690dee48 100644
--- a/hw/loongarch/Kconfig
+++ b/hw/loongarch/Kconfig
@@ -15,6 +15,7 @@ config LOONGARCH_VIRT
select LOONGARCH_EXTIOI
select LS7A_RTC
select FW_CFG_LOONGARCH
+ select SMBIOS
config FW_CFG_LOONGARCH
bool
diff --git a/hw/loongarch/loongson3.c b/hw/loongarch/loongson3.c
index 9533057110..4189ffc34d 100644
--- a/hw/loongarch/loongson3.c
+++ b/hw/loongarch/loongson3.c
@@ -29,6 +29,9 @@
#include "hw/pci-host/gpex.h"
#include "hw/misc/unimp.h"
#include "hw/loongarch/fw_cfg.h"
+#include "hw/misc/unimp.h"
+#include "hw/loongarch/fw_cfg.h"
+#include "hw/firmware/smbios.h"
#include "target/loongarch/cpu.h"
@@ -159,6 +162,42 @@ 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";
+
+ if (!lams->fw_cfg) {
+ return;
+ }
+
+ product = "Loongson-3A5000-7A1000-TCG";
+
+ 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 loongarch_machine_done(Notifier *notifier, void *data)
+{
+ LoongArchMachineState *lams = container_of(notifier,
+ LoongArchMachineState, machine_done);
+ loongarch_build_smbios(lams);
+}
+
static void loongarch_cpu_reset(void *opaque)
{
LoongArchCPU *cpu = opaque;
@@ -484,6 +523,10 @@ static void loongarch_init(MachineState *machine)
/* Initialize the IO interrupt subsystem */
loongarch_irq_init(lams, ipi, extioi);
+
+ lams->machine_done.notify = loongarch_machine_done;
+ qemu_add_machine_init_done_notifier(&lams->machine_done);
+
}
static void loongarch_class_init(ObjectClass *oc, void *data)
diff --git a/include/hw/loongarch/loongarch.h b/include/hw/loongarch/loongarch.h
index adb1ecd042..26e62a50bf 100644
--- a/include/hw/loongarch/loongarch.h
+++ b/include/hw/loongarch/loongarch.h
@@ -56,6 +56,7 @@ typedef struct LoongArchMachineState {
MemoryRegion bios;
/* State for other subsystems/APIs: */
+ Notifier machine_done;
FWCfgState *fw_cfg;
} LoongArchMachineState;
--
2.27.0
- [RFC PATCH v6 01/29] target/loongarch: Add system emulation introduction, (continued)
- [RFC PATCH v6 01/29] target/loongarch: Add system emulation introduction, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 03/29] target/loongarch: Add basic vmstate description of CPU., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 13/29] target/loongarch: Add gdb support., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 22/29] hw/loongarch: Add some devices support for 3A5000., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 15/29] hw/loongarch: Add LoongArch cpu interrupt support(CPUINTC), Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 29/29] tests/tcg/loongarch64: Add hello/memory test in loongarch64 system, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 12/29] target/loongarch: Add timer related instructions support., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 28/29] hw/loongarch: Add fdt support., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 16/29] hw/loongarch: Add LoongArch ipi interrupt support(IPI), Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 10/29] target/loongarch: Add other core instructions support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 26/29] hw/loongarch: Add LoongArch smbios support,
Xiaojuan Yang <=
- [RFC PATCH v6 08/29] target/loongarch: Add LoongArch IOCSR instruction, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 04/29] target/loongarch: Implement qmp_query_cpu_definitions(), Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 21/29] Enable common virtio pci support for LoongArch, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 05/29] target/loongarch: Add constant timer support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 25/29] hw/loongarch: Add -kernel and -initrd options support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 20/29] hw/loongarch: Add irq hierarchy for the system, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 06/29] target/loongarch: Add MMU support for LoongArch CPU., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 17/29] hw/intc: Add LoongArch ls7a interrupt controller support(PCH-PIC), Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 24/29] hw/loongarch: Add default bios startup support., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 07/29] target/loongarch: Add LoongArch CSR instruction, Xiaojuan Yang, 2022/02/25