2008-04-10 10:49:28 +02:00
|
|
|
/** @file
|
|
|
|
Provides Set/Get time operations.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2016-05-18 07:18:28 +02:00
|
|
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 14:07:51 +02:00
|
|
|
This program and the accompanying materials
|
2007-07-24 12:52:02 +02:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-04-10 10:49:28 +02:00
|
|
|
**/
|
2007-07-19 12:26:16 +02:00
|
|
|
|
|
|
|
#include "PcRtc.h"
|
|
|
|
|
2015-12-23 03:23:54 +01:00
|
|
|
PC_RTC_MODULE_GLOBALS mModuleGlobal;
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
EFI_HANDLE mHandle = NULL;
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
/**
|
|
|
|
Returns the current time and date information, and the time-keeping capabilities
|
|
|
|
of the hardware platform.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
@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.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
@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.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PcRtcEfiGetTime (
|
|
|
|
OUT EFI_TIME *Time,
|
|
|
|
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
|
|
|
|
)
|
2007-07-19 12:26:16 +02:00
|
|
|
{
|
|
|
|
return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);
|
|
|
|
}
|
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
/**
|
|
|
|
Sets the current local time and date information.
|
|
|
|
|
|
|
|
@param Time A pointer to the current time.
|
|
|
|
|
|
|
|
@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.
|
|
|
|
|
|
|
|
**/
|
2007-07-19 12:26:16 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PcRtcEfiSetTime (
|
|
|
|
IN EFI_TIME *Time
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return PcRtcSetTime (Time, &mModuleGlobal);
|
|
|
|
}
|
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
@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.
|
|
|
|
|
|
|
|
**/
|
2007-07-19 12:26:16 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PcRtcEfiGetWakeupTime (
|
|
|
|
OUT BOOLEAN *Enabled,
|
|
|
|
OUT BOOLEAN *Pending,
|
|
|
|
OUT EFI_TIME *Time
|
|
|
|
)
|
2008-11-07 08:44:21 +01:00
|
|
|
{
|
|
|
|
return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);
|
|
|
|
}
|
2007-07-19 12:26:16 +02:00
|
|
|
|
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
/**
|
|
|
|
Sets the system wakeup alarm clock time.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
@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.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
@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.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
**/
|
2007-07-19 12:26:16 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PcRtcEfiSetWakeupTime (
|
|
|
|
IN BOOLEAN Enabled,
|
2008-11-07 08:44:21 +01:00
|
|
|
IN EFI_TIME *Time OPTIONAL
|
2007-07-19 12:26:16 +02:00
|
|
|
)
|
2008-11-07 08:44:21 +01:00
|
|
|
{
|
|
|
|
return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);
|
|
|
|
}
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
/**
|
|
|
|
The user Entry Point for PcRTC module.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
This is the entrhy point for PcRTC module. It installs the UEFI runtime service
|
|
|
|
including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
@param ImageHandle The firmware allocated handle for the EFI image.
|
|
|
|
@param SystemTable A pointer to the EFI System Table.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
@retval EFI_SUCCESS The entry point is executed successfully.
|
|
|
|
@retval Others Some error occurs when executing this entry point.
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2008-11-07 08:44:21 +01:00
|
|
|
**/
|
2007-07-19 12:26:16 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InitializePcRtc (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2015-12-22 14:52:47 +01:00
|
|
|
EFI_EVENT Event;
|
2007-07-19 12:26:16 +02:00
|
|
|
|
2010-11-10 04:18:21 +01:00
|
|
|
EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_CALLBACK);
|
2016-05-18 07:18:28 +02:00
|
|
|
mModuleGlobal.CenturyRtcAddress = GetCenturyRtcAddress ();
|
2007-07-19 12:26:16 +02:00
|
|
|
|
|
|
|
Status = PcRtcInit (&mModuleGlobal);
|
2011-11-22 07:11:16 +01:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
2015-12-22 14:52:47 +01:00
|
|
|
|
|
|
|
Status = gBS->CreateEventEx (
|
|
|
|
EVT_NOTIFY_SIGNAL,
|
|
|
|
TPL_CALLBACK,
|
|
|
|
PcRtcAcpiTableChangeCallback,
|
|
|
|
NULL,
|
|
|
|
&gEfiAcpi10TableGuid,
|
|
|
|
&Event
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = gBS->CreateEventEx (
|
|
|
|
EVT_NOTIFY_SIGNAL,
|
|
|
|
TPL_CALLBACK,
|
|
|
|
PcRtcAcpiTableChangeCallback,
|
|
|
|
NULL,
|
|
|
|
&gEfiAcpiTableGuid,
|
|
|
|
&Event
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2007-07-19 12:26:16 +02:00
|
|
|
|
|
|
|
gRT->GetTime = PcRtcEfiGetTime;
|
|
|
|
gRT->SetTime = PcRtcEfiSetTime;
|
|
|
|
gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;
|
|
|
|
gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;
|
|
|
|
|
|
|
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
2008-11-07 08:44:21 +01:00
|
|
|
&mHandle,
|
2007-07-19 12:26:16 +02:00
|
|
|
&gEfiRealTimeClockArchProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2008-11-07 08:44:21 +01:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
2007-07-19 12:26:16 +02:00
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|