diff mbox

[RFC,v2,05/12] acpi: build static _PRT

Message ID 1472120105-29235-6-git-send-email-chao.p.peng@linux.intel.com
State New
Headers show

Commit Message

Chao Peng Aug. 25, 2016, 10:14 a.m. UTC
...to reduce the interpretation burden for guest ACPI component.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
---
 hw/i386/acpi-build.c | 31 ++++++++++++++++++++++++++++++-
 hw/i386/pc.c         |  1 +
 include/hw/i386/pc.h |  2 ++
 3 files changed, 33 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini Aug. 29, 2016, 5:06 p.m. UTC | #1
On 25/08/2016 12:14, Chao Peng wrote:
> ...to reduce the interpretation burden for guest ACPI component.
> 
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---
>  hw/i386/acpi-build.c | 31 ++++++++++++++++++++++++++++++-
>  hw/i386/pc.c         |  1 +
>  include/hw/i386/pc.h |  2 ++
>  3 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index a26a4bb..60c0896 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1772,6 +1772,31 @@ static void build_q35_pci0_int(Aml *table)
>      aml_append(table, sb_scope);
>  }
>  
> +static void build_static_q35_pci0_int(Aml *table)
> +{
> +    int i, j;
> +    Aml *method, *res, *pkg;
> +    Aml *sb_scope = aml_scope("_SB");
> +    Aml *pci0_scope = aml_scope("PCI0");
> +
> +    method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
> +    res = aml_package(128);
> +    for (i = 0; i < 32; i++) {
> +        for (j = 0; j < 4; j++) {
> +            pkg = aml_package(4);
> +            aml_append(pkg, aml_int((i << 16) | 0xffff));
> +            aml_append(pkg, aml_int(j));
> +            aml_append(pkg, aml_int(0));
> +            aml_append(pkg, aml_int(0x10 + j));
> +            aml_append(res, pkg);
> +        }
> +    }
> +
> +    aml_append(method, aml_return(res));
> +    aml_append(pci0_scope, method);
> +    aml_append(sb_scope, pci0_scope);
> +}
> +
>  static void build_q35_isa_bridge(Aml *table)
>  {
>      Aml *dev;
> @@ -2007,7 +2032,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>          build_hpet_aml(dsdt);
>          build_q35_isa_bridge(dsdt);
>          build_isa_devices_aml(dsdt);
> -        build_q35_pci0_int(dsdt);
> +        if (pcms->static_prt) {
> +            build_static_q35_pci0_int(dsdt);
> +        } else {
> +            build_q35_pci0_int(dsdt);
> +        }
>      }
>  
>      if (pcmc->legacy_cpu_hotplug) {
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 1d62957..f479697 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -2196,6 +2196,7 @@ static void pc_machine_initfn(Object *obj)
>      PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_SATA, sata, true);
>      PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_PIC, pic, true);
>      PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_PIT, pit, true);
> +    PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_STATIC_PRT, static_prt, false);
>  }
>  
>  static void pc_machine_reset(void)
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 1dc7954..55ab09a 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -81,6 +81,7 @@ struct PCMachineState {
>      bool sata;
>      bool pic;
>      bool pit;
> +    bool static_prt;
>  };
>  
>  #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
> @@ -93,6 +94,7 @@ struct PCMachineState {
>  #define PC_MACHINE_SATA             "sata"
>  #define PC_MACHINE_PIC              "pic"
>  #define PC_MACHINE_PIT              "pit"
> +#define PC_MACHINE_STATIC_PRT       "static-prt"
>  
>  /**
>   * PCMachineClass:
> 

You can do this unconditionally, but it should match the contents of the
q35 PRT.

Paolo
diff mbox

Patch

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a26a4bb..60c0896 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1772,6 +1772,31 @@  static void build_q35_pci0_int(Aml *table)
     aml_append(table, sb_scope);
 }
 
+static void build_static_q35_pci0_int(Aml *table)
+{
+    int i, j;
+    Aml *method, *res, *pkg;
+    Aml *sb_scope = aml_scope("_SB");
+    Aml *pci0_scope = aml_scope("PCI0");
+
+    method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
+    res = aml_package(128);
+    for (i = 0; i < 32; i++) {
+        for (j = 0; j < 4; j++) {
+            pkg = aml_package(4);
+            aml_append(pkg, aml_int((i << 16) | 0xffff));
+            aml_append(pkg, aml_int(j));
+            aml_append(pkg, aml_int(0));
+            aml_append(pkg, aml_int(0x10 + j));
+            aml_append(res, pkg);
+        }
+    }
+
+    aml_append(method, aml_return(res));
+    aml_append(pci0_scope, method);
+    aml_append(sb_scope, pci0_scope);
+}
+
 static void build_q35_isa_bridge(Aml *table)
 {
     Aml *dev;
@@ -2007,7 +2032,11 @@  build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_hpet_aml(dsdt);
         build_q35_isa_bridge(dsdt);
         build_isa_devices_aml(dsdt);
-        build_q35_pci0_int(dsdt);
+        if (pcms->static_prt) {
+            build_static_q35_pci0_int(dsdt);
+        } else {
+            build_q35_pci0_int(dsdt);
+        }
     }
 
     if (pcmc->legacy_cpu_hotplug) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 1d62957..f479697 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -2196,6 +2196,7 @@  static void pc_machine_initfn(Object *obj)
     PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_SATA, sata, true);
     PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_PIC, pic, true);
     PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_PIT, pit, true);
+    PC_MACHINE_DEFINE_PROP_BOOL(pcms, PC_MACHINE_STATIC_PRT, static_prt, false);
 }
 
 static void pc_machine_reset(void)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1dc7954..55ab09a 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -81,6 +81,7 @@  struct PCMachineState {
     bool sata;
     bool pic;
     bool pit;
+    bool static_prt;
 };
 
 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
@@ -93,6 +94,7 @@  struct PCMachineState {
 #define PC_MACHINE_SATA             "sata"
 #define PC_MACHINE_PIC              "pic"
 #define PC_MACHINE_PIT              "pit"
+#define PC_MACHINE_STATIC_PRT       "static-prt"
 
 /**
  * PCMachineClass: