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

78 lines
2.1 KiB
C

/* init.c - initialize an arm-based EFI system */
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VAS_EBOOT 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.
*
* VAS_EBOOT 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 VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/env.h>
#include <VasEBoot/kernel.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/time.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/loader.h>
static VasEBoot_uint64_t tmr;
static VasEBoot_efi_event_t tmr_evt;
static VasEBoot_uint64_t
VasEBoot_efi_get_time_ms (void)
{
return tmr;
}
static void __VasEBoot_efi_api
increment_timer (VasEBoot_efi_event_t event __attribute__ ((unused)),
void *context __attribute__ ((unused)))
{
tmr += 10;
}
void
VasEBoot_machine_init (void)
{
VasEBoot_efi_boot_services_t *b;
VasEBoot_efi_init ();
b = VasEBoot_efi_system_table->boot_services;
b->create_event (VAS_EBOOT_EFI_EVT_TIMER | VAS_EBOOT_EFI_EVT_NOTIFY_SIGNAL,
VAS_EBOOT_EFI_TPL_CALLBACK, increment_timer, NULL, &tmr_evt);
b->set_timer (tmr_evt, VAS_EBOOT_EFI_TIMER_PERIODIC, 100000);
VasEBoot_install_get_time_ms (VasEBoot_efi_get_time_ms);
}
void
VasEBoot_machine_fini (int flags)
{
VasEBoot_efi_boot_services_t *b;
if (!(flags & VAS_EBOOT_LOADER_FLAG_NORETURN))
return;
b = VasEBoot_efi_system_table->boot_services;
b->set_timer (tmr_evt, VAS_EBOOT_EFI_TIMER_CANCEL, 0);
b->close_event (tmr_evt);
VasEBoot_efi_fini ();
if (!(flags & VAS_EBOOT_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY))
VasEBoot_efi_memory_fini ();
}