]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / PcAtChipsetPkg / PcatRealTimeClockRuntimeDxe / PcRtc.h
index 85492f7b5972a861cebeca9c78f025dac5dd4042..7e0e98fbcc188ed5d0f1d2d2268c0beadd2b7605 100644 (file)
@@ -1,24 +1,20 @@
 /** @file\r
   Header file for real time clock driver.\r
 \r
-Copyright (c) 2006 - 2007, 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
-http://opensource.org/licenses/bsd-license.php\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2017, AMD Inc. All rights reserved.<BR>\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-\r
 #ifndef _RTC_H_\r
 #define _RTC_H_\r
 \r
-\r
 #include <Uefi.h>\r
 \r
+#include <Guid/Acpi.h>\r
+\r
 #include <Protocol/RealTimeClock.h>\r
 \r
 #include <Library/BaseLib.h>\r
@@ -32,16 +28,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
+  EFI_LOCK    RtcLock;\r
+  INT16       SavedTimeZone;\r
+  UINT8       Daylight;\r
+  UINT8       CenturyRtcAddress;\r
 } PC_RTC_MODULE_GLOBALS;\r
 \r
-#define PCAT_RTC_ADDRESS_REGISTER 0x70\r
-#define PCAT_RTC_DATA_REGISTER    0x71\r
+extern PC_RTC_MODULE_GLOBALS  mModuleGlobal;\r
 \r
 //\r
 // Dallas DS12C887 Real Time Clock\r
@@ -60,86 +56,77 @@ typedef struct {
 #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
 //\r
-#define RTC_INIT_SECOND 0\r
-#define RTC_INIT_MINUTE 0\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
-//\r
-#define RTC_INIT_REGISTER_A 0x26\r
-#define RTC_INIT_REGISTER_B 0x02\r
-#define RTC_INIT_REGISTER_D 0x0\r
+#define RTC_INIT_SECOND  0\r
+#define RTC_INIT_MINUTE  0\r
+#define RTC_INIT_HOUR    0\r
+#define RTC_INIT_DAY     1\r
+#define RTC_INIT_MONTH   1\r
 \r
 #pragma pack(1)\r
 //\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
-  RTC_REGISTER_A_BITS Bits;\r
-  UINT8               Data;\r
+  RTC_REGISTER_A_BITS    Bits;\r
+  UINT8                  Data;\r
 } RTC_REGISTER_A;\r
 \r
 //\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
-  RTC_REGISTER_B_BITS Bits;\r
-  UINT8               Data;\r
+  RTC_REGISTER_B_BITS    Bits;\r
+  UINT8                  Data;\r
 } RTC_REGISTER_B;\r
 \r
 //\r
 // Register C\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    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; // Interrupt Request Flag = PF & PIE | AF & AIE | UF & UIE\r
 } RTC_REGISTER_C_BITS;\r
 \r
 typedef union {\r
-  RTC_REGISTER_C_BITS Bits;\r
-  UINT8               Data;\r
+  RTC_REGISTER_C_BITS    Bits;\r
+  UINT8                  Data;\r
 } RTC_REGISTER_C;\r
 \r
 //\r
 // Register D\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    Reserved : 7; // Read as zero.  Can not be written.\r
+  UINT8    Vrt      : 1; // Valid RAM and Time\r
 } RTC_REGISTER_D_BITS;\r
 \r
 typedef union {\r
-  RTC_REGISTER_D_BITS Bits;\r
-  UINT8               Data;\r
+  RTC_REGISTER_D_BITS    Bits;\r
+  UINT8                  Data;\r
 } RTC_REGISTER_D;\r
 \r
 #pragma pack()\r
@@ -191,9 +178,9 @@ PcRtcSetTime (
 **/\r
 EFI_STATUS\r
 PcRtcGetTime (\r
-  OUT EFI_TIME              *Time,\r
-  OUT EFI_TIME_CAPABILITIES *Capabilities, OPTIONAL\r
-  IN  PC_RTC_MODULE_GLOBALS *Global\r
+  OUT EFI_TIME               *Time,\r
+  OUT EFI_TIME_CAPABILITIES  *Capabilities  OPTIONAL,\r
+  IN  PC_RTC_MODULE_GLOBALS  *Global\r
   );\r
 \r
 /**\r
@@ -214,7 +201,7 @@ PcRtcGetTime (
 EFI_STATUS\r
 PcRtcSetWakeupTime (\r
   IN BOOLEAN                Enable,\r
-  IN EFI_TIME               *Time,  OPTIONAL\r
+  IN EFI_TIME               *Time   OPTIONAL,\r
   IN PC_RTC_MODULE_GLOBALS  *Global\r
   );\r
 \r
@@ -236,16 +223,16 @@ PcRtcSetWakeupTime (
 **/\r
 EFI_STATUS\r
 PcRtcGetWakeupTime (\r
-  OUT BOOLEAN               *Enabled,\r
-  OUT BOOLEAN               *Pending,\r
-  OUT EFI_TIME              *Time,\r
-  IN  PC_RTC_MODULE_GLOBALS *Global\r
+  OUT BOOLEAN                *Enabled,\r
+  OUT BOOLEAN                *Pending,\r
+  OUT EFI_TIME               *Time,\r
+  IN  PC_RTC_MODULE_GLOBALS  *Global\r
   );\r
 \r
 /**\r
   The user Entry Point for PcRTC module.\r
 \r
-  This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
+  This is the entry point for PcRTC module. It installs the UEFI runtime service\r
   including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
 \r
   @param  ImageHandle    The firmware allocated handle for the EFI image.\r
@@ -258,8 +245,8 @@ PcRtcGetWakeupTime (
 EFI_STATUS\r
 EFIAPI\r
 InitializePcRtc (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
   );\r
 \r
 /**\r
@@ -273,30 +260,26 @@ InitializePcRtc (
 **/\r
 EFI_STATUS\r
 RtcTimeFieldsValid (\r
-  IN EFI_TIME *Time\r
+  IN EFI_TIME  *Time\r
   );\r
 \r
 /**\r
-  Converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
+  Converts time from EFI_TIME format defined by UEFI spec to RTC format.\r
 \r
-  This function converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
+  This function converts time from EFI_TIME format defined by UEFI spec to RTC format.\r
   If data mode of RTC is BCD, then converts EFI_TIME to it.\r
   If RTC is in 12-hour format, then converts EFI_TIME to it.\r
 \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
   Converts time read from RTC to EFI_TIME format defined by UEFI spec.\r
 \r
@@ -307,7 +290,6 @@ ConvertEfiTimeToRtcTime (
 \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
@@ -318,7 +300,6 @@ ConvertEfiTimeToRtcTime (
 EFI_STATUS\r
 ConvertRtcTimeToEfiTime (\r
   IN OUT EFI_TIME        *Time,\r
-  IN     UINT8           Century,\r
   IN     RTC_REGISTER_B  RegisterB\r
   );\r
 \r
@@ -328,11 +309,11 @@ ConvertRtcTimeToEfiTime (
   @param    Timeout  Tell how long it should take to wait.\r
 \r
   @retval   EFI_DEVICE_ERROR   RTC device error.\r
-  @retval   EFI_SUCCESS        RTC is updated and ready.  \r
+  @retval   EFI_SUCCESS        RTC is updated and ready.\r
 **/\r
 EFI_STATUS\r
 RtcWaitToUpdate (\r
-  UINTN Timeout\r
+  UINTN  Timeout\r
   );\r
 \r
 /**\r
@@ -358,7 +339,34 @@ DayValid (
 **/\r
 BOOLEAN\r
 IsLeapYear (\r
-  IN EFI_TIME   *Time\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
 \r
 #endif\r