Skip to contentSkip to conversation

pc: acpi: convert DSDT to AML API and drop ASL templates support

PATCH Superseded Igor Mammedov 5 participants 165 messages Dec 9, 2015 – Dec 22, 2015 Page 2 of 2

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#127 lore raw

Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT

In reply to Michael S. Tsirkin
Quoted 39 lines · On Tue, 22 Dec 2015 16:47:18 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov

On Tue, 22 Dec 2015 11:37:40 +0200
"Michael S. Tsirkin" <[email protected]> wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 8 lines

hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1435

Quoted 6 lines
hw/i386/acpi-build.c +6 -0
+        for (i = 4; i <= 0xF; i++) {
+            char *name = g_strdup_printf("_L0%X", i);
+            method = aml_method(name, 0, AML_NOTSERIALIZED);
+            aml_append(scope, method);
+            g_free(name);
+        }

How about we make aml_method accept ... format instead?

actually instead of making aml_method(format,...) it would be easier to make it accept Aml* so we could reuse aml_name(format,...) in the end it would look like:

Aml gpe_name = aml_name("_L0%X", i);
aml_method(gpe_name, AML_NOTSERIALIZED);

Quoted 6 lines
Quoted 2 lines

in addition name object could be reused in other places that reference that method.

Except most methods are simple, so maybe do both APIs. Avoiding string duplication is a good idea, but using string constants works just as well.

I don't like having 2 APIs, one with 'Aml* name' and other with 'const char *name' in C. I'd prefer to have just one that suits the majority use cases and

Quoted 8 lines

I'm not so comfortable with using format string here directly as it would look weird (at least to me):
aml_method("_L0%X", i, argcount, AML_NOTSERIALIZED);
- static format string check at compile time won't work here
or
aml_method(argcount, AML_NOTSERIALIZED, "_L0%X", i);
- that should be fine except of that argument order doesn't match the way it's in spec, which I'd prefer to keep

Quoted 3 lines

Just add ... at the end:

aml_method("_L0%X", argcount, AML_NOTSERIALIZED, i);

ok, I'll try to do it.

Quoted 14 lines

looks a bit weird if you have to use it, but it's uncommon, and the common case looks simple.

Quoted 10 lines

so it leaves for me 2 options:
1: use aml_method(aml_name("_L0%X", i), argcount, AML_NOTSERIALIZED)
It's a bit of code churn and not sure if we really need it but I can do if asked for it.

2: just leave it as is for now, because the most of method names
are just string constants. These "_L0%X" will be gone after cleanup, leaving us with only handlers that use string const and do some work.

Quoted 6 lines
Quoted 2 lines

I can replace g_strdup_printf() with static buffer here if you dislike alloc/free in this patch.

So how about just open-coding this loop for now? That's just about 10 lines of code,
not a big deal.

sure

Quoted 3 lines

As you say, will be gone after refactoring.

#128 lore raw

PATCH 55/74 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
index 99c0294..f5e519b 100644
@@ -1303,9 +1303,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);
@@ -1315,6 +1355,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
#129 lore raw

PATCH 56/74 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
index f5e519b..2720262 100644
@@ -1344,6 +1344,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");
@@ -1355,6 +1356,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
index b74cffd..1f58ec4 100644
@@ -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
#130 lore raw

PATCH 57/74 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
index 2720262..cf98037 100644
@@ -1356,6 +1356,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
index 1f58ec4..bc6bd45 100644
@@ -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
#131 lore raw

PATCH 58/74 pc: acpi: piix4: move PCI0._PRT() into SSDT

In reply to Igor Mammedov
---
 hw/i386/acpi-build.c  | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt.dsl | 60 -------------------------------------
 2 files changed, 83 insertions(+), 60 deletions(-)
hw/i386/acpi-build.c +83 -0
index cf98037..f0966b8 100644
@@ -1339,6 +1339,17 @@ static Aml *build_link_dev(const char *name, uint8_t uid, Aml *reg)
     return dev;
  }
 
+static Aml *build_prt_entry(const char *dev)
+{
+    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", dev));
+    aml_append(pkg, a_zero);
+    return pkg;
+}
+
 static void build_piix4_pci0_int(Aml *table)
 {
     Aml *dev;
@@ -1348,6 +1359,78 @@ 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");
+
+    method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
+    {
+        Aml *w_ctx;
+        Aml *if_ctx2;
+        Aml *else_ctx2;
+        Aml *a_zero = aml_int(0);
+        Aml *a_prt = aml_local(0);
+        Aml *a_pin = aml_local(1);
+        Aml *a_lnk = aml_local(3);
+        Aml *a_slot = aml_local(2);
+        Aml *a_prt_ent = aml_local(4);
+
+        aml_append(method, aml_store(aml_package(128), a_prt));
+        aml_append(method, aml_store(a_zero, a_pin));
+        w_ctx = aml_while(aml_lless(a_pin, aml_int(128)));
+
+        /* slot = pin >> 2 */
+        aml_append(w_ctx,
+            aml_store(aml_shiftright(a_pin, aml_int(2), NULL), a_slot));
+
+        /* lnk = (slot + pin) & 3 */
+        aml_append(w_ctx,
+            aml_store(aml_and(aml_add(a_pin, a_slot, NULL), aml_int(3), NULL),
+                      a_lnk));
+
+        if_ctx = aml_if(aml_equal(a_lnk, a_zero));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKD"), a_prt_ent));
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(1)));
+        /* device 1 is the power-management device, needs SCI */
+        if_ctx2 = aml_if(aml_equal(a_pin, aml_int(4)));
+        aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), a_prt_ent));
+        aml_append(if_ctx, if_ctx2);
+        else_ctx2 = aml_else();
+        aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), a_prt_ent));
+        aml_append(if_ctx, else_ctx2);
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(2)));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKB"), a_prt_ent));
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(3)));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKC"), a_prt_ent));
+        aml_append(w_ctx, if_ctx);
+
+        /*
+         * Complete the interrupt routing entry:
+         *    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
+         */
+        aml_append(w_ctx,
+            aml_store(
+                aml_or(aml_shiftleft(a_slot, aml_int(16)),
+                       aml_int(0xFFFF), NULL),
+                aml_index(a_prt_ent, a_zero)
+            )
+        );
+        aml_append(w_ctx,
+            aml_store(aml_and(a_pin, aml_int(3), NULL),
+                      aml_index(a_prt_ent, aml_int(1))));
+        aml_append(w_ctx, aml_store(a_prt_ent, aml_index(a_prt, a_pin)));
+
+        aml_append(w_ctx, aml_increment(a_pin));
+        aml_append(method, w_ctx);
+
+        aml_append(method, aml_return(aml_local(0)));
+    }
+    aml_append(pci0_scope, method);
+    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));
hw/i386/acpi-dsdt.dsl +0 -60

64 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#132 lore raw

Re: [Qemu-devel] [PATCH 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 29 lines · Igor Mammedov
---
  hw/i386/acpi-build.c  | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
  hw/i386/acpi-dsdt.dsl | 60 -------------------------------------
  2 files changed, 83 insertions(+), 60 deletions(-)
hw/i386/acpi-build.c +11 -0
index cf98037..f0966b8 100644
@@ -1339,6 +1339,17 @@ static Aml *build_link_dev(const char *name, uint8_t uid, Aml *reg)
      return dev;
   }
 
+static Aml *build_prt_entry(const char *dev)
+{
+    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", dev));
+    aml_append(pkg, a_zero);
+    return pkg;
+}
+
  static void build_piix4_pci0_int(Aml *table)
  {
      Aml *dev;

hw/i386/acpi-build.c static void build_piix4_pci0_int(Aml *table) · line 1365

Quoted 7 lines
hw/i386/acpi-build.c +4 -0
@@ -1348,6 +1359,78 @@ 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");
+
+    method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
+    {

Hi,

Actually there is a PRT implementation already, please see:
static Aml *build_prt(void)

It is used for PXB host-bridges and it is *almost* the same. The only difference is the power-management device.

I think is better to unify those (instead of duplicating the code).

Thanks,
Marcel

Quoted 141 lines
hw/i386/acpi-build.c +68 -0
+        Aml *w_ctx;
+        Aml *if_ctx2;
+        Aml *else_ctx2;
+        Aml *a_zero = aml_int(0);
+        Aml *a_prt = aml_local(0);
+        Aml *a_pin = aml_local(1);
+        Aml *a_lnk = aml_local(3);
+        Aml *a_slot = aml_local(2);
+        Aml *a_prt_ent = aml_local(4);
+
+        aml_append(method, aml_store(aml_package(128), a_prt));
+        aml_append(method, aml_store(a_zero, a_pin));
+        w_ctx = aml_while(aml_lless(a_pin, aml_int(128)));
+
+        /* slot = pin >> 2 */
+        aml_append(w_ctx,
+            aml_store(aml_shiftright(a_pin, aml_int(2), NULL), a_slot));
+
+        /* lnk = (slot + pin) & 3 */
+        aml_append(w_ctx,
+            aml_store(aml_and(aml_add(a_pin, a_slot, NULL), aml_int(3), NULL),
+                      a_lnk));
+
+        if_ctx = aml_if(aml_equal(a_lnk, a_zero));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKD"), a_prt_ent));
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(1)));
+        /* device 1 is the power-management device, needs SCI */
+        if_ctx2 = aml_if(aml_equal(a_pin, aml_int(4)));
+        aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), a_prt_ent));
+        aml_append(if_ctx, if_ctx2);
+        else_ctx2 = aml_else();
+        aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), a_prt_ent));
+        aml_append(if_ctx, else_ctx2);
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(2)));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKB"), a_prt_ent));
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(3)));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKC"), a_prt_ent));
+        aml_append(w_ctx, if_ctx);
+
+        /*
+         * Complete the interrupt routing entry:
+         *    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
+         */
+        aml_append(w_ctx,
+            aml_store(
+                aml_or(aml_shiftleft(a_slot, aml_int(16)),
+                       aml_int(0xFFFF), NULL),
+                aml_index(a_prt_ent, a_zero)
+            )
+        );
+        aml_append(w_ctx,
+            aml_store(aml_and(a_pin, aml_int(3), NULL),
+                      aml_index(a_prt_ent, aml_int(1))));
+        aml_append(w_ctx, aml_store(a_prt_ent, aml_index(a_prt, a_pin)));
+
+        aml_append(w_ctx, aml_increment(a_pin));
+        aml_append(method, w_ctx);
+
+        aml_append(method, aml_return(aml_local(0)));
+    }
+    aml_append(pci0_scope, method);
+    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));
hw/i386/acpi-dsdt.dsl +0 -60
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
          /* Hotplug notification method supplied by SSDT */
          External(\_SB.PCI0.PCNT, MethodObj)
      }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management device, needs SCI
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
-
-                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
-                    Store(And(Local1, 3),                    Index(Local4, 1))
-                    Store(Local4,                            Index(Local0, Local1))
-
-                    Increment(Local1)
-                }
-
-                Return(Local0)
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
  }
#133 lore raw

Re: [Qemu-devel] [PATCH 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 41 lines · On Thu, 10 Dec 2015 14:32:11 +0200 Marcel Apfelbaum…
Quoted 30 lines · Igor Mammedov
---
  hw/i386/acpi-build.c  | 83

+++++++++++++++++++++++++++++++++++++++++++++++++++
hw/i386/acpi-dsdt.dsl | 60 ------------------------------------- 2 files changed, 83 insertions(+), 60 deletions(-)

hw/i386/acpi-build.c +11 -0
index cf98037..f0966b8 100644
@@ -1339,6 +1339,17 @@ static Aml *build_link_dev(const char *name,
 uint8_t uid, Aml *reg) return dev;
   }
 
+static Aml *build_prt_entry(const char *dev)
+{
+    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", dev));
+    aml_append(pkg, a_zero);
+    return pkg;
+}
+
  static void build_piix4_pci0_int(Aml *table)
  {
      Aml *dev;

hw/i386/acpi-build.c static void build_piix4_pci0_int(Aml *table) · line 1365

Quoted 7 lines
hw/i386/acpi-build.c +4 -0
@@ -1348,6 +1359,78 @@ 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");
+
+    method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
+    {

Hi,

Quoted 7 lines

Actually there is a PRT implementation already, please see:
static Aml *build_prt(void)

It is used for PXB host-bridges and it is *almost* the same. The only difference is the power-management device.

I think is better to unify those (instead of duplicating the code).

Ok, I'll check if it possible to unify while keeping byte compatible with IASL generated DSDT. If it's not we can do some code duplication here and in follow up optimizations drop/replace it in favor of build_prt() to remove code duplication and optimize resulting AML.

Quoted 162 lines

Thanks,
Marcel

Quoted 155 lines
hw/i386/acpi-build.c +17 -0
+        Aml *w_ctx;
+        Aml *if_ctx2;
+        Aml *else_ctx2;
+        Aml *a_zero = aml_int(0);
+        Aml *a_prt = aml_local(0);
+        Aml *a_pin = aml_local(1);
+        Aml *a_lnk = aml_local(3);
+        Aml *a_slot = aml_local(2);
+        Aml *a_prt_ent = aml_local(4);
+
+        aml_append(method, aml_store(aml_package(128), a_prt));
+        aml_append(method, aml_store(a_zero, a_pin));
+        w_ctx = aml_while(aml_lless(a_pin, aml_int(128)));
+
+        /* slot = pin >> 2 */
+        aml_append(w_ctx,
+            aml_store(aml_shiftright(a_pin, aml_int(2), NULL),

a_slot)); +

hw/i386/acpi-build.c +3 -0
+        /* lnk = (slot + pin) & 3 */
+        aml_append(w_ctx,
+            aml_store(aml_and(aml_add(a_pin, a_slot, NULL),

aml_int(3), NULL),

hw/i386/acpi-build.c +4 -0
+                      a_lnk));
+
+        if_ctx = aml_if(aml_equal(a_lnk, a_zero));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKD"),

a_prt_ent));

hw/i386/acpi-build.c +6 -0
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(1)));
+        /* device 1 is the power-management device, needs SCI */
+        if_ctx2 = aml_if(aml_equal(a_pin, aml_int(4)));
+        aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"),

a_prt_ent));

hw/i386/acpi-build.c +3 -0
+        aml_append(if_ctx, if_ctx2);
+        else_ctx2 = aml_else();
+        aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"),

a_prt_ent));

hw/i386/acpi-build.c +5 -0
+        aml_append(if_ctx, else_ctx2);
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(2)));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKB"),

a_prt_ent));

hw/i386/acpi-build.c +4 -0
+        aml_append(w_ctx, if_ctx);
+
+        if_ctx = aml_if(aml_equal(a_lnk, aml_int(3)));
+        aml_append(if_ctx, aml_store(build_prt_entry("LNKC"),

a_prt_ent));

hw/i386/acpi-build.c +17 -0
+        aml_append(w_ctx, if_ctx);
+
+        /*
+         * Complete the interrupt routing entry:
+         *    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
+         */
+        aml_append(w_ctx,
+            aml_store(
+                aml_or(aml_shiftleft(a_slot, aml_int(16)),
+                       aml_int(0xFFFF), NULL),
+                aml_index(a_prt_ent, a_zero)
+            )
+        );
+        aml_append(w_ctx,
+            aml_store(aml_and(a_pin, aml_int(3), NULL),
+                      aml_index(a_prt_ent, aml_int(1))));
+        aml_append(w_ctx, aml_store(a_prt_ent, aml_index(a_prt,

a_pin))); +

hw/i386/acpi-build.c +7 -0
+        aml_append(w_ctx, aml_increment(a_pin));
+        aml_append(method, w_ctx);
+
+        aml_append(method, aml_return(aml_local(0)));
+    }
+    aml_append(pci0_scope, method);
+    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));

hw/i386/acpi-dsdt.dsl +0 -22
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
          /* Hotplug notification method supplied by SSDT */
          External(\_SB.PCI0.PCNT, MethodObj)
      }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD,
 Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management

device, needs SCI

hw/i386/acpi-dsdt.dsl +0 -2
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -2
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -4
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -3
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -4
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin],

[link], 0) } -
- Store(Or(ShiftLeft(Local2, 16), 0xFFFF),
Index(Local4, 0))
- Store(And(Local1, 3),
Index(Local4, 1))
- Store(Local4,
Index(Local0, Local1)) -

hw/i386/acpi-dsdt.dsl +0 -18
-                    Increment(Local1)
-                }
-
-                Return(Local0)
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
  }
#134 lore raw

PATCH v2 58/74 pc: acpi: piix4: move PCI0._PRT() into SSDT

In reply to Marcel Apfelbaum

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
 hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
 hw/i386/acpi-dsdt.dsl | 60 ---------------------------------------------------
 2 files changed, 32 insertions(+), 69 deletions(-)
hw/i386/acpi-build.c +32 -9
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
     qobject_decref(bsel);
 }
 
+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:
@@ -630,12 +641,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;
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2, *else_ctx2;
 
     method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
     res = aml_local(0);
@@ -678,7 +685,19 @@ 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI */
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), route));
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), route));
+            aml_append(if_ctx, else_ctx2);
+            aml_append(while_ctx, if_ctx);
+        } 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));
 
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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
Reviewed-by on v2 58/74
#135 lore raw

Re: [Qemu-devel] [PATCH v2 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 163 lines · Igor Mammedov

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
  hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
  hw/i386/acpi-dsdt.dsl | 60 ---------------------------------------------------
  2 files changed, 32 insertions(+), 69 deletions(-)
hw/i386/acpi-build.c +32 -9
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
      qobject_decref(bsel);
  }
 
+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:
@@ -630,12 +641,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;
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2, *else_ctx2;
 
      method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
      res = aml_local(0);
@@ -678,7 +685,19 @@ 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI */
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), route));
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), route));
+            aml_append(if_ctx, else_ctx2);
+            aml_append(while_ctx, if_ctx);
+        } 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));
 
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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 -51
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
          /* Hotplug notification method supplied by SSDT */
          External(\_SB.PCI0.PCNT, MethodObj)
      }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management device, needs SCI
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
-
-                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
-                    Store(And(Local1, 3),                    Index(Local4, 1))
-                    Store(Local4,                            Index(Local0, Local1))
-
-                    Increment(Local1)
-                }
-
-                Return(Local0)
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)

hw/i386/acpi-dsdt.dsl DefinitionBlock ( · line 81

Quoted 10 lines
hw/i386/acpi-dsdt.dsl +0 -9
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
  }

Assuming that there are no differences in the PRT:

Thanks,
Marcel

#136 lore raw

Re: [Qemu-devel] [PATCH v2 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 196 lines · On Sun, 13 Dec 2015 17:19:23 +0200 Marcel Apfelbaum…
Quoted 182 lines · Igor Mammedov

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code
duplication, Suggested-by: Marcel Apfelbaum <[email protected]>

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
  hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
  hw/i386/acpi-dsdt.dsl | 60

--------------------------------------------------- 2 files changed, 32 insertions(+), 69 deletions(-)

hw/i386/acpi-build.c +14 -7
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml
 *parent_scope, PCIBus *bus, qobject_decref(bsel);
  }
 
+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:
@@ -630,12 +641,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;
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2,
 *else_ctx2;
 
      method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
      res = aml_local(0);
hw/i386/acpi-build.c +5 -1
@@ -678,7 +685,19 @@ 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI
 */
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"),

route));

hw/i386/acpi-build.c +3 -0
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2,

aml_store(build_prt_entry("LNKA"), route));

hw/i386/acpi-build.c +4 -0
+            aml_append(if_ctx, else_ctx2);
+            aml_append(while_ctx, if_ctx);
+        } 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));

hw/i386/acpi-build.c +5 -1
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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 -22
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
          /* Hotplug notification method supplied by SSDT */
          External(\_SB.PCI0.PCNT, MethodObj)
      }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD,
 Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management

device, needs SCI

hw/i386/acpi-dsdt.dsl +0 -2
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -2
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -4
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -3
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC,

Zero }, Local4)

hw/i386/acpi-dsdt.dsl +0 -4
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin],

[link], 0) } -
- Store(Or(ShiftLeft(Local2, 16), 0xFFFF),
Index(Local4, 0))
- Store(And(Local1, 3),
Index(Local4, 1))
- Store(Local4,
Index(Local0, Local1)) -

hw/i386/acpi-dsdt.dsl +0 -9
-                    Increment(Local1)
-                }
-
-                Return(Local0)
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)

hw/i386/acpi-dsdt.dsl DefinitionBlock ( · line 81

Quoted 10 lines
hw/i386/acpi-dsdt.dsl +0 -9
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
  }

Assuming that there are no differences in the PRT:

Quoted 1 line

Yep, series still passes 'make check' so there aren't any differences in DSDT nor SSDT

Quoted 3 lines

Thanks,
Marcel

#137 lore raw

Re: [Qemu-devel] [PATCH v2 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

In reply to Igor Mammedov
Quoted 51 lines · Igor Mammedov

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
 hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
 hw/i386/acpi-dsdt.dsl | 60 ---------------------------------------------------
 2 files changed, 32 insertions(+), 69 deletions(-)
hw/i386/acpi-build.c +12 -5
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
     qobject_decref(bsel);
 }
 
+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:
@@ -630,12 +641,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;

hw/i386/acpi-build.c static Aml *initialize_route(Aml *route, const char *link_name, · line 663

Quoted 8 lines
hw/i386/acpi-build.c +2 -2
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2, *else_ctx2;

Move if_ctx2/if_ctx/else_ctx2 where they are used? Also, can't we come up with better name than if_ctx2? How about if_lnk_1 and if_pin_4?

hw/i386/acpi-build.c static Aml *build_prt(void) · line 690

Quoted 11 lines
hw/i386/acpi-build.c +3 -1
     method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
     res = aml_local(0);
@@ -678,7 +685,19 @@ 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI */

Doesn't this context belong above the previous line?

hw/i386/acpi-build.c static Aml *build_prt(void) · line 696

Quoted 6 lines
hw/i386/acpi-build.c +6 -0
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), route));
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), route));
+            aml_append(if_ctx, else_ctx2);

This looks weird. Why isn't else_ctx2 added to if_ctx2?

Quoted 71 lines
hw/i386/acpi-build.c +9 -1
+            aml_append(while_ctx, if_ctx);
+        } 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));
 
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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 -36
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
         /* Hotplug notification method supplied by SSDT */
         External(\_SB.PCI0.PCNT, MethodObj)
     }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management device, needs SCI
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
-                    }
-
-                    // Complete the interrupt routing entry:

hw/i386/acpi-dsdt.dsl DefinitionBlock ( · line 126

Quoted 10 lines
hw/i386/acpi-dsdt.dsl +0 -10
-                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
-
-                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
-                    Store(And(Local1, 3),                    Index(Local4, 1))
-                    Store(Local4,                            Index(Local0, Local1))
-
-                    Increment(Local1)
-                }
-
-                Return(Local0)

Interesting. And where's this code? Probably in previous or follow-up patches ...

Quoted 18 lines
hw/i386/acpi-dsdt.dsl +0 -14
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
 }
Signature · 1 line
1.8.3.1
#138 lore raw

Re: [Qemu-devel] [PATCH v2 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 50 lines · On Sat, 19 Dec 2015 21:23:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 49 lines · Igor Mammedov

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
 hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
 hw/i386/acpi-dsdt.dsl | 60 ---------------------------------------------------
 2 files changed, 32 insertions(+), 69 deletions(-)
hw/i386/acpi-build.c +12 -5
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
     qobject_decref(bsel);
 }
 
+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:
@@ -630,12 +641,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));
 
Quoted 14 lines

hw/i386/acpi-build.c static Aml *initialize_route(Aml *route, const char *link_name, · line 663

Quoted 10 lines
hw/i386/acpi-build.c +2 -2
     return if_ctx;
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2, *else_ctx2;

Move if_ctx2/if_ctx/else_ctx2 where they are used? Also, can't we come up with better name than if_ctx2? How about if_lnk_1 and if_pin_4?

sure

Quoted 6 lines
Quoted 6 lines
hw/i386/acpi-build.c +0 -0
     method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
     res = aml_local(0);
@@ -678,7 +685,19 @@ static Aml *build_prt(void)
 
Quoted 8 lines

hw/i386/acpi-build.c static Aml *build_prt(void) · line 690

Quoted 6 lines
hw/i386/acpi-build.c +3 -1
         /* 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI */

Doesn't this context belong above the previous line?

that how it was in ASL, but yep it belongs to a whole if block so I'll move it up

Quoted 9 lines

hw/i386/acpi-build.c static Aml *build_prt(void) · line 696

Quoted 7 lines
hw/i386/acpi-build.c +6 -0
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), route));
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), route));
+            aml_append(if_ctx, else_ctx2);

This looks weird. Why isn't else_ctx2 added to if_ctx2?

it should be if_ctx2, I'll fix it.

Quoted 76 lines
Quoted 76 lines
hw/i386/acpi-build.c +9 -1
+            aml_append(while_ctx, if_ctx);
+        } 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));
 
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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 -40
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
         /* Hotplug notification method supplied by SSDT */
         External(\_SB.PCI0.PCNT, MethodObj)
     }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management device, needs SCI
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
-
-                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
-                    Store(And(Local1, 3),                    Index(Local4, 1))
Quoted 8 lines

hw/i386/acpi-dsdt.dsl DefinitionBlock ( · line 126

Quoted 6 lines
hw/i386/acpi-dsdt.dsl +0 -6
-                    Store(Local4,                            Index(Local0, Local1))
-
-                    Increment(Local1)
-                }
-
-                Return(Local0)

Interesting. And where's this code? Probably in previous or follow-up patches ...

it was and still is in original build_prt(),
I'm just modifying it to generate missing parts of DSDT AML equivalent which it's replacing.

Quoted 19 lines
Quoted 19 lines
hw/i386/acpi-dsdt.dsl +0 -14
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
 }
Signature · 1 line
1.8.3.1
#139 lore raw

Re: [Qemu-devel] [PATCH v2 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 26 lines · Igor Mammedov
Quoted 23 lines · On Sat, 19 Dec 2015 21:23:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 22 lines · Igor Mammedov

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
 hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
 hw/i386/acpi-dsdt.dsl | 60 ---------------------------------------------------
 2 files changed, 32 insertions(+), 69 deletions(-)
hw/i386/acpi-build.c +0 -0
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
     qobject_decref(bsel);
 }
 
Quoted 1 line
Quoted 1 line

hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, · line 623

Quoted 1 line
hw/i386/acpi-build.c +1 -0
+static Aml *build_prt_entry(const char *link_name)

Pls document what this does.

Quoted 67 lines
Quoted 26 lines
Quoted 26 lines
hw/i386/acpi-build.c +11 -5
+{
+    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:
@@ -630,12 +641,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));
 
Quoted 14 lines

hw/i386/acpi-build.c static Aml *initialize_route(Aml *route, const char *link_name, · line 663

Quoted 10 lines
hw/i386/acpi-build.c +2 -2
     return if_ctx;
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2, *else_ctx2;

Move if_ctx2/if_ctx/else_ctx2 where they are used? Also, can't we come up with better name than if_ctx2? How about if_lnk_1 and if_pin_4?

sure

Quoted 6 lines
Quoted 6 lines
hw/i386/acpi-build.c +0 -0
     method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
     res = aml_local(0);
@@ -678,7 +685,19 @@ static Aml *build_prt(void)
 
Quoted 8 lines

hw/i386/acpi-build.c static Aml *build_prt(void) · line 690

Quoted 6 lines
hw/i386/acpi-build.c +3 -1
         /* 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI */

Doesn't this context belong above the previous line?

that how it was in ASL, but yep it belongs to a whole if block so I'll move it up

Quoted 8 lines
Quoted 7 lines
hw/i386/acpi-build.c +6 -0
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), route));
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), route));
+            aml_append(if_ctx, else_ctx2);
Quoted 2 lines
Quoted 1 line

This looks weird. Why isn't else_ctx2 added to if_ctx2?

it should be if_ctx2, I'll fix it.

Hmm I'm not sure actually.
The API for if/else is confusing, but I'm not sure what's a better one.

Quoted 84 lines
Quoted 76 lines
Quoted 76 lines
hw/i386/acpi-build.c +9 -1
+            aml_append(while_ctx, if_ctx);
+        } 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));
 
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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 -40
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
         /* Hotplug notification method supplied by SSDT */
         External(\_SB.PCI0.PCNT, MethodObj)
     }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management device, needs SCI
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
-
-                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
-                    Store(And(Local1, 3),                    Index(Local4, 1))
Quoted 8 lines

hw/i386/acpi-dsdt.dsl DefinitionBlock ( · line 126

Quoted 6 lines
hw/i386/acpi-dsdt.dsl +0 -6
-                    Store(Local4,                            Index(Local0, Local1))
-
-                    Increment(Local1)
-                }
-
-                Return(Local0)

Interesting. And where's this code? Probably in previous or follow-up patches ...

Quoted 3 lines

it was and still is in original build_prt(),
I'm just modifying it to generate missing parts of DSDT AML equivalent which it's replacing.

OK so commit log should explain that PRT for expander buses was already generated in C, the only difference for root bus is LINKA.

And add comment explaining that for pci0,
device 1 is connected to SCI (LNKS)
(maybe rename flag to device_1_is_pm?).

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
hw/i386/acpi-dsdt.dsl +0 -14
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
 }
Signature · 1 line
1.8.3.1
#140 lore raw

Re: [Qemu-devel] [PATCH v2 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 98 lines · On Tue, 22 Dec 2015 11:34:46 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 26 lines · Igor Mammedov
Quoted 23 lines · On Sat, 19 Dec 2015 21:23:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 22 lines · Igor Mammedov

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
 hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
 hw/i386/acpi-dsdt.dsl | 60 ---------------------------------------------------
 2 files changed, 32 insertions(+), 69 deletions(-)
hw/i386/acpi-build.c +0 -0
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
     qobject_decref(bsel);
 }
 
Quoted 1 line
Quoted 1 line

hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, · line 623

Quoted 1 line
hw/i386/acpi-build.c +1 -0
+static Aml *build_prt_entry(const char *link_name)

Pls document what this does.

Quoted 67 lines
Quoted 26 lines
Quoted 26 lines
hw/i386/acpi-build.c +11 -5
+{
+    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:
@@ -630,12 +641,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));
 
Quoted 14 lines

hw/i386/acpi-build.c static Aml *initialize_route(Aml *route, const char *link_name, · line 663

Quoted 10 lines
hw/i386/acpi-build.c +2 -2
     return if_ctx;
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2, *else_ctx2;

Move if_ctx2/if_ctx/else_ctx2 where they are used? Also, can't we come up with better name than if_ctx2? How about if_lnk_1 and if_pin_4?

sure

Quoted 6 lines
Quoted 6 lines
hw/i386/acpi-build.c +0 -0
     method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
     res = aml_local(0);
@@ -678,7 +685,19 @@ static Aml *build_prt(void)
 
Quoted 8 lines

hw/i386/acpi-build.c static Aml *build_prt(void) · line 690

Quoted 6 lines
hw/i386/acpi-build.c +3 -1
         /* 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI */

Doesn't this context belong above the previous line?

that how it was in ASL, but yep it belongs to a whole if block so I'll move it up

Quoted 8 lines
Quoted 7 lines
hw/i386/acpi-build.c +6 -0
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), route));
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), route));
+            aml_append(if_ctx, else_ctx2);
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

This looks weird. Why isn't else_ctx2 added to if_ctx2?

it should be if_ctx2, I'll fix it.

Hmm I'm not sure actually.
The API for if/else is confusing, but I'm not sure what's a better one.

the weird thing is that this creates exactly the same AML as in original DSDT, anyway I'll try to make it more clear on respin

Quoted 89 lines
Quoted 85 lines
Quoted 77 lines
Quoted 77 lines
hw/i386/acpi-build.c +9 -1
+            aml_append(while_ctx, if_ctx);
+        } 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));
 
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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 -40
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
         /* Hotplug notification method supplied by SSDT */
         External(\_SB.PCI0.PCNT, MethodObj)
     }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management device, needs SCI
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
-
-                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
-                    Store(And(Local1, 3),                    Index(Local4, 1))
Quoted 8 lines

hw/i386/acpi-dsdt.dsl DefinitionBlock ( · line 126

Quoted 6 lines
hw/i386/acpi-dsdt.dsl +0 -6
-                    Store(Local4,                            Index(Local0, Local1))
-
-                    Increment(Local1)
-                }
-
-                Return(Local0)

Interesting. And where's this code? Probably in previous or follow-up patches ...

Quoted 3 lines

it was and still is in original build_prt(),
I'm just modifying it to generate missing parts of DSDT AML equivalent which it's replacing.

Quoted 7 lines

OK so commit log should explain that PRT for expander buses was already generated in C, the only difference for root bus is LINKA.

And add comment explaining that for pci0,
device 1 is connected to SCI (LNKS)
(maybe rename flag to device_1_is_pm?).

sure

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
hw/i386/acpi-dsdt.dsl +0 -14
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
 }
Signature · 1 line
1.8.3.1
#141 lore raw

Re: [Qemu-devel] [PATCH v2 58/74] pc: acpi: piix4: move PCI0._PRT() into SSDT

Quoted 104 lines · Igor Mammedov
Quoted 101 lines · On Tue, 22 Dec 2015 11:34:46 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 26 lines · Igor Mammedov
Quoted 23 lines · On Sat, 19 Dec 2015 21:23:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 22 lines · Igor Mammedov

---
v2:
- adapt build_prt() for using for PCI0._PRT(), reduces code duplication,

pc: acpi: piix4: adapt build_prt() for using for PCI0._PRT()

---
 hw/i386/acpi-build.c  | 41 +++++++++++++++++++++++++++--------
 hw/i386/acpi-dsdt.dsl | 60 ---------------------------------------------------
 2 files changed, 32 insertions(+), 69 deletions(-)
hw/i386/acpi-build.c +0 -0
index cf98037..1b065df 100644
@@ -620,6 +620,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
     qobject_decref(bsel);
 }
 
Quoted 1 line
Quoted 1 line

hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, · line 623

Quoted 1 line
hw/i386/acpi-build.c +1 -0
+static Aml *build_prt_entry(const char *link_name)

Pls document what this does.

Quoted 69 lines
Quoted 26 lines
Quoted 26 lines
hw/i386/acpi-build.c +11 -5
+{
+    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:
@@ -630,12 +641,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));
 
Quoted 14 lines

hw/i386/acpi-build.c static Aml *initialize_route(Aml *route, const char *link_name, · line 663

Quoted 10 lines
hw/i386/acpi-build.c +2 -2
     return if_ctx;
@@ -651,9 +658,9 @@ 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;
+    Aml *method, *while_ctx, *pin, *res, *if_ctx, *if_ctx2, *else_ctx2;

Move if_ctx2/if_ctx/else_ctx2 where they are used? Also, can't we come up with better name than if_ctx2? How about if_lnk_1 and if_pin_4?

sure

Quoted 6 lines
Quoted 6 lines
hw/i386/acpi-build.c +0 -0
     method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
     res = aml_local(0);
@@ -678,7 +685,19 @@ static Aml *build_prt(void)
 
Quoted 8 lines

hw/i386/acpi-build.c static Aml *build_prt(void) · line 690

Quoted 6 lines
hw/i386/acpi-build.c +3 -1
         /* 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) {
+            if_ctx = aml_if(aml_equal(lnk_idx, aml_int(1)));
+            /* device 1 is the power-management device, needs SCI */

Doesn't this context belong above the previous line?

that how it was in ASL, but yep it belongs to a whole if block so I'll move it up

Quoted 9 lines

hw/i386/acpi-build.c static Aml *build_prt(void) · line 696

Quoted 7 lines
hw/i386/acpi-build.c +6 -0
+            if_ctx2 = aml_if(aml_equal(pin, aml_int(4)));
+            aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), route));
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), route));
+            aml_append(if_ctx, else_ctx2);

This looks weird. Why isn't else_ctx2 added to if_ctx2?

it should be if_ctx2, I'll fix it.

Quoted 7 lines
Quoted 3 lines

Hmm I'm not sure actually.
The API for if/else is confusing, but I'm not sure what's a better one.

the weird thing is that this creates exactly the same AML as in original DSDT,
anyway I'll try to make it more clear
on respin

Maybe by using {} scopes and declaring variables there. Also name them more explicitly: if_device_1 if_pin_4.

Quoted 119 lines
Quoted 89 lines
Quoted 85 lines
Quoted 77 lines
Quoted 77 lines
hw/i386/acpi-build.c +9 -1
+            aml_append(while_ctx, if_ctx);
+        } 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));
 
@@ -1348,6 +1367,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));
@@ -1569,7 +1592,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 -40
index bc6bd45..5d741dd 100644
@@ -78,64 +78,4 @@ DefinitionBlock (
         /* Hotplug notification method supplied by SSDT */
         External(\_SB.PCI0.PCNT, MethodObj)
     }
-
-
-/****************************************************************
- * PCI IRQs
- ****************************************************************/
-
-    Scope(\_SB) {
-        Scope(PCI0) {
-            Method (_PRT, 0) {
-                Store(Package(128) {}, Local0)
-                Store(Zero, Local1)
-                While(LLess(Local1, 128)) {
-                    // slot = pin >> 2
-                    Store(ShiftRight(Local1, 2), Local2)
-
-                    // lnk = (slot + pin) & 3
-                    Store(And(Add(Local1, Local2), 3), Local3)
-                    If (LEqual(Local3, 0)) {
-                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 1)) {
-                        // device 1 is the power-management device, needs SCI
-                        If (LEqual(Local1, 4)) {
-                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
-                        } Else {
-                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
-                        }
-                    }
-                    If (LEqual(Local3, 2)) {
-                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
-                    }
-                    If (LEqual(Local3, 3)) {
-                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
-                    }
-
-                    // Complete the interrupt routing entry:
-                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
-
-                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
-                    Store(And(Local1, 3),                    Index(Local4, 1))
Quoted 8 lines

hw/i386/acpi-dsdt.dsl DefinitionBlock ( · line 126

Quoted 6 lines
hw/i386/acpi-dsdt.dsl +0 -6
-                    Store(Local4,                            Index(Local0, Local1))
-
-                    Increment(Local1)
-                }
-
-                Return(Local0)

Interesting. And where's this code? Probably in previous or follow-up patches ...

Quoted 3 lines

it was and still is in original build_prt(),
I'm just modifying it to generate missing parts of DSDT AML equivalent which it's replacing.

Quoted 7 lines

OK so commit log should explain that PRT for expander buses was already generated in C, the only difference for root bus is LINKA.

And add comment explaining that for pci0,
device 1 is connected to SCI (LNKS)
(maybe rename flag to device_1_is_pm?).

sure

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
hw/i386/acpi-dsdt.dsl +0 -14
-            }
-        }
-
-
-        External(PRQ0, FieldUnitObj)
-        External(PRQ1, FieldUnitObj)
-        External(PRQ2, FieldUnitObj)
-        External(PRQ3, FieldUnitObj)
-        External(LNKA, DeviceObj)
-        External(LNKB, DeviceObj)
-        External(LNKC, DeviceObj)
-        External(LNKD, DeviceObj)
-        External(LNKS, DeviceObj)
-    }
 }
Signature · 1 line
1.8.3.1
#142 lore raw

PATCH 59/74 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
index f0966b8..ba941aa 100644
@@ -1555,6 +1555,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,
@@ -1581,6 +1623,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
index 5d741dd..a7769fc 100644
@@ -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
#143 lore raw

PATCH 60/74 pc: acpi: piix4: acpi move PCI0 device to SSDT

In reply to Igor Mammedov

leave 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
index ba941aa..4b1bd0b 100644
@@ -1619,6 +1619,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
index a7769fc..82e4470 100644
@@ -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
#144 lore raw

PATCH 61/74 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
index 4b1bd0b..75a46c7 100644
@@ -1339,6 +1339,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 Aml *build_prt_entry(const char *dev)
 {
     Aml *a_zero = aml_int(0);
@@ -1508,6 +1533,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;
@@ -1636,7 +1681,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
index e157615..f2c154a 100644
@@ -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
#145 lore raw

PATCH 62/74 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
index 75a46c7..51a07eb 100644
@@ -1537,6 +1537,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
index f2c154a..2da3515 100644
@@ -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
#146 lore raw

PATCH 63/74 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
index 51a07eb..a4c2b43 100644
@@ -1375,6 +1375,36 @@ static Aml *build_prt_entry(const char *dev)
     return pkg;
 }
 
+/* _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;
@@ -1474,24 +1504,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")));
@@ -1537,6 +1550,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
index 2da3515..85b0a2c 100644
@@ -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
#147 lore raw

PATCH 64/74 pc: acpi: q35: move IQST() into SSDT

In reply to Igor Mammedov
---
 hw/i386/acpi-build.c      | 25 +++++++++++++++----------
 hw/i386/q35-acpi-dsdt.dsl |  8 --------
 2 files changed, 15 insertions(+), 18 deletions(-)
hw/i386/acpi-build.c +15 -10
index a4c2b43..2f0b9b7 100644
@@ -1405,6 +1405,19 @@ 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;
@@ -1494,16 +1507,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")));
@@ -1550,6 +1554,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
index 85b0a2c..ec8a48c 100644
@@ -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
#148 lore raw

PATCH 65/74 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
index 2f0b9b7..876605d 100644
@@ -1552,8 +1552,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));
 
@@ -1582,6 +1595,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;
@@ -1709,6 +1762,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
#149 lore raw

PATCH 66/74 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
index 876605d..744f047 100644
@@ -1553,7 +1553,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
index b01d4de..f265583 100644
@@ -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
#150 lore raw

PATCH 67/74 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
index 744f047..0008d9f 100644
@@ -1550,6 +1550,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;
@@ -1557,6 +1615,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
#151 lore raw

PATCH 68/74 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
index 0008d9f..b54fb0a 100644
@@ -1616,6 +1616,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
#152 lore raw

PATCH 69/74 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
index b54fb0a..bd8d864 100644
@@ -1615,6 +1615,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
index 34485e7..7c7aef7 100644
@@ -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
#153 lore raw

PATCH 70/74 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
index bd8d864..59041b3 100644
@@ -1815,6 +1815,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,
@@ -1853,6 +1901,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
#154 lore raw

PATCH 71/74 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
index 59041b3..b546516 100644
@@ -1902,11 +1902,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
index b53663c..f234f5c 100644
@@ -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
#155 lore raw

PATCH 72/74 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
index b546516..4808a53 100644
@@ -1902,6 +1902,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
index f234f5c..3ecdb50 100644
@@ -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
#156 lore raw

PATCH 73/74 pc: acpi: switch to AML API composed DSDT

In reply to Igor Mammedov
---
 hw/i386/acpi-build.c | 228 +++++++++++++++++++++++++--------------------------
 1 file changed, 112 insertions(+), 116 deletions(-)
hw/i386/acpi-build.c +112 -116
index 4808a53..36c5a4e 100644
@@ -52,9 +52,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"
@@ -123,24 +120,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)
 {
@@ -239,6 +218,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();
@@ -1884,91 +1874,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")));
-
-        method = aml_method("_L00", 0, AML_NOTSERIALIZED);
-        aml_append(scope, method);
-
-        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 {
-            method = aml_method("_L01", 0, AML_NOTSERIALIZED);
-            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);
-
-        for (i = 4; i <= 0xF; i++) {
-            char *name = g_strdup_printf("_L0%X", i);
-            method = aml_method(name, 0, AML_NOTSERIALIZED);
-            aml_append(scope, method);
-            g_free(name);
-        }
-    }
-    aml_append(ssdt, scope);
-
     /* Extra PCI root buses are implemented  only for i440fx */
     bus = find_i440fx();
     if (bus) {
@@ -2439,18 +2344,110 @@ 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;
+    int i;
+    Aml *dsdt, *sb_scope, *scope, *dev, *method, *field;
+    MachineState *machine = MACHINE(qdev_get_machine());
+    uint32_t nr_mem = machine->ram_slots;
 
-    assert(misc->dsdt_code && misc->dsdt_size);
+    dsdt = init_aml_allocator();
 
-    dsdt = acpi_data_push(table_data, misc->dsdt_size);
-    memcpy(dsdt, misc->dsdt_code, misc->dsdt_size);
+    /* Reserve space for header */
+    acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader));
+
+    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);
 
-    memset(dsdt, 0, sizeof *dsdt);
-    build_header(linker, table_data, dsdt, "DSDT",
-                 misc->dsdt_size, 1);
+        build_hpet_aml(dsdt);
+        build_q35_isa_bridge(dsdt);
+        build_isa_devices_aml(dsdt);
+        build_q35_pci0_int(dsdt);
+    }
+
+    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")));
+
+        method = aml_method("_L00", 0, AML_NOTSERIALIZED);
+        aml_append(scope, method);
+
+        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 {
+            method = aml_method("_L01", 0, AML_NOTSERIALIZED);
+            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);
+
+        for (i = 4; i <= 0xF; i++) {
+            char *name = g_strdup_printf("_L0%X", i);
+            method = aml_method(name, 0, AML_NOTSERIALIZED);
+            aml_append(scope, method);
+            g_free(name);
+        }
+    }
+    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);
+    free_aml_allocator();
 }
 
 static GArray *
@@ -2537,7 +2534,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);
 
@@ -2559,7 +2555,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
#157 lore raw

PATCH 74/74 pc: acpi: remove unused ASL templates and related blobs/utils

In reply to Igor Mammedov

QEMU 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               |   31 +-
 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, 1 insertion(+), 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 +1 -30
index c250deb..fd4a524 100644
@@ -8,33 +8,4 @@ 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
+obj-y += acpi-build.o
hw/i386/acpi-dsdt.dsl deleted +0 -33
deleted file mode 100644
index 82e4470..0000000
@@ -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,933 lines not on this page · raw message

hw/i386/q35-acpi-dsdt.dsl deleted +0 -40
deleted file mode 100644
index 3ecdb50..0000000

Lines of this file are not shown. View the 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

scripts/update-acpi.sh deleted +0 -4
deleted file mode 100644
index b5f05ff..0000000

Lines of this file are not shown. View the 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.

#158 lore raw
In reply to Igor Mammedov
Quoted 11 lines · Igor Mammedov

Due to huge size, CCing only cover letter instead of individual patches.

Series consist of 2 parts the 1st part prefixed 'acpi:' adds necessary AML API functions and the second part 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.

Quoted 7 lines

Diff-stat looks nice but actual code base is reduced by ~2000LOC while the rest of 10000 removals is dropping precompiled AML templates from 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 of the scope of this series.

Hi Igor,
Please consider splinting this series...

Maybe ACPI new constructs first, then memhp/cpu, piix/q35. (only a suggestion) In this you will have some "sane" 20 something patches series that can be more easily "swallowed".

Thanks,
Marcel

Quoted 131 lines
CC "Michael S. Tsirkin" <[email protected]> (supporter:ACPI/SMBIOS)
CC Shannon Zhao <[email protected]> (maintainer:ARM ACPI Subsystem)
CC Peter Maydell <[email protected]> (maintainer:ARM)
CC Paolo Bonzini <[email protected]> (maintainer:X86)
CC Richard Henderson <[email protected]> (maintainer:X86)
CC Eduardo Habkost <[email protected]> (maintainer:X86)
CC [email protected] (open list:ARM ACPI Subsystem)

Igor Mammedov (70):
tests: acpi: print ASL diff in verbose mode
acpi: add aml_lgreater_equal()
acpi: add aml_create_qword_field()
acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
acpi: extend aml_add() to accept target argument
acpi: add aml_decrement() and aml_subtract()
acpi: add aml_call0() helper
acpi: add aml_to_integer()
acpi: extend aml_shiftright() to accept target argument
acpi: add aml_alias()
acpi: add aml_sleep()
acpi: add aml_lor()
acpi: add aml_lgreater()
acpi: extend aml_field() to support LockRule
acpi: add aml_to_hexstring()
acpi: add aml_to_buffer()
acpi add aml_dma()
acpi: extend aml_or() to accept target argument
acpi: extend aml_and() to accept target argument
acpi: extend aml_interrupt() to support multiple irqs
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

Xiao Guangrong (4):
acpi: add aml_derefof
acpi: add aml_sizeof
acpi: add aml_mutex(), aml_acquire(), aml_release()
acpi: support serialized method

  hw/acpi/Makefile.objs               |    4 +-
  hw/acpi/aml-build.c                 |  294 +-
  hw/acpi/cpu_hotplug_acpi_table.c    |  124 +
  hw/acpi/memory_hotplug_acpi_table.c |  249 ++
  hw/arm/virt-acpi-build.c            |   41 +-
  hw/i386/Makefile.objs               |   31 +-
  hw/i386/acpi-build.c                | 1329 ++++--
  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         |   66 +-
  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            |    7 +
  26 files changed, 1848 insertions(+), 12573 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

#159 lore raw

On Thu, 10 Dec 2015 17:53:31 +0200
Marcel Apfelbaum <[email protected]> wrote:

[...]

Quoted 6 lines

Hi Igor,
Please consider splinting this series...

Maybe ACPI new constructs first, then memhp/cpu, piix/q35. (only a suggestion) In this you will have some "sane" 20 something patches series that can be more easily "swallowed".

I'd also prefer to do it incrementally but
I've tried something like this before, but Michael suggested to avoid optimizations/refactoring and make it so that conversion would pass 'make check' so it would be easy to prove that it hasn't regressed anything and to do it the only way is to convert whole DSDT at once.

Nevertheless, the series more or less organized with split in mind, so it's possible first commit AML API patches ('acpi:' prefixed) and then just go in order the blocks as they are in series:

memhp/cpuhp/misc devices/piix4/q35/final cleanup

Quoted 138 lines

Thanks,
Marcel

Quoted 133 lines

CC: "Michael S. Tsirkin" <[email protected]> (supporter:ACPI/SMBIOS)
CC: Shannon Zhao <[email protected]> (maintainer:ARM ACPI Subsystem) CC: Peter Maydell <[email protected]> (maintainer:ARM) CC: Paolo Bonzini <[email protected]> (maintainer:X86) CC: Richard Henderson <[email protected]> (maintainer:X86) CC: Eduardo Habkost <[email protected]> (maintainer:X86) CC: [email protected] (open list:ARM ACPI Subsystem)

Igor Mammedov (70):
tests: acpi: print ASL diff in verbose mode
acpi: add aml_lgreater_equal()
acpi: add aml_create_qword_field()
acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
acpi: extend aml_add() to accept target argument
acpi: add aml_decrement() and aml_subtract()
acpi: add aml_call0() helper
acpi: add aml_to_integer()
acpi: extend aml_shiftright() to accept target argument
acpi: add aml_alias()
acpi: add aml_sleep()
acpi: add aml_lor()
acpi: add aml_lgreater()
acpi: extend aml_field() to support LockRule
acpi: add aml_to_hexstring()
acpi: add aml_to_buffer()
acpi add aml_dma()
acpi: extend aml_or() to accept target argument
acpi: extend aml_and() to accept target argument
acpi: extend aml_interrupt() to support multiple irqs
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

Xiao Guangrong (4):
acpi: add aml_derefof
acpi: add aml_sizeof
acpi: add aml_mutex(), aml_acquire(), aml_release()
acpi: support serialized method

  hw/acpi/Makefile.objs               |    4 +-
  hw/acpi/aml-build.c                 |  294 +-
  hw/acpi/cpu_hotplug_acpi_table.c    |  124 +
  hw/acpi/memory_hotplug_acpi_table.c |  249 ++
  hw/arm/virt-acpi-build.c            |   41 +-
  hw/i386/Makefile.objs               |   31 +-
  hw/i386/acpi-build.c                | 1329 ++++--
  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         |   66 +-
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            |    7 + 26 files changed, 1848

insertions(+), 12573 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

#160 lore raw
Quoted 16 lines · Igor Mammedov

On Thu, 10 Dec 2015 17:53:31 +0200
Marcel Apfelbaum <[email protected]> wrote:

[...]

Quoted 6 lines

Hi Igor,
Please consider splinting this series...

Maybe ACPI new constructs first, then memhp/cpu, piix/q35. (only a suggestion) In this you will have some "sane" 20 something patches series that can be more easily "swallowed".

I'd also prefer to do it incrementally but
I've tried something like this before, but Michael suggested to avoid optimizations/refactoring and make it so that conversion would pass 'make check' so it would be easy to prove that it hasn't regressed anything and to do it the only way is to convert whole DSDT at once.

Quoted 5 lines

Nevertheless, the series more or less organized with split in mind, so it's possible first commit AML API patches ('acpi:' prefixed) and then just go in order the blocks as they are in series:

memhp/cpuhp/misc devices/piix4/q35/final cleanup

Indeed, the way the series is organized, it can be split-ted/committed into the mentioned blocks without breaking make check.

However, if Michael is willing to take it "as is" ... :) I'll do my best to go over it this week.
Marcel

Quoted 141 lines
Quoted 140 lines

Thanks,
Marcel

Quoted 133 lines

CC: "Michael S. Tsirkin" <[email protected]> (supporter:ACPI/SMBIOS)
CC: Shannon Zhao <[email protected]> (maintainer:ARM ACPI Subsystem) CC: Peter Maydell <[email protected]> (maintainer:ARM) CC: Paolo Bonzini <[email protected]> (maintainer:X86) CC: Richard Henderson <[email protected]> (maintainer:X86) CC: Eduardo Habkost <[email protected]> (maintainer:X86) CC: [email protected] (open list:ARM ACPI Subsystem)

Igor Mammedov (70):
tests: acpi: print ASL diff in verbose mode
acpi: add aml_lgreater_equal()
acpi: add aml_create_qword_field()
acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
acpi: extend aml_add() to accept target argument
acpi: add aml_decrement() and aml_subtract()
acpi: add aml_call0() helper
acpi: add aml_to_integer()
acpi: extend aml_shiftright() to accept target argument
acpi: add aml_alias()
acpi: add aml_sleep()
acpi: add aml_lor()
acpi: add aml_lgreater()
acpi: extend aml_field() to support LockRule
acpi: add aml_to_hexstring()
acpi: add aml_to_buffer()
acpi add aml_dma()
acpi: extend aml_or() to accept target argument
acpi: extend aml_and() to accept target argument
acpi: extend aml_interrupt() to support multiple irqs
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

Xiao Guangrong (4):
acpi: add aml_derefof
acpi: add aml_sizeof
acpi: add aml_mutex(), aml_acquire(), aml_release()
acpi: support serialized method

   hw/acpi/Makefile.objs               |    4 +-
   hw/acpi/aml-build.c                 |  294 +-
   hw/acpi/cpu_hotplug_acpi_table.c    |  124 +
   hw/acpi/memory_hotplug_acpi_table.c |  249 ++
   hw/arm/virt-acpi-build.c            |   41 +-
   hw/i386/Makefile.objs               |   31 +-
   hw/i386/acpi-build.c                | 1329 ++++--
   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         |   66 +-
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            |    7 + 26 files changed, 1848

insertions(+), 12573 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

#162 lore raw
In reply to Igor Mammedov
Quoted 19 lines · Igor Mammedov

Due to huge size, CCing only cover letter instead of individual patches.

Series consist of 2 parts the 1st part prefixed 'acpi:' adds necessary AML API functions and the second part 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 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 of the scope of this series.

Quoted 7 lines
CC "Michael S. Tsirkin" <[email protected]> (supporter:ACPI/SMBIOS)
CC Shannon Zhao <[email protected]> (maintainer:ARM ACPI Subsystem)
CC Peter Maydell <[email protected]> (maintainer:ARM)
CC Paolo Bonzini <[email protected]> (maintainer:X86)
CC Richard Henderson <[email protected]> (maintainer:X86)
CC Eduardo Habkost <[email protected]> (maintainer:X86)
CC [email protected] (open list:ARM ACPI Subsystem)

I think this is a nice series, and I think we can live with the fact make check warns in the middle.

I sent some comments I'd like to see addressed.

Main points
- one v2 patch seems garbled
- please don't create functions with tons of parameters which just do if (a) on each of these internally. instead, move common code into a small function that can be reused without so many conditionals.
- I really dislike local variables starting with a_ for no good reason.

Thanks!

Quoted 125 lines

Igor Mammedov (70):
tests: acpi: print ASL diff in verbose mode
acpi: add aml_lgreater_equal()
acpi: add aml_create_qword_field()
acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
acpi: extend aml_add() to accept target argument
acpi: add aml_decrement() and aml_subtract()
acpi: add aml_call0() helper
acpi: add aml_to_integer()
acpi: extend aml_shiftright() to accept target argument
acpi: add aml_alias()
acpi: add aml_sleep()
acpi: add aml_lor()
acpi: add aml_lgreater()
acpi: extend aml_field() to support LockRule
acpi: add aml_to_hexstring()
acpi: add aml_to_buffer()
acpi add aml_dma()
acpi: extend aml_or() to accept target argument
acpi: extend aml_and() to accept target argument
acpi: extend aml_interrupt() to support multiple irqs
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

Xiao Guangrong (4):
acpi: add aml_derefof
acpi: add aml_sizeof
acpi: add aml_mutex(), aml_acquire(), aml_release()
acpi: support serialized method

 hw/acpi/Makefile.objs               |    4 +-
 hw/acpi/aml-build.c                 |  294 +-
 hw/acpi/cpu_hotplug_acpi_table.c    |  124 +
 hw/acpi/memory_hotplug_acpi_table.c |  249 ++
 hw/arm/virt-acpi-build.c            |   41 +-
 hw/i386/Makefile.objs               |   31 +-
 hw/i386/acpi-build.c                | 1329 ++++--
 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         |   66 +-
 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            |    7 +
 26 files changed, 1848 insertions(+), 12573 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
#163 lore raw
Quoted 33 lines · On Sat, 19 Dec 2015 22:38:41 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 19 lines · Igor Mammedov

Due to huge size, CCing only cover letter instead of individual patches.

Series consist of 2 parts the 1st part prefixed 'acpi:' adds necessary AML API functions and the second part 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 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 of the scope of this series.

Quoted 7 lines
CC "Michael S. Tsirkin" <[email protected]> (supporter:ACPI/SMBIOS)
CC Shannon Zhao <[email protected]> (maintainer:ARM ACPI Subsystem)
CC Peter Maydell <[email protected]> (maintainer:ARM)
CC Paolo Bonzini <[email protected]> (maintainer:X86)
CC Richard Henderson <[email protected]> (maintainer:X86)
CC Eduardo Habkost <[email protected]> (maintainer:X86)
CC [email protected] (open list:ARM ACPI Subsystem)

I think this is a nice series, and I think we can live with the fact make check warns in the middle.

I sent some comments I'd like to see addressed.

Quoted 8 lines

Main points
- one v2 patch seems garbled
- please don't create functions with tons of parameters which just do if (a) on each of these internally. instead, move common code into a small function that can be reused without so many conditionals.
- I really dislike local variables starting with a_ for no good reason.

Michael,

Could you apply already reviewed AML API patches 1-24 and push it to master early, pls?

That will help to reduce collisions with other AML patches on list and provide more complete API for others to use.

Quoted 129 lines

Thanks!

Quoted 125 lines

Igor Mammedov (70):
tests: acpi: print ASL diff in verbose mode
acpi: add aml_lgreater_equal()
acpi: add aml_create_qword_field()
acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
acpi: extend aml_add() to accept target argument
acpi: add aml_decrement() and aml_subtract()
acpi: add aml_call0() helper
acpi: add aml_to_integer()
acpi: extend aml_shiftright() to accept target argument
acpi: add aml_alias()
acpi: add aml_sleep()
acpi: add aml_lor()
acpi: add aml_lgreater()
acpi: extend aml_field() to support LockRule
acpi: add aml_to_hexstring()
acpi: add aml_to_buffer()
acpi add aml_dma()
acpi: extend aml_or() to accept target argument
acpi: extend aml_and() to accept target argument
acpi: extend aml_interrupt() to support multiple irqs
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

Xiao Guangrong (4):
acpi: add aml_derefof
acpi: add aml_sizeof
acpi: add aml_mutex(), aml_acquire(), aml_release()
acpi: support serialized method

 hw/acpi/Makefile.objs               |    4 +-
 hw/acpi/aml-build.c                 |  294 +-
 hw/acpi/cpu_hotplug_acpi_table.c    |  124 +
 hw/acpi/memory_hotplug_acpi_table.c |  249 ++
 hw/arm/virt-acpi-build.c            |   41 +-
 hw/i386/Makefile.objs               |   31 +-
 hw/i386/acpi-build.c                | 1329 ++++--
 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         |   66 +-
 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            |    7 +
 26 files changed, 1848 insertions(+), 12573 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
#164 lore raw
Quoted 44 lines · Igor Mammedov
Quoted 33 lines · On Sat, 19 Dec 2015 22:38:41 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 33 lines · Igor Mammedov
Quoted 19 lines
Quoted 19 lines

Due to huge size, CCing only cover letter instead of individual patches.

Series consist of 2 parts the 1st part prefixed 'acpi:' adds necessary AML API functions and the second part 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 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 of the scope of this series.

Quoted 7 lines
Quoted 7 lines
CC "Michael S. Tsirkin" <[email protected]> (supporter:ACPI/SMBIOS)
CC Shannon Zhao <[email protected]> (maintainer:ARM ACPI Subsystem)
CC Peter Maydell <[email protected]> (maintainer:ARM)
CC Paolo Bonzini <[email protected]> (maintainer:X86)
CC Richard Henderson <[email protected]> (maintainer:X86)
CC Eduardo Habkost <[email protected]> (maintainer:X86)
CC [email protected] (open list:ARM ACPI Subsystem)

I think this is a nice series, and I think we can live with the fact make check warns in the middle.

I sent some comments I'd like to see addressed.

Quoted 8 lines
Quoted 8 lines

Main points
- one v2 patch seems garbled
- please don't create functions with tons of parameters which just do if (a) on each of these internally. instead, move common code into a small function that can be reused without so many conditionals.
- I really dislike local variables starting with a_ for no good reason.

Quoted 5 lines

Michael,

Could you apply already reviewed AML API patches 1-24 and push it to master early, pls?

+1

BTW, Below patches are already in master.

[PATCH 15/74] acpi: support serialized method
[PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs

Quoted 3 lines

That will help to reduce collisions with other AML patches on list and provide more complete API for others to use.

Signature · 1 line
Shannon