RealTimeClockLib.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /** @file
  2. Implement EFI RealTimeClock runtime services via RTC Lib.
  3. Currently this driver does not support runtime virtual calling.
  4. Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <PiDxe.h>
  8. #include <Library/BaseLib.h>
  9. #include <Library/DebugLib.h>
  10. #include <Library/IoLib.h>
  11. #include <Library/RealTimeClockLib.h>
  12. /**
  13. Returns the current time and date information, and the time-keeping capabilities
  14. of the hardware platform.
  15. @param Time A pointer to storage to receive a snapshot of the current time.
  16. @param Capabilities An optional pointer to a buffer to receive the real time clock
  17. device's capabilities.
  18. @retval EFI_SUCCESS The operation completed successfully.
  19. @retval EFI_INVALID_PARAMETER Time is NULL.
  20. @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
  21. **/
  22. EFI_STATUS
  23. EFIAPI
  24. LibGetTime (
  25. OUT EFI_TIME *Time,
  26. OUT EFI_TIME_CAPABILITIES *Capabilities
  27. )
  28. {
  29. //
  30. // Fill in Time and Capabilities via data from you RTC
  31. //
  32. return EFI_DEVICE_ERROR;
  33. }
  34. /**
  35. Sets the current local time and date information.
  36. @param Time A pointer to the current time.
  37. @retval EFI_SUCCESS The operation completed successfully.
  38. @retval EFI_INVALID_PARAMETER A time field is out of range.
  39. @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
  40. **/
  41. EFI_STATUS
  42. EFIAPI
  43. LibSetTime (
  44. IN EFI_TIME *Time
  45. )
  46. {
  47. //
  48. // Use Time, to set the time in your RTC hardware
  49. //
  50. return EFI_DEVICE_ERROR;
  51. }
  52. /**
  53. Returns the current wakeup alarm clock setting.
  54. @param Enabled Indicates if the alarm is currently enabled or disabled.
  55. @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
  56. @param Time The current alarm setting.
  57. @retval EFI_SUCCESS The alarm settings were returned.
  58. @retval EFI_INVALID_PARAMETER Any parameter is NULL.
  59. @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
  60. **/
  61. EFI_STATUS
  62. EFIAPI
  63. LibGetWakeupTime (
  64. OUT BOOLEAN *Enabled,
  65. OUT BOOLEAN *Pending,
  66. OUT EFI_TIME *Time
  67. )
  68. {
  69. // Not a required feature
  70. return EFI_UNSUPPORTED;
  71. }
  72. /**
  73. Sets the system wakeup alarm clock time.
  74. @param Enabled Enable or disable the wakeup alarm.
  75. @param Time If Enable is TRUE, the time to set the wakeup alarm for.
  76. @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
  77. Enable is FALSE, then the wakeup alarm was disabled.
  78. @retval EFI_INVALID_PARAMETER A time field is out of range.
  79. @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
  80. @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
  81. **/
  82. EFI_STATUS
  83. EFIAPI
  84. LibSetWakeupTime (
  85. IN BOOLEAN Enabled,
  86. OUT EFI_TIME *Time
  87. )
  88. {
  89. // Not a required feature
  90. return EFI_UNSUPPORTED;
  91. }
  92. /**
  93. This is the declaration of an EFI image entry point. This can be the entry point to an application
  94. written to this specification, an EFI boot service driver, or an EFI runtime driver.
  95. @param ImageHandle Handle that identifies the loaded image.
  96. @param SystemTable System Table for this image.
  97. @retval EFI_SUCCESS The operation completed successfully.
  98. **/
  99. EFI_STATUS
  100. EFIAPI
  101. LibRtcInitialize (
  102. IN EFI_HANDLE ImageHandle,
  103. IN EFI_SYSTEM_TABLE *SystemTable
  104. )
  105. {
  106. //
  107. // Do some initialization if required to turn on the RTC
  108. //
  109. return EFI_SUCCESS;
  110. }
  111. /**
  112. Fixup internal data so that EFI can be call in virtual mode.
  113. Call the passed in Child Notify event and convert any pointers in
  114. lib to virtual mode.
  115. @param[in] Event The Event that is being processed
  116. @param[in] Context Event Context
  117. **/
  118. VOID
  119. EFIAPI
  120. LibRtcVirtualNotifyEvent (
  121. IN EFI_EVENT Event,
  122. IN VOID *Context
  123. )
  124. {
  125. //
  126. // Only needed if you are going to support the OS calling RTC functions in virtual mode.
  127. // You will need to call EfiConvertPointer (). To convert any stored physical addresses
  128. // to virtual address. After the OS transitions to calling in virtual mode, all future
  129. // runtime calls will be made in virtual mode.
  130. //
  131. return;
  132. }