2005-08-19 Yoshinori K. Okuji <okuji@enbug.org>
* DISTLIST: Replace commands/i386/pc/vbe_list_modes.c and commands/i386/pc/vbe_test.c with commands/i386/pc/vbeinfo.c and commands/i386/pc/vbetest.c. * video/i386/pc/vbe.c (grub_vbe_probe): If INFOBLOCK is not NULL, call grub_vbe_get_controller_info again, because the returned information is volatile. (grub_vbe_set_video_mode): Mostly rewritten. (grub_vbe_get_video_mode): Use grub_vbe_probe and use grub_vbe_status_t correctly. (grub_vbe_get_video_mode_info): Likewise. (grub_vbe_set_pixel_rgb): Use a switch statement rather than several if statements. * commands/i386/pc/vbe_list_modes.c: Renamed to ... * commands/i386/pc/vbeinfo.c: ... this. * commands/i386/pc/vbe_test.c: Renamed to ... * commands/i386/pc/vbetest.c: ... this. * commands/i386/pc/vbeinfo.c (grub_cmd_vbe_list_modes): Renamed to ... (grub_cmd_vbeinfo): ... this. Save video modes before iterating. Skip a video mode, if it is not available, not enough information is given or it is monochrome. Show the memory model. Leave the interpretation of MODEVAR to grub_strtoul completely. (GRUB_MOD_INIT): Rename vbe_list_modes to vbeinfo. (GRUB_MOD_FINI): Likewise. * commands/i386/pc/vbetest.c (grub_cmd_vbe_test): Renamed to ... (grub_cmd_vbetest): ... this. Don't print unnecessarily. Use grub_err_t instead of grub_uint32_t. Don't use SPTR. Remove a duplicated grub_env_get. Leave the interpretation of MODEVAR to grub_strtoul completely. (real2pm): Removed. (GRUB_MOD_INIT): Rename vbe_test to vbetest. (GRUB_MOD_FINI): Likewise. * normal/misc.c: Include grub/mm.h. * conf/i386-pc.rmk (pkgdata_MODULES): Replaced vbe_test.mod and vbe_list_modes with vbetest.mod and vbeinfo.mod. (vbe_list_modes_mod_SOURCES): Removed. (vbe_list_modes_mod_CFLAGS): Likewise. (vbe_test_mod_SOURCES): Likewise. (vbe_test_mod_CFLAGS): Likewise. (vbeinfo_mod_SOURCES): New variable. (vbeinfo_mod_CFLAGS): Likewise. (vbetest_mod_SOURCES): Likewise. (vbetest_mod_CFLAGS): Likewise.
This commit is contained in:
parent
a7db563eb6
commit
1f0a95e481
9 changed files with 461 additions and 426 deletions
54
ChangeLog
54
ChangeLog
|
@ -1,3 +1,57 @@
|
|||
2005-08-19 Yoshinori K. Okuji <okuji@enbug.org>
|
||||
|
||||
* DISTLIST: Replace commands/i386/pc/vbe_list_modes.c and
|
||||
commands/i386/pc/vbe_test.c with commands/i386/pc/vbeinfo.c and
|
||||
commands/i386/pc/vbetest.c.
|
||||
|
||||
* video/i386/pc/vbe.c (grub_vbe_probe): If INFOBLOCK is not NULL,
|
||||
call grub_vbe_get_controller_info again, because the returned
|
||||
information is volatile.
|
||||
(grub_vbe_set_video_mode): Mostly rewritten.
|
||||
(grub_vbe_get_video_mode): Use grub_vbe_probe and use
|
||||
grub_vbe_status_t correctly.
|
||||
(grub_vbe_get_video_mode_info): Likewise.
|
||||
(grub_vbe_set_pixel_rgb): Use a switch statement rather than
|
||||
several if statements.
|
||||
|
||||
* commands/i386/pc/vbe_list_modes.c: Renamed to ...
|
||||
* commands/i386/pc/vbeinfo.c: ... this.
|
||||
|
||||
* commands/i386/pc/vbe_test.c: Renamed to ...
|
||||
* commands/i386/pc/vbetest.c: ... this.
|
||||
|
||||
* commands/i386/pc/vbeinfo.c (grub_cmd_vbe_list_modes): Renamed to
|
||||
...
|
||||
(grub_cmd_vbeinfo): ... this. Save video modes before
|
||||
iterating. Skip a video mode, if it is not available, not enough
|
||||
information is given or it is monochrome. Show the memory
|
||||
model. Leave the interpretation of MODEVAR to grub_strtoul
|
||||
completely.
|
||||
(GRUB_MOD_INIT): Rename vbe_list_modes to vbeinfo.
|
||||
(GRUB_MOD_FINI): Likewise.
|
||||
|
||||
* commands/i386/pc/vbetest.c (grub_cmd_vbe_test): Renamed to ...
|
||||
(grub_cmd_vbetest): ... this. Don't print unnecessarily. Use
|
||||
grub_err_t instead of grub_uint32_t. Don't use SPTR. Remove a
|
||||
duplicated grub_env_get. Leave the interpretation of MODEVAR to
|
||||
grub_strtoul completely.
|
||||
(real2pm): Removed.
|
||||
(GRUB_MOD_INIT): Rename vbe_test to vbetest.
|
||||
(GRUB_MOD_FINI): Likewise.
|
||||
|
||||
* normal/misc.c: Include grub/mm.h.
|
||||
|
||||
* conf/i386-pc.rmk (pkgdata_MODULES): Replaced vbe_test.mod and
|
||||
vbe_list_modes with vbetest.mod and vbeinfo.mod.
|
||||
(vbe_list_modes_mod_SOURCES): Removed.
|
||||
(vbe_list_modes_mod_CFLAGS): Likewise.
|
||||
(vbe_test_mod_SOURCES): Likewise.
|
||||
(vbe_test_mod_CFLAGS): Likewise.
|
||||
(vbeinfo_mod_SOURCES): New variable.
|
||||
(vbeinfo_mod_CFLAGS): Likewise.
|
||||
(vbetest_mod_SOURCES): Likewise.
|
||||
(vbetest_mod_CFLAGS): Likewise.
|
||||
|
||||
2005-08-18 Yoshinori K. Okuji <okuji@enbug.org>
|
||||
|
||||
* normal/misc.c: New file.
|
||||
|
|
4
DISTLIST
4
DISTLIST
|
@ -32,8 +32,8 @@ boot/powerpc/ieee1275/cmain.c
|
|||
boot/powerpc/ieee1275/crt0.S
|
||||
commands/i386/pc/halt.c
|
||||
commands/i386/pc/reboot.c
|
||||
commands/i386/pc/vbe_list_modes.c
|
||||
commands/i386/pc/vbe_test.c
|
||||
commands/i386/pc/vbeinfo.c
|
||||
commands/i386/pc/vbetest.c
|
||||
commands/ieee1275/halt.c
|
||||
commands/ieee1275/reboot.c
|
||||
commands/ieee1275/suspend.c
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
/* vbe_list_modes.c - command to list compatible VBE video modes. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#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>
|
||||
|
||||
static void *
|
||||
real2pm(grub_vbe_farptr_t ptr)
|
||||
{
|
||||
return (void *)((((unsigned long)ptr & 0xFFFF0000) >> 12UL)
|
||||
+ ((unsigned long)ptr & 0x0000FFFF));
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_vbe_list_modes(struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_vbe_info_block controller_info;
|
||||
struct grub_vbe_mode_info_block mode_info_tmp;
|
||||
grub_uint32_t use_mode = GRUB_VBE_DEFAULT_VIDEO_MODE;
|
||||
grub_uint16_t *sptr;
|
||||
grub_uint32_t rc;
|
||||
char *modevar;
|
||||
|
||||
grub_printf ("List of compatible video modes:\n");
|
||||
|
||||
rc = grub_vbe_probe (&controller_info);
|
||||
|
||||
if (rc != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_printf ("VESA BIOS Extension not detected!\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
sptr = real2pm (controller_info.video_mode_ptr);
|
||||
|
||||
/* Walk thru all video modes listed. */
|
||||
for (;*sptr != 0xFFFF; sptr++)
|
||||
{
|
||||
int valid_mode = 1;
|
||||
|
||||
rc = grub_vbe_get_video_mode_info (*sptr, &mode_info_tmp);
|
||||
if (rc != GRUB_ERR_NONE) continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & 0x080) == 0)
|
||||
{
|
||||
/* We support only linear frame buffer modes. */
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & 0x010) == 0)
|
||||
{
|
||||
/* We allow only graphical modes. */
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(mode_info_tmp.memory_model)
|
||||
{
|
||||
case 0x04:
|
||||
case 0x06:
|
||||
break;
|
||||
|
||||
default:
|
||||
valid_mode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (valid_mode == 0) continue;
|
||||
|
||||
grub_printf ("0x%03x: %d x %d x %d bpp\n",
|
||||
*sptr,
|
||||
mode_info_tmp.x_resolution,
|
||||
mode_info_tmp.y_resolution,
|
||||
mode_info_tmp.bits_per_pixel);
|
||||
}
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
|
||||
if (modevar != 0)
|
||||
{
|
||||
unsigned long value = 0;
|
||||
|
||||
if ((grub_strncmp (modevar, "0x", 2) == 0) ||
|
||||
(grub_strncmp (modevar, "0X", 2) == 0))
|
||||
{
|
||||
/* Convert HEX mode number. */
|
||||
value = grub_strtoul (modevar + 2, 0, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Convert DEC mode number. */
|
||||
value = grub_strtoul (modevar, 0, 10);
|
||||
}
|
||||
|
||||
if (value != 0)
|
||||
{
|
||||
use_mode = value;
|
||||
}
|
||||
}
|
||||
|
||||
grub_printf ("Configured VBE mode (vbe_mode) = 0x%03x\n", use_mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("vbe_list_modes",
|
||||
grub_cmd_vbe_list_modes,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"vbe_list_modes",
|
||||
"List compatible VESA BIOS extension video modes.",
|
||||
0);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI
|
||||
{
|
||||
grub_unregister_command ("vbe_list_modes");
|
||||
}
|
163
commands/i386/pc/vbeinfo.c
Normal file
163
commands/i386/pc/vbeinfo.c
Normal file
|
@ -0,0 +1,163 @@
|
|||
/* vbeinfo.c - command to list compatible VBE video modes. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#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>
|
||||
|
||||
static void *
|
||||
real2pm (grub_vbe_farptr_t ptr)
|
||||
{
|
||||
return (void *) ((((unsigned long) ptr & 0xFFFF0000) >> 12UL)
|
||||
+ ((unsigned long) ptr & 0x0000FFFF));
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_vbeinfo (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_vbe_info_block controller_info;
|
||||
struct grub_vbe_mode_info_block mode_info_tmp;
|
||||
grub_uint32_t use_mode = GRUB_VBE_DEFAULT_VIDEO_MODE;
|
||||
grub_uint16_t *video_mode_list;
|
||||
grub_uint16_t *p;
|
||||
grub_uint16_t *saved_video_mode_list;
|
||||
grub_size_t video_mode_list_size;
|
||||
grub_err_t err;
|
||||
char *modevar;
|
||||
|
||||
grub_printf ("List of compatible video modes:\n");
|
||||
|
||||
err = grub_vbe_probe (&controller_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
/* Because the information on video modes is stored in a temporary place,
|
||||
it is better to copy it to somewhere safe. */
|
||||
p = video_mode_list = real2pm (controller_info.video_mode_ptr);
|
||||
while (*p++ != 0xFFFF)
|
||||
;
|
||||
|
||||
video_mode_list_size = (grub_addr_t) p - (grub_addr_t) video_mode_list;
|
||||
saved_video_mode_list = grub_malloc (video_mode_list_size);
|
||||
if (! saved_video_mode_list)
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (saved_video_mode_list, video_mode_list, video_mode_list_size);
|
||||
|
||||
/* Walk through all video modes listed. */
|
||||
for (p = saved_video_mode_list; *p != 0xFFFF; p++)
|
||||
{
|
||||
const char *memory_model = 0;
|
||||
grub_uint32_t mode = (grub_uint32_t) *p;
|
||||
|
||||
err = grub_vbe_get_video_mode_info (mode, &mode_info_tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & 0x001) == 0)
|
||||
/* If not available, skip it. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & 0x002) == 0)
|
||||
/* Not enough information. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & 0x008) == 0)
|
||||
/* Monochrome is unusable. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & 0x080) == 0)
|
||||
/* We support only linear frame buffer modes. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & 0x010) == 0)
|
||||
/* We allow only graphical modes. */
|
||||
continue;
|
||||
|
||||
switch (mode_info_tmp.memory_model)
|
||||
{
|
||||
case 0x04:
|
||||
memory_model = "Packed Pixel";
|
||||
break;
|
||||
case 0x06:
|
||||
memory_model = "Direct Color";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (! memory_model)
|
||||
continue;
|
||||
|
||||
grub_printf ("0x%03x: %d x %d x %d bpp (%s)\n",
|
||||
mode,
|
||||
mode_info_tmp.x_resolution,
|
||||
mode_info_tmp.y_resolution,
|
||||
mode_info_tmp.bits_per_pixel,
|
||||
memory_model);
|
||||
}
|
||||
|
||||
grub_free (saved_video_mode_list);
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
|
||||
if (modevar != 0)
|
||||
{
|
||||
unsigned long value;
|
||||
|
||||
value = grub_strtoul (modevar, 0, 0);
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
use_mode = value;
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_printf ("Configured VBE mode (vbe_mode) = 0x%03x\n", use_mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT
|
||||
{
|
||||
(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);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI
|
||||
{
|
||||
grub_unregister_command ("vbeinfo");
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* vbe_test.c - command to test VESA BIOS Extension 2.0+ support. */
|
||||
/* vbetest.c - command to test VESA BIOS Extension 2.0+ support. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
@ -26,21 +26,14 @@
|
|||
#include <grub/term.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/vbe.h>
|
||||
|
||||
static void *
|
||||
real2pm(grub_vbe_farptr_t ptr)
|
||||
{
|
||||
return (void *)((((unsigned long)ptr & 0xFFFF0000) >> 12UL)
|
||||
+ ((unsigned long)ptr & 0x0000FFFF));
|
||||
}
|
||||
#include <grub/err.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_vbe_test(struct grub_arg_list *state __attribute__ ((unused)),
|
||||
grub_cmd_vbetest (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
grub_uint32_t rc;
|
||||
grub_uint16_t *sptr;
|
||||
grub_err_t err;
|
||||
char *modevar;
|
||||
struct grub_vbe_mode_info_block mode_info;
|
||||
struct grub_vbe_info_block controller_info;
|
||||
|
@ -54,12 +47,10 @@ grub_cmd_vbe_test(struct grub_arg_list *state __attribute__ ((unused)),
|
|||
grub_printf ("Probing for VESA BIOS Extension ... ");
|
||||
|
||||
/* Check if VESA BIOS exists. */
|
||||
rc = grub_vbe_probe(&controller_info);
|
||||
if (rc != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_printf ("not found!\n");
|
||||
return rc;
|
||||
}
|
||||
err = grub_vbe_probe (&controller_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
grub_printf ("found!\n");
|
||||
|
||||
/* Dump out controller information. */
|
||||
|
@ -77,42 +68,30 @@ grub_cmd_vbe_test(struct grub_arg_list *state __attribute__ ((unused)),
|
|||
grub_printf ("Total memory = %d\n",
|
||||
controller_info.total_memory);
|
||||
|
||||
sptr = real2pm(controller_info.video_mode_ptr);
|
||||
err = grub_vbe_get_video_mode (&old_mode);
|
||||
grub_printf ("Get video mode err = %04x\n", err);
|
||||
|
||||
rc = grub_vbe_get_video_mode(&old_mode);
|
||||
grub_printf ("Get video mode rc = %04x\n", rc);
|
||||
|
||||
if (rc == GRUB_ERR_NONE)
|
||||
{
|
||||
if (err == GRUB_ERR_NONE)
|
||||
grub_printf ("Old video mode = %04x\n", old_mode);
|
||||
}
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
|
||||
if (modevar != 0)
|
||||
{
|
||||
unsigned long value = 0;
|
||||
unsigned long value;
|
||||
|
||||
if ((grub_strncmp (modevar, "0x", 2) == 0) ||
|
||||
(grub_strncmp (modevar, "0X", 2) == 0))
|
||||
{
|
||||
/* Convert HEX mode number. */
|
||||
value = grub_strtoul (modevar + 2, 0, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Convert DEC mode number. */
|
||||
value = grub_strtoul (modevar, 0, 10);
|
||||
}
|
||||
|
||||
if (value != 0)
|
||||
{
|
||||
value = grub_strtoul (modevar, 0, 0);
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
use_mode = value;
|
||||
}
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
rc = grub_vbe_get_video_mode_info (use_mode, &mode_info);
|
||||
err = grub_vbe_get_video_mode_info (use_mode, &mode_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
/* Dump out details about the mode being tested. */
|
||||
grub_printf ("mode: 0x%03x\n",
|
||||
|
@ -144,10 +123,12 @@ grub_cmd_vbe_test(struct grub_arg_list *state __attribute__ ((unused)),
|
|||
grub_getkey ();
|
||||
|
||||
/* Setup GFX mode. */
|
||||
rc = grub_vbe_set_video_mode (use_mode, &mode_info);
|
||||
err = grub_vbe_set_video_mode (use_mode, &mode_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
/* Determine framebuffer address and how many bytes are in scan line. */
|
||||
framebuffer = (grub_uint8_t *)mode_info.phys_base_addr;
|
||||
framebuffer = (grub_uint8_t *) mode_info.phys_base_addr;
|
||||
ptr = framebuffer;
|
||||
|
||||
if (controller_info.version >= 0x300)
|
||||
|
@ -179,21 +160,21 @@ grub_cmd_vbe_test(struct grub_arg_list *state __attribute__ ((unused)),
|
|||
/* Restore old video mode. */
|
||||
grub_vbe_set_video_mode (old_mode, 0);
|
||||
|
||||
return 0;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT
|
||||
{
|
||||
(void)mod; /* To stop warning. */
|
||||
grub_register_command ("vbe_test",
|
||||
grub_cmd_vbe_test,
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("vbetest",
|
||||
grub_cmd_vbetest,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"vbe_test",
|
||||
"vbetest",
|
||||
"Test VESA BIOS Extension 2.0+ support",
|
||||
0);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI
|
||||
{
|
||||
grub_unregister_command ("vbe_test");
|
||||
grub_unregister_command ("vbetest");
|
||||
}
|
118
conf/i386-pc.mk
118
conf/i386-pc.mk
|
@ -1150,7 +1150,7 @@ pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod \
|
|||
terminal.mod fshelp.mod chain.mod multiboot.mod amiga.mod \
|
||||
apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod \
|
||||
help.mod default.mod timeout.mod configfile.mod vbe.mod \
|
||||
vesafb.mod vbe_test.mod vbe_list_modes.mod
|
||||
vesafb.mod vbetest.mod vbeinfo.mod
|
||||
|
||||
# For _chain.mod.
|
||||
_chain_mod_SOURCES = loader/i386/pc/chainloader.c
|
||||
|
@ -3081,105 +3081,105 @@ fs-vesafb.lst: term/i386/pc/vesafb.c genfslist.sh
|
|||
|
||||
vesafb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
||||
# For vbe_list_modes.mod.
|
||||
vbe_list_modes_mod_SOURCES = commands/i386/pc/vbe_list_modes.c
|
||||
CLEANFILES += vbe_list_modes.mod mod-vbe_list_modes.o mod-vbe_list_modes.c pre-vbe_list_modes.o vbe_list_modes_mod-commands_i386_pc_vbe_list_modes.o def-vbe_list_modes.lst und-vbe_list_modes.lst
|
||||
MOSTLYCLEANFILES += vbe_list_modes_mod-commands_i386_pc_vbe_list_modes.d
|
||||
DEFSYMFILES += def-vbe_list_modes.lst
|
||||
UNDSYMFILES += und-vbe_list_modes.lst
|
||||
# For vbeinfo.mod.
|
||||
vbeinfo_mod_SOURCES = commands/i386/pc/vbeinfo.c
|
||||
CLEANFILES += vbeinfo.mod mod-vbeinfo.o mod-vbeinfo.c pre-vbeinfo.o vbeinfo_mod-commands_i386_pc_vbeinfo.o def-vbeinfo.lst und-vbeinfo.lst
|
||||
MOSTLYCLEANFILES += vbeinfo_mod-commands_i386_pc_vbeinfo.d
|
||||
DEFSYMFILES += def-vbeinfo.lst
|
||||
UNDSYMFILES += und-vbeinfo.lst
|
||||
|
||||
vbe_list_modes.mod: pre-vbe_list_modes.o mod-vbe_list_modes.o
|
||||
vbeinfo.mod: pre-vbeinfo.o mod-vbeinfo.o
|
||||
-rm -f $@
|
||||
$(LD) -r -d -o $@ $^
|
||||
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||
|
||||
pre-vbe_list_modes.o: vbe_list_modes_mod-commands_i386_pc_vbe_list_modes.o
|
||||
pre-vbeinfo.o: vbeinfo_mod-commands_i386_pc_vbeinfo.o
|
||||
-rm -f $@
|
||||
$(LD) -r -d -o $@ $^
|
||||
|
||||
mod-vbe_list_modes.o: mod-vbe_list_modes.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(vbe_list_modes_mod_CFLAGS) -c -o $@ $<
|
||||
mod-vbeinfo.o: mod-vbeinfo.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(vbeinfo_mod_CFLAGS) -c -o $@ $<
|
||||
|
||||
mod-vbe_list_modes.c: moddep.lst genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh 'vbe_list_modes' $< > $@ || (rm -f $@; exit 1)
|
||||
mod-vbeinfo.c: moddep.lst genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh 'vbeinfo' $< > $@ || (rm -f $@; exit 1)
|
||||
|
||||
def-vbe_list_modes.lst: pre-vbe_list_modes.o
|
||||
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 vbe_list_modes/' > $@
|
||||
def-vbeinfo.lst: pre-vbeinfo.o
|
||||
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 vbeinfo/' > $@
|
||||
|
||||
und-vbe_list_modes.lst: pre-vbe_list_modes.o
|
||||
echo 'vbe_list_modes' > $@
|
||||
und-vbeinfo.lst: pre-vbeinfo.o
|
||||
echo 'vbeinfo' > $@
|
||||
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||
|
||||
vbe_list_modes_mod-commands_i386_pc_vbe_list_modes.o: commands/i386/pc/vbe_list_modes.c
|
||||
$(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_list_modes_mod_CFLAGS) -c -o $@ $<
|
||||
vbeinfo_mod-commands_i386_pc_vbeinfo.o: commands/i386/pc/vbeinfo.c
|
||||
$(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbeinfo_mod_CFLAGS) -c -o $@ $<
|
||||
|
||||
vbe_list_modes_mod-commands_i386_pc_vbe_list_modes.d: commands/i386/pc/vbe_list_modes.c
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_list_modes_mod_CFLAGS) -M $< | sed 's,vbe_list_modes\.o[ :]*,vbe_list_modes_mod-commands_i386_pc_vbe_list_modes.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
|
||||
vbeinfo_mod-commands_i386_pc_vbeinfo.d: commands/i386/pc/vbeinfo.c
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbeinfo_mod_CFLAGS) -M $< | sed 's,vbeinfo\.o[ :]*,vbeinfo_mod-commands_i386_pc_vbeinfo.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
|
||||
|
||||
-include vbe_list_modes_mod-commands_i386_pc_vbe_list_modes.d
|
||||
-include vbeinfo_mod-commands_i386_pc_vbeinfo.d
|
||||
|
||||
CLEANFILES += cmd-vbe_list_modes.lst fs-vbe_list_modes.lst
|
||||
COMMANDFILES += cmd-vbe_list_modes.lst
|
||||
FSFILES += fs-vbe_list_modes.lst
|
||||
CLEANFILES += cmd-vbeinfo.lst fs-vbeinfo.lst
|
||||
COMMANDFILES += cmd-vbeinfo.lst
|
||||
FSFILES += fs-vbeinfo.lst
|
||||
|
||||
cmd-vbe_list_modes.lst: commands/i386/pc/vbe_list_modes.c gencmdlist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_list_modes_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh vbe_list_modes > $@ || (rm -f $@; exit 1)
|
||||
cmd-vbeinfo.lst: commands/i386/pc/vbeinfo.c gencmdlist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbeinfo_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh vbeinfo > $@ || (rm -f $@; exit 1)
|
||||
|
||||
fs-vbe_list_modes.lst: commands/i386/pc/vbe_list_modes.c genfslist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_list_modes_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh vbe_list_modes > $@ || (rm -f $@; exit 1)
|
||||
fs-vbeinfo.lst: commands/i386/pc/vbeinfo.c genfslist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbeinfo_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh vbeinfo > $@ || (rm -f $@; exit 1)
|
||||
|
||||
|
||||
vbe_list_modes_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
vbeinfo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
||||
# For vbe_test.mod.
|
||||
vbe_test_mod_SOURCES = commands/i386/pc/vbe_test.c
|
||||
CLEANFILES += vbe_test.mod mod-vbe_test.o mod-vbe_test.c pre-vbe_test.o vbe_test_mod-commands_i386_pc_vbe_test.o def-vbe_test.lst und-vbe_test.lst
|
||||
MOSTLYCLEANFILES += vbe_test_mod-commands_i386_pc_vbe_test.d
|
||||
DEFSYMFILES += def-vbe_test.lst
|
||||
UNDSYMFILES += und-vbe_test.lst
|
||||
# For vbetest.mod.
|
||||
vbetest_mod_SOURCES = commands/i386/pc/vbetest.c
|
||||
CLEANFILES += vbetest.mod mod-vbetest.o mod-vbetest.c pre-vbetest.o vbetest_mod-commands_i386_pc_vbetest.o def-vbetest.lst und-vbetest.lst
|
||||
MOSTLYCLEANFILES += vbetest_mod-commands_i386_pc_vbetest.d
|
||||
DEFSYMFILES += def-vbetest.lst
|
||||
UNDSYMFILES += und-vbetest.lst
|
||||
|
||||
vbe_test.mod: pre-vbe_test.o mod-vbe_test.o
|
||||
vbetest.mod: pre-vbetest.o mod-vbetest.o
|
||||
-rm -f $@
|
||||
$(LD) -r -d -o $@ $^
|
||||
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||
|
||||
pre-vbe_test.o: vbe_test_mod-commands_i386_pc_vbe_test.o
|
||||
pre-vbetest.o: vbetest_mod-commands_i386_pc_vbetest.o
|
||||
-rm -f $@
|
||||
$(LD) -r -d -o $@ $^
|
||||
|
||||
mod-vbe_test.o: mod-vbe_test.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(vbe_test_mod_CFLAGS) -c -o $@ $<
|
||||
mod-vbetest.o: mod-vbetest.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(vbetest_mod_CFLAGS) -c -o $@ $<
|
||||
|
||||
mod-vbe_test.c: moddep.lst genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh 'vbe_test' $< > $@ || (rm -f $@; exit 1)
|
||||
mod-vbetest.c: moddep.lst genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh 'vbetest' $< > $@ || (rm -f $@; exit 1)
|
||||
|
||||
def-vbe_test.lst: pre-vbe_test.o
|
||||
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 vbe_test/' > $@
|
||||
def-vbetest.lst: pre-vbetest.o
|
||||
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 vbetest/' > $@
|
||||
|
||||
und-vbe_test.lst: pre-vbe_test.o
|
||||
echo 'vbe_test' > $@
|
||||
und-vbetest.lst: pre-vbetest.o
|
||||
echo 'vbetest' > $@
|
||||
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||
|
||||
vbe_test_mod-commands_i386_pc_vbe_test.o: commands/i386/pc/vbe_test.c
|
||||
$(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_test_mod_CFLAGS) -c -o $@ $<
|
||||
vbetest_mod-commands_i386_pc_vbetest.o: commands/i386/pc/vbetest.c
|
||||
$(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbetest_mod_CFLAGS) -c -o $@ $<
|
||||
|
||||
vbe_test_mod-commands_i386_pc_vbe_test.d: commands/i386/pc/vbe_test.c
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_test_mod_CFLAGS) -M $< | sed 's,vbe_test\.o[ :]*,vbe_test_mod-commands_i386_pc_vbe_test.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
|
||||
vbetest_mod-commands_i386_pc_vbetest.d: commands/i386/pc/vbetest.c
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbetest_mod_CFLAGS) -M $< | sed 's,vbetest\.o[ :]*,vbetest_mod-commands_i386_pc_vbetest.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
|
||||
|
||||
-include vbe_test_mod-commands_i386_pc_vbe_test.d
|
||||
-include vbetest_mod-commands_i386_pc_vbetest.d
|
||||
|
||||
CLEANFILES += cmd-vbe_test.lst fs-vbe_test.lst
|
||||
COMMANDFILES += cmd-vbe_test.lst
|
||||
FSFILES += fs-vbe_test.lst
|
||||
CLEANFILES += cmd-vbetest.lst fs-vbetest.lst
|
||||
COMMANDFILES += cmd-vbetest.lst
|
||||
FSFILES += fs-vbetest.lst
|
||||
|
||||
cmd-vbe_test.lst: commands/i386/pc/vbe_test.c gencmdlist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_test_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh vbe_test > $@ || (rm -f $@; exit 1)
|
||||
cmd-vbetest.lst: commands/i386/pc/vbetest.c gencmdlist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbetest_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh vbetest > $@ || (rm -f $@; exit 1)
|
||||
|
||||
fs-vbe_test.lst: commands/i386/pc/vbe_test.c genfslist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbe_test_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh vbe_test > $@ || (rm -f $@; exit 1)
|
||||
fs-vbetest.lst: commands/i386/pc/vbetest.c genfslist.sh
|
||||
set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(vbetest_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh vbetest > $@ || (rm -f $@; exit 1)
|
||||
|
||||
|
||||
vbe_test_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
CLEANFILES += moddep.lst command.lst fs.lst
|
||||
pkgdata_DATA += moddep.lst command.lst fs.lst
|
||||
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep
|
||||
|
|
|
@ -112,7 +112,7 @@ pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod \
|
|||
terminal.mod fshelp.mod chain.mod multiboot.mod amiga.mod \
|
||||
apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod \
|
||||
help.mod default.mod timeout.mod configfile.mod vbe.mod \
|
||||
vesafb.mod vbe_test.mod vbe_list_modes.mod
|
||||
vesafb.mod vbetest.mod vbeinfo.mod
|
||||
|
||||
# For _chain.mod.
|
||||
_chain_mod_SOURCES = loader/i386/pc/chainloader.c
|
||||
|
@ -262,10 +262,10 @@ vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
vesafb_mod_SOURCES = term/i386/pc/vesafb.c
|
||||
vesafb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
||||
# For vbe_list_modes.mod.
|
||||
vbe_list_modes_mod_SOURCES = commands/i386/pc/vbe_list_modes.c
|
||||
vbe_list_modes_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
# For vbeinfo.mod.
|
||||
vbeinfo_mod_SOURCES = commands/i386/pc/vbeinfo.c
|
||||
vbeinfo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
||||
# For vbe_test.mod.
|
||||
vbe_test_mod_SOURCES = commands/i386/pc/vbe_test.c
|
||||
vbe_test_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
# For vbetest.mod.
|
||||
vbetest_mod_SOURCES = commands/i386/pc/vbetest.c
|
||||
vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <grub/fs.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
/* Print the information on the device NAME. */
|
||||
grub_err_t
|
||||
|
|
|
@ -71,45 +71,27 @@ grub_err_t
|
|||
grub_vbe_probe (struct grub_vbe_info_block *info_block)
|
||||
{
|
||||
struct grub_vbe_info_block *vbe_ib;
|
||||
grub_uint32_t rc;
|
||||
grub_vbe_status_t status;
|
||||
|
||||
/* Clear caller's controller info block. */
|
||||
if (info_block != 0)
|
||||
{
|
||||
grub_memset (info_block, 0, sizeof(struct grub_vbe_info_block));
|
||||
}
|
||||
if (info_block)
|
||||
grub_memset (info_block, 0, sizeof (*info_block));
|
||||
|
||||
/* Do not probe more than one time. */
|
||||
if (vbe_detected != -1)
|
||||
/* Do not probe more than one time, if not necessary. */
|
||||
if (vbe_detected == -1 || info_block)
|
||||
{
|
||||
if (vbe_detected == 1)
|
||||
{
|
||||
/* Make copy of controller info block to caller. */
|
||||
if (info_block != 0)
|
||||
{
|
||||
grub_memcpy (info_block,
|
||||
&controller_info,
|
||||
sizeof(struct grub_vbe_info_block));
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear old copy of controller info block. */
|
||||
grub_memset (&controller_info, 0, sizeof(struct grub_vbe_info_block));
|
||||
grub_memset (&controller_info, 0, sizeof (controller_info));
|
||||
|
||||
/* Mark VESA BIOS extension as undetected. */
|
||||
vbe_detected = 0;
|
||||
|
||||
/* Use low memory scratch area as temporary storage for VESA BIOS call. */
|
||||
/* Use low memory scratch area as temporary storage
|
||||
for VESA BIOS call. */
|
||||
vbe_ib = (struct grub_vbe_info_block *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
|
||||
/* Prepare info block. */
|
||||
grub_memset (vbe_ib, 0, sizeof(struct grub_vbe_info_block));
|
||||
grub_memset (vbe_ib, 0, sizeof (*vbe_ib));
|
||||
|
||||
vbe_ib->signature[0] = 'V';
|
||||
vbe_ib->signature[1] = 'B';
|
||||
|
@ -117,24 +99,23 @@ grub_vbe_probe (struct grub_vbe_info_block *info_block)
|
|||
vbe_ib->signature[3] = '2';
|
||||
|
||||
/* Try to get controller info block. */
|
||||
rc = grub_vbe_get_controller_info (vbe_ib);
|
||||
if (rc != 0x004F)
|
||||
status = grub_vbe_get_controller_info (vbe_ib);
|
||||
if (status == 0x004F)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
|
||||
/* Copy it for later usage. */
|
||||
grub_memcpy (&controller_info,
|
||||
vbe_ib,
|
||||
sizeof(struct grub_vbe_info_block));
|
||||
|
||||
/* Copy it for caller. */
|
||||
grub_memcpy (info_block,
|
||||
vbe_ib,
|
||||
sizeof(struct grub_vbe_info_block));
|
||||
grub_memcpy (&controller_info, vbe_ib, sizeof (controller_info));
|
||||
|
||||
/* Mark VESA BIOS extension as detected. */
|
||||
vbe_detected = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (! vbe_detected)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "VESA BIOS Extension not found");
|
||||
|
||||
/* Make copy of controller info block to caller. */
|
||||
if (info_block)
|
||||
grub_memcpy (info_block, &controller_info, sizeof (*info_block));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -143,20 +124,16 @@ grub_err_t
|
|||
grub_vbe_set_video_mode (grub_uint32_t mode,
|
||||
struct grub_vbe_mode_info_block *mode_info)
|
||||
{
|
||||
grub_uint32_t rc;
|
||||
grub_vbe_status_t status;
|
||||
grub_uint32_t old_mode;
|
||||
|
||||
/* If grub_vesafb_probe has not been called or no VBE, abort. */
|
||||
if (vbe_detected == 0)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
/* Make sure that VBE is supported. */
|
||||
if (grub_vbe_probe (0) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
/* Try to get mode info. */
|
||||
rc = grub_vbe_get_video_mode_info (mode, &active_mode_info);
|
||||
if (rc != GRUB_ERR_NONE)
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
if (grub_vbe_get_video_mode_info (mode, &active_mode_info) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
/* For all VESA BIOS modes, force linear frame buffer. */
|
||||
if (mode >= 0x100)
|
||||
|
@ -165,7 +142,7 @@ grub_vbe_set_video_mode (grub_uint32_t mode,
|
|||
mode |= 1 << 14;
|
||||
|
||||
/* Determine frame buffer pixel format. */
|
||||
switch(active_mode_info.memory_model)
|
||||
switch (active_mode_info.memory_model)
|
||||
{
|
||||
case 0x04:
|
||||
index_color_mode = 1;
|
||||
|
@ -176,16 +153,20 @@ grub_vbe_set_video_mode (grub_uint32_t mode,
|
|||
break;
|
||||
|
||||
default:
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"unsupported pixel format 0x%x",
|
||||
active_mode_info.memory_model);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get current mode. */
|
||||
if (grub_vbe_get_video_mode (&old_mode) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
/* Try to set video mode. */
|
||||
rc = grub_vbe_set_mode (mode, 0);
|
||||
if (rc != 0x004F)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
status = grub_vbe_set_mode (mode, 0);
|
||||
if (status != 0x004F)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot set VBE mode %x", mode);
|
||||
|
||||
/* Save information for later usage. */
|
||||
active_mode = mode;
|
||||
|
@ -193,40 +174,43 @@ grub_vbe_set_video_mode (grub_uint32_t mode,
|
|||
if (mode < 0x100)
|
||||
{
|
||||
/* If this is not a VESA mode, guess address. */
|
||||
framebuffer = (grub_uint8_t *)0xA0000;
|
||||
framebuffer = (grub_uint8_t *) 0xA0000;
|
||||
index_color_mode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
framebuffer = (grub_uint8_t *)active_mode_info.phys_base_addr;
|
||||
framebuffer = (grub_uint8_t *) active_mode_info.phys_base_addr;
|
||||
|
||||
if (controller_info.version >= 0x300)
|
||||
{
|
||||
bytes_per_scan_line = active_mode_info.lin_bytes_per_scan_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes_per_scan_line = active_mode_info.bytes_per_scan_line;
|
||||
}
|
||||
}
|
||||
|
||||
/* If video mode is in indexed color, setup default VGA palette. */
|
||||
if (index_color_mode != 0)
|
||||
if (index_color_mode)
|
||||
{
|
||||
rc = grub_vbe_set_palette_data (16, 0, vga_colors);
|
||||
if (rc != 0x004F)
|
||||
struct grub_vbe_palette_data *palette
|
||||
= (struct grub_vbe_palette_data *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
|
||||
/* Make sure that the BIOS can reach the palette. */
|
||||
grub_memcpy (palette, vga_colors, sizeof (vga_colors));
|
||||
status = grub_vbe_set_palette_data (16, 0, palette);
|
||||
|
||||
/* For now, ignore the status. Not sure if this is fatal. */
|
||||
#if 0
|
||||
if (status != 0x004F)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
grub_vbe_set_mode (old_mode, 0);
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot set the default VGA palette");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Copy mode info for caller. */
|
||||
if (mode_info != 0)
|
||||
{
|
||||
grub_memcpy (mode_info,
|
||||
&active_mode_info,
|
||||
sizeof(struct grub_vbe_mode_info_block));
|
||||
}
|
||||
if (mode_info)
|
||||
grub_memcpy (mode_info, &active_mode_info, sizeof (*mode_info));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -234,20 +218,16 @@ grub_vbe_set_video_mode (grub_uint32_t mode,
|
|||
grub_err_t
|
||||
grub_vbe_get_video_mode (grub_uint32_t *mode)
|
||||
{
|
||||
grub_uint32_t rc;
|
||||
grub_vbe_status_t status;
|
||||
|
||||
/* If grub_vesafb_probe has not been called or no VBE, abort. */
|
||||
if (vbe_detected == 0)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
/* Make sure that VBE is supported. */
|
||||
if (grub_vbe_probe (0) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
/* Try to query current mode from VESA BIOS. */
|
||||
rc = grub_vbe_get_mode (mode);
|
||||
if (rc != 0x004F)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
status = grub_vbe_get_mode (mode);
|
||||
if (status != 0x004F)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get current VBE mode");
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -256,37 +236,29 @@ grub_err_t
|
|||
grub_vbe_get_video_mode_info (grub_uint32_t mode,
|
||||
struct grub_vbe_mode_info_block *mode_info)
|
||||
{
|
||||
struct grub_vbe_mode_info_block *mi_tmp = (struct grub_vbe_mode_info_block *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
grub_uint32_t rc;
|
||||
struct grub_vbe_mode_info_block *mi_tmp
|
||||
= (struct grub_vbe_mode_info_block *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
grub_vbe_status_t status;
|
||||
|
||||
/* If grub_vesafb_probe has not been called or no VBE, abort. */
|
||||
if (vbe_detected == 0)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
/* Make sure that VBE is supported. */
|
||||
if (grub_vbe_probe (0) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
/* If mode is not VESA mode, skip mode info query. */
|
||||
if (mode >= 0x100)
|
||||
{
|
||||
/* Try to get mode info from VESA BIOS. */
|
||||
rc = grub_vbe_get_mode_info (mode, mi_tmp);
|
||||
if (rc != 0x004F)
|
||||
{
|
||||
return GRUB_ERR_BAD_DEVICE;
|
||||
}
|
||||
status = grub_vbe_get_mode_info (mode, mi_tmp);
|
||||
if (status != 0x004F)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot get information on the mode %x", mode);
|
||||
|
||||
/* Make copy of mode info block. */
|
||||
grub_memcpy (mode_info,
|
||||
mi_tmp,
|
||||
sizeof(struct grub_vbe_mode_info_block));
|
||||
grub_memcpy (mode_info, mi_tmp, sizeof (*mode_info));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just clear mode info block if it isn't a VESA mode. */
|
||||
grub_memset (mode_info,
|
||||
0,
|
||||
sizeof(struct grub_vbe_mode_info_block));
|
||||
}
|
||||
grub_memset (mode_info, 0, sizeof (*mode_info));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -327,33 +299,44 @@ grub_vbe_set_pixel_rgb (grub_uint32_t x,
|
|||
value |= blue << active_mode_info.blue_field_position;
|
||||
}
|
||||
|
||||
if (active_mode_info.bits_per_pixel == 32)
|
||||
switch (active_mode_info.bits_per_pixel)
|
||||
{
|
||||
grub_uint32_t *ptr = (grub_uint32_t *)(framebuffer
|
||||
case 32:
|
||||
{
|
||||
grub_uint32_t *ptr = (grub_uint32_t *) (framebuffer
|
||||
+ y * bytes_per_scan_line
|
||||
+ x * 4);
|
||||
|
||||
*ptr = value;
|
||||
}
|
||||
else if (active_mode_info.bits_per_pixel == 24)
|
||||
break;
|
||||
|
||||
case 24:
|
||||
{
|
||||
grub_uint8_t *ptr = (grub_uint8_t *)(framebuffer
|
||||
grub_uint8_t *ptr = (grub_uint8_t *) (framebuffer
|
||||
+ y * bytes_per_scan_line
|
||||
+ x * 3);
|
||||
grub_uint8_t *ptr2 = (grub_uint8_t *)&value;
|
||||
grub_uint8_t *ptr2 = (grub_uint8_t *) &value;
|
||||
|
||||
ptr[0] = ptr2[0];
|
||||
ptr[1] = ptr2[1];
|
||||
ptr[2] = ptr2[2];
|
||||
}
|
||||
else if ((active_mode_info.bits_per_pixel == 16) ||
|
||||
(active_mode_info.bits_per_pixel == 15))
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case 15:
|
||||
{
|
||||
grub_uint16_t *ptr = (grub_uint16_t *)(framebuffer
|
||||
grub_uint16_t *ptr = (grub_uint16_t *) (framebuffer
|
||||
+ y * bytes_per_scan_line
|
||||
+ x * 2);
|
||||
|
||||
*ptr = (grub_uint16_t)(value & 0xFFFF);
|
||||
*ptr = (grub_uint16_t) (value & 0xFFFF);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +353,7 @@ grub_vbe_set_pixel_index (grub_uint32_t x,
|
|||
|
||||
if (index_color_mode == 1)
|
||||
{
|
||||
grub_uint8_t *ptr = (grub_uint8_t *)(framebuffer
|
||||
grub_uint8_t *ptr = (grub_uint8_t *) (framebuffer
|
||||
+ y * bytes_per_scan_line
|
||||
+ x);
|
||||
|
||||
|
|
Loading…
Reference in a new issue