2010-09-15 09:42:18 +00:00
|
|
|
/*
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
|
|
|
* Copyright (C) 2010 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/machine/int.h>
|
|
|
|
#include <grub/machine/apm.h>
|
|
|
|
#include <grub/dl.h>
|
|
|
|
#include <grub/command.h>
|
|
|
|
#include <grub/i18n.h>
|
|
|
|
|
2011-04-11 21:01:51 +00:00
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
|
2010-09-15 09:42:18 +00:00
|
|
|
int
|
|
|
|
grub_apm_get_info (struct grub_apm_info *info)
|
|
|
|
{
|
|
|
|
struct grub_bios_int_registers regs;
|
|
|
|
|
|
|
|
/* detect APM */
|
|
|
|
regs.eax = 0x5300;
|
|
|
|
regs.ebx = 0;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x15, ®s);
|
|
|
|
|
|
|
|
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
|
|
|
|
return 0;
|
|
|
|
info->version = regs.eax & 0xffff;
|
|
|
|
info->flags = regs.ecx & 0xffff;
|
|
|
|
|
|
|
|
/* disconnect APM first */
|
|
|
|
regs.eax = 0x5304;
|
|
|
|
regs.ebx = 0;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x15, ®s);
|
|
|
|
|
|
|
|
/* connect APM */
|
|
|
|
regs.eax = 0x5303;
|
|
|
|
regs.ebx = 0;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x15, ®s);
|
|
|
|
|
|
|
|
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
info->cseg = regs.eax & 0xffff;
|
|
|
|
info->offset = regs.ebx;
|
|
|
|
info->cseg_16 = regs.ecx & 0xffff;
|
|
|
|
info->dseg = regs.edx & 0xffff;
|
|
|
|
info->cseg_len = regs.esi >> 16;
|
|
|
|
info->cseg_16_len = regs.esi & 0xffff;
|
|
|
|
info->dseg_len = regs.edi;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_cmd_lsapm (grub_command_t cmd __attribute__ ((unused)),
|
|
|
|
int argc __attribute__ ((unused)), char **args __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
struct grub_apm_info info;
|
|
|
|
if (!grub_apm_get_info (&info))
|
2012-02-12 14:25:25 +00:00
|
|
|
return grub_error (GRUB_ERR_IO, N_("no APM found"));
|
2010-09-15 09:42:18 +00:00
|
|
|
|
2012-02-08 18:26:01 +00:00
|
|
|
grub_printf_ (N_("Version %u.%u\n"
|
2011-11-11 23:34:14 +00:00
|
|
|
"32-bit CS = 0x%x, len = 0x%x, offset = 0x%x\n"
|
|
|
|
"16-bit CS = 0x%x, len = 0x%x\n"
|
|
|
|
"DS = 0x%x, len = 0x%x\n"),
|
|
|
|
info.version >> 8, info.version & 0xff,
|
|
|
|
info.cseg, info.cseg_len, info.offset,
|
|
|
|
info.cseg_16, info.cseg_16_len,
|
|
|
|
info.dseg, info.dseg_len);
|
2010-09-15 09:42:18 +00:00
|
|
|
grub_xputs (info.flags & GRUB_APM_FLAGS_16BITPROTECTED_SUPPORTED
|
2011-11-11 23:34:14 +00:00
|
|
|
? _("16-bit protected interface supported\n")
|
|
|
|
: _("16-bit protected interface unsupported\n"));
|
2010-09-15 09:42:18 +00:00
|
|
|
grub_xputs (info.flags & GRUB_APM_FLAGS_32BITPROTECTED_SUPPORTED
|
2011-11-11 23:34:14 +00:00
|
|
|
? _("32-bit protected interface supported\n")
|
|
|
|
: _("32-bit protected interface unsupported\n"));
|
2010-09-15 09:42:18 +00:00
|
|
|
grub_xputs (info.flags & GRUB_APM_FLAGS_CPUIDLE_SLOWS_DOWN
|
2011-11-11 23:34:14 +00:00
|
|
|
? _("CPU Idle slows down processor\n")
|
|
|
|
: _("CPU Idle doesn't slow down processor\n"));
|
2010-09-15 09:42:18 +00:00
|
|
|
grub_xputs (info.flags & GRUB_APM_FLAGS_DISABLED
|
2011-11-11 23:34:14 +00:00
|
|
|
? _("APM disabled\n") : _("APM enabled\n"));
|
2010-09-15 09:42:18 +00:00
|
|
|
grub_xputs (info.flags & GRUB_APM_FLAGS_DISENGAGED
|
2011-11-11 23:34:14 +00:00
|
|
|
? _("APM disengaged\n") : _("APM engaged\n"));
|
2010-09-15 09:42:18 +00:00
|
|
|
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_command_t cmd;
|
|
|
|
|
|
|
|
GRUB_MOD_INIT(lsapm)
|
|
|
|
{
|
|
|
|
cmd = grub_register_command ("lsapm", grub_cmd_lsapm, 0,
|
|
|
|
N_("Show APM information."));
|
|
|
|
}
|
|
|
|
|
|
|
|
GRUB_MOD_FINI(lsapm)
|
|
|
|
{
|
|
|
|
grub_unregister_command (cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
|