From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjOWA-00020u-8Y for qemu-devel@nongnu.org; Thu, 21 Nov 2013 02:17:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjOW4-0001rW-90 for qemu-devel@nongnu.org; Thu, 21 Nov 2013 02:17:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjOW4-0001rP-1O for qemu-devel@nongnu.org; Thu, 21 Nov 2013 02:17:32 -0500 Date: Thu, 21 Nov 2013 09:20:18 +0200 From: "Michael S. Tsirkin" Message-ID: <20131121072018.GD19703@redhat.com> References: <1385001528-12003-1-git-send-email-imammedo@redhat.com> <1385001528-12003-26-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1385001528-12003-26-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 25/27] pc: ACPI BIOS: use enum for defining memory affinity flags List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: peter.maydell@linaro.org, stefanha@redhat.com, stefanb@linux.vnet.ibm.com, qemu-devel@nongnu.org, chegu_vinod@hp.com, marcel.a@redhat.com, mjt@tls.msk.ru, mdroth@linux.vnet.ibm.com, armbru@redhat.com, vasilis.liaskovitis@profitbricks.com, quintela@redhat.com, kraxel@redhat.com, aliguori@amazon.com, hutao@cn.fujitsu.com, pbonzini@redhat.com, lcapitulino@redhat.com, afaerber@suse.de On Thu, Nov 21, 2013 at 03:38:46AM +0100, Igor Mammedov wrote: > 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 > --- > hw/i386/acpi-build.c | 22 +++++++++++++++------- > 1 files changed, 15 insertions(+), 7 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index d41fd81..86c1372 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -1038,15 +1038,22 @@ build_hpet(GArray *table_data, GArray *linker) > (void *)hpet, ACPI_HPET_SIGNATURE, sizeof(*hpet), 1); > } > > +typedef enum { > + NOFLAGS_MEM = 0, > + ENABLED_MEM = (1 << 0), > + HOT_PLUGGABLE_MEM = (1 << 1), > + NON_VOLATILE_MEM = (1 << 2), > +} MemoryAffinityFlags; Absolutely but please use prefixes not suffixes, and make them a bit more specific. E.g. MEM_AFFINITY_NOFLAGS > + > 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); > } > @@ -1094,7 +1101,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, ENABLED_MEM); > next_base = 1024 * 1024; > for (i = 1; i < guest_info->numa_nodes + 1; ++i) { > mem_base = next_base; > @@ -1110,19 +1117,20 @@ build_srat(GArray *table_data, GArray *linker, > mem_len -= next_base - guest_info->ram_size; > 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, > + ENABLED_MEM); > } > mem_base = 1ULL << 32; > mem_len = next_base - guest_info->ram_size; > next_base += (1ULL << 32) - guest_info->ram_size; > } > 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, ENABLED_MEM); > } > 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, NOFLAGS_MEM); > } > > build_header(linker, table_data, > -- > 1.7.1