2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
/*
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
|
|
|
* Copyright (C) 2008 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <grub/cpu/io.h>
|
|
|
|
#include <grub/misc.h>
|
2010-09-13 18:29:15 +00:00
|
|
|
#include <grub/acpi.h>
|
2011-11-11 20:44:56 +00:00
|
|
|
#include <grub/i18n.h>
|
2013-04-12 12:49:33 +00:00
|
|
|
#include <grub/pci.h>
|
|
|
|
#include <grub/mm.h>
|
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
|
|
|
|
const char bochs_shutdown[] = "Shutdown";
|
|
|
|
|
2010-05-04 15:15:36 +00:00
|
|
|
/*
|
|
|
|
* This call is special... it never returns... in fact it should simply
|
|
|
|
* hang at this point!
|
|
|
|
*/
|
|
|
|
static inline void __attribute__ ((noreturn))
|
|
|
|
stop (void)
|
|
|
|
{
|
|
|
|
asm volatile ("cli");
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
asm volatile ("hlt");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-12 12:49:33 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
void
|
|
|
|
grub_halt (void)
|
|
|
|
{
|
2009-06-11 19:11:25 +00:00
|
|
|
unsigned int i;
|
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
|
2010-09-13 18:29:15 +00:00
|
|
|
#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT)
|
|
|
|
grub_acpi_halt ();
|
|
|
|
#endif
|
|
|
|
|
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
/* Disable interrupts. */
|
|
|
|
__asm__ __volatile__ ("cli");
|
|
|
|
|
2013-04-12 12:49:33 +00:00
|
|
|
/* Bochs, QEMU, etc. Removed in newer QEMU releases. */
|
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
for (i = 0; i < sizeof (bochs_shutdown) - 1; i++)
|
|
|
|
grub_outb (bochs_shutdown[i], 0x8900);
|
|
|
|
|
2013-04-12 12:49:33 +00:00
|
|
|
grub_pci_iterate (grub_shutdown_pci_iter, NULL);
|
|
|
|
|
2011-11-11 20:44:56 +00:00
|
|
|
grub_puts_ (N_("GRUB doesn't know how to halt this machine yet!"));
|
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
|
|
|
|
/* In order to return we'd have to check what the previous status of IF
|
|
|
|
flag was. But user most likely doesn't want to return anyway ... */
|
2010-05-04 15:15:36 +00:00
|
|
|
stop ();
|
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
`halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS)
(halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file.
* kern/i386/reboot.c: Likewise.
* include/grub/i386/reboot.h: Likewise.
* include/grub/i386/halt.h: Likewise.
* commands/halt.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]:
Include `<grub/cpu/halt.h>'.
* commands/reboot.c [! GRUB_MACHINE_IEEE1275 ! GRUB_MACHINE_EFI]
[! GRUB_MACHINE_PCBIOS]: Include `<grub/cpu/reboot.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/cpu/at_keyboard.h>'.
(SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK, KEYBOARD_REG_DATA)
(KEYBOARD_REG_STATUS, KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ)
(KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT)
(KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY)
(KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move
from here ...
* include/grub/i386/at_keyboard.h: ... to here.
2008-08-06 00:20:04 +00:00
|
|
|
}
|