TianoCore EDK2 master
Loading...
Searching...
No Matches
PcRtc.h File Reference

Go to the source code of this file.

Data Structures

struct  PC_RTC_MODULE_GLOBALS
 
struct  RTC_REGISTER_A_BITS
 
union  RTC_REGISTER_A
 
struct  RTC_REGISTER_B_BITS
 
union  RTC_REGISTER_B
 
struct  RTC_REGISTER_C_BITS
 
union  RTC_REGISTER_C
 
struct  RTC_REGISTER_D_BITS
 
union  RTC_REGISTER_D
 

Macros

#define RTC_ADDRESS_SECONDS   0
 
#define RTC_ADDRESS_SECONDS_ALARM   1
 
#define RTC_ADDRESS_MINUTES   2
 
#define RTC_ADDRESS_MINUTES_ALARM   3
 
#define RTC_ADDRESS_HOURS   4
 
#define RTC_ADDRESS_HOURS_ALARM   5
 
#define RTC_ADDRESS_DAY_OF_THE_WEEK   6
 
#define RTC_ADDRESS_DAY_OF_THE_MONTH   7
 
#define RTC_ADDRESS_MONTH   8
 
#define RTC_ADDRESS_YEAR   9
 
#define RTC_ADDRESS_REGISTER_A   10
 
#define RTC_ADDRESS_REGISTER_B   11
 
#define RTC_ADDRESS_REGISTER_C   12
 
#define RTC_ADDRESS_REGISTER_D   13
 
#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_DIV_RESET   0x70
 

Functions

EFI_STATUS PcRtcInit (IN PC_RTC_MODULE_GLOBALS *Global)
 
EFI_STATUS PcRtcSetTime (IN EFI_TIME *Time, IN PC_RTC_MODULE_GLOBALS *Global)
 
EFI_STATUS PcRtcGetTime (OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL, IN PC_RTC_MODULE_GLOBALS *Global)
 
EFI_STATUS PcRtcSetWakeupTime (IN BOOLEAN Enable, IN EFI_TIME *Time OPTIONAL, IN PC_RTC_MODULE_GLOBALS *Global)
 
EFI_STATUS PcRtcGetWakeupTime (OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time, IN PC_RTC_MODULE_GLOBALS *Global)
 
EFI_STATUS EFIAPI InitializePcRtc (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS RtcTimeFieldsValid (IN EFI_TIME *Time)
 
VOID ConvertEfiTimeToRtcTime (IN OUT EFI_TIME *Time, IN RTC_REGISTER_B RegisterB)
 
EFI_STATUS ConvertRtcTimeToEfiTime (IN OUT EFI_TIME *Time, IN RTC_REGISTER_B RegisterB)
 
EFI_STATUS RtcWaitToUpdate (UINTN Timeout)
 
BOOLEAN DayValid (IN EFI_TIME *Time)
 
BOOLEAN IsLeapYear (IN EFI_TIME *Time)
 
UINT8 GetCenturyRtcAddress (VOID)
 
VOID EFIAPI PcRtcAcpiTableChangeCallback (IN EFI_EVENT Event, IN VOID *Context)
 

Variables

PC_RTC_MODULE_GLOBALS mModuleGlobal
 

Detailed Description

Header file for real time clock driver.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Inc. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PcRtc.h.

Macro Definition Documentation

◆ RTC_ADDRESS_DAY_OF_THE_MONTH

#define RTC_ADDRESS_DAY_OF_THE_MONTH   7

Definition at line 52 of file PcRtc.h.

◆ RTC_ADDRESS_DAY_OF_THE_WEEK

#define RTC_ADDRESS_DAY_OF_THE_WEEK   6

Definition at line 51 of file PcRtc.h.

◆ RTC_ADDRESS_HOURS

#define RTC_ADDRESS_HOURS   4

Definition at line 49 of file PcRtc.h.

◆ RTC_ADDRESS_HOURS_ALARM

#define RTC_ADDRESS_HOURS_ALARM   5

Definition at line 50 of file PcRtc.h.

◆ RTC_ADDRESS_MINUTES

#define RTC_ADDRESS_MINUTES   2

Definition at line 47 of file PcRtc.h.

◆ RTC_ADDRESS_MINUTES_ALARM

#define RTC_ADDRESS_MINUTES_ALARM   3

Definition at line 48 of file PcRtc.h.

◆ RTC_ADDRESS_MONTH

#define RTC_ADDRESS_MONTH   8

Definition at line 53 of file PcRtc.h.

◆ RTC_ADDRESS_REGISTER_A

#define RTC_ADDRESS_REGISTER_A   10

Definition at line 55 of file PcRtc.h.

◆ RTC_ADDRESS_REGISTER_B

#define RTC_ADDRESS_REGISTER_B   11

Definition at line 56 of file PcRtc.h.

◆ RTC_ADDRESS_REGISTER_C

#define RTC_ADDRESS_REGISTER_C   12

Definition at line 57 of file PcRtc.h.

◆ RTC_ADDRESS_REGISTER_D

#define RTC_ADDRESS_REGISTER_D   13

Definition at line 58 of file PcRtc.h.

◆ RTC_ADDRESS_SECONDS

#define RTC_ADDRESS_SECONDS   0

Definition at line 45 of file PcRtc.h.

◆ RTC_ADDRESS_SECONDS_ALARM

#define RTC_ADDRESS_SECONDS_ALARM   1

Definition at line 46 of file PcRtc.h.

◆ RTC_ADDRESS_YEAR

#define RTC_ADDRESS_YEAR   9

Definition at line 54 of file PcRtc.h.

◆ RTC_DIV_RESET

#define RTC_DIV_RESET   0x70

Definition at line 73 of file PcRtc.h.

◆ RTC_INIT_DAY

#define RTC_INIT_DAY   1

Definition at line 66 of file PcRtc.h.

◆ RTC_INIT_HOUR

#define RTC_INIT_HOUR   0

Definition at line 65 of file PcRtc.h.

◆ RTC_INIT_MINUTE

#define RTC_INIT_MINUTE   0

Definition at line 64 of file PcRtc.h.

◆ RTC_INIT_MONTH

#define RTC_INIT_MONTH   1

Definition at line 67 of file PcRtc.h.

◆ RTC_INIT_SECOND

#define RTC_INIT_SECOND   0

Definition at line 63 of file PcRtc.h.

Function Documentation

◆ ConvertEfiTimeToRtcTime()

VOID ConvertEfiTimeToRtcTime ( IN OUT EFI_TIME Time,
IN RTC_REGISTER_B  RegisterB 
)

Converts time from EFI_TIME format defined by UEFI spec to RTC format.

This function converts time from EFI_TIME format defined by UEFI spec to RTC format. 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.

Parameters
TimeOn input, the time data read from UEFI to convert On output, the time converted to RTC format
RegisterBValue of Register B of RTC, indicating data mode

Definition at line 1260 of file PcRtc.c.

◆ ConvertRtcTimeToEfiTime()

EFI_STATUS ConvertRtcTimeToEfiTime ( IN OUT EFI_TIME Time,
IN RTC_REGISTER_B  RegisterB 
)

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.

Parameters
TimeOn input, the time data read from RTC to convert On output, the time converted to UEFI format
RegisterBValue of Register B of RTC, indicating data mode and hour format.
Return values
EFI_INVALID_PARAMETERParameters passed in are invalid.
EFI_SUCCESSConvert RTC time to EFI time successfully.

Definition at line 1051 of file PcRtc.c.

◆ DayValid()

BOOLEAN DayValid ( IN EFI_TIME Time)

See if field Day of an EFI_TIME is correct.

Parameters
TimeIts Day field is to be checked.
Return values
TRUEDay field of Time is correct.
FALSEDay field of Time is NOT correct.

Definition at line 271 of file RealTimeClock.c.

◆ GetCenturyRtcAddress()

UINT8 GetCenturyRtcAddress ( VOID  )

Get the century RTC address from the ACPI FADT table.

Returns
The century RTC address or 0 if not found.

Definition at line 1404 of file PcRtc.c.

◆ InitializePcRtc()

EFI_STATUS EFIAPI InitializePcRtc ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The user Entry Point for PcRTC module.

This is the entry point for PcRTC module. It installs the UEFI runtime service including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
OthersSome error occurs when executing this entry point.

Definition at line 157 of file PcRtcEntry.c.

◆ IsLeapYear()

BOOLEAN IsLeapYear ( IN EFI_TIME Time)

Check if it is a leapyear.

Parameters
TimeThe time to be checked.
Return values
TRUEIt is a leapyear.
FALSEIt is NOT a leapyear.

Check if it is a leap year.

Parameters
TimeThe UEFI time to be checked.
Return values
TRUEIt is a leap year.
FALSEIt is NOT a leap year.

Check if it is a leap year.

Parameters
TimeThe time to be checked.
Return values
TRUEIt is a leap year.
FALSEIt is NOT a leap year.

Definition at line 166 of file TimeBaseLib.c.

◆ PcRtcAcpiTableChangeCallback()

VOID EFIAPI PcRtcAcpiTableChangeCallback ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Notification function of ACPI Table change.

This is a notification function registered on ACPI Table change event. It saves the Century address stored in ACPI FADT table.

Parameters
EventEvent whose notification function is being invoked.
ContextPointer to the notification function's context.

Definition at line 1436 of file PcRtc.c.

◆ PcRtcGetTime()

EFI_STATUS PcRtcGetTime ( OUT EFI_TIME Time,
OUT EFI_TIME_CAPABILITIES *Capabilities  OPTIONAL,
IN PC_RTC_MODULE_GLOBALS Global 
)

Returns the current time and date information, and the time-keeping capabilities of the hardware platform.

Parameters
TimeA pointer to storage to receive a snapshot of the current time.
CapabilitiesAn optional pointer to a buffer to receive the real time clock device's capabilities.
GlobalFor global use inside this module.
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_INVALID_PARAMETERTime is NULL.
EFI_DEVICE_ERRORThe time could not be retrieved due to hardware error.

Definition at line 527 of file PcRtc.c.

◆ PcRtcGetWakeupTime()

EFI_STATUS PcRtcGetWakeupTime ( OUT BOOLEAN *  Enabled,
OUT BOOLEAN *  Pending,
OUT EFI_TIME Time,
IN PC_RTC_MODULE_GLOBALS Global 
)

Returns the current wakeup alarm clock setting.

Parameters
EnabledIndicates if the alarm is currently enabled or disabled.
PendingIndicates if the alarm signal is pending and requires acknowledgement.
TimeThe current alarm setting.
GlobalFor global use inside this module.
Return values
EFI_SUCCESSThe alarm settings were returned.
EFI_INVALID_PARAMETEREnabled is NULL.
EFI_INVALID_PARAMETERPending is NULL.
EFI_INVALID_PARAMETERTime is NULL.
EFI_DEVICE_ERRORThe wakeup time could not be retrieved due to a hardware error.
EFI_UNSUPPORTEDA wakeup timer is not supported on this platform.

Returns the current wakeup alarm clock setting.

Parameters
EnabledIndicates if the alarm is currently enabled or disabled.
PendingIndicates if the alarm signal is pending and requires acknowledgment.
TimeThe current alarm setting.
GlobalFor global use inside this module.
Return values
EFI_SUCCESSThe alarm settings were returned.
EFI_INVALID_PARAMETEREnabled is NULL.
EFI_INVALID_PARAMETERPending is NULL.
EFI_INVALID_PARAMETERTime is NULL.
EFI_DEVICE_ERRORThe wakeup time could not be retrieved due to a hardware error.
EFI_UNSUPPORTEDA wakeup timer is not supported on this platform.

Definition at line 750 of file PcRtc.c.

◆ PcRtcInit()

EFI_STATUS PcRtcInit ( IN PC_RTC_MODULE_GLOBALS Global)

Initialize RTC.

Parameters
GlobalFor global use inside this module.
Return values
EFI_DEVICE_ERRORInitialization failed due to device error.
EFI_SUCCESSInitialization successful.

Definition at line 262 of file PcRtc.c.

◆ PcRtcSetTime()

EFI_STATUS PcRtcSetTime ( IN EFI_TIME Time,
IN PC_RTC_MODULE_GLOBALS Global 
)

Sets the current local time and date information.

Parameters
TimeA pointer to the current time.
GlobalFor global use inside this module.
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_INVALID_PARAMETERA time field is out of range.
EFI_DEVICE_ERRORThe time could not be set due due to hardware error.

Definition at line 632 of file PcRtc.c.

◆ PcRtcSetWakeupTime()

EFI_STATUS PcRtcSetWakeupTime ( IN BOOLEAN  Enable,
IN EFI_TIME *Time  OPTIONAL,
IN PC_RTC_MODULE_GLOBALS Global 
)

Sets the system wakeup alarm clock time.

Parameters
EnabledEnable or disable the wakeup alarm.
TimeIf Enable is TRUE, the time to set the wakeup alarm for. If Enable is FALSE, then this parameter is optional, and may be NULL.
GlobalFor global use inside this module.
Return values
EFI_SUCCESSIf Enable is TRUE, then the wakeup alarm was enabled. If Enable is FALSE, then the wakeup alarm was disabled.
EFI_INVALID_PARAMETERA time field is out of range.
EFI_DEVICE_ERRORThe wakeup time could not be set due to a hardware error.
EFI_UNSUPPORTEDA wakeup timer is not supported on this platform.

Definition at line 868 of file PcRtc.c.

◆ RtcTimeFieldsValid()

EFI_STATUS RtcTimeFieldsValid ( IN EFI_TIME Time)

See if all fields of a variable of EFI_TIME type is correct.

Parameters
TimeThe time to be checked.
Return values
EFI_INVALID_PARAMETERSome fields of Time are not correct.
EFI_SUCCESSTime is a valid EFI_TIME variable.

Definition at line 238 of file RealTimeClock.c.

◆ RtcWaitToUpdate()

EFI_STATUS RtcWaitToUpdate ( UINTN  Timeout)

Wait for a period for the RTC to be ready.

Parameters
TimeoutTell how long it should take to wait.
Return values
EFI_DEVICE_ERRORRTC device error.
EFI_SUCCESSRTC is updated and ready.

Definition at line 1124 of file PcRtc.c.

Variable Documentation

◆ mModuleGlobal

PC_RTC_MODULE_GLOBALS mModuleGlobal
extern

Definition at line 13 of file PcRtcEntry.c.