PcAtChipsetPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the PcAtChipsetPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
ac0a286f4d
commit
5220bd211d
@@ -17,12 +17,12 @@ extern UINTN mRtcTargetRegister;
|
||||
//
|
||||
// Days of month.
|
||||
//
|
||||
UINTN mDayOfMonth[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
UINTN mDayOfMonth[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
//
|
||||
// The name of NV variable to store the timezone and daylight saving information.
|
||||
//
|
||||
CHAR16 mTimeZoneVariableName[] = L"RTC";
|
||||
CHAR16 mTimeZoneVariableName[] = L"RTC";
|
||||
|
||||
/**
|
||||
Compare the Hour, Minute and Second of the From time and the To time.
|
||||
@@ -38,8 +38,8 @@ CHAR16 mTimeZoneVariableName[] = L"RTC";
|
||||
**/
|
||||
INTN
|
||||
CompareHMS (
|
||||
IN EFI_TIME *From,
|
||||
IN EFI_TIME *To
|
||||
IN EFI_TIME *From,
|
||||
IN EFI_TIME *To
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -53,8 +53,8 @@ CompareHMS (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsWithinOneDay (
|
||||
IN EFI_TIME *From,
|
||||
IN EFI_TIME *To
|
||||
IN EFI_TIME *From,
|
||||
IN EFI_TIME *To
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ IsWithinOneDay (
|
||||
STATIC
|
||||
UINT8
|
||||
IoRtcRead (
|
||||
IN UINTN Address
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
IoWrite8 (
|
||||
@@ -89,8 +89,8 @@ IoRtcRead (
|
||||
STATIC
|
||||
VOID
|
||||
IoRtcWrite (
|
||||
IN UINTN Address,
|
||||
IN UINT8 Data
|
||||
IN UINTN Address,
|
||||
IN UINT8 Data
|
||||
)
|
||||
{
|
||||
IoWrite8 (
|
||||
@@ -111,7 +111,7 @@ IoRtcWrite (
|
||||
STATIC
|
||||
UINT8
|
||||
MmioRtcRead (
|
||||
IN UINTN Address
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
MmioWrite8 (
|
||||
@@ -132,8 +132,8 @@ MmioRtcRead (
|
||||
STATIC
|
||||
VOID
|
||||
MmioRtcWrite (
|
||||
IN UINTN Address,
|
||||
IN UINT8 Data
|
||||
IN UINTN Address,
|
||||
IN UINT8 Data
|
||||
)
|
||||
{
|
||||
MmioWrite8 (
|
||||
@@ -154,7 +154,7 @@ MmioRtcWrite (
|
||||
STATIC
|
||||
UINT8
|
||||
RtcRead (
|
||||
IN UINTN Address
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
if (FeaturePcdGet (PcdRtcUseMmio)) {
|
||||
@@ -175,8 +175,8 @@ RtcRead (
|
||||
STATIC
|
||||
VOID
|
||||
RtcWrite (
|
||||
IN UINTN Address,
|
||||
IN UINT8 Data
|
||||
IN UINTN Address,
|
||||
IN UINT8 Data
|
||||
)
|
||||
{
|
||||
if (FeaturePcdGet (PcdRtcUseMmio)) {
|
||||
@@ -216,6 +216,7 @@ PcRtcInit (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiAcquireLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize RTC Register
|
||||
//
|
||||
@@ -254,8 +255,10 @@ PcRtcInit (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Time/Date/Daylight Savings values.
|
||||
//
|
||||
@@ -285,16 +288,16 @@ PcRtcInit (
|
||||
// stored in NV variable during previous boot.
|
||||
//
|
||||
DataSize = sizeof (UINT32);
|
||||
Status = EfiGetVariable (
|
||||
mTimeZoneVariableName,
|
||||
&gEfiCallerIdGuid,
|
||||
NULL,
|
||||
&DataSize,
|
||||
&TimerVar
|
||||
);
|
||||
Status = EfiGetVariable (
|
||||
mTimeZoneVariableName,
|
||||
&gEfiCallerIdGuid,
|
||||
NULL,
|
||||
&DataSize,
|
||||
&TimerVar
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Time.TimeZone = (INT16) TimerVar;
|
||||
Time.Daylight = (UINT8) (TimerVar >> 16);
|
||||
Time.TimeZone = (INT16)TimerVar;
|
||||
Time.Daylight = (UINT8)(TimerVar >> 16);
|
||||
} else {
|
||||
Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
|
||||
Time.Daylight = 0;
|
||||
@@ -307,6 +310,7 @@ PcRtcInit (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = RtcTimeFieldsValid (&Time);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Report Status Code to indicate that the RTC has bad date and time
|
||||
@@ -315,15 +319,15 @@ PcRtcInit (
|
||||
EFI_ERROR_CODE | EFI_ERROR_MINOR,
|
||||
(EFI_SOFTWARE_DXE_RT_DRIVER | EFI_SW_EC_BAD_DATE_TIME)
|
||||
);
|
||||
Time.Second = RTC_INIT_SECOND;
|
||||
Time.Minute = RTC_INIT_MINUTE;
|
||||
Time.Hour = RTC_INIT_HOUR;
|
||||
Time.Day = RTC_INIT_DAY;
|
||||
Time.Month = RTC_INIT_MONTH;
|
||||
Time.Year = PcdGet16 (PcdMinimalValidYear);
|
||||
Time.Nanosecond = 0;
|
||||
Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
|
||||
Time.Daylight = 0;
|
||||
Time.Second = RTC_INIT_SECOND;
|
||||
Time.Minute = RTC_INIT_MINUTE;
|
||||
Time.Hour = RTC_INIT_HOUR;
|
||||
Time.Day = RTC_INIT_DAY;
|
||||
Time.Month = RTC_INIT_MONTH;
|
||||
Time.Year = PcdGet16 (PcdMinimalValidYear);
|
||||
Time.Nanosecond = 0;
|
||||
Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
|
||||
Time.Daylight = 0;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -348,15 +352,15 @@ PcRtcInit (
|
||||
// When wakeup time is disabled and invalid, reset wakeup time register to valid state
|
||||
// but keep wakeup alarm disabled.
|
||||
//
|
||||
Time.Second = RTC_INIT_SECOND;
|
||||
Time.Minute = RTC_INIT_MINUTE;
|
||||
Time.Hour = RTC_INIT_HOUR;
|
||||
Time.Day = RTC_INIT_DAY;
|
||||
Time.Month = RTC_INIT_MONTH;
|
||||
Time.Year = PcdGet16 (PcdMinimalValidYear);
|
||||
Time.Nanosecond = 0;
|
||||
Time.TimeZone = Global->SavedTimeZone;
|
||||
Time.Daylight = Global->Daylight;;
|
||||
Time.Second = RTC_INIT_SECOND;
|
||||
Time.Minute = RTC_INIT_MINUTE;
|
||||
Time.Hour = RTC_INIT_HOUR;
|
||||
Time.Day = RTC_INIT_DAY;
|
||||
Time.Month = RTC_INIT_MONTH;
|
||||
Time.Year = PcdGet16 (PcdMinimalValidYear);
|
||||
Time.Nanosecond = 0;
|
||||
Time.TimeZone = Global->SavedTimeZone;
|
||||
Time.Daylight = Global->Daylight;
|
||||
|
||||
//
|
||||
// Acquire RTC Lock to make access to RTC atomic
|
||||
@@ -364,14 +368,16 @@ PcRtcInit (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiAcquireLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
//
|
||||
// Wait for up to 0.1 seconds for the RTC to be updated
|
||||
//
|
||||
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@@ -391,13 +397,14 @@ PcRtcInit (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Inhibit updates of the RTC
|
||||
//
|
||||
RegisterB.Bits.Set = 1;
|
||||
RegisterB.Bits.Set = 1;
|
||||
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
|
||||
|
||||
//
|
||||
@@ -419,6 +426,7 @@ PcRtcInit (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -451,24 +459,27 @@ PcRtcGetTime (
|
||||
//
|
||||
if (Time == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Acquire RTC Lock to make access to RTC atomic
|
||||
//
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiAcquireLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
//
|
||||
// Wait for up to 0.1 seconds for the RTC to be updated
|
||||
//
|
||||
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Read Register B
|
||||
//
|
||||
@@ -477,12 +488,12 @@ PcRtcGetTime (
|
||||
//
|
||||
// Get the Time/Date/Daylight Savings values.
|
||||
//
|
||||
Time->Second = RtcRead (RTC_ADDRESS_SECONDS);
|
||||
Time->Minute = RtcRead (RTC_ADDRESS_MINUTES);
|
||||
Time->Hour = RtcRead (RTC_ADDRESS_HOURS);
|
||||
Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||
Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||
Time->Second = RtcRead (RTC_ADDRESS_SECONDS);
|
||||
Time->Minute = RtcRead (RTC_ADDRESS_MINUTES);
|
||||
Time->Hour = RtcRead (RTC_ADDRESS_HOURS);
|
||||
Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||
Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||
|
||||
//
|
||||
// Release RTC Lock.
|
||||
@@ -494,8 +505,8 @@ PcRtcGetTime (
|
||||
//
|
||||
// Get the variable that contains the TimeZone and Daylight fields
|
||||
//
|
||||
Time->TimeZone = Global->SavedTimeZone;
|
||||
Time->Daylight = Global->Daylight;
|
||||
Time->TimeZone = Global->SavedTimeZone;
|
||||
Time->Daylight = Global->Daylight;
|
||||
|
||||
//
|
||||
// Make sure all field values are in correct range
|
||||
@@ -504,6 +515,7 @@ PcRtcGetTime (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = RtcTimeFieldsValid (Time);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@@ -539,8 +551,8 @@ PcRtcGetTime (
|
||||
**/
|
||||
EFI_STATUS
|
||||
PcRtcSetTime (
|
||||
IN EFI_TIME *Time,
|
||||
IN PC_RTC_MODULE_GLOBALS *Global
|
||||
IN EFI_TIME *Time,
|
||||
IN PC_RTC_MODULE_GLOBALS *Global
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -551,6 +563,7 @@ PcRtcSetTime (
|
||||
if (Time == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure that the time fields are valid
|
||||
//
|
||||
@@ -567,14 +580,16 @@ PcRtcSetTime (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiAcquireLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
//
|
||||
// Wait for up to 0.1 seconds for the RTC to be updated
|
||||
//
|
||||
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -594,35 +609,36 @@ PcRtcSetTime (
|
||||
}
|
||||
} else {
|
||||
TimerVar = Time->Daylight;
|
||||
TimerVar = (UINT32) ((TimerVar << 16) | (UINT16)(Time->TimeZone));
|
||||
Status = EfiSetVariable (
|
||||
mTimeZoneVariableName,
|
||||
&gEfiCallerIdGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
sizeof (TimerVar),
|
||||
&TimerVar
|
||||
);
|
||||
TimerVar = (UINT32)((TimerVar << 16) | (UINT16)(Time->TimeZone));
|
||||
Status = EfiSetVariable (
|
||||
mTimeZoneVariableName,
|
||||
&gEfiCallerIdGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
sizeof (TimerVar),
|
||||
&TimerVar
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Read Register B, and inhibit updates of the RTC
|
||||
//
|
||||
RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
|
||||
RegisterB.Bits.Set = 1;
|
||||
RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
|
||||
RegisterB.Bits.Set = 1;
|
||||
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
|
||||
|
||||
//
|
||||
// Store the century value to RTC before converting to BCD format.
|
||||
//
|
||||
if (Global->CenturyRtcAddress != 0) {
|
||||
RtcWrite (Global->CenturyRtcAddress, DecimalToBcd8 ((UINT8) (RtcTime.Year / 100)));
|
||||
RtcWrite (Global->CenturyRtcAddress, DecimalToBcd8 ((UINT8)(RtcTime.Year / 100)));
|
||||
}
|
||||
|
||||
ConvertEfiTimeToRtcTime (&RtcTime, RegisterB);
|
||||
@@ -632,7 +648,7 @@ PcRtcSetTime (
|
||||
RtcWrite (RTC_ADDRESS_HOURS, RtcTime.Hour);
|
||||
RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH, RtcTime.Day);
|
||||
RtcWrite (RTC_ADDRESS_MONTH, RtcTime.Month);
|
||||
RtcWrite (RTC_ADDRESS_YEAR, (UINT8) RtcTime.Year);
|
||||
RtcWrite (RTC_ADDRESS_YEAR, (UINT8)RtcTime.Year);
|
||||
|
||||
//
|
||||
// Allow updates of the RTC registers
|
||||
@@ -646,6 +662,7 @@ PcRtcSetTime (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the variable that contains the TimeZone and Daylight fields
|
||||
//
|
||||
@@ -690,29 +707,32 @@ PcRtcGetWakeupTime (
|
||||
//
|
||||
if ((Enabled == NULL) || (Pending == NULL) || (Time == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Acquire RTC Lock to make access to RTC atomic
|
||||
//
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiAcquireLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
//
|
||||
// Wait for up to 0.1 seconds for the RTC to be updated
|
||||
//
|
||||
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Read Register B and Register C
|
||||
//
|
||||
RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
|
||||
RegisterC.Data = RtcRead (RTC_ADDRESS_REGISTER_C);
|
||||
RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
|
||||
RegisterC.Data = RtcRead (RTC_ADDRESS_REGISTER_C);
|
||||
|
||||
//
|
||||
// Get the Time/Date/Daylight Savings values.
|
||||
@@ -720,12 +740,12 @@ PcRtcGetWakeupTime (
|
||||
*Enabled = RegisterB.Bits.Aie;
|
||||
*Pending = RegisterC.Bits.Af;
|
||||
|
||||
Time->Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
|
||||
Time->Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
|
||||
Time->Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
|
||||
Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||
Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||
Time->Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
|
||||
Time->Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
|
||||
Time->Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
|
||||
Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||
Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||
Time->TimeZone = Global->SavedTimeZone;
|
||||
Time->Daylight = Global->Daylight;
|
||||
|
||||
@@ -733,13 +753,13 @@ PcRtcGetWakeupTime (
|
||||
// Get the alarm info from variable
|
||||
//
|
||||
DataSize = sizeof (EFI_TIME);
|
||||
Status = EfiGetVariable (
|
||||
L"RTCALARM",
|
||||
&gEfiCallerIdGuid,
|
||||
NULL,
|
||||
&DataSize,
|
||||
&RtcTime
|
||||
);
|
||||
Status = EfiGetVariable (
|
||||
L"RTCALARM",
|
||||
&gEfiCallerIdGuid,
|
||||
NULL,
|
||||
&DataSize,
|
||||
&RtcTime
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// The alarm variable exists. In this case, we read variable to get info.
|
||||
@@ -763,6 +783,7 @@ PcRtcGetWakeupTime (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = RtcTimeFieldsValid (Time);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@@ -792,18 +813,18 @@ PcRtcSetWakeupTime (
|
||||
IN PC_RTC_MODULE_GLOBALS *Global
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_TIME RtcTime;
|
||||
RTC_REGISTER_B RegisterB;
|
||||
EFI_TIME_CAPABILITIES Capabilities;
|
||||
EFI_STATUS Status;
|
||||
EFI_TIME RtcTime;
|
||||
RTC_REGISTER_B RegisterB;
|
||||
EFI_TIME_CAPABILITIES Capabilities;
|
||||
|
||||
ZeroMem (&RtcTime, sizeof (RtcTime));
|
||||
|
||||
if (Enable) {
|
||||
|
||||
if (Time == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure that the time fields are valid
|
||||
//
|
||||
@@ -811,6 +832,7 @@ PcRtcSetWakeupTime (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Just support set alarm time within 24 hours
|
||||
//
|
||||
@@ -819,31 +841,36 @@ PcRtcSetWakeupTime (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (!IsWithinOneDay (&RtcTime, Time)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Make a local copy of the time and date
|
||||
//
|
||||
CopyMem (&RtcTime, Time, sizeof (EFI_TIME));
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Acquire RTC Lock to make access to RTC atomic
|
||||
//
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiAcquireLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
//
|
||||
// Wait for up to 0.1 seconds for the RTC to be updated
|
||||
//
|
||||
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Read Register B
|
||||
//
|
||||
@@ -855,12 +882,12 @@ PcRtcSetWakeupTime (
|
||||
//
|
||||
// if the alarm is disable, record the current setting.
|
||||
//
|
||||
RtcTime.Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
|
||||
RtcTime.Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
|
||||
RtcTime.Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
|
||||
RtcTime.Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||
RtcTime.Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||
RtcTime.Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||
RtcTime.Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
|
||||
RtcTime.Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
|
||||
RtcTime.Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
|
||||
RtcTime.Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
||||
RtcTime.Month = RtcRead (RTC_ADDRESS_MONTH);
|
||||
RtcTime.Year = RtcRead (RTC_ADDRESS_YEAR);
|
||||
RtcTime.TimeZone = Global->SavedTimeZone;
|
||||
RtcTime.Daylight = Global->Daylight;
|
||||
}
|
||||
@@ -879,13 +906,14 @@ PcRtcSetWakeupTime (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Inhibit updates of the RTC
|
||||
//
|
||||
RegisterB.Bits.Set = 1;
|
||||
RegisterB.Bits.Set = 1;
|
||||
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
|
||||
|
||||
if (Enable) {
|
||||
@@ -897,10 +925,10 @@ PcRtcSetWakeupTime (
|
||||
RtcWrite (RTC_ADDRESS_HOURS_ALARM, RtcTime.Hour);
|
||||
|
||||
RegisterB.Bits.Aie = 1;
|
||||
|
||||
} else {
|
||||
RegisterB.Bits.Aie = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Allow updates of the RTC registers
|
||||
//
|
||||
@@ -913,10 +941,10 @@ PcRtcSetWakeupTime (
|
||||
if (!EfiAtRuntime ()) {
|
||||
EfiReleaseLock (&Global->RtcLock);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Checks an 8-bit BCD value, and converts to an 8-bit value if valid.
|
||||
|
||||
@@ -964,8 +992,8 @@ ConvertRtcTimeToEfiTime (
|
||||
IN RTC_REGISTER_B RegisterB
|
||||
)
|
||||
{
|
||||
BOOLEAN IsPM;
|
||||
UINT8 Century;
|
||||
BOOLEAN IsPM;
|
||||
UINT8 Century;
|
||||
|
||||
if ((Time->Hour & 0x80) != 0) {
|
||||
IsPM = TRUE;
|
||||
@@ -973,19 +1001,20 @@ ConvertRtcTimeToEfiTime (
|
||||
IsPM = FALSE;
|
||||
}
|
||||
|
||||
Time->Hour = (UINT8) (Time->Hour & 0x7f);
|
||||
Time->Hour = (UINT8)(Time->Hour & 0x7f);
|
||||
|
||||
if (RegisterB.Bits.Dm == 0) {
|
||||
Time->Year = CheckAndConvertBcd8ToDecimal8 ((UINT8) Time->Year);
|
||||
Time->Month = CheckAndConvertBcd8ToDecimal8 (Time->Month);
|
||||
Time->Day = CheckAndConvertBcd8ToDecimal8 (Time->Day);
|
||||
Time->Hour = CheckAndConvertBcd8ToDecimal8 (Time->Hour);
|
||||
Time->Minute = CheckAndConvertBcd8ToDecimal8 (Time->Minute);
|
||||
Time->Second = CheckAndConvertBcd8ToDecimal8 (Time->Second);
|
||||
Time->Year = CheckAndConvertBcd8ToDecimal8 ((UINT8)Time->Year);
|
||||
Time->Month = CheckAndConvertBcd8ToDecimal8 (Time->Month);
|
||||
Time->Day = CheckAndConvertBcd8ToDecimal8 (Time->Day);
|
||||
Time->Hour = CheckAndConvertBcd8ToDecimal8 (Time->Hour);
|
||||
Time->Minute = CheckAndConvertBcd8ToDecimal8 (Time->Minute);
|
||||
Time->Second = CheckAndConvertBcd8ToDecimal8 (Time->Second);
|
||||
}
|
||||
|
||||
if (Time->Year == 0xff || Time->Month == 0xff || Time->Day == 0xff ||
|
||||
Time->Hour == 0xff || Time->Minute == 0xff || Time->Second == 0xff) {
|
||||
if ((Time->Year == 0xff) || (Time->Month == 0xff) || (Time->Day == 0xff) ||
|
||||
(Time->Hour == 0xff) || (Time->Minute == 0xff) || (Time->Second == 0xff))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -994,26 +1023,27 @@ ConvertRtcTimeToEfiTime (
|
||||
// Century is 19 if RTC year >= 70,
|
||||
// Century is 20 otherwise.
|
||||
//
|
||||
Century = (UINT8) (PcdGet16 (PcdMinimalValidYear) / 100);
|
||||
Century = (UINT8)(PcdGet16 (PcdMinimalValidYear) / 100);
|
||||
if (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) {
|
||||
Century++;
|
||||
}
|
||||
Time->Year = (UINT16) (Century * 100 + Time->Year);
|
||||
|
||||
Time->Year = (UINT16)(Century * 100 + Time->Year);
|
||||
|
||||
//
|
||||
// If time is in 12 hour format, convert it to 24 hour format
|
||||
//
|
||||
if (RegisterB.Bits.Mil == 0) {
|
||||
if (IsPM && Time->Hour < 12) {
|
||||
Time->Hour = (UINT8) (Time->Hour + 12);
|
||||
if (IsPM && (Time->Hour < 12)) {
|
||||
Time->Hour = (UINT8)(Time->Hour + 12);
|
||||
}
|
||||
|
||||
if (!IsPM && Time->Hour == 12) {
|
||||
if (!IsPM && (Time->Hour == 12)) {
|
||||
Time->Hour = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Time->Nanosecond = 0;
|
||||
Time->Nanosecond = 0;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -1028,7 +1058,7 @@ ConvertRtcTimeToEfiTime (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RtcWaitToUpdate (
|
||||
UINTN Timeout
|
||||
UINTN Timeout
|
||||
)
|
||||
{
|
||||
RTC_REGISTER_A RegisterA;
|
||||
@@ -1042,11 +1072,12 @@ RtcWaitToUpdate (
|
||||
if (RegisterD.Bits.Vrt == 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Wait for up to 0.1 seconds for the RTC to be ready.
|
||||
//
|
||||
Timeout = (Timeout / 10) + 1;
|
||||
RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
|
||||
Timeout = (Timeout / 10) + 1;
|
||||
RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
|
||||
while (RegisterA.Bits.Uip == 1 && Timeout > 0) {
|
||||
MicroSecondDelay (10);
|
||||
RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
|
||||
@@ -1054,7 +1085,7 @@ RtcWaitToUpdate (
|
||||
}
|
||||
|
||||
RegisterD.Data = RtcRead (RTC_ADDRESS_REGISTER_D);
|
||||
if (Timeout == 0 || RegisterD.Bits.Vrt == 0) {
|
||||
if ((Timeout == 0) || (RegisterD.Bits.Vrt == 0)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@@ -1072,20 +1103,21 @@ RtcWaitToUpdate (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RtcTimeFieldsValid (
|
||||
IN EFI_TIME *Time
|
||||
IN EFI_TIME *Time
|
||||
)
|
||||
{
|
||||
if (Time->Year < PcdGet16 (PcdMinimalValidYear) ||
|
||||
Time->Year > PcdGet16 (PcdMaximalValidYear) ||
|
||||
Time->Month < 1 ||
|
||||
Time->Month > 12 ||
|
||||
if ((Time->Year < PcdGet16 (PcdMinimalValidYear)) ||
|
||||
(Time->Year > PcdGet16 (PcdMaximalValidYear)) ||
|
||||
(Time->Month < 1) ||
|
||||
(Time->Month > 12) ||
|
||||
(!DayValid (Time)) ||
|
||||
Time->Hour > 23 ||
|
||||
Time->Minute > 59 ||
|
||||
Time->Second > 59 ||
|
||||
Time->Nanosecond > 999999999 ||
|
||||
(!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||
|
||||
((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0)) {
|
||||
(Time->Hour > 23) ||
|
||||
(Time->Minute > 59) ||
|
||||
(Time->Second > 59) ||
|
||||
(Time->Nanosecond > 999999999) ||
|
||||
(!((Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) || ((Time->TimeZone >= -1440) && (Time->TimeZone <= 1440)))) ||
|
||||
((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -1108,12 +1140,13 @@ DayValid (
|
||||
//
|
||||
// The validity of Time->Month field should be checked before
|
||||
//
|
||||
ASSERT (Time->Month >=1);
|
||||
ASSERT (Time->Month <=12);
|
||||
if (Time->Day < 1 ||
|
||||
Time->Day > mDayOfMonth[Time->Month - 1] ||
|
||||
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
|
||||
) {
|
||||
ASSERT (Time->Month >= 1);
|
||||
ASSERT (Time->Month <= 12);
|
||||
if ((Time->Day < 1) ||
|
||||
(Time->Day > mDayOfMonth[Time->Month - 1]) ||
|
||||
((Time->Month == 2) && (!IsLeapYear (Time) && (Time->Day > 28)))
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1130,7 +1163,7 @@ DayValid (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsLeapYear (
|
||||
IN EFI_TIME *Time
|
||||
IN EFI_TIME *Time
|
||||
)
|
||||
{
|
||||
if (Time->Year % 4 == 0) {
|
||||
@@ -1165,7 +1198,7 @@ ConvertEfiTimeToRtcTime (
|
||||
IN RTC_REGISTER_B RegisterB
|
||||
)
|
||||
{
|
||||
BOOLEAN IsPM;
|
||||
BOOLEAN IsPM;
|
||||
|
||||
IsPM = TRUE;
|
||||
//
|
||||
@@ -1177,29 +1210,31 @@ ConvertEfiTimeToRtcTime (
|
||||
}
|
||||
|
||||
if (Time->Hour >= 13) {
|
||||
Time->Hour = (UINT8) (Time->Hour - 12);
|
||||
Time->Hour = (UINT8)(Time->Hour - 12);
|
||||
} else if (Time->Hour == 0) {
|
||||
Time->Hour = 12;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Set the Time/Date values.
|
||||
//
|
||||
Time->Year = (UINT16) (Time->Year % 100);
|
||||
Time->Year = (UINT16)(Time->Year % 100);
|
||||
|
||||
if (RegisterB.Bits.Dm == 0) {
|
||||
Time->Year = DecimalToBcd8 ((UINT8) Time->Year);
|
||||
Time->Month = DecimalToBcd8 (Time->Month);
|
||||
Time->Day = DecimalToBcd8 (Time->Day);
|
||||
Time->Hour = DecimalToBcd8 (Time->Hour);
|
||||
Time->Minute = DecimalToBcd8 (Time->Minute);
|
||||
Time->Second = DecimalToBcd8 (Time->Second);
|
||||
Time->Year = DecimalToBcd8 ((UINT8)Time->Year);
|
||||
Time->Month = DecimalToBcd8 (Time->Month);
|
||||
Time->Day = DecimalToBcd8 (Time->Day);
|
||||
Time->Hour = DecimalToBcd8 (Time->Hour);
|
||||
Time->Minute = DecimalToBcd8 (Time->Minute);
|
||||
Time->Second = DecimalToBcd8 (Time->Second);
|
||||
}
|
||||
|
||||
//
|
||||
// If we are in 12 hour mode and PM is set, then set bit 7 of the Hour field.
|
||||
//
|
||||
if (RegisterB.Bits.Mil == 0 && IsPM) {
|
||||
Time->Hour = (UINT8) (Time->Hour | 0x80);
|
||||
if ((RegisterB.Bits.Mil == 0) && IsPM) {
|
||||
Time->Hour = (UINT8)(Time->Hour | 0x80);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1217,13 +1252,14 @@ ConvertEfiTimeToRtcTime (
|
||||
**/
|
||||
INTN
|
||||
CompareHMS (
|
||||
IN EFI_TIME *From,
|
||||
IN EFI_TIME *To
|
||||
IN EFI_TIME *From,
|
||||
IN EFI_TIME *To
|
||||
)
|
||||
{
|
||||
if ((From->Hour > To->Hour) ||
|
||||
((From->Hour == To->Hour) && (From->Minute > To->Minute)) ||
|
||||
((From->Hour == To->Hour) && (From->Minute == To->Minute) && (From->Second > To->Second))) {
|
||||
((From->Hour == To->Hour) && (From->Minute > To->Minute)) ||
|
||||
((From->Hour == To->Hour) && (From->Minute == To->Minute) && (From->Second > To->Second)))
|
||||
{
|
||||
return 1;
|
||||
} else if ((From->Hour == To->Hour) && (From->Minute == To->Minute) && (From->Second == To->Second)) {
|
||||
return 0;
|
||||
@@ -1247,37 +1283,37 @@ IsWithinOneDay (
|
||||
IN EFI_TIME *To
|
||||
)
|
||||
{
|
||||
BOOLEAN Adjacent;
|
||||
BOOLEAN Adjacent;
|
||||
|
||||
Adjacent = FALSE;
|
||||
|
||||
//
|
||||
// The validity of From->Month field should be checked before
|
||||
//
|
||||
ASSERT (From->Month >=1);
|
||||
ASSERT (From->Month <=12);
|
||||
ASSERT (From->Month >= 1);
|
||||
ASSERT (From->Month <= 12);
|
||||
|
||||
if (From->Year == To->Year) {
|
||||
if (From->Month == To->Month) {
|
||||
if ((From->Day + 1) == To->Day) {
|
||||
if ((CompareHMS(From, To) >= 0)) {
|
||||
if ((CompareHMS (From, To) >= 0)) {
|
||||
Adjacent = TRUE;
|
||||
}
|
||||
} else if (From->Day == To->Day) {
|
||||
if ((CompareHMS(From, To) <= 0)) {
|
||||
if ((CompareHMS (From, To) <= 0)) {
|
||||
Adjacent = TRUE;
|
||||
}
|
||||
}
|
||||
} else if (((From->Month + 1) == To->Month) && (To->Day == 1)) {
|
||||
if ((From->Month == 2) && !IsLeapYear(From)) {
|
||||
if ((From->Month == 2) && !IsLeapYear (From)) {
|
||||
if (From->Day == 28) {
|
||||
if ((CompareHMS(From, To) >= 0)) {
|
||||
if ((CompareHMS (From, To) >= 0)) {
|
||||
Adjacent = TRUE;
|
||||
}
|
||||
}
|
||||
} else if (From->Day == mDayOfMonth[From->Month - 1]) {
|
||||
if ((CompareHMS(From, To) >= 0)) {
|
||||
Adjacent = TRUE;
|
||||
if ((CompareHMS (From, To) >= 0)) {
|
||||
Adjacent = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1285,8 +1321,9 @@ IsWithinOneDay (
|
||||
(From->Month == 12) &&
|
||||
(From->Day == 31) &&
|
||||
(To->Month == 1) &&
|
||||
(To->Day == 1)) {
|
||||
if ((CompareHMS(From, To) >= 0)) {
|
||||
(To->Day == 1))
|
||||
{
|
||||
if ((CompareHMS (From, To) >= 0)) {
|
||||
Adjacent = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1304,15 +1341,16 @@ GetCenturyRtcAddress (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
|
||||
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
|
||||
|
||||
Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) EfiLocateFirstAcpiTable (
|
||||
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
|
||||
);
|
||||
Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)EfiLocateFirstAcpiTable (
|
||||
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
|
||||
);
|
||||
|
||||
if ((Fadt != NULL) &&
|
||||
(Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return Fadt->Century;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -1332,21 +1370,21 @@ GetCenturyRtcAddress (
|
||||
VOID
|
||||
EFIAPI
|
||||
PcRtcAcpiTableChangeCallback (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_TIME Time;
|
||||
UINT8 CenturyRtcAddress;
|
||||
UINT8 Century;
|
||||
EFI_STATUS Status;
|
||||
EFI_TIME Time;
|
||||
UINT8 CenturyRtcAddress;
|
||||
UINT8 Century;
|
||||
|
||||
CenturyRtcAddress = GetCenturyRtcAddress ();
|
||||
if ((CenturyRtcAddress != 0) && (mModuleGlobal.CenturyRtcAddress != CenturyRtcAddress)) {
|
||||
mModuleGlobal.CenturyRtcAddress = CenturyRtcAddress;
|
||||
Status = PcRtcGetTime (&Time, NULL, &mModuleGlobal);
|
||||
Status = PcRtcGetTime (&Time, NULL, &mModuleGlobal);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Century = (UINT8) (Time.Year / 100);
|
||||
Century = (UINT8)(Time.Year / 100);
|
||||
Century = DecimalToBcd8 (Century);
|
||||
DEBUG ((DEBUG_INFO, "PcRtc: Write 0x%x to CMOS location 0x%x\n", Century, mModuleGlobal.CenturyRtcAddress));
|
||||
RtcWrite (mModuleGlobal.CenturyRtcAddress, Century);
|
||||
|
@@ -8,11 +8,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _RTC_H_
|
||||
#define _RTC_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Guid/Acpi.h>
|
||||
@@ -33,10 +31,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
|
||||
typedef struct {
|
||||
EFI_LOCK RtcLock;
|
||||
INT16 SavedTimeZone;
|
||||
UINT8 Daylight;
|
||||
UINT8 CenturyRtcAddress;
|
||||
EFI_LOCK RtcLock;
|
||||
INT16 SavedTimeZone;
|
||||
UINT8 Daylight;
|
||||
UINT8 CenturyRtcAddress;
|
||||
} PC_RTC_MODULE_GLOBALS;
|
||||
|
||||
extern PC_RTC_MODULE_GLOBALS mModuleGlobal;
|
||||
@@ -62,73 +60,73 @@ extern PC_RTC_MODULE_GLOBALS mModuleGlobal;
|
||||
// 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_SECOND 0
|
||||
#define RTC_INIT_MINUTE 0
|
||||
#define RTC_INIT_HOUR 0
|
||||
#define RTC_INIT_DAY 1
|
||||
#define RTC_INIT_MONTH 1
|
||||
|
||||
#pragma pack(1)
|
||||
//
|
||||
// Register A
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 Rs : 4; // Rate Selection Bits
|
||||
UINT8 Dv : 3; // Divisor
|
||||
UINT8 Uip : 1; // Update in progress
|
||||
UINT8 Rs : 4; // Rate Selection Bits
|
||||
UINT8 Dv : 3; // Divisor
|
||||
UINT8 Uip : 1; // Update in progress
|
||||
} RTC_REGISTER_A_BITS;
|
||||
|
||||
typedef union {
|
||||
RTC_REGISTER_A_BITS Bits;
|
||||
UINT8 Data;
|
||||
RTC_REGISTER_A_BITS Bits;
|
||||
UINT8 Data;
|
||||
} RTC_REGISTER_A;
|
||||
|
||||
//
|
||||
// Register B
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 Dse : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
|
||||
UINT8 Mil : 1; // 0 - 12 hour mode 1 - 24 hour mode
|
||||
UINT8 Dm : 1; // 0 - BCD Format 1 - Binary Format
|
||||
UINT8 Sqwe : 1; // 0 - Disable SQWE output 1 - Enable SQWE output
|
||||
UINT8 Uie : 1; // 0 - Update INT disabled 1 - Update INT enabled
|
||||
UINT8 Aie : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
|
||||
UINT8 Pie : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
|
||||
UINT8 Set : 1; // 0 - Normal operation. 1 - Updates inhibited
|
||||
UINT8 Dse : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
|
||||
UINT8 Mil : 1; // 0 - 12 hour mode 1 - 24 hour mode
|
||||
UINT8 Dm : 1; // 0 - BCD Format 1 - Binary Format
|
||||
UINT8 Sqwe : 1; // 0 - Disable SQWE output 1 - Enable SQWE output
|
||||
UINT8 Uie : 1; // 0 - Update INT disabled 1 - Update INT enabled
|
||||
UINT8 Aie : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
|
||||
UINT8 Pie : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
|
||||
UINT8 Set : 1; // 0 - Normal operation. 1 - Updates inhibited
|
||||
} RTC_REGISTER_B_BITS;
|
||||
|
||||
typedef union {
|
||||
RTC_REGISTER_B_BITS Bits;
|
||||
UINT8 Data;
|
||||
RTC_REGISTER_B_BITS Bits;
|
||||
UINT8 Data;
|
||||
} RTC_REGISTER_B;
|
||||
|
||||
//
|
||||
// Register C
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 Reserved : 4; // Read as zero. Can not be written.
|
||||
UINT8 Uf : 1; // Update End Interrupt Flag
|
||||
UINT8 Af : 1; // Alarm Interrupt Flag
|
||||
UINT8 Pf : 1; // Periodic Interrupt Flag
|
||||
UINT8 Irqf : 1; // Interrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
|
||||
UINT8 Reserved : 4; // Read as zero. Can not be written.
|
||||
UINT8 Uf : 1; // Update End Interrupt Flag
|
||||
UINT8 Af : 1; // Alarm Interrupt Flag
|
||||
UINT8 Pf : 1; // Periodic Interrupt Flag
|
||||
UINT8 Irqf : 1; // Interrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
|
||||
} RTC_REGISTER_C_BITS;
|
||||
|
||||
typedef union {
|
||||
RTC_REGISTER_C_BITS Bits;
|
||||
UINT8 Data;
|
||||
RTC_REGISTER_C_BITS Bits;
|
||||
UINT8 Data;
|
||||
} RTC_REGISTER_C;
|
||||
|
||||
//
|
||||
// Register D
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 Reserved : 7; // Read as zero. Can not be written.
|
||||
UINT8 Vrt : 1; // Valid RAM and Time
|
||||
UINT8 Reserved : 7; // Read as zero. Can not be written.
|
||||
UINT8 Vrt : 1; // Valid RAM and Time
|
||||
} RTC_REGISTER_D_BITS;
|
||||
|
||||
typedef union {
|
||||
RTC_REGISTER_D_BITS Bits;
|
||||
UINT8 Data;
|
||||
RTC_REGISTER_D_BITS Bits;
|
||||
UINT8 Data;
|
||||
} RTC_REGISTER_D;
|
||||
|
||||
#pragma pack()
|
||||
@@ -180,9 +178,9 @@ PcRtcSetTime (
|
||||
**/
|
||||
EFI_STATUS
|
||||
PcRtcGetTime (
|
||||
OUT EFI_TIME *Time,
|
||||
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL,
|
||||
IN PC_RTC_MODULE_GLOBALS *Global
|
||||
OUT EFI_TIME *Time,
|
||||
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL,
|
||||
IN PC_RTC_MODULE_GLOBALS *Global
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -225,10 +223,10 @@ PcRtcSetWakeupTime (
|
||||
**/
|
||||
EFI_STATUS
|
||||
PcRtcGetWakeupTime (
|
||||
OUT BOOLEAN *Enabled,
|
||||
OUT BOOLEAN *Pending,
|
||||
OUT EFI_TIME *Time,
|
||||
IN PC_RTC_MODULE_GLOBALS *Global
|
||||
OUT BOOLEAN *Enabled,
|
||||
OUT BOOLEAN *Pending,
|
||||
OUT EFI_TIME *Time,
|
||||
IN PC_RTC_MODULE_GLOBALS *Global
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -247,8 +245,8 @@ PcRtcGetWakeupTime (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializePcRtc (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -262,7 +260,7 @@ InitializePcRtc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RtcTimeFieldsValid (
|
||||
IN EFI_TIME *Time
|
||||
IN EFI_TIME *Time
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -282,7 +280,6 @@ ConvertEfiTimeToRtcTime (
|
||||
IN RTC_REGISTER_B RegisterB
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Converts time read from RTC to EFI_TIME format defined by UEFI spec.
|
||||
|
||||
@@ -316,7 +313,7 @@ ConvertRtcTimeToEfiTime (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RtcWaitToUpdate (
|
||||
UINTN Timeout
|
||||
UINTN Timeout
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -342,7 +339,7 @@ DayValid (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsLeapYear (
|
||||
IN EFI_TIME *Time
|
||||
IN EFI_TIME *Time
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -368,7 +365,8 @@ GetCenturyRtcAddress (
|
||||
VOID
|
||||
EFIAPI
|
||||
PcRtcAcpiTableChangeCallback (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -12,12 +12,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
PC_RTC_MODULE_GLOBALS mModuleGlobal;
|
||||
|
||||
EFI_HANDLE mHandle = NULL;
|
||||
EFI_HANDLE mHandle = NULL;
|
||||
|
||||
STATIC EFI_EVENT mVirtualAddrChangeEvent;
|
||||
STATIC EFI_EVENT mVirtualAddrChangeEvent;
|
||||
|
||||
UINTN mRtcIndexRegister;
|
||||
UINTN mRtcTargetRegister;
|
||||
UINTN mRtcIndexRegister;
|
||||
UINTN mRtcTargetRegister;
|
||||
|
||||
/**
|
||||
Returns the current time and date information, and the time-keeping capabilities
|
||||
@@ -35,8 +35,8 @@ UINTN mRtcTargetRegister;
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PcRtcEfiGetTime (
|
||||
OUT EFI_TIME *Time,
|
||||
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
|
||||
OUT EFI_TIME *Time,
|
||||
OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
|
||||
)
|
||||
{
|
||||
return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);
|
||||
@@ -55,7 +55,7 @@ PcRtcEfiGetTime (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PcRtcEfiSetTime (
|
||||
IN EFI_TIME *Time
|
||||
IN EFI_TIME *Time
|
||||
)
|
||||
{
|
||||
return PcRtcSetTime (Time, &mModuleGlobal);
|
||||
@@ -79,15 +79,14 @@ PcRtcEfiSetTime (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PcRtcEfiGetWakeupTime (
|
||||
OUT BOOLEAN *Enabled,
|
||||
OUT BOOLEAN *Pending,
|
||||
OUT EFI_TIME *Time
|
||||
OUT BOOLEAN *Enabled,
|
||||
OUT BOOLEAN *Pending,
|
||||
OUT EFI_TIME *Time
|
||||
)
|
||||
{
|
||||
return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets the system wakeup alarm clock time.
|
||||
|
||||
@@ -105,8 +104,8 @@ PcRtcEfiGetWakeupTime (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PcRtcEfiSetWakeupTime (
|
||||
IN BOOLEAN Enabled,
|
||||
IN EFI_TIME *Time OPTIONAL
|
||||
IN BOOLEAN Enabled,
|
||||
IN EFI_TIME *Time OPTIONAL
|
||||
)
|
||||
{
|
||||
return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);
|
||||
@@ -123,8 +122,8 @@ PcRtcEfiSetWakeupTime (
|
||||
VOID
|
||||
EFIAPI
|
||||
LibRtcVirtualNotifyEvent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
// Only needed if you are going to support the OS calling RTC functions in
|
||||
@@ -132,8 +131,8 @@ LibRtcVirtualNotifyEvent (
|
||||
// stored physical addresses to virtual address. After the OS transitions to
|
||||
// calling in virtual mode, all future runtime calls will be made in virtual
|
||||
// mode.
|
||||
EfiConvertPointer (0x0, (VOID**)&mRtcIndexRegister);
|
||||
EfiConvertPointer (0x0, (VOID**)&mRtcTargetRegister);
|
||||
EfiConvertPointer (0x0, (VOID **)&mRtcIndexRegister);
|
||||
EfiConvertPointer (0x0, (VOID **)&mRtcTargetRegister);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,8 +151,8 @@ LibRtcVirtualNotifyEvent (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializePcRtc (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -163,7 +162,7 @@ InitializePcRtc (
|
||||
mModuleGlobal.CenturyRtcAddress = GetCenturyRtcAddress ();
|
||||
|
||||
if (FeaturePcdGet (PcdRtcUseMmio)) {
|
||||
mRtcIndexRegister = (UINTN)PcdGet64 (PcdRtcIndexRegister64);
|
||||
mRtcIndexRegister = (UINTN)PcdGet64 (PcdRtcIndexRegister64);
|
||||
mRtcTargetRegister = (UINTN)PcdGet64 (PcdRtcTargetRegister64);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user