TianoCore EDK2 master
Loading...
Searching...
No Matches
PcRtc.h
Go to the documentation of this file.
1
11#ifndef _RTC_H_
12#define _RTC_H_
13
14#include <Uefi.h>
15
16#include <Guid/Acpi.h>
17
19
20#include <Library/BaseLib.h>
21#include <Library/DebugLib.h>
22#include <Library/UefiLib.h>
24#include <Library/IoLib.h>
25#include <Library/TimerLib.h>
30#include <Library/PcdLib.h>
32
33typedef struct {
34 EFI_LOCK RtcLock;
35 INT16 SavedTimeZone;
36 UINT8 Daylight;
37 UINT8 CenturyRtcAddress;
39
40extern PC_RTC_MODULE_GLOBALS mModuleGlobal;
41
42//
43// Dallas DS12C887 Real Time Clock
44//
45#define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
46#define RTC_ADDRESS_SECONDS_ALARM 1 // R/W Range 0..59
47#define RTC_ADDRESS_MINUTES 2 // R/W Range 0..59
48#define RTC_ADDRESS_MINUTES_ALARM 3 // R/W Range 0..59
49#define RTC_ADDRESS_HOURS 4 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
50#define RTC_ADDRESS_HOURS_ALARM 5 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
51#define RTC_ADDRESS_DAY_OF_THE_WEEK 6 // R/W Range 1..7
52#define RTC_ADDRESS_DAY_OF_THE_MONTH 7 // R/W Range 1..31
53#define RTC_ADDRESS_MONTH 8 // R/W Range 1..12
54#define RTC_ADDRESS_YEAR 9 // R/W Range 0..99
55#define RTC_ADDRESS_REGISTER_A 10 // R/W[0..6] R0[7]
56#define RTC_ADDRESS_REGISTER_B 11 // R/W
57#define RTC_ADDRESS_REGISTER_C 12 // RO
58#define RTC_ADDRESS_REGISTER_D 13 // RO
59//
60// Date and time initial values.
61// They are used if the RTC values are invalid during driver initialization
62//
63#define RTC_INIT_SECOND 0
64#define RTC_INIT_MINUTE 0
65#define RTC_INIT_HOUR 0
66#define RTC_INIT_DAY 1
67#define RTC_INIT_MONTH 1
68
69#pragma pack(1)
70//
71// Register A
72//
73#define RTC_DIV_RESET 0x70
74typedef struct {
75 UINT8 Rs : 4; // Rate Selection Bits
76 UINT8 Dv : 3; // Divisor
77 UINT8 Uip : 1; // Update in progress
79
80typedef union {
82 UINT8 Data;
84
85//
86// Register B
87//
88typedef struct {
89 UINT8 Dse : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
90 UINT8 Mil : 1; // 0 - 12 hour mode 1 - 24 hour mode
91 UINT8 Dm : 1; // 0 - BCD Format 1 - Binary Format
92 UINT8 Sqwe : 1; // 0 - Disable SQWE output 1 - Enable SQWE output
93 UINT8 Uie : 1; // 0 - Update INT disabled 1 - Update INT enabled
94 UINT8 Aie : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
95 UINT8 Pie : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
96 UINT8 Set : 1; // 0 - Normal operation. 1 - Updates inhibited
98
99typedef union {
101 UINT8 Data;
103
104//
105// Register C
106//
107typedef struct {
108 UINT8 Reserved : 4; // Read as zero. Can not be written.
109 UINT8 Uf : 1; // Update End Interrupt Flag
110 UINT8 Af : 1; // Alarm Interrupt Flag
111 UINT8 Pf : 1; // Periodic Interrupt Flag
112 UINT8 Irqf : 1; // Interrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
114
115typedef union {
117 UINT8 Data;
119
120//
121// Register D
122//
123typedef struct {
124 UINT8 Reserved : 7; // Read as zero. Can not be written.
125 UINT8 Vrt : 1; // Valid RAM and Time
127
128typedef union {
130 UINT8 Data;
132
133#pragma pack()
134
145PcRtcInit (
147 );
148
162 IN EFI_TIME *Time,
164 );
165
182 OUT EFI_TIME *Time,
183 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL,
185 );
186
204 IN BOOLEAN Enable,
205 IN EFI_TIME *Time OPTIONAL,
207 );
208
227 OUT BOOLEAN *Enabled,
228 OUT BOOLEAN *Pending,
229 OUT EFI_TIME *Time,
231 );
232
247EFIAPI
249 IN EFI_HANDLE ImageHandle,
250 IN EFI_SYSTEM_TABLE *SystemTable
251 );
252
264 IN EFI_TIME *Time
265 );
266
278VOID
280 IN OUT EFI_TIME *Time,
281 IN RTC_REGISTER_B RegisterB
282 );
283
303 IN OUT EFI_TIME *Time,
304 IN RTC_REGISTER_B RegisterB
305 );
306
317 UINTN Timeout
318 );
319
328BOOLEAN
329DayValid (
330 IN EFI_TIME *Time
331 );
332
341BOOLEAN
343 IN EFI_TIME *Time
344 );
345
351UINT8
353 VOID
354 );
355
366VOID
367EFIAPI
369 IN EFI_EVENT Event,
370 IN VOID *Context
371 );
372
373#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS EFIAPI Set(IN EMBEDDED_GPIO *This, IN EMBEDDED_GPIO_PIN Gpio, IN EMBEDDED_GPIO_MODE Mode)
Definition: PL061Gpio.c:219
UINT8 GetCenturyRtcAddress(VOID)
Definition: PcRtc.c:1404
BOOLEAN DayValid(IN EFI_TIME *Time)
EFI_STATUS PcRtcSetWakeupTime(IN BOOLEAN Enable, IN EFI_TIME *Time OPTIONAL, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:868
EFI_STATUS RtcWaitToUpdate(UINTN Timeout)
Definition: PcRtc.c:1124
EFI_STATUS EFIAPI InitializePcRtc(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: PcRtcEntry.c:157
EFI_STATUS PcRtcInit(IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:262
BOOLEAN IsLeapYear(IN EFI_TIME *Time)
Definition: TimeBaseLib.c:166
EFI_STATUS ConvertRtcTimeToEfiTime(IN OUT EFI_TIME *Time, IN RTC_REGISTER_B RegisterB)
Definition: PcRtc.c:1051
EFI_STATUS PcRtcGetWakeupTime(OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:750
EFI_STATUS PcRtcGetTime(OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:527
VOID ConvertEfiTimeToRtcTime(IN OUT EFI_TIME *Time, IN RTC_REGISTER_B RegisterB)
Definition: PcRtc.c:1260
EFI_STATUS PcRtcSetTime(IN EFI_TIME *Time, IN PC_RTC_MODULE_GLOBALS *Global)
Definition: PcRtc.c:632
EFI_STATUS RtcTimeFieldsValid(IN EFI_TIME *Time)
VOID EFIAPI PcRtcAcpiTableChangeCallback(IN EFI_EVENT Event, IN VOID *Context)
Definition: PcRtc.c:1436
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33