Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame] | 1 | /** @file
|
| 2 | Implement EFI RealTimeClock runtime services via RTC Lib.
|
| 3 |
|
| 4 | Currently this driver does not support runtime virtual calling.
|
| 5 |
|
| 6 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
| 7 |
|
| 8 | This program and the accompanying materials
|
| 9 | are licensed and made available under the terms and conditions of the BSD License
|
| 10 | which accompanies this distribution. The full text of the license may be found at
|
| 11 | http://opensource.org/licenses/bsd-license.php
|
| 12 |
|
| 13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
| 14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
| 15 |
|
| 16 | **/
|
| 17 |
|
| 18 | #include <PiDxe.h>
|
| 19 | #include <Library/BaseLib.h>
|
| 20 | #include <Library/DebugLib.h>
|
| 21 | #include <Library/IoLib.h>
|
| 22 | #include <Library/RealTimeClockLib.h>
|
| 23 |
|
| 24 |
|
| 25 | /**
|
| 26 | Returns the current time and date information, and the time-keeping capabilities
|
| 27 | of the hardware platform.
|
| 28 |
|
| 29 | @param Time A pointer to storage to receive a snapshot of the current time.
|
| 30 | @param Capabilities An optional pointer to a buffer to receive the real time clock
|
| 31 | device's capabilities.
|
| 32 |
|
| 33 | @retval EFI_SUCCESS The operation completed successfully.
|
| 34 | @retval EFI_INVALID_PARAMETER Time is NULL.
|
| 35 | @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
|
| 36 |
|
| 37 | **/
|
| 38 | EFI_STATUS
|
| 39 | EFIAPI
|
| 40 | LibGetTime (
|
| 41 | OUT EFI_TIME *Time,
|
| 42 | OUT EFI_TIME_CAPABILITIES *Capabilities
|
| 43 | )
|
| 44 | {
|
| 45 | //
|
| 46 | // Fill in Time and Capabilities via data from you RTC
|
| 47 | //
|
| 48 | return EFI_DEVICE_ERROR;
|
| 49 | }
|
| 50 |
|
| 51 |
|
| 52 | /**
|
| 53 | Sets the current local time and date information.
|
| 54 |
|
| 55 | @param Time A pointer to the current time.
|
| 56 |
|
| 57 | @retval EFI_SUCCESS The operation completed successfully.
|
| 58 | @retval EFI_INVALID_PARAMETER A time field is out of range.
|
| 59 | @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
|
| 60 |
|
| 61 | **/
|
| 62 | EFI_STATUS
|
| 63 | EFIAPI
|
| 64 | LibSetTime (
|
| 65 | IN EFI_TIME *Time
|
| 66 | )
|
| 67 | {
|
| 68 | //
|
| 69 | // Use Time, to set the time in your RTC hardware
|
| 70 | //
|
| 71 | return EFI_DEVICE_ERROR;
|
| 72 | }
|
| 73 |
|
| 74 |
|
| 75 | /**
|
| 76 | Returns the current wakeup alarm clock setting.
|
| 77 |
|
| 78 | @param Enabled Indicates if the alarm is currently enabled or disabled.
|
| 79 | @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
|
| 80 | @param Time The current alarm setting.
|
| 81 |
|
| 82 | @retval EFI_SUCCESS The alarm settings were returned.
|
| 83 | @retval EFI_INVALID_PARAMETER Any parameter is NULL.
|
| 84 | @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
|
| 85 |
|
| 86 | **/
|
| 87 | EFI_STATUS
|
| 88 | EFIAPI
|
| 89 | LibGetWakeupTime (
|
| 90 | OUT BOOLEAN *Enabled,
|
| 91 | OUT BOOLEAN *Pending,
|
| 92 | OUT EFI_TIME *Time
|
| 93 | )
|
| 94 | {
|
| 95 | // Not a required feature
|
| 96 | return EFI_UNSUPPORTED;
|
| 97 | }
|
| 98 |
|
| 99 |
|
| 100 | /**
|
| 101 | Sets the system wakeup alarm clock time.
|
| 102 |
|
| 103 | @param Enabled Enable or disable the wakeup alarm.
|
| 104 | @param Time If Enable is TRUE, the time to set the wakeup alarm for.
|
| 105 |
|
| 106 | @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
|
| 107 | Enable is FALSE, then the wakeup alarm was disabled.
|
| 108 | @retval EFI_INVALID_PARAMETER A time field is out of range.
|
| 109 | @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
|
| 110 | @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
|
| 111 |
|
| 112 | **/
|
| 113 | EFI_STATUS
|
| 114 | EFIAPI
|
| 115 | LibSetWakeupTime (
|
| 116 | IN BOOLEAN Enabled,
|
| 117 | OUT EFI_TIME *Time
|
| 118 | )
|
| 119 | {
|
| 120 | // Not a required feature
|
| 121 | return EFI_UNSUPPORTED;
|
| 122 | }
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 | /**
|
| 127 | This is the declaration of an EFI image entry point. This can be the entry point to an application
|
| 128 | written to this specification, an EFI boot service driver, or an EFI runtime driver.
|
| 129 |
|
| 130 | @param ImageHandle Handle that identifies the loaded image.
|
| 131 | @param SystemTable System Table for this image.
|
| 132 |
|
| 133 | @retval EFI_SUCCESS The operation completed successfully.
|
| 134 |
|
| 135 | **/
|
| 136 | EFI_STATUS
|
| 137 | EFIAPI
|
| 138 | LibRtcInitialize (
|
| 139 | IN EFI_HANDLE ImageHandle,
|
| 140 | IN EFI_SYSTEM_TABLE *SystemTable
|
| 141 | )
|
| 142 | {
|
| 143 | //
|
| 144 | // Do some initialization if reqruied to turn on the RTC
|
| 145 | //
|
| 146 | return EFI_SUCCESS;
|
| 147 | }
|
| 148 |
|
| 149 |
|
| 150 | /**
|
| 151 | Fixup internal data so that EFI can be call in virtual mode.
|
| 152 | Call the passed in Child Notify event and convert any pointers in
|
| 153 | lib to virtual mode.
|
| 154 |
|
| 155 | @param[in] Event The Event that is being processed
|
| 156 | @param[in] Context Event Context
|
| 157 | **/
|
| 158 | VOID
|
| 159 | EFIAPI
|
| 160 | LibRtcVirtualNotifyEvent (
|
| 161 | IN EFI_EVENT Event,
|
| 162 | IN VOID *Context
|
| 163 | )
|
| 164 | {
|
| 165 | //
|
| 166 | // Only needed if you are going to support the OS calling RTC functions in virtual mode.
|
| 167 | // You will need to call EfiConvertPointer (). To convert any stored physical addresses
|
| 168 | // to virtual address. After the OS transistions to calling in virtual mode, all future
|
| 169 | // runtime calls will be made in virtual mode.
|
| 170 | //
|
| 171 | return;
|
| 172 | }
|
| 173 |
|
| 174 |
|
| 175 |
|