2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove <grub/normal.h> and <grub/arg.h>. (grub_cmd_blocklist): Use the new command interface. (GRUB_MOD_INIT): Likewise. (GRUB_MOD_FINI): Likewise. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/crc.c: Likewise. * commands/echo.c: Likewise. * commands/halt.c: Likewise. * commands/handler.c: Likewise. * commands/hdparm.c: Likewise. * commands/help.c: Likewise. * commands/hexdump.c: Likewise. * commands/loadenv.c: Likewise. * commands/ls.c: Likewise. * commands/lsmmap.c: Likewise. * commands/lspci.c: Likewise. * commands/loadenv.c: Likewise. * commands/read.c: Likewise. * commands/reboot.c: Likewise. * commands/search.c: Likewise. * commands/sleep.c: Likewise. * commands/test.c: Likewise. * commands/usbtest.c: Likewise. * commands/videotest.c: Likewise. * commands/i386/cpuid.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/pxecmd.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/i386/pc/vbetest.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * disk/loopback.c: Likewise. * font/font_cmd.c: Likewise. * hello/hello.c: Likewise. * loader/efi/appleloader.c: Likewise. * loader/efi/chainloader.c: Likewise. * loader/i386/bsd.c: Likewise. * loader/i386/efi/linux.c: Likewise. * loader/i386/ieee1275/linux.c: Likewise. * loader/i386/linux.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/multiboot_loader.c: Likewise. * term/gfxterm.c: Likewise. * term/i386/pc/serial.c: Likewise. * term/terminfo.c: Likewise. * term/i386/pc/vesafb.c: Removed <grub/arg.h>. * term/i386/pc/vga.c: Likewise. * video/readers/jpeg.c: Likewise. * video/readers/png.c: Likewise. * video/readers/tga.c: Likewise. * util/grub-fstest (cmd_loopback): Removed. (cmd_blocklist): Likewise. (cmd_ls): Likewise. (grub_register_command): Likewise. (grub_unregister_command): Likewise. (execute_command): Use grub_command_find to locate command and execute it. * include/grub/efi/chainloader.h: Removed. * loader/efi/chainloader_normal.c: Likewise. * loader/i386/bsd_normal.c: Likewise. * loader/i386/pc/chainloader_normal.c: Likewise. * loader/i386/pc/multiboot_normal.c: Likewise. * loader/linux_normal.c: Likewise. * loader/multiboot_loader_normal.c: Likewise. * loader/powerpc/ieee1275/linux_normal.c: Likewise. * gencmdlist.sh: Scan new registration command grub_register_extcmd and grub_register_command_p1. * conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c, kern/command.c, lib/arg.c and commands/extcmd.c. (pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod. (minicmd_mod_SOURCES): New variable. (minicmd_mod_CFLAGS): Likewise. (minicmd_mod_LDFLAGS): Likewise. (extcmd_mod_SOURCES): Likewise. (extcmd_mod_CFLAGS): Likewise. (extcmd_mod_LDFLAGS): Likewise. (boot_mod_SOURCES): Removed. (boot_mod_CFLAGS): Likewise. (boot_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and kern/corecmd.c. (kernel_img_HEADERS): Add command.h. (grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c and lib/arg.c. (pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and _multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod, remove the corresponding normal mode command. (normal_mod_SOURCES): Remove normal/arg.c. * conf/i386-coreboot.rmk: Likewise. * conf/i386-efi.rmk: Likewise. * conf/i386-ieee1275.rmk: Likewise. * conf/powerpc-ieee1275.rmk: Likewise. * conf/x86_64-efi.rmk: Likewise. * include/grub/arg.h: Move from here ... * include/grub/lib/arg.h: ... to here. * normal/arg.c: Move from here ... * lib/arg.c: ... to here. * commands/extcmd.c: New file. * commands/minicmd.c: Likewise. * include/grub/command.h: Likewise. * include/grub/extcmd.h: Likewise. * kern/command.c: Likewise. * kern/corecmd.c: Likewise. * kern/list.c (grub_list_iterate): Return int instead of void. (grub_list_insert): New function. (grub_prio_list_insert): Likewise. * kern/rescue.c (grub_rescue_command): Removed. (grub_rescue_command_list): Likewise. (grub_rescue_register_command): Likewise. (grub_rescue_unregister_command): Likewise. (grub_rescue_cmd_boot): Move to minicmd.c (grub_rescue_cmd_help): Likewise. (grub_rescue_cmd_info): Likewise. (grub_rescue_cmd_boot): Likewise. (grub_rescue_cmd_testload): Likewise. (grub_rescue_cmd_dump): Likewise. (grub_rescue_cmd_rmmod): Likewise. (grub_rescue_cmd_lsmod): Likewise. (grub_rescue_cmd_exit): Likewise. (grub_rescue_print_devices): Moved to corecmd.c. (grub_rescue_print_files): Likewise. (grub_rescue_cmd_ls): Likewise. (grub_rescue_cmd_insmod): Likewise. (grub_rescue_cmd_set): Likewise. (grub_rescue_cmd_unset): Likewise. (attemp_normal_mode): Use grub_command_find to get normal module. (grub_enter_rescue_mode): Use grub_register_core_commands to register commands, remove grub_rescue_regiter_command calls. * normal/command.c (grub_regiser_command): Removed. (grub_unregister_command): Likewise. (grub_command_find): Likewise. (grub_iterate_commands): Likewise. (rescue_command): Likewise. (export_command): Moved to corecmd.c. (set_command): Removed. (unset_command): Likewise. (insmod_command): Likewise. (rmmod_command): Likewise. (lsmod_command): Likewise. (grub_command_init): Likewise. * normal/completion.c (iterate_command): Use cmd->prio to check for active command. (complete_arguments): Use grub_extcmd_t structure to find options. (grub_normal_do_completion): Change function grub_iterate_commands to grub_command_iterate. * normal/execute.c (grub_script_execute_cmd): No need to parse argument here. * normal/main.c (grub_dyncmd_dispatcher): New function. (read_command_list): Register unload commands as dyncmd. (grub_cmd_normal): Use new command interface, register rescue, unregister normal at entry, register normal, unregister rescue at exit. * include/grub/list.h (grub_list_test_t): New type. (grub_list_iterate): Return int instead of void. (grub_list_insert): New function. (GRUB_AS_NAMED_LIST_P): New macro. (GRUB_AS_PRIO_LIST): Likewise. (GRUB_AS_PRIO_LIST_P): Likewise. (GRUB_PRIO_LIST_PRIO_MASK): New constant. (GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise. (grub_prio_list): New structure. (grub_prio_list_insert): New function. (grub_prio_list_remove): New inline function. * include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>. (GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h. (GRUB_COMMAND_FLAG_MENU): Likewise. (GRUB_COMMAND_FLAG_BOTH): Likewise. (GRUB_COMMAND_FLAG_TITLE): Likewise. (GRUB_COMMAND_FLAG_NO_ECHO): Likewise. (GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed. (GRUB_COMMAND_FLAG_NOT_LOADED): Likewise. (grub_command): Likewise. (grub_register_command): Likewise. (grub_command_find): Likewise. (grub_iterate_commands): Likewise. (grub_command_init): Likewise. (grub_arg_parse): Likewise. (grub_arg_show_help): Likewise. * include/grub/rescue.h (grub_rescue_register_command): Removed. (grub_rescue_unregister_command): Likewise. * include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd, grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd, grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module. * include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and grub_rescue_cmd_initrd. * include/grub/i386/loader.h: Likewise. * include/grub/x86_64/loader.h: Likewise. * include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
This commit is contained in:
parent
1f4147aaf0
commit
b1b797cb1b
100 changed files with 3058 additions and 3914 deletions
|
@ -17,17 +17,16 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_blocklist (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_file_t file;
|
||||
|
@ -106,17 +105,16 @@ grub_cmd_blocklist (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(blocklist)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("blocklist", grub_cmd_blocklist,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"blocklist FILE",
|
||||
"Print a block list.", 0);
|
||||
cmd = grub_register_command ("blocklist", grub_cmd_blocklist,
|
||||
"blocklist FILE", "Print a block list.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(blocklist)
|
||||
{
|
||||
grub_unregister_command ("blocklist");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/loader.h>
|
||||
|
||||
|
|
|
@ -17,17 +17,16 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gzio.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_cat (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
|
||||
{
|
||||
|
@ -74,15 +73,16 @@ grub_cmd_cat (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(cat)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("cat", grub_cmd_cat, GRUB_COMMAND_FLAG_BOTH,
|
||||
"cat FILE", "Show the contents of a file.", 0);
|
||||
cmd = grub_register_command_p1 ("cat", grub_cmd_cat,
|
||||
"cat FILE", "Show the contents of a file.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(cat)
|
||||
{
|
||||
grub_unregister_command ("cat");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,18 +17,17 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/gzio.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#define BUFFER_SIZE 512
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_cmp (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_ssize_t rd1, rd2;
|
||||
|
@ -105,15 +104,16 @@ cleanup:
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(cmp)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("cmp", grub_cmd_cmp, GRUB_COMMAND_FLAG_BOTH,
|
||||
"cmp FILE1 FILE2", "Compare two files.", 0);
|
||||
cmd = grub_register_command ("cmp", grub_cmd_cmp,
|
||||
"cmp FILE1 FILE2", "Compare two files.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(cmp)
|
||||
{
|
||||
grub_unregister_command ("cmp");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,62 +17,59 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_configfile (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
|
||||
{
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
|
||||
grub_cls ();
|
||||
grub_env_context_open ();
|
||||
grub_normal_execute (args[0], 1);
|
||||
grub_env_context_close ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_source (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
|
||||
grub_cmd_source (grub_command_t cmd, int argc, char **args)
|
||||
{
|
||||
int new_env;
|
||||
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
|
||||
new_env = (cmd->name[0] == 'c');
|
||||
|
||||
if (new_env)
|
||||
{
|
||||
grub_cls ();
|
||||
grub_env_context_open ();
|
||||
}
|
||||
|
||||
grub_normal_execute (args[0], 1);
|
||||
|
||||
if (new_env)
|
||||
grub_env_context_close ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd_configfile, cmd_source, cmd_dot;
|
||||
|
||||
GRUB_MOD_INIT(configfile)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("configfile", grub_cmd_configfile,
|
||||
GRUB_COMMAND_FLAG_BOTH, "configfile FILE",
|
||||
"Load another config file.", 0);
|
||||
grub_register_command ("source", grub_cmd_source,
|
||||
GRUB_COMMAND_FLAG_BOTH, "source FILE",
|
||||
"Load another config file without changing context.",
|
||||
0);
|
||||
grub_register_command (".", grub_cmd_source,
|
||||
GRUB_COMMAND_FLAG_BOTH, ". FILE",
|
||||
"Load another config file without changing context.",
|
||||
0);
|
||||
cmd_configfile =
|
||||
grub_register_command ("configfile", grub_cmd_source,
|
||||
"configfile FILE", "Load another config file.");
|
||||
cmd_source =
|
||||
grub_register_command ("source", grub_cmd_source,
|
||||
"source FILE",
|
||||
"Load another config file without changing context."
|
||||
);
|
||||
cmd_dot =
|
||||
grub_register_command (".", grub_cmd_source,
|
||||
". FILE",
|
||||
"Load another config file without changing context."
|
||||
);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(configfile)
|
||||
{
|
||||
grub_unregister_command ("configfile");
|
||||
grub_unregister_command ("source");
|
||||
grub_unregister_command (".");
|
||||
grub_unregister_command (cmd_configfile);
|
||||
grub_unregister_command (cmd_source);
|
||||
grub_unregister_command (cmd_dot);
|
||||
}
|
||||
|
|
|
@ -17,16 +17,15 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/lib/crc.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_crc (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_crc (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
|
||||
{
|
||||
|
@ -53,14 +52,17 @@ grub_cmd_crc (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(crc)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("crc", grub_cmd_crc, GRUB_COMMAND_FLAG_BOTH,
|
||||
"crc FILE", "Calculate the crc32 checksum of a file.", 0);
|
||||
cmd = grub_register_command ("crc", grub_cmd_crc,
|
||||
"crc FILE",
|
||||
"Calculate the crc32 checksum of a file.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(crc)
|
||||
{
|
||||
grub_unregister_command ("crc");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/lib/datetime.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#define GRUB_DATETIME_SET_YEAR 1
|
||||
#define GRUB_DATETIME_SET_MONTH 2
|
||||
|
@ -32,7 +31,7 @@
|
|||
#define GRUB_DATETIME_SET_SECOND 32
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_date (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_date (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
struct grub_datetime datetime;
|
||||
|
@ -130,16 +129,18 @@ fail:
|
|||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid datetime");
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(date)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("date", grub_cmd_date,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"date [[year-]month-day] [hour:minute[:second]]",
|
||||
"Command to display/set current datetime.", 0);
|
||||
cmd =
|
||||
grub_register_command ("date", grub_cmd_date,
|
||||
"date [[year-]month-day] [hour:minute[:second]]",
|
||||
"Command to display/set current datetime.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(date)
|
||||
{
|
||||
grub_unregister_command ("date");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,10 +17,9 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -29,10 +28,10 @@ static const struct grub_arg_option options[] =
|
|||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_echo (struct grub_arg_list *state, int argc, char **args)
|
||||
grub_cmd_echo (grub_extcmd_t cmd, int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
int newline = 1;
|
||||
int i;
|
||||
|
||||
|
@ -109,16 +108,17 @@ grub_cmd_echo (struct grub_arg_list *state, int argc, char **args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(echo)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH,
|
||||
"echo [-e|-n] FILE", "Display a line of text.",
|
||||
options);
|
||||
cmd = grub_register_extcmd ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH,
|
||||
"echo [-e|-n] FILE", "Display a line of text.",
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(echo)
|
||||
{
|
||||
grub_unregister_command ("echo");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
97
commands/extcmd.c
Normal file
97
commands/extcmd.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* extcmd.c - support extended command */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 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/mm.h>
|
||||
#include <grub/list.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_extcmd_dispatcher (struct grub_command *cmd,
|
||||
int argc, char **args)
|
||||
{
|
||||
int new_argc;
|
||||
char **new_args;
|
||||
struct grub_arg_option *parser;
|
||||
struct grub_arg_list *state;
|
||||
int maxargs = 0;
|
||||
grub_err_t ret;
|
||||
grub_extcmd_t ext;
|
||||
|
||||
ext = cmd->data;
|
||||
parser = (struct grub_arg_option *) ext->options;
|
||||
while (parser && (parser++)->doc)
|
||||
maxargs++;
|
||||
|
||||
/* Set up the option state. */
|
||||
state = grub_malloc (sizeof (struct grub_arg_list) * maxargs);
|
||||
grub_memset (state, 0, sizeof (struct grub_arg_list) * maxargs);
|
||||
|
||||
if (grub_arg_parse (ext, argc, args, state, &new_args, &new_argc))
|
||||
{
|
||||
ext->state = state;
|
||||
ret = (ext->func) (ext, new_argc, new_args);
|
||||
grub_free (new_args);
|
||||
}
|
||||
else
|
||||
ret = grub_errno;
|
||||
|
||||
grub_free (state);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
grub_extcmd_t
|
||||
grub_register_extcmd (const char *name, grub_extcmd_func_t func,
|
||||
unsigned flags, const char *summary,
|
||||
const char *description,
|
||||
const struct grub_arg_option *parser)
|
||||
{
|
||||
grub_extcmd_t ext;
|
||||
grub_command_t cmd;
|
||||
|
||||
ext = (grub_extcmd_t) grub_malloc (sizeof (*ext));
|
||||
if (! ext)
|
||||
return 0;
|
||||
|
||||
cmd = grub_register_command_prio (name, grub_extcmd_dispatcher,
|
||||
summary, description, 1);
|
||||
if (! cmd)
|
||||
{
|
||||
grub_free (ext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmd->flags = (flags | GRUB_COMMAND_FLAG_EXTCMD);
|
||||
cmd->data = ext;
|
||||
|
||||
ext->cmd = cmd;
|
||||
ext->func = func;
|
||||
ext->options = parser;
|
||||
ext->data = 0;
|
||||
|
||||
return ext;
|
||||
}
|
||||
|
||||
void
|
||||
grub_unregister_extcmd (grub_extcmd_t ext)
|
||||
{
|
||||
grub_unregister_command (ext->cmd);
|
||||
grub_free (ext);
|
||||
}
|
|
@ -17,9 +17,9 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/machine/machine.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#if defined(GRUB_MACHINE_IEEE1275)
|
||||
#include <grub/machine/kernel.h>
|
||||
|
@ -31,7 +31,7 @@
|
|||
#endif
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_halt (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -39,16 +39,17 @@ grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(halt)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
|
||||
"halt", "halts the computer. This command does not"
|
||||
" work on all firmware.", 0);
|
||||
cmd = grub_register_command ("halt", grub_cmd_halt,
|
||||
0, "halts the computer. This command does not"
|
||||
" work on all firmware.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(halt)
|
||||
{
|
||||
grub_unregister_command ("halt");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,18 +17,18 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/handler.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_handler_generic (int argc, char **args, char *class_name)
|
||||
grub_cmd_handler (struct grub_command *cmd,
|
||||
int argc, char **args)
|
||||
{
|
||||
char *find_name;
|
||||
void *find_result;
|
||||
char *class_name;
|
||||
void *curr_item = 0;
|
||||
grub_handler_class_t head;
|
||||
|
||||
|
@ -43,10 +43,12 @@ grub_cmd_handler_generic (int argc, char **args, char *class_name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
class_name = (grub_strcmp (cmd->name, "handler")) ? (char *) cmd->name : 0;
|
||||
|
||||
head = grub_handler_class_list;
|
||||
if ((argc == 0) && (class_name == 0))
|
||||
{
|
||||
grub_list_iterate (head, (grub_list_hook_t) list_item);
|
||||
grub_list_iterate (GRUB_AS_LIST (head), (grub_list_hook_t) list_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66,7 +68,7 @@ grub_cmd_handler_generic (int argc, char **args, char *class_name)
|
|||
if (argc == 0)
|
||||
{
|
||||
curr_item = class->cur_handler;
|
||||
grub_list_iterate (class->handler_list,
|
||||
grub_list_iterate (GRUB_AS_LIST (class->handler_list),
|
||||
(grub_list_hook_t) list_item);
|
||||
}
|
||||
else
|
||||
|
@ -87,46 +89,28 @@ grub_cmd_handler_generic (int argc, char **args, char *class_name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_handler (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
return grub_cmd_handler_generic (argc, args, 0);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_terminal_input (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
return grub_cmd_handler_generic (argc, args, "terminal_input");
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_terminal_output (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
return grub_cmd_handler_generic (argc, args, "terminal_output");
|
||||
}
|
||||
static grub_command_t cmd_handler, cmd_terminal_input, cmd_terminal_output;
|
||||
|
||||
GRUB_MOD_INIT(handler)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("handler", grub_cmd_handler, GRUB_COMMAND_FLAG_BOTH,
|
||||
"handler [class [handler]]",
|
||||
"List or select a handler", 0);
|
||||
grub_register_command ("terminal_input", grub_cmd_terminal_input,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"terminal_input [handler]",
|
||||
"List or select a handler", 0);
|
||||
grub_register_command ("terminal_output", grub_cmd_terminal_output,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"terminal_output [handler]",
|
||||
"List or select a handler", 0);
|
||||
cmd_handler =
|
||||
grub_register_command ("handler", grub_cmd_handler,
|
||||
"handler [class [handler]]",
|
||||
"List or select a handler");
|
||||
cmd_terminal_input =
|
||||
grub_register_command ("terminal_input", grub_cmd_handler,
|
||||
"terminal_input [handler]",
|
||||
"List or select a handler");
|
||||
cmd_terminal_output =
|
||||
grub_register_command ("terminal_output", grub_cmd_handler,
|
||||
"terminal_output [handler]",
|
||||
"List or select a handler");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(handler)
|
||||
{
|
||||
grub_unregister_command ("terminal_input");
|
||||
grub_unregister_command ("terminal_output");
|
||||
grub_unregister_command ("handler");
|
||||
grub_unregister_command (cmd_handler);
|
||||
grub_unregister_command (cmd_terminal_input);
|
||||
grub_unregister_command (cmd_terminal_output);
|
||||
}
|
||||
|
|
|
@ -17,15 +17,13 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/arg.h>
|
||||
#include <grub/ata.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/lib/hexdump.h>
|
||||
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] = {
|
||||
{"apm", 'B', 0, "set Advanced Power Management\n"
|
||||
|
@ -270,10 +268,11 @@ static int get_int_arg (const struct grub_arg_list *state)
|
|||
return (state->set ? (int)grub_strtoul (state->arg, 0, 0) : -1);
|
||||
}
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_hdparm (struct grub_arg_list *state, int argc, char **args) // state????
|
||||
grub_cmd_hdparm (grub_extcmd_t cmd, int argc, char **args) // state????
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
|
||||
/* Check command line. */
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing device name argument");
|
||||
|
@ -405,17 +404,19 @@ grub_cmd_hdparm (struct grub_arg_list *state, int argc, char **args) // state???
|
|||
return status;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(hdparm)
|
||||
{
|
||||
(void) mod;
|
||||
|
||||
grub_register_command ("hdparm", grub_cmd_hdparm, GRUB_COMMAND_FLAG_BOTH,
|
||||
"hdparm [OPTIONS] DISK",
|
||||
"Get/set ATA disk parameters.", options);
|
||||
cmd = grub_register_extcmd ("hdparm", grub_cmd_hdparm,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"hdparm [OPTIONS] DISK",
|
||||
"Get/set ATA disk parameters.", options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(hdparm)
|
||||
{
|
||||
grub_unregister_command ("hdparm");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -17,16 +17,14 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_help (struct grub_arg_list *state __attribute__ ((unused)), int argc,
|
||||
grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
||||
char **args)
|
||||
|
||||
{
|
||||
int cnt = 0;
|
||||
char *currarg;
|
||||
|
@ -36,44 +34,46 @@ grub_cmd_help (struct grub_arg_list *state __attribute__ ((unused)), int argc,
|
|||
|
||||
int print_command_info (grub_command_t cmd)
|
||||
{
|
||||
if (grub_command_find (cmd->name))
|
||||
if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) &&
|
||||
(cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
|
||||
{
|
||||
if (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)
|
||||
{
|
||||
char description[GRUB_TERM_WIDTH / 2];
|
||||
int desclen = grub_strlen (cmd->summary);
|
||||
|
||||
/* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled
|
||||
with the description followed by spaces. */
|
||||
grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1);
|
||||
description[GRUB_TERM_WIDTH / 2 - 1] = '\0';
|
||||
grub_memcpy (description, cmd->summary,
|
||||
(desclen < GRUB_TERM_WIDTH / 2 - 1
|
||||
? desclen : GRUB_TERM_WIDTH / 2 - 1));
|
||||
|
||||
grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " ");
|
||||
}
|
||||
char description[GRUB_TERM_WIDTH / 2];
|
||||
int desclen = grub_strlen (cmd->summary);
|
||||
|
||||
/* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled
|
||||
with the description followed by spaces. */
|
||||
grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1);
|
||||
description[GRUB_TERM_WIDTH / 2 - 1] = '\0';
|
||||
grub_memcpy (description, cmd->summary,
|
||||
(desclen < GRUB_TERM_WIDTH / 2 - 1
|
||||
? desclen : GRUB_TERM_WIDTH / 2 - 1));
|
||||
|
||||
grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " ");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int print_command_help (grub_command_t cmd)
|
||||
{
|
||||
if (grub_command_find (cmd->name))
|
||||
if (cmd->flags & GRUB_PRIO_LIST_FLAG_ACTIVE)
|
||||
{
|
||||
if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg)))
|
||||
{
|
||||
if (cnt++ > 0)
|
||||
grub_printf ("\n\n");
|
||||
|
||||
grub_arg_show_help (cmd);
|
||||
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
|
||||
grub_arg_show_help ((grub_extcmd_t) cmd->data);
|
||||
else
|
||||
grub_printf ("Usage: %s\n%s\b", cmd->summary,
|
||||
cmd->description);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc == 0)
|
||||
grub_iterate_commands (print_command_info);
|
||||
grub_command_iterate (print_command_info);
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
@ -81,23 +81,25 @@ grub_cmd_help (struct grub_arg_list *state __attribute__ ((unused)), int argc,
|
|||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
currarg = args[i];
|
||||
grub_iterate_commands (print_command_help);
|
||||
grub_command_iterate (print_command_help);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(help)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("help", grub_cmd_help, GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"help [PATTERN ...]", "Show a help message.", 0);
|
||||
cmd = grub_register_extcmd ("help", grub_cmd_help,
|
||||
GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"help [PATTERN ...]",
|
||||
"Show a help message.", 0);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(help)
|
||||
{
|
||||
grub_unregister_command ("help");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -17,15 +17,14 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gzio.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/lib/hexdump.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] = {
|
||||
{"skip", 's', 0, "skip offset bytes from the beginning of file.", 0,
|
||||
|
@ -35,8 +34,9 @@ static const struct grub_arg_option options[] = {
|
|||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_hexdump (struct grub_arg_list *state, int argc, char **args)
|
||||
grub_cmd_hexdump (grub_extcmd_t cmd, int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
char buf[GRUB_DISK_SECTOR_SIZE * 4];
|
||||
grub_ssize_t size, length;
|
||||
grub_addr_t skip;
|
||||
|
@ -121,16 +121,19 @@ grub_cmd_hexdump (struct grub_arg_list *state, int argc, char **args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT (hexdump)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("hexdump", grub_cmd_hexdump, GRUB_COMMAND_FLAG_BOTH,
|
||||
"hexdump [OPTIONS] FILE_OR_DEVICE",
|
||||
"Dump the contents of a file or memory.", options);
|
||||
cmd = grub_register_extcmd ("hexdump", grub_cmd_hexdump,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"hexdump [OPTIONS] FILE_OR_DEVICE",
|
||||
"Dump the contents of a file or memory.",
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (hexdump)
|
||||
{
|
||||
grub_unregister_command ("hexdump");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -18,12 +18,11 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#define cpuid(num,a,b,c,d) \
|
||||
asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" \
|
||||
|
@ -34,20 +33,16 @@
|
|||
|
||||
static unsigned char has_longmode = 0;
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
{"long-mode", 'l', 0, "check for long mode flag (default)", 0, 0},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_cpuid (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_cpuid (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
return !has_longmode;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(cpuid)
|
||||
{
|
||||
#ifdef __x86_64__
|
||||
|
@ -83,11 +78,11 @@ GRUB_MOD_INIT(cpuid)
|
|||
done:
|
||||
#endif
|
||||
|
||||
grub_register_command ("cpuid", grub_cmd_cpuid, GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"cpuid", "Check for CPU features", options);
|
||||
cmd = grub_register_command ("cpuid", grub_cmd_cpuid,
|
||||
0, "Check for CPU features");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(cpuid)
|
||||
{
|
||||
grub_unregister_command ("cpuid");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,10 +17,9 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -29,11 +28,12 @@ static const struct grub_arg_option options[] =
|
|||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_halt (struct grub_arg_list *state,
|
||||
grub_cmd_halt (grub_extcmd_t cmd,
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
int no_apm = 0;
|
||||
if (state[0].set)
|
||||
no_apm = 1;
|
||||
|
@ -41,17 +41,18 @@ grub_cmd_halt (struct grub_arg_list *state,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(halt)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
|
||||
"halt [-n]",
|
||||
"Halt the system, if possible using APM", options);
|
||||
cmd = grub_register_extcmd ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
|
||||
"halt [-n]",
|
||||
"Halt the system, if possible using APM",
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(halt)
|
||||
{
|
||||
grub_unregister_command ("halt");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -19,15 +19,14 @@
|
|||
|
||||
/* Lots of this file is borrowed from GNU/Hurd generic-speaker driver. */
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/machine/time.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#define BASE_TEMPO 120
|
||||
|
||||
|
@ -144,7 +143,7 @@ beep_on (short pitch)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_play (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_file_t file;
|
||||
|
@ -203,15 +202,16 @@ grub_cmd_play (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(play)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("play", grub_cmd_play, GRUB_COMMAND_FLAG_BOTH,
|
||||
"play FILE", "Play a tune", 0);
|
||||
cmd = grub_register_command ("play", grub_cmd_play,
|
||||
"play FILE", "Play a tune");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(play)
|
||||
{
|
||||
grub_unregister_command ("play");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/machine/pxe.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -46,9 +45,11 @@ print_ip (grub_uint32_t ip)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_pxe (struct grub_arg_list *state, int argc __attribute__ ((unused)),
|
||||
grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
|
||||
if (! grub_pxe_pxenv)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no pxe environment");
|
||||
|
||||
|
@ -83,15 +84,17 @@ grub_cmd_pxe (struct grub_arg_list *state, int argc __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(pxecmd)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH,
|
||||
"pxe [-i|-b|-u]",
|
||||
"Command to control the PXE device.", options);
|
||||
cmd = grub_register_extcmd ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH,
|
||||
"pxe [-i|-b|-u]",
|
||||
"Command to control the PXE device.", options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(pxecmd)
|
||||
{
|
||||
grub_unregister_command ("pxe");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/vbe.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static void *
|
||||
real2pm (grub_vbe_farptr_t ptr)
|
||||
|
@ -34,7 +33,7 @@ real2pm (grub_vbe_farptr_t ptr)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_vbeinfo (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_vbeinfo (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -53,7 +52,7 @@ grub_cmd_vbeinfo (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return err;
|
||||
|
||||
grub_printf ("VBE info: version: %d.%d OEM software rev: %d.%d\n",
|
||||
controller_info.version >> 8,
|
||||
controller_info.version >> 8,
|
||||
controller_info.version & 0xFF,
|
||||
controller_info.oem_software_rev >> 8,
|
||||
controller_info.oem_software_rev & 0xFF);
|
||||
|
@ -77,7 +76,7 @@ grub_cmd_vbeinfo (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
|
||||
grub_printf ("List of compatible video modes:\n");
|
||||
grub_printf ("Legend: P=Packed pixel, D=Direct color, "
|
||||
"mask/pos=R/G/B/reserved\n");
|
||||
"mask/pos=R/G/B/reserved\n");
|
||||
|
||||
/* Walk through all video modes listed. */
|
||||
for (p = saved_video_mode_list; *p != 0xFFFF; p++)
|
||||
|
@ -170,18 +169,17 @@ grub_cmd_vbeinfo (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(vbeinfo)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("vbeinfo",
|
||||
grub_cmd_vbeinfo,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"vbeinfo",
|
||||
"List compatible VESA BIOS extension video modes.",
|
||||
0);
|
||||
cmd =
|
||||
grub_register_command ("vbeinfo", grub_cmd_vbeinfo, 0,
|
||||
"List compatible VESA BIOS extension video modes.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(vbeinfo)
|
||||
{
|
||||
grub_unregister_command ("vbeinfo");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/term.h>
|
||||
|
@ -28,7 +27,7 @@
|
|||
#include <grub/err.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_vbetest (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -162,18 +161,16 @@ grub_cmd_vbetest (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(vbetest)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("vbetest",
|
||||
grub_cmd_vbetest,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"vbetest",
|
||||
"Test VESA BIOS Extension 2.0+ support",
|
||||
0);
|
||||
cmd = grub_register_command ("vbetest", grub_cmd_vbetest,
|
||||
0, "Test VESA BIOS Extension 2.0+ support");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(vbetest)
|
||||
{
|
||||
grub_unregister_command ("vbetest");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_suspend (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_suspend (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -34,15 +34,16 @@ grub_cmd_suspend (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(ieee1275_suspend)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("suspend", grub_cmd_suspend, GRUB_COMMAND_FLAG_BOTH,
|
||||
"suspend", "Return to Open Firmware prompt", 0);
|
||||
cmd = grub_register_command ("suspend", grub_cmd_suspend,
|
||||
0, "Return to Open Firmware prompt");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(ieee1275_suspend)
|
||||
{
|
||||
grub_unregister_command ("suspend");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,16 +17,15 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/lib/envblk.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -102,10 +101,12 @@ read_envblk_file (char *filename, void NESTED_FUNC_ATTR read_hook (grub_disk_add
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_load_env (struct grub_arg_list *state,
|
||||
int argc __attribute__ ((unused)), char **args __attribute__ ((unused)))
|
||||
grub_cmd_load_env (grub_extcmd_t cmd,
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
grub_file_t file;
|
||||
|
||||
auto int hook (char *name, char *value);
|
||||
|
@ -128,9 +129,11 @@ grub_cmd_load_env (struct grub_arg_list *state,
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_list_env (struct grub_arg_list *state,
|
||||
int argc __attribute__ ((unused)), char **args __attribute__ ((unused)))
|
||||
grub_cmd_list_env (grub_extcmd_t cmd,
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
grub_file_t file;
|
||||
|
||||
auto int hook (char *name, char *value);
|
||||
|
@ -153,8 +156,9 @@ grub_cmd_list_env (struct grub_arg_list *state,
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_save_env (struct grub_arg_list *state, int argc, char **args)
|
||||
grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
grub_file_t file;
|
||||
grub_disk_t disk;
|
||||
grub_disk_addr_t addr[GRUB_ENVBLK_MAXLEN >> GRUB_DISK_SECTOR_BITS];
|
||||
|
@ -238,20 +242,35 @@ quit:
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd_load, cmd_list, cmd_save;
|
||||
|
||||
GRUB_MOD_INIT(loadenv)
|
||||
{
|
||||
(void) mod;
|
||||
grub_register_command ("load_env", grub_cmd_load_env, GRUB_COMMAND_FLAG_BOTH,
|
||||
"load_env [-f FILE]", "Load variables from environment block file.", options);
|
||||
grub_register_command ("list_env", grub_cmd_list_env, GRUB_COMMAND_FLAG_BOTH,
|
||||
"list_env [-f FILE]", "List variables from environment block file.", options);
|
||||
grub_register_command ("save_env", grub_cmd_save_env, GRUB_COMMAND_FLAG_BOTH,
|
||||
"save_env [-f FILE] variable_name [...]", "Save variables to environment block file.", options);
|
||||
|
||||
cmd_load =
|
||||
grub_register_extcmd ("load_env", grub_cmd_load_env,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"load_env [-f FILE]",
|
||||
"Load variables from environment block file.",
|
||||
options);
|
||||
cmd_list =
|
||||
grub_register_extcmd ("list_env", grub_cmd_list_env,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"list_env [-f FILE]",
|
||||
"List variables from environment block file.",
|
||||
options);
|
||||
cmd_save =
|
||||
grub_register_extcmd ("save_env", grub_cmd_save_env,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"save_env [-f FILE] variable_name [...]",
|
||||
"Save variables to environment block file.",
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(loadenv)
|
||||
{
|
||||
grub_unregister_command ("load_env");
|
||||
grub_unregister_command ("list_env");
|
||||
grub_unregister_command ("save_env");
|
||||
grub_unregister_extcmd (cmd_load);
|
||||
grub_unregister_extcmd (cmd_list);
|
||||
grub_unregister_extcmd (cmd_save);
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
|
||||
}
|
||||
grub_file_close (file);
|
||||
}
|
||||
}
|
||||
else
|
||||
grub_printf ("%-12s", "DIR");
|
||||
|
||||
|
@ -220,8 +220,10 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_ls (struct grub_arg_list *state, int argc, char **args)
|
||||
grub_cmd_ls (grub_extcmd_t cmd, int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
|
||||
if (argc == 0)
|
||||
grub_ls_list_devices (state[0].set);
|
||||
else
|
||||
|
@ -231,15 +233,17 @@ grub_cmd_ls (struct grub_arg_list *state, int argc, char **args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(ls)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH,
|
||||
"ls [-l|-h|-a] [FILE]",
|
||||
"List devices and files.", options);
|
||||
cmd = grub_register_extcmd ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH,
|
||||
"ls [-l|-h|-a] [FILE]",
|
||||
"List devices and files.", options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(ls)
|
||||
{
|
||||
grub_unregister_command ("ls");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -17,13 +17,12 @@
|
|||
*/
|
||||
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_lsmmap (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)), char **args __attribute__ ((unused)))
|
||||
|
||||
{
|
||||
|
@ -39,15 +38,16 @@ grub_cmd_lsmmap (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(lsmmap)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("lsmmap", grub_cmd_lsmmap, GRUB_COMMAND_FLAG_BOTH,
|
||||
"lsmmap", "List memory map provided by firmware.", 0);
|
||||
cmd = grub_register_command ("lsmmap", grub_cmd_lsmmap,
|
||||
0, "List memory map provided by firmware.");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(lsmmap)
|
||||
{
|
||||
grub_unregister_command ("lsmmap");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
#include <grub/pci.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
struct grub_pci_classname
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_lspci (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_lspci (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -154,18 +154,16 @@ grub_cmd_lspci (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(pci)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("lspci", grub_cmd_lspci, GRUB_COMMAND_FLAG_BOTH,
|
||||
"lspci", "List PCI devices", 0);
|
||||
cmd = grub_register_command ("lspci", grub_cmd_lspci,
|
||||
0, "List PCI devices");
|
||||
}
|
||||
|
||||
|
||||
GRUB_MOD_FINI(pci)
|
||||
{
|
||||
grub_unregister_command ("lspci");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
391
commands/minicmd.c
Normal file
391
commands/minicmd.c
Normal file
|
@ -0,0 +1,391 @@
|
|||
/* minicmd.c - commands for the rescue mode */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2005,2006,2007 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/dl.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/loader.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
/* boot */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_boot (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char *argv[] __attribute__ ((unused)))
|
||||
{
|
||||
return grub_loader_boot ();
|
||||
}
|
||||
|
||||
/* cat FILE */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file;
|
||||
char buf[GRUB_DISK_SECTOR_SIZE];
|
||||
grub_ssize_t size;
|
||||
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
|
||||
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
while ((size = grub_file_read (file, buf, sizeof (buf))) > 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
unsigned char c = buf[i];
|
||||
|
||||
if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
|
||||
grub_putchar (c);
|
||||
else
|
||||
{
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
|
||||
grub_printf ("<%x>", (int) c);
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grub_putchar ('\n');
|
||||
grub_refresh ();
|
||||
grub_file_close (file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* help */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_help (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char *argv[] __attribute__ ((unused)))
|
||||
{
|
||||
grub_command_t p;
|
||||
|
||||
for (p = grub_command_list; p; p = p->next)
|
||||
grub_printf ("%s (%d%c)\t%s\n", p->name,
|
||||
p->prio & GRUB_PRIO_LIST_PRIO_MASK,
|
||||
(p->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) ? '+' : '-',
|
||||
p->description);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
grub_rescue_cmd_info (void)
|
||||
{
|
||||
extern void grub_disk_cache_get_performance (unsigned long *,
|
||||
unsigned long *);
|
||||
unsigned long hits, misses;
|
||||
|
||||
grub_disk_cache_get_performance (&hits, &misses);
|
||||
grub_printf ("Disk cache: hits = %u, misses = %u ", hits, misses);
|
||||
if (hits + misses)
|
||||
{
|
||||
unsigned long ratio = hits * 10000 / (hits + misses);
|
||||
grub_printf ("(%u.%u%%)\n", ratio / 100, ratio % 100);
|
||||
}
|
||||
else
|
||||
grub_printf ("(N/A)\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* root [DEVICE] */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_root (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
grub_device_t dev;
|
||||
grub_fs_t fs;
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
char *device_name = grub_file_get_device_name (argv[0]);
|
||||
if (! device_name)
|
||||
return grub_errno;
|
||||
|
||||
grub_env_set ("root", device_name);
|
||||
grub_free (device_name);
|
||||
}
|
||||
|
||||
dev = grub_device_open (0);
|
||||
if (! dev)
|
||||
return grub_errno;
|
||||
|
||||
fs = grub_fs_probe (dev);
|
||||
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
grub_printf ("(%s): Filesystem is %s.\n",
|
||||
grub_env_get ("root"), fs ? fs->name : "unknown");
|
||||
|
||||
grub_device_close (dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
grub_rescue_cmd_testload (int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file;
|
||||
char *buf;
|
||||
grub_ssize_t size;
|
||||
grub_ssize_t pos;
|
||||
auto void read_func (unsigned long sector, unsigned offset, unsigned len);
|
||||
|
||||
void read_func (unsigned long sector __attribute__ ((unused)),
|
||||
unsigned offset __attribute__ ((unused)),
|
||||
unsigned len __attribute__ ((unused)))
|
||||
{
|
||||
grub_putchar ('.');
|
||||
grub_refresh ();
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
|
||||
return;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return;
|
||||
|
||||
size = grub_file_size (file) & ~(GRUB_DISK_SECTOR_SIZE - 1);
|
||||
if (size == 0)
|
||||
{
|
||||
grub_file_close (file);
|
||||
return;
|
||||
}
|
||||
|
||||
buf = grub_malloc (size);
|
||||
if (! buf)
|
||||
goto fail;
|
||||
|
||||
grub_printf ("Reading %s sequentially", argv[0]);
|
||||
file->read_hook = read_func;
|
||||
if (grub_file_read (file, buf, size) != size)
|
||||
goto fail;
|
||||
grub_printf (" Done.\n");
|
||||
|
||||
/* Read sequentially again. */
|
||||
grub_printf ("Reading %s sequentially again", argv[0]);
|
||||
if (grub_file_seek (file, 0) < 0)
|
||||
goto fail;
|
||||
|
||||
for (pos = 0; pos < size; pos += GRUB_DISK_SECTOR_SIZE)
|
||||
{
|
||||
char sector[GRUB_DISK_SECTOR_SIZE];
|
||||
|
||||
if (grub_file_read (file, sector, GRUB_DISK_SECTOR_SIZE)
|
||||
!= GRUB_DISK_SECTOR_SIZE)
|
||||
goto fail;
|
||||
|
||||
if (grub_memcmp (sector, buf + pos, GRUB_DISK_SECTOR_SIZE) != 0)
|
||||
{
|
||||
grub_printf ("\nDiffers in %d\n", pos);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
grub_printf (" Done.\n");
|
||||
|
||||
/* Read backwards and compare. */
|
||||
grub_printf ("Reading %s backwards", argv[0]);
|
||||
pos = size;
|
||||
while (pos > 0)
|
||||
{
|
||||
char sector[GRUB_DISK_SECTOR_SIZE];
|
||||
|
||||
pos -= GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
if (grub_file_seek (file, pos) < 0)
|
||||
goto fail;
|
||||
|
||||
if (grub_file_read (file, sector, GRUB_DISK_SECTOR_SIZE)
|
||||
!= GRUB_DISK_SECTOR_SIZE)
|
||||
goto fail;
|
||||
|
||||
if (grub_memcmp (sector, buf + pos, GRUB_DISK_SECTOR_SIZE) != 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
grub_printf ("\nDiffers in %d\n", pos);
|
||||
|
||||
for (i = 0; i < GRUB_DISK_SECTOR_SIZE; i++)
|
||||
grub_putchar (buf[pos + i]);
|
||||
|
||||
if (i)
|
||||
grub_refresh ();
|
||||
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
grub_printf (" Done.\n");
|
||||
|
||||
fail:
|
||||
|
||||
grub_file_close (file);
|
||||
grub_free (buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* dump ADDRESS [SIZE] */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_dump (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
grub_uint8_t *addr;
|
||||
grub_size_t size = 4;
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no address specified");
|
||||
|
||||
addr = (grub_uint8_t *) grub_strtoul (argv[0], 0, 0);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
if (argc > 1)
|
||||
size = (grub_size_t) grub_strtoul (argv[1], 0, 0);
|
||||
|
||||
while (size--)
|
||||
{
|
||||
grub_printf ("%x%x ", *addr >> 4, *addr & 0xf);
|
||||
addr++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* rmmod MODULE */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_rmmod (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
grub_dl_t mod;
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified");
|
||||
|
||||
mod = grub_dl_get (argv[0]);
|
||||
if (! mod)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such module");
|
||||
|
||||
if (grub_dl_unref (mod) <= 0)
|
||||
grub_dl_unload (mod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* lsmod */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char *argv[] __attribute__ ((unused)))
|
||||
{
|
||||
auto int print_module (grub_dl_t mod);
|
||||
|
||||
int print_module (grub_dl_t mod)
|
||||
{
|
||||
grub_dl_dep_t dep;
|
||||
|
||||
grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count);
|
||||
for (dep = mod->dep; dep; dep = dep->next)
|
||||
{
|
||||
if (dep != mod->dep)
|
||||
grub_putchar (',');
|
||||
|
||||
grub_printf ("%s", dep->mod->name);
|
||||
}
|
||||
grub_putchar ('\n');
|
||||
grub_refresh ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_printf ("Name\tRef Count\tDependencies\n");
|
||||
grub_dl_iterate (print_module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* exit */
|
||||
static grub_err_t
|
||||
grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char *argv[] __attribute__ ((unused)))
|
||||
{
|
||||
grub_exit ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd_boot, cmd_cat, cmd_help, cmd_root;
|
||||
static grub_command_t cmd_dump, cmd_rmmod, cmd_lsmod, cmd_exit;
|
||||
|
||||
GRUB_MOD_INIT(minicmd)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
|
||||
cmd_boot =
|
||||
grub_register_command ("boot", grub_mini_cmd_boot,
|
||||
0, "boot an operating system");
|
||||
cmd_cat =
|
||||
grub_register_command ("cat", grub_mini_cmd_cat,
|
||||
"cat FILE", "show the contents of a file");
|
||||
cmd_help =
|
||||
grub_register_command ("help", grub_mini_cmd_help,
|
||||
0, "show this message");
|
||||
cmd_root =
|
||||
grub_register_command ("root", grub_mini_cmd_root,
|
||||
"root [DEVICE]", "set the root device");
|
||||
cmd_dump =
|
||||
grub_register_command ("dump", grub_mini_cmd_dump,
|
||||
"dump ADDR", "dump memory");
|
||||
cmd_rmmod =
|
||||
grub_register_command ("rmmod", grub_mini_cmd_rmmod,
|
||||
"rmmod MODULE", "remove a module");
|
||||
cmd_lsmod =
|
||||
grub_register_command ("lsmod", grub_mini_cmd_lsmod,
|
||||
0, "show loaded modules");
|
||||
cmd_exit =
|
||||
grub_register_command ("exit", grub_mini_cmd_exit,
|
||||
0, "exit from GRUB");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(minicmd)
|
||||
{
|
||||
grub_unregister_command (cmd_boot);
|
||||
grub_unregister_command (cmd_cat);
|
||||
grub_unregister_command (cmd_help);
|
||||
grub_unregister_command (cmd_root);
|
||||
grub_unregister_command (cmd_dump);
|
||||
grub_unregister_command (cmd_rmmod);
|
||||
grub_unregister_command (cmd_lsmod);
|
||||
grub_unregister_command (cmd_exit);
|
||||
}
|
|
@ -20,9 +20,10 @@
|
|||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static char *
|
||||
grub_getline (void)
|
||||
|
@ -61,7 +62,7 @@ grub_getline (void)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_read (struct grub_arg_list *state UNUSED, int argc, char **args)
|
||||
grub_cmd_read (grub_command_t cmd UNUSED, int argc, char **args)
|
||||
{
|
||||
char *line = grub_getline ();
|
||||
if (! line)
|
||||
|
@ -73,14 +74,16 @@ grub_cmd_read (struct grub_arg_list *state UNUSED, int argc, char **args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(read)
|
||||
{
|
||||
grub_register_command ("read", grub_cmd_read, GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"read [ENVVAR]", "Set variable with user input", 0);
|
||||
cmd = grub_register_command ("read", grub_cmd_read,
|
||||
"read [ENVVAR]",
|
||||
"Set variable with user input");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(read)
|
||||
{
|
||||
grub_unregister_command ("read");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/machine/machine.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#if defined(GRUB_MACHINE_IEEE1275)
|
||||
#include <grub/machine/kernel.h>
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -42,15 +42,16 @@ grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(reboot)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("reboot", grub_cmd_reboot, GRUB_COMMAND_FLAG_BOTH,
|
||||
"reboot", "Reboot the computer", 0);
|
||||
cmd = grub_register_command ("reboot", grub_cmd_reboot,
|
||||
0, "Reboot the computer");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(reboot)
|
||||
{
|
||||
grub_unregister_command ("reboot");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -22,11 +22,10 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -121,8 +120,8 @@ search_fs_uuid (const char *key, const char *var)
|
|||
count++;
|
||||
if (var)
|
||||
{
|
||||
grub_env_set (var, name);
|
||||
abort = 1;
|
||||
grub_env_set (var, name);
|
||||
abort = 1;
|
||||
}
|
||||
else
|
||||
grub_printf (" %s", name);
|
||||
|
@ -196,8 +195,9 @@ search_file (const char *key, const char *var)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_search (struct grub_arg_list *state, int argc, char **args)
|
||||
grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
const char *var = 0;
|
||||
|
||||
if (argc == 0)
|
||||
|
@ -216,19 +216,23 @@ grub_cmd_search (struct grub_arg_list *state, int argc, char **args)
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(search)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("search", grub_cmd_search, GRUB_COMMAND_FLAG_BOTH,
|
||||
"search [-f|-l|-u|-s] NAME",
|
||||
"Search devices by file, filesystem label or filesystem UUID."
|
||||
" If --set is specified, the first device found is"
|
||||
" set to a variable. If no variable name is"
|
||||
" specified, \"root\" is used.",
|
||||
options);
|
||||
cmd =
|
||||
grub_register_extcmd ("search", grub_cmd_search,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"search [-f|-l|-u|-s] NAME",
|
||||
"Search devices by file, filesystem label or filesystem UUID."
|
||||
" If --set is specified, the first device found is"
|
||||
" set to a variable. If no variable name is"
|
||||
" specified, \"root\" is used.",
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(search)
|
||||
{
|
||||
grub_unregister_command ("search");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/machine/time.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -60,8 +60,9 @@ grub_interruptible_millisleep (grub_uint32_t ms)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_sleep (struct grub_arg_list *state, int argc, char **args)
|
||||
grub_cmd_sleep (grub_extcmd_t cmd, int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
grub_uint16_t xy;
|
||||
int n;
|
||||
|
||||
|
@ -99,14 +100,17 @@ grub_cmd_sleep (struct grub_arg_list *state, int argc, char **args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(sleep)
|
||||
{
|
||||
grub_register_command ("sleep", grub_cmd_sleep, GRUB_COMMAND_FLAG_BOTH,
|
||||
"sleep NUMBER_OF_SECONDS", "Wait for a specified number of seconds", options);
|
||||
cmd = grub_register_extcmd ("sleep", grub_cmd_sleep, GRUB_COMMAND_FLAG_BOTH,
|
||||
"sleep NUMBER_OF_SECONDS",
|
||||
"Wait for a specified number of seconds",
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(sleep)
|
||||
{
|
||||
grub_unregister_command ("sleep");
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
||||
|
|
|
@ -17,17 +17,15 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_test (struct grub_arg_list *state __attribute__ ((unused)), int argc,
|
||||
char **args)
|
||||
|
||||
grub_cmd_test (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
char *eq;
|
||||
char *eqis;
|
||||
|
@ -52,19 +50,19 @@ grub_cmd_test (struct grub_arg_list *state __attribute__ ((unused)), int argc,
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
static grub_command_t cmd_1, cmd_2;
|
||||
|
||||
GRUB_MOD_INIT(test)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("[", grub_cmd_test, GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"[ EXPRESSION ]", "Evaluate an expression", 0);
|
||||
grub_register_command ("test", grub_cmd_test, GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"test EXPRESSION", "Evaluate an expression", 0);
|
||||
cmd_1 = grub_register_command ("[", grub_cmd_test,
|
||||
"[ EXPRESSION ]", "Evaluate an expression");
|
||||
cmd_2 = grub_register_command ("test", grub_cmd_test,
|
||||
"test EXPRESSION", "Evaluate an expression");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(test)
|
||||
{
|
||||
grub_unregister_command ("[");
|
||||
grub_unregister_command ("test");
|
||||
grub_unregister_command (cmd_1);
|
||||
grub_unregister_command (cmd_2);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/usb.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static const char *usb_classes[] =
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ usb_iterate (grub_usb_device_t dev)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_usbtest (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_usbtest (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -147,14 +147,16 @@ grub_cmd_usbtest (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(usbtest)
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("usb", grub_cmd_usbtest, GRUB_COMMAND_FLAG_BOTH,
|
||||
"usb", "Test USB support", 0);
|
||||
cmd = grub_register_command ("usb", grub_cmd_usbtest,
|
||||
0, "Test USB support");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(usbtest)
|
||||
{
|
||||
grub_unregister_command ("usb");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -20,14 +20,13 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/arg.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_videotest (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -175,17 +174,15 @@ grub_cmd_videotest (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(videotest)
|
||||
{
|
||||
grub_register_command ("videotest",
|
||||
grub_cmd_videotest,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"videotest",
|
||||
"Test video subsystem",
|
||||
0);
|
||||
cmd = grub_register_command ("videotest", grub_cmd_videotest,
|
||||
0, "Test video subsystem");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(videotest)
|
||||
{
|
||||
grub_unregister_command ("videotest");
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue