qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 37/74] pc: acpi: memhp: drop not needed stringify(ME


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH 37/74] pc: acpi: memhp: drop not needed stringify(MEMORY_foo) usage
Date: Thu, 10 Dec 2015 00:41:31 +0100

most of MEMORY_foo defines are not shared
with ASL anymore and are used only inside of
memory_hotplug_acpi_table.c, so move them
there and make them strings. As result we
can replace stringify(MEMORY_foo) with just
MEMORY_foo, which makes code a bit cleaner.

No AML change introduced by this patch.

Signed-off-by: Igor Mammedov <address@hidden>
---
 hw/acpi/memory_hotplug_acpi_table.c | 53 +++++++++++++++++--------------------
 hw/i386/acpi-build.c                | 52 ++++++++++++++++++------------------
 include/hw/acpi/memory_hotplug.h    |  6 ++---
 include/hw/acpi/pc-hotplug.h        | 42 ++++++++++++++---------------
 4 files changed, 74 insertions(+), 79 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c 
b/hw/acpi/memory_hotplug_acpi_table.c
index b913edc..3e943c3 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -35,14 +35,14 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
     Aml *while_ctx;
     Aml *a_zero = aml_int(0);
     Aml *a_one = aml_int(1);
-    Aml *a_slots_nr = aml_name(stringify(MEMORY_SLOTS_NUMBER));
+    Aml *a_slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
 
     /* scope for memory hotplug controller device node */
     pci_scope = aml_scope("_SB.PCI0");
-    ctrl_dev = aml_device(stringify(MEMORY_HOTPLUG_DEVICE));
+    ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
     {
-        Aml *a_ctrl_lock = aml_name(stringify(MEMORY_SLOT_LOCK));
-        Aml *a_slot_selector = aml_name(stringify(MEMORY_SLOT_SLECTOR));
+        Aml *a_ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
+        Aml *a_slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
         Aml *a_ret_val = aml_local(0);
         Aml *a_slot_arg0 = aml_arg(0);
 
@@ -59,10 +59,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         aml_append(method, aml_return(aml_int(0xB)));
         aml_append(ctrl_dev, method);
 
-        aml_append(ctrl_dev, aml_mutex(stringify(MEMORY_SLOT_LOCK), 0));
+        aml_append(ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
 
-        method = aml_method(stringify(MEMORY_SLOT_SCAN_METHOD), 0,
-                            AML_NOTSERIALIZED);
+        method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
         {
             Aml *a_idx = aml_local(0);
 
@@ -75,13 +74,13 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
             while_ctx = aml_while(
                 aml_lless(a_idx, a_slots_nr));
             {
-                Aml *a_ins_evt = aml_name(stringify(MEMORY_SLOT_INSERT_EVENT));
-                Aml *a_rm_evt = aml_name(stringify(MEMORY_SLOT_REMOVE_EVENT));
+                Aml *a_ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
+                Aml *a_rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
 
                 aml_append(while_ctx, aml_store(a_idx, a_slot_selector));
                 ifctx = aml_if(aml_equal(a_ins_evt, a_one));
                 aml_append(ifctx,
-                    aml_call2(stringify(MEMORY_SLOT_NOTIFY_METHOD),
+                    aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
                               a_idx, a_one));
                 aml_append(ifctx, aml_store(a_one, a_ins_evt));
                 aml_append(while_ctx, ifctx);
@@ -89,7 +88,7 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
                 else_ctx = aml_else();
                 ifctx = aml_if(aml_equal(a_rm_evt, a_one));
                 aml_append(ifctx,
-                    aml_call2(stringify(MEMORY_SLOT_NOTIFY_METHOD),
+                    aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
                               a_idx, aml_int(3)));
                 aml_append(ifctx, aml_store(a_one, a_rm_evt));
                 aml_append(else_ctx, ifctx);
@@ -103,10 +102,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         }
         aml_append(ctrl_dev, method);
 
-        method = aml_method(stringify(MEMORY_SLOT_STATUS_METHOD), 1,
-                            AML_NOTSERIALIZED);
+        method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
         {
-            Aml *a_slot_enabled = aml_name(stringify(MEMORY_SLOT_ENABLED));
+            Aml *a_slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
 
             aml_append(method, aml_store(a_zero, a_ret_val));
             aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
@@ -122,8 +120,7 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         }
         aml_append(ctrl_dev, method);
 
-        method = aml_method(stringify(MEMORY_SLOT_CRS_METHOD), 1,
-                            AML_SERIALIZED);
+        method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
         {
             Aml *a_mr64 = aml_name("MR64");
             Aml *a_mr32 = aml_name("MR32");
@@ -159,13 +156,13 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
                 aml_create_dword_field(a_mr64, aml_int(26), "MAXH"));
 
             aml_append(method,
-                aml_store(aml_name(stringify(MEMORY_SLOT_ADDR_HIGH)), a_minh));
+                aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), a_minh));
             aml_append(method,
-                aml_store(aml_name(stringify(MEMORY_SLOT_ADDR_LOW)), a_minl));
+                aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), a_minl));
             aml_append(method,
-                aml_store(aml_name(stringify(MEMORY_SLOT_SIZE_HIGH)), a_lenh));
+                aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), a_lenh));
             aml_append(method,
-                aml_store(aml_name(stringify(MEMORY_SLOT_SIZE_LOW)), a_lenl));
+                aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), a_lenl));
 
             /* 64-bit math: MAX = MIN + LEN - 1 */
             aml_append(method, aml_add(a_minl, a_lenl, a_maxl));
@@ -207,10 +204,10 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         }
         aml_append(ctrl_dev, method);
 
-        method = aml_method(stringify(MEMORY_SLOT_PROXIMITY_METHOD), 1,
+        method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
                             AML_NOTSERIALIZED);
         {
-            Aml *a_proximity = aml_name(stringify(MEMORY_SLOT_PROXIMITY));
+            Aml *a_proximity = aml_name(MEMORY_SLOT_PROXIMITY);
 
             aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
             aml_append(method, aml_store(aml_to_integer(a_slot_arg0),
@@ -221,11 +218,10 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         }
         aml_append(ctrl_dev, method);
 
-        method = aml_method(stringify(MEMORY_SLOT_OST_METHOD), 4,
-                            AML_NOTSERIALIZED);
+        method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
         {
-            Aml *a_ost_evt = aml_name(stringify(MEMORY_SLOT_OST_EVENT));
-            Aml *a_ost_status = aml_name(stringify(MEMORY_SLOT_OST_STATUS));
+            Aml *a_ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
+            Aml *a_ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
 
             aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
             aml_append(method, aml_store(aml_to_integer(a_slot_arg0),
@@ -236,10 +232,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         }
         aml_append(ctrl_dev, method);
 
-        method = aml_method(stringify(MEMORY_SLOT_EJECT_METHOD), 2,
-                            AML_NOTSERIALIZED);
+        method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
         {
-            Aml *a_eject = aml_name(stringify(MEMORY_SLOT_EJECT));
+            Aml *a_eject = aml_name(MEMORY_SLOT_EJECT);
 
             aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
             aml_append(method, aml_store(aml_to_integer(a_slot_arg0),
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 94371f7..f6337ca 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -916,9 +916,9 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,
 
     /* build memory devices */
     assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
-    scope = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
+    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
     aml_append(scope,
-        aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
+        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
     );
 
     crs = aml_resource_template();
@@ -928,53 +928,53 @@ static void build_memory_devices(Aml *sb_scope, int 
nr_mem,
     aml_append(scope, aml_name_decl("_CRS", crs));
 
     aml_append(scope, aml_operation_region(
-        stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
+        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
         io_base, io_len)
     );
 
-    field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
+    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
                       AML_NOLOCK, AML_PRESERVE);
     aml_append(field, /* read only */
-        aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
+        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
     aml_append(field, /* read only */
-        aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
+        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
     aml_append(field, /* read only */
-        aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
+        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
     aml_append(field, /* read only */
-        aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
+        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
     aml_append(field, /* read only */
-        aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
+        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
     aml_append(scope, field);
 
-    field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
+    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
                       AML_NOLOCK, AML_WRITE_AS_ZEROS);
     aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
     aml_append(field, /* 1 if enabled, read only */
-        aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
+        aml_named_field(MEMORY_SLOT_ENABLED, 1));
     aml_append(field,
         /*(read) 1 if has a insert event. (write) 1 to clear event */
-        aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
+        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
     aml_append(field,
         /* (read) 1 if has a remove event. (write) 1 to clear event */
-        aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
+        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
     aml_append(field,
         /* initiates device eject, write only */
-        aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
+        aml_named_field(MEMORY_SLOT_EJECT, 1));
     aml_append(scope, field);
 
-    field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
+    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
                       AML_NOLOCK, AML_PRESERVE);
     aml_append(field, /* DIMM selector, write only */
-        aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
+        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
     aml_append(field, /* _OST event code, write only */
-        aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
+        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
     aml_append(field, /* _OST status code, write only */
-        aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
+        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
     aml_append(scope, field);
     aml_append(sb_scope, scope);
 
     for (i = 0; i < nr_mem; i++) {
-        #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
+        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
         const char *s;
 
         dev = aml_device("MP%02X", i);
@@ -982,29 +982,30 @@ static void build_memory_devices(Aml *sb_scope, int 
nr_mem,
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
 
         method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
-        s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
+        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
         aml_append(dev, method);
 
         method = aml_method("_STA", 0, AML_NOTSERIALIZED);
-        s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
+        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
         aml_append(dev, method);
 
         method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
-        s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
+        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
         aml_append(dev, method);
 
         method = aml_method("_OST", 3, AML_NOTSERIALIZED);
-        s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
+        s = BASEPATH MEMORY_SLOT_OST_METHOD;
+
         aml_append(method, aml_return(aml_call4(
             s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
         )));
         aml_append(dev, method);
 
         method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-        s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
+        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
         aml_append(method, aml_return(aml_call2(
                    s, aml_name("_UID"), aml_arg(0))));
         aml_append(dev, method);
@@ -1015,8 +1016,7 @@ static void build_memory_devices(Aml *sb_scope, int 
nr_mem,
     /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
      *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
      */
-    method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2,
-                        AML_NOTSERIALIZED);
+    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
     for (i = 0; i < nr_mem; i++) {
         ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
         aml_append(ifctx,
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index de164f2..3a646b1 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -47,10 +47,10 @@ extern const VMStateDescription vmstate_memory_hotplug;
 
 void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
-#define MEMORY_HOTPLUG_DEVICE        MHPD
-#define MEMORY_SLOT_SCAN_METHOD      MSCN
+#define MEMORY_HOTPLUG_DEVICE        "MHPD"
+#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
 #define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
-     stringify(MEMORY_HOTPLUG_DEVICE) "." stringify(MEMORY_SLOT_SCAN_METHOD)
+     MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
 
 void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
                               uint16_t io_base, uint16_t io_len);
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index e5bb321..6a8d268 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -32,26 +32,26 @@
 #define ACPI_MEMORY_HOTPLUG_IO_LEN 24
 #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
 
-#define MEMORY_SLOTS_NUMBER          MDNR
-#define MEMORY_HOTPLUG_IO_REGION     HPMR
-#define MEMORY_SLOT_ADDR_LOW         MRBL
-#define MEMORY_SLOT_ADDR_HIGH        MRBH
-#define MEMORY_SLOT_SIZE_LOW         MRLL
-#define MEMORY_SLOT_SIZE_HIGH        MRLH
-#define MEMORY_SLOT_PROXIMITY        MPX
-#define MEMORY_SLOT_ENABLED          MES
-#define MEMORY_SLOT_INSERT_EVENT     MINS
-#define MEMORY_SLOT_REMOVE_EVENT     MRMV
-#define MEMORY_SLOT_EJECT            MEJ
-#define MEMORY_SLOT_SLECTOR          MSEL
-#define MEMORY_SLOT_OST_EVENT        MOEV
-#define MEMORY_SLOT_OST_STATUS       MOSC
-#define MEMORY_SLOT_LOCK             MLCK
-#define MEMORY_SLOT_STATUS_METHOD    MRST
-#define MEMORY_SLOT_CRS_METHOD       MCRS
-#define MEMORY_SLOT_OST_METHOD       MOST
-#define MEMORY_SLOT_PROXIMITY_METHOD MPXM
-#define MEMORY_SLOT_EJECT_METHOD     MEJ0
-#define MEMORY_SLOT_NOTIFY_METHOD    MTFY
+#define MEMORY_SLOTS_NUMBER          "MDNR"
+#define MEMORY_HOTPLUG_IO_REGION     "HPMR"
+#define MEMORY_SLOT_ADDR_LOW         "MRBL"
+#define MEMORY_SLOT_ADDR_HIGH        "MRBH"
+#define MEMORY_SLOT_SIZE_LOW         "MRLL"
+#define MEMORY_SLOT_SIZE_HIGH        "MRLH"
+#define MEMORY_SLOT_PROXIMITY        "MPX"
+#define MEMORY_SLOT_ENABLED          "MES"
+#define MEMORY_SLOT_INSERT_EVENT     "MINS"
+#define MEMORY_SLOT_REMOVE_EVENT     "MRMV"
+#define MEMORY_SLOT_EJECT            "MEJ"
+#define MEMORY_SLOT_SLECTOR          "MSEL"
+#define MEMORY_SLOT_OST_EVENT        "MOEV"
+#define MEMORY_SLOT_OST_STATUS       "MOSC"
+#define MEMORY_SLOT_LOCK             "MLCK"
+#define MEMORY_SLOT_STATUS_METHOD    "MRST"
+#define MEMORY_SLOT_CRS_METHOD       "MCRS"
+#define MEMORY_SLOT_OST_METHOD       "MOST"
+#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
+#define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
+#define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
 
 #endif
-- 
1.8.3.1




reply via email to

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