2006-04-19 08:59:44 +00:00
|
|
|
/* init.c - generic EFI initialization and finalization */
|
|
|
|
/*
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
2007-07-21 23:32:33 +00:00
|
|
|
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
|
2006-04-19 08:59:44 +00:00
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
2006-04-19 08:59:44 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-21 23:32:33 +00:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2006-04-19 08:59:44 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
2006-04-19 08:59:44 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-21 23:32:33 +00:00
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2006-04-19 08:59:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <grub/efi/efi.h>
|
|
|
|
#include <grub/efi/console.h>
|
2006-04-23 13:37:36 +00:00
|
|
|
#include <grub/efi/disk.h>
|
2006-04-19 08:59:44 +00:00
|
|
|
#include <grub/term.h>
|
|
|
|
#include <grub/misc.h>
|
2006-04-23 13:37:36 +00:00
|
|
|
#include <grub/env.h>
|
2006-04-25 20:08:31 +00:00
|
|
|
#include <grub/mm.h>
|
2010-04-27 09:08:53 +00:00
|
|
|
#include <grub/kernel.h>
|
2006-04-19 08:59:44 +00:00
|
|
|
|
2011-10-16 13:23:29 +00:00
|
|
|
grub_addr_t grub_modbase;
|
|
|
|
|
2006-04-19 08:59:44 +00:00
|
|
|
void
|
|
|
|
grub_efi_init (void)
|
|
|
|
{
|
2011-10-16 13:23:29 +00:00
|
|
|
grub_modbase = grub_efi_modules_addr ();
|
2006-04-19 08:59:44 +00:00
|
|
|
/* First of all, initialize the console so that GRUB can display
|
|
|
|
messages. */
|
|
|
|
grub_console_init ();
|
|
|
|
|
|
|
|
/* Initialize the memory management system. */
|
|
|
|
grub_efi_mm_init ();
|
|
|
|
|
2010-07-02 12:42:18 +00:00
|
|
|
efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
|
|
|
|
0, 0, 0, NULL);
|
2010-07-02 00:43:09 +00:00
|
|
|
|
2006-04-23 13:37:36 +00:00
|
|
|
grub_efidisk_init ();
|
2006-04-25 20:08:31 +00:00
|
|
|
}
|
|
|
|
|
2011-07-02 14:56:35 +00:00
|
|
|
void (*grub_efi_net_config) (grub_efi_handle_t hnd,
|
|
|
|
char **device,
|
|
|
|
char **path);
|
|
|
|
|
2006-04-25 20:08:31 +00:00
|
|
|
void
|
2011-07-02 12:09:36 +00:00
|
|
|
grub_machine_get_bootlocation (char **device, char **path)
|
2006-04-25 20:08:31 +00:00
|
|
|
{
|
2010-04-27 09:08:53 +00:00
|
|
|
grub_efi_loaded_image_t *image = NULL;
|
2011-07-02 12:09:36 +00:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
image = grub_efi_get_loaded_image (grub_efi_image_handle);
|
|
|
|
if (!image)
|
|
|
|
return;
|
|
|
|
*device = grub_efidisk_get_device_name (image->device_handle);
|
2011-07-02 14:56:35 +00:00
|
|
|
if (!*device && grub_efi_net_config)
|
2016-12-19 09:09:04 +00:00
|
|
|
{
|
|
|
|
grub_efi_net_config (image->device_handle, device, path);
|
|
|
|
return;
|
|
|
|
}
|
2011-07-02 12:09:36 +00:00
|
|
|
|
2016-12-19 09:09:04 +00:00
|
|
|
*path = grub_efi_get_filename (image->file_path);
|
2014-11-17 14:11:01 +00:00
|
|
|
if (*path)
|
|
|
|
{
|
|
|
|
/* Get the directory. */
|
|
|
|
p = grub_strrchr (*path, '/');
|
|
|
|
if (p)
|
|
|
|
*p = '\0';
|
|
|
|
}
|
2006-04-19 08:59:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
grub_efi_fini (void)
|
|
|
|
{
|
2006-04-23 13:37:36 +00:00
|
|
|
grub_efidisk_fini ();
|
2006-04-19 08:59:44 +00:00
|
|
|
grub_console_fini ();
|
2017-08-31 14:40:19 +00:00
|
|
|
grub_efi_memory_fini ();
|
2006-04-19 08:59:44 +00:00
|
|
|
}
|