Signed-off-by: Igor Mammedov <imamm...@redhat.com>
---
hw/i386/acpi-build.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
hw/i386/acpi-dsdt.dsl | 60 -------------------------------------
2 files changed, 83 insertions(+), 60 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index cf98037..f0966b8 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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));
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index bc6bd45..5d741dd 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -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)
- }
}