/** @file\r
Header file for real time clock driver.\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
#include <Uefi.h>\r
\r
+#include <Guid/Acpi.h>\r
+\r
#include <Protocol/RealTimeClock.h>\r
\r
#include <Library/BaseLib.h>\r
#include <Library/UefiRuntimeLib.h>\r
#include <Library/UefiRuntimeServicesTableLib.h>\r
#include <Library/PcdLib.h>\r
-\r
+#include <Library/ReportStatusCodeLib.h>\r
\r
typedef struct {\r
EFI_LOCK RtcLock;\r
INT16 SavedTimeZone;\r
UINT8 Daylight;\r
+ UINT8 CenturyRtcAddress;\r
} PC_RTC_MODULE_GLOBALS;\r
\r
+extern PC_RTC_MODULE_GLOBALS mModuleGlobal;\r
+\r
#define PCAT_RTC_ADDRESS_REGISTER 0x70\r
#define PCAT_RTC_DATA_REGISTER 0x71\r
\r
#define RTC_ADDRESS_REGISTER_B 11 // R/W\r
#define RTC_ADDRESS_REGISTER_C 12 // RO\r
#define RTC_ADDRESS_REGISTER_D 13 // RO\r
-#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W\r
//\r
// Date and time initial values.\r
// They are used if the RTC values are invalid during driver initialization\r
#define RTC_INIT_HOUR 0\r
#define RTC_INIT_DAY 1\r
#define RTC_INIT_MONTH 1\r
-#define RTC_INIT_YEAR 2001\r
\r
//\r
// Register initial values\r
// Register A\r
//\r
typedef struct {\r
- UINT8 RS : 4; // Rate Selection Bits\r
- UINT8 DV : 3; // Divisor\r
- UINT8 UIP : 1; // Update in progress\r
+ UINT8 Rs : 4; // Rate Selection Bits\r
+ UINT8 Dv : 3; // Divisor\r
+ UINT8 Uip : 1; // Update in progress\r
} RTC_REGISTER_A_BITS;\r
\r
typedef union {\r
// Register B\r
//\r
typedef struct {\r
- UINT8 DSE : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled\r
- UINT8 MIL : 1; // 0 - 12 hour mode 1 - 24 hour mode\r
- UINT8 DM : 1; // 0 - BCD Format 1 - Binary Format\r
- UINT8 SQWE : 1; // 0 - Disable SQWE output 1 - Enable SQWE output\r
- UINT8 UIE : 1; // 0 - Update INT disabled 1 - Update INT enabled\r
- UINT8 AIE : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled\r
- UINT8 PIE : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled\r
- UINT8 SET : 1; // 0 - Normal operation. 1 - Updates inhibited\r
+ UINT8 Dse : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled\r
+ UINT8 Mil : 1; // 0 - 12 hour mode 1 - 24 hour mode\r
+ UINT8 Dm : 1; // 0 - BCD Format 1 - Binary Format\r
+ UINT8 Sqwe : 1; // 0 - Disable SQWE output 1 - Enable SQWE output\r
+ UINT8 Uie : 1; // 0 - Update INT disabled 1 - Update INT enabled\r
+ UINT8 Aie : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled\r
+ UINT8 Pie : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled\r
+ UINT8 Set : 1; // 0 - Normal operation. 1 - Updates inhibited\r
} RTC_REGISTER_B_BITS;\r
\r
typedef union {\r
//\r
typedef struct {\r
UINT8 Reserved : 4; // Read as zero. Can not be written.\r
- UINT8 UF : 1; // Update End Interrupt Flag\r
- UINT8 AF : 1; // Alarm Interrupt Flag\r
- UINT8 PF : 1; // Periodic Interrupt Flag\r
- UINT8 IRQF : 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE\r
+ UINT8 Uf : 1; // Update End Interrupt Flag\r
+ UINT8 Af : 1; // Alarm Interrupt Flag\r
+ UINT8 Pf : 1; // Periodic Interrupt Flag\r
+ UINT8 Irqf : 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE\r
} RTC_REGISTER_C_BITS;\r
\r
typedef union {\r
//\r
typedef struct {\r
UINT8 Reserved : 7; // Read as zero. Can not be written.\r
- UINT8 VRT : 1; // Valid RAM and Time\r
+ UINT8 Vrt : 1; // Valid RAM and Time\r
} RTC_REGISTER_D_BITS;\r
\r
typedef union {\r
@param Time On input, the time data read from UEFI to convert\r
On output, the time converted to RTC format\r
@param RegisterB Value of Register B of RTC, indicating data mode\r
- @param Century It is set according to EFI_TIME Time.\r
-\r
**/\r
VOID\r
ConvertEfiTimeToRtcTime (\r
IN OUT EFI_TIME *Time,\r
- IN RTC_REGISTER_B RegisterB,\r
- OUT UINT8 *Century\r
+ IN RTC_REGISTER_B RegisterB\r
);\r
\r
\r
\r
@param Time On input, the time data read from RTC to convert\r
On output, the time converted to UEFI format\r
- @param Century Value of century read from RTC.\r
@param RegisterB Value of Register B of RTC, indicating data mode\r
and hour format.\r
\r
EFI_STATUS\r
ConvertRtcTimeToEfiTime (\r
IN OUT EFI_TIME *Time,\r
- IN UINT8 Century,\r
IN RTC_REGISTER_B RegisterB\r
);\r
\r
IN EFI_TIME *Time\r
);\r
\r
+/**\r
+ Get the century RTC address from the ACPI FADT table.\r
+\r
+ @return The century RTC address or 0 if not found.\r
+**/\r
+UINT8\r
+GetCenturyRtcAddress (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Notification function of ACPI Table change.\r
+\r
+ This is a notification function registered on ACPI Table change event.\r
+ It saves the Century address stored in ACPI FADT table.\r
+\r
+ @param Event Event whose notification function is being invoked.\r
+ @param Context Pointer to the notification function's context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PcRtcAcpiTableChangeCallback (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ );\r
#endif\r