* util/grub-mkconfig.in: Capitalise and export GRUB_PREFIX. Stop
setting GRUB_VIDEO_BACKEND. Make it available as a user override instead. Replace the gfxterm backend check with a check that ${GRUB_PREFIX}/video.lst is non-empty. * util/grub.d/00_header.in: Use GRUB_PREFIX rather than computing it again. (load_video): New generated function. Call it before loading gfxterm rather than loading ${GRUB_VIDEO_BACKEND}. * util/grub.d/10_linux.in (linux_entry): Call load_video. * util/grub.d/30_os-prober.in (osx_entry): Likewise. * docs/grub.texi (Simple configuration): Document GRUB_VIDEO_BACKEND. Use video functions in linux and xnu loaders. * conf/i386-pc.rmk (xnu_mod_SOURCES): Remove loader/i386/pc/xnu.c. * conf/x86-efi.rmk (xnu_mod_SOURCES): Remove loader/i386/efi/xnu.c. * include/grub/i386/xnu.h (grub_xnu_set_video): Removed. * loader/i386/efi/linux.c (grub_linux_setup_video): Copied from loader/i386/pc/linux.c. (grub_linux_boot): Resynced with loader/i386/pc/linux.c. (find_line_len): Removed. (find_framebuf): Likewise. (grub_cmd_linux): Declare grub_linux_boot as possibly returning. * loader/i386/efi/xnu.c: Removed. * loader/i386/pc/xnu.c: Moved from here... * loader/i386/xnu.c: ...here. Enable priorities in video drivers. * include/grub/video.h (grub_video_adapter_prio_t): New type. (grub_video_adapter): New field prio. (grub_video_register): Respect prio when inserting. * video/efi_gop.c (grub_video_gop_adapter): Add prio. * video/efi_uga.c (grub_video_uga_adapter): Likewise. * video/emu/sdl.c (grub_video_sdl_adapter): Likewise. * video/i386/pc/vbe.c (grub_video_vbe_adapter): Likewise. * video/i386/pc/vga.c (grub_video_vga_adapter): Likewise. * video/ieee1275.c (grub_video_ieee1275_adapter): Likewise. * video/sm712.c (grub_video_sm712_adapter): Likewise. Fix SDL driver ID. * include/grub/video.h (grub_video_driver_id_t): New value GRUB_VIDEO_DRIVER_SDL. * video/emu/sdl.c (grub_video_sdl_adapter): Add id. Also-By: Vladimir Serbinenko <phcoder@gmail.com>
This commit is contained in:
commit
4321c64aff
21 changed files with 325 additions and 497 deletions
51
ChangeLog
51
ChangeLog
|
@ -1,3 +1,54 @@
|
||||||
|
2010-06-20 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
* util/grub-mkconfig.in: Capitalise and export GRUB_PREFIX. Stop
|
||||||
|
setting GRUB_VIDEO_BACKEND. Make it available as a user override
|
||||||
|
instead. Replace the gfxterm backend check with a check that
|
||||||
|
${GRUB_PREFIX}/video.lst is non-empty.
|
||||||
|
* util/grub.d/00_header.in: Use GRUB_PREFIX rather than computing it
|
||||||
|
again.
|
||||||
|
(load_video): New generated function. Call it before loading
|
||||||
|
gfxterm rather than loading ${GRUB_VIDEO_BACKEND}.
|
||||||
|
* util/grub.d/10_linux.in (linux_entry): Call load_video.
|
||||||
|
* util/grub.d/30_os-prober.in (osx_entry): Likewise.
|
||||||
|
* docs/grub.texi (Simple configuration): Document
|
||||||
|
GRUB_VIDEO_BACKEND.
|
||||||
|
|
||||||
|
2010-06-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Use video functions in linux and xnu loaders.
|
||||||
|
|
||||||
|
* conf/i386-pc.rmk (xnu_mod_SOURCES): Remove loader/i386/pc/xnu.c.
|
||||||
|
* conf/x86-efi.rmk (xnu_mod_SOURCES): Remove loader/i386/efi/xnu.c.
|
||||||
|
* include/grub/i386/xnu.h (grub_xnu_set_video): Removed.
|
||||||
|
* loader/i386/efi/linux.c (grub_linux_setup_video): Copied from
|
||||||
|
loader/i386/pc/linux.c.
|
||||||
|
(grub_linux_boot): Resynced with loader/i386/pc/linux.c.
|
||||||
|
(find_line_len): Removed.
|
||||||
|
(find_framebuf): Likewise.
|
||||||
|
(grub_cmd_linux): Declare grub_linux_boot as possibly returning.
|
||||||
|
* loader/i386/efi/xnu.c: Removed.
|
||||||
|
* loader/i386/pc/xnu.c: Moved from here...
|
||||||
|
* loader/i386/xnu.c: ...here.
|
||||||
|
|
||||||
|
Enable priorities in video drivers.
|
||||||
|
|
||||||
|
* include/grub/video.h (grub_video_adapter_prio_t): New type.
|
||||||
|
(grub_video_adapter): New field prio.
|
||||||
|
(grub_video_register): Respect prio when inserting.
|
||||||
|
* video/efi_gop.c (grub_video_gop_adapter): Add prio.
|
||||||
|
* video/efi_uga.c (grub_video_uga_adapter): Likewise.
|
||||||
|
* video/emu/sdl.c (grub_video_sdl_adapter): Likewise.
|
||||||
|
* video/i386/pc/vbe.c (grub_video_vbe_adapter): Likewise.
|
||||||
|
* video/i386/pc/vga.c (grub_video_vga_adapter): Likewise.
|
||||||
|
* video/ieee1275.c (grub_video_ieee1275_adapter): Likewise.
|
||||||
|
* video/sm712.c (grub_video_sm712_adapter): Likewise.
|
||||||
|
|
||||||
|
Fix SDL driver ID.
|
||||||
|
|
||||||
|
* include/grub/video.h (grub_video_driver_id_t): New value
|
||||||
|
GRUB_VIDEO_DRIVER_SDL.
|
||||||
|
* video/emu/sdl.c (grub_video_sdl_adapter): Add id.
|
||||||
|
|
||||||
2010-06-17 Colin Watson <cjwatson@ubuntu.com>
|
2010-06-17 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
* util/i386/pc/grub-setup.c (usage): Pass an extra `program_name'
|
* util/i386/pc/grub-setup.c (usage): Pass an extra `program_name'
|
||||||
|
|
|
@ -147,7 +147,7 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
pkglib_MODULES += xnu.mod
|
pkglib_MODULES += xnu.mod
|
||||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c \
|
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
|
||||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
||||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
|
@ -102,7 +102,7 @@ efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
pkglib_MODULES += xnu.mod
|
pkglib_MODULES += xnu.mod
|
||||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
|
||||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
||||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
|
@ -934,6 +934,16 @@ Disable the generation of recovery mode menu entries for Linux.
|
||||||
@item GRUB_DISABLE_NETBSD_RECOVERY
|
@item GRUB_DISABLE_NETBSD_RECOVERY
|
||||||
Disable the generation of recovery mode menu entries for NetBSD.
|
Disable the generation of recovery mode menu entries for NetBSD.
|
||||||
|
|
||||||
|
@item GRUB_VIDEO_BACKEND
|
||||||
|
If graphical video support is required, either because the @samp{gfxterm}
|
||||||
|
graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
|
||||||
|
then @command{grub-mkconfig} will normally load all available GRUB video
|
||||||
|
drivers and use the one most appropriate for your hardware. If you need to
|
||||||
|
override this for some reason, then you can set this option.
|
||||||
|
|
||||||
|
After @command{grub-install} has been run, the available video drivers are
|
||||||
|
listed in @file{/boot/grub/video.lst}.
|
||||||
|
|
||||||
@item GRUB_GFXMODE
|
@item GRUB_GFXMODE
|
||||||
Set the resolution used on the @samp{gfxterm} graphical terminal. Note that
|
Set the resolution used on the @samp{gfxterm} graphical terminal. Note that
|
||||||
you can only use modes which your graphics card supports via VESA BIOS
|
you can only use modes which your graphics card supports via VESA BIOS
|
||||||
|
|
|
@ -114,8 +114,6 @@ extern grub_uint32_t grub_xnu_stack;
|
||||||
extern grub_uint32_t grub_xnu_arg1;
|
extern grub_uint32_t grub_xnu_arg1;
|
||||||
extern char grub_xnu_cmdline[1024];
|
extern char grub_xnu_cmdline[1024];
|
||||||
grub_err_t grub_xnu_boot (void);
|
grub_err_t grub_xnu_boot (void);
|
||||||
grub_err_t grub_xnu_set_video (struct grub_xnu_boot_params *bootparams_relloc);
|
grub_err_t grub_cpu_xnu_fill_devicetree (void);
|
||||||
grub_err_t
|
|
||||||
grub_cpu_xnu_fill_devicetree (void);
|
|
||||||
extern grub_uint32_t grub_xnu_heap_will_be_at;
|
extern grub_uint32_t grub_xnu_heap_will_be_at;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -183,9 +183,19 @@ typedef enum grub_video_driver_id
|
||||||
GRUB_VIDEO_DRIVER_EFI_UGA,
|
GRUB_VIDEO_DRIVER_EFI_UGA,
|
||||||
GRUB_VIDEO_DRIVER_EFI_GOP,
|
GRUB_VIDEO_DRIVER_EFI_GOP,
|
||||||
GRUB_VIDEO_DRIVER_SM712,
|
GRUB_VIDEO_DRIVER_SM712,
|
||||||
GRUB_VIDEO_DRIVER_VGA
|
GRUB_VIDEO_DRIVER_VGA,
|
||||||
|
GRUB_VIDEO_DRIVER_SDL
|
||||||
} grub_video_driver_id_t;
|
} grub_video_driver_id_t;
|
||||||
|
|
||||||
|
typedef enum grub_video_adapter_prio
|
||||||
|
{
|
||||||
|
GRUB_VIDEO_ADAPTER_PRIO_FALLBACK = 60,
|
||||||
|
GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY = 70,
|
||||||
|
GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE = 80,
|
||||||
|
GRUB_VIDEO_ADAPTER_PRIO_NATIVE = 100
|
||||||
|
} grub_video_adapter_prio_t;
|
||||||
|
|
||||||
|
|
||||||
struct grub_video_adapter
|
struct grub_video_adapter
|
||||||
{
|
{
|
||||||
/* The next video adapter. */
|
/* The next video adapter. */
|
||||||
|
@ -195,6 +205,8 @@ struct grub_video_adapter
|
||||||
const char *name;
|
const char *name;
|
||||||
grub_video_driver_id_t id;
|
grub_video_driver_id_t id;
|
||||||
|
|
||||||
|
grub_video_adapter_prio_t prio;
|
||||||
|
|
||||||
/* Initialize the video adapter. */
|
/* Initialize the video adapter. */
|
||||||
grub_err_t (*init) (void);
|
grub_err_t (*init) (void);
|
||||||
|
|
||||||
|
@ -269,8 +281,11 @@ extern grub_video_adapter_t EXPORT_VAR(grub_video_adapter_list);
|
||||||
static inline void
|
static inline void
|
||||||
grub_video_register (grub_video_adapter_t adapter)
|
grub_video_register (grub_video_adapter_t adapter)
|
||||||
{
|
{
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_video_adapter_list),
|
grub_video_adapter_t *p;
|
||||||
GRUB_AS_LIST (adapter));
|
for (p = &grub_video_adapter_list; *p && (*p)->prio > adapter->prio;
|
||||||
|
p = &((*p)->next));
|
||||||
|
adapter->next = *p;
|
||||||
|
*p = adapter;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,11 @@
|
||||||
#include <grub/cpu/linux.h>
|
#include <grub/cpu/linux.h>
|
||||||
#include <grub/efi/api.h>
|
#include <grub/efi/api.h>
|
||||||
#include <grub/efi/efi.h>
|
#include <grub/efi/efi.h>
|
||||||
#include <grub/efi/uga_draw.h>
|
|
||||||
#include <grub/pci.h>
|
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/video.h>
|
||||||
|
#include <grub/time.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
#define GRUB_LINUX_CL_OFFSET 0x1000
|
#define GRUB_LINUX_CL_OFFSET 0x1000
|
||||||
|
@ -286,6 +287,67 @@ grub_e820_add_region (struct grub_e820_mmap *e820_map, int *e820_num,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_linux_setup_video (struct linux_kernel_params *params)
|
||||||
|
{
|
||||||
|
struct grub_video_mode_info mode_info;
|
||||||
|
void *framebuffer;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
|
err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
params->lfb_width = mode_info.width;
|
||||||
|
params->lfb_height = mode_info.height;
|
||||||
|
params->lfb_depth = mode_info.bpp;
|
||||||
|
params->lfb_line_len = mode_info.pitch;
|
||||||
|
|
||||||
|
params->lfb_base = (grub_size_t) framebuffer;
|
||||||
|
params->lfb_size = ALIGN_UP (params->lfb_line_len * params->lfb_height,
|
||||||
|
65536);
|
||||||
|
|
||||||
|
params->red_mask_size = mode_info.red_mask_size;
|
||||||
|
params->red_field_pos = mode_info.red_field_pos;
|
||||||
|
params->green_mask_size = mode_info.green_mask_size;
|
||||||
|
params->green_field_pos = mode_info.green_field_pos;
|
||||||
|
params->blue_mask_size = mode_info.blue_mask_size;
|
||||||
|
params->blue_field_pos = mode_info.blue_field_pos;
|
||||||
|
params->reserved_mask_size = mode_info.reserved_mask_size;
|
||||||
|
params->reserved_field_pos = mode_info.reserved_field_pos;
|
||||||
|
|
||||||
|
params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_PCBIOS
|
||||||
|
/* VESA packed modes may come with zeroed mask sizes, which need
|
||||||
|
to be set here according to DAC Palette width. If we don't,
|
||||||
|
this results in Linux displaying a black screen. */
|
||||||
|
if (mode_info.bpp <= 8)
|
||||||
|
{
|
||||||
|
struct grub_vbe_info_block controller_info;
|
||||||
|
int status;
|
||||||
|
int width = 8;
|
||||||
|
|
||||||
|
status = grub_vbe_bios_get_controller_info (&controller_info);
|
||||||
|
|
||||||
|
if (status == GRUB_VBE_STATUS_OK &&
|
||||||
|
(controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH))
|
||||||
|
status = grub_vbe_bios_set_dac_palette_width (&width);
|
||||||
|
|
||||||
|
if (status != GRUB_VBE_STATUS_OK)
|
||||||
|
/* 6 is default after mode reset. */
|
||||||
|
width = 6;
|
||||||
|
|
||||||
|
params->red_mask_size = params->green_mask_size
|
||||||
|
= params->blue_mask_size = width;
|
||||||
|
params->reserved_mask_size = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
extern grub_uint8_t grub_linux_trampoline_start[];
|
extern grub_uint8_t grub_linux_trampoline_start[];
|
||||||
extern grub_uint8_t grub_linux_trampoline_end[];
|
extern grub_uint8_t grub_linux_trampoline_end[];
|
||||||
|
@ -300,6 +362,9 @@ grub_linux_boot (void)
|
||||||
grub_efi_uintn_t desc_size;
|
grub_efi_uintn_t desc_size;
|
||||||
grub_efi_uint32_t desc_version;
|
grub_efi_uint32_t desc_version;
|
||||||
int e820_num;
|
int e820_num;
|
||||||
|
const char *modevar;
|
||||||
|
char *tmp;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
params = real_mode_mem;
|
params = real_mode_mem;
|
||||||
|
|
||||||
|
@ -353,6 +418,35 @@ grub_linux_boot (void)
|
||||||
grub_mmap_iterate (hook);
|
grub_mmap_iterate (hook);
|
||||||
params->mmap_size = e820_num;
|
params->mmap_size = e820_num;
|
||||||
|
|
||||||
|
grub_printf ("Trampoline at %p. code32=%x, real_mode_mem=%p\n",
|
||||||
|
((char *) prot_mode_mem + (prot_mode_pages << 12)),
|
||||||
|
(unsigned) params->code32_start, real_mode_mem);
|
||||||
|
|
||||||
|
modevar = grub_env_get ("gfxpayload");
|
||||||
|
|
||||||
|
/* Now all graphical modes are acceptable.
|
||||||
|
May change in future if we have modes without framebuffer. */
|
||||||
|
if (modevar && *modevar != 0)
|
||||||
|
{
|
||||||
|
tmp = grub_xasprintf ("%s;auto", modevar);
|
||||||
|
if (! tmp)
|
||||||
|
return grub_errno;
|
||||||
|
err = grub_video_set_mode (tmp, GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||||
|
grub_free (tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
err = grub_video_set_mode ("auto", GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
err = grub_linux_setup_video (params);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
grub_print_error ();
|
||||||
|
grub_printf ("Booting however\n");
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
mmap_size = find_mmap_size ();
|
mmap_size = find_mmap_size ();
|
||||||
if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key,
|
if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key,
|
||||||
&desc_size, &desc_version) <= 0)
|
&desc_size, &desc_version) <= 0)
|
||||||
|
@ -425,174 +519,6 @@ grub_linux_unload (void)
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
|
|
||||||
|
|
||||||
|
|
||||||
#define RGB_MASK 0xffffff
|
|
||||||
#define RGB_MAGIC 0x121314
|
|
||||||
#define LINE_MIN 800
|
|
||||||
#define LINE_MAX 4096
|
|
||||||
#define FBTEST_STEP (0x10000 >> 2)
|
|
||||||
#define FBTEST_COUNT 8
|
|
||||||
|
|
||||||
static int
|
|
||||||
find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
|
||||||
{
|
|
||||||
grub_uint32_t *base = (grub_uint32_t *) (grub_target_addr_t) *fb_base;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < FBTEST_COUNT; i++, base += FBTEST_STEP)
|
|
||||||
{
|
|
||||||
if ((*base & RGB_MASK) == RGB_MAGIC)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = LINE_MIN; j <= LINE_MAX; j++)
|
|
||||||
{
|
|
||||||
if ((base[j] & RGB_MASK) == RGB_MAGIC)
|
|
||||||
{
|
|
||||||
*fb_base = (grub_uint32_t) (grub_target_addr_t) base;
|
|
||||||
*line_len = j << 2;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
|
||||||
{
|
|
||||||
int found = 0;
|
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
|
||||||
grub_pci_id_t pciid);
|
|
||||||
|
|
||||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
|
||||||
grub_pci_id_t pciid)
|
|
||||||
{
|
|
||||||
grub_pci_address_t addr;
|
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
|
||||||
if (grub_pci_read (addr) >> 24 == 0x3)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
grub_printf ("Display controller: %d:%d.%d\nDevice id: %x\n",
|
|
||||||
grub_pci_get_bus (dev), grub_pci_get_device (dev),
|
|
||||||
grub_pci_get_function (dev), pciid);
|
|
||||||
addr += 8;
|
|
||||||
for (i = 0; i < 6; i++, addr += 4)
|
|
||||||
{
|
|
||||||
grub_uint32_t old_bar1, old_bar2, type;
|
|
||||||
grub_uint64_t base64;
|
|
||||||
|
|
||||||
old_bar1 = grub_pci_read (addr);
|
|
||||||
if ((! old_bar1) || (old_bar1 & GRUB_PCI_ADDR_SPACE_IO))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
type = old_bar1 & GRUB_PCI_ADDR_MEM_TYPE_MASK;
|
|
||||||
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
|
|
||||||
{
|
|
||||||
if (i == 5)
|
|
||||||
break;
|
|
||||||
|
|
||||||
old_bar2 = grub_pci_read (addr + 4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
old_bar2 = 0;
|
|
||||||
|
|
||||||
base64 = old_bar2;
|
|
||||||
base64 <<= 32;
|
|
||||||
base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK);
|
|
||||||
|
|
||||||
grub_printf ("%s(%d): 0x%llx\n",
|
|
||||||
((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ?
|
|
||||||
"VMEM" : "MMIO"), i,
|
|
||||||
(unsigned long long) base64);
|
|
||||||
|
|
||||||
if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! found))
|
|
||||||
{
|
|
||||||
*fb_base = base64;
|
|
||||||
if (find_line_len (fb_base, line_len))
|
|
||||||
found++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
addr += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_pci_iterate (find_card);
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
grub_linux_setup_video (struct linux_kernel_params *params)
|
|
||||||
{
|
|
||||||
grub_efi_uga_draw_protocol_t *c;
|
|
||||||
grub_uint32_t width, height, depth, rate, pixel, fb_base, line_len;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
c = grub_efi_locate_protocol (&uga_draw_guid, 0);
|
|
||||||
if (! c)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (efi_call_5 (c->get_mode, c, &width, &height, &depth, &rate))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
grub_printf ("Video mode: %ux%u-%u@%u\n", width, height, depth, rate);
|
|
||||||
|
|
||||||
grub_efi_set_text_mode (0);
|
|
||||||
pixel = RGB_MAGIC;
|
|
||||||
efi_call_10 (c->blt, c, (struct grub_efi_uga_pixel *) &pixel,
|
|
||||||
GRUB_EFI_UGA_VIDEO_FILL, 0, 0, 0, 0, 1, height, 0);
|
|
||||||
ret = find_framebuf (&fb_base, &line_len);
|
|
||||||
grub_efi_set_text_mode (1);
|
|
||||||
|
|
||||||
if (! ret)
|
|
||||||
{
|
|
||||||
grub_printf ("Can\'t find frame buffer address\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_printf ("Frame buffer base: 0x%x\n", fb_base);
|
|
||||||
grub_printf ("Video line length: %d\n", line_len);
|
|
||||||
|
|
||||||
params->lfb_width = width;
|
|
||||||
params->lfb_height = height;
|
|
||||||
params->lfb_depth = depth;
|
|
||||||
params->lfb_line_len = line_len;
|
|
||||||
|
|
||||||
params->lfb_base = fb_base;
|
|
||||||
params->lfb_size = ALIGN_UP (line_len * params->lfb_height, 65536);
|
|
||||||
|
|
||||||
params->red_mask_size = 8;
|
|
||||||
params->red_field_pos = 16;
|
|
||||||
params->green_mask_size = 8;
|
|
||||||
params->green_field_pos = 8;
|
|
||||||
params->blue_mask_size = 8;
|
|
||||||
params->blue_field_pos = 0;
|
|
||||||
params->reserved_mask_size = 8;
|
|
||||||
params->reserved_field_pos = 24;
|
|
||||||
|
|
||||||
params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
|
|
||||||
params->vid_mode = 0x338; /* 1024x768x32 */
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
|
@ -809,8 +735,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||||
grub_printf (" [Linux-bzImage, setup=0x%x, size=0x%x]\n",
|
grub_printf (" [Linux-bzImage, setup=0x%x, size=0x%x]\n",
|
||||||
(unsigned) real_size, (unsigned) prot_size);
|
(unsigned) real_size, (unsigned) prot_size);
|
||||||
|
|
||||||
grub_linux_setup_video (params);
|
|
||||||
|
|
||||||
/* Detect explicitly specified memory size, if any. */
|
/* Detect explicitly specified memory size, if any. */
|
||||||
linux_mem_size = 0;
|
linux_mem_size = 0;
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
|
@ -876,7 +800,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
|
||||||
if (grub_errno == GRUB_ERR_NONE)
|
if (grub_errno == GRUB_ERR_NONE)
|
||||||
{
|
{
|
||||||
grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
|
grub_loader_set (grub_linux_boot, grub_linux_unload, 0);
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,178 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/env.h>
|
|
||||||
#include <grub/xnu.h>
|
|
||||||
#include <grub/cpu/xnu.h>
|
|
||||||
#include <grub/efi/api.h>
|
|
||||||
#include <grub/efi/efi.h>
|
|
||||||
#include <grub/efi/uga_draw.h>
|
|
||||||
#include <grub/pci.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
|
|
||||||
/* Setup video for xnu. Big parts are copied from linux.c. */
|
|
||||||
|
|
||||||
static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
|
|
||||||
|
|
||||||
#define RGB_MASK 0xffffff
|
|
||||||
#define RGB_MAGIC 0x121314
|
|
||||||
#define LINE_MIN 800
|
|
||||||
#define LINE_MAX 4096
|
|
||||||
#define FBTEST_STEP (0x10000 >> 2)
|
|
||||||
#define FBTEST_COUNT 8
|
|
||||||
|
|
||||||
static int
|
|
||||||
find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
|
||||||
{
|
|
||||||
grub_uint32_t *base = (grub_uint32_t *) (grub_target_addr_t) *fb_base;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < FBTEST_COUNT; i++, base += FBTEST_STEP)
|
|
||||||
{
|
|
||||||
if ((*base & RGB_MASK) == RGB_MAGIC)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = LINE_MIN; j <= LINE_MAX; j++)
|
|
||||||
{
|
|
||||||
if ((base[j] & RGB_MASK) == RGB_MAGIC)
|
|
||||||
{
|
|
||||||
*fb_base = (grub_uint32_t) (grub_target_addr_t) base;
|
|
||||||
*line_len = j << 2;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
|
||||||
{
|
|
||||||
int found = 0;
|
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
|
||||||
grub_pci_id_t pciid);
|
|
||||||
|
|
||||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
|
||||||
grub_pci_id_t pciid)
|
|
||||||
{
|
|
||||||
grub_pci_address_t addr;
|
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
|
||||||
if (grub_pci_read (addr) >> 24 == 0x3)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
grub_printf ("Display controller: %d:%d.%d\nDevice id: %x\n",
|
|
||||||
grub_pci_get_bus (dev), grub_pci_get_device (dev),
|
|
||||||
grub_pci_get_function (dev), pciid);
|
|
||||||
addr += 8;
|
|
||||||
for (i = 0; i < 6; i++, addr += 4)
|
|
||||||
{
|
|
||||||
grub_uint32_t old_bar1, old_bar2, type;
|
|
||||||
grub_uint64_t base64;
|
|
||||||
|
|
||||||
old_bar1 = grub_pci_read (addr);
|
|
||||||
if ((! old_bar1) || (old_bar1 & GRUB_PCI_ADDR_SPACE_IO))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
type = old_bar1 & GRUB_PCI_ADDR_MEM_TYPE_MASK;
|
|
||||||
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
|
|
||||||
{
|
|
||||||
if (i == 5)
|
|
||||||
break;
|
|
||||||
|
|
||||||
old_bar2 = grub_pci_read (addr + 4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
old_bar2 = 0;
|
|
||||||
|
|
||||||
base64 = old_bar2;
|
|
||||||
base64 <<= 32;
|
|
||||||
base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK);
|
|
||||||
|
|
||||||
grub_printf ("%s(%d): 0x%llx\n",
|
|
||||||
((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ?
|
|
||||||
"VMEM" : "MMIO"), i,
|
|
||||||
(unsigned long long) base64);
|
|
||||||
|
|
||||||
if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! found))
|
|
||||||
{
|
|
||||||
*fb_base = base64;
|
|
||||||
if (find_line_len (fb_base, line_len))
|
|
||||||
found++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
addr += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_pci_iterate (find_card);
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_err_t
|
|
||||||
grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|
||||||
{
|
|
||||||
grub_efi_uga_draw_protocol_t *c;
|
|
||||||
grub_uint32_t width, height, depth, rate, pixel, fb_base, line_len;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
c = grub_efi_locate_protocol (&uga_draw_guid, 0);
|
|
||||||
if (! c)
|
|
||||||
return grub_error (GRUB_ERR_IO, "couldn't find UGADraw");
|
|
||||||
|
|
||||||
if (efi_call_5 (c->get_mode, c, &width, &height, &depth, &rate))
|
|
||||||
return grub_error (GRUB_ERR_IO, "couldn't retrieve video mode");
|
|
||||||
|
|
||||||
grub_printf ("Video mode: %ux%u-%u@%u\n", width, height, depth, rate);
|
|
||||||
|
|
||||||
grub_efi_set_text_mode (0);
|
|
||||||
pixel = RGB_MAGIC;
|
|
||||||
efi_call_10 (c->blt, c, (struct grub_efi_uga_pixel *) &pixel,
|
|
||||||
GRUB_EFI_UGA_VIDEO_FILL, 0, 0, 0, 0, 1, height, 0);
|
|
||||||
ret = find_framebuf (&fb_base, &line_len);
|
|
||||||
grub_efi_set_text_mode (1);
|
|
||||||
|
|
||||||
if (! ret)
|
|
||||||
return grub_error (GRUB_ERR_IO, "can\'t find frame buffer address");
|
|
||||||
|
|
||||||
grub_printf ("Frame buffer base: 0x%x\n", fb_base);
|
|
||||||
grub_printf ("Video line length: %d\n", line_len);
|
|
||||||
|
|
||||||
params->lfb_width = width;
|
|
||||||
params->lfb_height = height;
|
|
||||||
params->lfb_depth = depth;
|
|
||||||
params->lfb_line_len = line_len;
|
|
||||||
params->lfb_mode = GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
|
|
||||||
params->lfb_base = fb_base;
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
|
@ -1,123 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/env.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
#include <grub/xnu.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/cpu/xnu.h>
|
|
||||||
#include <grub/video_fb.h>
|
|
||||||
#include <grub/bitmap_scale.h>
|
|
||||||
|
|
||||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
|
||||||
|
|
||||||
#define DEFAULT_VIDEO_MODE "auto"
|
|
||||||
|
|
||||||
/* Setup video for xnu. */
|
|
||||||
grub_err_t
|
|
||||||
grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|
||||||
{
|
|
||||||
struct grub_video_mode_info mode_info;
|
|
||||||
int ret;
|
|
||||||
char *tmp;
|
|
||||||
const char *modevar;
|
|
||||||
void *framebuffer;
|
|
||||||
grub_err_t err;
|
|
||||||
struct grub_video_bitmap *bitmap = NULL;
|
|
||||||
|
|
||||||
modevar = grub_env_get ("gfxpayload");
|
|
||||||
/* Consider only graphical 32-bit deep modes. */
|
|
||||||
if (! modevar || *modevar == 0)
|
|
||||||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE,
|
|
||||||
GRUB_VIDEO_MODE_TYPE_PURE_TEXT
|
|
||||||
| GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
|
|
||||||
32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
|
|
||||||
if (! tmp)
|
|
||||||
return grub_errno;
|
|
||||||
err = grub_video_set_mode (tmp,
|
|
||||||
GRUB_VIDEO_MODE_TYPE_PURE_TEXT
|
|
||||||
| GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
|
|
||||||
32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
|
|
||||||
grub_free (tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
ret = grub_video_get_info (&mode_info);
|
|
||||||
if (ret)
|
|
||||||
return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
|
|
||||||
|
|
||||||
if (grub_xnu_bitmap)
|
|
||||||
{
|
|
||||||
if (grub_xnu_bitmap_mode == GRUB_XNU_BITMAP_STRETCH)
|
|
||||||
err = grub_video_bitmap_create_scaled (&bitmap,
|
|
||||||
mode_info.width,
|
|
||||||
mode_info.height,
|
|
||||||
grub_xnu_bitmap,
|
|
||||||
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
|
|
||||||
else
|
|
||||||
bitmap = grub_xnu_bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitmap)
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
x = mode_info.width - bitmap->mode_info.width;
|
|
||||||
x /= 2;
|
|
||||||
y = mode_info.height - bitmap->mode_info.height;
|
|
||||||
y /= 2;
|
|
||||||
err = grub_video_blit_bitmap (bitmap,
|
|
||||||
GRUB_VIDEO_BLIT_REPLACE,
|
|
||||||
x > 0 ? x : 0,
|
|
||||||
y > 0 ? y : 0,
|
|
||||||
x < 0 ? -x : 0,
|
|
||||||
y < 0 ? -y : 0,
|
|
||||||
min (bitmap->mode_info.width,
|
|
||||||
mode_info.width),
|
|
||||||
min (bitmap->mode_info.height,
|
|
||||||
mode_info.height));
|
|
||||||
}
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
grub_print_error ();
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
|
||||||
bitmap = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = grub_video_get_info_and_fini (&mode_info, &framebuffer);
|
|
||||||
if (ret)
|
|
||||||
return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
|
|
||||||
|
|
||||||
params->lfb_width = mode_info.width;
|
|
||||||
params->lfb_height = mode_info.height;
|
|
||||||
params->lfb_depth = mode_info.bpp;
|
|
||||||
params->lfb_line_len = mode_info.pitch;
|
|
||||||
|
|
||||||
params->lfb_base = PTR_TO_UINT32 (framebuffer);
|
|
||||||
params->lfb_mode = bitmap ? GRUB_XNU_VIDEO_SPLASH
|
|
||||||
: GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,6 +33,12 @@
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/gzio.h>
|
#include <grub/gzio.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/bitmap_scale.h>
|
||||||
|
|
||||||
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
|
#define DEFAULT_VIDEO_MODE "auto"
|
||||||
|
|
||||||
char grub_xnu_cmdline[1024];
|
char grub_xnu_cmdline[1024];
|
||||||
grub_uint32_t grub_xnu_heap_will_be_at;
|
grub_uint32_t grub_xnu_heap_will_be_at;
|
||||||
|
@ -838,6 +844,98 @@ grub_xnu_boot_resume (void)
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Setup video for xnu. */
|
||||||
|
static grub_err_t
|
||||||
|
grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
||||||
|
{
|
||||||
|
struct grub_video_mode_info mode_info;
|
||||||
|
int ret;
|
||||||
|
char *tmp;
|
||||||
|
const char *modevar;
|
||||||
|
void *framebuffer;
|
||||||
|
grub_err_t err;
|
||||||
|
struct grub_video_bitmap *bitmap = NULL;
|
||||||
|
|
||||||
|
modevar = grub_env_get ("gfxpayload");
|
||||||
|
/* Consider only graphical 32-bit deep modes. */
|
||||||
|
if (! modevar || *modevar == 0)
|
||||||
|
err = grub_video_set_mode (DEFAULT_VIDEO_MODE,
|
||||||
|
GRUB_VIDEO_MODE_TYPE_PURE_TEXT
|
||||||
|
| GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
|
||||||
|
32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||||
|
if (! tmp)
|
||||||
|
return grub_errno;
|
||||||
|
err = grub_video_set_mode (tmp,
|
||||||
|
GRUB_VIDEO_MODE_TYPE_PURE_TEXT
|
||||||
|
| GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
|
||||||
|
32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
|
||||||
|
grub_free (tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
ret = grub_video_get_info (&mode_info);
|
||||||
|
if (ret)
|
||||||
|
return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
|
||||||
|
|
||||||
|
if (grub_xnu_bitmap)
|
||||||
|
{
|
||||||
|
if (grub_xnu_bitmap_mode == GRUB_XNU_BITMAP_STRETCH)
|
||||||
|
err = grub_video_bitmap_create_scaled (&bitmap,
|
||||||
|
mode_info.width,
|
||||||
|
mode_info.height,
|
||||||
|
grub_xnu_bitmap,
|
||||||
|
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
|
||||||
|
else
|
||||||
|
bitmap = grub_xnu_bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
x = mode_info.width - bitmap->mode_info.width;
|
||||||
|
x /= 2;
|
||||||
|
y = mode_info.height - bitmap->mode_info.height;
|
||||||
|
y /= 2;
|
||||||
|
err = grub_video_blit_bitmap (bitmap,
|
||||||
|
GRUB_VIDEO_BLIT_REPLACE,
|
||||||
|
x > 0 ? x : 0,
|
||||||
|
y > 0 ? y : 0,
|
||||||
|
x < 0 ? -x : 0,
|
||||||
|
y < 0 ? -y : 0,
|
||||||
|
min (bitmap->mode_info.width,
|
||||||
|
mode_info.width),
|
||||||
|
min (bitmap->mode_info.height,
|
||||||
|
mode_info.height));
|
||||||
|
}
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
grub_print_error ();
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
bitmap = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = grub_video_get_info_and_fini (&mode_info, &framebuffer);
|
||||||
|
if (ret)
|
||||||
|
return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
|
||||||
|
|
||||||
|
params->lfb_width = mode_info.width;
|
||||||
|
params->lfb_height = mode_info.height;
|
||||||
|
params->lfb_depth = mode_info.bpp;
|
||||||
|
params->lfb_line_len = mode_info.pitch;
|
||||||
|
|
||||||
|
params->lfb_base = PTR_TO_UINT32 (framebuffer);
|
||||||
|
params->lfb_mode = bitmap ? GRUB_XNU_VIDEO_SPLASH
|
||||||
|
: GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Boot xnu. */
|
/* Boot xnu. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_xnu_boot (void)
|
grub_xnu_boot (void)
|
||||||
|
|
|
@ -96,11 +96,11 @@ case "$host_os" in
|
||||||
netbsd* | openbsd*)
|
netbsd* | openbsd*)
|
||||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||||
# instead of /boot/grub.
|
# instead of /boot/grub.
|
||||||
grub_prefix=`echo /grub | sed ${transform}`
|
GRUB_PREFIX=`echo /grub | sed ${transform}`
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Use /boot/grub by default.
|
# Use /boot/grub by default.
|
||||||
grub_prefix=`echo /boot/grub | sed ${transform}`
|
GRUB_PREFIX=`echo /boot/grub | sed ${transform}`
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -141,9 +141,9 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p ${grub_prefix}
|
mkdir -p ${GRUB_PREFIX}
|
||||||
|
|
||||||
if test -e ${grub_prefix}/device.map ; then : ; else
|
if test -e ${GRUB_PREFIX}/device.map ; then : ; else
|
||||||
${grub_mkdevicemap}
|
${grub_mkdevicemap}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -178,17 +178,14 @@ fi
|
||||||
for x in ${GRUB_TERMINAL_OUTPUT}; do
|
for x in ${GRUB_TERMINAL_OUTPUT}; do
|
||||||
if [ "x${x}" = "xgfxterm" ]; then
|
if [ "x${x}" = "xgfxterm" ]; then
|
||||||
# If this platform supports gfxterm, try to use it.
|
# If this platform supports gfxterm, try to use it.
|
||||||
if ! test -e ${grub_prefix}/gfxterm.mod ; then
|
if ! test -e ${GRUB_PREFIX}/gfxterm.mod ; then
|
||||||
if [ "x$termoutdefault" != "x1" ]; then
|
if [ "x$termoutdefault" != "x1" ]; then
|
||||||
echo "gfxterm isn't available on your platform" >&2 ; exit 1
|
echo "gfxterm isn't available on your platform" >&2 ; exit 1
|
||||||
fi
|
fi
|
||||||
GRUB_TERMINAL_OUTPUT=
|
GRUB_TERMINAL_OUTPUT=
|
||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
# FIXME: this should do something smarter than just loading first
|
if [ ! -s "${GRUB_PREFIX}/video.lst" ] ; then
|
||||||
# video backend.
|
|
||||||
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
|
|
||||||
if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
|
|
||||||
if [ "x$termoutdefault" != "x1" ]; then
|
if [ "x$termoutdefault" != "x1" ]; then
|
||||||
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
|
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -246,7 +243,7 @@ export GRUB_DEVICE \
|
||||||
GRUB_FS \
|
GRUB_FS \
|
||||||
GRUB_FONT_PATH \
|
GRUB_FONT_PATH \
|
||||||
GRUB_PRELOAD_MODULES \
|
GRUB_PRELOAD_MODULES \
|
||||||
GRUB_VIDEO_BACKEND
|
GRUB_PREFIX
|
||||||
|
|
||||||
# These are optional, user-defined variables.
|
# These are optional, user-defined variables.
|
||||||
export GRUB_DEFAULT \
|
export GRUB_DEFAULT \
|
||||||
|
@ -268,6 +265,7 @@ export GRUB_DEFAULT \
|
||||||
GRUB_DISABLE_LINUX_UUID \
|
GRUB_DISABLE_LINUX_UUID \
|
||||||
GRUB_DISABLE_LINUX_RECOVERY \
|
GRUB_DISABLE_LINUX_RECOVERY \
|
||||||
GRUB_DISABLE_NETBSD_RECOVERY \
|
GRUB_DISABLE_NETBSD_RECOVERY \
|
||||||
|
GRUB_VIDEO_BACKEND \
|
||||||
GRUB_GFXMODE \
|
GRUB_GFXMODE \
|
||||||
GRUB_BACKGROUND \
|
GRUB_BACKGROUND \
|
||||||
GRUB_THEME \
|
GRUB_THEME \
|
||||||
|
|
|
@ -21,8 +21,7 @@ transform="@program_transform_name@"
|
||||||
prefix=@prefix@
|
prefix=@prefix@
|
||||||
exec_prefix=@exec_prefix@
|
exec_prefix=@exec_prefix@
|
||||||
libdir=@libdir@
|
libdir=@libdir@
|
||||||
grub_prefix=`echo /boot/grub | sed ${transform}`
|
locale_dir=`echo ${GRUB_PREFIX}/locale | sed ${transform}`
|
||||||
locale_dir=`echo /boot/grub/locale | sed ${transform}`
|
|
||||||
grub_lang=`echo $LANG | cut -d _ -f 1`
|
grub_lang=`echo $LANG | cut -d _ -f 1`
|
||||||
|
|
||||||
. ${libdir}/grub/grub-mkconfig_lib
|
. ${libdir}/grub/grub-mkconfig_lib
|
||||||
|
@ -75,6 +74,24 @@ function savedefault {
|
||||||
save_env saved_entry
|
save_env saved_entry
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function load_video {
|
||||||
|
EOF
|
||||||
|
if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
|
||||||
|
cat <<EOF
|
||||||
|
insmod ${GRUB_VIDEO_BACKEND}
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
# Insert all available backends; GRUB will use the most appropriate.
|
||||||
|
for backend in $(cat "${GRUB_PREFIX}/video.lst"); do
|
||||||
|
cat <<EOF
|
||||||
|
insmod ${backend}
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
cat <<EOF
|
||||||
|
}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
serial=0;
|
serial=0;
|
||||||
|
@ -89,7 +106,7 @@ for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "x$serial" = x1 ]; then
|
if [ "x$serial" = x1 ]; then
|
||||||
if ! test -e ${grub_prefix}/serial.mod ; then
|
if ! test -e ${GRUB_PREFIX}/serial.mod ; then
|
||||||
echo "Serial terminal not available on this platform." >&2 ; exit 1
|
echo "Serial terminal not available on this platform." >&2 ; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -107,8 +124,8 @@ if [ "x$gfxterm" = x1 ]; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
|
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
|
||||||
set gfxmode=${GRUB_GFXMODE}
|
set gfxmode=${GRUB_GFXMODE}
|
||||||
|
load_video
|
||||||
insmod gfxterm
|
insmod gfxterm
|
||||||
insmod ${GRUB_VIDEO_BACKEND}
|
|
||||||
EOF
|
EOF
|
||||||
if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
|
if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
|
||||||
&& is_path_readable_by_grub "$GRUB_THEME"; then
|
&& is_path_readable_by_grub "$GRUB_THEME"; then
|
||||||
|
|
|
@ -66,6 +66,9 @@ linux_entry ()
|
||||||
# Use ELILO's generic "efifb" when it's known to be available.
|
# Use ELILO's generic "efifb" when it's known to be available.
|
||||||
# FIXME: We need an interface to select vesafb in case efifb can't be used.
|
# FIXME: We need an interface to select vesafb in case efifb can't be used.
|
||||||
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
|
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
|
||||||
|
cat << EOF
|
||||||
|
load_video
|
||||||
|
EOF
|
||||||
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \
|
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \
|
||||||
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then
|
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
|
@ -44,7 +44,7 @@ EOF
|
||||||
save_default_entry | sed -e "s/^/\t/"
|
save_default_entry | sed -e "s/^/\t/"
|
||||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||||
cat << EOF
|
cat << EOF
|
||||||
insmod ${GRUB_VIDEO_BACKEND}
|
load_video
|
||||||
set do_resume=0
|
set do_resume=0
|
||||||
if [ /var/vm/sleepimage -nt10 / ]; then
|
if [ /var/vm/sleepimage -nt10 / ]; then
|
||||||
if xnu_resume /var/vm/sleepimage; then
|
if xnu_resume /var/vm/sleepimage; then
|
||||||
|
|
|
@ -355,6 +355,8 @@ static struct grub_video_adapter grub_video_gop_adapter =
|
||||||
.name = "EFI GOP driver",
|
.name = "EFI GOP driver",
|
||||||
.id = GRUB_VIDEO_DRIVER_EFI_GOP,
|
.id = GRUB_VIDEO_DRIVER_EFI_GOP,
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
|
||||||
|
|
||||||
.init = grub_video_gop_init,
|
.init = grub_video_gop_init,
|
||||||
.fini = grub_video_gop_fini,
|
.fini = grub_video_gop_fini,
|
||||||
.setup = grub_video_gop_setup,
|
.setup = grub_video_gop_setup,
|
||||||
|
|
|
@ -302,6 +302,8 @@ static struct grub_video_adapter grub_video_uga_adapter =
|
||||||
.name = "EFI UGA driver",
|
.name = "EFI UGA driver",
|
||||||
.id = GRUB_VIDEO_DRIVER_EFI_UGA,
|
.id = GRUB_VIDEO_DRIVER_EFI_UGA,
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY,
|
||||||
|
|
||||||
.init = grub_video_uga_init,
|
.init = grub_video_uga_init,
|
||||||
.fini = grub_video_uga_fini,
|
.fini = grub_video_uga_fini,
|
||||||
.setup = grub_video_uga_setup,
|
.setup = grub_video_uga_setup,
|
||||||
|
|
|
@ -200,6 +200,9 @@ grub_video_sdl_set_active_render_target (struct grub_video_render_target *target
|
||||||
static struct grub_video_adapter grub_video_sdl_adapter =
|
static struct grub_video_adapter grub_video_sdl_adapter =
|
||||||
{
|
{
|
||||||
.name = "SDL Video Driver",
|
.name = "SDL Video Driver",
|
||||||
|
.id = GRUB_VIDEO_DRIVER_SDL,
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
|
||||||
|
|
||||||
.init = grub_video_sdl_init,
|
.init = grub_video_sdl_init,
|
||||||
.fini = grub_video_sdl_fini,
|
.fini = grub_video_sdl_fini,
|
||||||
|
|
|
@ -783,6 +783,8 @@ static struct grub_video_adapter grub_video_vbe_adapter =
|
||||||
.name = "VESA BIOS Extension Video Driver",
|
.name = "VESA BIOS Extension Video Driver",
|
||||||
.id = GRUB_VIDEO_DRIVER_VBE,
|
.id = GRUB_VIDEO_DRIVER_VBE,
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
|
||||||
|
|
||||||
.init = grub_video_vbe_init,
|
.init = grub_video_vbe_init,
|
||||||
.fini = grub_video_vbe_fini,
|
.fini = grub_video_vbe_fini,
|
||||||
.setup = grub_video_vbe_setup,
|
.setup = grub_video_vbe_setup,
|
||||||
|
|
|
@ -375,6 +375,8 @@ static struct grub_video_adapter grub_video_vga_adapter =
|
||||||
.name = "VGA Video Driver",
|
.name = "VGA Video Driver",
|
||||||
.id = GRUB_VIDEO_DRIVER_VGA,
|
.id = GRUB_VIDEO_DRIVER_VGA,
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_FALLBACK,
|
||||||
|
|
||||||
.init = grub_video_vga_init,
|
.init = grub_video_vga_init,
|
||||||
.fini = grub_video_vga_fini,
|
.fini = grub_video_vga_fini,
|
||||||
.setup = grub_video_vga_setup,
|
.setup = grub_video_vga_setup,
|
||||||
|
|
|
@ -254,6 +254,8 @@ static struct grub_video_adapter grub_video_ieee1275_adapter =
|
||||||
{
|
{
|
||||||
.name = "IEEE1275 video driver",
|
.name = "IEEE1275 video driver",
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
|
||||||
|
|
||||||
.init = grub_video_ieee1275_init,
|
.init = grub_video_ieee1275_init,
|
||||||
.fini = grub_video_ieee1275_fini,
|
.fini = grub_video_ieee1275_fini,
|
||||||
.setup = grub_video_ieee1275_setup,
|
.setup = grub_video_ieee1275_setup,
|
||||||
|
|
|
@ -193,6 +193,8 @@ static struct grub_video_adapter grub_video_sm712_adapter =
|
||||||
.name = "SM712 Video Driver",
|
.name = "SM712 Video Driver",
|
||||||
.id = GRUB_VIDEO_DRIVER_SM712,
|
.id = GRUB_VIDEO_DRIVER_SM712,
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
|
||||||
|
|
||||||
.init = grub_video_sm712_video_init,
|
.init = grub_video_sm712_video_init,
|
||||||
.fini = grub_video_sm712_video_fini,
|
.fini = grub_video_sm712_video_fini,
|
||||||
.setup = grub_video_sm712_setup,
|
.setup = grub_video_sm712_setup,
|
||||||
|
|
Loading…
Reference in a new issue