~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to efiemu/prepare.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
 
/* Prepare efiemu. E.g. allocate memory, load the runtime
2
 
   to appropriate place, etc */
3
 
/*
4
 
 *  GRUB  --  GRand Unified Bootloader
5
 
 *  Copyright (C) 2009  Free Software Foundation, Inc.
6
 
 *
7
 
 *  GRUB is free software: you can redistribute it and/or modify
8
 
 *  it under the terms of the GNU General Public License as published by
9
 
 *  the Free Software Foundation, either version 3 of the License, or
10
 
 *  (at your option) any later version.
11
 
 *
12
 
 *  GRUB is distributed in the hope that it will be useful,
13
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 *  GNU General Public License for more details.
16
 
 *
17
 
 *  You should have received a copy of the GNU General Public License
18
 
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
19
 
 */
20
 
 
21
 
#include <grub/err.h>
22
 
#include <grub/mm.h>
23
 
#include <grub/misc.h>
24
 
#include <grub/efiemu/efiemu.h>
25
 
#include <grub/lib/crc.h>
26
 
 
27
 
grub_err_t
28
 
SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
29
 
                              struct grub_efiemu_configuration_table
30
 
                              *config_tables)
31
 
{
32
 
  grub_err_t err;
33
 
  int conftable_handle;
34
 
  struct grub_efiemu_configuration_table *cur;
35
 
  struct grub_efiemu_prepare_hook *curhook;
36
 
 
37
 
  int cntconftables = 0;
38
 
  struct SUFFIX (grub_efiemu_configuration_table) *conftables = 0;
39
 
  int i;
40
 
  int handle;
41
 
  grub_off_t off;
42
 
 
43
 
  grub_dprintf ("efiemu", "Preparing EfiEmu\n");
44
 
 
45
 
  /* Request space for the list of configuration tables */
46
 
  for (cur = config_tables; cur; cur = cur->next)
47
 
    cntconftables++;
48
 
  conftable_handle
49
 
    = grub_efiemu_request_memalign (GRUB_EFIEMU_PAGESIZE,
50
 
                                    cntconftables * sizeof (*conftables),
51
 
                                    GRUB_EFI_RUNTIME_SERVICES_DATA);
52
 
 
53
 
  /* Switch from phase 1 (counting) to phase 2 (real job) */
54
 
  grub_efiemu_alloc_syms ();
55
 
  grub_efiemu_mm_do_alloc ();
56
 
  grub_efiemu_write_sym_markers ();
57
 
 
58
 
  grub_efiemu_system_table32 = 0;
59
 
  grub_efiemu_system_table64 = 0;
60
 
 
61
 
  /* Execute hooks */
62
 
  for (curhook = prepare_hooks; curhook; curhook = curhook->next)
63
 
    curhook->hook (curhook->data);
64
 
 
65
 
  /* Move runtime to its due place */
66
 
  err = grub_efiemu_loadcore_load ();
67
 
  if (err)
68
 
    {
69
 
      grub_efiemu_unload ();
70
 
      return err;
71
 
    }
72
 
 
73
 
  err = grub_efiemu_resolve_symbol ("efiemu_system_table", &handle, &off);
74
 
  if (err)
75
 
    {
76
 
      grub_efiemu_unload ();
77
 
      return err;
78
 
    }
79
 
 
80
 
  SUFFIX (grub_efiemu_system_table)
81
 
    = (struct SUFFIX (grub_efi_system_table) *)
82
 
    ((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
83
 
 
84
 
  /* Put pointer to the list of configuration tables in system table */
85
 
  grub_efiemu_write_value
86
 
    (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
87
 
     conftable_handle, 0, 1,
88
 
     sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table));
89
 
  SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables;
90
 
 
91
 
  /* Fill the list of configuration tables */
92
 
  conftables = (struct SUFFIX (grub_efiemu_configuration_table) *)
93
 
    grub_efiemu_mm_obtain_request (conftable_handle);
94
 
  i = 0;
95
 
  for (cur = config_tables; cur; cur = cur->next, i++)
96
 
    {
97
 
      grub_memcpy (&(conftables[i].vendor_guid), &(cur->guid),
98
 
                       sizeof (cur->guid));
99
 
      if (cur->get_table)
100
 
        conftables[i].vendor_table
101
 
          = PTR_TO_UINT64 (cur->get_table (cur->data));
102
 
      else
103
 
        conftables[i].vendor_table = PTR_TO_UINT64 (cur->data);
104
 
    }
105
 
 
106
 
  err = SUFFIX (grub_efiemu_crc) ();
107
 
  if (err)
108
 
    {
109
 
      grub_efiemu_unload ();
110
 
      return err;
111
 
    }
112
 
 
113
 
  grub_dprintf ("efiemu","system_table = %p, conftables = %p (%d entries)\n",
114
 
                SUFFIX (grub_efiemu_system_table), conftables, cntconftables);
115
 
 
116
 
  return GRUB_ERR_NONE;
117
 
}
118
 
 
119
 
grub_err_t
120
 
SUFFIX (grub_efiemu_crc) (void)
121
 
{
122
 
  grub_err_t err;
123
 
  int handle;
124
 
  grub_off_t off;
125
 
  struct SUFFIX (grub_efiemu_runtime_services) *runtime_services;
126
 
 
127
 
  /* compute CRC32 of runtime_services */
128
 
  err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
129
 
                                    &handle, &off);
130
 
  if (err)
131
 
    return err;
132
 
 
133
 
  runtime_services = (struct SUFFIX (grub_efiemu_runtime_services) *)
134
 
        ((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
135
 
  runtime_services->hdr.crc32 = 0;
136
 
  runtime_services->hdr.crc32 = grub_getcrc32
137
 
    (0, runtime_services, runtime_services->hdr.header_size);
138
 
 
139
 
  err = grub_efiemu_resolve_symbol ("efiemu_system_table", &handle, &off);
140
 
  if (err)
141
 
    return err;
142
 
 
143
 
  /* compute CRC32 of system table */
144
 
  SUFFIX (grub_efiemu_system_table)->hdr.crc32 = 0;
145
 
  SUFFIX (grub_efiemu_system_table)->hdr.crc32
146
 
    = grub_getcrc32 (0, SUFFIX (grub_efiemu_system_table),
147
 
                     SUFFIX (grub_efiemu_system_table)->hdr.header_size);
148
 
 
149
 
  grub_dprintf ("efiemu","system_table = %p, runtime_services = %p\n",
150
 
                SUFFIX (grub_efiemu_system_table), runtime_services);
151
 
 
152
 
  return GRUB_ERR_NONE;
153
 
}