* grub-core/commands/i386/cmostest.c (+parse_args): New function.
(grub_cmd_cmosclean): Likewise. (GRUB_MOD_INIT): Register command cmosclean. * util/grub-mkconfig.in: Export GRUB_BUTTON_CMOS_CLEAN. * util/grub.d/00_header.in: Handle GRUB_BUTTON_CMOS_CLEAN.
This commit is contained in:
parent
de0bd1d940
commit
eaf41b2592
4 changed files with 52 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2010-09-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/commands/i386/cmostest.c (+parse_args): New function.
|
||||||
|
(grub_cmd_cmosclean): Likewise.
|
||||||
|
(GRUB_MOD_INIT): Register command cmosclean.
|
||||||
|
* util/grub-mkconfig.in: Export GRUB_BUTTON_CMOS_CLEAN.
|
||||||
|
* util/grub.d/00_header.in: Handle GRUB_BUTTON_CMOS_CLEAN.
|
||||||
|
|
||||||
2010-09-18 Carles Pina i Estany <carles@pina.cat>
|
2010-09-18 Carles Pina i Estany <carles@pina.cat>
|
||||||
2010-09-18 Aleš Nesrsta <starous@volny.cz>
|
2010-09-18 Aleš Nesrsta <starous@volny.cz>
|
||||||
2010-09-18 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-09-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
|
@ -22,20 +22,32 @@
|
||||||
#include <grub/cmos.h>
|
#include <grub/cmos.h>
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
|
parse_args (int argc, char *argv[], int *byte, int *bit)
|
||||||
int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
int byte, bit;
|
|
||||||
char *rest;
|
char *rest;
|
||||||
|
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
|
||||||
|
|
||||||
byte = grub_strtoul (argv[0], &rest, 0);
|
*byte = grub_strtoul (argv[0], &rest, 0);
|
||||||
if (*rest != ':')
|
if (*rest != ':')
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
|
||||||
|
|
||||||
bit = grub_strtoul (rest + 1, 0, 0);
|
*bit = grub_strtoul (rest + 1, 0, 0);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int byte, bit;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
|
err = parse_args (argc, argv, &byte, &bit);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
if (grub_cmos_read (byte) & (1 << bit))
|
if (grub_cmos_read (byte) & (1 << bit))
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
|
@ -43,7 +55,22 @@ grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
return grub_error (GRUB_ERR_TEST_FAILURE, "false");
|
return grub_error (GRUB_ERR_TEST_FAILURE, "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_command_t cmd;
|
static grub_err_t
|
||||||
|
grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int byte, bit;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
|
err = parse_args (argc, argv, &byte, &bit);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
grub_cmos_write (byte, grub_cmos_read (byte) & (~(1 << bit)));
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_command_t cmd, cmd_clean;
|
||||||
|
|
||||||
|
|
||||||
GRUB_MOD_INIT(cmostest)
|
GRUB_MOD_INIT(cmostest)
|
||||||
|
@ -51,9 +78,13 @@ GRUB_MOD_INIT(cmostest)
|
||||||
cmd = grub_register_command ("cmostest", grub_cmd_cmostest,
|
cmd = grub_register_command ("cmostest", grub_cmd_cmostest,
|
||||||
"cmostest BYTE:BIT",
|
"cmostest BYTE:BIT",
|
||||||
"Test bit at BYTE:BIT in CMOS.");
|
"Test bit at BYTE:BIT in CMOS.");
|
||||||
|
cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean,
|
||||||
|
"cmosclean BYTE:BIT",
|
||||||
|
"Clean bit at BYTE:BIT in CMOS.");
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(cmostest)
|
GRUB_MOD_FINI(cmostest)
|
||||||
{
|
{
|
||||||
grub_unregister_command (cmd);
|
grub_unregister_command (cmd);
|
||||||
|
grub_unregister_command (cmd_clean);
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,7 @@ export GRUB_DEFAULT \
|
||||||
GRUB_HIDDEN_TIMEOUT_BUTTON \
|
GRUB_HIDDEN_TIMEOUT_BUTTON \
|
||||||
GRUB_TIMEOUT_BUTTON \
|
GRUB_TIMEOUT_BUTTON \
|
||||||
GRUB_BUTTON_CMOS_ADDRESS \
|
GRUB_BUTTON_CMOS_ADDRESS \
|
||||||
|
GRUB_BUTTON_CMOS_CLEAN \
|
||||||
GRUB_DISTRIBUTOR \
|
GRUB_DISTRIBUTOR \
|
||||||
GRUB_CMDLINE_LINUX \
|
GRUB_CMDLINE_LINUX \
|
||||||
GRUB_CMDLINE_LINUX_DEFAULT \
|
GRUB_CMDLINE_LINUX_DEFAULT \
|
||||||
|
|
|
@ -247,6 +247,12 @@ else
|
||||||
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
|
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then
|
||||||
|
cat <<EOF
|
||||||
|
cmosclean $GRUB_BUTTON_CMOS_ADDRESS
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
# Play an initial tune
|
# Play an initial tune
|
||||||
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
|
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
|
||||||
echo "play ${GRUB_INIT_TUNE}"
|
echo "play ${GRUB_INIT_TUNE}"
|
||||||
|
|
Loading…
Reference in a new issue