From f84548dda458bc4da89ecee7f812fcd4ce2eb651 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Mon, 28 Dec 2015 18:02:21 +0100 Subject: pc: acpi: memhp: drop not needed stringify(MEMORY_foo) usage 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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 b5b79e6841..080d9add5b 100644 --- a/hw/acpi/memory_hotplug_acpi_table.c +++ b/hw/acpi/memory_hotplug_acpi_table.c @@ -24,15 +24,15 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, /* scope for memory hotplug controller device node */ pci_scope = aml_scope("_SB.PCI0"); - mem_ctrl_dev = aml_device(stringify(MEMORY_HOTPLUG_DEVICE)); + mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE); { Aml *one = aml_int(1); Aml *zero = aml_int(0); Aml *ret_val = aml_local(0); Aml *slot_arg0 = aml_arg(0); - Aml *slots_nr = aml_name(stringify(MEMORY_SLOTS_NUMBER)); - Aml *ctrl_lock = aml_name(stringify(MEMORY_SLOT_LOCK)); - Aml *slot_selector = aml_name(stringify(MEMORY_SLOT_SLECTOR)); + Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER); + Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK); + Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR); aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06"))); aml_append(mem_ctrl_dev, @@ -48,10 +48,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, aml_append(method, aml_return(aml_int(0xB))); aml_append(mem_ctrl_dev, method); - aml_append(mem_ctrl_dev, aml_mutex(stringify(MEMORY_SLOT_LOCK), 0)); + aml_append(mem_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 *else_ctx; Aml *while_ctx; @@ -75,14 +74,14 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, */ while_ctx = aml_while(aml_lless(idx, slots_nr)); { - Aml *ins_evt = aml_name(stringify(MEMORY_SLOT_INSERT_EVENT)); - Aml *rm_evt = aml_name(stringify(MEMORY_SLOT_REMOVE_EVENT)); + Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT); + Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT); aml_append(while_ctx, aml_store(idx, slot_selector)); ifctx = aml_if(aml_equal(ins_evt, one)); { aml_append(ifctx, - aml_call2(stringify(MEMORY_SLOT_NOTIFY_METHOD), + aml_call2(MEMORY_SLOT_NOTIFY_METHOD, idx, dev_chk)); aml_append(ifctx, aml_store(one, ins_evt)); } @@ -92,7 +91,7 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, ifctx = aml_if(aml_equal(rm_evt, one)); { aml_append(ifctx, - aml_call2(stringify(MEMORY_SLOT_NOTIFY_METHOD), + aml_call2(MEMORY_SLOT_NOTIFY_METHOD, idx, eject_req)); aml_append(ifctx, aml_store(one, rm_evt)); } @@ -107,10 +106,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, } aml_append(mem_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 *slot_enabled = aml_name(stringify(MEMORY_SLOT_ENABLED)); + Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED); aml_append(method, aml_store(zero, ret_val)); aml_append(method, aml_acquire(ctrl_lock, 0xFFFF)); @@ -128,8 +126,7 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, } aml_append(mem_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 *mr64 = aml_name("MR64"); Aml *mr32 = aml_name("MR32"); @@ -165,13 +162,13 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, aml_create_dword_field(mr64, aml_int(26), "MAXH")); aml_append(method, - aml_store(aml_name(stringify(MEMORY_SLOT_ADDR_HIGH)), minh)); + aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh)); aml_append(method, - aml_store(aml_name(stringify(MEMORY_SLOT_ADDR_LOW)), minl)); + aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl)); aml_append(method, - aml_store(aml_name(stringify(MEMORY_SLOT_SIZE_HIGH)), lenh)); + aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh)); aml_append(method, - aml_store(aml_name(stringify(MEMORY_SLOT_SIZE_LOW)), lenl)); + aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl)); /* 64-bit math: MAX = MIN + LEN - 1 */ aml_append(method, aml_add(minl, lenl, maxl)); @@ -220,10 +217,10 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, } aml_append(mem_ctrl_dev, method); - method = aml_method(stringify(MEMORY_SLOT_PROXIMITY_METHOD), 1, + method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1, AML_NOTSERIALIZED); { - Aml *proximity = aml_name(stringify(MEMORY_SLOT_PROXIMITY)); + Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY); aml_append(method, aml_acquire(ctrl_lock, 0xFFFF)); aml_append(method, aml_store(aml_to_integer(slot_arg0), @@ -234,11 +231,10 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, } aml_append(mem_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 *ost_evt = aml_name(stringify(MEMORY_SLOT_OST_EVENT)); - Aml *ost_status = aml_name(stringify(MEMORY_SLOT_OST_STATUS)); + Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT); + Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS); aml_append(method, aml_acquire(ctrl_lock, 0xFFFF)); aml_append(method, aml_store(aml_to_integer(slot_arg0), @@ -249,10 +245,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, } aml_append(mem_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 *eject = aml_name(stringify(MEMORY_SLOT_EJECT)); + Aml *eject = aml_name(MEMORY_SLOT_EJECT); aml_append(method, aml_acquire(ctrl_lock, 0xFFFF)); aml_append(method, aml_store(aml_to_integer(slot_arg0), diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 3c2b889c6d..42e60c1d3a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -944,9 +944,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(); @@ -956,53 +956,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); @@ -1010,29 +1010,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); @@ -1043,8 +1044,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 de164f2d3e..3a646b12e0 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 e5bb3217c3..6a8d268f84 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 -- cgit v1.2.3