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

« back to all changes in this revision

Viewing changes to grub-core/kern/efi/init.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Robert Millan, Updated translations
  • Date: 2010-11-22 12:24:56 UTC
  • mfrom: (1.26.4 upstream) (17.3.36 sid)
  • mto: (17.3.43 sid)
  • mto: This revision was merged to the branch mainline in revision 89.
  • Revision ID: james.westby@ubuntu.com-20101122122456-y82z3sfb7k4zfdcc
Tags: 1.99~20101122-1
[ Colin Watson ]
* New Bazaar snapshot.  Too many changes to list in full, but some of the
  more user-visible ones are as follows:
  - GRUB script:
    + Function parameters, "break", "continue", "shift", "setparams",
      "return", and "!".
    + "export" command supports multiple variable names.
    + Multi-line quoted strings support.
    + Wildcard expansion.
  - sendkey support.
  - USB hotunplugging and USB serial support.
  - Rename CD-ROM to cd on BIOS.
  - Add new --boot-directory option to grub-install, grub-reboot, and
    grub-set-default; the old --root-directory option is still accepted
    but was often confusing.
  - Basic btrfs detection/UUID support (but no file reading yet).
  - bash-completion for utilities.
  - If a device is listed in device.map, always assume that it is
    BIOS-visible rather than using extra layers such as LVM or RAID.
  - Add grub-mknetdir script (closes: #550658).
  - Remove deprecated "root" command.
  - Handle RAID devices containing virtio components.
  - GRUB Legacy configuration file support (via grub-menulst2cfg).
  - Keyboard layout support (via grub-mklayout and grub-kbdcomp).
  - Check generated grub.cfg for syntax errors before saving.
  - Pause execution for at most ten seconds if any errors are displayed,
    so that the user has a chance to see them.
  - Support submenus.
  - Write embedding zone using Reed-Solomon, so that it's robust against
    being partially overwritten (closes: #550702, #591416, #593347).
  - GRUB_DISABLE_LINUX_RECOVERY and GRUB_DISABLE_NETBSD_RECOVERY merged
    into a single GRUB_DISABLE_RECOVERY variable.
  - Fix loader memory allocation failure (closes: #551627).
  - Don't call savedefault on recovery entries (closes: #589325).
  - Support triple-indirect blocks on ext2 (closes: #543924).
  - Recognise DDF1 fake RAID (closes: #603354).

[ Robert Millan ]
* Use dpkg architecture wildcards.

[ Updated translations ]
* Slovenian (Vanja Cvelbar).  Closes: #604003
* Dzongkha (dawa pemo via Tenzin Dendup).  Closes: #604102

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* init.c - generic EFI initialization and finalization */
 
2
/*
 
3
 *  GRUB  --  GRand Unified Bootloader
 
4
 *  Copyright (C) 2006,2007  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/efi/efi.h>
 
21
#include <grub/efi/console.h>
 
22
#include <grub/efi/disk.h>
 
23
#include <grub/term.h>
 
24
#include <grub/misc.h>
 
25
#include <grub/env.h>
 
26
#include <grub/mm.h>
 
27
#include <grub/kernel.h>
 
28
 
 
29
void
 
30
grub_efi_init (void)
 
31
{
 
32
  /* First of all, initialize the console so that GRUB can display
 
33
     messages.  */
 
34
  grub_console_init ();
 
35
 
 
36
  /* Initialize the memory management system.  */
 
37
  grub_efi_mm_init ();
 
38
 
 
39
  efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
 
40
              0, 0, 0, NULL);
 
41
 
 
42
  grub_efidisk_init ();
 
43
}
 
44
 
 
45
void
 
46
grub_efi_set_prefix (void)
 
47
{
 
48
  grub_efi_loaded_image_t *image = NULL;
 
49
  char *device = NULL;
 
50
  char *path = NULL;
 
51
 
 
52
  {
 
53
    char *pptr = NULL;
 
54
    if (grub_prefix[0] == '(')
 
55
      {
 
56
        pptr = grub_strrchr (grub_prefix, ')');
 
57
        if (pptr)
 
58
          {
 
59
            device = grub_strndup (grub_prefix + 1, pptr - grub_prefix - 1);
 
60
            pptr++;
 
61
          }
 
62
      }
 
63
    if (!pptr)
 
64
      pptr = grub_prefix;
 
65
    if (pptr[0])
 
66
      path = grub_strdup (pptr);
 
67
  }
 
68
 
 
69
  if ((!device || device[0] == ',' || !device[0]) || !path)
 
70
    image = grub_efi_get_loaded_image (grub_efi_image_handle);
 
71
  if (image)
 
72
    {
 
73
      if (!device)
 
74
        device = grub_efidisk_get_device_name (image->device_handle);
 
75
      else if (device[0] == ',' || !device[0])
 
76
        {
 
77
          /* We have a partition, but still need to fill in the drive.  */
 
78
          char *image_device, *comma, *new_device;
 
79
 
 
80
          image_device = grub_efidisk_get_device_name (image->device_handle);
 
81
          comma = grub_strchr (image_device, ',');
 
82
          if (comma)
 
83
            {
 
84
              char *drive = grub_strndup (image_device, comma - image_device);
 
85
              new_device = grub_xasprintf ("%s%s", drive, device);
 
86
              grub_free (drive);
 
87
            }
 
88
          else
 
89
            new_device = grub_xasprintf ("%s%s", image_device, device);
 
90
 
 
91
          grub_free (image_device);
 
92
          grub_free (device);
 
93
          device = new_device;
 
94
        }
 
95
    }
 
96
 
 
97
  if (image && !path)
 
98
    {
 
99
      char *p;
 
100
 
 
101
      path = grub_efi_get_filename (image->file_path);
 
102
 
 
103
      /* Get the directory.  */
 
104
      p = grub_strrchr (path, '/');
 
105
      if (p)
 
106
        *p = '\0';
 
107
    }
 
108
 
 
109
  if (device && path)
 
110
    {
 
111
      char *prefix;
 
112
 
 
113
      prefix = grub_xasprintf ("(%s)%s", device, path);
 
114
      if (prefix)
 
115
        {
 
116
          grub_env_set ("prefix", prefix);
 
117
          grub_free (prefix);
 
118
        }
 
119
    }
 
120
 
 
121
  grub_free (device);
 
122
  grub_free (path);
 
123
}
 
124
 
 
125
void
 
126
grub_efi_fini (void)
 
127
{
 
128
  grub_efidisk_fini ();
 
129
  grub_console_fini ();
 
130
}