merge mainline into newreloc
This commit is contained in:
commit
262355247f
44 changed files with 1520 additions and 62 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2008,2009,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
|
||||
|
@ -35,6 +35,7 @@
|
|||
#include <grub/i18n.h>
|
||||
#include <grub/i386/pc/serial.h>
|
||||
|
||||
#include <grub/video.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
#endif
|
||||
|
@ -599,6 +600,8 @@ grub_freebsd_boot (void)
|
|||
|
||||
bi.bi_kernend = kern_end;
|
||||
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
if (is_64bit)
|
||||
{
|
||||
struct grub_relocator64_state state;
|
||||
|
@ -773,6 +776,8 @@ grub_openbsd_boot (void)
|
|||
stack[7] = argbuf_target_end - argbuf_target_start;
|
||||
stack[8] = argbuf_target_start;
|
||||
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
return grub_relocator32_boot (relocator, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* multiboot.c - boot a multiboot OS image. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,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
|
||||
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
/* The bits in the required part of flags field we don't support. */
|
||||
#define UNSUPPORTED_FLAGS 0x0000fff0
|
||||
#define UNSUPPORTED_FLAGS 0x0000fff8
|
||||
|
||||
#include <grub/loader.h>
|
||||
#include <grub/multiboot.h>
|
||||
|
@ -43,6 +43,11 @@
|
|||
#include <grub/gzio.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/i386/relocator.h>
|
||||
#include <grub/video.h>
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
#include <grub/efi/efi.h>
|
||||
#endif
|
||||
|
||||
extern grub_dl_t my_mod;
|
||||
struct grub_relocator *grub_multiboot_relocator = NULL;
|
||||
|
@ -67,6 +72,11 @@ grub_multiboot_boot (void)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
if (! grub_efi_finish_boot_services ())
|
||||
grub_fatal ("cannot exit boot services");
|
||||
#endif
|
||||
|
||||
grub_relocator32_boot (grub_multiboot_relocator, state);
|
||||
|
||||
/* Not reached. */
|
||||
|
@ -211,6 +221,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);
|
||||
|
|
|
@ -29,6 +29,16 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/relocator.h>
|
||||
#include <grub/video.h>
|
||||
|
||||
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
|
||||
#include <grub/i386/pc/vbe.h>
|
||||
#define DEFAULT_VIDEO_MODE "text"
|
||||
#define HAS_VGA_TEXT 1
|
||||
#else
|
||||
#define DEFAULT_VIDEO_MODE "auto"
|
||||
#define HAS_VGA_TEXT 0
|
||||
#endif
|
||||
|
||||
struct module
|
||||
{
|
||||
|
@ -49,6 +59,13 @@ static int bootdev_set;
|
|||
static grub_size_t elf_sec_num, elf_sec_entsize;
|
||||
static unsigned elf_sec_shstrndx;
|
||||
static void *elf_sections;
|
||||
static int accepts_video;
|
||||
|
||||
void
|
||||
grub_multiboot_set_accepts_video (int val)
|
||||
{
|
||||
accepts_video = val;
|
||||
}
|
||||
|
||||
/* Return the length of the Multiboot mmap that will be needed to allocate
|
||||
our platform's map. */
|
||||
|
@ -77,7 +94,8 @@ grub_multiboot_get_mbi_size (void)
|
|||
return sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4)
|
||||
+ modcnt * sizeof (struct multiboot_mod_list) + total_modcmd
|
||||
+ ALIGN_UP (sizeof(PACKAGE_STRING), 4) + grub_get_multiboot_mmap_len ()
|
||||
+ elf_sec_entsize * elf_sec_num;
|
||||
+ elf_sec_entsize * elf_sec_num
|
||||
+ 256 * sizeof (struct multiboot_color);
|
||||
}
|
||||
|
||||
/* Fill previously allocated Multiboot mmap. */
|
||||
|
@ -110,6 +128,107 @@ grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry)
|
|||
grub_mmap_iterate (hook);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
set_video_mode (void)
|
||||
{
|
||||
grub_err_t err;
|
||||
const char *modevar;
|
||||
|
||||
if (accepts_video || !HAS_VGA_TEXT)
|
||||
{
|
||||
modevar = grub_env_get ("gfxpayload");
|
||||
if (! modevar || *modevar == 0)
|
||||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0, 0);
|
||||
else
|
||||
{
|
||||
char *tmp;
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
+ sizeof (DEFAULT_VIDEO_MODE) + 1);
|
||||
if (! tmp)
|
||||
return grub_errno;
|
||||
grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||
err = grub_video_set_mode (tmp, 0, 0);
|
||||
grub_free (tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
err = grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
retrieve_video_parameters (struct multiboot_info *mbi,
|
||||
grub_uint8_t *ptrorig, grub_uint32_t ptrdest)
|
||||
{
|
||||
grub_err_t err;
|
||||
struct grub_video_mode_info mode_info;
|
||||
void *framebuffer;
|
||||
grub_video_driver_id_t driv_id;
|
||||
struct grub_video_palette_data palette[256];
|
||||
|
||||
err = set_video_mode ();
|
||||
if (err)
|
||||
{
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_video_get_palette (0, ARRAY_SIZE (palette), palette);
|
||||
|
||||
driv_id = grub_video_get_driver_id ();
|
||||
if (driv_id == GRUB_VIDEO_DRIVER_NONE)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mbi->framebuffer_addr = (grub_addr_t) framebuffer;
|
||||
mbi->framebuffer_pitch = mode_info.pitch;
|
||||
|
||||
mbi->framebuffer_width = mode_info.width;
|
||||
mbi->framebuffer_height = mode_info.height;
|
||||
|
||||
mbi->framebuffer_bpp = mode_info.bpp;
|
||||
|
||||
if (mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
|
||||
{
|
||||
struct multiboot_color *mb_palette;
|
||||
unsigned i;
|
||||
mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED;
|
||||
mbi->framebuffer_palette_addr = ptrdest;
|
||||
mbi->framebuffer_palette_num_colors = mode_info.number_of_colors;
|
||||
if (mbi->framebuffer_palette_num_colors > ARRAY_SIZE (palette))
|
||||
mbi->framebuffer_palette_num_colors = ARRAY_SIZE (palette);
|
||||
mb_palette = (struct multiboot_color *) ptrorig;
|
||||
for (i = 0; i < mbi->framebuffer_palette_num_colors; i++)
|
||||
{
|
||||
mb_palette[i].red = palette[i].r;
|
||||
mb_palette[i].green = palette[i].g;
|
||||
mb_palette[i].blue = palette[i].b;
|
||||
}
|
||||
ptrorig += mbi->framebuffer_palette_num_colors
|
||||
* sizeof (struct multiboot_color);
|
||||
ptrdest += mbi->framebuffer_palette_num_colors
|
||||
* sizeof (struct multiboot_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_RGB;
|
||||
mbi->framebuffer_red_field_position = mode_info.green_field_pos;
|
||||
mbi->framebuffer_red_mask_size = mode_info.green_mask_size;
|
||||
mbi->framebuffer_green_field_position = mode_info.green_field_pos;
|
||||
mbi->framebuffer_green_mask_size = mode_info.green_mask_size;
|
||||
mbi->framebuffer_blue_field_position = mode_info.blue_field_pos;
|
||||
mbi->framebuffer_blue_mask_size = mode_info.blue_mask_size;
|
||||
}
|
||||
|
||||
mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_multiboot_make_mbi (grub_uint32_t *target)
|
||||
{
|
||||
|
@ -207,6 +326,13 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
|
|||
mbi->flags |= MULTIBOOT_INFO_ELF_SHDR;
|
||||
}
|
||||
|
||||
err = retrieve_video_parameters (mbi, ptrorig, ptrdest);
|
||||
if (err)
|
||||
{
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* chainloader.c - boot another boot loader */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,2007,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2002,2004,2007,2009,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
|
||||
|
@ -33,6 +33,8 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/machine/biosnum.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
static int boot_drive;
|
||||
|
@ -41,6 +43,7 @@ static void *boot_part_addr;
|
|||
static grub_err_t
|
||||
grub_chainloader_boot (void)
|
||||
{
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
grub_chainloader_real_boot (boot_drive, boot_part_addr);
|
||||
|
||||
/* Never reach here. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* linux.c - boot Linux zImage or bzImage */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,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
|
||||
|
@ -33,6 +33,7 @@
|
|||
#include <grub/i18n.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/cpu/relocator.h>
|
||||
#include <grub/video.h>
|
||||
|
||||
#define GRUB_LINUX_CL_OFFSET 0x9000
|
||||
#define GRUB_LINUX_CL_END_OFFSET 0x90FF
|
||||
|
@ -57,6 +58,8 @@ grub_linux16_boot (void)
|
|||
state.sp = GRUB_LINUX_SETUP_STACK;
|
||||
state.cs = segment + 0x20;
|
||||
state.ip = 0;
|
||||
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
return grub_relocator16_boot (relocator, state);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue