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:
Michael Kubacki 2021-12-05 14:54:10 -08:00 committed by mergify[bot]
parent ac0a286f4d
commit 5220bd211d
18 changed files with 663 additions and 606 deletions

View File

@ -230,7 +230,8 @@ IdeControllerStart (
// //
return gBS->InstallMultipleProtocolInterfaces ( return gBS->InstallMultipleProtocolInterfaces (
&Controller, &Controller,
&gEfiIdeControllerInitProtocolGuid, &gEfiIdeControllerInit, &gEfiIdeControllerInitProtocolGuid,
&gEfiIdeControllerInit,
NULL NULL
); );
} }
@ -285,7 +286,8 @@ IdeControllerStop (
// //
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
Controller, Controller,
&gEfiIdeControllerInitProtocolGuid, &gEfiIdeControllerInit, &gEfiIdeControllerInitProtocolGuid,
&gEfiIdeControllerInit,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -306,6 +308,7 @@ IdeControllerStop (
// //
// Interface functions of IDE_CONTROLLER_INIT protocol // Interface functions of IDE_CONTROLLER_INIT protocol
// //
/** /**
Returns the information about the specified IDE channel. Returns the information about the specified IDE channel.
@ -565,7 +568,7 @@ IdeInitCalculateMode (
OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
) )
{ {
if (Channel >= ICH_IDE_MAX_CHANNEL || Device >= ICH_IDE_MAX_DEVICES) { if ((Channel >= ICH_IDE_MAX_CHANNEL) || (Device >= ICH_IDE_MAX_DEVICES)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }

View File

@ -44,6 +44,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2;
// //
// Driver binding functions declaration // Driver binding functions declaration
// //
/** /**
Register Driver Binding protocol for this driver. Register Driver Binding protocol for this driver.
@ -110,6 +111,7 @@ IdeControllerStop (
// //
// IDE controller init functions declaration // IDE controller init functions declaration
// //
/** /**
Returns the information about the specified IDE channel. Returns the information about the specified IDE channel.
@ -388,6 +390,7 @@ IdeInitSetTiming (
// //
// Forward reference declaration // Forward reference declaration
// //
/** /**
Retrieves a Unicode string that is the user readable name of the EFI Driver. Retrieves a Unicode string that is the user readable name of the EFI Driver.

View File

@ -300,7 +300,9 @@ TimerInterruptHandler (
// //
// Count number of ticks // Count number of ticks
// //
DEBUG_CODE (mNumTicks++;); DEBUG_CODE (
mNumTicks++;
);
// //
// Clear HPET timer interrupt status // Clear HPET timer interrupt status
@ -376,6 +378,7 @@ TimerInterruptHandler (
// //
Delta = (mCounterMask - mPreviousMainCounter) + MainCounter; Delta = (mCounterMask - mPreviousMainCounter) + MainCounter;
} }
TimerPeriod = DivU64x32 ( TimerPeriod = DivU64x32 (
MultU64x32 ( MultU64x32 (
Delta & mCounterMask, Delta & mCounterMask,
@ -437,10 +440,11 @@ TimerDriverRegisterHandler (
// //
// Check for invalid parameters // Check for invalid parameters
// //
if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) { if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {
if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
@ -513,6 +517,7 @@ TimerDriverSetTimerPeriod (
} else { } else {
Delta = MainCounter - mPreviousMainCounter; Delta = MainCounter - mPreviousMainCounter;
} }
if ((Delta & mCounterMask) >= mTimerCount) { if ((Delta & mCounterMask) >= mTimerCount) {
// //
// Interrupt still happens after disable HPET, wait to be processed // Interrupt still happens after disable HPET, wait to be processed
@ -530,7 +535,7 @@ TimerDriverSetTimerPeriod (
// If TimerPeriod is 0, then mask HPET Timer interrupts // If TimerPeriod is 0, then mask HPET Timer interrupts
// //
if (mTimerConfiguration.Bits.MsiInterruptCapability != 0 && FeaturePcdGet (PcdHpetMsiEnable)) { if ((mTimerConfiguration.Bits.MsiInterruptCapability != 0) && FeaturePcdGet (PcdHpetMsiEnable)) {
// //
// Disable HPET MSI interrupt generation // Disable HPET MSI interrupt generation
// //
@ -567,6 +572,7 @@ TimerDriverSetTimerPeriod (
} else { } else {
Delta = (mCounterMask - mPreviousMainCounter) + MainCounter; Delta = (mCounterMask - mPreviousMainCounter) + MainCounter;
} }
if ((Delta & mCounterMask) >= mTimerCount) { if ((Delta & mCounterMask) >= mTimerCount) {
HpetWrite (HPET_TIMER_COMPARATOR_OFFSET + mTimerIndex * HPET_TIMER_STRIDE, (MainCounter + 1) & mCounterMask); HpetWrite (HPET_TIMER_COMPARATOR_OFFSET + mTimerIndex * HPET_TIMER_STRIDE, (MainCounter + 1) & mCounterMask);
} else { } else {
@ -576,7 +582,7 @@ TimerDriverSetTimerPeriod (
// //
// Enable HPET Timer interrupt generation // Enable HPET Timer interrupt generation
// //
if (mTimerConfiguration.Bits.MsiInterruptCapability != 0 && FeaturePcdGet (PcdHpetMsiEnable)) { if ((mTimerConfiguration.Bits.MsiInterruptCapability != 0) && FeaturePcdGet (PcdHpetMsiEnable)) {
// //
// Program MSI Address and MSI Data values in the selected HPET Timer // Program MSI Address and MSI Data values in the selected HPET Timer
// Program HPET register with APIC ID of current BSP in case BSP has been switched // Program HPET register with APIC ID of current BSP in case BSP has been switched
@ -787,7 +793,7 @@ TimerDriverInitialize (
// //
ASSERT (mHpetGeneralCapabilities.Uint64 != 0); ASSERT (mHpetGeneralCapabilities.Uint64 != 0);
ASSERT (mHpetGeneralCapabilities.Uint64 != 0xFFFFFFFFFFFFFFFFULL); ASSERT (mHpetGeneralCapabilities.Uint64 != 0xFFFFFFFFFFFFFFFFULL);
if (mHpetGeneralCapabilities.Uint64 == 0 || mHpetGeneralCapabilities.Uint64 == 0xFFFFFFFFFFFFFFFFULL) { if ((mHpetGeneralCapabilities.Uint64 == 0) || (mHpetGeneralCapabilities.Uint64 == 0xFFFFFFFFFFFFFFFFULL)) {
DEBUG ((DEBUG_ERROR, "HPET device is not present. Unload HPET driver.\n")); DEBUG ((DEBUG_ERROR, "HPET device is not present. Unload HPET driver.\n"));
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -812,6 +818,7 @@ TimerDriverInitialize (
DEBUG ((DEBUG_INFO, " HPET_TIMER%d_COMPARATOR = 0x%016lx\n", TimerIndex, HpetRead (HPET_TIMER_COMPARATOR_OFFSET + TimerIndex * HPET_TIMER_STRIDE))); DEBUG ((DEBUG_INFO, " HPET_TIMER%d_COMPARATOR = 0x%016lx\n", TimerIndex, HpetRead (HPET_TIMER_COMPARATOR_OFFSET + TimerIndex * HPET_TIMER_STRIDE)));
DEBUG ((DEBUG_INFO, " HPET_TIMER%d_MSI_ROUTE = 0x%016lx\n", TimerIndex, HpetRead (HPET_TIMER_MSI_ROUTE_OFFSET + TimerIndex * HPET_TIMER_STRIDE))); DEBUG ((DEBUG_INFO, " HPET_TIMER%d_MSI_ROUTE = 0x%016lx\n", TimerIndex, HpetRead (HPET_TIMER_MSI_ROUTE_OFFSET + TimerIndex * HPET_TIMER_STRIDE)));
} }
DEBUG_CODE_END (); DEBUG_CODE_END ();
// //
@ -857,7 +864,7 @@ TimerDriverInitialize (
} }
} }
if (FeaturePcdGet (PcdHpetMsiEnable) && MsiTimerIndex != HPET_INVALID_TIMER_INDEX) { if (FeaturePcdGet (PcdHpetMsiEnable) && (MsiTimerIndex != HPET_INVALID_TIMER_INDEX)) {
// //
// Use MSI interrupt if supported // Use MSI interrupt if supported
// //
@ -959,12 +966,13 @@ TimerDriverInitialize (
// Show state of enabled HPET timer // Show state of enabled HPET timer
// //
DEBUG_CODE_BEGIN (); DEBUG_CODE_BEGIN ();
if (mTimerConfiguration.Bits.MsiInterruptCapability != 0 && FeaturePcdGet (PcdHpetMsiEnable)) { if ((mTimerConfiguration.Bits.MsiInterruptCapability != 0) && FeaturePcdGet (PcdHpetMsiEnable)) {
DEBUG ((DEBUG_INFO, "HPET Interrupt Mode MSI\n")); DEBUG ((DEBUG_INFO, "HPET Interrupt Mode MSI\n"));
} else { } else {
DEBUG ((DEBUG_INFO, "HPET Interrupt Mode I/O APIC\n")); DEBUG ((DEBUG_INFO, "HPET Interrupt Mode I/O APIC\n"));
DEBUG ((DEBUG_INFO, "HPET I/O APIC IRQ = 0x%02x\n", mTimerIrq)); DEBUG ((DEBUG_INFO, "HPET I/O APIC IRQ = 0x%02x\n", mTimerIrq));
} }
DEBUG ((DEBUG_INFO, "HPET Interrupt Vector = 0x%02x\n", PcdGet8 (PcdHpetLocalApicVector))); DEBUG ((DEBUG_INFO, "HPET Interrupt Vector = 0x%02x\n", PcdGet8 (PcdHpetLocalApicVector)));
DEBUG ((DEBUG_INFO, "HPET Counter Mask = 0x%016lx\n", mCounterMask)); DEBUG ((DEBUG_INFO, "HPET Counter Mask = 0x%016lx\n", mCounterMask));
DEBUG ((DEBUG_INFO, "HPET Timer Period = %d\n", mTimerPeriod)); DEBUG ((DEBUG_INFO, "HPET Timer Period = %d\n", mTimerPeriod));
@ -976,7 +984,9 @@ TimerDriverInitialize (
// //
// Wait for a few timer interrupts to fire before continuing // Wait for a few timer interrupts to fire before continuing
// //
while (mNumTicks < 10); while (mNumTicks < 10) {
}
DEBUG_CODE_END (); DEBUG_CODE_END ();
// //
@ -984,7 +994,8 @@ TimerDriverInitialize (
// //
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&mTimerHandle, &mTimerHandle,
&gEfiTimerArchProtocolGuid, &mTimer, &gEfiTimerArchProtocolGuid,
&mTimer,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);

View File

@ -8,6 +8,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef __IO_APIC_LIB_H__ #ifndef __IO_APIC_LIB_H__
#define __IO_APIC_LIB_H__ #define __IO_APIC_LIB_H__
@ -96,4 +97,5 @@ IoApicConfigureInterrupt (
IN BOOLEAN LevelTriggered, IN BOOLEAN LevelTriggered,
IN BOOLEAN AssertionLevel IN BOOLEAN AssertionLevel
); );
#endif #endif

View File

@ -15,7 +15,9 @@
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <IndustryStandard/Acpi.h> #include <IndustryStandard/Acpi.h>
GUID mFrequencyHobGuid = { 0x3fca54f6, 0xe1a2, 0x4b20, { 0xbe, 0x76, 0x92, 0x6b, 0x4b, 0x48, 0xbf, 0xaa }}; GUID mFrequencyHobGuid = {
0x3fca54f6, 0xe1a2, 0x4b20, { 0xbe, 0x76, 0x92, 0x6b, 0x4b, 0x48, 0xbf, 0xaa }
};
/** /**
Internal function to retrieves the 64-bit frequency in Hz. Internal function to retrieves the 64-bit frequency in Hz.
@ -122,12 +124,14 @@ InternalAcpiGetAcpiTimerIoPort (
// value other than PcdAcpiIoPortBaseAddress // value other than PcdAcpiIoPortBaseAddress
// //
if (PcdGet16 (PcdAcpiIoPciBarRegisterOffset) != 0x0000) { if (PcdGet16 (PcdAcpiIoPciBarRegisterOffset) != 0x0000) {
Port = PciRead16 (PCI_LIB_ADDRESS ( Port = PciRead16 (
PCI_LIB_ADDRESS (
PcdGet8 (PcdAcpiIoPciBusNumber), PcdGet8 (PcdAcpiIoPciBusNumber),
PcdGet8 (PcdAcpiIoPciDeviceNumber), PcdGet8 (PcdAcpiIoPciDeviceNumber),
PcdGet8 (PcdAcpiIoPciFunctionNumber), PcdGet8 (PcdAcpiIoPciFunctionNumber),
PcdGet16 (PcdAcpiIoPciBarRegisterOffset) PcdGet16 (PcdAcpiIoPciBarRegisterOffset)
)); )
);
} }
return (Port & PcdGet16 (PcdAcpiIoPortBaseAddressMask)) + PcdGet16 (PcdAcpiPm1TmrOffset); return (Port & PcdGet16 (PcdAcpiIoPortBaseAddressMask)) + PcdGet16 (PcdAcpiPm1TmrOffset);
@ -285,6 +289,7 @@ GetPerformanceCounterProperties (
if (EndValue != NULL) { if (EndValue != NULL) {
*EndValue = 0xffffffffffffffffULL; *EndValue = 0xffffffffffffffffULL;
} }
return InternalGetPerformanceCounterFrequency (); return InternalGetPerformanceCounterFrequency ();
} }
@ -379,6 +384,7 @@ InternalCalculateTscFrequency (
while (((Ticks - IoBitFieldRead32 (TimerAddr, 0, 23)) & BIT23) == 0) { while (((Ticks - IoBitFieldRead32 (TimerAddr, 0, 23)) & BIT23) == 0) {
CpuPause (); CpuPause ();
} }
EndTSC = AsmReadTsc (); // TSC value 101.4 us later EndTSC = AsmReadTsc (); // TSC value 101.4 us later
TscFrequency = MultU64x32 ( TscFrequency = MultU64x32 (

View File

@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_ #ifndef _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_
#define _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_ #define _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_

View File

@ -64,7 +64,6 @@ ResetShutdown (
ASSERT (FALSE); ASSERT (FALSE);
} }
/** /**
This function causes a systemwide reset. The exact type of the reset is This function causes a systemwide reset. The exact type of the reset is
defined by the EFI_GUID that follows the Null-terminated Unicode string passed defined by the EFI_GUID that follows the Null-terminated Unicode string passed

View File

@ -144,13 +144,13 @@ SerialPortWrite (
do { do {
Data = IoRead8 ((UINT16)gUartBase + LSR_OFFSET); Data = IoRead8 ((UINT16)gUartBase + LSR_OFFSET);
} while ((Data & LSR_TXRDY) == 0); } while ((Data & LSR_TXRDY) == 0);
IoWrite8 ((UINT16)gUartBase, *Buffer++); IoWrite8 ((UINT16)gUartBase, *Buffer++);
} }
return Result; return Result;
} }
/** /**
Reads data from a serial device into a buffer. Reads data from a serial device into a buffer.
@ -480,4 +480,3 @@ SerialPortSetAttributes (
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -216,6 +216,7 @@ PcRtcInit (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiAcquireLock (&Global->RtcLock); EfiAcquireLock (&Global->RtcLock);
} }
// //
// Initialize RTC Register // Initialize RTC Register
// //
@ -254,8 +255,10 @@ PcRtcInit (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Get the Time/Date/Daylight Savings values. // Get the Time/Date/Daylight Savings values.
// //
@ -307,6 +310,7 @@ PcRtcInit (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (&Time); Status = RtcTimeFieldsValid (&Time);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
// Report Status Code to indicate that the RTC has bad date and time // Report Status Code to indicate that the RTC has bad date and time
@ -356,7 +360,7 @@ PcRtcInit (
Time.Year = PcdGet16 (PcdMinimalValidYear); Time.Year = PcdGet16 (PcdMinimalValidYear);
Time.Nanosecond = 0; Time.Nanosecond = 0;
Time.TimeZone = Global->SavedTimeZone; Time.TimeZone = Global->SavedTimeZone;
Time.Daylight = Global->Daylight;; Time.Daylight = Global->Daylight;
// //
// Acquire RTC Lock to make access to RTC atomic // Acquire RTC Lock to make access to RTC atomic
@ -364,6 +368,7 @@ PcRtcInit (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiAcquireLock (&Global->RtcLock); EfiAcquireLock (&Global->RtcLock);
} }
// //
// Wait for up to 0.1 seconds for the RTC to be updated // Wait for up to 0.1 seconds for the RTC to be updated
// //
@ -372,6 +377,7 @@ PcRtcInit (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -391,6 +397,7 @@ PcRtcInit (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -419,6 +426,7 @@ PcRtcInit (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -451,14 +459,15 @@ PcRtcGetTime (
// //
if (Time == NULL) { if (Time == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Acquire RTC Lock to make access to RTC atomic // Acquire RTC Lock to make access to RTC atomic
// //
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiAcquireLock (&Global->RtcLock); EfiAcquireLock (&Global->RtcLock);
} }
// //
// Wait for up to 0.1 seconds for the RTC to be updated // Wait for up to 0.1 seconds for the RTC to be updated
// //
@ -467,8 +476,10 @@ PcRtcGetTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return Status; return Status;
} }
// //
// Read Register B // Read Register B
// //
@ -504,6 +515,7 @@ PcRtcGetTime (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (Time); Status = RtcTimeFieldsValid (Time);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -551,6 +563,7 @@ PcRtcSetTime (
if (Time == NULL) { if (Time == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Make sure that the time fields are valid // Make sure that the time fields are valid
// //
@ -567,6 +580,7 @@ PcRtcSetTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiAcquireLock (&Global->RtcLock); EfiAcquireLock (&Global->RtcLock);
} }
// //
// Wait for up to 0.1 seconds for the RTC to be updated // Wait for up to 0.1 seconds for the RTC to be updated
// //
@ -575,6 +589,7 @@ PcRtcSetTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return Status; return Status;
} }
@ -608,6 +623,7 @@ PcRtcSetTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -646,6 +662,7 @@ PcRtcSetTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
// //
// Set the variable that contains the TimeZone and Daylight fields // Set the variable that contains the TimeZone and Daylight fields
// //
@ -690,14 +707,15 @@ PcRtcGetWakeupTime (
// //
if ((Enabled == NULL) || (Pending == NULL) || (Time == NULL)) { if ((Enabled == NULL) || (Pending == NULL) || (Time == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Acquire RTC Lock to make access to RTC atomic // Acquire RTC Lock to make access to RTC atomic
// //
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiAcquireLock (&Global->RtcLock); EfiAcquireLock (&Global->RtcLock);
} }
// //
// Wait for up to 0.1 seconds for the RTC to be updated // Wait for up to 0.1 seconds for the RTC to be updated
// //
@ -706,8 +724,10 @@ PcRtcGetWakeupTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Read Register B and Register C // Read Register B and Register C
// //
@ -763,6 +783,7 @@ PcRtcGetWakeupTime (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (Time); Status = RtcTimeFieldsValid (Time);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -800,10 +821,10 @@ PcRtcSetWakeupTime (
ZeroMem (&RtcTime, sizeof (RtcTime)); ZeroMem (&RtcTime, sizeof (RtcTime));
if (Enable) { if (Enable) {
if (Time == NULL) { if (Time == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Make sure that the time fields are valid // Make sure that the time fields are valid
// //
@ -811,6 +832,7 @@ PcRtcSetWakeupTime (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Just support set alarm time within 24 hours // Just support set alarm time within 24 hours
// //
@ -819,21 +841,24 @@ PcRtcSetWakeupTime (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
if (!IsWithinOneDay (&RtcTime, Time)) { if (!IsWithinOneDay (&RtcTime, Time)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Make a local copy of the time and date // Make a local copy of the time and date
// //
CopyMem (&RtcTime, Time, sizeof (EFI_TIME)); CopyMem (&RtcTime, Time, sizeof (EFI_TIME));
} }
// //
// Acquire RTC Lock to make access to RTC atomic // Acquire RTC Lock to make access to RTC atomic
// //
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiAcquireLock (&Global->RtcLock); EfiAcquireLock (&Global->RtcLock);
} }
// //
// Wait for up to 0.1 seconds for the RTC to be updated // Wait for up to 0.1 seconds for the RTC to be updated
// //
@ -842,8 +867,10 @@ PcRtcSetWakeupTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Read Register B // Read Register B
// //
@ -879,6 +906,7 @@ PcRtcSetWakeupTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -897,10 +925,10 @@ PcRtcSetWakeupTime (
RtcWrite (RTC_ADDRESS_HOURS_ALARM, RtcTime.Hour); RtcWrite (RTC_ADDRESS_HOURS_ALARM, RtcTime.Hour);
RegisterB.Bits.Aie = 1; RegisterB.Bits.Aie = 1;
} else { } else {
RegisterB.Bits.Aie = 0; RegisterB.Bits.Aie = 0;
} }
// //
// Allow updates of the RTC registers // Allow updates of the RTC registers
// //
@ -913,10 +941,10 @@ PcRtcSetWakeupTime (
if (!EfiAtRuntime ()) { if (!EfiAtRuntime ()) {
EfiReleaseLock (&Global->RtcLock); EfiReleaseLock (&Global->RtcLock);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Checks an 8-bit BCD value, and converts to an 8-bit value if valid. Checks an 8-bit BCD value, and converts to an 8-bit value if valid.
@ -984,8 +1012,9 @@ ConvertRtcTimeToEfiTime (
Time->Second = CheckAndConvertBcd8ToDecimal8 (Time->Second); Time->Second = CheckAndConvertBcd8ToDecimal8 (Time->Second);
} }
if (Time->Year == 0xff || Time->Month == 0xff || Time->Day == 0xff || if ((Time->Year == 0xff) || (Time->Month == 0xff) || (Time->Day == 0xff) ||
Time->Hour == 0xff || Time->Minute == 0xff || Time->Second == 0xff) { (Time->Hour == 0xff) || (Time->Minute == 0xff) || (Time->Second == 0xff))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -998,17 +1027,18 @@ ConvertRtcTimeToEfiTime (
if (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) { if (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) {
Century++; 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 time is in 12 hour format, convert it to 24 hour format
// //
if (RegisterB.Bits.Mil == 0) { if (RegisterB.Bits.Mil == 0) {
if (IsPM && Time->Hour < 12) { if (IsPM && (Time->Hour < 12)) {
Time->Hour = (UINT8)(Time->Hour + 12); Time->Hour = (UINT8)(Time->Hour + 12);
} }
if (!IsPM && Time->Hour == 12) { if (!IsPM && (Time->Hour == 12)) {
Time->Hour = 0; Time->Hour = 0;
} }
} }
@ -1042,6 +1072,7 @@ RtcWaitToUpdate (
if (RegisterD.Bits.Vrt == 0) { if (RegisterD.Bits.Vrt == 0) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Wait for up to 0.1 seconds for the RTC to be ready. // Wait for up to 0.1 seconds for the RTC to be ready.
// //
@ -1054,7 +1085,7 @@ RtcWaitToUpdate (
} }
RegisterD.Data = RtcRead (RTC_ADDRESS_REGISTER_D); 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; return EFI_DEVICE_ERROR;
} }
@ -1075,17 +1106,18 @@ RtcTimeFieldsValid (
IN EFI_TIME *Time IN EFI_TIME *Time
) )
{ {
if (Time->Year < PcdGet16 (PcdMinimalValidYear) || if ((Time->Year < PcdGet16 (PcdMinimalValidYear)) ||
Time->Year > PcdGet16 (PcdMaximalValidYear) || (Time->Year > PcdGet16 (PcdMaximalValidYear)) ||
Time->Month < 1 || (Time->Month < 1) ||
Time->Month > 12 || (Time->Month > 12) ||
(!DayValid (Time)) || (!DayValid (Time)) ||
Time->Hour > 23 || (Time->Hour > 23) ||
Time->Minute > 59 || (Time->Minute > 59) ||
Time->Second > 59 || (Time->Second > 59) ||
Time->Nanosecond > 999999999 || (Time->Nanosecond > 999999999) ||
(!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) || (!((Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE) || ((Time->TimeZone >= -1440) && (Time->TimeZone <= 1440)))) ||
((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0)) { ((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1110,10 +1142,11 @@ DayValid (
// //
ASSERT (Time->Month >= 1); ASSERT (Time->Month >= 1);
ASSERT (Time->Month <= 12); ASSERT (Time->Month <= 12);
if (Time->Day < 1 || if ((Time->Day < 1) ||
Time->Day > mDayOfMonth[Time->Month - 1] || (Time->Day > mDayOfMonth[Time->Month - 1]) ||
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28)) ((Time->Month == 2) && (!IsLeapYear (Time) && (Time->Day > 28)))
) { )
{
return FALSE; return FALSE;
} }
@ -1182,6 +1215,7 @@ ConvertEfiTimeToRtcTime (
Time->Hour = 12; Time->Hour = 12;
} }
} }
// //
// Set the Time/Date values. // Set the Time/Date values.
// //
@ -1195,10 +1229,11 @@ ConvertEfiTimeToRtcTime (
Time->Minute = DecimalToBcd8 (Time->Minute); Time->Minute = DecimalToBcd8 (Time->Minute);
Time->Second = DecimalToBcd8 (Time->Second); 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 we are in 12 hour mode and PM is set, then set bit 7 of the Hour field.
// //
if (RegisterB.Bits.Mil == 0 && IsPM) { if ((RegisterB.Bits.Mil == 0) && IsPM) {
Time->Hour = (UINT8)(Time->Hour | 0x80); Time->Hour = (UINT8)(Time->Hour | 0x80);
} }
} }
@ -1223,7 +1258,8 @@ CompareHMS (
{ {
if ((From->Hour > To->Hour) || if ((From->Hour > To->Hour) ||
((From->Hour == To->Hour) && (From->Minute > To->Minute)) || ((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->Second > To->Second)))
{
return 1; return 1;
} else if ((From->Hour == To->Hour) && (From->Minute == To->Minute) && (From->Second == To->Second)) { } else if ((From->Hour == To->Hour) && (From->Minute == To->Minute) && (From->Second == To->Second)) {
return 0; return 0;
@ -1285,7 +1321,8 @@ IsWithinOneDay (
(From->Month == 12) && (From->Month == 12) &&
(From->Day == 31) && (From->Day == 31) &&
(To->Month == 1) && (To->Month == 1) &&
(To->Day == 1)) { (To->Day == 1))
{
if ((CompareHMS (From, To) >= 0)) { if ((CompareHMS (From, To) >= 0)) {
Adjacent = TRUE; Adjacent = TRUE;
} }
@ -1312,7 +1349,8 @@ GetCenturyRtcAddress (
if ((Fadt != NULL) && if ((Fadt != NULL) &&
(Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80) (Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80)
) { )
{
return Fadt->Century; return Fadt->Century;
} else { } else {
return 0; return 0;

View File

@ -8,11 +8,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _RTC_H_ #ifndef _RTC_H_
#define _RTC_H_ #define _RTC_H_
#include <Uefi.h> #include <Uefi.h>
#include <Guid/Acpi.h> #include <Guid/Acpi.h>
@ -282,7 +280,6 @@ ConvertEfiTimeToRtcTime (
IN RTC_REGISTER_B RegisterB IN RTC_REGISTER_B RegisterB
); );
/** /**
Converts time read from RTC to EFI_TIME format defined by UEFI spec. Converts time read from RTC to EFI_TIME format defined by UEFI spec.
@ -371,4 +368,5 @@ PcRtcAcpiTableChangeCallback (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN VOID *Context IN VOID *Context
); );
#endif #endif

View File

@ -87,7 +87,6 @@ PcRtcEfiGetWakeupTime (
return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal); return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);
} }
/** /**
Sets the system wakeup alarm clock time. Sets the system wakeup alarm clock time.