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
30 // The package level header files this module uses
34 // The protocols, PPI and GUID defintions for this module
36 #include <Protocol/RealTimeClock.h>
38 // The Library classes this module consumes
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>
56 } PC_RTC_MODULE_GLOBALS
;
58 #define PCAT_RTC_ADDRESS_REGISTER 0x70
59 #define PCAT_RTC_DATA_REGISTER 0x71
62 // Dallas DS12C887 Real Time Clock
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
80 // Date and time initial values.
81 // They are used if the RTC values are invalid during driver initialization
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
91 // Register initial values
93 #define RTC_INIT_REGISTER_A 0x26
94 #define RTC_INIT_REGISTER_B 0x02
95 #define RTC_INIT_REGISTER_D 0x0
102 UINT8 RS
: 4; // Rate Selection Bits
103 UINT8 DV
: 3; // Divisor
104 UINT8 UIP
: 1; // Update in progress
105 } RTC_REGISTER_A_BITS
;
108 RTC_REGISTER_A_BITS Bits
;
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
;
127 RTC_REGISTER_B_BITS Bits
;
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
;
143 RTC_REGISTER_C_BITS Bits
;
151 UINT8 Reserved
: 7; // Read as zero. Can not be written.
152 UINT8 VRT
: 1; // Valid RAM and Time
153 } RTC_REGISTER_D_BITS
;
156 RTC_REGISTER_D_BITS Bits
;
164 IN PC_RTC_MODULE_GLOBALS
*Global
170 GC_TODO: Add function description
174 Global - GC_TODO: add argument description
178 GC_TODO: add return values
186 IN PC_RTC_MODULE_GLOBALS
*Global
192 GC_TODO: Add function description
196 Time - GC_TODO: add argument description
197 Global - GC_TODO: add argument description
201 GC_TODO: add return values
209 IN EFI_TIME_CAPABILITIES
*Capabilities
,
210 IN PC_RTC_MODULE_GLOBALS
*Global
216 GC_TODO: Add function description
220 Time - GC_TODO: add argument description
221 Capabilities - GC_TODO: add argument description
222 Global - GC_TODO: add argument description
226 GC_TODO: add return values
235 IN PC_RTC_MODULE_GLOBALS
*Global
241 GC_TODO: Add function description
245 Enable - GC_TODO: add argument description
246 Time - GC_TODO: add argument description
247 Global - GC_TODO: add argument description
251 GC_TODO: add return values
258 OUT BOOLEAN
*Enabled
,
259 OUT BOOLEAN
*Pending
,
261 IN PC_RTC_MODULE_GLOBALS
*Global
267 GC_TODO: Add function description
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
278 GC_TODO: add return values
286 IN EFI_HANDLE ImageHandle
,
287 IN EFI_SYSTEM_TABLE
*SystemTable
293 GC_TODO: Add function description
297 ImageHandle - GC_TODO: add argument description
298 SystemTable - GC_TODO: add argument description
302 GC_TODO: add return values
315 GC_TODO: Add function description
319 BcdValue - GC_TODO: add argument description
323 GC_TODO: add return values
336 GC_TODO: Add function description
340 Time - GC_TODO: add argument description
344 GC_TODO: add return values
357 GC_TODO: Add function description
361 DecValue - GC_TODO: add argument description
365 GC_TODO: add return values
371 ConvertEfiTimeToRtcTime (
373 IN RTC_REGISTER_B RegisterB
,
380 GC_TODO: Add function description
384 Time - GC_TODO: add argument description
385 RegisterB - GC_TODO: add argument description
386 Century - GC_TODO: add argument description
390 GC_TODO: add return values
396 RtcTestCenturyRegister (
403 GC_TODO: Add function description
411 GC_TODO: add return values
417 ConvertRtcTimeToEfiTime (
419 IN RTC_REGISTER_B RegisterB
425 GC_TODO: Add function description
429 Time - GC_TODO: add argument description
430 RegisterB - GC_TODO: add argument description
434 GC_TODO: add return values
447 GC_TODO: Add function description
451 Timeout - GC_TODO: add argument description
455 GC_TODO: add return values
462 IN PC_RTC_MODULE_GLOBALS
*Global
468 GC_TODO: Add function description
472 Global - GC_TODO: add argument description
476 GC_TODO: add return values
483 IN UINT8 SavedAddressRegister
,
484 IN PC_RTC_MODULE_GLOBALS
*Global
490 GC_TODO: Add function description
494 SavedAddressRegister - GC_TODO: add argument description
495 Global - GC_TODO: add argument description
499 GC_TODO: add return values