3 Copyright (c) 2005, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 Include for real time clock driver
27 #include <FrameworkDxe.h>
29 #include <Protocol/RealTimeClock.h>
31 #include <Library/UefiLib.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/IoLib.h>
34 #include <Library/TimerLib.h>
35 #include <Library/BaseMemoryLib.h>
41 } PC_RTC_MODULE_GLOBALS
;
43 #define PCAT_RTC_ADDRESS_REGISTER 0x70
44 #define PCAT_RTC_DATA_REGISTER 0x71
47 // Dallas DS12C887 Real Time Clock
49 #define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
50 #define RTC_ADDRESS_SECONDS_ALARM 1 // R/W Range 0..59
51 #define RTC_ADDRESS_MINUTES 2 // R/W Range 0..59
52 #define RTC_ADDRESS_MINUTES_ALARM 3 // R/W Range 0..59
53 #define RTC_ADDRESS_HOURS 4 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
54 #define RTC_ADDRESS_HOURS_ALARM 5 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
55 #define RTC_ADDRESS_DAY_OF_THE_WEEK 6 // R/W Range 1..7
56 #define RTC_ADDRESS_DAY_OF_THE_MONTH 7 // R/W Range 1..31
57 #define RTC_ADDRESS_MONTH 8 // R/W Range 1..12
58 #define RTC_ADDRESS_YEAR 9 // R/W Range 0..99
59 #define RTC_ADDRESS_REGISTER_A 10 // R/W[0..6] R0[7]
60 #define RTC_ADDRESS_REGISTER_B 11 // R/W
61 #define RTC_ADDRESS_REGISTER_C 12 // RO
62 #define RTC_ADDRESS_REGISTER_D 13 // RO
63 #define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
65 // Date and time initial values.
66 // They are used if the RTC values are invalid during driver initialization
68 #define RTC_INIT_SECOND 0
69 #define RTC_INIT_MINUTE 0
70 #define RTC_INIT_HOUR 0
71 #define RTC_INIT_DAY 1
72 #define RTC_INIT_MONTH 1
73 #define RTC_INIT_YEAR 2001
76 // Register initial values
78 #define RTC_INIT_REGISTER_A 0x26
79 #define RTC_INIT_REGISTER_B 0x02
80 #define RTC_INIT_REGISTER_D 0x0
87 UINT8 RS
: 4; // Rate Selection Bits
88 UINT8 DV
: 3; // Divisor
89 UINT8 UIP
: 1; // Update in progress
90 } RTC_REGISTER_A_BITS
;
93 RTC_REGISTER_A_BITS Bits
;
101 UINT8 DSE
: 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
102 UINT8 MIL
: 1; // 0 - 12 hour mode 1 - 24 hour mode
103 UINT8 DM
: 1; // 0 - BCD Format 1 - Binary Format
104 UINT8 SQWE
: 1; // 0 - Disable SQWE output 1 - Enable SQWE output
105 UINT8 UIE
: 1; // 0 - Update INT disabled 1 - Update INT enabled
106 UINT8 AIE
: 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
107 UINT8 PIE
: 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
108 UINT8 SET
: 1; // 0 - Normal operation. 1 - Updates inhibited
109 } RTC_REGISTER_B_BITS
;
112 RTC_REGISTER_B_BITS Bits
;
120 UINT8 Reserved
: 4; // Read as zero. Can not be written.
121 UINT8 UF
: 1; // Update End Interrupt Flag
122 UINT8 AF
: 1; // Alarm Interrupt Flag
123 UINT8 PF
: 1; // Periodic Interrupt Flag
124 UINT8 IRQF
: 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
125 } RTC_REGISTER_C_BITS
;
128 RTC_REGISTER_C_BITS Bits
;
136 UINT8 Reserved
: 7; // Read as zero. Can not be written.
137 UINT8 VRT
: 1; // Valid RAM and Time
138 } RTC_REGISTER_D_BITS
;
141 RTC_REGISTER_D_BITS Bits
;
149 IN PC_RTC_MODULE_GLOBALS
*Global
155 TODO: Add function description
159 Global - TODO: add argument description
163 TODO: add return values
171 IN PC_RTC_MODULE_GLOBALS
*Global
177 TODO: Add function description
181 Time - TODO: add argument description
182 Global - TODO: add argument description
186 TODO: add return values
194 IN EFI_TIME_CAPABILITIES
*Capabilities
,
195 IN PC_RTC_MODULE_GLOBALS
*Global
201 TODO: Add function description
205 Time - TODO: add argument description
206 Capabilities - TODO: add argument description
207 Global - TODO: add argument description
211 TODO: add return values
221 IN PC_RTC_MODULE_GLOBALS
*Global
227 TODO: Add function description
231 Enable - TODO: add argument description
232 Time - TODO: add argument description
233 Global - TODO: add argument description
237 TODO: add return values
245 OUT BOOLEAN
*Enabled
,
246 OUT BOOLEAN
*Pending
,
248 IN PC_RTC_MODULE_GLOBALS
*Global
254 TODO: Add function description
258 Enabled - TODO: add argument description
259 Pending - TODO: add argument description
260 Time - TODO: add argument description
261 Global - TODO: add argument description
265 TODO: add return values
273 IN EFI_HANDLE ImageHandle
,
274 IN EFI_SYSTEM_TABLE
*SystemTable
280 TODO: Add function description
284 ImageHandle - TODO: add argument description
285 SystemTable - TODO: add argument description
289 TODO: add return values
302 TODO: Add function description
306 BcdValue - TODO: add argument description
310 TODO: add return values
323 TODO: Add function description
327 Time - TODO: add argument description
331 TODO: add return values
344 TODO: Add function description
348 DecValue - TODO: add argument description
352 TODO: add return values
358 ConvertEfiTimeToRtcTime (
360 IN RTC_REGISTER_B RegisterB
,
367 TODO: Add function description
371 Time - TODO: add argument description
372 RegisterB - TODO: add argument description
373 Century - TODO: add argument description
377 TODO: add return values
383 RtcTestCenturyRegister (
390 TODO: Add function description
398 TODO: add return values
404 ConvertRtcTimeToEfiTime (
406 IN RTC_REGISTER_B RegisterB
412 TODO: Add function description
416 Time - TODO: add argument description
417 RegisterB - TODO: add argument description
421 TODO: add return values
434 TODO: Add function description
438 Timeout - TODO: add argument description
442 TODO: add return values
449 IN PC_RTC_MODULE_GLOBALS
*Global
455 TODO: Add function description
459 Global - TODO: add argument description
463 TODO: add return values
470 IN UINT8 SavedAddressRegister
,
471 IN PC_RTC_MODULE_GLOBALS
*Global
477 TODO: Add function description
481 SavedAddressRegister - TODO: add argument description
482 Global - TODO: add argument description
486 TODO: add return values