]> git.proxmox.com Git - grub2.git/commitdiff
Turn off QEMU ACPI-way since new releases don't have shutdown port
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 12 Apr 2013 12:49:33 +0000 (14:49 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 12 Apr 2013 12:49:33 +0000 (14:49 +0200)
anymore.

ChangeLog
Makefile.am
grub-core/lib/i386/halt.c
grub-core/tests/boot/kfreebsd.init-i386.S
grub-core/tests/boot/kfreebsd.init-x86_64.S
grub-core/tests/boot/qemu-shutdown-x86.S

index 5212955995016938d3e759ebf7e1ac3f624d3bae..1c77abf0e200cf43d1ae51e9a3ed0592b2baac70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-12  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Turn off QEMU ACPI-way since new releases don't have shutdown port
+       anymore.
+
 2013-04-12  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * docs/grub.texi: Update coreboot status info.
index 30aa5a7702c56bf79b9cfc272e8e472018d7e7db..9d38405af77e1255de6d0e802af156ed08e931f0 100644 (file)
@@ -153,10 +153,10 @@ if COND_x86_64_efi
 QEMU32=qemu-system-x86_64
 endif
 
-linux.init.x86_64: $(srcdir)/grub-core/tests/boot/linux.init-x86_64.S
+linux.init.x86_64: $(srcdir)/grub-core/tests/boot/linux.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
 
-linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S
+linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
 
 linux.init.mips: $(srcdir)/grub-core/tests/boot/linux.init-mips.S
@@ -171,46 +171,46 @@ linux.init.mipsel: $(srcdir)/grub-core/tests/boot/linux.init-mips.S
 linux.init.loongson: $(srcdir)/grub-core/tests/boot/linux.init-mips.S
        $(TARGET_CC) -o $@ $< -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -DREBOOT=1
 
-multiboot.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
+multiboot.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(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
 
-kfreebsd.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
+kfreebsd.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(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
 
 kfreebsd.aout: kfreebsd.elf
        $(OBJCOPY) -O a.out-i386-linux $< $@ -R .note.gnu.build-id -R .note.gnu.gold-version
 
-pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S
+pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(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
 
 pc-chainloader.bin: pc-chainloader.elf
        $(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@;
 
-ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S
+ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(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
 
 ntldr.bin: ntldr.elf
        $(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@;
 
-multiboot2.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
+multiboot2.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(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
 
-kfreebsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kfreebsd.init-x86_64.S
+kfreebsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kfreebsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
 
-kfreebsd.init.i386: $(srcdir)/grub-core/tests/boot/kfreebsd.init-i386.S
+kfreebsd.init.i386: $(srcdir)/grub-core/tests/boot/kfreebsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
 
-knetbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S
+knetbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_NETBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
 
-kopenbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S
+kopenbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_OPENBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
 
-knetbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S
+knetbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m64 -DTARGET_NETBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
 
-kopenbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S
+kopenbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
        $(TARGET_CC) -o $@ $< -m64 -DTARGET_OPENBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
 
 linux-initramfs.mips: linux.init.mips Makefile
@@ -335,18 +335,17 @@ BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-
 endif
 
 if COND_i386_multiboot
-# Freebsd crashes because memory at 0-0x1000 is occupied and requires ACPI
+# FreeBSD requires ACPI
 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
 endif
 
 if COND_i386_coreboot
-# 64-bit NetBSD crashes because memory at 0-0x1000 is occupied
-# Freebsd crashes because memory at 0-0x1000 is occupied and requires ACPI
-BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64
+# Freebsd requires ACPI
+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
 endif
 
 if COND_i386_qemu
-# Freebsd crashes because memory at 0-0x1000 is occupied and requires ACPI
+# FreeBSD requires ACPI
 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
 endif
 
index bd878c9bf09ee4a35498264647866ce7a3ba1c2f..9f840549407bcbd7cef6082b3f444d88d8fee58c 100644 (file)
@@ -20,6 +20,8 @@
 #include <grub/misc.h>
 #include <grub/acpi.h>
 #include <grub/i18n.h>
+#include <grub/pci.h>
+#include <grub/mm.h>
 
 const char bochs_shutdown[] = "Shutdown";
 
@@ -37,6 +39,23 @@ stop (void)
     }
 }
 
+static int
+grub_shutdown_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
+                       void *data __attribute__ ((unused)))
+{
+  /* QEMU.  */
+  if (pciid == 0x71138086)
+    {
+      grub_pci_address_t addr;
+      addr = grub_pci_make_address (dev, 0x40);
+      grub_pci_write (addr, 0x7001);
+      addr = grub_pci_make_address (dev, 0x80);
+      grub_pci_write (addr, grub_pci_read (addr) | 1);
+      grub_outw (0x2000, 0x7004);
+    }
+  return 0;
+}
+
 void
 grub_halt (void)
 {
@@ -49,10 +68,12 @@ grub_halt (void)
   /* Disable interrupts.  */
   __asm__ __volatile__ ("cli");
 
-  /* Bochs, QEMU, etc.  */
+  /* Bochs, QEMU, etc. Removed in newer QEMU releases.  */
   for (i = 0; i < sizeof (bochs_shutdown) - 1; i++)
     grub_outb (bochs_shutdown[i], 0x8900);
 
+  grub_pci_iterate (grub_shutdown_pci_iter, NULL);
+
   grub_puts_ (N_("GRUB doesn't know how to halt this machine yet!"));
 
   /* In order to return we'd have to check what the previous status of IF
index a4481520a2814fcebcacd90698642aef7f68680e..7a4babaf997f99057669b558629dda7f158aa879 100644 (file)
@@ -65,7 +65,7 @@ _start:
 
        /* IOPERM.  */
        movl $SYSCALL_ARCH, %eax
-       pushl $iopl_arg1
+       pushl $ioperm_arg1
        pushl $SYSCALL_ARCH_IOPERM
        pushl $0
        int $SYSCALL_INT
@@ -73,7 +73,7 @@ _start:
 
        /* IOPERM.  */
        movl $SYSCALL_ARCH, %eax
-       pushl $iopl_arg2
+       pushl $ioperm_arg2
        pushl $SYSCALL_ARCH_IOPERM
        pushl $0
        int $SYSCALL_INT
@@ -104,6 +104,6 @@ ioperm_arg1:
        .long 8
        .long 1
 ioperm_arg2:
-       .long 0x1000
+       .long 0x7000
        .long 8
        .long 1
index de7bab6cea62641580e8209b7bfcf7a3d014c0ea..05e5760e0a372b6bf6a4277847b7679c0b13d0a9 100644 (file)
@@ -85,6 +85,6 @@ ioperm_arg1:
        .long 8
        .long 1
 ioperm_arg2:
-       .long 0x1000
+       .long 0x7000
        .long 8
        .long 1
index 9f8bc40515c548e8d85f1e142eaf6e3ba0e96b04..e37f5df79d30a249b573183a74307a13a24c8091 100644 (file)
@@ -1,18 +1,17 @@
        movl $0x80000b80, %eax
        movw $0xcf8, %dx
        outl  %eax, %dx
-       movl $0x1001, %eax
        movw $0xcfc, %dx
-       inb  %al, %dx
+       inb  %dx, %al
        orb  $1, %al
        outb  %al, %dx
 
        movl $0x80000b40, %eax
        movw $0xcf8, %dx
        outl  %eax, %dx
-       movl $0x1001, %eax
+       movl $0x7001, %eax
        movw $0xcfc, %dx
        outl  %eax, %dx
        movw $0x2000, %ax
-       movw $0x1004, %dx       
+       movw $0x7004, %dx       
        outw  %ax, %dx