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
19 Include for real time clock driver
32 #include <Protocol/RealTimeClock.h>
34 #include <Library/BaseLib.h>
35 #include <Library/DebugLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseMemoryLib.h>
38 #include <Library/IoLib.h>
39 #include <Library/TimerLib.h>
40 #include <Library/UefiDriverEntryPoint.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/UefiRuntimeLib.h>
43 #include <Library/UefiRuntimeServicesTableLib.h>
50 } PC_RTC_MODULE_GLOBALS
;
52 #define PCAT_RTC_ADDRESS_REGISTER 0x70
53 #define PCAT_RTC_DATA_REGISTER 0x71
56 // Dallas DS12C887 Real Time Clock
58 #define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
59 #define RTC_ADDRESS_SECONDS_ALARM 1 // R/W Range 0..59
60 #define RTC_ADDRESS_MINUTES 2 // R/W Range 0..59
61 #define RTC_ADDRESS_MINUTES_ALARM 3 // R/W Range 0..59
62 #define RTC_ADDRESS_HOURS 4 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
63 #define RTC_ADDRESS_HOURS_ALARM 5 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
64 #define RTC_ADDRESS_DAY_OF_THE_WEEK 6 // R/W Range 1..7
65 #define RTC_ADDRESS_DAY_OF_THE_MONTH 7 // R/W Range 1..31
66 #define RTC_ADDRESS_MONTH 8 // R/W Range 1..12
67 #define RTC_ADDRESS_YEAR 9 // R/W Range 0..99
68 #define RTC_ADDRESS_REGISTER_A 10 // R/W[0..6] R0[7]
69 #define RTC_ADDRESS_REGISTER_B 11 // R/W
70 #define RTC_ADDRESS_REGISTER_C 12 // RO
71 #define RTC_ADDRESS_REGISTER_D 13 // RO
72 #define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
74 // Date and time initial values.
75 // They are used if the RTC values are invalid during driver initialization
77 #define RTC_INIT_SECOND 0
78 #define RTC_INIT_MINUTE 0
79 #define RTC_INIT_HOUR 0
80 #define RTC_INIT_DAY 1
81 #define RTC_INIT_MONTH 1
82 #define RTC_INIT_YEAR 2001
85 // Register initial values
87 #define RTC_INIT_REGISTER_A 0x26
88 #define RTC_INIT_REGISTER_B 0x02
89 #define RTC_INIT_REGISTER_D 0x0
96 UINT8 RS
: 4; // Rate Selection Bits
97 UINT8 DV
: 3; // Divisor
98 UINT8 UIP
: 1; // Update in progress
99 } RTC_REGISTER_A_BITS
;
102 RTC_REGISTER_A_BITS Bits
;
110 UINT8 DSE
: 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
111 UINT8 MIL
: 1; // 0 - 12 hour mode 1 - 24 hour mode
112 UINT8 DM
: 1; // 0 - BCD Format 1 - Binary Format
113 UINT8 SQWE
: 1; // 0 - Disable SQWE output 1 - Enable SQWE output
114 UINT8 UIE
: 1; // 0 - Update INT disabled 1 - Update INT enabled
115 UINT8 AIE
: 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
116 UINT8 PIE
: 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
117 UINT8 SET
: 1; // 0 - Normal operation. 1 - Updates inhibited
118 } RTC_REGISTER_B_BITS
;
121 RTC_REGISTER_B_BITS Bits
;
129 UINT8 Reserved
: 4; // Read as zero. Can not be written.
130 UINT8 UF
: 1; // Update End Interrupt Flag
131 UINT8 AF
: 1; // Alarm Interrupt Flag
132 UINT8 PF
: 1; // Periodic Interrupt Flag
133 UINT8 IRQF
: 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
134 } RTC_REGISTER_C_BITS
;
137 RTC_REGISTER_C_BITS Bits
;
145 UINT8 Reserved
: 7; // Read as zero. Can not be written.
146 UINT8 VRT
: 1; // Valid RAM and Time
147 } RTC_REGISTER_D_BITS
;
150 RTC_REGISTER_D_BITS Bits
;
158 IN PC_RTC_MODULE_GLOBALS
*Global
164 GC_TODO: Add function description
168 Global - GC_TODO: add argument description
172 GC_TODO: add return values
180 IN PC_RTC_MODULE_GLOBALS
*Global
186 GC_TODO: Add function description
190 Time - GC_TODO: add argument description
191 Global - GC_TODO: add argument description
195 GC_TODO: add return values
203 IN EFI_TIME_CAPABILITIES
*Capabilities
,
204 IN PC_RTC_MODULE_GLOBALS
*Global
210 GC_TODO: Add function description
214 Time - GC_TODO: add argument description
215 Capabilities - GC_TODO: add argument description
216 Global - GC_TODO: add argument description
220 GC_TODO: add return values
229 IN PC_RTC_MODULE_GLOBALS
*Global
235 GC_TODO: Add function description
239 Enable - GC_TODO: add argument description
240 Time - GC_TODO: add argument description
241 Global - GC_TODO: add argument description
245 GC_TODO: add return values
252 OUT BOOLEAN
*Enabled
,
253 OUT BOOLEAN
*Pending
,
255 IN PC_RTC_MODULE_GLOBALS
*Global
261 GC_TODO: Add function description
265 Enabled - GC_TODO: add argument description
266 Pending - GC_TODO: add argument description
267 Time - GC_TODO: add argument description
268 Global - GC_TODO: add argument description
272 GC_TODO: add return values
280 IN EFI_HANDLE ImageHandle
,
281 IN EFI_SYSTEM_TABLE
*SystemTable
287 GC_TODO: Add function description
291 ImageHandle - GC_TODO: add argument description
292 SystemTable - GC_TODO: add argument description
296 GC_TODO: add return values
309 GC_TODO: Add function description
313 BcdValue - GC_TODO: add argument description
317 GC_TODO: add return values
330 GC_TODO: Add function description
334 Time - GC_TODO: add argument description
338 GC_TODO: add return values
351 GC_TODO: Add function description
355 DecValue - GC_TODO: add argument description
359 GC_TODO: add return values
365 ConvertEfiTimeToRtcTime (
367 IN RTC_REGISTER_B RegisterB
,
374 GC_TODO: Add function description
378 Time - GC_TODO: add argument description
379 RegisterB - GC_TODO: add argument description
380 Century - GC_TODO: add argument description
384 GC_TODO: add return values
390 RtcTestCenturyRegister (
397 GC_TODO: Add function description
405 GC_TODO: add return values
411 ConvertRtcTimeToEfiTime (
413 IN RTC_REGISTER_B RegisterB
419 GC_TODO: Add function description
423 Time - GC_TODO: add argument description
424 RegisterB - GC_TODO: add argument description
428 GC_TODO: add return values
441 GC_TODO: Add function description
445 Timeout - GC_TODO: add argument description
449 GC_TODO: add return values
456 IN PC_RTC_MODULE_GLOBALS
*Global
462 GC_TODO: Add function description
466 Global - GC_TODO: add argument description
470 GC_TODO: add return values
477 IN UINT8 SavedAddressRegister
,
478 IN PC_RTC_MODULE_GLOBALS
*Global
484 GC_TODO: Add function description
488 SavedAddressRegister - GC_TODO: add argument description
489 Global - GC_TODO: add argument description
493 GC_TODO: add return values