qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 25/27] pc: ACPI BIOS: use enum for defining memo


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH 25/27] pc: ACPI BIOS: use enum for defining memory affinity flags
Date: Thu, 21 Nov 2013 09:20:18 +0200

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 <address@hidden>
> ---
>  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]