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