PcRtc.h revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Header file for real time clock driver.
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _RTC_H_
#define _RTC_H_
#include <Uefi.h>
#include <Protocol/RealTimeClock.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/TimerLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
typedef struct {
#define PCAT_RTC_ADDRESS_REGISTER 0x70
#define PCAT_RTC_DATA_REGISTER 0x71
//
// Dallas DS12C887 Real Time Clock
//
#define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
//
// Date and time initial values.
// They are used if the RTC values are invalid during driver initialization
//
#define RTC_INIT_SECOND 0
#define RTC_INIT_MINUTE 0
#define RTC_INIT_HOUR 0
#define RTC_INIT_DAY 1
#define RTC_INIT_MONTH 1
#define RTC_INIT_YEAR 2001
//
// Register initial values
//
#define RTC_INIT_REGISTER_A 0x26
#define RTC_INIT_REGISTER_B 0x02
#define RTC_INIT_REGISTER_D 0x0
#pragma pack(1)
//
// Register A
//
typedef struct {
typedef union {
//
// Register B
//
typedef struct {
typedef union {
//
// Register C
//
typedef struct {
typedef union {
//
// Register D
//
typedef struct {
typedef union {
#pragma pack()
/**
Initialize RTC.
@param Global For global use inside this module.
@retval EFI_DEVICE_ERROR Initialization failed due to device error.
@retval EFI_SUCCESS Initialization successful.
**/
);
/**
Sets the current local time and date information.
@param Time A pointer to the current time.
@param Global For global use inside this module.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_INVALID_PARAMETER A time field is out of range.
@retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
**/
);
/**
Returns the current time and date information, and the time-keeping capabilities
of the hardware platform.
@param Time A pointer to storage to receive a snapshot of the current time.
@param Capabilities An optional pointer to a buffer to receive the real time clock
device's capabilities.
@param Global For global use inside this module.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_INVALID_PARAMETER Time is NULL.
@retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
**/
);
/**
Sets the system wakeup alarm clock time.
@param Enabled Enable or disable the wakeup alarm.
@param Time If Enable is TRUE, the time to set the wakeup alarm for.
If Enable is FALSE, then this parameter is optional, and may be NULL.
@param Global For global use inside this module.
@retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.
If Enable is FALSE, then the wakeup alarm was disabled.
@retval EFI_INVALID_PARAMETER A time field is out of range.
@retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
@retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
**/
);
/**
Returns the current wakeup alarm clock setting.
@param Enabled Indicates if the alarm is currently enabled or disabled.
@param Pending Indicates if the alarm signal is pending and requires acknowledgement.
@param Time The current alarm setting.
@param Global For global use inside this module.
@retval EFI_SUCCESS The alarm settings were returned.
@retval EFI_INVALID_PARAMETER Enabled is NULL.
@retval EFI_INVALID_PARAMETER Pending is NULL.
@retval EFI_INVALID_PARAMETER Time is NULL.
@retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
@retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
**/
);
/**
The user Entry Point for PcRTC module.
This is the entrhy point for PcRTC module. It installs the UEFI runtime service
including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval Others Some error occurs when executing this entry point.
**/
);
/**
See if all fields of a variable of EFI_TIME type is correct.
@param Time The time to be checked.
@retval EFI_INVALID_PARAMETER Some fields of Time are not correct.
@retval EFI_SUCCESS Time is a valid EFI_TIME variable.
**/
);
/**
Converts time from EFI_TIME format defined by UEFI spec to RTC's.
This function converts time from EFI_TIME format defined by UEFI spec to RTC's.
If data mode of RTC is BCD, then converts EFI_TIME to it.
If RTC is in 12-hour format, then converts EFI_TIME to it.
@param Time On input, the time data read from UEFI to convert
On output, the time converted to RTC format
@param RegisterB Value of Register B of RTC, indicating data mode
@param Century It is set according to EFI_TIME Time.
**/
);
/**
Converts time read from RTC to EFI_TIME format defined by UEFI spec.
This function converts raw time data read from RTC to the EFI_TIME format
defined by UEFI spec.
If data mode of RTC is BCD, then converts it to decimal,
If RTC is in 12-hour format, then converts it to 24-hour format.
@param Time On input, the time data read from RTC to convert
On output, the time converted to UEFI format
@param Century Value of century read from RTC.
@param RegisterB Value of Register B of RTC, indicating data mode
and hour format.
@retval EFI_INVALID_PARAMETER Parameters passed in are invalid.
@retval EFI_SUCCESS Convert RTC time to EFI time successfully.
**/
);
/**
Wait for a period for the RTC to be ready.
@param Timeout Tell how long it should take to wait.
@retval EFI_DEVICE_ERROR RTC device error.
@retval EFI_SUCCESS RTC is updated and ready.
**/
);
/**
See if field Day of an EFI_TIME is correct.
@param Time Its Day field is to be checked.
@retval TRUE Day field of Time is correct.
@retval FALSE Day field of Time is NOT correct.
**/
DayValid (
);
/**
Check if it is a leapyear.
@param Time The time to be checked.
@retval TRUE It is a leapyear.
@retval FALSE It is NOT a leapyear.
**/
);
#endif