Blob Blame History Raw
Add pvpanic device driver

Message-id: <1370958628-888-1-git-send-email-lersek@redhat.com>
Patchwork-id: 51850
O-Subject: [RHEL7 seabios PATCH] Add pvpanic device driver
Bugzilla: 967777
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>

From: Hu Tao <hutao@cn.fujitsu.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=967777
Brew:     https://brewweb.devel.redhat.com/taskinfo?taskID=5890930
Testing:  https://bugzilla.redhat.com/show_bug.cgi?id=967777#c3

pvpanic device is used to notify host(qemu) when guest panic happens.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
(cherry picked from commit e9725dd76d5d7212cb4a97fd18ff2599538955cf)

Conflicts:

	src/acpi.c

RHEL-7 note:

Gerd already ported this patch to 1.7.2 (which is where RHEL-7 is at
currently). See <https://bugzilla.redhat.com/show_bug.cgi?id=831210#c17>
and <https://bugzilla.redhat.com/show_bug.cgi?id=831210#c18> for details.

I cherry picked his port from <git://git.kraxel.org/seabios>, commit
5d01ca924a5c8fcd898ddc5813d88b3c32043882. Unfortunately this seems to
introduce a compile error. I fixed that up.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 src/acpi.c        |    4 ++++
 src/ssdt-susp.dsl |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c
index 6267d7b..9b09118 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -535,6 +535,10 @@ build_ssdt(void)
         ssdt_ptr[acpi_s4_name[0]] = 'X';
     else
         ssdt_ptr[acpi_s4_pkg[0] + 1] = ssdt[acpi_s4_pkg[0] + 3] = sys_states[4] & 127;
+
+    int pvpanic_port = romfile_loadint("etc/pvpanic-port", 0x0);
+    *(u16 *)(ssdt_ptr + *ssdt_isa_pest) = pvpanic_port;
+
     ssdt_ptr += sizeof(ssdp_susp_aml);
 
     // build Scope(_SB_) header
diff --git a/src/ssdt-susp.dsl b/src/ssdt-susp.dsl
index ca9428f..b8e9cf4 100644
--- a/src/ssdt-susp.dsl
+++ b/src/ssdt-susp.dsl
@@ -35,4 +35,50 @@ DefinitionBlock ("ssdt-susp.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)
+            }
+        }
+    }
 }