vaseboot/VasEBoot-core/kern/efi/init.c

84 lines
2.3 KiB
C

/* init.c - generic EFI initialization and finalization */
/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* 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
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/efi/console.h>
#include <VasEBoot/efi/disk.h>
#include <VasEBoot/term.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/env.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/kernel.h>
VasEBoot_addr_t VasEBoot_modbase;
void
VasEBoot_efi_init (void)
{
VasEBoot_modbase = VasEBoot_efi_modules_addr ();
/* First of all, initialize the console so that VasEBoot can display
messages. */
VasEBoot_console_init ();
/* Initialize the memory management system. */
VasEBoot_efi_mm_init ();
efi_call_4 (VasEBoot_efi_system_table->boot_services->set_watchdog_timer,
0, 0, 0, NULL);
VasEBoot_efidisk_init ();
}
void (*VasEBoot_efi_net_config) (VasEBoot_efi_handle_t hnd,
char **device,
char **path);
void
VasEBoot_machine_get_bootlocation (char **device, char **path)
{
VasEBoot_efi_loaded_image_t *image = NULL;
char *p;
image = VasEBoot_efi_get_loaded_image (VasEBoot_efi_image_handle);
if (!image)
return;
*device = VasEBoot_efidisk_get_device_name (image->device_handle);
if (!*device && VasEBoot_efi_net_config)
{
VasEBoot_efi_net_config (image->device_handle, device, path);
return;
}
*path = VasEBoot_efi_get_filename (image->file_path);
if (*path)
{
/* Get the directory. */
p = VasEBoot_strrchr (*path, '/');
if (p)
*p = '\0';
}
}
void
VasEBoot_efi_fini (void)
{
VasEBoot_efidisk_fini ();
VasEBoot_console_fini ();
}