Patchwork [v15.1] Add pvpanic device driver

login
register
mail settings
Submitter Hu Tao
Date March 26, 2013, 8:52 a.m.
Message ID <1364287937-19684-1-git-send-email-hutao@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/231116/
State New
Headers show

Comments

Hu Tao - March 26, 2013, 8:52 a.m.
pvpanic device is used to notify host(qemu) when guest panic happens.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---

Paolo,

Can I add your Signed-off-by? Since the original code is given by you.

Thank you, Paolo :)

 src/acpi.c        |  3 +++
 src/ssdt-misc.dsl | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
Paolo Bonzini - March 26, 2013, 9:08 a.m.
Il 26/03/2013 09:52, Hu Tao ha scritto:
> pvpanic device is used to notify host(qemu) when guest panic happens.
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
> 
> Paolo,
> 
> Can I add your Signed-off-by? Since the original code is given by you.

Sure, as you prefer.

Paolo

>  src/acpi.c        |  3 +++
>  src/ssdt-misc.dsl | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
> 
> diff --git a/src/acpi.c b/src/acpi.c
> index bc4d8ea..fe504f0 100644
> --- a/src/acpi.c
> +++ b/src/acpi.c
> @@ -534,6 +534,9 @@ build_ssdt(void)
>          ssdt_ptr[acpi_pci64_valid[0]] = 0;
>      }
>  
> +    int pvpanic_port = romfile_loadint("etc/pvpanic-port", 0x0);
> +    *(u16 *)(ssdt_ptr + *ssdt_isa_pest) = pvpanic_port;
> +
>      ssdt_ptr += sizeof(ssdp_misc_aml);
>  
>      // build Scope(_SB_) header
> diff --git a/src/ssdt-misc.dsl b/src/ssdt-misc.dsl
> index 679422b..acc850e 100644
> --- a/src/ssdt-misc.dsl
> +++ b/src/ssdt-misc.dsl
> @@ -55,4 +55,50 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
>              Zero   /* reserved */
>          })
>      }
> +
> +    External(\_SB.PCI0, DeviceObj)
> +    External(\_SB.PCI0.ISA, DeviceObj)
> +
> +    Scope(\_SB.PCI0.ISA) {
> +        Device(PEVT) {
> +            Name(_HID, "QEMU0001")
> +            /* PEST will be patched to be Zero if no such device */
> +            ACPI_EXTRACT_NAME_WORD_CONST ssdt_isa_pest
> +            Name(PEST, 0xFFFF)
> +            OperationRegion(PEOR, SystemIO, PEST, 0x01)
> +            Field(PEOR, ByteAcc, NoLock, Preserve) {
> +                PEPT,   8,
> +            }
> +
> +            Method(_STA, 0, NotSerialized) {
> +                Store(PEST, Local0)
> +                If (LEqual(Local0, Zero)) {
> +                    Return (0x00)
> +                } Else {
> +                    Return (0x0F)
> +                }
> +            }
> +
> +            Method(RDPT, 0, NotSerialized) {
> +                Store(PEPT, Local0)
> +                Return (Local0)
> +            }
> +
> +            Method(WRPT, 1, NotSerialized) {
> +                Store(Arg0, PEPT)
> +            }
> +
> +            Name(_CRS, ResourceTemplate() {
> +                IO(Decode16, 0x00, 0x00, 0x01, 0x01, IO)
> +            })
> +
> +            CreateWordField(_CRS, IO._MIN, IOMN)
> +            CreateWordField(_CRS, IO._MAX, IOMX)
> +
> +            Method(_INI, 0, NotSerialized) {
> +                Store(PEST, IOMN)
> +                Store(PEST, IOMX)
> +            }
> +        }
> +    }
>  }
>

Patch

diff --git a/src/acpi.c b/src/acpi.c
index bc4d8ea..fe504f0 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -534,6 +534,9 @@  build_ssdt(void)
         ssdt_ptr[acpi_pci64_valid[0]] = 0;
     }
 
+    int pvpanic_port = romfile_loadint("etc/pvpanic-port", 0x0);
+    *(u16 *)(ssdt_ptr + *ssdt_isa_pest) = pvpanic_port;
+
     ssdt_ptr += sizeof(ssdp_misc_aml);
 
     // build Scope(_SB_) header
diff --git a/src/ssdt-misc.dsl b/src/ssdt-misc.dsl
index 679422b..acc850e 100644
--- a/src/ssdt-misc.dsl
+++ b/src/ssdt-misc.dsl
@@ -55,4 +55,50 @@  DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
             Zero   /* reserved */
         })
     }
+
+    External(\_SB.PCI0, DeviceObj)
+    External(\_SB.PCI0.ISA, DeviceObj)
+
+    Scope(\_SB.PCI0.ISA) {
+        Device(PEVT) {
+            Name(_HID, "QEMU0001")
+            /* PEST will be patched to be Zero if no such device */
+            ACPI_EXTRACT_NAME_WORD_CONST ssdt_isa_pest
+            Name(PEST, 0xFFFF)
+            OperationRegion(PEOR, SystemIO, PEST, 0x01)
+            Field(PEOR, ByteAcc, NoLock, Preserve) {
+                PEPT,   8,
+            }
+
+            Method(_STA, 0, NotSerialized) {
+                Store(PEST, Local0)
+                If (LEqual(Local0, Zero)) {
+                    Return (0x00)
+                } Else {
+                    Return (0x0F)
+                }
+            }
+
+            Method(RDPT, 0, NotSerialized) {
+                Store(PEPT, Local0)
+                Return (Local0)
+            }
+
+            Method(WRPT, 1, NotSerialized) {
+                Store(Arg0, PEPT)
+            }
+
+            Name(_CRS, ResourceTemplate() {
+                IO(Decode16, 0x00, 0x00, 0x01, 0x01, IO)
+            })
+
+            CreateWordField(_CRS, IO._MIN, IOMN)
+            CreateWordField(_CRS, IO._MAX, IOMX)
+
+            Method(_INI, 0, NotSerialized) {
+                Store(PEST, IOMN)
+                Store(PEST, IOMX)
+            }
+        }
+    }
 }