From 4a1875b61089e467165be46a7e538e8beb47d8ac Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 12 Apr 2013 14:49:33 +0200 Subject: [PATCH 286/364] Turn off QEMU ACPI-way since new releases don't have shutdown port anymore. --- ChangeLog | 5 +++++ Makefile.am | 35 ++++++++++++++--------------- grub-core/lib/i386/halt.c | 23 ++++++++++++++++++- grub-core/tests/boot/kfreebsd.init-i386.S | 6 ++--- grub-core/tests/boot/kfreebsd.init-x86_64.S | 2 +- grub-core/tests/boot/qemu-shutdown-x86.S | 7 +++--- 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5212955..1c77abf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2013-04-12 Vladimir Serbinenko + Turn off QEMU ACPI-way since new releases don't have shutdown port + anymore. + +2013-04-12 Vladimir Serbinenko + * docs/grub.texi: Update coreboot status info. 2013-04-12 Vladimir Serbinenko diff --git a/Makefile.am b/Makefile.am index 30aa5a7..9d38405 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/grub-core/lib/i386/halt.c b/grub-core/lib/i386/halt.c index bd878c9..9f84054 100644 --- a/grub-core/lib/i386/halt.c +++ b/grub-core/lib/i386/halt.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include 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 diff --git a/grub-core/tests/boot/kfreebsd.init-i386.S b/grub-core/tests/boot/kfreebsd.init-i386.S index a448152..7a4baba 100644 --- a/grub-core/tests/boot/kfreebsd.init-i386.S +++ b/grub-core/tests/boot/kfreebsd.init-i386.S @@ -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 diff --git a/grub-core/tests/boot/kfreebsd.init-x86_64.S b/grub-core/tests/boot/kfreebsd.init-x86_64.S index de7bab6..05e5760 100644 --- a/grub-core/tests/boot/kfreebsd.init-x86_64.S +++ b/grub-core/tests/boot/kfreebsd.init-x86_64.S @@ -85,6 +85,6 @@ ioperm_arg1: .long 8 .long 1 ioperm_arg2: - .long 0x1000 + .long 0x7000 .long 8 .long 1 diff --git a/grub-core/tests/boot/qemu-shutdown-x86.S b/grub-core/tests/boot/qemu-shutdown-x86.S index 9f8bc40..e37f5df 100644 --- a/grub-core/tests/boot/qemu-shutdown-x86.S +++ b/grub-core/tests/boot/qemu-shutdown-x86.S @@ -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 -- 1.8.1.4