Turn off QEMU ACPI-way since new releases don't have shutdown port

anymore.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-12 14:49:33 +02:00
parent a21eec9ec5
commit 5121223465
6 changed files with 51 additions and 27 deletions

View 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

View 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

View file

@ -85,6 +85,6 @@ ioperm_arg1:
.long 8
.long 1
ioperm_arg2:
.long 0x1000
.long 0x7000
.long 8
.long 1

View 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