Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / common / boot / grub2 / kern / efi / init.c
blob115a087fadbb87430e7d8326946a0c7a2f40625d
1 /* init.c - generic EFI initialization and finalization */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2006,2007 Free Software Foundation, Inc.
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.
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.
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/>.
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/machine/kernel.h>
29 void
30 grub_efi_init (void)
32 /* First of all, initialize the console so that GRUB can display
33 messages. */
34 grub_console_init ();
36 /* Initialize the memory management system. */
37 grub_efi_mm_init ();
39 grub_efidisk_init ();
42 void
43 grub_efi_set_prefix (void)
45 grub_efi_loaded_image_t *image;
47 image = grub_efi_get_loaded_image (grub_efi_image_handle);
48 if (image)
50 char *device;
51 char *file;
53 device = grub_efidisk_get_device_name (image->device_handle);
54 file = grub_efi_get_filename (image->file_path);
56 if (device && file)
58 char *p;
59 char *prefix;
61 /* Get the directory. */
62 p = grub_strrchr (file, '/');
63 if (p)
64 *p = '\0';
66 prefix = grub_malloc (1 + grub_strlen (device) + 1
67 + grub_strlen (file) + 1);
68 if (prefix)
70 grub_sprintf (prefix, "(%s)%s", device, file);
71 grub_env_set ("prefix", prefix);
72 grub_free (prefix);
76 grub_free (device);
77 grub_free (file);
81 void
82 grub_efi_fini (void)
84 grub_efidisk_fini ();
85 grub_efi_mm_fini ();
86 grub_console_fini ();