ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync/** @file
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync Header file for real time clock driver.
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncCopyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsyncThis program and the accompanying materials
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsyncare licensed and made available under the terms and conditions of the BSD License
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsyncwhich accompanies this distribution. The full text of the license may be found at
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsynchttp://opensource.org/licenses/bsd-license.php
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsyncTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsyncWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync**/
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#ifndef _RTC_H_
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define _RTC_H_
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#include <Uefi.h>
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#include <Protocol/RealTimeClock.h>
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync#include <Library/BaseLib.h>
2412a232e34038160df062f7939f353bee5567a9vboxsync#include <Library/DebugLib.h>
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#include <Library/UefiLib.h>
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#include <Library/BaseMemoryLib.h>
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#include <Library/IoLib.h>
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#include <Library/TimerLib.h>
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#include <Library/UefiDriverEntryPoint.h>
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#include <Library/UefiBootServicesTableLib.h>
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#include <Library/UefiRuntimeLib.h>
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#include <Library/UefiRuntimeServicesTableLib.h>
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#include <Library/PcdLib.h>
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsynctypedef struct {
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync EFI_LOCK RtcLock;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync INT16 SavedTimeZone;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Daylight;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync} PC_RTC_MODULE_GLOBALS;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define PCAT_RTC_ADDRESS_REGISTER 0x70
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define PCAT_RTC_DATA_REGISTER 0x71
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync//
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync// Dallas DS12C887 Real Time Clock
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync//
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_SECONDS_ALARM 1 // R/W Range 0..59
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_MINUTES 2 // R/W Range 0..59
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_MINUTES_ALARM 3 // R/W Range 0..59
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_HOURS 4 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_HOURS_ALARM 5 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_DAY_OF_THE_WEEK 6 // R/W Range 1..7
2412a232e34038160df062f7939f353bee5567a9vboxsync#define RTC_ADDRESS_DAY_OF_THE_MONTH 7 // R/W Range 1..31
2412a232e34038160df062f7939f353bee5567a9vboxsync#define RTC_ADDRESS_MONTH 8 // R/W Range 1..12
2412a232e34038160df062f7939f353bee5567a9vboxsync#define RTC_ADDRESS_YEAR 9 // R/W Range 0..99
2412a232e34038160df062f7939f353bee5567a9vboxsync#define RTC_ADDRESS_REGISTER_A 10 // R/W[0..6] R0[7]
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_REGISTER_B 11 // R/W
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_REGISTER_C 12 // RO
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_REGISTER_D 13 // RO
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync//
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync// Date and time initial values.
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync// They are used if the RTC values are invalid during driver initialization
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync//
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define RTC_INIT_SECOND 0
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define RTC_INIT_MINUTE 0
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define RTC_INIT_HOUR 0
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define RTC_INIT_DAY 1
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define RTC_INIT_MONTH 1
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync#define RTC_INIT_YEAR 2001
2412a232e34038160df062f7939f353bee5567a9vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync//
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync// Register initial values
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync//
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#define RTC_INIT_REGISTER_A 0x26
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#define RTC_INIT_REGISTER_B 0x02
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#define RTC_INIT_REGISTER_D 0x0
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync#pragma pack(1)
06913e4efbdb8192155c00fa59de4174c7a50b57vboxsync//
06913e4efbdb8192155c00fa59de4174c7a50b57vboxsync// Register A
06913e4efbdb8192155c00fa59de4174c7a50b57vboxsync//
06913e4efbdb8192155c00fa59de4174c7a50b57vboxsynctypedef struct {
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Rs : 4; // Rate Selection Bits
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Dv : 3; // Divisor
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Uip : 1; // Update in progress
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync} RTC_REGISTER_A_BITS;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsynctypedef union {
2412a232e34038160df062f7939f353bee5567a9vboxsync RTC_REGISTER_A_BITS Bits;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Data;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync} RTC_REGISTER_A;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync//
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync// Register B
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync//
a5b0b691c49d35639207d4539753eaebf3f05275vboxsynctypedef struct {
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Dse : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Mil : 1; // 0 - 12 hour mode 1 - 24 hour mode
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Dm : 1; // 0 - BCD Format 1 - Binary Format
2412a232e34038160df062f7939f353bee5567a9vboxsync UINT8 Sqwe : 1; // 0 - Disable SQWE output 1 - Enable SQWE output
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync UINT8 Uie : 1; // 0 - Update INT disabled 1 - Update INT enabled
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync UINT8 Aie : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync UINT8 Pie : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync UINT8 Set : 1; // 0 - Normal operation. 1 - Updates inhibited
2412a232e34038160df062f7939f353bee5567a9vboxsync} RTC_REGISTER_B_BITS;
2412a232e34038160df062f7939f353bee5567a9vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsynctypedef union {
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync RTC_REGISTER_B_BITS Bits;
2412a232e34038160df062f7939f353bee5567a9vboxsync UINT8 Data;
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync} RTC_REGISTER_B;
2412a232e34038160df062f7939f353bee5567a9vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync//
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync// Register C
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync//
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsynctypedef struct {
2412a232e34038160df062f7939f353bee5567a9vboxsync UINT8 Reserved : 4; // Read as zero. Can not be written.
2412a232e34038160df062f7939f353bee5567a9vboxsync UINT8 Uf : 1; // Update End Interrupt Flag
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync UINT8 Af : 1; // Alarm Interrupt Flag
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync UINT8 Pf : 1; // Periodic Interrupt Flag
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync UINT8 Irqf : 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
2412a232e34038160df062f7939f353bee5567a9vboxsync} RTC_REGISTER_C_BITS;
2412a232e34038160df062f7939f353bee5567a9vboxsync
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsynctypedef union {
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync RTC_REGISTER_C_BITS Bits;
2412a232e34038160df062f7939f353bee5567a9vboxsync UINT8 Data;
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync} RTC_REGISTER_C;
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync//
2412a232e34038160df062f7939f353bee5567a9vboxsync// Register D
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync//
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsynctypedef struct {
ba5dd00fabaa3475fa5da200d134c73f1c961b49vboxsync UINT8 Reserved : 7; // Read as zero. Can not be written.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Vrt : 1; // Valid RAM and Time
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync} RTC_REGISTER_D_BITS;
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsynctypedef union {
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync RTC_REGISTER_D_BITS Bits;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync UINT8 Data;
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync} RTC_REGISTER_D;
2412a232e34038160df062f7939f353bee5567a9vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync#pragma pack()
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync/**
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync Initialize RTC.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Global For global use inside this module.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_DEVICE_ERROR Initialization failed due to device error.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_SUCCESS Initialization successful.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFI_STATUS
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsyncPcRtcInit (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN PC_RTC_MODULE_GLOBALS *Global
2412a232e34038160df062f7939f353bee5567a9vboxsync );
2412a232e34038160df062f7939f353bee5567a9vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync/**
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync Sets the current local time and date information.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync @param Time A pointer to the current time.
56dabd8ef969a182c5f3cc6ac76cabf21751192evboxsync @param Global For global use inside this module.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_SUCCESS The operation completed successfully.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_INVALID_PARAMETER A time field is out of range.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFI_STATUS
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncPcRtcSetTime (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN EFI_TIME *Time,
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN PC_RTC_MODULE_GLOBALS *Global
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync );
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync/**
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync Returns the current time and date information, and the time-keeping capabilities
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync of the hardware platform.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Time A pointer to storage to receive a snapshot of the current time.
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Capabilities An optional pointer to a buffer to receive the real time clock
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync device's capabilities.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Global For global use inside this module.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_SUCCESS The operation completed successfully.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_INVALID_PARAMETER Time is NULL.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFI_STATUS
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncPcRtcGetTime (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync OUT EFI_TIME *Time,
2412a232e34038160df062f7939f353bee5567a9vboxsync OUT EFI_TIME_CAPABILITIES *Capabilities, OPTIONAL
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN PC_RTC_MODULE_GLOBALS *Global
89e8859a3e62fe1a0f3c2e8b23b0b72b692728a9vboxsync );
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync/**
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync Sets the system wakeup alarm clock time.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Enabled Enable or disable the wakeup alarm.
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Time If Enable is TRUE, the time to set the wakeup alarm for.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync If Enable is FALSE, then this parameter is optional, and may be NULL.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Global For global use inside this module.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync If Enable is FALSE, then the wakeup alarm was disabled.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_INVALID_PARAMETER A time field is out of range.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFI_STATUS
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncPcRtcSetWakeupTime (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN BOOLEAN Enable,
2412a232e34038160df062f7939f353bee5567a9vboxsync IN EFI_TIME *Time, OPTIONAL
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN PC_RTC_MODULE_GLOBALS *Global
2412a232e34038160df062f7939f353bee5567a9vboxsync );
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync/**
2412a232e34038160df062f7939f353bee5567a9vboxsync Returns the current wakeup alarm clock setting.
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Enabled Indicates if the alarm is currently enabled or disabled.
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Time The current alarm setting.
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Global For global use inside this module.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_SUCCESS The alarm settings were returned.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_INVALID_PARAMETER Enabled is NULL.
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval EFI_INVALID_PARAMETER Pending is NULL.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_INVALID_PARAMETER Time is NULL.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFI_STATUS
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncPcRtcGetWakeupTime (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync OUT BOOLEAN *Enabled,
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync OUT BOOLEAN *Pending,
2412a232e34038160df062f7939f353bee5567a9vboxsync OUT EFI_TIME *Time,
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN PC_RTC_MODULE_GLOBALS *Global
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync );
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync/**
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync The user Entry Point for PcRTC module.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync This is the entrhy point for PcRTC module. It installs the UEFI runtime service
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param ImageHandle The firmware allocated handle for the EFI image.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param SystemTable A pointer to the EFI System Table.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval EFI_SUCCESS The entry point is executed successfully.
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval Others Some error occurs when executing this entry point.
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync**/
2412a232e34038160df062f7939f353bee5567a9vboxsyncEFI_STATUS
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFIAPI
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncInitializePcRtc (
2412a232e34038160df062f7939f353bee5567a9vboxsync IN EFI_HANDLE ImageHandle,
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN EFI_SYSTEM_TABLE *SystemTable
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync );
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync/**
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync See if all fields of a variable of EFI_TIME type is correct.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Time The time to be checked.
2412a232e34038160df062f7939f353bee5567a9vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_INVALID_PARAMETER Some fields of Time are not correct.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_SUCCESS Time is a valid EFI_TIME variable.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFI_STATUS
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncRtcTimeFieldsValid (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN EFI_TIME *Time
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync );
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync/**
2412a232e34038160df062f7939f353bee5567a9vboxsync Converts time from EFI_TIME format defined by UEFI spec to RTC's.
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync This function converts time from EFI_TIME format defined by UEFI spec to RTC's.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync If data mode of RTC is BCD, then converts EFI_TIME to it.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync If RTC is in 12-hour format, then converts EFI_TIME to it.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Time On input, the time data read from UEFI to convert
2412a232e34038160df062f7939f353bee5567a9vboxsync On output, the time converted to RTC format
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param RegisterB Value of Register B of RTC, indicating data mode
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Century It is set according to EFI_TIME Time.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncVOID
2412a232e34038160df062f7939f353bee5567a9vboxsyncConvertEfiTimeToRtcTime (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN OUT EFI_TIME *Time,
2412a232e34038160df062f7939f353bee5567a9vboxsync IN RTC_REGISTER_B RegisterB,
2412a232e34038160df062f7939f353bee5567a9vboxsync OUT UINT8 *Century
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync );
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync/**
2412a232e34038160df062f7939f353bee5567a9vboxsync Converts time read from RTC to EFI_TIME format defined by UEFI spec.
2412a232e34038160df062f7939f353bee5567a9vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync This function converts raw time data read from RTC to the EFI_TIME format
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync defined by UEFI spec.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync If data mode of RTC is BCD, then converts it to decimal,
2412a232e34038160df062f7939f353bee5567a9vboxsync If RTC is in 12-hour format, then converts it to 24-hour format.
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Time On input, the time data read from RTC to convert
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync On output, the time converted to UEFI format
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param Century Value of century read from RTC.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @param RegisterB Value of Register B of RTC, indicating data mode
2412a232e34038160df062f7939f353bee5567a9vboxsync and hour format.
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval EFI_INVALID_PARAMETER Parameters passed in are invalid.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval EFI_SUCCESS Convert RTC time to EFI time successfully.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncEFI_STATUS
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncConvertRtcTimeToEfiTime (
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN OUT EFI_TIME *Time,
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN UINT8 Century,
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync IN RTC_REGISTER_B RegisterB
2412a232e34038160df062f7939f353bee5567a9vboxsync );
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync/**
2412a232e34038160df062f7939f353bee5567a9vboxsync Wait for a period for the RTC to be ready.
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Timeout Tell how long it should take to wait.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval EFI_DEVICE_ERROR RTC device error.
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval EFI_SUCCESS RTC is updated and ready.
2412a232e34038160df062f7939f353bee5567a9vboxsync**/
2412a232e34038160df062f7939f353bee5567a9vboxsyncEFI_STATUS
2412a232e34038160df062f7939f353bee5567a9vboxsyncRtcWaitToUpdate (
2412a232e34038160df062f7939f353bee5567a9vboxsync UINTN Timeout
2412a232e34038160df062f7939f353bee5567a9vboxsync );
16de144b8b8cd79af7102935cdbc11a2e98c9e35vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync/**
2412a232e34038160df062f7939f353bee5567a9vboxsync See if field Day of an EFI_TIME is correct.
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Time Its Day field is to be checked.
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval TRUE Day field of Time is correct.
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval FALSE Day field of Time is NOT correct.
2412a232e34038160df062f7939f353bee5567a9vboxsync**/
a5b0b691c49d35639207d4539753eaebf3f05275vboxsyncBOOLEAN
2412a232e34038160df062f7939f353bee5567a9vboxsyncDayValid (
2412a232e34038160df062f7939f353bee5567a9vboxsync IN EFI_TIME *Time
2412a232e34038160df062f7939f353bee5567a9vboxsync );
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync/**
2412a232e34038160df062f7939f353bee5567a9vboxsync Check if it is a leapyear.
16de144b8b8cd79af7102935cdbc11a2e98c9e35vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync @param Time The time to be checked.
2412a232e34038160df062f7939f353bee5567a9vboxsync
a5b0b691c49d35639207d4539753eaebf3f05275vboxsync @retval TRUE It is a leapyear.
2412a232e34038160df062f7939f353bee5567a9vboxsync @retval FALSE It is NOT a leapyear.
2412a232e34038160df062f7939f353bee5567a9vboxsync**/
2412a232e34038160df062f7939f353bee5567a9vboxsyncBOOLEAN
2412a232e34038160df062f7939f353bee5567a9vboxsyncIsLeapYear (
2412a232e34038160df062f7939f353bee5567a9vboxsync IN EFI_TIME *Time
2412a232e34038160df062f7939f353bee5567a9vboxsync );
2412a232e34038160df062f7939f353bee5567a9vboxsync
2412a232e34038160df062f7939f353bee5567a9vboxsync#endif
2412a232e34038160df062f7939f353bee5567a9vboxsync