~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to commands/i386/pc/vbeinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu.  Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed.  If it is, show the
    menu, otherwise boot immediately.  If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt.  Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* vbeinfo.c - command to list compatible VBE video modes.  */
2
 
/*
3
 
 *  GRUB  --  GRand Unified Bootloader
4
 
 *  Copyright (C) 2005,2007,2008,2009  Free Software Foundation, Inc.
5
 
 *
6
 
 *  GRUB is free software: you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation, either version 3 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  GRUB is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18
 
 */
19
 
 
20
 
#include <grub/dl.h>
21
 
#include <grub/env.h>
22
 
#include <grub/misc.h>
23
 
#include <grub/machine/init.h>
24
 
#include <grub/machine/vbe.h>
25
 
#include <grub/mm.h>
26
 
#include <grub/command.h>
27
 
#include <grub/i18n.h>
28
 
 
29
 
static void *
30
 
real2pm (grub_vbe_farptr_t ptr)
31
 
{
32
 
  return (void *) ((((unsigned long) ptr & 0xFFFF0000) >> 12UL)
33
 
                   + ((unsigned long) ptr & 0x0000FFFF));
34
 
}
35
 
 
36
 
static grub_err_t
37
 
grub_cmd_vbeinfo (grub_command_t cmd __attribute__ ((unused)),
38
 
                  int argc __attribute__ ((unused)),
39
 
                  char **args __attribute__ ((unused)))
40
 
{
41
 
  struct grub_vbe_info_block controller_info;
42
 
  struct grub_vbe_mode_info_block mode_info_tmp;
43
 
  grub_uint32_t use_mode = GRUB_VBE_DEFAULT_VIDEO_MODE;
44
 
  grub_uint16_t *video_mode_list;
45
 
  grub_uint16_t *p;
46
 
  grub_uint16_t *saved_video_mode_list;
47
 
  grub_size_t video_mode_list_size;
48
 
  grub_err_t err;
49
 
  char *modevar;
50
 
 
51
 
  err = grub_vbe_probe (&controller_info);
52
 
  if (err != GRUB_ERR_NONE)
53
 
    return err;
54
 
 
55
 
  grub_printf ("VBE info:   version: %d.%d  OEM software rev: %d.%d\n",
56
 
               controller_info.version >> 8,
57
 
               controller_info.version & 0xFF,
58
 
               controller_info.oem_software_rev >> 8,
59
 
               controller_info.oem_software_rev & 0xFF);
60
 
 
61
 
  /* The total_memory field is in 64 KiB units.  */
62
 
  grub_printf ("            total memory: %d KiB\n",
63
 
               (controller_info.total_memory << 16) / 1024);
64
 
 
65
 
  /* Because the information on video modes is stored in a temporary place,
66
 
     it is better to copy it to somewhere safe.  */
67
 
  p = video_mode_list = real2pm (controller_info.video_mode_ptr);
68
 
  while (*p++ != 0xFFFF)
69
 
    ;
70
 
 
71
 
  video_mode_list_size = (grub_addr_t) p - (grub_addr_t) video_mode_list;
72
 
  saved_video_mode_list = grub_malloc (video_mode_list_size);
73
 
  if (! saved_video_mode_list)
74
 
    return grub_errno;
75
 
 
76
 
  grub_memcpy (saved_video_mode_list, video_mode_list, video_mode_list_size);
77
 
 
78
 
  grub_printf ("List of compatible video modes:\n");
79
 
  grub_printf ("Legend: P=Packed pixel, D=Direct color, "
80
 
               "mask/pos=R/G/B/reserved\n");
81
 
 
82
 
  /* Walk through all video modes listed.  */
83
 
  for (p = saved_video_mode_list; *p != 0xFFFF; p++)
84
 
    {
85
 
      const char *memory_model = 0;
86
 
      grub_uint32_t mode = (grub_uint32_t) *p;
87
 
 
88
 
      err = grub_vbe_get_video_mode_info (mode, &mode_info_tmp);
89
 
      if (err != GRUB_ERR_NONE)
90
 
        {
91
 
          grub_errno = GRUB_ERR_NONE;
92
 
          continue;
93
 
        }
94
 
 
95
 
      if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_SUPPORTED) == 0)
96
 
        /* If not available, skip it.  */
97
 
        continue;
98
 
 
99
 
      if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_RESERVED_1) == 0)
100
 
        /* Not enough information.  */
101
 
        continue;
102
 
 
103
 
      if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_COLOR) == 0)
104
 
        /* Monochrome is unusable.  */
105
 
        continue;
106
 
 
107
 
      if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_LFB_AVAIL) == 0)
108
 
        /* We support only linear frame buffer modes.  */
109
 
        continue;
110
 
 
111
 
      if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_GRAPHICS) == 0)
112
 
        /* We allow only graphical modes.  */
113
 
        continue;
114
 
 
115
 
      switch (mode_info_tmp.memory_model)
116
 
        {
117
 
        case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL:
118
 
          memory_model = "Packed";
119
 
          break;
120
 
        case GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR:
121
 
          memory_model = "Direct";
122
 
          break;
123
 
 
124
 
        default:
125
 
          break;
126
 
        }
127
 
 
128
 
      if (! memory_model)
129
 
        continue;
130
 
 
131
 
      grub_printf ("0x%03x:  %4d x %4d x %2d  %s",
132
 
                   mode,
133
 
                   mode_info_tmp.x_resolution,
134
 
                   mode_info_tmp.y_resolution,
135
 
                   mode_info_tmp.bits_per_pixel,
136
 
                   memory_model);
137
 
 
138
 
      /* Show mask and position details for direct color modes.  */
139
 
      if (mode_info_tmp.memory_model == GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)
140
 
        grub_printf (", mask: %d/%d/%d/%d  pos: %d/%d/%d/%d",
141
 
                     mode_info_tmp.red_mask_size,
142
 
                     mode_info_tmp.green_mask_size,
143
 
                     mode_info_tmp.blue_mask_size,
144
 
                     mode_info_tmp.rsvd_mask_size,
145
 
                     mode_info_tmp.red_field_position,
146
 
                     mode_info_tmp.green_field_position,
147
 
                     mode_info_tmp.blue_field_position,
148
 
                     mode_info_tmp.rsvd_field_position);
149
 
      grub_printf ("\n");
150
 
    }
151
 
 
152
 
  grub_free (saved_video_mode_list);
153
 
 
154
 
  /* Check existence of vbe_mode environment variable.  */
155
 
  modevar = grub_env_get ("vbe_mode");
156
 
 
157
 
  if (modevar != 0)
158
 
    {
159
 
      unsigned long value;
160
 
 
161
 
      value = grub_strtoul (modevar, 0, 0);
162
 
      if (grub_errno == GRUB_ERR_NONE)
163
 
        use_mode = value;
164
 
      else
165
 
        grub_errno = GRUB_ERR_NONE;
166
 
    }
167
 
 
168
 
  grub_printf ("Configured VBE mode (vbe_mode) = 0x%03x\n", use_mode);
169
 
 
170
 
  return 0;
171
 
}
172
 
 
173
 
static grub_command_t cmd;
174
 
 
175
 
GRUB_MOD_INIT(vbeinfo)
176
 
{
177
 
  cmd =
178
 
    grub_register_command ("vbeinfo", grub_cmd_vbeinfo, 0,
179
 
                           N_("List compatible VESA BIOS extension video modes."));
180
 
}
181
 
 
182
 
GRUB_MOD_FINI(vbeinfo)
183
 
{
184
 
  grub_unregister_command (cmd);
185
 
}