pc: acpi: convert DSDT to AML API and drop ASL templates support
v2 cover pc: acpi: convert DSDT to AML API and drop ASL templates support
Changelog:
v1->v2:
- rebase on top of PCI tree skipping AML API patches
as they are already applied there
- drop a_ prefix for AML variables
- use DIFF env. var. to specify diff utility to show ASL difference
- build ISA device with a function pre device type
at expence of some code duplication it makes code a little bit more readable. Later refactoring will remove duplicated code folding all of it into one simple function for all ISA devices.
- unfold GPE stub handlers loop and opencode it, it adds ~10 extra LOC that will be removed at refactoring stage since stubs are not required by spec/guest leaving only GPE handlers that are actually doing something.
- minor cleanups to make code more readble/clear,
based on Marcel's and Michael's review.
Due to huge size, CCing only cover letter instead of individual patches.
Series converts DSDT using existing and new AML API.
Series does exact byte by byte conversion and passes ACPI tables 'make check' tests.
The conversion first moves common for PIIX4/Q35 parts, getting rid of *.dsl includes and then converts PIIX4 and Q35 parts of DSDT.
Diff-stat looks nice but actual code base is reduced by ~2000LOC while the rest of 10000 removals is dropping precompiled AML templates from the tree.
There are some AML parts that could be optimized/simplified and shared between PIIX4/Q35/ARM but doing it will break exact match with original tests, hence it's left out for later refactoring.
git tree for testing:
https://github.com/imammedo/qemu/tree/drop_ASL_support_v2
or
github.com:imammedo/qemu.git drop_ASL_support_v2
Igor Mammedov (51):
tests: acpi: print ASL diff in verbose mode
pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
pc: acpi: memhp: move MHPD._STA method into SSDT
pc: acpi: memhp: move MHPD.MLCK mutex into SSDT
pc: acpi: memhp: move MHPD.MSCN method into SSDT
pc: acpi: memhp: move MHPD.MRST method into SSDT
pc: acpi: memhp: move MHPD.MPXM method into SSDT
pc: acpi: memhp: move MHPD.MOST method into SSDT
pc: acpi: memhp: move MHPD.MEJ0 method into SSDT
pc: acpi: memhp: move MHPD.MCRS method into SSDT
pc: acpi: memhp: move MHPD Device into SSDT
pc: acpi: factor out memhp code from build_ssdt() into separate
function
pc: acpi: memhp: move \_GPE._E03 into SSDT
pc: acpi: memhp: drop not needed stringify(MEMORY_foo) usage
pc: acpi: drop unused CPU_STATUS_LEN from DSDT
pc: acpi: cpuhp: move CPEJ() method to SSDT
pc: acpi: cpuhp: move CPMA() method into SSDT
pc: acpi: cpuhp: move CPST() method into SSDT
pc: acpi: cpuhp: move PRSC() method into SSDT
pc: acpi: cpuhp: move \_GPE._E02() into SSDT
pc: acpi: factor out cpu hotplug code from build_ssdt() into separate
function
pc: acpi: move HPET from DSDT to SSDT
pc: acpi: move DBUG() from DSDT to SSDT
pc: acpi: move RTC device from DSDT to SSDT
pc: acpi: move KBD device from DSDT to SSDT
pc: acpi: move MOU device from DSDT to SSDT
pc: acpi: move FDC0 device from DSDT to SSDT
pc: acpi: move LPT device from DSDT to SSDT
pc: acpi: move COM devices from DSDT to SSDT
pc: acpi: move PIIX4 isa-bridge and pm devices into SSDT
pc: acpi: move remaining GPE handlers into SSDT
pc: acpi: pci: move link devices into SSDT
pc: acpi: piix4: move IQCR() into SSDT
pc: acpi: piix4: move IQST() into SSDT
pc: acpi: piix4: move PCI0._PRT() into SSDT
pc: acpi: piix4: move remaining PCI hotplug bits into SSDT
pc: acpi: piix4: acpi move PCI0 device to SSDT
pc: acpi: q35: move GSI links to SSDT
pc: acpi: q35: move link devices to SSDT
pc: acpi: q35: move IQCR() into SSDT
pc: acpi: q35: move IQST() into SSDT
pc: acpi: q35: move ISA bridge into SSDT
pc: acpi: q35: move _PRT() into SSDT
pc: acpi: q35: move PRTA routing table into SSDT
pc: acpi: q35: move PRTP routing table into SSDT
pc: acpi: q35: move _PIC() method into SSDT
pc: acpi: q35: move PCI0._OSC() method into SSDT
pc: acpi: q35: move PCI0 device definition into SSDT
pc: acpi: q35: PCST, PCSB opregions and PCIB field into SSDT
pc: acpi: switch to AML API composed DSDT
pc: acpi: remove unused ASL templates and related blobs/utils
hw/acpi/Makefile.objs | 4 +- hw/acpi/cpu_hotplug_acpi_table.c | 135 + hw/acpi/memory_hotplug_acpi_table.c | 262 ++ hw/i386/Makefile.objs | 30 - hw/i386/acpi-build.c | 1367 +++++-- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 90 - hw/i386/acpi-dsdt-dbug.dsl | 41 - hw/i386/acpi-dsdt-hpet.dsl | 48 - hw/i386/acpi-dsdt-isa.dsl | 117 - hw/i386/acpi-dsdt-mem-hotplug.dsl | 171 - hw/i386/acpi-dsdt.dsl | 303 -- hw/i386/acpi-dsdt.hex.generated | 2972 -------------- hw/i386/q35-acpi-dsdt.dsl | 436 -- hw/i386/q35-acpi-dsdt.hex.generated | 7610 ----------------------------------- hw/timer/hpet.c | 2 +- include/hw/acpi/aml-build.h | 3 + include/hw/acpi/cpu_hotplug.h | 10 + include/hw/acpi/memory_hotplug.h | 9 + include/hw/acpi/pc-hotplug.h | 44 +- include/hw/timer/hpet.h | 1 + scripts/acpi_extract.py | 367 -- scripts/acpi_extract_preprocess.py | 51 - scripts/update-acpi.sh | 4 - tests/bios-tables-test.c | 16 + 24 files changed, 1599 insertions(+), 12494 deletions(-) create mode 100644 hw/acpi/cpu_hotplug_acpi_table.c create mode 100644 hw/acpi/memory_hotplug_acpi_table.c delete mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl delete mode 100644 hw/i386/acpi-dsdt-isa.dsl delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl delete mode 100644 hw/i386/acpi-dsdt.dsl delete mode 100644 hw/i386/acpi-dsdt.hex.generated delete mode 100644 hw/i386/q35-acpi-dsdt.dsl delete mode 100644 hw/i386/q35-acpi-dsdt.hex.generated delete mode 100755 scripts/acpi_extract.py delete mode 100755 scripts/acpi_extract_preprocess.py delete mode 100644 scripts/update-acpi.sh
Signature · 1 line
1.8.3.1
PATCH v2 1/51 tests: acpi: print ASL diff in verbose mode
print ASL difference if there is any when executing 'make V=1 check'.
Use 'DIFF' environment variable to determine which diff utility to use and if it's not set notify user by printing warning that DIFF is not set if run in verbose mode and there is difference in ASL.
--- tests/bios-tables-test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tests/bios-tables-test.c +16 -0
@@ -580,6 +580,22 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) { +const char *diff_cmd =getenv ("DIFF" ); +if (diff_cmd) { + int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("%s %s %s" , diff_cmd, + exp_sdt->asl_file, sdt->asl_file); + ret =system (diff) ; +g_free (diff); + }else { +fprintf (stderr,"acpi-test: Warning. not showing " +"difference since no diff utility is specified. " +"Set 'DIFF' environment variable to a preferred " +"diff utility and run 'make V=1 check' again to " +"see ASL difference." ); + } + } } }g_string_free (asl, true);
Signature · 1 line
1.8.3.1
PATCH v2 2/51 pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
In reply to Igor Mammedov--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 30 ++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
hw/acpi/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
hw/acpi/memory_hotplug_acpi_table.c new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Memory hotplug AML code of DSDT ACPI table +* +* Copyright (C) 2015 Red Hat Inc +* +* Author: Igor Mammedov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len) +{ +Aml *pci_scope; +Aml *mem_ctrl_dev; + +/* scope for memory hotplug controller device node */ + pci_scope =aml_scope ("_SB.PCI0" ); + mem_ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); + { + } +aml_append (pci_scope, mem_ctrl_dev); +aml_append (ctx, pci_scope); +}
hw/i386/acpi-build.c +3 -0
@@ -954,6 +954,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); + bus =PC_MACHINE (machine)->bus;if (bus) { QLIST_FOREACH(bus, &bus->child, sibling) {
include/hw/acpi/memory_hotplug.h +4 -0
@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus:
@@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState)void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Signature · 1 line
1.8.3.1
PATCH v2 3/51 pc: acpi: memhp: move MHPD._STA method into SSDT
In reply to Igor Mammedov---
v3:
- drop ASL comment
- s/ctrl_dev/mem_ctrl_dev/
- move locals 'zero', 'slots_nr' inside if block
v2:
- add parentheses around ifctx block
--- hw/acpi/memory_hotplug_acpi_table.c | 14 ++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +14 -0
@@ -17,6 +17,8 @@void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len) { +Aml *ifctx; +Aml *method;Aml *pci_scope;Aml *mem_ctrl_dev;
@@ -24,6 +26,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, pci_scope =aml_scope ("_SB.PCI0" ); mem_ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +Aml *zero =aml_int (0 ); +Aml *slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER )); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (slots_nr, zero)); + { +aml_append (ifctx,aml_return (zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -8
@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {
Signature · 1 line
1.8.3.1
PATCH v2 4/51 pc: acpi: memhp: move MHPD.MLCK mutex into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 2 ++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +2 -0
@@ -38,6 +38,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,/* present, functioning, decoding, not shown in UI */ 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 (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +1 -2
@@ -34,8 +34,7 @@ External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - - Mutex (MEMORY_SLOT_LOCK, 0) + External(MEMORY_SLOT_LOCK, MutexObj) Method(MEMORY_SLOT_SCAN_METHOD, 0) { If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
Signature · 1 line
1.8.3.1
PATCH v2 5/51 pc: acpi: memhp: move MHPD.MSCN method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 60 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 27 +---------------- 2 files changed, 61 insertions(+), 26 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +60 -0
@@ -26,8 +26,11 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, pci_scope =aml_scope ("_SB.PCI0" ); mem_ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +Aml *one =aml_int (1 );Aml *zero =aml_int (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 )); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero));
@@ -40,6 +43,63 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (mem_ctrl_dev, method);aml_append (mem_ctrl_dev,aml_mutex (stringify (MEMORY_SLOT_LOCK ),0 )); + + method =aml_method (stringify (MEMORY_SLOT_SCAN_METHOD ),0 , +AML_NOTSERIALIZED ); + { +Aml *else_ctx; +Aml *while_ctx; +Aml *idx =aml_local (0 ); +Aml *eject_req =aml_int (3 ); +Aml *dev_chk =aml_int (1 ); + + ifctx =aml_if (aml_equal (slots_nr, zero)); + { +aml_append (ifctx,aml_return (zero)); + } +aml_append (method, ifctx); + +aml_append (method,aml_store (zero, idx)); +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +/* build AML that: +* loops over all slots and Notifies DIMMs with +* Device Check or Eject Request notifications if +* slot has corresponding status bit set and clears +* slot status. +*/ + 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_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 ), + idx, dev_chk)); +aml_append (ifctx,aml_store (one, ins_evt)); + } +aml_append (while_ctx, ifctx); + + else_ctx =aml_else (); + ifctx =aml_if (aml_equal (rm_evt, one)); + { +aml_append (ifctx, +aml_call2 (stringify (MEMORY_SLOT_NOTIFY_METHOD ), + idx, eject_req)); +aml_append (ifctx,aml_store (one, rm_evt)); + } +aml_append (else_ctx, ifctx); +aml_append (while_ctx, else_ctx); + +aml_append (while_ctx,aml_add (idx, one, idx)); + } +aml_append (method, while_ctx); +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (one)); + } +aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +1 -26
@@ -13,13 +13,12 @@ * with this program; if not, see <http://www.gnu.org/licenses/>. */ - External(MEMORY_SLOT_NOTIFY_METHOD, MethodObj) + External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj) Scope(\_SB.PCI0) { Device(MEMORY_HOTPLUG_DEVICE) { Name(_HID, "PNP0A06") Name(_UID, "Memory hotplug resources") - External(MEMORY_SLOTS_NUMBER, IntObj) /* Memory hotplug IO registers */ External(MEMORY_SLOT_ADDR_LOW, FieldUnitObj) // read only
@@ -28,36 +27,12 @@ External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only - External(MEMORY_SLOT_INSERT_EVENT, FieldUnitObj) // (read) 1 if has a insert event. (write) 1 to clear event - External(MEMORY_SLOT_REMOVE_EVENT, FieldUnitObj) // (read) 1 if has a remove event. (write) 1 to clear event External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only External(MEMORY_SLOT_LOCK, MutexObj) - Method(MEMORY_SLOT_SCAN_METHOD, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(Zero) - } - - Store(Zero, Local0) // Mem devs iterrator - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - while (LLess(Local0, MEMORY_SLOTS_NUMBER)) { - Store(Local0, MEMORY_SLOT_SLECTOR) // select Local0 DIMM - If (LEqual(MEMORY_SLOT_INSERT_EVENT, One)) { // Memory device needs check - MEMORY_SLOT_NOTIFY_METHOD(Local0, 1) - Store(1, MEMORY_SLOT_INSERT_EVENT) - } Elseif (LEqual(MEMORY_SLOT_REMOVE_EVENT, One)) { // Ejection request - MEMORY_SLOT_NOTIFY_METHOD(Local0, 3) - Store(1, MEMORY_SLOT_REMOVE_EVENT) - } - Add(Local0, One, Local0) // goto next DIMM - } - Release(MEMORY_SLOT_LOCK) - Return(One) - } - Method(MEMORY_SLOT_STATUS_METHOD, 1) { Store(Zero, Local0)
Signature · 1 line
1.8.3.1
PATCH v2 6/51 pc: acpi: memhp: move MHPD.MRST method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 23 +++++++++++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 15 --------------- 2 files changed, 23 insertions(+), 15 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +23 -0
@@ -28,6 +28,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {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 ));
@@ -100,6 +102,27 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_return (one)); }aml_append (mem_ctrl_dev, method); + + method =aml_method (stringify (MEMORY_SLOT_STATUS_METHOD ),1 , +AML_NOTSERIALIZED ); + { +Aml *slot_enabled =aml_name (stringify (MEMORY_SLOT_ENABLED )); + +aml_append (method,aml_store (zero, ret_val)); +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method, +aml_store (aml_to_integer (slot_arg0), slot_selector)); + + ifctx =aml_if (aml_equal (slot_enabled, one)); + { +aml_append (ifctx,aml_store (aml_int (0xF ), ret_val)); + } +aml_append (method, ifctx); + +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (ret_val)); + } +aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -15
@@ -26,27 +26,12 @@ External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only - External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only External(MEMORY_SLOT_LOCK, MutexObj) - Method(MEMORY_SLOT_STATUS_METHOD, 1) { - Store(Zero, Local0) - - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - - If (LEqual(MEMORY_SLOT_ENABLED, One)) { - Store(0xF, Local0) - } - - Release(MEMORY_SLOT_LOCK) - Return(Local0) - } - Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) { Acquire(MEMORY_SLOT_LOCK, 0xFFFF) Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
Signature · 1 line
1.8.3.1
PATCH v2 7/51 pc: acpi: memhp: move MHPD.MPXM method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 14 ++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 9 --------- 2 files changed, 14 insertions(+), 9 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +14 -0
@@ -123,6 +123,20 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_return (ret_val)); }aml_append (mem_ctrl_dev, method); + + method =aml_method (stringify (MEMORY_SLOT_PROXIMITY_METHOD ),1 , +AML_NOTSERIALIZED ); + { +Aml *proximity =aml_name (stringify (MEMORY_SLOT_PROXIMITY )); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); +aml_append (method,aml_store (proximity, ret_val)); +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (ret_val)); + } +aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -9
@@ -25,7 +25,6 @@ External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only - External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
@@ -96,14 +95,6 @@ Return(MR64) } - Method(MEMORY_SLOT_PROXIMITY_METHOD, 1) { - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - Store(MEMORY_SLOT_PROXIMITY, Local0) - Release(MEMORY_SLOT_LOCK) - Return(Local0) - } - Method(MEMORY_SLOT_OST_METHOD, 4) { Acquire(MEMORY_SLOT_LOCK, 0xFFFF) Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
Signature · 1 line
1.8.3.1
PATCH v2 8/51 pc: acpi: memhp: move MHPD.MOST method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 15 +++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 10 ---------- 2 files changed, 15 insertions(+), 10 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +15 -0
@@ -137,6 +137,21 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_return (ret_val)); }aml_append (mem_ctrl_dev, method); + + method =aml_method (stringify (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_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); +aml_append (method,aml_store (aml_arg (1 ), ost_evt)); +aml_append (method,aml_store (aml_arg (2 ), ost_status)); +aml_append (method,aml_release (ctrl_lock)); + } +aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -10
@@ -27,8 +27,6 @@ External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only - External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only - External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only External(MEMORY_SLOT_LOCK, MutexObj) Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
@@ -95,14 +93,6 @@ Return(MR64) } - Method(MEMORY_SLOT_OST_METHOD, 4) { - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - Store(Arg1, MEMORY_SLOT_OST_EVENT) - Store(Arg2, MEMORY_SLOT_OST_STATUS) - Release(MEMORY_SLOT_LOCK) - } - Method(MEMORY_SLOT_EJECT_METHOD, 2) { Acquire(MEMORY_SLOT_LOCK, 0xFFFF) Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
Signature · 1 line
1.8.3.1
PATCH v2 9/51 pc: acpi: memhp: move MHPD.MEJ0 method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 13 +++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 13 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +13 -0
@@ -152,6 +152,19 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock)); }aml_append (mem_ctrl_dev, method); + + method =aml_method (stringify (MEMORY_SLOT_EJECT_METHOD ),2 , +AML_NOTSERIALIZED ); + { +Aml *eject =aml_name (stringify (MEMORY_SLOT_EJECT )); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); +aml_append (method,aml_store (one, eject)); +aml_append (method,aml_release (ctrl_lock)); + } +aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -8
@@ -25,7 +25,6 @@ External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only - External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_LOCK, MutexObj)
@@ -92,12 +91,5 @@ Release(MEMORY_SLOT_LOCK) Return(MR64) } - - Method(MEMORY_SLOT_EJECT_METHOD, 2) { - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - Store(1, MEMORY_SLOT_EJECT) - Release(MEMORY_SLOT_LOCK) - } } // Device() } // Scope()
Signature · 1 line
1.8.3.1
PATCH v2 10/51 pc: acpi: memhp: move MHPD.MCRS method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 92 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 72 ----------------------------- 2 files changed, 92 insertions(+), 72 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +92 -0
@@ -124,6 +124,98 @@ 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 ); + { +Aml *mr64 =aml_name ("MR64" ); +Aml *mr32 =aml_name ("MR32" ); +Aml *crs_tmpl =aml_resource_template (); +Aml *minl =aml_name ("MINL" ); +Aml *minh =aml_name ("MINH" ); +Aml *maxl =aml_name ("MAXL" ); +Aml *maxh =aml_name ("MAXH" ); +Aml *lenl =aml_name ("LENL" ); +Aml *lenh =aml_name ("LENH" ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); + +aml_append (crs_tmpl, +aml_qword_memory (AML_POS_DECODE ,AML_MIN_FIXED ,AML_MAX_FIXED , +AML_CACHEABLE ,AML_READ_WRITE , +0 ,0x0 ,0xFFFFFFFFFFFFFFFE ,0 , +0xFFFFFFFFFFFFFFFF )); +aml_append (method,aml_name_decl ("MR64" , crs_tmpl)); +aml_append (method, +aml_create_dword_field (mr64,aml_int (14 ),"MINL" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (18 ),"MINH" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (38 ),"LENL" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (42 ),"LENH" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (22 ),"MAXL" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (26 ),"MAXH" )); + +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_ADDR_HIGH )), minh)); +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_ADDR_LOW )), minl)); +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_SIZE_HIGH )), lenh)); +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_SIZE_LOW )), lenl)); + +/* 64-bit math: MAX = MIN + LEN - 1 */ +aml_append (method,aml_add (minl, lenl, maxl)); +aml_append (method,aml_add (minh, lenh, maxh)); + ifctx =aml_if (aml_lless (maxl, minl)); + { +aml_append (ifctx,aml_add (maxh, one, maxh)); + } +aml_append (method, ifctx); + ifctx =aml_if (aml_lless (maxl, one)); + { +aml_append (ifctx,aml_subtract (maxh, one, maxh)); + } +aml_append (method, ifctx); +aml_append (method,aml_subtract (maxl, one, maxl)); + +/* return 32-bit _CRS if addr/size is in low mem */ +/* TODO: remove it since all hotplugged DIMMs are in high mem */ + ifctx =aml_if (aml_equal (maxh, zero)); + { + crs_tmpl =aml_resource_template (); +aml_append (crs_tmpl, +aml_dword_memory (AML_POS_DECODE ,AML_MIN_FIXED , +AML_MAX_FIXED ,AML_CACHEABLE , +AML_READ_WRITE , +0 ,0x0 ,0xFFFFFFFE ,0 , +0xFFFFFFFF )); +aml_append (ifctx,aml_name_decl ("MR32" , crs_tmpl)); +aml_append (ifctx, +aml_create_dword_field (mr32,aml_int (10 ),"MIN" )); +aml_append (ifctx, +aml_create_dword_field (mr32,aml_int (14 ),"MAX" )); +aml_append (ifctx, +aml_create_dword_field (mr32,aml_int (22 ),"LEN" )); +aml_append (ifctx,aml_store (minl,aml_name ("MIN" ))); +aml_append (ifctx,aml_store (maxl,aml_name ("MAX" ))); +aml_append (ifctx,aml_store (lenl,aml_name ("LEN" ))); + +aml_append (ifctx,aml_release (ctrl_lock)); +aml_append (ifctx,aml_return (mr32)); + } +aml_append (method, ifctx); + +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (mr64)); + } +aml_append (mem_ctrl_dev, method); + method =aml_method (stringify (MEMORY_SLOT_PROXIMITY_METHOD ),1 ,AML_NOTSERIALIZED ); {
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -72
77 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 11/51 pc: acpi: memhp: move MHPD Device into SSDT
In reply to Igor Mammedovmove remnants of MHPD device from DSDT into SSDT.
i.e. Device(MHPD), _UID, _HID
--- hw/acpi/memory_hotplug_acpi_table.c | 6 +++++- hw/i386/acpi-dsdt-mem-hotplug.dsl | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +5 -1
@@ -24,7 +24,7 @@ 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_scope (stringify (MEMORY_HOTPLUG_DEVICE )); + mem_ctrl_dev =aml_device (stringify (MEMORY_HOTPLUG_DEVICE )); {Aml *one =aml_int (1 );Aml *zero =aml_int (0 );
@@ -34,6 +34,10 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,Aml *ctrl_lock =aml_name (stringify (MEMORY_SLOT_LOCK ));Aml *slot_selector =aml_name (stringify (MEMORY_SLOT_SLECTOR )); +aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" ))); +aml_append (mem_ctrl_dev, +aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero)); {
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -7
@@ -14,10 +14,3 @@ */ External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj) - - Scope(\_SB.PCI0) { - Device(MEMORY_HOTPLUG_DEVICE) { - Name(_HID, "PNP0A06") - Name(_UID, "Memory hotplug resources") - } // Device() - } // Scope()
Signature · 1 line
1.8.3.1
PATCH v2 12/51 pc: acpi: factor out memhp code from build_ssdt() into separate function
In reply to Igor Mammedovbefore consolidating memhp code in memory_hotplug_acpi_table.c and for simplifying review, first factor out memhp code into new function build_memory_devices() in i386/acpi-build.c
----
PS:
no functional change, only code movement.
--- hw/i386/acpi-build.c | 239 +++++++++++++++++++++++++++------------------------ 1 file changed, 126 insertions(+), 113 deletions(-)
hw/i386/acpi-build.c +126 -113
@@ -929,6 +929,130 @@ static Aml *build_crs(PCIHostState *host,return crs; } +static void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len) +{ +int i; +Aml *scope; +Aml *crs; +Aml *field; +Aml *dev; +Aml *method; +Aml *ifctx; + +/* build memory devices */ +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); + scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); +aml_append (scope, +aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +aml_append (scope,aml_name_decl ("_CRS" , crs)); + +aml_append (scope,aml_operation_region ( +stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , + io_base, io_len) + ); + + field =aml_field (stringify (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_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); +aml_append (scope, field); + + field =aml_field (stringify (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_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (stringify (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_append (field, +/* initiates device eject, write only */ +aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); +aml_append (scope, field); + + field =aml_field (stringify (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_append (field,/* _OST event code, write only */ +aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (stringify (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) "." +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(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); +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); +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); +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); +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* 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 ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1231,119 +1355,8 @@ build_ssdt(GArray *table_data, GArray *linker, }aml_append (sb_scope,aml_name_decl ("CPON" , pkg)); -/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); -aml_append (scope, -aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , pm->mem_hp_io_base, pm->mem_hp_io_base,0 , - pm->mem_hp_io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , - pm->mem_hp_io_base, pm->mem_hp_io_len) - ); - - field =aml_field (stringify (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_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); -aml_append (scope, field); - - field =aml_field (stringify (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_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (stringify (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_append (field, -/* initiates device eject, write only */ -aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); -aml_append (scope, field); - - field =aml_field (stringify (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_append (field,/* _OST event code, write only */ -aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (stringify (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) "." -const char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(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); -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); -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); -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); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* 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 ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); +build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); {Object *pci_host;
Signature · 1 line
1.8.3.1
PATCH v2 13/51 pc: acpi: memhp: move \_GPE._E03 into SSDT
In reply to Igor Mammedovin addition remove no longer needed acpi-dsdt-mem-hotplug.dsl.
--- hw/i386/acpi-build.c | 6 ++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 16 ---------------- hw/i386/acpi-dsdt.dsl | 5 ----- hw/i386/q35-acpi-dsdt.dsl | 5 ----- include/hw/acpi/memory_hotplug.h | 5 +++++ include/hw/acpi/pc-hotplug.h | 2 -- 6 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl
hw/i386/acpi-build.c +6 -0
@@ -1081,6 +1081,12 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); + scope =aml_scope ("\\_GPE" ); + method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); +aml_append (scope, method); +aml_append (ssdt, scope); + bus =PC_MACHINE (machine)->bus;if (bus) { QLIST_FOREACH(bus, &bus->child, sibling) {
hw/i386/acpi-dsdt-mem-hotplug.dsl deleted +0 -16
@@ -1,16 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ - - External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj)
hw/i386/acpi-dsdt.dsl +0 -5
@@ -250,7 +250,6 @@ DefinitionBlock ( #include "hw/acpi/pc-hotplug.h" #define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl" -#include "acpi-dsdt-mem-hotplug.dsl" /****************************************************************
@@ -271,10 +270,6 @@ DefinitionBlock ( // CPU hotplug event \_SB.PRSC() } - Method(_E03) { - // Memory hotplug event - \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
hw/i386/q35-acpi-dsdt.dsl +0 -5
@@ -387,7 +387,6 @@ DefinitionBlock ( #include "hw/acpi/pc-hotplug.h" #define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl" -#include "acpi-dsdt-mem-hotplug.dsl" /****************************************************************
@@ -404,10 +403,6 @@ DefinitionBlock ( // CPU hotplug event \_SB.PRSC() } - Method(_E03) { - // Memory hotplug event - \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
include/hw/acpi/memory_hotplug.h +5 -0
@@ -47,6 +47,11 @@ 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_HANDLER_PATH "\\_SB.PCI0." \ + stringify(MEMORY_HOTPLUG_DEVICE) "." stringify(MEMORY_SLOT_SCAN_METHOD) +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);#endif
include/hw/acpi/pc-hotplug.h +0 -2
@@ -32,7 +32,6 @@#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00 -#define MEMORY_HOTPLUG_DEVICE MHPD#define MEMORY_SLOTS_NUMBER MDNR#define MEMORY_HOTPLUG_IO_REGION HPMR#define MEMORY_SLOT_ADDR_LOW MRBL
@@ -54,6 +53,5 @@#define MEMORY_SLOT_PROXIMITY_METHOD MPXM#define MEMORY_SLOT_EJECT_METHOD MEJ0#define MEMORY_SLOT_NOTIFY_METHOD MTFY -#define MEMORY_SLOT_SCAN_METHOD MSCN#endif
Signature · 1 line
1.8.3.1
PATCH v2 14/51 pc: acpi: memhp: drop not needed stringify(MEMORY_foo) usage
In reply to Igor Mammedovmost 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.
--- 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(-)
hw/acpi/memory_hotplug_acpi_table.c +24 -29
@@ -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),
hw/i386/acpi-build.c +26 -26
125 lines not on this page · raw message
include/hw/acpi/memory_hotplug.h +3 -3
@@ -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_METHODvoid build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);
include/hw/acpi/pc-hotplug.h +21 -21
47 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 15/51 pc: acpi: drop unused CPU_STATUS_LEN from DSDT
In reply to Igor Mammedov--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 1 - 1 file changed, 1 deletion(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -1
@@ -53,7 +53,6 @@ Scope(\_SB) { Sleep(200) } -#define CPU_STATUS_LEN ACPI_GPE_PROC_LEN Method(PRSC, 0) { // Local5 = active cpu bitmap Store(PRS, Local5)
Signature · 1 line
1.8.3.1
PATCH v2 16/51 pc: acpi: cpuhp: move CPEJ() method to SSDT
In reply to Igor Mammedov--- hw/acpi/Makefile.objs | 2 +- hw/acpi/cpu_hotplug_acpi_table.c | 28 ++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 ++- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 4 ---- include/hw/acpi/cpu_hotplug.h | 5 +++++ 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 hw/acpi/cpu_hotplug_acpi_table.c
hw/acpi/Makefile.objs +1 -1
@@ -1,6 +1,6 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o -common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o +common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o cpu_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI) += acpi_interface.o
hw/acpi/cpu_hotplug_acpi_table.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "hw/acpi/cpu_hotplug.h" + +void build_cpu_hotplug_aml (Aml *ctx) +{ +Aml *method; +Aml *sb_scope =aml_scope ("_SB" ); + + method =aml_method (CPU_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); +aml_append (method,aml_sleep (200 )); +aml_append (sb_scope, method); + +aml_append (ctx, sb_scope); +}
hw/i386/acpi-build.c +2 -1
@@ -1078,6 +1078,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
@@ -1324,7 +1325,7 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method, -aml_return (aml_call2 ("CPEJ" ,aml_int (i),aml_arg (0 ))) +aml_return (aml_call2 (CPU_EJECT_METHOD ,aml_int (i),aml_arg (0 ))) );aml_append (dev, method);
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -4
@@ -48,10 +48,6 @@ Scope(\_SB) { Return (0x0) } } - Method(CPEJ, 2, NotSerialized) { - // _EJ0 method - eject callback - Sleep(200) - } Method(PRSC, 0) { // Local5 = active cpu bitmap
include/hw/acpi/cpu_hotplug.h +5 -0
@@ -14,6 +14,7 @@#include "hw/acpi/acpi.h" #include "hw/acpi/pc-hotplug.h" +#include "hw/acpi/aml-build.h" typedef struct AcpiCpuHotplug { MemoryRegion io;
@@ -25,4 +26,8 @@ void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,void acpi_cpu_hotplug_init (MemoryRegion *parent,Object *owner,AcpiCpuHotplug *gpe_cpu,uint16_t base); + +#define CPU_EJECT_METHOD "CPEJ" + +void build_cpu_hotplug_aml (Aml *ctx);#endif
Signature · 1 line
1.8.3.1
PATCH v2 17/51 pc: acpi: cpuhp: move CPMA() method into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 23 +++++++++++++++++++++++ hw/i386/acpi-build.c | 5 +++-- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 13 ------------- include/hw/acpi/cpu_hotplug.h | 2 ++ 4 files changed, 28 insertions(+), 15 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +23 -0
@@ -19,6 +19,29 @@ void build_cpu_hotplug_aml(Aml *ctx) {Aml *method;Aml *sb_scope =aml_scope ("_SB" ); +uint8_t madt_tmpl[8 ] = {0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0 ,0 ,0 }; +Aml *cpu_id =aml_arg (0 ); +Aml *cpu_on =aml_local (0 ); +Aml *madt =aml_local (1 ); +Aml *cpus_map =aml_name (CPU_ON_BITMAP ); + +/* +* _MAT method - creates an madt apic buffer +* cpu_id = Arg0 = Processor ID = Local APIC ID +* cpu_on = Local0 = CPON flag for this cpu +* madt = Local1 = Buffer (in madt apic form) to return +*/ + method =aml_method (CPU_MAT_METHOD ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_store (aml_derefof (aml_index (cpus_map, cpu_id)), cpu_on)); +aml_append (method, +aml_store (aml_buffer (sizeof (madt_tmpl), madt_tmpl), madt)); +/* Update the processor id, lapic id, and enable/disable status */ +aml_append (method,aml_store (cpu_id,aml_index (madt,aml_int (2 )))); +aml_append (method,aml_store (cpu_id,aml_index (madt,aml_int (3 )))); +aml_append (method,aml_store (cpu_on,aml_index (madt,aml_int (4 )))); +aml_append (method,aml_return (madt)); +aml_append (sb_scope, method); method =aml_method (CPU_EJECT_METHOD ,2 ,AML_NOTSERIALIZED );aml_append (method,aml_sleep (200 ));
hw/i386/acpi-build.c +3 -2
@@ -1316,7 +1316,8 @@ build_ssdt(GArray *table_data, GArray *linker, dev =aml_processor (i,0 ,0 ,"CP%.02X" , i); method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (aml_call1 ("CPMA" ,aml_int (i)))); +aml_append (method, +aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (i))));aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED );
@@ -1360,7 +1361,7 @@ build_ssdt(GArray *table_data, GArray *linker,uint8_t b =test_bit (i, cpu->found_cpus) ?0x01 :0x00 ;aml_append (pkg,aml_int (b)); } -aml_append (sb_scope,aml_name_decl ("CPON" , pkg)); +aml_append (sb_scope,aml_name_decl (CPU_ON_BITMAP , pkg));build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -13
@@ -24,19 +24,6 @@ Scope(\_SB) { External(PRS, FieldUnitObj) /* Methods called by run-time generated SSDT Processor objects */ - Method(CPMA, 1, NotSerialized) { - // _MAT method - create an madt apic buffer - // Arg0 = Processor ID = Local APIC ID - // Local0 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Arg0)), Local0) - // Local1 = Buffer (in madt apic form) to return - Store(Buffer(8) {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}, Local1) - // Update the processor id, lapic id, and enable/disable status - Store(Arg0, Index(Local1, 2)) - Store(Arg0, Index(Local1, 3)) - Store(Local0, Index(Local1, 4)) - Return (Local1) - } Method(CPST, 1, NotSerialized) { // _STA method - return ON status of cpu // Arg0 = Processor ID = Local APIC ID
include/hw/acpi/cpu_hotplug.h +2 -0
@@ -28,6 +28,8 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base);#define CPU_EJECT_METHOD "CPEJ" +#define CPU_MAT_METHOD "CPMA" +#define CPU_ON_BITMAP "CPON"void build_cpu_hotplug_aml (Aml *ctx);#endif
Signature · 1 line
1.8.3.1
PATCH v2 18/51 pc: acpi: cpuhp: move CPST() method into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 22 ++++++++++++++++++++++ hw/i386/acpi-build.c | 3 ++- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 12 ------------ include/hw/acpi/cpu_hotplug.h | 1 + 4 files changed, 25 insertions(+), 13 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +22 -0
@@ -18,6 +18,8 @@void build_cpu_hotplug_aml (Aml *ctx) {Aml *method; +Aml *if_ctx; +Aml *else_ctx;Aml *sb_scope =aml_scope ("_SB" );uint8_t madt_tmpl[8 ] = {0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0 ,0 ,0 };Aml *cpu_id =aml_arg (0 );
@@ -43,6 +45,26 @@ void build_cpu_hotplug_aml(Aml *ctx)aml_append (method,aml_return (madt));aml_append (sb_scope, method); +/* +* _STA method - return ON status of cpu +* cpu_id = Arg0 = Processor ID = Local APIC ID +* cpu_on = Local0 = CPON flag for this cpu +*/ + method =aml_method (CPU_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_store (aml_derefof (aml_index (cpus_map, cpu_id)), cpu_on)); + if_ctx =aml_if (cpu_on); + { +aml_append (if_ctx,aml_return (aml_int (0xF ))); + } +aml_append (method, if_ctx); + else_ctx =aml_else (); + { +aml_append (else_ctx,aml_return (aml_int (0x0 ))); + } +aml_append (method, else_ctx); +aml_append (sb_scope, method); + method =aml_method (CPU_EJECT_METHOD ,2 ,AML_NOTSERIALIZED );aml_append (method,aml_sleep (200 ));aml_append (sb_scope, method);
hw/i386/acpi-build.c +2 -1
@@ -1321,7 +1321,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (aml_call1 ("CPST" ,aml_int (i)))); +aml_append (method, +aml_return (aml_call1 (CPU_STATUS_METHOD ,aml_int (i))));aml_append (dev, method); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -12
@@ -24,18 +24,6 @@ Scope(\_SB) { External(PRS, FieldUnitObj) /* Methods called by run-time generated SSDT Processor objects */ - Method(CPST, 1, NotSerialized) { - // _STA method - return ON status of cpu - // Arg0 = Processor ID = Local APIC ID - // Local0 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Arg0)), Local0) - If (Local0) { - Return (0xF) - } Else { - Return (0x0) - } - } - Method(PRSC, 0) { // Local5 = active cpu bitmap Store(PRS, Local5)
include/hw/acpi/cpu_hotplug.h +1 -0
@@ -30,6 +30,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,#define CPU_EJECT_METHOD "CPEJ"#define CPU_MAT_METHOD "CPMA"#define CPU_ON_BITMAP "CPON" +#define CPU_STATUS_METHOD "CPST"void build_cpu_hotplug_aml (Aml *ctx);#endif
Signature · 1 line
1.8.3.1
PATCH v2 19/51 pc: acpi: cpuhp: move PRSC() method into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 64 ++++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 2 +- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +----------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- include/hw/acpi/aml-build.h | 2 ++ include/hw/acpi/cpu_hotplug.h | 1 + include/hw/acpi/pc-hotplug.h | 1 + 8 files changed, 71 insertions(+), 42 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +63 -1
@@ -26,6 +26,8 @@ void build_cpu_hotplug_aml(Aml *ctx)Aml *cpu_on =aml_local (0 );Aml *madt =aml_local (1 );Aml *cpus_map =aml_name (CPU_ON_BITMAP ); +Aml *zero =aml_int (0 ); +Aml *one =aml_int (1 );/* * _MAT method - creates an madt apic buffer
@@ -60,7 +62,7 @@ void build_cpu_hotplug_aml(Aml *ctx)aml_append (method, if_ctx); else_ctx =aml_else (); { -aml_append (else_ctx,aml_return (aml_int (0x0 ))); +aml_append (else_ctx,aml_return (zero)); }aml_append (method, else_ctx);aml_append (sb_scope, method);
@@ -69,5 +71,65 @@ void build_cpu_hotplug_aml(Aml *ctx)aml_append (method,aml_sleep (200 ));aml_append (sb_scope, method); + method =aml_method (stringify (CPU_SCAN_METHOD ),0 ,AML_NOTSERIALIZED ); + { +Aml *while_ctx, *if_ctx2, *else_ctx2; +Aml *bus_check_evt =aml_int (1 ); +Aml *remove_evt =aml_int (3 ); +Aml *status_map =aml_local (5 );/* Local5 = active cpu bitmap */ +Aml *byte =aml_local (2 );/* Local2 = last read byte from bitmap */ +Aml *idx =aml_local (0 );/* Processor ID / APIC ID iterator */ +Aml *is_cpu_on =aml_local (1 );/* Local1 = CPON flag for cpu */ +Aml *status =aml_local (3 );/* Local3 = active state for cpu */ + +aml_append (method,aml_store (aml_name (CPU_STATUS_MAP ), status_map)); +aml_append (method,aml_store (zero, byte)); +aml_append (method,aml_store (zero, idx)); + +/* While (idx < SizeOf(CPON)) */ + while_ctx =aml_while (aml_lless (idx,aml_sizeof (cpus_map))); +aml_append (while_ctx, +aml_store (aml_derefof (aml_index (cpus_map, idx)), is_cpu_on)); + + if_ctx =aml_if (aml_and (idx,aml_int (0x07 ),NULL )); + { +/* Shift down previously read bitmap byte */ +aml_append (if_ctx,aml_shiftright (byte, one, byte)); + } +aml_append (while_ctx, if_ctx); + + else_ctx =aml_else (); + { +/* Read next byte from cpu bitmap */ +aml_append (else_ctx,aml_store (aml_derefof (aml_index (status_map, +aml_shiftright (idx,aml_int (3 ),NULL ))), byte)); + } +aml_append (while_ctx, else_ctx); + +aml_append (while_ctx,aml_store (aml_and (byte, one,NULL ), status)); + if_ctx =aml_if (aml_lnot (aml_equal (is_cpu_on, status))); + { +/* State change - update CPON with new state */ +aml_append (if_ctx,aml_store (status,aml_index (cpus_map, idx))); + if_ctx2 =aml_if (aml_equal (status, one)); + { +aml_append (if_ctx2, +aml_call2 (AML_NOTIFY_METHOD , idx, bus_check_evt)); + } +aml_append (if_ctx, if_ctx2); + else_ctx2 =aml_else (); + { +aml_append (else_ctx2, +aml_call2 (AML_NOTIFY_METHOD , idx, remove_evt)); + } + } +aml_append (if_ctx, else_ctx2); +aml_append (while_ctx, if_ctx); + +aml_append (while_ctx,aml_increment (idx));/* go to next cpu */ +aml_append (method, while_ctx); + } +aml_append (sb_scope, method); +aml_append (ctx, sb_scope); }
hw/i386/acpi-build.c +1 -1
@@ -1338,7 +1338,7 @@ build_ssdt(GArray *table_data, GArray *linker,* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ /* Arg0 = Processor ID = APIC ID */ - method =aml_method ("NTFY" ,2 ,AML_NOTSERIALIZED ); + method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED );for (i =0 ; i < acpi_cpus; i++) { ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); aml_append(ifctx,
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -38
@@ -19,42 +19,5 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ - External(NTFY, MethodObj) - External(CPON, PkgObj) - External(PRS, FieldUnitObj) - - /* Methods called by run-time generated SSDT Processor objects */ - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } + External(CPU_SCAN_METHOD, MethodObj) }
hw/i386/acpi-dsdt.dsl +1 -1
@@ -268,7 +268,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPU_SCAN_METHOD() } Method(_L04) { }
hw/i386/q35-acpi-dsdt.dsl +1 -1
@@ -401,7 +401,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPU_SCAN_METHOD() } Method(_L04) { }
include/hw/acpi/aml-build.h +2 -0
@@ -16,6 +16,8 @@#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log" +#define AML_NOTIFY_METHOD "NTFY" + typedef enum { AML_NO_OPCODE = 0,/* has only data */ AML_OPCODE, /* has opcode optionally followed by data */
include/hw/acpi/cpu_hotplug.h +1 -0
@@ -31,6 +31,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,#define CPU_MAT_METHOD "CPMA"#define CPU_ON_BITMAP "CPON"#define CPU_STATUS_METHOD "CPST" +#define CPU_STATUS_MAP "PRS"void build_cpu_hotplug_aml (Aml *ctx);#endif
include/hw/acpi/pc-hotplug.h +1 -0
@@ -28,6 +28,7 @@#define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00#define CPU_HOTPLUG_RESOURCE_DEVICE PRES +#define CPU_SCAN_METHOD PRSC#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
Signature · 1 line
1.8.3.1
PATCH v2 20/51 pc: acpi: cpuhp: move \_GPE._E02() into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 2 +- hw/i386/acpi-build.c | 12 +++++++++--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 23 ----------------------- hw/i386/acpi-dsdt.dsl | 9 --------- hw/i386/q35-acpi-dsdt.dsl | 9 --------- include/hw/acpi/cpu_hotplug.h | 1 + include/hw/acpi/pc-hotplug.h | 1 - 7 files changed, 11 insertions(+), 46 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl
hw/acpi/cpu_hotplug_acpi_table.c +1 -1
@@ -71,7 +71,7 @@ void build_cpu_hotplug_aml(Aml *ctx)aml_append (method,aml_sleep (200 ));aml_append (sb_scope, method); - method =aml_method (stringify (CPU_SCAN_METHOD ),0 ,AML_NOTSERIALIZED ); + method =aml_method (CPU_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {Aml *while_ctx, *if_ctx2, *else_ctx2;Aml *bus_check_evt =aml_int (1 );
hw/i386/acpi-build.c +9 -3
@@ -1083,9 +1083,15 @@ build_ssdt(GArray *table_data, GArray *linker, pm->mem_hp_io_len); scope =aml_scope ("\\_GPE" ); - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); + { + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD )); +aml_append (scope, method); + + method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); +aml_append (scope, method); + }aml_append (ssdt, scope); bus =PC_MACHINE (machine)->bus;
hw/i386/acpi-dsdt-cpu-hotplug.dsl deleted +0 -23
@@ -1,23 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -/**************************************************************** - * CPU hotplug - ****************************************************************/ - -Scope(\_SB) { - /* Objects filled in by run-time generated SSDT */ - External(CPU_SCAN_METHOD, MethodObj) -}
hw/i386/acpi-dsdt.dsl +0 -9
@@ -247,11 +247,6 @@ DefinitionBlock ( } } -#include "hw/acpi/pc-hotplug.h" -#define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE -#include "acpi-dsdt-cpu-hotplug.dsl" - - /**************************************************************** * General purpose events ****************************************************************/
@@ -266,10 +261,6 @@ DefinitionBlock ( \_SB.PCI0.PCNT() Release(\_SB.PCI0.BLCK) } - Method(_E02) { - // CPU hotplug event - \_SB.CPU_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
hw/i386/q35-acpi-dsdt.dsl +0 -9
@@ -384,11 +384,6 @@ DefinitionBlock ( define_gsi_link(GSIH, 0, 0x17) } -#include "hw/acpi/pc-hotplug.h" -#define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE -#include "acpi-dsdt-cpu-hotplug.dsl" - - /**************************************************************** * General purpose events ****************************************************************/
@@ -399,10 +394,6 @@ DefinitionBlock ( } Method(_L01) { } - Method(_E02) { - // CPU hotplug event - \_SB.CPU_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
include/hw/acpi/cpu_hotplug.h +1 -0
@@ -32,6 +32,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,#define CPU_ON_BITMAP "CPON"#define CPU_STATUS_METHOD "CPST"#define CPU_STATUS_MAP "PRS" +#define CPU_SCAN_METHOD "PRSC"void build_cpu_hotplug_aml (Aml *ctx);#endif
include/hw/acpi/pc-hotplug.h +0 -1
@@ -28,7 +28,6 @@#define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00#define CPU_HOTPLUG_RESOURCE_DEVICE PRES -#define CPU_SCAN_METHOD PRSC#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
Signature · 1 line
1.8.3.1
PATCH v2 21/51 pc: acpi: factor out cpu hotplug code from build_ssdt() into separate function
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 174 ++++++++++++++++++++++++++++----------------------- 1 file changed, 94 insertions(+), 80 deletions(-)
hw/i386/acpi-build.c +94 -80
@@ -929,6 +929,98 @@ static Aml *build_crs(PCIHostState *host,return crs; } +static void build_processor_devices (Aml *sb_scope,unsigned acpi_cpus, +AcpiCpuInfo *cpu,AcpiPmInfo *pm) +{ +int i; +Aml *dev; +Aml *crs; +Aml *pkg; +Aml *field; +Aml *ifctx; +Aml *method; + +/* The current AML generator can cover the APIC ID range [0..255], +* inclusive, for VCPU hotplug. */ +QEMU_BUILD_BUG_ON (ACPI_CPU_HOTPLUG_ID_LIMIT >256 ); +g_assert (acpi_cpus <=ACPI_CPU_HOTPLUG_ID_LIMIT ); + +/* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */ + dev =aml_device ("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE )); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A06" ))); +aml_append (dev, +aml_name_decl ("_UID" ,aml_string ("CPU Hotplug resources" )) + ); +/* device present, functioning, decoding, not shown in UI */ +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , pm->cpu_hp_io_base, pm->cpu_hp_io_base,1 , + pm->cpu_hp_io_len) + ); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (sb_scope, dev); +/* declare CPU hotplug MMIO region and PRS field to access it */ +aml_append (sb_scope,aml_operation_region ( +"PRST" ,AML_SYSTEM_IO , pm->cpu_hp_io_base, pm->cpu_hp_io_len)); + field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("PRS" ,256 )); +aml_append (sb_scope, field); + +/* build Processor object for each processor */ +for (i =0 ; i < acpi_cpus; i++) { + dev =aml_processor (i,0 ,0 ,"CP%.02X" , i); + + method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (i)))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call1 (CPU_STATUS_METHOD ,aml_int (i)))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call2 (CPU_EJECT_METHOD ,aml_int (i),aml_arg (0 ))) + ); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* build this code: +* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} +*/ +/* Arg0 = Processor ID = APIC ID */ + method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < acpi_cpus; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("CP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); + +/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" +* +* Note: The ability to create variable-sized packages was first +* introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages +* ith up to 255 elements. Windows guests up to win2k8 fail when +* VarPackageOp is used. +*/ + pkg = acpi_cpus <=255 ?aml_package (acpi_cpus) : +aml_varpackage (acpi_cpus); + +for (i =0 ; i < acpi_cpus; i++) { +uint8_t b =test_bit (i, cpu->found_cpus) ?0x01 :0x00 ; +aml_append (pkg,aml_int (b)); + } +aml_append (sb_scope,aml_name_decl (CPU_ON_BITMAP , pkg)); +} +static void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len) {
@@ -1060,8 +1152,7 @@ build_ssdt(GArray *table_data, GArray *linker, {MachineState *machine =MACHINE (qdev_get_machine ());uint32_t nr_mem = machine->ram_slots; -unsigned acpi_cpus = guest_info->apic_id_limit; -Aml *ssdt, *sb_scope, *scope, *pkg, *dev, *method, *crs, *field, *ifctx; +Aml *ssdt, *sb_scope, *scope, *pkg, *dev, *method, *crs, *field;PCIBus *bus =NULL ;GPtrArray *io_ranges =g_ptr_array_new_with_free_func (crs_range_free);GPtrArray *mem_ranges =g_ptr_array_new_with_free_func (crs_range_free);
@@ -1070,10 +1161,6 @@ build_ssdt(GArray *table_data, GArray *linker,int i; ssdt =init_aml_allocator (); -/* The current AML generator can cover the APIC ID range [0..255], -* inclusive, for VCPU hotplug. */ -QEMU_BUILD_BUG_ON (ACPI_CPU_HOTPLUG_ID_LIMIT >256 ); -g_assert (acpi_cpus <=ACPI_CPU_HOTPLUG_ID_LIMIT );/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader));
@@ -1295,80 +1382,7 @@ build_ssdt(GArray *table_data, GArray *linker, sb_scope =aml_scope ("\\_SB" ); { -/* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */ - dev =aml_device ("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE )); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A06" ))); -aml_append (dev, -aml_name_decl ("_UID" ,aml_string ("CPU Hotplug resources" )) - ); -/* device present, functioning, decoding, not shown in UI */ -aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , pm->cpu_hp_io_base, pm->cpu_hp_io_base,1 , - pm->cpu_hp_io_len) - ); -aml_append (dev,aml_name_decl ("_CRS" , crs)); -aml_append (sb_scope, dev); -/* declare CPU hotplug MMIO region and PRS field to access it */ -aml_append (sb_scope,aml_operation_region ( -"PRST" ,AML_SYSTEM_IO , pm->cpu_hp_io_base, pm->cpu_hp_io_len)); - field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,aml_named_field ("PRS" ,256 )); -aml_append (sb_scope, field); - -/* build Processor object for each processor */ -for (i =0 ; i < acpi_cpus; i++) { - dev =aml_processor (i,0 ,0 ,"CP%.02X" , i); - - method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (i)))); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_return (aml_call1 (CPU_STATUS_METHOD ,aml_int (i)))); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_return (aml_call2 (CPU_EJECT_METHOD ,aml_int (i),aml_arg (0 ))) - ); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* build this code: -* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} -*/ -/* Arg0 = Processor ID = APIC ID */ - method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < acpi_cpus; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("CP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); - -/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" -* -* Note: The ability to create variable-sized packages was first -* introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages -* ith up to 255 elements. Windows guests up to win2k8 fail when -* VarPackageOp is used. -*/ - pkg = acpi_cpus <=255 ?aml_package (acpi_cpus) : -aml_varpackage (acpi_cpus); - -for (i =0 ; i < acpi_cpus; i++) { -uint8_t b =test_bit (i, cpu->found_cpus) ?0x01 :0x00 ; -aml_append (pkg,aml_int (b)); - } -aml_append (sb_scope,aml_name_decl (CPU_ON_BITMAP , pkg)); +build_processor_devices (sb_scope, guest_info->apic_id_limit, cpu, pm);build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
Signature · 1 line
1.8.3.1
PATCH v2 22/51 pc: acpi: move HPET from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-hpet.dsl | 48 ----------------------------------------- hw/i386/acpi-dsdt.dsl | 2 -- hw/i386/q35-acpi-dsdt.dsl | 3 --- hw/timer/hpet.c | 2 +- include/hw/timer/hpet.h | 1 + 6 files changed, 55 insertions(+), 54 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl
hw/i386/acpi-build.c +53 -0
@@ -51,6 +51,7 @@#include "hw/pci/pci_bus.h" #include "hw/pci-host/q35.h" #include "hw/i386/intel_iommu.h" +#include "hw/timer/hpet.h" #include "hw/i386/q35-acpi-dsdt.hex" #include "hw/i386/acpi-dsdt.hex"
@@ -1145,6 +1146,57 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,aml_append (sb_scope, method); } +static void build_hpet_aml (Aml *table) +{ +Aml *crs; +Aml *field; +Aml *method; +Aml *if_ctx; +Aml *scope =aml_scope ("_SB" ); +Aml *dev =aml_device ("HPET" ); +Aml *zero =aml_int (0 ); +Aml *id =aml_local (0 ); +Aml *period =aml_local (1 ); + +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0103" ))); +aml_append (dev,aml_name_decl ("_UID" , zero)); + +aml_append (dev, +aml_operation_region ("HPTM" ,AML_SYSTEM_MEMORY ,HPET_BASE ,HPET_LEN )); + field =aml_field ("HPTM" ,AML_DWORD_ACC ,AML_LOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("VEND" ,32 )); +aml_append (field,aml_named_field ("PRD" ,32 )); +aml_append (dev, field); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store (aml_name ("VEND" ), id)); +aml_append (method,aml_store (aml_name ("PRD" ), period)); +aml_append (method,aml_shiftright (id,aml_int (16 ), id)); + if_ctx =aml_if (aml_lor (aml_equal (id, zero), +aml_equal (id,aml_int (0xffff )))); + { +aml_append (if_ctx,aml_return (zero)); + } +aml_append (method, if_ctx); + + if_ctx =aml_if (aml_lor (aml_equal (period, zero), +aml_lgreater (period,aml_int (100000000 )))); + { +aml_append (if_ctx,aml_return (zero)); + } +aml_append (method, if_ctx); + +aml_append (method,aml_return (aml_int (0x0F ))); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (HPET_BASE ,HPET_LEN ,AML_READ_ONLY )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +aml_append (scope, dev); +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1165,6 +1217,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_hpet_aml (ssdt);build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt-hpet.dsl deleted +0 -48
48 lines not on this page · raw message
hw/i386/acpi-dsdt.dsl +0 -2
@@ -41,8 +41,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - /**************************************************************** * PIIX4 PM ****************************************************************/
hw/i386/q35-acpi-dsdt.dsl +0 -3
@@ -115,9 +115,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - - /**************************************************************** * LPC ISA bridge ****************************************************************/
hw/timer/hpet.c +1 -1
@@ -713,7 +713,7 @@ static void hpet_init(Object *obj)HPETState *s =HPET (obj);/* HPET Area */ -memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,0x400 ); +memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,HPET_LEN );sysbus_init_mmio (sbd, &s->iomem); }
include/hw/timer/hpet.h +1 -0
@@ -16,6 +16,7 @@#include "qom/object.h" #define HPET_BASE 0xfed00000 +#define HPET_LEN 0x400#define HPET_CLK_PERIOD 10/* 10 ns*/ #define FS_PER_NS 1000000/* 1000000 femtoseconds == 1 ns */
Signature · 1 line
1.8.3.1
PATCH v2 23/51 pc: acpi: move DBUG() from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 36 ++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-dbug.dsl | 41 ----------------------------------------- hw/i386/acpi-dsdt.dsl | 2 -- hw/i386/q35-acpi-dsdt.dsl | 2 -- 4 files changed, 36 insertions(+), 45 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl
hw/i386/acpi-build.c +36 -0
@@ -1197,6 +1197,41 @@ static void build_hpet_aml(Aml *table)aml_append (table, scope); } +static void build_dbg_aml (Aml *table) +{ +Aml *field; +Aml *method; +Aml *while_ctx; +Aml *scope =aml_scope ("\\" ); +Aml *buf =aml_local (0 ); +Aml *len =aml_local (1 ); +Aml *idx =aml_local (2 ); + +aml_append (scope, +aml_operation_region ("DBG" ,AML_SYSTEM_IO ,0x0402 ,0x01 )); + field =aml_field ("DBG" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("DBGB" ,8 )); +aml_append (scope, field); + + method =aml_method ("DBUG" ,1 ,AML_NOTSERIALIZED ); + +aml_append (method,aml_to_hexstring (aml_arg (0 ), buf)); +aml_append (method,aml_to_buffer (buf, buf)); +aml_append (method,aml_subtract (aml_sizeof (buf),aml_int (1 ), len)); +aml_append (method,aml_store (aml_int (0 ), idx)); + + while_ctx =aml_while (aml_lless (idx, len)); +aml_append (while_ctx, +aml_store (aml_derefof (aml_index (buf, idx)),aml_name ("DBGB" ))); +aml_append (while_ctx,aml_increment (idx)); +aml_append (method, while_ctx); + +aml_append (method,aml_store (aml_int (0x0A ),aml_name ("DBGB" ))); +aml_append (scope, method); + +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1217,6 +1252,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_dbg_aml (ssdt);build_hpet_aml (ssdt);build_cpu_hotplug_aml (ssdt); build_memory_hotplug_aml(ssdt, nr_mem, pm->mem_hp_io_base,
hw/i386/acpi-dsdt-dbug.dsl deleted +0 -41
41 lines not on this page · raw message
hw/i386/acpi-dsdt.dsl +0 -2
@@ -29,8 +29,6 @@ DefinitionBlock ( ) { -#include "acpi-dsdt-dbug.dsl" - Scope(\_SB) { Device(PCI0) { Name(_HID, EisaId("PNP0A03"))
hw/i386/q35-acpi-dsdt.dsl +0 -2
@@ -35,8 +35,6 @@ DefinitionBlock ( ) { -#include "acpi-dsdt-dbug.dsl" - Scope(\_SB) { OperationRegion(PCST, SystemIO, 0xae00, 0x0c) OperationRegion(PCSB, SystemIO, 0xae0c, 0x01)
Signature · 1 line
1.8.3.1
PATCH v2 24/51 pc: acpi: move RTC device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 26 ++++++++++++++++++++++++++ hw/i386/acpi-dsdt-isa.dsl | 9 --------- 2 files changed, 26 insertions(+), 9 deletions(-)
hw/i386/acpi-build.c +26 -0
@@ -1197,6 +1197,31 @@ static void build_hpet_aml(Aml *table)aml_append (table, scope); } +static Aml *build_rtc_device_aml (void ) +{ +Aml *dev; +Aml *crs; + + dev =aml_device ("RTC" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0B00" ))); + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x0070 ,0x0070 ,0x10 ,0x02 )); +aml_append (crs,aml_irq_no_flags (8 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} + +static void build_isa_devices_aml (Aml *table) +{ +Aml *scope =aml_scope ("_SB.PCI0.ISA" ); + +aml_append (scope,build_rtc_device_aml ()); + +aml_append (table, scope); +} +static void build_dbg_aml (Aml *table) {Aml *field;
@@ -1254,6 +1279,7 @@ build_ssdt(GArray *table_data, GArray *linker,build_dbg_aml (ssdt);build_hpet_aml (ssdt); +build_isa_devices_aml (ssdt);build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt-isa.dsl +0 -9
@@ -16,15 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(RTC) { - Name(_HID, EisaId("PNP0B00")) - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x0070, 0x0070, 0x10, 0x02) - IRQNoFlags() { 8 } - IO(Decode16, 0x0072, 0x0072, 0x02, 0x06) - }) - } - Device(KBD) { Name(_HID, EisaId("PNP0303")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
PATCH v2 25/51 pc: acpi: move KBD device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 22 ++++++++++++++++++++++ hw/i386/acpi-dsdt-isa.dsl | 12 ------------ 2 files changed, 22 insertions(+), 12 deletions(-)
hw/i386/acpi-build.c +22 -0
@@ -1208,6 +1208,27 @@ static Aml *build_rtc_device_aml(void)aml_append (crs,aml_io (AML_DECODE16 ,0x0070 ,0x0070 ,0x10 ,0x02 ));aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 )); + +return dev; +} + +static Aml *build_kbd_device_aml (void ) +{ +Aml *dev; +Aml *crs; +Aml *method; + + dev =aml_device ("KBD" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0303" ))); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (0x0f ))); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x0060 ,0x0060 ,0x01 ,0x01 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x0064 ,0x0064 ,0x01 ,0x01 )); +aml_append (crs,aml_irq_no_flags (1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));return dev;
@@ -1218,6 +1239,7 @@ static void build_isa_devices_aml(Aml *table)Aml *scope =aml_scope ("_SB.PCI0.ISA" );aml_append (scope,build_rtc_device_aml ()); +aml_append (scope,build_kbd_device_aml ());aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -12
@@ -16,18 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(KBD) { - Name(_HID, EisaId("PNP0303")) - Method(_STA, 0, NotSerialized) { - Return (0x0f) - } - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x0060, 0x0060, 0x01, 0x01) - IO(Decode16, 0x0064, 0x0064, 0x01, 0x01) - IRQNoFlags() { 1 } - }) - } - Device(MOU) { Name(_HID, EisaId("PNP0F13")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
PATCH v2 26/51 pc: acpi: move MOU device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 21 +++++++++++++++++++++ hw/i386/acpi-dsdt-isa.dsl | 10 ---------- 2 files changed, 21 insertions(+), 10 deletions(-)
hw/i386/acpi-build.c +21 -0
@@ -1234,12 +1234,33 @@ static Aml *build_kbd_device_aml(void)return dev; } +static Aml *build_mouse_device_aml (void ) +{ +Aml *dev; +Aml *crs; +Aml *method; + + dev =aml_device ("MOU" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0F13" ))); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (0x0f ))); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs,aml_irq_no_flags (12 )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static void build_isa_devices_aml (Aml *table) {Aml *scope =aml_scope ("_SB.PCI0.ISA" );aml_append (scope,build_rtc_device_aml ());aml_append (scope,build_kbd_device_aml ()); +aml_append (scope,build_mouse_device_aml ());aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -10
@@ -16,16 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(MOU) { - Name(_HID, EisaId("PNP0F13")) - Method(_STA, 0, NotSerialized) { - Return (0x0f) - } - Name(_CRS, ResourceTemplate() { - IRQNoFlags() { 12 } - }) - } - Device(FDC0) { Name(_HID, EisaId("PNP0700")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
PATCH v2 27/51 pc: acpi: move FDC0 device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-isa.dsl | 18 ------------------ 2 files changed, 40 insertions(+), 18 deletions(-)
hw/i386/acpi-build.c +40 -0
@@ -1197,6 +1197,44 @@ static void build_hpet_aml(Aml *table)aml_append (table, scope); } +static Aml *build_fdc_device_aml (void ) +{ +Aml *dev; +Aml *crs; +Aml *method; +Aml *if_ctx; +Aml *else_ctx; +Aml *zero =aml_int (0 ); +Aml *is_present =aml_local (0 ); + + dev =aml_device ("FDC0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0700" ))); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store (aml_name ("FDEN" ), is_present)); + if_ctx =aml_if (aml_equal (is_present, zero)); + { +aml_append (if_ctx,aml_return (aml_int (0x00 ))); + } +aml_append (method, if_ctx); + else_ctx =aml_else (); + { +aml_append (else_ctx,aml_return (aml_int (0x0f ))); + } +aml_append (method, else_ctx); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F2 ,0x03F2 ,0x00 ,0x04 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F7 ,0x03F7 ,0x00 ,0x01 )); +aml_append (crs,aml_irq_no_flags (6 )); +aml_append (crs, +aml_dma (AML_COMPATIBILITY ,AML_NOTBUSMASTER ,AML_TRANSFER8 ,2 )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static Aml *build_rtc_device_aml (void ) {Aml *dev;
@@ -1208,6 +1246,7 @@ static Aml *build_rtc_device_aml(void)aml_append (crs,aml_io (AML_DECODE16 ,0x0070 ,0x0070 ,0x10 ,0x02 ));aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 )); +aml_append (dev,aml_name_decl ("_CRS" , crs));return dev; }
@@ -1261,6 +1300,7 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_rtc_device_aml ());aml_append (scope,build_kbd_device_aml ());aml_append (scope,build_mouse_device_aml ()); +aml_append (scope,build_fdc_device_aml ());aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -18
@@ -16,24 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(FDC0) { - Name(_HID, EisaId("PNP0700")) - Method(_STA, 0, NotSerialized) { - Store(FDEN, Local0) - If (LEqual(Local0, 0)) { - Return (0x00) - } Else { - Return (0x0F) - } - } - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04) - IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01) - IRQNoFlags() { 6 } - DMA(Compatibility, NotBusMaster, Transfer8) { 2 } - }) - } - Device(LPT) { Name(_HID, EisaId("PNP0400")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
PATCH v2 28/51 pc: acpi: move LPT device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 36 ++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-isa.dsl | 16 ---------------- 2 files changed, 36 insertions(+), 16 deletions(-)
hw/i386/acpi-build.c +36 -0
@@ -1293,6 +1293,41 @@ static Aml *build_mouse_device_aml(void)return dev; } +static Aml *build_lpt_device_aml (void ) +{ +Aml *dev; +Aml *crs; +Aml *method; +Aml *if_ctx; +Aml *else_ctx; +Aml *zero =aml_int (0 ); +Aml *is_present =aml_local (0 ); + + dev =aml_device ("LPT" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0400" ))); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store (aml_name ("LPEN" ), is_present)); + if_ctx =aml_if (aml_equal (is_present, zero)); + { +aml_append (if_ctx,aml_return (aml_int (0x00 ))); + } +aml_append (method, if_ctx); + else_ctx =aml_else (); + { +aml_append (else_ctx,aml_return (aml_int (0x0f ))); + } +aml_append (method, else_ctx); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x0378 ,0x0378 ,0x08 ,0x08 )); +aml_append (crs,aml_irq_no_flags (7 )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static void build_isa_devices_aml (Aml *table) {Aml *scope =aml_scope ("_SB.PCI0.ISA" );
@@ -1301,6 +1336,7 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_kbd_device_aml ());aml_append (scope,build_mouse_device_aml ());aml_append (scope,build_fdc_device_aml ()); +aml_append (scope,build_lpt_device_aml ());aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -16
@@ -16,22 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(LPT) { - Name(_HID, EisaId("PNP0400")) - Method(_STA, 0, NotSerialized) { - Store(LPEN, Local0) - If (LEqual(Local0, 0)) { - Return (0x00) - } Else { - Return (0x0F) - } - } - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x0378, 0x0378, 0x08, 0x08) - IRQNoFlags() { 7 } - }) - } - Device(COM1) { Name(_HID, EisaId("PNP0501")) Name(_UID, 0x01)
Signature · 1 line
1.8.3.1
PATCH v2 29/51 pc: acpi: move COM devices from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 48 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-isa.dsl | 52 ----------------------------------------------- hw/i386/acpi-dsdt.dsl | 3 --- hw/i386/q35-acpi-dsdt.dsl | 3 --- 4 files changed, 48 insertions(+), 58 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-isa.dsl
hw/i386/acpi-build.c +48 -0
@@ -1328,6 +1328,52 @@ static Aml *build_lpt_device_aml(void)return dev; } +static Aml *build_com_device_aml (uint8_t uid) +{ +Aml *dev; +Aml *crs; +Aml *method; +Aml *if_ctx; +Aml *else_ctx; +Aml *zero =aml_int (0 ); +Aml *is_present =aml_local (0 ); +const char *enabled_field ="CAEN" ; +uint8_t irq =4 ; +uint16_t io_port =0x03F8 ; + +assert (uid ==1 || uid ==2 ); +if (uid ==2 ) { + enabled_field ="CBEN" ; + irq =3 ; + io_port =0x02F8 ; + } + + dev =aml_device ("COM%d" , uid); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0501" ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (uid))); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store (aml_name ("%s" , enabled_field), is_present)); + if_ctx =aml_if (aml_equal (is_present, zero)); + { +aml_append (if_ctx,aml_return (aml_int (0x00 ))); + } +aml_append (method, if_ctx); + else_ctx =aml_else (); + { +aml_append (else_ctx,aml_return (aml_int (0x0f ))); + } +aml_append (method, else_ctx); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 , io_port, io_port,0x00 ,0x08 )); +aml_append (crs,aml_irq_no_flags (irq)); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static void build_isa_devices_aml (Aml *table) {Aml *scope =aml_scope ("_SB.PCI0.ISA" );
@@ -1337,6 +1383,8 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_mouse_device_aml ());aml_append (scope,build_fdc_device_aml ());aml_append (scope,build_lpt_device_aml ()); +aml_append (scope,build_com_device_aml (1 )); +aml_append (scope,build_com_device_aml (2 ));aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl deleted +0 -52
52 lines not on this page · raw message
hw/i386/acpi-dsdt.dsl +0 -3
@@ -80,9 +80,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-isa.dsl" - - /**************************************************************** * PCI hotplug ****************************************************************/
hw/i386/q35-acpi-dsdt.dsl +0 -3
@@ -146,9 +146,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-isa.dsl" - - /**************************************************************** * PCI IRQs ****************************************************************/
Signature · 1 line
1.8.3.1
PATCH v2 30/51 pc: acpi: move PIIX4 isa-bridge and pm devices into SSDT
In reply to Igor Mammedovand also move PRQx fields declaration as it can't be split out into separate patch since fields use PCI0.ISA.P40C operation region and OperationRegion must be declared in the same table as a Field that uses it. If this condition is not statisfied Windows will BSOD ans IASL (make check) will error out as well.
For the same reason pm is moved together with isa-bridge as the later refernces P13C OperationRegion from pm device.
--- hw/i386/acpi-build.c | 77 +++++++++++++++++++++++++++++++++++++++++++-- hw/i386/acpi-dsdt.dsl | 52 +++--------------------------- include/hw/acpi/aml-build.h | 1 + 3 files changed, 81 insertions(+), 49 deletions(-)
hw/i386/acpi-build.c +75 -2
@@ -108,6 +108,7 @@ typedef struct AcpiPmInfo { } AcpiPmInfo; typedef struct AcpiMiscInfo { + bool is_piix4; bool has_hpet; TPMVersion tpm_version; const unsigned char *dsdt_code;
@@ -130,10 +131,12 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)assert (!!piix != !!lpc);if (piix) { + info->is_piix4 = true; info->dsdt_code = AcpiDsdtAmlCode; info->dsdt_size =sizeof AcpiDsdtAmlCode; }if (lpc) { + info->is_piix4 = false; info->dsdt_code = Q35AcpiDsdtAmlCode; info->dsdt_size =sizeof Q35AcpiDsdtAmlCode; }
@@ -1424,6 +1427,68 @@ static void build_dbg_aml(Aml *table)aml_append (table, scope); } +static void build_piix4_pci0_int (Aml *table) +{ +Aml *field; +Aml *sb_scope =aml_scope ("_SB" ); + + field =aml_field ("PCI0.ISA.P40C" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("PRQ0" ,8 )); +aml_append (field,aml_named_field ("PRQ1" ,8 )); +aml_append (field,aml_named_field ("PRQ2" ,8 )); +aml_append (field,aml_named_field ("PRQ3" ,8 )); +aml_append (sb_scope, field); + +aml_append (table, sb_scope); +} + +static void build_piix4_pm (Aml *table) +{ +Aml *dev; +Aml *scope; + + scope =aml_scope ("_SB.PCI0" ); + dev =aml_device ("PX13" ); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0x00010003 ))); + +aml_append (dev,aml_operation_region ("P13C" ,AML_PCI_CONFIG , +0x00 ,0xff )); +aml_append (scope, dev); +aml_append (table, scope); +} + +static void build_piix4_isa_bridge (Aml *table) +{ +Aml *dev; +Aml *scope; +Aml *field; + + scope =aml_scope ("_SB.PCI0" ); + dev =aml_device ("ISA" ); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0x00010000 ))); + +/* PIIX PCI to ISA irq remapping */ +aml_append (dev,aml_operation_region ("P40C" ,AML_PCI_CONFIG , +0x60 ,0x04 )); +/* enable bits */ + field =aml_field ("^PX13.P13C" ,AML_ANY_ACC ,AML_NOLOCK ,AML_PRESERVE ); +/* Offset(0x5f),, 7, */ +aml_append (field,aml_reserved_field (0x2f8 )); +aml_append (field,aml_reserved_field (7 )); +aml_append (field,aml_named_field ("LPEN" ,1 )); +/* Offset(0x67),, 3, */ +aml_append (field,aml_reserved_field (0x38 )); +aml_append (field,aml_reserved_field (3 )); +aml_append (field,aml_named_field ("CAEN" ,1 )); +aml_append (field,aml_reserved_field (3 )); +aml_append (field,aml_named_field ("CBEN" ,1 )); +aml_append (dev, field); +aml_append (dev,aml_name_decl ("FDEN" ,aml_int (1 ))); + +aml_append (scope, dev); +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1445,8 +1510,16 @@ build_ssdt(GArray *table_data, GArray *linker,acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader));build_dbg_aml (ssdt); -build_hpet_aml (ssdt); -build_isa_devices_aml (ssdt); +if (misc->is_piix4) { +build_hpet_aml (ssdt); +build_piix4_pm (ssdt); +build_piix4_isa_bridge (ssdt); +build_isa_devices_aml (ssdt); +build_piix4_pci0_int (ssdt); + }else { +build_hpet_aml (ssdt); +build_isa_devices_aml (ssdt); + }build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt.dsl +5 -47
64 lines not on this page · raw message
include/hw/acpi/aml-build.h +1 -0
@@ -82,6 +82,7 @@ typedef enum {typedef enum {AML_SYSTEM_MEMORY =0X00 ,AML_SYSTEM_IO =0X01 , +AML_PCI_CONFIG =0X02 , }AmlRegionSpace ; typedef enum {
Signature · 1 line
1.8.3.1
PATCH v2 31/51 pc: acpi: move remaining GPE handlers into SSDT
In reply to Igor Mammedov---
* unflod _L0X methods building loop and opencode it, with intent to remove these (unused) handlers later at refactoring time.
--- hw/i386/acpi-build.c | 30 +++++++++++++++++++++++++++++- hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- hw/i386/q35-acpi-dsdt.dsl | 36 ------------------------------------ 3 files changed, 29 insertions(+), 77 deletions(-)
hw/i386/acpi-build.c +29 -1
@@ -1524,8 +1524,23 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); - scope =aml_scope ("\\_GPE" ); + scope =aml_scope ("_GPE" ); { +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + +aml_append (scope,aml_method ("_L00" ,0 ,AML_NOTSERIALIZED )); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { +aml_append (scope,aml_method ("_L01" ,0 ,AML_NOTSERIALIZED )); + } + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD ));aml_append (scope, method);
@@ -1533,6 +1548,19 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); + +aml_append (scope,aml_method ("_L04" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L05" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L06" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L07" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L08" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L09" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0A" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0B" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0C" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0D" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0E" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0F" ,0 ,AML_NOTSERIALIZED )); }aml_append (ssdt, scope);
hw/i386/acpi-dsdt.dsl +0 -40
@@ -197,44 +197,4 @@ DefinitionBlock ( Method(_SRS, 1, NotSerialized) { } } } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_E01) { - // PCI hotplug event - Acquire(\_SB.PCI0.BLCK, 0xFFFF) - \_SB.PCI0.PCNT() - Release(\_SB.PCI0.BLCK) - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }
hw/i386/q35-acpi-dsdt.dsl +0 -36
@@ -375,40 +375,4 @@ DefinitionBlock ( define_gsi_link(GSIG, 0, 0x16) define_gsi_link(GSIH, 0, 0x17) } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_L01) { - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }
Signature · 1 line
1.8.3.1
PATCH v2 32/51 pc: acpi: pci: move link devices into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt.dsl | 49 ++++---------------------------- 2 files changed, 82 insertions(+), 44 deletions(-)
hw/i386/acpi-build.c +77 -0
@@ -1427,9 +1427,49 @@ static void build_dbg_aml(Aml *table)aml_append (table, scope); } +static Aml *build_link_dev (const char *name,uint8_t uid,Aml *reg) +{ +Aml *dev; +Aml *crs; +Aml *method; +uint32_t irqs[] = {5 ,10 ,11 }; + + dev =aml_device ("%s" , name); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C0F" ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (uid))); + + crs =aml_resource_template (); +aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , +AML_SHARED , irqs,ARRAY_SIZE (irqs))); +aml_append (dev,aml_name_decl ("_PRS" , crs)); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_call1 ("IQST" , reg))); +aml_append (dev, method); + + method =aml_method ("_DIS" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_or (reg,aml_int (0x80 ), reg)); +aml_append (dev, method); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_call1 ("IQCR" , reg))); +aml_append (dev, method); + + method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED ); +aml_append (method,aml_create_dword_field (aml_arg (0 ),aml_int (5 ),"PRRI" )); +aml_append (method,aml_store (aml_name ("PRRI" ), reg)); +aml_append (dev, method); + +return dev; + } +static void build_piix4_pci0_int (Aml *table) { +Aml *dev; +Aml *crs;Aml *field; +Aml *method; +uint32_t irqs;Aml *sb_scope =aml_scope ("_SB" ); field =aml_field ("PCI0.ISA.P40C" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );
@@ -1439,6 +1479,43 @@ static void build_piix4_pci0_int(Aml *table)aml_append (field,aml_named_field ("PRQ3" ,8 ));aml_append (sb_scope, field); +aml_append (sb_scope,build_link_dev ("LNKA" ,0 ,aml_name ("PRQ0" ))); +aml_append (sb_scope,build_link_dev ("LNKB" ,1 ,aml_name ("PRQ1" ))); +aml_append (sb_scope,build_link_dev ("LNKC" ,2 ,aml_name ("PRQ2" ))); +aml_append (sb_scope,build_link_dev ("LNKD" ,3 ,aml_name ("PRQ3" ))); + + dev =aml_device ("LNKS" ); + { +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C0F" ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (4 ))); + + crs =aml_resource_template (); + irqs =9 ; +aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL , +AML_ACTIVE_HIGH ,AML_SHARED , + &irqs,1 )); +aml_append (dev,aml_name_decl ("_PRS" , crs)); + +/* The SCI cannot be disabled and is always attached to GSI 9, +* so these are no-ops. We only need this link to override the +* polarity to active high and match the content of the MADT. +*/ + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_int (0x0b ))); +aml_append (dev, method); + + method =aml_method ("_DIS" ,0 ,AML_NOTSERIALIZED ); +aml_append (dev, method); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_name ("_PRS" ))); +aml_append (dev, method); + + method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED ); +aml_append (dev, method); + } +aml_append (sb_scope, dev); +aml_append (table, sb_scope); }
hw/i386/acpi-dsdt.dsl +5 -44
54 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 33/51 pc: acpi: piix4: move IQCR() into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 20 ++++++++++++++++++++ hw/i386/acpi-dsdt.dsl | 11 ----------- 2 files changed, 20 insertions(+), 11 deletions(-)
hw/i386/acpi-build.c +20 -0
@@ -1468,6 +1468,7 @@ static void build_piix4_pci0_int(Aml *table)Aml *dev;Aml *crs;Aml *field; +Aml *if_ctx;Aml *method;uint32_t irqs;Aml *sb_scope =aml_scope ("_SB" );
@@ -1479,6 +1480,25 @@ static void build_piix4_pci0_int(Aml *table)aml_append (field,aml_named_field ("PRQ3" ,8 ));aml_append (sb_scope, field); +/* _CRS method - get current settings */ + method =aml_method ("IQCR" ,1 ,AML_SERIALIZED ); + { + crs =aml_resource_template (); + irqs =0 ; +aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL , +AML_ACTIVE_HIGH ,AML_SHARED , &irqs,1 )); +aml_append (method,aml_name_decl ("PRR0" , crs)); + +aml_append (method, +aml_create_dword_field (aml_name ("PRR0" ),aml_int (5 ),"PRRI" )); + + if_ctx =aml_if (aml_lless (aml_arg (0 ),aml_int (0x80 ))); +aml_append (if_ctx,aml_store (aml_arg (0 ),aml_name ("PRRI" ))); +aml_append (method, if_ctx); +aml_append (method,aml_return (aml_name ("PRR0" ))); + } +aml_append (sb_scope, method); +aml_append (sb_scope,build_link_dev ("LNKA" ,0 ,aml_name ("PRQ0" )));aml_append (sb_scope,build_link_dev ("LNKB" ,1 ,aml_name ("PRQ1" )));aml_append (sb_scope,build_link_dev ("LNKC" ,2 ,aml_name ("PRQ2" )));
hw/i386/acpi-dsdt.dsl +0 -11
@@ -140,17 +140,6 @@ DefinitionBlock ( } Return (0x0B) } - Method(IQCR, 1, Serialized) { - // _CRS method - get current settings - Name(PRR0, ResourceTemplate() { - Interrupt(, Level, ActiveHigh, Shared) { 0 } - }) - CreateDWordField(PRR0, 0x05, PRRI) - If (LLess(Arg0, 0x80)) { - Store(Arg0, PRRI) - } - Return (PRR0) - } External(LNKA, DeviceObj) External(LNKB, DeviceObj)
Signature · 1 line
1.8.3.1
PATCH v2 34/51 pc: acpi: piix4: move IQST() into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 10 ++++++++++ hw/i386/acpi-dsdt.dsl | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-)
hw/i386/acpi-build.c +10 -0
@@ -1480,6 +1480,16 @@ static void build_piix4_pci0_int(Aml *table)aml_append (field,aml_named_field ("PRQ3" ,8 ));aml_append (sb_scope, field); +/* _STA method - get status */ + method =aml_method ("IQST" ,1 ,AML_NOTSERIALIZED ); + { + if_ctx =aml_if (aml_and (aml_int (0x80 ),aml_arg (0 ),NULL )); +aml_append (if_ctx,aml_return (aml_int (0x09 ))); +aml_append (method, if_ctx); +aml_append (method,aml_return (aml_int (0x0B ))); + } +aml_append (sb_scope, method); +/* _CRS method - get current settings */ method =aml_method ("IQCR" ,1 ,AML_SERIALIZED ); {
hw/i386/acpi-dsdt.dsl +0 -9
@@ -132,15 +132,6 @@ DefinitionBlock ( External(PRQ1, FieldUnitObj) External(PRQ2, FieldUnitObj) External(PRQ3, FieldUnitObj) - - Method(IQST, 1, NotSerialized) { - // _STA method - get status - If (And(0x80, Arg0)) { - Return (0x09) - } - Return (0x0B) - } - External(LNKA, DeviceObj) External(LNKB, DeviceObj) External(LNKC, DeviceObj)
Signature · 1 line
1.8.3.1
PATCH v2 35/51 pc: acpi: piix4: move PCI0._PRT() into SSDT
In reply to Igor MammedovPCI routing table for expander buses is build with help of build_prt() using AML API. And it's almost the same as PRT for PCI0 bus except of power-management device. So make existing build_prt() build PRT table for PCI0 bus as well.
---
v3:
- document build_prt_entry()
- use {} scope for if/else AML constructs to make code more readble and clear what code belongs to what if ctx
- rename if_ctx to if_device_1
- rename if_ctx2/else_ctx2 to [if|else]_pin_4
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,
--- hw/i386/acpi-build.c | 55 +++++++++++++++++++++++++++++++++++++++------- hw/i386/acpi-dsdt.dsl | 60 --------------------------------------------------- 2 files changed, 47 insertions(+), 68 deletions(-)
hw/i386/acpi-build.c +47 -8
@@ -621,6 +621,23 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,qobject_decref (bsel); } +/** +* build_prt_entry: +* @link_name: link name for PCI route entry +* +* build AML package containing a PCI route entry for @link_name +*/ +static Aml *build_prt_entry (const char *link_name) +{ +Aml *a_zero =aml_int (0 ); +Aml *pkg =aml_package (4 ); +aml_append (pkg, a_zero); +aml_append (pkg, a_zero); +aml_append (pkg,aml_name ("%s" , link_name)); +aml_append (pkg, a_zero); +return pkg; +} +/* * initialize_route - Initialize the interrupt routing rule * through a specific LINK:
@@ -631,12 +648,8 @@ static Aml *initialize_route(Aml *route, const char *link_name, Aml *lnk_idx, int idx) {Aml *if_ctx =aml_if (aml_equal (lnk_idx,aml_int (idx))); -Aml *pkg =aml_package (4 ); +Aml *pkg =build_prt_entry (link_name); -aml_append (pkg,aml_int (0 )); -aml_append (pkg,aml_int (0 )); -aml_append (pkg,aml_name ("%s" , link_name)); -aml_append (pkg,aml_int (0 ));aml_append (if_ctx,aml_store (pkg, route));return if_ctx;
@@ -652,7 +665,7 @@ static Aml *initialize_route(Aml *route, const char *link_name,* The hash function is (slot + pin) & 3 -> "LNK[D|A|B|C]". * */ -static Aml *build_prt (void ) +static Aml *build_prt (bool is_pci0_prt) {Aml *method, *while_ctx, *pin, *res;
@@ -679,7 +692,29 @@ static Aml *build_prt(void)/* route[2] = "LNK[D|A|B|C]", selection based on pin % 3 */ aml_append (while_ctx,initialize_route (route,"LNKD" , lnk_idx,0 )); -aml_append (while_ctx,initialize_route (route,"LNKA" , lnk_idx,1 )); +if (is_pci0_prt) { +Aml *if_device_1, *if_pin_4, *else_pin_4; + +/* device 1 is the power-management device, needs SCI */ + if_device_1 =aml_if (aml_equal (lnk_idx,aml_int (1 ))); + { + if_pin_4 =aml_if (aml_equal (pin,aml_int (4 ))); + { +aml_append (if_pin_4, +aml_store (build_prt_entry ("LNKS" ), route)); + } +aml_append (if_device_1, if_pin_4); + else_pin_4 =aml_else (); + { +aml_append (else_pin_4, +aml_store (build_prt_entry ("LNKA" ), route)); + } +aml_append (if_device_1, else_pin_4); + } +aml_append (while_ctx, if_device_1); + }else { +aml_append (while_ctx,initialize_route (route,"LNKA" , lnk_idx,1 )); + }aml_append (while_ctx,initialize_route (route,"LNKB" , lnk_idx,2 ));aml_append (while_ctx,initialize_route (route,"LNKC" , lnk_idx,3 ));
@@ -1472,6 +1507,10 @@ static void build_piix4_pci0_int(Aml *table)Aml *method;uint32_t irqs;Aml *sb_scope =aml_scope ("_SB" ); +Aml *pci0_scope =aml_scope ("PCI0" ); + +aml_append (pci0_scope,build_prt (true)); +aml_append (sb_scope, pci0_scope); field =aml_field ("PCI0.ISA.P40C" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("PRQ0" ,8 ));
@@ -1696,7 +1735,7 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (dev,aml_name_decl ("_PXM" ,aml_int (numa_node))); } -aml_append (dev,build_prt ()); +aml_append (dev,build_prt (false)); crs =build_crs (PCI_HOST_BRIDGE (BUS (bus)->parent), io_ranges, mem_ranges);aml_append (dev,aml_name_decl ("_CRS" , crs));
hw/i386/acpi-dsdt.dsl +0 -60
64 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 36/51 pc: acpi: piix4: move remaining PCI hotplug bits into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- 2 files changed, 43 insertions(+), 40 deletions(-)
hw/i386/acpi-build.c +43 -0
@@ -1635,6 +1635,48 @@ static void build_piix4_isa_bridge(Aml *table)aml_append (table, scope); } +static void build_piix4_pci_hotplug (Aml *table) +{ +Aml *scope; +Aml *field; +Aml *method; + + scope =aml_scope ("_SB.PCI0" ); + +aml_append (scope, +aml_operation_region ("PCST" ,AML_SYSTEM_IO ,0xae00 ,0x08 )); + field =aml_field ("PCST" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("PCIU" ,32 )); +aml_append (field,aml_named_field ("PCID" ,32 )); +aml_append (scope, field); + +aml_append (scope, +aml_operation_region ("SEJ" ,AML_SYSTEM_IO ,0xae08 ,0x04 )); + field =aml_field ("SEJ" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("B0EJ" ,32 )); +aml_append (scope, field); + +aml_append (scope, +aml_operation_region ("BNMR" ,AML_SYSTEM_IO ,0xae10 ,0x04 )); + field =aml_field ("BNMR" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("BNUM" ,32 )); +aml_append (scope, field); + +aml_append (scope,aml_mutex ("BLCK" ,0 )); + + method =aml_method ("PCEJ" ,2 ,AML_NOTSERIALIZED ); +aml_append (method,aml_acquire (aml_name ("BLCK" ),0xFFFF )); +aml_append (method,aml_store (aml_arg (0 ),aml_name ("BNUM" ))); +aml_append (method, +aml_store (aml_shiftleft (aml_int (1 ),aml_arg (1 )),aml_name ("B0EJ" ))); +aml_append (method,aml_release (aml_name ("BLCK" ))); +aml_append (method,aml_return (aml_int (0 ))); +aml_append (scope, method); + +aml_append (table, scope); +} + + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1661,6 +1703,7 @@ build_ssdt(GArray *table_data, GArray *linker,build_piix4_pm (ssdt);build_piix4_isa_bridge (ssdt);build_isa_devices_aml (ssdt); +build_piix4_pci_hotplug (ssdt);build_piix4_pci0_int (ssdt); }else {build_hpet_aml (ssdt);
hw/i386/acpi-dsdt.dsl +0 -40
@@ -38,44 +38,4 @@ DefinitionBlock ( // External(PX13, DeviceObj) } } - -/**************************************************************** - * PCI hotplug - ****************************************************************/ - - Scope(\_SB.PCI0) { - OperationRegion(PCST, SystemIO, 0xae00, 0x08) - Field(PCST, DWordAcc, NoLock, WriteAsZeros) { - PCIU, 32, - PCID, 32, - } - - OperationRegion(SEJ, SystemIO, 0xae08, 0x04) - Field(SEJ, DWordAcc, NoLock, WriteAsZeros) { - B0EJ, 32, - } - - OperationRegion(BNMR, SystemIO, 0xae10, 0x04) - Field(BNMR, DWordAcc, NoLock, WriteAsZeros) { - BNUM, 32, - } - - /* Lock to protect access to fields above. */ - Mutex(BLCK, 0) - - /* Methods called by bulk generated PCI devices below */ - - /* Methods called by hotplug devices */ - Method(PCEJ, 2, NotSerialized) { - // _EJ0 method - eject callback - Acquire(BLCK, 0xFFFF) - Store(Arg0, BNUM) - Store(ShiftLeft(1, Arg1), B0EJ) - Release(BLCK) - Return (0x0) - } - - /* Hotplug notification method supplied by SSDT */ - External(\_SB.PCI0.PCNT, MethodObj) - } }
Signature · 1 line
1.8.3.1
PATCH v2 37/51 pc: acpi: piix4: acpi move PCI0 device to SSDT
In reply to Igor Mammedovleave Scope(\_SB) definition in DSDT so that iasl would be able to compile DSDT since we are still need definition block for table.
After Q35 ASL is converted, DSDT templates will be completly replaced by AML API generated tables.
--- hw/i386/acpi-build.c | 8 ++++++++ hw/i386/acpi-dsdt.dsl | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +8 -0
@@ -1699,6 +1699,14 @@ build_ssdt(GArray *table_data, GArray *linker,build_dbg_aml (ssdt);if (misc->is_piix4) { + sb_scope =aml_scope ("_SB" ); + dev =aml_device ("PCI0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A03" ))); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (1 ))); +aml_append (sb_scope, dev); +aml_append (ssdt, sb_scope); +build_hpet_aml (ssdt);build_piix4_pm (ssdt);build_piix4_isa_bridge (ssdt);
hw/i386/acpi-dsdt.dsl +0 -8
@@ -28,14 +28,6 @@ DefinitionBlock ( 0x1 // OEM Revision ) { - Scope(\_SB) { - Device(PCI0) { - Name(_HID, EisaId("PNP0A03")) - Name(_ADR, 0x00) - Name(_UID, 1) -//#define PX13 S0B_ -// External(PX13, DeviceObj) - } } }
Signature · 1 line
1.8.3.1
PATCH v2 38/51 pc: acpi: q35: move GSI links to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 34 ++++++++-------------------------- 2 files changed, 55 insertions(+), 26 deletions(-)
hw/i386/acpi-build.c +47 -0
@@ -1498,6 +1498,31 @@ static Aml *build_link_dev(const char *name, uint8_t uid, Aml *reg)return dev; } +static Aml *build_gsi_link_dev (const char *name,uint8_t uid,uint8_t gsi) +{ +Aml *dev; +Aml *crs; +Aml *method; +uint32_t irqs; + + dev =aml_device ("%s" , name); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C0F" ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (uid))); + + crs =aml_resource_template (); + irqs = gsi; +aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , +AML_SHARED , &irqs,1 )); +aml_append (dev,aml_name_decl ("_PRS" , crs)); + +aml_append (dev,aml_name_decl ("_CRS" , crs)); + + method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED ); +aml_append (dev, method); + +return dev; +} +static void build_piix4_pci0_int (Aml *table) {Aml *dev;
@@ -1588,6 +1613,26 @@ static void build_piix4_pci0_int(Aml *table)aml_append (table, sb_scope); } +static void build_q35_pci0_int (Aml *table) +{ +Aml *sb_scope =aml_scope ("_SB" ); + +/* +* TODO: UID probably shouldn't be the same for GSIx devices +* but that's how it was in original ASL so keep it for now +*/ +aml_append (sb_scope,build_gsi_link_dev ("GSIA" ,0 ,0x10 )); +aml_append (sb_scope,build_gsi_link_dev ("GSIB" ,0 ,0x11 )); +aml_append (sb_scope,build_gsi_link_dev ("GSIC" ,0 ,0x12 )); +aml_append (sb_scope,build_gsi_link_dev ("GSID" ,0 ,0x13 )); +aml_append (sb_scope,build_gsi_link_dev ("GSIE" ,0 ,0x14 )); +aml_append (sb_scope,build_gsi_link_dev ("GSIF" ,0 ,0x15 )); +aml_append (sb_scope,build_gsi_link_dev ("GSIG" ,0 ,0x16 )); +aml_append (sb_scope,build_gsi_link_dev ("GSIH" ,0 ,0x17 )); + +aml_append (table, sb_scope); +} +static void build_piix4_pm (Aml *table) {Aml *dev;
@@ -1716,7 +1761,9 @@ build_ssdt(GArray *table_data, GArray *linker, }else {build_hpet_aml (ssdt);build_isa_devices_aml (ssdt); +build_q35_pci0_int (ssdt); } +build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/q35-acpi-dsdt.dsl +8 -26
@@ -348,31 +348,13 @@ DefinitionBlock ( define_link(LNKG, 6, PRQG) define_link(LNKH, 7, PRQH) -#define define_gsi_link(link, uid, gsi) \ - Device(link) { \ - Name(_HID, EISAID("PNP0C0F")) \ - Name(_UID, uid) \ - Name(_PRS, ResourceTemplate() { \ - Interrupt(, Level, ActiveHigh, Shared) { \ - gsi \ - } \ - }) \ - Name(_CRS, ResourceTemplate() { \ - Interrupt(, Level, ActiveHigh, Shared) { \ - gsi \ - } \ - }) \ - Method(_SRS, 1, NotSerialized) { \ - } \ - } - - define_gsi_link(GSIA, 0, 0x10) - define_gsi_link(GSIB, 0, 0x11) - define_gsi_link(GSIC, 0, 0x12) - define_gsi_link(GSID, 0, 0x13) - define_gsi_link(GSIE, 0, 0x14) - define_gsi_link(GSIF, 0, 0x15) - define_gsi_link(GSIG, 0, 0x16) - define_gsi_link(GSIH, 0, 0x17) + External(GSIA, DeviceObj) + External(GSIB, DeviceObj) + External(GSIC, DeviceObj) + External(GSID, DeviceObj) + External(GSIE, DeviceObj) + External(GSIF, DeviceObj) + External(GSIG, DeviceObj) + External(GSIH, DeviceObj) } }
Signature · 1 line
1.8.3.1
PATCH v2 39/51 pc: acpi: q35: move link devices to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 9 +++++++++ hw/i386/q35-acpi-dsdt.dsl | 40 ++++++++-------------------------------- 2 files changed, 17 insertions(+), 32 deletions(-)
hw/i386/acpi-build.c +9 -0
@@ -1617,6 +1617,15 @@ static void build_q35_pci0_int(Aml *table) {Aml *sb_scope =aml_scope ("_SB" ); +aml_append (sb_scope,build_link_dev ("LNKA" ,0 ,aml_name ("PRQA" ))); +aml_append (sb_scope,build_link_dev ("LNKB" ,1 ,aml_name ("PRQB" ))); +aml_append (sb_scope,build_link_dev ("LNKC" ,2 ,aml_name ("PRQC" ))); +aml_append (sb_scope,build_link_dev ("LNKD" ,3 ,aml_name ("PRQD" ))); +aml_append (sb_scope,build_link_dev ("LNKE" ,4 ,aml_name ("PRQE" ))); +aml_append (sb_scope,build_link_dev ("LNKF" ,5 ,aml_name ("PRQF" ))); +aml_append (sb_scope,build_link_dev ("LNKG" ,6 ,aml_name ("PRQG" ))); +aml_append (sb_scope,build_link_dev ("LNKH" ,7 ,aml_name ("PRQH" ))); +/* * TODO: UID probably shouldn't be the same for GSIx devices * but that's how it was in original ASL so keep it for now
hw/i386/q35-acpi-dsdt.dsl +8 -32
@@ -315,38 +315,14 @@ DefinitionBlock ( Return (PRR0) } -#define define_link(link, uid, reg) \ - Device(link) { \ - Name(_HID, EISAID("PNP0C0F")) \ - Name(_UID, uid) \ - Name(_PRS, ResourceTemplate() { \ - Interrupt(, Level, ActiveHigh, Shared) { \ - 5, 10, 11 \ - } \ - }) \ - Method(_STA, 0, NotSerialized) { \ - Return (IQST(reg)) \ - } \ - Method(_DIS, 0, NotSerialized) { \ - Or(reg, 0x80, reg) \ - } \ - Method(_CRS, 0, NotSerialized) { \ - Return (IQCR(reg)) \ - } \ - Method(_SRS, 1, NotSerialized) { \ - CreateDWordField(Arg0, 0x05, PRRI) \ - Store(PRRI, reg) \ - } \ - } - - define_link(LNKA, 0, PRQA) - define_link(LNKB, 1, PRQB) - define_link(LNKC, 2, PRQC) - define_link(LNKD, 3, PRQD) - define_link(LNKE, 4, PRQE) - define_link(LNKF, 5, PRQF) - define_link(LNKG, 6, PRQG) - define_link(LNKH, 7, PRQH) + External(LNKA, DeviceObj) + External(LNKB, DeviceObj) + External(LNKC, DeviceObj) + External(LNKD, DeviceObj) + External(LNKE, DeviceObj) + External(LNKF, DeviceObj) + External(LNKG, DeviceObj) + External(LNKH, DeviceObj) External(GSIA, DeviceObj) External(GSIB, DeviceObj)
Signature · 1 line
1.8.3.1
PATCH v2 40/51 pc: acpi: q35: move IQCR() into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 51 ++++++++++++++++++++++++++++++----------------- hw/i386/q35-acpi-dsdt.dsl | 9 --------- 2 files changed, 33 insertions(+), 27 deletions(-)
hw/i386/acpi-build.c +33 -18
@@ -1523,6 +1523,36 @@ static Aml *build_gsi_link_dev(const char *name, uint8_t uid, uint8_t gsi)return dev; } +/* _CRS method - get current settings */ +static Aml *build_iqcr_method (bool is_piix4) +{ +Aml *if_ctx; +uint32_t irqs; +Aml *method =aml_method ("IQCR" ,1 ,AML_SERIALIZED ); +Aml *crs =aml_resource_template (); + + irqs =0 ; +aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL , +AML_ACTIVE_HIGH ,AML_SHARED , &irqs,1 )); +aml_append (method,aml_name_decl ("PRR0" , crs)); + +aml_append (method, +aml_create_dword_field (aml_name ("PRR0" ),aml_int (5 ),"PRRI" )); + +if (is_piix4) { + if_ctx =aml_if (aml_lless (aml_arg (0 ),aml_int (0x80 ))); +aml_append (if_ctx,aml_store (aml_arg (0 ),aml_name ("PRRI" ))); +aml_append (method, if_ctx); + }else { +aml_append (method, +aml_store (aml_and (aml_arg (0 ),aml_int (0xF ),NULL ), +aml_name ("PRRI" ))); + } + +aml_append (method,aml_return (aml_name ("PRR0" ))); +return method; +} +static void build_piix4_pci0_int (Aml *table) {Aml *dev;
@@ -1554,24 +1584,7 @@ static void build_piix4_pci0_int(Aml *table) }aml_append (sb_scope, method); -/* _CRS method - get current settings */ - method =aml_method ("IQCR" ,1 ,AML_SERIALIZED ); - { - crs =aml_resource_template (); - irqs =0 ; -aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL , -AML_ACTIVE_HIGH ,AML_SHARED , &irqs,1 )); -aml_append (method,aml_name_decl ("PRR0" , crs)); - -aml_append (method, -aml_create_dword_field (aml_name ("PRR0" ),aml_int (5 ),"PRRI" )); - - if_ctx =aml_if (aml_lless (aml_arg (0 ),aml_int (0x80 ))); -aml_append (if_ctx,aml_store (aml_arg (0 ),aml_name ("PRRI" ))); -aml_append (method, if_ctx); -aml_append (method,aml_return (aml_name ("PRR0" ))); - } -aml_append (sb_scope, method); +aml_append (sb_scope,build_iqcr_method (true));aml_append (sb_scope,build_link_dev ("LNKA" ,0 ,aml_name ("PRQ0" )));aml_append (sb_scope,build_link_dev ("LNKB" ,1 ,aml_name ("PRQ1" )));
@@ -1617,6 +1630,8 @@ static void build_q35_pci0_int(Aml *table) {Aml *sb_scope =aml_scope ("_SB" ); +aml_append (sb_scope,build_iqcr_method (false)); +aml_append (sb_scope,build_link_dev ("LNKA" ,0 ,aml_name ("PRQA" )));aml_append (sb_scope,build_link_dev ("LNKB" ,1 ,aml_name ("PRQB" )));aml_append (sb_scope,build_link_dev ("LNKC" ,2 ,aml_name ("PRQC" )));
hw/i386/q35-acpi-dsdt.dsl +0 -9
@@ -305,15 +305,6 @@ DefinitionBlock ( } Return (0x0B) } - Method(IQCR, 1, Serialized) { - // _CRS method - get current settings - Name(PRR0, ResourceTemplate() { - Interrupt(, Level, ActiveHigh, Shared) { 0 } - }) - CreateDWordField(PRR0, 0x05, PRRI) - Store(And(Arg0, 0x0F), PRRI) - Return (PRR0) - } External(LNKA, DeviceObj) External(LNKB, DeviceObj)
Signature · 1 line
1.8.3.1
PATCH v2 41/51 pc: acpi: q35: move IQST() into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 26 +++++++++++++++----------- hw/i386/q35-acpi-dsdt.dsl | 8 -------- 2 files changed, 15 insertions(+), 19 deletions(-)
hw/i386/acpi-build.c +15 -11
@@ -1553,12 +1553,24 @@ static Aml *build_iqcr_method(bool is_piix4)return method; } +/* _STA method - get status */ +static Aml *build_irq_status_method (void ) +{ +Aml *if_ctx; +Aml *method =aml_method ("IQST" ,1 ,AML_NOTSERIALIZED ); + + if_ctx =aml_if (aml_and (aml_int (0x80 ),aml_arg (0 ),NULL )); +aml_append (if_ctx,aml_return (aml_int (0x09 ))); +aml_append (method, if_ctx); +aml_append (method,aml_return (aml_int (0x0B ))); +return method; +} +static void build_piix4_pci0_int (Aml *table) {Aml *dev;Aml *crs;Aml *field; -Aml *if_ctx;Aml *method;uint32_t irqs;Aml *sb_scope =aml_scope ("_SB" );
@@ -1574,16 +1586,7 @@ static void build_piix4_pci0_int(Aml *table)aml_append (field,aml_named_field ("PRQ3" ,8 ));aml_append (sb_scope, field); -/* _STA method - get status */ - method =aml_method ("IQST" ,1 ,AML_NOTSERIALIZED ); - { - if_ctx =aml_if (aml_and (aml_int (0x80 ),aml_arg (0 ),NULL )); -aml_append (if_ctx,aml_return (aml_int (0x09 ))); -aml_append (method, if_ctx); -aml_append (method,aml_return (aml_int (0x0B ))); - } -aml_append (sb_scope, method); - +aml_append (sb_scope,build_irq_status_method ());aml_append (sb_scope,build_iqcr_method (true));aml_append (sb_scope,build_link_dev ("LNKA" ,0 ,aml_name ("PRQ0" )));
@@ -1630,6 +1633,7 @@ static void build_q35_pci0_int(Aml *table) {Aml *sb_scope =aml_scope ("_SB" ); +aml_append (sb_scope,build_irq_status_method ());aml_append (sb_scope,build_iqcr_method (false));aml_append (sb_scope,build_link_dev ("LNKA" ,0 ,aml_name ("PRQA" )));
hw/i386/q35-acpi-dsdt.dsl +0 -8
@@ -298,14 +298,6 @@ DefinitionBlock ( PRQH, 8 } - Method(IQST, 1, NotSerialized) { - // _STA method - get status - If (And(0x80, Arg0)) { - Return (0x09) - } - Return (0x0B) - } - External(LNKA, DeviceObj) External(LNKB, DeviceObj) External(LNKC, DeviceObj)
Signature · 1 line
1.8.3.1
PATCH v2 42/51 pc: acpi: q35: move ISA bridge into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 46 ---------------------------------------- 2 files changed, 54 insertions(+), 46 deletions(-)
hw/i386/acpi-build.c +54 -0
@@ -1631,8 +1631,21 @@ static void build_piix4_pci0_int(Aml *table)static void build_q35_pci0_int (Aml *table) { +Aml *field;Aml *sb_scope =aml_scope ("_SB" ); + field =aml_field ("PCI0.ISA.PIRQ" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("PRQA" ,8 )); +aml_append (field,aml_named_field ("PRQB" ,8 )); +aml_append (field,aml_named_field ("PRQC" ,8 )); +aml_append (field,aml_named_field ("PRQD" ,8 )); +aml_append (field,aml_reserved_field (0x20 )); +aml_append (field,aml_named_field ("PRQE" ,8 )); +aml_append (field,aml_named_field ("PRQF" ,8 )); +aml_append (field,aml_named_field ("PRQG" ,8 )); +aml_append (field,aml_named_field ("PRQH" ,8 )); +aml_append (sb_scope, field); +aml_append (sb_scope,build_irq_status_method ());aml_append (sb_scope,build_iqcr_method (false));
@@ -1661,6 +1674,46 @@ static void build_q35_pci0_int(Aml *table)aml_append (table, sb_scope); } +static void build_q35_isa_bridge (Aml *table) +{ +Aml *dev; +Aml *scope; +Aml *field; + + scope =aml_scope ("_SB.PCI0" ); + dev =aml_device ("ISA" ); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0x001F0000 ))); + +/* ICH9 PCI to ISA irq remapping */ +aml_append (dev,aml_operation_region ("PIRQ" ,AML_PCI_CONFIG , +0x60 ,0x0C )); + +aml_append (dev,aml_operation_region ("LPCD" ,AML_PCI_CONFIG , +0x80 ,0x02 )); + field =aml_field ("LPCD" ,AML_ANY_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("COMA" ,3 )); +aml_append (field,aml_reserved_field (1 )); +aml_append (field,aml_named_field ("COMB" ,3 )); +aml_append (field,aml_reserved_field (1 )); +aml_append (field,aml_named_field ("LPTD" ,2 )); +aml_append (field,aml_reserved_field (2 )); +aml_append (field,aml_named_field ("FDCD" ,2 )); +aml_append (dev, field); + +aml_append (dev,aml_operation_region ("LPCE" ,AML_PCI_CONFIG , +0x82 ,0x02 )); +/* enable bits */ + field =aml_field ("LPCE" ,AML_ANY_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("CAEN" ,1 )); +aml_append (field,aml_named_field ("CBEN" ,1 )); +aml_append (field,aml_named_field ("LPEN" ,1 )); +aml_append (field,aml_named_field ("FDEN" ,1 )); +aml_append (dev, field); + +aml_append (scope, dev); +aml_append (table, scope); +} +static void build_piix4_pm (Aml *table) {Aml *dev;
@@ -1788,6 +1841,7 @@ build_ssdt(GArray *table_data, GArray *linker,build_piix4_pci0_int (ssdt); }else {build_hpet_aml (ssdt); +build_q35_isa_bridge (ssdt);build_isa_devices_aml (ssdt);build_q35_pci0_int (ssdt); }
hw/i386/q35-acpi-dsdt.dsl +0 -46
58 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 43/51 pc: acpi: q35: move _PRT() into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 21 +++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 12 ------------ 2 files changed, 21 insertions(+), 12 deletions(-)
hw/i386/acpi-build.c +21 -0
@@ -1632,7 +1632,28 @@ static void build_piix4_pci0_int(Aml *table)static void build_q35_pci0_int (Aml *table) {Aml *field; +Aml *method;Aml *sb_scope =aml_scope ("_SB" ); +Aml *pci0_scope =aml_scope ("PCI0" ); + + method =aml_method ("_PRT" ,0 ,AML_NOTSERIALIZED ); + { +Aml *if_ctx; +Aml *else_ctx; + +/* PCI IRQ routing table, example from ACPI 2.0a specification, +section 6.2.8.1 */ +/* Note: we provide the same info as the PCI routing +table of the Bochs BIOS */ + if_ctx =aml_if (aml_equal (aml_name ("PICF" ),aml_int (0 ))); +aml_append (if_ctx,aml_return (aml_name ("PRTP" ))); +aml_append (method, if_ctx); + else_ctx =aml_else (); +aml_append (else_ctx,aml_return (aml_name ("PRTA" ))); +aml_append (method, else_ctx); + } +aml_append (pci0_scope, method); +aml_append (sb_scope, pci0_scope); field =aml_field ("PCI0.ISA.PIRQ" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("PRQA" ,8 ));
hw/i386/q35-acpi-dsdt.dsl +0 -12
@@ -238,18 +238,6 @@ DefinitionBlock ( prt_slot_gsiA(0x001f) }) - - Method(_PRT, 0, NotSerialized) { - /* PCI IRQ routing table, example from ACPI 2.0a specification, - section 6.2.8.1 */ - /* Note: we provide the same info as the PCI routing - table of the Bochs BIOS */ - If (LEqual(\PICF, Zero)) { - Return (PRTP) - } Else { - Return (PRTA) - } - } } External(LNKA, DeviceObj)
Signature · 1 line
1.8.3.1
PATCH v2 44/51 pc: acpi: q35: move PRTA routing table into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 57 ------------------------------------------- 2 files changed, 61 insertions(+), 57 deletions(-)
hw/i386/acpi-build.c +61 -0
@@ -1629,6 +1629,64 @@ static void build_piix4_pci0_int(Aml *table)aml_append (table, sb_scope); } +static void append_q35_prt_entry (Aml *ctx,uint32_t nr,const char *name) +{ +int i; +int head; +Aml *pkg; +char base = name[3 ] <'E' ?'A' :'E' ; +char *s =g_strdup (name); +Aml *a_nr =aml_int ((nr <<16 ) |0xffff ); + +assert (strlen (s) ==4 ); + + head = name[3 ] - base; +for (i =0 ; i <4 ; i++) { +if (head + i >3 ) { + head = i *-1 ; + } + s[3 ] = base + head + i; + pkg =aml_package (4 ); +aml_append (pkg, a_nr); +aml_append (pkg,aml_int (i)); +aml_append (pkg,aml_name ("%s" , s)); +aml_append (pkg,aml_int (0 )); +aml_append (ctx, pkg); + } +g_free (s); +} + +static Aml *build_q35_routing_table (const char *str) +{ +int i; +Aml *pkg; +char *name =g_strdup_printf ("%s " , str); + + pkg =aml_package (128 ); +for (i =0 ; i <0x18 ; i++) { + name[3 ] ='E' + (i &0x3 ); +append_q35_prt_entry (pkg, i, name); + } + + name[3 ] ='E' ; +append_q35_prt_entry (pkg,0x18 , name); + +/* INTA -> PIRQA for slot 25 - 31, see the default value of D<N>IR */ +for (i =0x0019 ; i <0x1e ; i++) { + name[3 ] ='A' ; +append_q35_prt_entry (pkg, i, name); + } + +/* PCIe->PCI bridge. use PIRQ[E-H] */ + name[3 ] ='E' ; +append_q35_prt_entry (pkg,0x1e , name); + name[3 ] ='A' ; +append_q35_prt_entry (pkg,0x1f , name); + +g_free (name); +return pkg; +} +static void build_q35_pci0_int (Aml *table) {Aml *field;
@@ -1636,6 +1694,9 @@ static void build_q35_pci0_int(Aml *table)Aml *sb_scope =aml_scope ("_SB" );Aml *pci0_scope =aml_scope ("PCI0" ); +aml_append (pci0_scope, +aml_name_decl ("PRTA" ,build_q35_routing_table ("GSI" ))); + method =aml_method ("_PRT" ,0 ,AML_NOTSERIALIZED ); {Aml *if_ctx;
hw/i386/q35-acpi-dsdt.dsl +0 -57
63 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 45/51 pc: acpi: q35: move PRTP routing table into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 2 ++ hw/i386/q35-acpi-dsdt.dsl | 79 ----------------------------------------------- 2 files changed, 2 insertions(+), 79 deletions(-)
hw/i386/acpi-build.c +2 -0
@@ -1695,6 +1695,8 @@ static void build_q35_pci0_int(Aml *table)Aml *pci0_scope =aml_scope ("PCI0" );aml_append (pci0_scope, +aml_name_decl ("PRTP" ,build_q35_routing_table ("LNK" ))); +aml_append (pci0_scope,aml_name_decl ("PRTA" ,build_q35_routing_table ("GSI" ))); method =aml_method ("_PRT" ,0 ,AML_NOTSERIALIZED );
hw/i386/q35-acpi-dsdt.dsl +0 -79
83 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 46/51 pc: acpi: q35: move _PIC() method into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 8 ++++++++ hw/i386/q35-acpi-dsdt.dsl | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-)
hw/i386/acpi-build.c +8 -0
@@ -1694,6 +1694,14 @@ static void build_q35_pci0_int(Aml *table)Aml *sb_scope =aml_scope ("_SB" );Aml *pci0_scope =aml_scope ("PCI0" ); +/* Zero => PIC mode, One => APIC Mode */ +aml_append (table,aml_name_decl ("PICF" ,aml_int (0 ))); + method =aml_method ("_PIC" ,1 ,AML_NOTSERIALIZED ); + { +aml_append (method,aml_store (aml_arg (0 ),aml_name ("PICF" ))); + } +aml_append (table, method); +aml_append (pci0_scope,aml_name_decl ("PRTP" ,build_q35_routing_table ("LNK" ))); aml_append(pci0_scope,
hw/i386/q35-acpi-dsdt.dsl +0 -10
@@ -112,14 +112,4 @@ DefinitionBlock ( } } } - -/**************************************************************** - * PCI IRQs - ****************************************************************/ - - /* Zero => PIC mode, One => APIC Mode */ - Name(\PICF, Zero) - Method(\_PIC, 1, NotSerialized) { - Store(Arg0, \PICF) - } }
Signature · 1 line
1.8.3.1
PATCH v2 47/51 pc: acpi: q35: move PCI0._OSC() method into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 57 ----------------------------------------------- 2 files changed, 56 insertions(+), 57 deletions(-)
hw/i386/acpi-build.c +56 -0
@@ -1894,6 +1894,54 @@ static void build_piix4_pci_hotplug(Aml *table)aml_append (table, scope); } +static Aml *build_q35_osc_method (void ) +{ +Aml *if_ctx; +Aml *if_ctx2; +Aml *else_ctx; +Aml *method; +Aml *a_cwd1 =aml_name ("CDW1" ); +Aml *a_ctrl =aml_name ("CTRL" ); + + method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED ); +aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" )); + + if_ctx =aml_if (aml_equal ( +aml_arg (0 ),aml_touuid ("33DB4D5B-1FF7-401C-9657-7441C03DD766" ))); +aml_append (if_ctx,aml_create_dword_field (aml_arg (3 ),aml_int (4 ),"CDW2" )); +aml_append (if_ctx,aml_create_dword_field (aml_arg (3 ),aml_int (8 ),"CDW3" )); + +aml_append (if_ctx,aml_store (aml_name ("CDW2" ),aml_name ("SUPP" ))); +aml_append (if_ctx,aml_store (aml_name ("CDW3" ), a_ctrl)); + +/* +* Always allow native PME, AER (no dependencies) +* Never allow SHPC (no SHPC controller in this system) +*/ +aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1D ), a_ctrl)); + + if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 )))); +/* Unknown revision */ +aml_append (if_ctx2,aml_or (a_cwd1,aml_int (0x08 ), a_cwd1)); +aml_append (if_ctx, if_ctx2); + + if_ctx2 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ), a_ctrl))); +/* Capabilities bits were masked */ +aml_append (if_ctx2,aml_or (a_cwd1,aml_int (0x10 ), a_cwd1)); +aml_append (if_ctx, if_ctx2); + +/* Update DWORD3 in the buffer */ +aml_append (if_ctx,aml_store (a_ctrl,aml_name ("CDW3" ))); +aml_append (method, if_ctx); + + else_ctx =aml_else (); +/* Unrecognized UUID */ +aml_append (else_ctx,aml_or (a_cwd1,aml_int (4 ), a_cwd1)); +aml_append (method, else_ctx); + +aml_append (method,aml_return (aml_arg (3 ))); +return method; +} static void build_ssdt(GArray *table_data, GArray *linker,
@@ -1932,6 +1980,14 @@ build_ssdt(GArray *table_data, GArray *linker,build_piix4_pci_hotplug (ssdt);build_piix4_pci0_int (ssdt); }else { + sb_scope =aml_scope ("_SB" ); + scope =aml_scope ("PCI0" ); +aml_append (scope,aml_name_decl ("SUPP" ,aml_int (0 ))); +aml_append (scope,aml_name_decl ("CTRL" ,aml_int (0 ))); +aml_append (scope,build_q35_osc_method ()); +aml_append (sb_scope, scope); +aml_append (ssdt, sb_scope); +build_hpet_aml (ssdt);build_q35_isa_bridge (ssdt);build_isa_devices_aml (ssdt);
hw/i386/q35-acpi-dsdt.dsl +0 -57
63 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 48/51 pc: acpi: q35: move PCI0 device definition into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 14 +++++++++----- hw/i386/q35-acpi-dsdt.dsl | 13 ------------- 2 files changed, 9 insertions(+), 18 deletions(-)
hw/i386/acpi-build.c +9 -5
@@ -1981,11 +1981,15 @@ build_ssdt(GArray *table_data, GArray *linker,build_piix4_pci0_int (ssdt); }else { sb_scope =aml_scope ("_SB" ); - scope =aml_scope ("PCI0" ); -aml_append (scope,aml_name_decl ("SUPP" ,aml_int (0 ))); -aml_append (scope,aml_name_decl ("CTRL" ,aml_int (0 ))); -aml_append (scope,build_q35_osc_method ()); -aml_append (sb_scope, scope); + dev =aml_device ("PCI0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A08" ))); +aml_append (dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A03" ))); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (1 ))); +aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); +aml_append (dev,build_q35_osc_method ()); +aml_append (sb_scope, dev);aml_append (ssdt, sb_scope);build_hpet_aml (ssdt);
hw/i386/q35-acpi-dsdt.dsl +0 -13
@@ -42,17 +42,4 @@ DefinitionBlock ( PCIB, 8, } } - - -/**************************************************************** - * PCI Bus definition - ****************************************************************/ - Scope(\_SB) { - Device(PCI0) { - Name(_HID, EisaId("PNP0A08")) - Name(_CID, EisaId("PNP0A03")) - Name(_ADR, 0x00) - Name(_UID, 1) - } - } }
Signature · 1 line
1.8.3.1
PATCH v2 49/51 pc: acpi: q35: PCST, PCSB opregions and PCIB field into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 10 ++++++++++ hw/i386/q35-acpi-dsdt.dsl | 5 ----- 2 files changed, 10 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +10 -0
@@ -1981,6 +1981,16 @@ build_ssdt(GArray *table_data, GArray *linker,build_piix4_pci0_int (ssdt); }else { sb_scope =aml_scope ("_SB" ); +aml_append (sb_scope, +aml_operation_region ("PCST" ,AML_SYSTEM_IO ,0xae00 ,0x0c )); +aml_append (sb_scope, +aml_operation_region ("PCSB" ,AML_SYSTEM_IO ,0xae0c ,0x01 )); + field =aml_field ("PCSB" ,AML_ANY_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("PCIB" ,8 )); +aml_append (sb_scope, field); +aml_append (ssdt, sb_scope); + + sb_scope =aml_scope ("_SB" ); dev =aml_device ("PCI0" );aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A08" )));aml_append (dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A03" )));
hw/i386/q35-acpi-dsdt.dsl +0 -5
@@ -36,10 +36,5 @@ DefinitionBlock ( { Scope(\_SB) { - OperationRegion(PCST, SystemIO, 0xae00, 0x0c) - OperationRegion(PCSB, SystemIO, 0xae0c, 0x01) - Field(PCSB, AnyAcc, NoLock, WriteAsZeros) { - PCIB, 8, - } } }
Signature · 1 line
1.8.3.1
PATCH v2 50/51 pc: acpi: switch to AML API composed DSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 235 +++++++++++++++++++++++++-------------------------- 1 file changed, 115 insertions(+), 120 deletions(-)
hw/i386/acpi-build.c +115 -120
@@ -53,9 +53,6 @@#include "hw/i386/intel_iommu.h" #include "hw/timer/hpet.h" -#include "hw/i386/q35-acpi-dsdt.hex" -#include "hw/i386/acpi-dsdt.hex" -#include "hw/acpi/aml-build.h" #include "qapi/qmp/qint.h"
@@ -124,24 +121,6 @@ typedef struct AcpiBuildPciBusHotplugState {bool pcihp_bridge_en; } AcpiBuildPciBusHotplugState; -static void acpi_get_dsdt (AcpiMiscInfo *info) -{ -Object *piix =piix4_pm_find (); -Object *lpc =ich9_lpc_find (); -assert (!!piix != !!lpc); - -if (piix) { - info->is_piix4 = true; - info->dsdt_code = AcpiDsdtAmlCode; - info->dsdt_size =sizeof AcpiDsdtAmlCode; - } -if (lpc) { - info->is_piix4 = false; - info->dsdt_code = Q35AcpiDsdtAmlCode; - info->dsdt_size =sizeof Q35AcpiDsdtAmlCode; - } -} -static int acpi_add_cpu_info (Object *o,void *opaque) {
@@ -240,6 +219,17 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)static void acpi_get_misc_info (AcpiMiscInfo *info) { +Object *piix =piix4_pm_find (); +Object *lpc =ich9_lpc_find (); +assert (!!piix != !!lpc); + +if (piix) { + info->is_piix4 = true; + } +if (lpc) { + info->is_piix4 = false; + } + info->has_hpet =hpet_find (); info->tpm_version =tpm_get_version (); info->pvpanic_port =pvpanic_port ();
@@ -1963,95 +1953,6 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); -build_dbg_aml (ssdt); -if (misc->is_piix4) { - sb_scope =aml_scope ("_SB" ); - dev =aml_device ("PCI0" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A03" ))); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0 ))); -aml_append (dev,aml_name_decl ("_UID" ,aml_int (1 ))); -aml_append (sb_scope, dev); -aml_append (ssdt, sb_scope); - -build_hpet_aml (ssdt); -build_piix4_pm (ssdt); -build_piix4_isa_bridge (ssdt); -build_isa_devices_aml (ssdt); -build_piix4_pci_hotplug (ssdt); -build_piix4_pci0_int (ssdt); - }else { - sb_scope =aml_scope ("_SB" ); -aml_append (sb_scope, -aml_operation_region ("PCST" ,AML_SYSTEM_IO ,0xae00 ,0x0c )); -aml_append (sb_scope, -aml_operation_region ("PCSB" ,AML_SYSTEM_IO ,0xae0c ,0x01 )); - field =aml_field ("PCSB" ,AML_ANY_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_named_field ("PCIB" ,8 )); -aml_append (sb_scope, field); -aml_append (ssdt, sb_scope); - - sb_scope =aml_scope ("_SB" ); - dev =aml_device ("PCI0" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A08" ))); -aml_append (dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A03" ))); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0 ))); -aml_append (dev,aml_name_decl ("_UID" ,aml_int (1 ))); -aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 ))); -aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); -aml_append (dev,build_q35_osc_method ()); -aml_append (sb_scope, dev); -aml_append (ssdt, sb_scope); - -build_hpet_aml (ssdt); -build_q35_isa_bridge (ssdt); -build_isa_devices_aml (ssdt); -build_q35_pci0_int (ssdt); - } - -build_cpu_hotplug_aml (ssdt); -build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); - - scope =aml_scope ("_GPE" ); - { -aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); - -aml_append (scope,aml_method ("_L00" ,0 ,AML_NOTSERIALIZED )); - -if (misc->is_piix4) { - method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); -aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); -aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); -aml_append (scope, method); - }else { -aml_append (scope,aml_method ("_L01" ,0 ,AML_NOTSERIALIZED )); - } - - method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD )); -aml_append (scope, method); - - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); - -aml_append (scope,aml_method ("_L04" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L05" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L06" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L07" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L08" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L09" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0A" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0B" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0C" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0D" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0E" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0F" ,0 ,AML_NOTSERIALIZED )); - } -aml_append (ssdt, scope); - bus =PC_MACHINE (machine)->bus;if (bus) { QLIST_FOREACH(bus, &bus->child, sibling) {
@@ -2521,18 +2422,113 @@ build_dmar_q35(GArray *table_data, GArray *linker) }static void -build_dsdt (GArray *table_data,GArray *linker,AcpiMiscInfo *misc) +build_dsdt (GArray *table_data,GArray *linker, +AcpiPmInfo *pm,AcpiMiscInfo *misc) { -AcpiTableHeader *dsdt; +Aml *dsdt, *sb_scope, *scope, *dev, *method, *field; +MachineState *machine =MACHINE (qdev_get_machine ()); +uint32_t nr_mem = machine->ram_slots; + + dsdt =init_aml_allocator (); -assert (misc->dsdt_code && misc->dsdt_size); +/* Reserve space for header */ +acpi_data_push (dsdt->buf,sizeof (AcpiTableHeader)); - dsdt =acpi_data_push (table_data, misc->dsdt_size); -memcpy (dsdt, misc->dsdt_code, misc->dsdt_size); +build_dbg_aml (dsdt); +if (misc->is_piix4) { + sb_scope =aml_scope ("_SB" ); + dev =aml_device ("PCI0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A03" ))); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (1 ))); +aml_append (sb_scope, dev); +aml_append (dsdt, sb_scope); + +build_hpet_aml (dsdt); +build_piix4_pm (dsdt); +build_piix4_isa_bridge (dsdt); +build_isa_devices_aml (dsdt); +build_piix4_pci_hotplug (dsdt); +build_piix4_pci0_int (dsdt); + }else { + sb_scope =aml_scope ("_SB" ); +aml_append (sb_scope, +aml_operation_region ("PCST" ,AML_SYSTEM_IO ,0xae00 ,0x0c )); +aml_append (sb_scope, +aml_operation_region ("PCSB" ,AML_SYSTEM_IO ,0xae0c ,0x01 )); + field =aml_field ("PCSB" ,AML_ANY_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("PCIB" ,8 )); +aml_append (sb_scope, field); +aml_append (dsdt, sb_scope); + + sb_scope =aml_scope ("_SB" ); + dev =aml_device ("PCI0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A08" ))); +aml_append (dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A03" ))); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (1 ))); +aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); +aml_append (dev,build_q35_osc_method ()); +aml_append (sb_scope, dev); +aml_append (dsdt, sb_scope); + +build_hpet_aml (dsdt); +build_q35_isa_bridge (dsdt); +build_isa_devices_aml (dsdt); +build_q35_pci0_int (dsdt); + } -memset (dsdt,0 ,sizeof *dsdt); -build_header (linker, table_data, dsdt,"DSDT" , - misc->dsdt_size,1 ,NULL ); +build_cpu_hotplug_aml (dsdt); +build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); + + scope =aml_scope ("_GPE" ); + { +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + +aml_append (scope,aml_method ("_L00" ,0 ,AML_NOTSERIALIZED )); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { +aml_append (scope,aml_method ("_L01" ,0 ,AML_NOTSERIALIZED )); + } + + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD )); +aml_append (scope, method); + + method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); +aml_append (scope, method); + +aml_append (scope,aml_method ("_L04" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L05" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L06" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L07" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L08" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L09" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0A" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0B" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0C" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0D" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0E" ,0 ,AML_NOTSERIALIZED )); +aml_append (scope,aml_method ("_L0F" ,0 ,AML_NOTSERIALIZED )); + } +aml_append (dsdt, scope); + +/* copy AML table into ACPI tables blob and patch header there */ +g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len); +build_header (linker, table_data, + (void *)(table_data->data + table_data->len - dsdt->buf->len), +"DSDT" , dsdt->buf->len,1 ,NULL ); +free_aml_allocator (); } static GArray *
@@ -2626,7 +2622,6 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)acpi_get_cpu_info (&cpu);acpi_get_pm_info (&pm); -acpi_get_dsdt (&misc);acpi_get_misc_info (&misc);acpi_get_pci_info (&pci);
@@ -2648,7 +2643,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)/* DSDT is pointed to by FADT */ dsdt = tables_blob->len; -build_dsdt (tables_blob, tables->linker, &misc); +build_dsdt (tables_blob, tables->linker, &pm, &misc);/* Count the size of the DSDT and SSDT, we will need it for legacy * sizing of ACPI tables.
Signature · 1 line
1.8.3.1
PATCH v2 51/51 pc: acpi: remove unused ASL templates and related blobs/utils
In reply to Igor MammedovQEMU now uses internally composed DSDT so drop now empty *.dsl templates and related *.generated binary blobs.
Also since templates are not used anymore/obolete remove utility scripts used for extracting/patching AML blobs compiled by IASL and for updating them in git tree.
--- hw/i386/Makefile.objs | 30 - hw/i386/acpi-dsdt.dsl | 33 - hw/i386/acpi-dsdt.hex.generated | 2972 -------------- hw/i386/q35-acpi-dsdt.dsl | 40 - hw/i386/q35-acpi-dsdt.hex.generated | 7610 ----------------------------------- scripts/acpi_extract.py | 367 -- scripts/acpi_extract_preprocess.py | 51 - scripts/update-acpi.sh | 4 - 8 files changed, 11107 deletions(-) delete mode 100644 hw/i386/acpi-dsdt.dsl delete mode 100644 hw/i386/acpi-dsdt.hex.generated delete mode 100644 hw/i386/q35-acpi-dsdt.dsl delete mode 100644 hw/i386/q35-acpi-dsdt.hex.generated delete mode 100755 scripts/acpi_extract.py delete mode 100755 scripts/acpi_extract_preprocess.py delete mode 100644 scripts/update-acpi.sh
hw/i386/Makefile.objs +0 -30
@@ -8,33 +8,3 @@ obj-$(CONFIG_XEN) += ../xenpv/ xen/ obj-y += kvmvapic.o obj-y += acpi-build.o obj-y += pci-assign-load-rom.o - -gen-hex-y += hw/i386/acpi-dsdt.hex -gen-hex-y += hw/i386/q35-acpi-dsdt.hex - -hw/i386/acpi-build.o: hw/i386/acpi-build.c \ - $(gen-hex-y) - --include $(gen-hex-y:.hex=.d) - -iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ - ; then echo "$(2)"; else echo "$(3)"; fi ;) - -ifdef IASL -#IASL Present. Generate hex files from .dsl -hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py - $(call quiet-command, $(CPP) -x c -P $(QEMU_DGFLAGS) $(QEMU_INCLUDES) $< -o $*.dsl.i.orig, " CPP $(TARGET_DIR)$*.dsl.i.orig") - $(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, " ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i") - $(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ," IASL $(TARGET_DIR)$*.dsl.i") - $(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, " ACPI_EXTRACT $(TARGET_DIR)$*.off") - $(call quiet-command, cat $*.off > $@, " CAT $(TARGET_DIR)$@") -else -#IASL Not present. Restore pre-generated hex files. -hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.hex.generated - $(call quiet-command, cp -f $< $@, " CP $(TARGET_DIR)$@") -endif - -.PHONY: cleanhex -cleanhex: - rm -f hw/i386/*hex -clean: cleanhex
hw/i386/acpi-dsdt.dsl deleted +0 -33
@@ -1,33 +0,0 @@ -/* - * Bochs/QEMU ACPI DSDT ASL definition - * - * Copyright (c) 2006 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode - -DefinitionBlock ( - "acpi-dsdt.aml", // Output Filename - "DSDT", // Signature - 0x01, // DSDT Compliance Revision - "BXPC", // OEMID - "BXDSDT", // TABLE ID - 0x1 // OEM Revision - ) -{ - Scope(\_SB) { - } -}
hw/i386/acpi-dsdt.hex.generated deleted +0 -2972
2,934 lines not on this page · raw message
hw/i386/q35-acpi-dsdt.hex.generated deleted +0 -7610
7,610 lines not on this page · raw message
scripts/acpi_extract.py deleted +0 -367
367 lines not on this page · raw message
scripts/acpi_extract_preprocess.py deleted +0 -51
51 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.