Support vbeprobe MODE

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-15 14:37:28 +02:00
parent c99dead654
commit 3f8fcb6a24
2 changed files with 45 additions and 9 deletions

View file

@ -25,9 +25,17 @@
#include <grub/command.h> #include <grub/command.h>
#include <grub/i18n.h> #include <grub/i18n.h>
static unsigned height, width, depth;
static int static int
hook (const struct grub_video_mode_info *info) hook (const struct grub_video_mode_info *info)
{ {
if (height && width && (info->width != width || info->height != height))
return 0;
if (depth && info->bpp != depth)
return 0;
if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID) if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID)
grub_printf (" "); grub_printf (" ");
else else
@ -71,12 +79,34 @@ hook (const struct grub_video_mode_info *info)
static grub_err_t static grub_err_t
grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)), grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc, char **args)
char **args __attribute__ ((unused)))
{ {
grub_video_adapter_t adapter; grub_video_adapter_t adapter;
grub_video_driver_id_t id; grub_video_driver_id_t id;
height = width = depth = 0;
if (argc)
{
char *ptr;
ptr = args[0];
width = grub_strtoul (ptr, &ptr, 0);
if (grub_errno)
return grub_errno;
if (*ptr != 'x')
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid mode specification");
ptr++;
height = grub_strtoul (ptr, &ptr, 0);
if (grub_errno)
return grub_errno;
if (*ptr == 'x')
{
ptr++;
depth = grub_strtoul (ptr, &ptr, 0);
if (grub_errno)
return grub_errno;
}
}
#ifdef GRUB_MACHINE_PCBIOS #ifdef GRUB_MACHINE_PCBIOS
if (grub_strcmp (cmd->name, "vbeinfo") == 0) if (grub_strcmp (cmd->name, "vbeinfo") == 0)
grub_dl_load ("vbe"); grub_dl_load ("vbe");
@ -132,11 +162,15 @@ static grub_command_t cmd_vbe;
GRUB_MOD_INIT(videoinfo) GRUB_MOD_INIT(videoinfo)
{ {
cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo, 0, cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo, "[WxH[xD]]",
N_("List available video modes.")); N_("List available video modes. If "
"resolution is given show only modes"
" matching it."));
#ifdef GRUB_MACHINE_PCBIOS #ifdef GRUB_MACHINE_PCBIOS
cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, 0, cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, "[WxH[xD]]",
N_("List available video modes.")); N_("List available video modes. If "
"resolution is given show only modes"
" matching it."));
#endif #endif
} }

View file

@ -292,10 +292,12 @@ struct legacy_command legacy_commands[] =
/* FIXME: uppermem unsupported. */ /* FIXME: uppermem unsupported. */
{"uuid", "search --set=root --fs-uuid '%s'\n", NULL, 0, 1, {TYPE_VERBATIM}, {"uuid", "search --set=root --fs-uuid '%s'\n", NULL, 0, 1, {TYPE_VERBATIM},
0, "UUID", "Find root by UUID"}, 0, "UUID", "Find root by UUID"},
/* FIXME: support MODE. */ {"vbeprobe", "insmod vbe; videoinfo '%s'\n", NULL, 0, 1, {TYPE_VBE_MODE},
{"vbeprobe", "insmod vbe; videoinfo\n", NULL, 0, 0, {}, 0, "[MODE]", FLAG_FALLBACK_AVAILABLE, "[MODE]",
"Probe VBE information. If the mode number MODE is specified, show only" "Probe VBE information. If the mode number MODE is specified, show only"
" the information about only the mode."} " the information about only the mode."},
{"vbeprobe", "insmod vbe; videoinfo\n", NULL, 0, 0, {},
FLAG_FALLBACK, NULL, NULL}
}; };
char * char *