80 lines
2.4 KiB
C
80 lines
2.4 KiB
C
/* kern/efi/datetime.c - efi datetime function.
|
|
*
|
|
* VAS_EBOOT -- GRand Unified Bootloader
|
|
* Copyright (C) 2008 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/types.h>
|
|
#include <VasEBoot/symbol.h>
|
|
#include <VasEBoot/efi/api.h>
|
|
#include <VasEBoot/efi/efi.h>
|
|
#include <VasEBoot/datetime.h>
|
|
#include <VasEBoot/dl.h>
|
|
|
|
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
|
|
|
|
VasEBoot_err_t
|
|
VasEBoot_get_datetime (struct VasEBoot_datetime *datetime)
|
|
{
|
|
VasEBoot_efi_status_t status;
|
|
struct VasEBoot_efi_time efi_time;
|
|
|
|
status = VasEBoot_efi_system_table->runtime_services->get_time (&efi_time, 0);
|
|
|
|
if (status)
|
|
return VasEBoot_error (VAS_EBOOT_ERR_INVALID_COMMAND,
|
|
"can\'t get datetime using efi");
|
|
else
|
|
{
|
|
datetime->year = efi_time.year;
|
|
datetime->month = efi_time.month;
|
|
datetime->day = efi_time.day;
|
|
datetime->hour = efi_time.hour;
|
|
datetime->minute = efi_time.minute;
|
|
datetime->second = efi_time.second;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
VasEBoot_err_t
|
|
VasEBoot_set_datetime (struct VasEBoot_datetime *datetime)
|
|
{
|
|
VasEBoot_efi_status_t status;
|
|
struct VasEBoot_efi_time efi_time;
|
|
|
|
status = VasEBoot_efi_system_table->runtime_services->get_time (&efi_time, 0);
|
|
|
|
if (status)
|
|
return VasEBoot_error (VAS_EBOOT_ERR_INVALID_COMMAND,
|
|
"can\'t get datetime using efi");
|
|
|
|
efi_time.year = datetime->year;
|
|
efi_time.month = datetime->month;
|
|
efi_time.day = datetime->day;
|
|
efi_time.hour = datetime->hour;
|
|
efi_time.minute = datetime->minute;
|
|
efi_time.second = datetime->second;
|
|
|
|
status = VasEBoot_efi_system_table->runtime_services->set_time (&efi_time);
|
|
|
|
if (status)
|
|
return VasEBoot_error (VAS_EBOOT_ERR_INVALID_COMMAND,
|
|
"can\'t set datetime using efi");
|
|
|
|
return 0;
|
|
}
|