X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=PcAtChipsetPkg%2FPcatRealTimeClockRuntimeDxe%2FPcRtc.h;h=47293ce44c5a1f4792892892f7da40d7f0a5a001;hp=d38c8e1464a4e88c644f57a19e99b87347b24c95;hb=HEAD;hpb=24115e44926b33c763f81026690f20efd913daf2 diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h index d38c8e1464..7e0e98fbcc 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h @@ -1,24 +1,20 @@ /** @file Header file for real time clock driver. -Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
-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 -http://opensource.org/licenses/bsd-license.php +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Inc. All rights reserved.
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +SPDX-License-Identifier: BSD-2-Clause-Patent **/ - #ifndef _RTC_H_ #define _RTC_H_ - #include +#include + #include #include @@ -32,16 +28,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include - +#include typedef struct { - EFI_LOCK RtcLock; - INT16 SavedTimeZone; - UINT8 Daylight; + EFI_LOCK RtcLock; + INT16 SavedTimeZone; + UINT8 Daylight; + UINT8 CenturyRtcAddress; } PC_RTC_MODULE_GLOBALS; -#define PCAT_RTC_ADDRESS_REGISTER 0x70 -#define PCAT_RTC_DATA_REGISTER 0x71 +extern PC_RTC_MODULE_GLOBALS mModuleGlobal; // // Dallas DS12C887 Real Time Clock @@ -60,86 +56,77 @@ typedef struct { #define RTC_ADDRESS_REGISTER_B 11 // R/W #define RTC_ADDRESS_REGISTER_C 12 // RO #define RTC_ADDRESS_REGISTER_D 13 // RO -#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W // // 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 +#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; // Iterrupt 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() @@ -191,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 ); /** @@ -214,7 +201,7 @@ PcRtcGetTime ( EFI_STATUS PcRtcSetWakeupTime ( IN BOOLEAN Enable, - IN EFI_TIME *Time, OPTIONAL + IN EFI_TIME *Time OPTIONAL, IN PC_RTC_MODULE_GLOBALS *Global ); @@ -236,16 +223,16 @@ 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 ); /** The user Entry Point for PcRTC module. - This is the entrhy point for PcRTC module. It installs the UEFI runtime service + This is the entry 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. @@ -258,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 ); /** @@ -273,30 +260,26 @@ InitializePcRtc ( **/ EFI_STATUS RtcTimeFieldsValid ( - IN EFI_TIME *Time + IN EFI_TIME *Time ); /** - Converts time from EFI_TIME format defined by UEFI spec to RTC's. + 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's. + 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. @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. - **/ VOID ConvertEfiTimeToRtcTime ( IN OUT EFI_TIME *Time, - IN RTC_REGISTER_B RegisterB, - OUT UINT8 *Century + IN RTC_REGISTER_B RegisterB ); - /** Converts time read from RTC to EFI_TIME format defined by UEFI spec. @@ -307,7 +290,6 @@ ConvertEfiTimeToRtcTime ( @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. @@ -318,7 +300,6 @@ ConvertEfiTimeToRtcTime ( EFI_STATUS ConvertRtcTimeToEfiTime ( IN OUT EFI_TIME *Time, - IN UINT8 Century, IN RTC_REGISTER_B RegisterB ); @@ -328,11 +309,11 @@ ConvertRtcTimeToEfiTime ( @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. + @retval EFI_SUCCESS RTC is updated and ready. **/ EFI_STATUS RtcWaitToUpdate ( - UINTN Timeout + UINTN Timeout ); /** @@ -358,7 +339,34 @@ DayValid ( **/ BOOLEAN IsLeapYear ( - IN EFI_TIME *Time + IN EFI_TIME *Time + ); + +/** + Get the century RTC address from the ACPI FADT table. + + @return The century RTC address or 0 if not found. +**/ +UINT8 +GetCenturyRtcAddress ( + VOID + ); + +/** + 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. + + @param Event Event whose notification function is being invoked. + @param Context Pointer to the notification function's context. + +**/ +VOID +EFIAPI +PcRtcAcpiTableChangeCallback ( + IN EFI_EVENT Event, + IN VOID *Context ); #endif