[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 002/106] pc: ACPI BIOS: use enum for defining memo
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 002/106] pc: ACPI BIOS: use enum for defining memory affinity flags |
Date: |
Wed, 18 Jun 2014 19:15:31 +0300 |
From: Igor Mammedov <address@hidden>
replace magic numbers with enum describing Flags field of
memory affinity in SRAT table.
MemoryAffinityFlags enum will define flags decribed by:
ACPI spec 5.0, "5.2.16.2 Memory Affinity Structure",
"Table 5-69 Flags - Memory Affinity Structure"
Signed-off-by: Igor Mammedov <address@hidden>
Acked-by: Peter Crosthwaite <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/i386/acpi-build.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 1e0aa09..9a41510 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1132,15 +1132,22 @@ build_hpet(GArray *table_data, GArray *linker)
(void *)hpet, "HPET", sizeof(*hpet), 1);
}
+typedef enum {
+ MEM_AFFINITY_NOFLAGS = 0,
+ MEM_AFFINITY_ENABLED = (1 << 0),
+ MEM_AFFINITY_HOTPLUGGABLE = (1 << 1),
+ MEM_AFFINITY_NON_VOLATILE = (1 << 2),
+} MemoryAffinityFlags;
+
static void
-acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem,
- uint64_t base, uint64_t len, int node, int enabled)
+acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
+ uint64_t len, int node, MemoryAffinityFlags flags)
{
numamem->type = ACPI_SRAT_MEMORY;
numamem->length = sizeof(*numamem);
memset(numamem->proximity, 0, 4);
numamem->proximity[0] = node;
- numamem->flags = cpu_to_le32(!!enabled);
+ numamem->flags = cpu_to_le32(flags);
numamem->base_addr = cpu_to_le64(base);
numamem->range_length = cpu_to_le64(len);
}
@@ -1188,7 +1195,7 @@ build_srat(GArray *table_data, GArray *linker,
numa_start = table_data->len;
numamem = acpi_data_push(table_data, sizeof *numamem);
- acpi_build_srat_memory(numamem, 0, 640*1024, 0, 1);
+ acpi_build_srat_memory(numamem, 0, 640*1024, 0, MEM_AFFINITY_ENABLED);
next_base = 1024 * 1024;
for (i = 1; i < guest_info->numa_nodes + 1; ++i) {
mem_base = next_base;
@@ -1204,19 +1211,21 @@ build_srat(GArray *table_data, GArray *linker,
mem_len -= next_base - guest_info->ram_size_below_4g;
if (mem_len > 0) {
numamem = acpi_data_push(table_data, sizeof *numamem);
- acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, 1);
+ acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1,
+ MEM_AFFINITY_ENABLED);
}
mem_base = 1ULL << 32;
mem_len = next_base - guest_info->ram_size_below_4g;
next_base += (1ULL << 32) - guest_info->ram_size_below_4g;
}
numamem = acpi_data_push(table_data, sizeof *numamem);
- acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1, 1);
+ acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1,
+ MEM_AFFINITY_ENABLED);
}
slots = (table_data->len - numa_start) / sizeof *numamem;
for (; slots < guest_info->numa_nodes + 2; slots++) {
numamem = acpi_data_push(table_data, sizeof *numamem);
- acpi_build_srat_memory(numamem, 0, 0, 0, 0);
+ acpi_build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS);
}
build_header(linker, table_data,
--
MST
- [Qemu-devel] [PULL v2 000/106] pc, pci, virtio, hotplug fixes, enhancements, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 001/106] pc: create custom generic PC machine type, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 002/106] pc: ACPI BIOS: use enum for defining memory affinity flags,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 003/106] object_add: allow completion handler to get canonical path, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 004/106] vl.c: daemonize before guest memory allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 005/106] add memdev backend infrastructure, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 007/106] qdev: hotplug for bus-less devices, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 009/106] pc: implement pc-dimm device abstraction, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 011/106] pc-dimm: do not allow setting an in-use memdev, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 010/106] memory: add memory_region_is_mapped() API, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 012/106] pc: initialize memory hotplug address space, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 014/106] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 018/106] pc-dimm: add busy slot check and slot auto-allocation, Michael S. Tsirkin, 2014/06/18