]> git.proxmox.com Git - mirror_edk2.git/blob - PcAtChipsetPkg/PcRtc/RealTimeClock.h
supply comments on data structure to follow spec.
[mirror_edk2.git] / PcAtChipsetPkg / PcRtc / RealTimeClock.h
1 /*++
2
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
8
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.
11
12 Module Name:
13 PcRtc.h
14
15 Abstract:
16
17 Include for real time clock driver
18
19 Revision History
20
21
22 --*/
23
24 #ifndef _RTC_H_
25 #define _RTC_H_
26
27 #include <FrameworkDxe.h>
28
29 #include <Protocol/RealTimeClock.h>
30
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>
36
37 typedef struct {
38 EFI_LOCK RtcLock;
39 UINT16 SavedTimeZone;
40 UINT8 Daylight;
41 } PC_RTC_MODULE_GLOBALS;
42
43 #define PCAT_RTC_ADDRESS_REGISTER 0x70
44 #define PCAT_RTC_DATA_REGISTER 0x71
45
46 //
47 // Dallas DS12C887 Real Time Clock
48 //
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
64 //
65 // Date and time initial values.
66 // They are used if the RTC values are invalid during driver initialization
67 //
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
74
75 //
76 // Register initial values
77 //
78 #define RTC_INIT_REGISTER_A 0x26
79 #define RTC_INIT_REGISTER_B 0x02
80 #define RTC_INIT_REGISTER_D 0x0
81
82 #pragma pack(1)
83 //
84 // Register A
85 //
86 typedef struct {
87 UINT8 RS : 4; // Rate Selection Bits
88 UINT8 DV : 3; // Divisor
89 UINT8 UIP : 1; // Update in progress
90 } RTC_REGISTER_A_BITS;
91
92 typedef union {
93 RTC_REGISTER_A_BITS Bits;
94 UINT8 Data;
95 } RTC_REGISTER_A;
96
97 //
98 // Register B
99 //
100 typedef struct {
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;
110
111 typedef union {
112 RTC_REGISTER_B_BITS Bits;
113 UINT8 Data;
114 } RTC_REGISTER_B;
115
116 //
117 // Register C
118 //
119 typedef struct {
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;
126
127 typedef union {
128 RTC_REGISTER_C_BITS Bits;
129 UINT8 Data;
130 } RTC_REGISTER_C;
131
132 //
133 // Register D
134 //
135 typedef struct {
136 UINT8 Reserved : 7; // Read as zero. Can not be written.
137 UINT8 VRT : 1; // Valid RAM and Time
138 } RTC_REGISTER_D_BITS;
139
140 typedef union {
141 RTC_REGISTER_D_BITS Bits;
142 UINT8 Data;
143 } RTC_REGISTER_D;
144
145 #pragma pack()
146
147 EFI_STATUS
148 PcRtcInit (
149 IN PC_RTC_MODULE_GLOBALS *Global
150 )
151 /*++
152
153 Routine Description:
154
155 TODO: Add function description
156
157 Arguments:
158
159 Global - TODO: add argument description
160
161 Returns:
162
163 TODO: add return values
164
165 --*/
166 ;
167
168 EFI_STATUS
169 PcRtcSetTime (
170 IN EFI_TIME *Time,
171 IN PC_RTC_MODULE_GLOBALS *Global
172 )
173 /*++
174
175 Routine Description:
176
177 TODO: Add function description
178
179 Arguments:
180
181 Time - TODO: add argument description
182 Global - TODO: add argument description
183
184 Returns:
185
186 TODO: add return values
187
188 --*/
189 ;
190
191 EFI_STATUS
192 PcRtcGetTime (
193 OUT EFI_TIME *Time,
194 IN EFI_TIME_CAPABILITIES *Capabilities,
195 IN PC_RTC_MODULE_GLOBALS *Global
196 )
197 /*++
198
199 Routine Description:
200
201 TODO: Add function description
202
203 Arguments:
204
205 Time - TODO: add argument description
206 Capabilities - TODO: add argument description
207 Global - TODO: add argument description
208
209 Returns:
210
211 TODO: add return values
212
213 --*/
214 ;
215
216 EFI_STATUS
217 EFIAPI
218 PcRtcSetWakeupTime (
219 IN BOOLEAN Enable,
220 OUT EFI_TIME *Time,
221 IN PC_RTC_MODULE_GLOBALS *Global
222 )
223 /*++
224
225 Routine Description:
226
227 TODO: Add function description
228
229 Arguments:
230
231 Enable - TODO: add argument description
232 Time - TODO: add argument description
233 Global - TODO: add argument description
234
235 Returns:
236
237 TODO: add return values
238
239 --*/
240 ;
241
242 EFI_STATUS
243 EFIAPI
244 PcRtcGetWakeupTime (
245 OUT BOOLEAN *Enabled,
246 OUT BOOLEAN *Pending,
247 OUT EFI_TIME *Time,
248 IN PC_RTC_MODULE_GLOBALS *Global
249 )
250 /*++
251
252 Routine Description:
253
254 TODO: Add function description
255
256 Arguments:
257
258 Enabled - TODO: add argument description
259 Pending - TODO: add argument description
260 Time - TODO: add argument description
261 Global - TODO: add argument description
262
263 Returns:
264
265 TODO: add return values
266
267 --*/
268 ;
269
270 EFI_STATUS
271 EFIAPI
272 InitializePcRtc (
273 IN EFI_HANDLE ImageHandle,
274 IN EFI_SYSTEM_TABLE *SystemTable
275 )
276 /*++
277
278 Routine Description:
279
280 TODO: Add function description
281
282 Arguments:
283
284 ImageHandle - TODO: add argument description
285 SystemTable - TODO: add argument description
286
287 Returns:
288
289 TODO: add return values
290
291 --*/
292 ;
293
294 EFI_STATUS
295 RtcTimeFieldsValid (
296 IN EFI_TIME *Time
297 )
298 /*++
299
300 Routine Description:
301
302 TODO: Add function description
303
304 Arguments:
305
306 Time - TODO: add argument description
307
308 Returns:
309
310 TODO: add return values
311
312 --*/
313 ;
314
315 UINT8
316 DecimaltoBcd (
317 IN UINT8 DecValue
318 )
319 /*++
320
321 Routine Description:
322
323 TODO: Add function description
324
325 Arguments:
326
327 DecValue - TODO: add argument description
328
329 Returns:
330
331 TODO: add return values
332
333 --*/
334 ;
335
336 VOID
337 ConvertEfiTimeToRtcTime (
338 IN EFI_TIME *Time,
339 IN RTC_REGISTER_B RegisterB,
340 IN UINT8 *Century
341 )
342 /*++
343
344 Routine Description:
345
346 TODO: Add function description
347
348 Arguments:
349
350 Time - TODO: add argument description
351 RegisterB - TODO: add argument description
352 Century - TODO: add argument description
353
354 Returns:
355
356 TODO: add return values
357
358 --*/
359 ;
360
361 VOID
362 ConvertRtcTimeToEfiTime (
363 IN EFI_TIME *Time,
364 IN RTC_REGISTER_B RegisterB
365 )
366 /*++
367
368 Routine Description:
369
370 TODO: Add function description
371
372 Arguments:
373
374 Time - TODO: add argument description
375 RegisterB - TODO: add argument description
376
377 Returns:
378
379 TODO: add return values
380
381 --*/
382 ;
383
384 EFI_STATUS
385 RtcWaitToUpdate (
386 UINTN Timeout
387 )
388 /*++
389
390 Routine Description:
391
392 TODO: Add function description
393
394 Arguments:
395
396 Timeout - TODO: add argument description
397
398 Returns:
399
400 TODO: add return values
401
402 --*/
403 ;
404
405 UINT8
406 RtcSaveContext (
407 IN PC_RTC_MODULE_GLOBALS *Global
408 )
409 /*++
410
411 Routine Description:
412
413 TODO: Add function description
414
415 Arguments:
416
417 Global - TODO: add argument description
418
419 Returns:
420
421 TODO: add return values
422
423 --*/
424 ;
425
426 VOID
427 RtcRestoreContext (
428 IN UINT8 SavedAddressRegister,
429 IN PC_RTC_MODULE_GLOBALS *Global
430 )
431 /*++
432
433 Routine Description:
434
435 TODO: Add function description
436
437 Arguments:
438
439 SavedAddressRegister - TODO: add argument description
440 Global - TODO: add argument description
441
442 Returns:
443
444 TODO: add return values
445
446 --*/
447 ;
448
449 #endif