2 Header file for real time clock driver.
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include <Protocol/RealTimeClock.h>
24 #include <Library/BaseLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/UefiLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/IoLib.h>
29 #include <Library/TimerLib.h>
30 #include <Library/UefiDriverEntryPoint.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/UefiRuntimeLib.h>
33 #include <Library/UefiRuntimeServicesTableLib.h>
40 } PC_RTC_MODULE_GLOBALS
;
42 #define PCAT_RTC_ADDRESS_REGISTER 0x70
43 #define PCAT_RTC_DATA_REGISTER 0x71
46 // Dallas DS12C887 Real Time Clock
48 #define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
49 #define RTC_ADDRESS_SECONDS_ALARM 1 // R/W Range 0..59
50 #define RTC_ADDRESS_MINUTES 2 // R/W Range 0..59
51 #define RTC_ADDRESS_MINUTES_ALARM 3 // R/W Range 0..59
52 #define RTC_ADDRESS_HOURS 4 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
53 #define RTC_ADDRESS_HOURS_ALARM 5 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
54 #define RTC_ADDRESS_DAY_OF_THE_WEEK 6 // R/W Range 1..7
55 #define RTC_ADDRESS_DAY_OF_THE_MONTH 7 // R/W Range 1..31
56 #define RTC_ADDRESS_MONTH 8 // R/W Range 1..12
57 #define RTC_ADDRESS_YEAR 9 // R/W Range 0..99
58 #define RTC_ADDRESS_REGISTER_A 10 // R/W[0..6] R0[7]
59 #define RTC_ADDRESS_REGISTER_B 11 // R/W
60 #define RTC_ADDRESS_REGISTER_C 12 // RO
61 #define RTC_ADDRESS_REGISTER_D 13 // RO
62 #define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
64 // Date and time initial values.
65 // They are used if the RTC values are invalid during driver initialization
67 #define RTC_INIT_SECOND 0
68 #define RTC_INIT_MINUTE 0
69 #define RTC_INIT_HOUR 0
70 #define RTC_INIT_DAY 1
71 #define RTC_INIT_MONTH 1
72 #define RTC_INIT_YEAR 2001
75 // Register initial values
77 #define RTC_INIT_REGISTER_A 0x26
78 #define RTC_INIT_REGISTER_B 0x02
79 #define RTC_INIT_REGISTER_D 0x0
86 UINT8 RS
: 4; // Rate Selection Bits
87 UINT8 DV
: 3; // Divisor
88 UINT8 UIP
: 1; // Update in progress
89 } RTC_REGISTER_A_BITS
;
92 RTC_REGISTER_A_BITS Bits
;
100 UINT8 DSE
: 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
101 UINT8 MIL
: 1; // 0 - 12 hour mode 1 - 24 hour mode
102 UINT8 DM
: 1; // 0 - BCD Format 1 - Binary Format
103 UINT8 SQWE
: 1; // 0 - Disable SQWE output 1 - Enable SQWE output
104 UINT8 UIE
: 1; // 0 - Update INT disabled 1 - Update INT enabled
105 UINT8 AIE
: 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
106 UINT8 PIE
: 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
107 UINT8 SET
: 1; // 0 - Normal operation. 1 - Updates inhibited
108 } RTC_REGISTER_B_BITS
;
111 RTC_REGISTER_B_BITS Bits
;
119 UINT8 Reserved
: 4; // Read as zero. Can not be written.
120 UINT8 UF
: 1; // Update End Interrupt Flag
121 UINT8 AF
: 1; // Alarm Interrupt Flag
122 UINT8 PF
: 1; // Periodic Interrupt Flag
123 UINT8 IRQF
: 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
124 } RTC_REGISTER_C_BITS
;
127 RTC_REGISTER_C_BITS Bits
;
135 UINT8 Reserved
: 7; // Read as zero. Can not be written.
136 UINT8 VRT
: 1; // Valid RAM and Time
137 } RTC_REGISTER_D_BITS
;
140 RTC_REGISTER_D_BITS Bits
;
148 IN PC_RTC_MODULE_GLOBALS
*Global
154 GC_TODO: Add function description
158 Global - GC_TODO: add argument description
162 GC_TODO: add return values
170 IN PC_RTC_MODULE_GLOBALS
*Global
176 GC_TODO: Add function description
180 Time - GC_TODO: add argument description
181 Global - GC_TODO: add argument description
185 GC_TODO: add return values
193 IN EFI_TIME_CAPABILITIES
*Capabilities
,
194 IN PC_RTC_MODULE_GLOBALS
*Global
200 GC_TODO: Add function description
204 Time - GC_TODO: add argument description
205 Capabilities - GC_TODO: add argument description
206 Global - GC_TODO: add argument description
210 GC_TODO: add return values
219 IN PC_RTC_MODULE_GLOBALS
*Global
225 GC_TODO: Add function description
229 Enable - GC_TODO: add argument description
230 Time - GC_TODO: add argument description
231 Global - GC_TODO: add argument description
235 GC_TODO: add return values
242 OUT BOOLEAN
*Enabled
,
243 OUT BOOLEAN
*Pending
,
245 IN PC_RTC_MODULE_GLOBALS
*Global
251 GC_TODO: Add function description
255 Enabled - GC_TODO: add argument description
256 Pending - GC_TODO: add argument description
257 Time - GC_TODO: add argument description
258 Global - GC_TODO: add argument description
262 GC_TODO: add return values
270 IN EFI_HANDLE ImageHandle
,
271 IN EFI_SYSTEM_TABLE
*SystemTable
277 GC_TODO: Add function description
281 ImageHandle - GC_TODO: add argument description
282 SystemTable - GC_TODO: add argument description
286 GC_TODO: add return values
299 GC_TODO: Add function description
303 BcdValue - GC_TODO: add argument description
307 GC_TODO: add return values
320 GC_TODO: Add function description
324 Time - GC_TODO: add argument description
328 GC_TODO: add return values
341 GC_TODO: Add function description
345 DecValue - GC_TODO: add argument description
349 GC_TODO: add return values
355 ConvertEfiTimeToRtcTime (
357 IN RTC_REGISTER_B RegisterB
,
364 GC_TODO: Add function description
368 Time - GC_TODO: add argument description
369 RegisterB - GC_TODO: add argument description
370 Century - GC_TODO: add argument description
374 GC_TODO: add return values
380 RtcTestCenturyRegister (
387 GC_TODO: Add function description
395 GC_TODO: add return values
401 ConvertRtcTimeToEfiTime (
403 IN RTC_REGISTER_B RegisterB
409 GC_TODO: Add function description
413 Time - GC_TODO: add argument description
414 RegisterB - GC_TODO: add argument description
418 GC_TODO: add return values
431 GC_TODO: Add function description
435 Timeout - GC_TODO: add argument description
439 GC_TODO: add return values
446 IN PC_RTC_MODULE_GLOBALS
*Global
452 GC_TODO: Add function description
456 Global - GC_TODO: add argument description
460 GC_TODO: add return values
467 IN UINT8 SavedAddressRegister
,
468 IN PC_RTC_MODULE_GLOBALS
*Global
474 GC_TODO: Add function description
478 SavedAddressRegister - GC_TODO: add argument description
479 Global - GC_TODO: add argument description
483 GC_TODO: add return values