2010-01-15 Vladimir Serbinenko <phcoder@gmail.com>

Video multiboot support.

	* include/grub/multiboot.h (grub_multiboot_set_accepts_video):
	New prototype.
	* include/multiboot.h: Resynced with multiboot specification.
	* include/multiboot2.h: Likewise.
	* loader/i386/multiboot.c (UNSUPPORTED_FLAGS): Support video flags.
	(grub_multiboot): Parse MULTIBOOT_VIDEO_MODE fields.
	* loader/i386/multiboot_mbi.c (DEFAULT_VIDEO_MODE): New constant.
	(HAS_VGA_TEXT): Likewise.
	(accepts_video): New variable.
	(grub_multiboot_set_accepts_video): New function.
	(grub_multiboot_get_mbi_size): Account for video structures.
	(set_video_mode): New function.
	(retrieve_video_parameters): Likewise.
	(grub_multiboot_make_mbi): Fill video fields.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-01-15 16:30:57 +01:00
parent 0d90e8a6fb
commit 884ade5654
6 changed files with 252 additions and 8 deletions

View file

@ -28,13 +28,11 @@
*/
/* The bits in the required part of flags field we don't support. */
#define UNSUPPORTED_FLAGS 0x0000fffc
#define UNSUPPORTED_FLAGS 0x0000fff8
#include <grub/loader.h>
#include <grub/machine/loader.h>
#include <grub/multiboot.h>
#include <grub/machine/init.h>
#include <grub/machine/memory.h>
#include <grub/cpu/multiboot.h>
#include <grub/elf.h>
#include <grub/aout.h>
@ -90,8 +88,6 @@ grub_multiboot_boot (void)
if (err)
return err;
grub_video_set_mode ("text", NULL);
grub_relocator32_boot (grub_multiboot_payload_orig,
grub_multiboot_payload_dest,
state);
@ -235,6 +231,34 @@ grub_multiboot (int argc, char *argv[])
else if (grub_multiboot_load_elf (file, buffer) != GRUB_ERR_NONE)
goto fail;
if (header->flags & MULTIBOOT_VIDEO_MODE)
{
switch (header->mode_type)
{
case 1:
grub_env_set ("gfxpayload", "text");
break;
case 0:
{
char buf[sizeof ("XXXXXXXXXXxXXXXXXXXXXxXXXXXXXXXX,XXXXXXXXXXxXXXXXXXXXX,auto")];
if (header->depth && header->width && header->height)
grub_sprintf (buf, "%dx%dx%d,%dx%d,auto", header->width,
header->height, header->depth, header->width,
header->height);
else if (header->width && header->height)
grub_sprintf (buf, "%dx%d,auto", header->width, header->height);
else
grub_sprintf (buf, "auto");
grub_env_set ("gfxpayload", buf);
break;
}
}
}
grub_multiboot_set_accepts_video (!!(header->flags & MULTIBOOT_VIDEO_MODE));
grub_multiboot_set_bootdev ();
grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0);