dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0287-Turn-off-QEMU-ACPI-way-since-new-releases-don-t-have.patch

f96e0b
From 0cd3f74d3dd9f2be5d819a802d0579e5ff2256ab Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Fri, 12 Apr 2013 14:49:33 +0200
f96e0b
Subject: [PATCH 287/482] 	Turn off QEMU ACPI-way since new releases
f96e0b
 don't have shutdown port 	anymore.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                                   |  5 +++++
f96e0b
 Makefile.am                                 | 35 ++++++++++++++---------------
f96e0b
 grub-core/lib/i386/halt.c                   | 23 ++++++++++++++++++-
f96e0b
 grub-core/tests/boot/kfreebsd.init-i386.S   |  6 ++---
f96e0b
 grub-core/tests/boot/kfreebsd.init-x86_64.S |  2 +-
f96e0b
 grub-core/tests/boot/qemu-shutdown-x86.S    |  7 +++---
f96e0b
 6 files changed, 51 insertions(+), 27 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 5212955..1c77abf 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,10 @@
f96e0b
 2013-04-12  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
+	Turn off QEMU ACPI-way since new releases don't have shutdown port
f96e0b
+	anymore.
f96e0b
+
f96e0b
+2013-04-12  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
 	* docs/grub.texi: Update coreboot status info.
f96e0b
 
f96e0b
 2013-04-12  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
diff --git a/Makefile.am b/Makefile.am
f96e0b
index 30aa5a7..9d38405 100644
f96e0b
--- a/Makefile.am
f96e0b
+++ b/Makefile.am
f96e0b
@@ -153,10 +153,10 @@ if COND_x86_64_efi
f96e0b
 QEMU32=qemu-system-x86_64
f96e0b
 endif
f96e0b
 
f96e0b
-linux.init.x86_64: $(srcdir)/grub-core/tests/boot/linux.init-x86_64.S
f96e0b
+linux.init.x86_64: $(srcdir)/grub-core/tests/boot/linux.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
f96e0b
 
f96e0b
-linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S
f96e0b
+linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
f96e0b
 
f96e0b
 linux.init.mips: $(srcdir)/grub-core/tests/boot/linux.init-mips.S
f96e0b
@@ -171,46 +171,46 @@ linux.init.mipsel: $(srcdir)/grub-core/tests/boot/linux.init-mips.S
f96e0b
 linux.init.loongson: $(srcdir)/grub-core/tests/boot/linux.init-mips.S
f96e0b
 	$(TARGET_CC) -o $@ $< -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -DREBOOT=1
f96e0b
 
f96e0b
-multiboot.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
f96e0b
+multiboot.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -DTARGET_MULTIBOOT=1 -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include
f96e0b
 
f96e0b
-kfreebsd.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
f96e0b
+kfreebsd.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include
f96e0b
 
f96e0b
 kfreebsd.aout: kfreebsd.elf
f96e0b
 	$(OBJCOPY) -O a.out-i386-linux $< $@ -R .note.gnu.build-id -R .note.gnu.gold-version
f96e0b
 
f96e0b
-pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S
f96e0b
+pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x7c00 -m32
f96e0b
 
f96e0b
 pc-chainloader.bin: pc-chainloader.elf
f96e0b
 	$(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@;
f96e0b
 
f96e0b
-ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S
f96e0b
+ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0 -m32
f96e0b
 
f96e0b
 ntldr.bin: ntldr.elf
f96e0b
 	$(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@;
f96e0b
 
f96e0b
-multiboot2.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
f96e0b
+multiboot2.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include -DTARGET_MULTIBOOT2=1
f96e0b
 
f96e0b
-kfreebsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kfreebsd.init-x86_64.S
f96e0b
+kfreebsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kfreebsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
f96e0b
 
f96e0b
-kfreebsd.init.i386: $(srcdir)/grub-core/tests/boot/kfreebsd.init-i386.S
f96e0b
+kfreebsd.init.i386: $(srcdir)/grub-core/tests/boot/kfreebsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
f96e0b
 
f96e0b
-knetbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S
f96e0b
+knetbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_NETBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
f96e0b
 
f96e0b
-kopenbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S
f96e0b
+kopenbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_OPENBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
f96e0b
 
f96e0b
-knetbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S
f96e0b
+knetbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m64 -DTARGET_NETBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
f96e0b
 
f96e0b
-kopenbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S
f96e0b
+kopenbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
 	$(TARGET_CC) -o $@ $< -m64 -DTARGET_OPENBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
f96e0b
 
f96e0b
 linux-initramfs.mips: linux.init.mips Makefile
f96e0b
@@ -335,18 +335,17 @@ BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-
f96e0b
 endif
f96e0b
 
f96e0b
 if COND_i386_multiboot
f96e0b
-# Freebsd crashes because memory at 0-0x1000 is occupied and requires ACPI
f96e0b
+# FreeBSD requires ACPI
f96e0b
 BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
f96e0b
 endif
f96e0b
 
f96e0b
 if COND_i386_coreboot
f96e0b
-# 64-bit NetBSD crashes because memory at 0-0x1000 is occupied
f96e0b
-# Freebsd crashes because memory at 0-0x1000 is occupied and requires ACPI
f96e0b
-BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64
f96e0b
+# Freebsd requires ACPI
f96e0b
+BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
f96e0b
 endif
f96e0b
 
f96e0b
 if COND_i386_qemu
f96e0b
-# Freebsd crashes because memory at 0-0x1000 is occupied and requires ACPI
f96e0b
+# FreeBSD requires ACPI
f96e0b
 BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
f96e0b
 endif
f96e0b
 
f96e0b
diff --git a/grub-core/lib/i386/halt.c b/grub-core/lib/i386/halt.c
f96e0b
index bd878c9..9f84054 100644
f96e0b
--- a/grub-core/lib/i386/halt.c
f96e0b
+++ b/grub-core/lib/i386/halt.c
f96e0b
@@ -20,6 +20,8 @@
f96e0b
 #include <grub/misc.h>
f96e0b
 #include <grub/acpi.h>
f96e0b
 #include <grub/i18n.h>
f96e0b
+#include <grub/pci.h>
f96e0b
+#include <grub/mm.h>
f96e0b
 
f96e0b
 const char bochs_shutdown[] = "Shutdown";
f96e0b
 
f96e0b
@@ -37,6 +39,23 @@ stop (void)
f96e0b
     }
f96e0b
 }
f96e0b
 
f96e0b
+static int
f96e0b
+grub_shutdown_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
f96e0b
+			void *data __attribute__ ((unused)))
f96e0b
+{
f96e0b
+  /* QEMU.  */
f96e0b
+  if (pciid == 0x71138086)
f96e0b
+    {
f96e0b
+      grub_pci_address_t addr;
f96e0b
+      addr = grub_pci_make_address (dev, 0x40);
f96e0b
+      grub_pci_write (addr, 0x7001);
f96e0b
+      addr = grub_pci_make_address (dev, 0x80);
f96e0b
+      grub_pci_write (addr, grub_pci_read (addr) | 1);
f96e0b
+      grub_outw (0x2000, 0x7004);
f96e0b
+    }
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
 void
f96e0b
 grub_halt (void)
f96e0b
 {
f96e0b
@@ -49,10 +68,12 @@ grub_halt (void)
f96e0b
   /* Disable interrupts.  */
f96e0b
   __asm__ __volatile__ ("cli");
f96e0b
 
f96e0b
-  /* Bochs, QEMU, etc.  */
f96e0b
+  /* Bochs, QEMU, etc. Removed in newer QEMU releases.  */
f96e0b
   for (i = 0; i < sizeof (bochs_shutdown) - 1; i++)
f96e0b
     grub_outb (bochs_shutdown[i], 0x8900);
f96e0b
 
f96e0b
+  grub_pci_iterate (grub_shutdown_pci_iter, NULL);
f96e0b
+
f96e0b
   grub_puts_ (N_("GRUB doesn't know how to halt this machine yet!"));
f96e0b
 
f96e0b
   /* In order to return we'd have to check what the previous status of IF
f96e0b
diff --git a/grub-core/tests/boot/kfreebsd.init-i386.S b/grub-core/tests/boot/kfreebsd.init-i386.S
f96e0b
index a448152..7a4baba 100644
f96e0b
--- a/grub-core/tests/boot/kfreebsd.init-i386.S
f96e0b
+++ b/grub-core/tests/boot/kfreebsd.init-i386.S
f96e0b
@@ -65,7 +65,7 @@ _start:
f96e0b
 
f96e0b
 	/* IOPERM.  */
f96e0b
 	movl $SYSCALL_ARCH, %eax
f96e0b
-	pushl $iopl_arg1
f96e0b
+	pushl $ioperm_arg1
f96e0b
 	pushl $SYSCALL_ARCH_IOPERM
f96e0b
 	pushl $0
f96e0b
 	int $SYSCALL_INT
f96e0b
@@ -73,7 +73,7 @@ _start:
f96e0b
 
f96e0b
 	/* IOPERM.  */
f96e0b
 	movl $SYSCALL_ARCH, %eax
f96e0b
-	pushl $iopl_arg2
f96e0b
+	pushl $ioperm_arg2
f96e0b
 	pushl $SYSCALL_ARCH_IOPERM
f96e0b
 	pushl $0
f96e0b
 	int $SYSCALL_INT
f96e0b
@@ -104,6 +104,6 @@ ioperm_arg1:
f96e0b
 	.long 8
f96e0b
 	.long 1
f96e0b
 ioperm_arg2:
f96e0b
-	.long 0x1000
f96e0b
+	.long 0x7000
f96e0b
 	.long 8
f96e0b
 	.long 1
f96e0b
diff --git a/grub-core/tests/boot/kfreebsd.init-x86_64.S b/grub-core/tests/boot/kfreebsd.init-x86_64.S
f96e0b
index de7bab6..05e5760 100644
f96e0b
--- a/grub-core/tests/boot/kfreebsd.init-x86_64.S
f96e0b
+++ b/grub-core/tests/boot/kfreebsd.init-x86_64.S
f96e0b
@@ -85,6 +85,6 @@ ioperm_arg1:
f96e0b
 	.long 8
f96e0b
 	.long 1
f96e0b
 ioperm_arg2:
f96e0b
-	.long 0x1000
f96e0b
+	.long 0x7000
f96e0b
 	.long 8
f96e0b
 	.long 1
f96e0b
diff --git a/grub-core/tests/boot/qemu-shutdown-x86.S b/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
index 9f8bc40..e37f5df 100644
f96e0b
--- a/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
+++ b/grub-core/tests/boot/qemu-shutdown-x86.S
f96e0b
@@ -1,18 +1,17 @@
f96e0b
 	movl $0x80000b80, %eax
f96e0b
 	movw $0xcf8, %dx
f96e0b
 	outl  %eax, %dx
f96e0b
-	movl $0x1001, %eax
f96e0b
 	movw $0xcfc, %dx
f96e0b
-	inb  %al, %dx
f96e0b
+	inb  %dx, %al
f96e0b
 	orb  $1, %al
f96e0b
 	outb  %al, %dx
f96e0b
 
f96e0b
 	movl $0x80000b40, %eax
f96e0b
 	movw $0xcf8, %dx
f96e0b
 	outl  %eax, %dx
f96e0b
-	movl $0x1001, %eax
f96e0b
+	movl $0x7001, %eax
f96e0b
 	movw $0xcfc, %dx
f96e0b
 	outl  %eax, %dx
f96e0b
 	movw $0x2000, %ax
f96e0b
-	movw $0x1004, %dx	
f96e0b
+	movw $0x7004, %dx	
f96e0b
 	outw  %ax, %dx
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b