]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcRtc.h
PcdIoBlockBaseAddressForIpf is required by IPF platform so need add it back
[mirror_edk2.git] / MdeModulePkg / Universal / PcatRealTimeClockRuntimeDxe / PcRtc.h
CommitLineData
8cd4d17c 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation. All rights reserved. \r
4This software and associated documentation (if any) is furnished\r
5under a license and may only be used or copied in accordance\r
6with the terms of the license. Except as permitted by such\r
7license, no part of this software or documentation may be\r
8reproduced, stored in a retrieval system, or transmitted in any\r
9form or by any means without the express written consent of\r
10Intel Corporation.\r
11\r
12\r
13Module Name:\r
14 \r
15 PcRtc.h\r
16\r
17Abstract:\r
18\r
19 Include for real time clock driver\r
20\r
21Revision History\r
22\r
23\r
24--*/\r
25\r
26#ifndef _RTC_H_\r
27#define _RTC_H_\r
28\r
29//\r
30// The package level header files this module uses\r
31//\r
32#include <PiDxe.h>\r
33//\r
34// The protocols, PPI and GUID defintions for this module\r
35//\r
36#include <Protocol/RealTimeClock.h>\r
37//\r
38// The Library classes this module consumes\r
39//\r
40#include <Library/BaseLib.h>\r
41#include <Library/DebugLib.h>\r
42#include <Library/UefiLib.h>\r
43#include <Library/BaseMemoryLib.h>\r
44#include <Library/IoLib.h>\r
45#include <Library/TimerLib.h>\r
46#include <Library/UefiDriverEntryPoint.h>\r
47#include <Library/UefiBootServicesTableLib.h>\r
48#include <Library/UefiRuntimeLib.h>\r
49#include <Library/UefiRuntimeServicesTableLib.h>\r
50\r
51\r
52typedef struct {\r
53 EFI_LOCK RtcLock;\r
54 UINT16 SavedTimeZone;\r
55 UINT8 Daylight;\r
56} PC_RTC_MODULE_GLOBALS;\r
57\r
58#define PCAT_RTC_ADDRESS_REGISTER 0x70\r
59#define PCAT_RTC_DATA_REGISTER 0x71\r
60\r
61//\r
62// Dallas DS12C887 Real Time Clock\r
63//\r
64#define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59\r
65#define RTC_ADDRESS_SECONDS_ALARM 1 // R/W Range 0..59\r
66#define RTC_ADDRESS_MINUTES 2 // R/W Range 0..59\r
67#define RTC_ADDRESS_MINUTES_ALARM 3 // R/W Range 0..59\r
68#define RTC_ADDRESS_HOURS 4 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM\r
69#define RTC_ADDRESS_HOURS_ALARM 5 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM\r
70#define RTC_ADDRESS_DAY_OF_THE_WEEK 6 // R/W Range 1..7\r
71#define RTC_ADDRESS_DAY_OF_THE_MONTH 7 // R/W Range 1..31\r
72#define RTC_ADDRESS_MONTH 8 // R/W Range 1..12\r
73#define RTC_ADDRESS_YEAR 9 // R/W Range 0..99\r
74#define RTC_ADDRESS_REGISTER_A 10 // R/W[0..6] R0[7]\r
75#define RTC_ADDRESS_REGISTER_B 11 // R/W\r
76#define RTC_ADDRESS_REGISTER_C 12 // RO\r
77#define RTC_ADDRESS_REGISTER_D 13 // RO\r
78#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W\r
79//\r
80// Date and time initial values.\r
81// They are used if the RTC values are invalid during driver initialization\r
82//\r
83#define RTC_INIT_SECOND 0\r
84#define RTC_INIT_MINUTE 0\r
85#define RTC_INIT_HOUR 0\r
86#define RTC_INIT_DAY 1\r
87#define RTC_INIT_MONTH 1\r
88#define RTC_INIT_YEAR 2001\r
89\r
90//\r
91// Register initial values\r
92//\r
93#define RTC_INIT_REGISTER_A 0x26\r
94#define RTC_INIT_REGISTER_B 0x02\r
95#define RTC_INIT_REGISTER_D 0x0\r
96\r
97#pragma pack(1)\r
98//\r
99// Register A\r
100//\r
101typedef struct {\r
102 UINT8 RS : 4; // Rate Selection Bits\r
103 UINT8 DV : 3; // Divisor\r
104 UINT8 UIP : 1; // Update in progress\r
105} RTC_REGISTER_A_BITS;\r
106\r
107typedef union {\r
108 RTC_REGISTER_A_BITS Bits;\r
109 UINT8 Data;\r
110} RTC_REGISTER_A;\r
111\r
112//\r
113// Register B\r
114//\r
115typedef struct {\r
116 UINT8 DSE : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled\r
117 UINT8 MIL : 1; // 0 - 12 hour mode 1 - 24 hour mode\r
118 UINT8 DM : 1; // 0 - BCD Format 1 - Binary Format\r
119 UINT8 SQWE : 1; // 0 - Disable SQWE output 1 - Enable SQWE output\r
120 UINT8 UIE : 1; // 0 - Update INT disabled 1 - Update INT enabled\r
121 UINT8 AIE : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled\r
122 UINT8 PIE : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled\r
123 UINT8 SET : 1; // 0 - Normal operation. 1 - Updates inhibited\r
124} RTC_REGISTER_B_BITS;\r
125\r
126typedef union {\r
127 RTC_REGISTER_B_BITS Bits;\r
128 UINT8 Data;\r
129} RTC_REGISTER_B;\r
130\r
131//\r
132// Register C\r
133//\r
134typedef struct {\r
135 UINT8 Reserved : 4; // Read as zero. Can not be written.\r
136 UINT8 UF : 1; // Update End Interrupt Flag\r
137 UINT8 AF : 1; // Alarm Interrupt Flag\r
138 UINT8 PF : 1; // Periodic Interrupt Flag\r
139 UINT8 IRQF : 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE\r
140} RTC_REGISTER_C_BITS;\r
141\r
142typedef union {\r
143 RTC_REGISTER_C_BITS Bits;\r
144 UINT8 Data;\r
145} RTC_REGISTER_C;\r
146\r
147//\r
148// Register D\r
149//\r
150typedef struct {\r
151 UINT8 Reserved : 7; // Read as zero. Can not be written.\r
152 UINT8 VRT : 1; // Valid RAM and Time\r
153} RTC_REGISTER_D_BITS;\r
154\r
155typedef union {\r
156 RTC_REGISTER_D_BITS Bits;\r
157 UINT8 Data;\r
158} RTC_REGISTER_D;\r
159\r
160#pragma pack()\r
161\r
162EFI_STATUS\r
163PcRtcInit (\r
164 IN PC_RTC_MODULE_GLOBALS *Global\r
165 )\r
166/*++\r
167\r
168Routine Description:\r
169\r
170 GC_TODO: Add function description\r
171\r
172Arguments:\r
173\r
174 Global - GC_TODO: add argument description\r
175\r
176Returns:\r
177\r
178 GC_TODO: add return values\r
179\r
180--*/\r
181;\r
182\r
183EFI_STATUS\r
184PcRtcSetTime (\r
185 IN EFI_TIME *Time,\r
186 IN PC_RTC_MODULE_GLOBALS *Global\r
187 )\r
188/*++\r
189\r
190Routine Description:\r
191\r
192 GC_TODO: Add function description\r
193\r
194Arguments:\r
195\r
196 Time - GC_TODO: add argument description\r
197 Global - GC_TODO: add argument description\r
198\r
199Returns:\r
200\r
201 GC_TODO: add return values\r
202\r
203--*/\r
204;\r
205\r
206EFI_STATUS\r
207PcRtcGetTime (\r
208 OUT EFI_TIME *Time,\r
209 IN EFI_TIME_CAPABILITIES *Capabilities,\r
210 IN PC_RTC_MODULE_GLOBALS *Global\r
211 )\r
212/*++\r
213\r
214Routine Description:\r
215\r
216 GC_TODO: Add function description\r
217\r
218Arguments:\r
219\r
220 Time - GC_TODO: add argument description\r
221 Capabilities - GC_TODO: add argument description\r
222 Global - GC_TODO: add argument description\r
223\r
224Returns:\r
225\r
226 GC_TODO: add return values\r
227\r
228--*/\r
229;\r
230\r
231EFI_STATUS\r
232PcRtcSetWakeupTime (\r
233 IN BOOLEAN Enable,\r
234 OUT EFI_TIME *Time,\r
235 IN PC_RTC_MODULE_GLOBALS *Global\r
236 )\r
237/*++\r
238\r
239Routine Description:\r
240\r
241 GC_TODO: Add function description\r
242\r
243Arguments:\r
244\r
245 Enable - GC_TODO: add argument description\r
246 Time - GC_TODO: add argument description\r
247 Global - GC_TODO: add argument description\r
248\r
249Returns:\r
250\r
251 GC_TODO: add return values\r
252\r
253--*/\r
254;\r
255\r
256EFI_STATUS\r
257PcRtcGetWakeupTime (\r
258 OUT BOOLEAN *Enabled,\r
259 OUT BOOLEAN *Pending,\r
260 OUT EFI_TIME *Time,\r
261 IN PC_RTC_MODULE_GLOBALS *Global\r
262 )\r
263/*++\r
264\r
265Routine Description:\r
266\r
267 GC_TODO: Add function description\r
268\r
269Arguments:\r
270\r
271 Enabled - GC_TODO: add argument description\r
272 Pending - GC_TODO: add argument description\r
273 Time - GC_TODO: add argument description\r
274 Global - GC_TODO: add argument description\r
275\r
276Returns:\r
277\r
278 GC_TODO: add return values\r
279\r
280--*/\r
281;\r
282\r
283EFI_STATUS\r
284EFIAPI\r
285InitializePcRtc (\r
286 IN EFI_HANDLE ImageHandle,\r
287 IN EFI_SYSTEM_TABLE *SystemTable\r
288 )\r
289/*++\r
290\r
291Routine Description:\r
292\r
293 GC_TODO: Add function description\r
294\r
295Arguments:\r
296\r
297 ImageHandle - GC_TODO: add argument description\r
298 SystemTable - GC_TODO: add argument description\r
299\r
300Returns:\r
301\r
302 GC_TODO: add return values\r
303\r
304--*/\r
305;\r
306\r
307UINT8\r
308BcdToDecimal (\r
309 IN UINT8 BcdValue\r
310 )\r
311/*++\r
312\r
313Routine Description:\r
314\r
315 GC_TODO: Add function description\r
316\r
317Arguments:\r
318\r
319 BcdValue - GC_TODO: add argument description\r
320\r
321Returns:\r
322\r
323 GC_TODO: add return values\r
324\r
325--*/\r
326;\r
327\r
328EFI_STATUS\r
329RtcTimeFieldsValid (\r
330 IN EFI_TIME *Time\r
331 )\r
332/*++\r
333\r
334Routine Description:\r
335\r
336 GC_TODO: Add function description\r
337\r
338Arguments:\r
339\r
340 Time - GC_TODO: add argument description\r
341\r
342Returns:\r
343\r
344 GC_TODO: add return values\r
345\r
346--*/\r
347;\r
348\r
349UINT8\r
350DecimaltoBcd (\r
351 IN UINT8 DecValue\r
352 )\r
353/*++\r
354\r
355Routine Description:\r
356\r
357 GC_TODO: Add function description\r
358\r
359Arguments:\r
360\r
361 DecValue - GC_TODO: add argument description\r
362\r
363Returns:\r
364\r
365 GC_TODO: add return values\r
366\r
367--*/\r
368;\r
369\r
370VOID\r
371ConvertEfiTimeToRtcTime (\r
372 IN EFI_TIME *Time,\r
373 IN RTC_REGISTER_B RegisterB,\r
374 IN UINT8 *Century\r
375 )\r
376/*++\r
377\r
378Routine Description:\r
379\r
380 GC_TODO: Add function description\r
381\r
382Arguments:\r
383\r
384 Time - GC_TODO: add argument description\r
385 RegisterB - GC_TODO: add argument description\r
386 Century - GC_TODO: add argument description\r
387\r
388Returns:\r
389\r
390 GC_TODO: add return values\r
391\r
392--*/\r
393;\r
394\r
395EFI_STATUS\r
396RtcTestCenturyRegister (\r
397 VOID\r
398 )\r
399/*++\r
400\r
401Routine Description:\r
402\r
403 GC_TODO: Add function description\r
404\r
405Arguments:\r
406\r
407 None\r
408\r
409Returns:\r
410\r
411 GC_TODO: add return values\r
412\r
413--*/\r
414;\r
415\r
416VOID\r
417ConvertRtcTimeToEfiTime (\r
418 IN EFI_TIME *Time,\r
419 IN RTC_REGISTER_B RegisterB\r
420 )\r
421/*++\r
422\r
423Routine Description:\r
424\r
425 GC_TODO: Add function description\r
426\r
427Arguments:\r
428\r
429 Time - GC_TODO: add argument description\r
430 RegisterB - GC_TODO: add argument description\r
431\r
432Returns:\r
433\r
434 GC_TODO: add return values\r
435\r
436--*/\r
437;\r
438\r
439EFI_STATUS\r
440RtcWaitToUpdate (\r
441 UINTN Timeout\r
442 )\r
443/*++\r
444\r
445Routine Description:\r
446\r
447 GC_TODO: Add function description\r
448\r
449Arguments:\r
450\r
451 Timeout - GC_TODO: add argument description\r
452\r
453Returns:\r
454\r
455 GC_TODO: add return values\r
456\r
457--*/\r
458;\r
459\r
460UINT8\r
461RtcSaveContext (\r
462 IN PC_RTC_MODULE_GLOBALS *Global\r
463 )\r
464/*++\r
465\r
466Routine Description:\r
467\r
468 GC_TODO: Add function description\r
469\r
470Arguments:\r
471\r
472 Global - GC_TODO: add argument description\r
473\r
474Returns:\r
475\r
476 GC_TODO: add return values\r
477\r
478--*/\r
479;\r
480\r
481VOID\r
482RtcRestoreContext (\r
483 IN UINT8 SavedAddressRegister,\r
484 IN PC_RTC_MODULE_GLOBALS *Global\r
485 )\r
486/*++\r
487\r
488Routine Description:\r
489\r
490 GC_TODO: Add function description\r
491\r
492Arguments:\r
493\r
494 SavedAddressRegister - GC_TODO: add argument description\r
495 Global - GC_TODO: add argument description\r
496\r
497Returns:\r
498\r
499 GC_TODO: add return values\r
500\r
501--*/\r
502;\r
503\r
504BOOLEAN\r
505DayValid (\r
506 IN EFI_TIME *Time\r
507 );\r
508\r
509BOOLEAN\r
510IsLeapYear (\r
511 IN EFI_TIME *Time\r
512 );\r
513\r
514#endif\r