merge with mainline

This commit is contained in:
BVK Chaitanya 2010-09-04 09:05:21 +05:30
commit e5a73c4247
182 changed files with 9977 additions and 5276 deletions

View file

@ -21,6 +21,7 @@
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/machine/int.h>
static const struct grub_arg_option options[] =
{
@ -28,6 +29,69 @@ static const struct grub_arg_option options[] =
{0, 0, 0, 0, 0, 0}
};
static inline void __attribute__ ((noreturn))
stop (void)
{
while (1)
{
asm volatile ("hlt");
}
}
/*
* Halt the system, using APM if possible. If NO_APM is true, don't use
* APM even if it is available.
*/
void
grub_halt (int no_apm)
{
struct grub_bios_int_registers regs;
if (no_apm)
stop ();
/* detect APM */
regs.eax = 0x5300;
regs.ebx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
stop ();
/* disconnect APM first */
regs.eax = 0x5304;
regs.ebx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
/* connect APM */
regs.eax = 0x5301;
regs.ebx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
stop ();
/* set APM protocol level - 1.1 or bust. (this covers APM 1.2 also) */
regs.eax = 0x530E;
regs.ebx = 0;
regs.ecx = 0x0101;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
stop ();
/* set the power state to off */
regs.eax = 0x5307;
regs.ebx = 1;
regs.ecx = 3;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
/* shouldn't reach here */
stop ();
}
static grub_err_t
grub_cmd_halt (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),