~ubuntu-branches/debian/sid/grub2/sid-200907171837

« back to all changes in this revision

Viewing changes to kern/efi/init.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2006-06-10 19:57:01 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060610195701-2khcfacexb229tq4
Tags: 1.94-3
Fix FTBFS in amd64. Closes: 372548

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  Free Software Foundation, Inc.
 
5
 *
 
6
 *  This program 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 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program 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 this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
19
 *  MA  02110-1301, USA.
 
20
 */
 
21
 
 
22
#include <grub/efi/efi.h>
 
23
#include <grub/efi/console.h>
 
24
#include <grub/efi/disk.h>
 
25
#include <grub/term.h>
 
26
#include <grub/misc.h>
 
27
#include <grub/env.h>
 
28
#include <grub/mm.h>
 
29
#include <grub/machine/kernel.h>
 
30
 
 
31
void
 
32
grub_efi_init (void)
 
33
{
 
34
  /* First of all, initialize the console so that GRUB can display
 
35
     messages.  */
 
36
  grub_console_init ();
 
37
 
 
38
  /* Initialize the memory management system.  */
 
39
  grub_efi_mm_init ();
 
40
 
 
41
  grub_efidisk_init ();
 
42
}
 
43
 
 
44
void
 
45
grub_efi_set_prefix (void)
 
46
{
 
47
  grub_efi_loaded_image_t *image;
 
48
  
 
49
  image = grub_efi_get_loaded_image (grub_efi_image_handle);
 
50
  if (image)
 
51
    {
 
52
      char *device;
 
53
      char *file;
 
54
 
 
55
      device = grub_efidisk_get_device_name (image->device_handle);
 
56
      file = grub_efi_get_filename (image->file_path);
 
57
      
 
58
      if (device && file)
 
59
        {
 
60
          char *p;
 
61
          char *prefix;
 
62
          
 
63
          /* Get the directory.  */
 
64
          p = grub_strrchr (file, '/');
 
65
          if (p)
 
66
            *p = '\0';
 
67
 
 
68
          prefix = grub_malloc (1 + grub_strlen (device) + 1
 
69
                                + grub_strlen (file) + 1);
 
70
          if (prefix)
 
71
            {
 
72
              grub_sprintf (prefix, "(%s)%s", device, file);
 
73
              grub_env_set ("prefix", prefix);
 
74
              grub_free (prefix);
 
75
            }
 
76
        }
 
77
      
 
78
      grub_free (device);
 
79
      grub_free (file);
 
80
    }
 
81
}
 
82
 
 
83
void
 
84
grub_efi_fini (void)
 
85
{
 
86
  grub_efidisk_fini ();
 
87
  grub_efi_mm_fini ();
 
88
  grub_console_fini ();
 
89
}