[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [RFC v2 10/15] acpi: move build_srat_hotpluggable_memory to g
From: |
Eric Auger |
Subject: |
[Qemu-arm] [RFC v2 10/15] acpi: move build_srat_hotpluggable_memory to generic ACPI source |
Date: |
Mon, 2 Jul 2018 19:22:37 +0200 |
We plan to reuse build_srat_hotpluggable_memory() for ARM so
let's move the function to aml-build.
Signed-off-by: Eric Auger <address@hidden>
---
hw/acpi/aml-build.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
hw/i386/acpi-build.c | 49 -------------------------------------------
include/hw/acpi/aml-build.h | 3 +++
3 files changed, 54 insertions(+), 49 deletions(-)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 1e43cd7..167fb6b 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -22,6 +22,7 @@
#include "qemu/osdep.h"
#include <glib/gprintf.h>
#include "hw/acpi/aml-build.h"
+#include "hw/mem/memory-device.h"
#include "qemu/bswap.h"
#include "qemu/bitops.h"
#include "sysemu/numa.h"
@@ -1802,3 +1803,53 @@ build_hdr:
build_header(linker, tbl, (void *)(tbl->data + fadt_start),
"FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_id);
}
+
+void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
+ uint64_t len, int default_node)
+{
+ MemoryDeviceInfoList *info_list = qmp_memory_device_list();
+ MemoryDeviceInfoList *info;
+ MemoryDeviceInfo *mi;
+ PCDIMMDeviceInfo *di;
+ uint64_t end = base + len, cur, size;
+ bool is_nvdimm;
+ AcpiSratMemoryAffinity *numamem;
+ MemoryAffinityFlags flags;
+
+ for (cur = base, info = info_list;
+ cur < end;
+ cur += size, info = info->next) {
+ numamem = acpi_data_push(table_data, sizeof *numamem);
+
+ if (!info) {
+ build_srat_memory(numamem, cur, end - cur, default_node,
+ MEM_AFFINITY_HOTPLUGGABLE |
MEM_AFFINITY_ENABLED);
+ break;
+ }
+
+ mi = info->value;
+ is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM);
+ di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data;
+
+ if (cur < di->addr) {
+ build_srat_memory(numamem, cur, di->addr - cur, default_node,
+ MEM_AFFINITY_HOTPLUGGABLE |
MEM_AFFINITY_ENABLED);
+ numamem = acpi_data_push(table_data, sizeof *numamem);
+ }
+
+ size = di->size;
+
+ flags = MEM_AFFINITY_ENABLED;
+ if (di->hotpluggable) {
+ flags |= MEM_AFFINITY_HOTPLUGGABLE;
+ }
+ if (is_nvdimm) {
+ flags |= MEM_AFFINITY_NON_VOLATILE;
+ }
+
+ build_srat_memory(numamem, di->addr, size, di->node, flags);
+ }
+
+ qapi_free_MemoryDeviceInfoList(info_list);
+}
+
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 9bc6d97..fcebd02 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2251,55 +2251,6 @@ build_tpm2(GArray *table_data, BIOSLinker *linker,
GArray *tcpalog)
#define HOLE_640K_START (640 * 1024)
#define HOLE_640K_END (1024 * 1024)
-static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
- uint64_t len, int default_node)
-{
- MemoryDeviceInfoList *info_list = qmp_memory_device_list();
- MemoryDeviceInfoList *info;
- MemoryDeviceInfo *mi;
- PCDIMMDeviceInfo *di;
- uint64_t end = base + len, cur, size;
- bool is_nvdimm;
- AcpiSratMemoryAffinity *numamem;
- MemoryAffinityFlags flags;
-
- for (cur = base, info = info_list;
- cur < end;
- cur += size, info = info->next) {
- numamem = acpi_data_push(table_data, sizeof *numamem);
-
- if (!info) {
- build_srat_memory(numamem, cur, end - cur, default_node,
- MEM_AFFINITY_HOTPLUGGABLE |
MEM_AFFINITY_ENABLED);
- break;
- }
-
- mi = info->value;
- is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM);
- di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data;
-
- if (cur < di->addr) {
- build_srat_memory(numamem, cur, di->addr - cur, default_node,
- MEM_AFFINITY_HOTPLUGGABLE |
MEM_AFFINITY_ENABLED);
- numamem = acpi_data_push(table_data, sizeof *numamem);
- }
-
- size = di->size;
-
- flags = MEM_AFFINITY_ENABLED;
- if (di->hotpluggable) {
- flags |= MEM_AFFINITY_HOTPLUGGABLE;
- }
- if (is_nvdimm) {
- flags |= MEM_AFFINITY_NON_VOLATILE;
- }
-
- build_srat_memory(numamem, di->addr, size, di->node, flags);
- }
-
- qapi_free_MemoryDeviceInfoList(info_list);
-}
-
static void
build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
{
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 6c36903..4c2ca13 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -416,4 +416,7 @@ void build_slit(GArray *table_data, BIOSLinker *linker);
void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
const char *oem_id, const char *oem_table_id);
+
+void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
+ uint64_t len, int default_node);
#endif
--
2.5.5
- [Qemu-arm] [RFC v2 00/15] ARM virt: PCDIMM/NVDIMM at 2TB, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 01/15] linux-headers: header update for KVM/ARM KVM_ARM_GET_MAX_VM_PHYS_SHIFT, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 02/15] hw/boards: Add a MachineState parameter to kvm_type callback, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 03/15] kvm: add kvm_arm_get_max_vm_phys_shift, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 04/15] hw/arm/virt: support kvm_type property, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 05/15] hw/arm/virt: handle max_vm_phys_shift conflicts on migration, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 06/15] hw/arm/virt: Allocate device_memory, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 07/15] hw/arm/virt: Add memory hotplug framework, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 08/15] hw/arm/boot: introduce fdt_add_memory_node helper, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 09/15] hw/arm/boot: Expose the PC-DIMM nodes in the DT, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 10/15] acpi: move build_srat_hotpluggable_memory to generic ACPI source,
Eric Auger <=
- [Qemu-arm] [RFC v2 11/15] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 12/15] nvdimm: use configurable ACPI IO base and size, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 13/15] hw/arm/virt: Add nvdimm hot-plug infrastructure, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 14/15] hw/arm/boot: Expose the pmem nodes in the DT, Eric Auger, 2018/07/02
- [Qemu-arm] [RFC v2 15/15] hw/arm/virt: Add nvdimm and nvdimm-persistence options, Eric Auger, 2018/07/02
- Re: [Qemu-arm] [Qemu-devel] [RFC v2 00/15] ARM virt: PCDIMM/NVDIMM at 2TB, no-reply, 2018/07/03