2 RTC Architectural Protocol GUID as defined in DxeCis 0.96.
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.
40 GC_TODO: Add function description
44 Address - GC_TODO: add argument description
48 GC_TODO: add return values
52 IoWrite8 (PCAT_RTC_ADDRESS_REGISTER
, (UINT8
) (Address
| (UINT8
) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER
) & 0x80)));
53 return IoRead8 (PCAT_RTC_DATA_REGISTER
);
66 GC_TODO: Add function description
70 Address - GC_TODO: add argument description
71 Data - GC_TODO: add argument description
75 GC_TODO: add return values
79 IoWrite8 (PCAT_RTC_ADDRESS_REGISTER
, (UINT8
) (Address
| (UINT8
) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER
) & 0x80)));
80 IoWrite8 (PCAT_RTC_DATA_REGISTER
, Data
);
85 IN PC_RTC_MODULE_GLOBALS
*Global
91 GC_TODO: Add function description
95 Global - GC_TODO: add argument description
99 EFI_DEVICE_ERROR - GC_TODO: Add description for return value
100 EFI_SUCCESS - GC_TODO: Add description for return value
105 RTC_REGISTER_A RegisterA
;
106 RTC_REGISTER_B RegisterB
;
107 RTC_REGISTER_D RegisterD
;
114 // Acquire RTC Lock to make access to RTC atomic
116 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
117 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
118 if (!EfiAtRuntime ()) {
119 EfiAcquireLock (&Global
->RtcLock
);
122 // Initialize RTC Register
124 // Make sure Division Chain is properly configured,
125 // or RTC clock won't "tick" -- time won't increment
127 RegisterA
.Data
= RTC_INIT_REGISTER_A
;
128 RtcWrite (RTC_ADDRESS_REGISTER_A
, RegisterA
.Data
);
133 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
136 // Clear RTC flag register
138 RtcRead (RTC_ADDRESS_REGISTER_C
);
141 // Clear RTC register D
143 RegisterD
.Data
= RTC_INIT_REGISTER_D
;
144 RtcWrite (RTC_ADDRESS_REGISTER_D
, RegisterD
.Data
);
147 // Wait for up to 0.1 seconds for the RTC to be updated
149 Status
= RtcWaitToUpdate (100000);
150 if (EFI_ERROR (Status
)) {
151 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
152 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
153 if (!EfiAtRuntime ()) {
154 EfiReleaseLock (&Global
->RtcLock
);
156 return EFI_DEVICE_ERROR
;
159 // Get the Time/Date/Daylight Savings values.
161 Time
.Second
= RtcRead (RTC_ADDRESS_SECONDS
);
162 Time
.Minute
= RtcRead (RTC_ADDRESS_MINUTES
);
163 Time
.Hour
= RtcRead (RTC_ADDRESS_HOURS
);
164 Time
.Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
165 Time
.Month
= RtcRead (RTC_ADDRESS_MONTH
);
166 Time
.Year
= RtcRead (RTC_ADDRESS_YEAR
);
168 ConvertRtcTimeToEfiTime (&Time
, RegisterB
);
170 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
171 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
173 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
176 Time
.Year
= (UINT16
) (Century
* 100 + Time
.Year
);
179 // Set RTC configuration after get original time
180 // The value of bit AIE should be reserved.
182 RtcWrite (RTC_ADDRESS_REGISTER_B
, (UINT8
)(RTC_INIT_REGISTER_B
| (RegisterB
.Data
& BIT5
)));
187 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
188 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
189 if (!EfiAtRuntime ()) {
190 EfiReleaseLock (&Global
->RtcLock
);
193 // Validate time fields
195 Status
= RtcTimeFieldsValid (&Time
);
196 if (EFI_ERROR (Status
)) {
197 Time
.Second
= RTC_INIT_SECOND
;
198 Time
.Minute
= RTC_INIT_MINUTE
;
199 Time
.Hour
= RTC_INIT_HOUR
;
200 Time
.Day
= RTC_INIT_DAY
;
201 Time
.Month
= RTC_INIT_MONTH
;
202 Time
.Year
= RTC_INIT_YEAR
;
205 // Get the data of Daylight saving and time zone, if they have been
206 // stored in NV variable during previous boot.
208 DataSize
= sizeof (UINT32
);
209 Status
= EfiGetVariable (
211 &gEfiGenericPlatformVariableGuid
,
216 if (!EFI_ERROR (Status
)) {
217 Global
->SavedTimeZone
= (INT16
) TimerVar
;
218 Global
->Daylight
= (UINT8
) (TimerVar
>> 16);
220 Time
.TimeZone
= Global
->SavedTimeZone
;
221 Time
.Daylight
= Global
->Daylight
;
224 // Reset time value according to new RTC configuration
226 PcRtcSetTime (&Time
, Global
);
234 IN EFI_TIME_CAPABILITIES
*Capabilities
,
235 IN PC_RTC_MODULE_GLOBALS
*Global
245 // GC_TODO: Time - add argument and description to function comment
246 // GC_TODO: Capabilities - add argument and description to function comment
247 // GC_TODO: Global - add argument and description to function comment
248 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
249 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
250 // GC_TODO: EFI_SUCCESS - add return value to function comment
253 RTC_REGISTER_B RegisterB
;
257 // Check parameters for null pointer
260 return EFI_INVALID_PARAMETER
;
264 // Acquire RTC Lock to make access to RTC atomic
266 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
267 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
268 if (!EfiAtRuntime ()) {
269 EfiAcquireLock (&Global
->RtcLock
);
272 // Wait for up to 0.1 seconds for the RTC to be updated
274 Status
= RtcWaitToUpdate (100000);
275 if (EFI_ERROR (Status
)) {
276 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
277 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
278 if (!EfiAtRuntime ()) {
279 EfiReleaseLock (&Global
->RtcLock
);
286 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
289 // Get the Time/Date/Daylight Savings values.
291 Time
->Second
= RtcRead (RTC_ADDRESS_SECONDS
);
292 Time
->Minute
= RtcRead (RTC_ADDRESS_MINUTES
);
293 Time
->Hour
= RtcRead (RTC_ADDRESS_HOURS
);
294 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
295 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
296 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
298 ConvertRtcTimeToEfiTime (Time
, RegisterB
);
300 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
301 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
303 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
306 Time
->Year
= (UINT16
) (Century
* 100 + Time
->Year
);
311 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
312 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
313 if (!EfiAtRuntime ()) {
314 EfiReleaseLock (&Global
->RtcLock
);
317 // Get the variable that containts the TimeZone and Daylight fields
319 Time
->TimeZone
= Global
->SavedTimeZone
;
320 Time
->Daylight
= Global
->Daylight
;
323 // Make sure all field values are in correct range
325 Status
= RtcTimeFieldsValid (Time
);
326 if (EFI_ERROR (Status
)) {
327 return EFI_DEVICE_ERROR
;
330 // Fill in Capabilities if it was passed in
333 Capabilities
->Resolution
= 1;
337 Capabilities
->Accuracy
= 50000000;
341 Capabilities
->SetsToZero
= FALSE
;
350 IN PC_RTC_MODULE_GLOBALS
*Global
360 // GC_TODO: Time - add argument and description to function comment
361 // GC_TODO: Global - add argument and description to function comment
362 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
366 RTC_REGISTER_B RegisterB
;
371 return EFI_INVALID_PARAMETER
;
374 // Make sure that the time fields are valid
376 Status
= RtcTimeFieldsValid (Time
);
377 if (EFI_ERROR (Status
)) {
381 CopyMem (&RtcTime
, Time
, sizeof (EFI_TIME
));
384 // Acquire RTC Lock to make access to RTC atomic
386 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
387 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
388 if (!EfiAtRuntime ()) {
389 EfiAcquireLock (&Global
->RtcLock
);
392 // Wait for up to 0.1 seconds for the RTC to be updated
394 Status
= RtcWaitToUpdate (100000);
395 if (EFI_ERROR (Status
)) {
396 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
397 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
398 if (!EfiAtRuntime ()) {
399 EfiReleaseLock (&Global
->RtcLock
);
404 // Read Register B, and inhibit updates of the RTC
406 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
407 RegisterB
.Bits
.SET
= 1;
408 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
410 ConvertEfiTimeToRtcTime (&RtcTime
, RegisterB
, &Century
);
412 RtcWrite (RTC_ADDRESS_SECONDS
, RtcTime
.Second
);
413 RtcWrite (RTC_ADDRESS_MINUTES
, RtcTime
.Minute
);
414 RtcWrite (RTC_ADDRESS_HOURS
, RtcTime
.Hour
);
415 RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH
, RtcTime
.Day
);
416 RtcWrite (RTC_ADDRESS_MONTH
, RtcTime
.Month
);
417 RtcWrite (RTC_ADDRESS_YEAR
, (UINT8
) RtcTime
.Year
);
418 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
419 Century
= (UINT8
) ((Century
& 0x7f) | (RtcRead (RTC_ADDRESS_CENTURY
) & 0x80));
422 RtcWrite (RTC_ADDRESS_CENTURY
, Century
);
425 // Allow updates of the RTC registers
427 RegisterB
.Bits
.SET
= 0;
428 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
433 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
434 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
435 if (!EfiAtRuntime ()) {
436 EfiReleaseLock (&Global
->RtcLock
);
439 // Set the variable that containts the TimeZone and Daylight fields
441 Global
->SavedTimeZone
= Time
->TimeZone
;
442 Global
->Daylight
= Time
->Daylight
;
444 TimerVar
= Time
->Daylight
;
445 TimerVar
= (UINT32
) ((TimerVar
<< 16) | Time
->TimeZone
);
446 Status
= EfiSetVariable (
448 &gEfiGenericPlatformVariableGuid
,
449 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
453 ASSERT_EFI_ERROR (Status
);
460 OUT BOOLEAN
*Enabled
,
461 OUT BOOLEAN
*Pending
,
463 IN PC_RTC_MODULE_GLOBALS
*Global
475 // GC_TODO: Enabled - add argument and description to function comment
476 // GC_TODO: Pending - add argument and description to function comment
477 // GC_TODO: Time - add argument and description to function comment
478 // GC_TODO: Global - add argument and description to function comment
479 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
480 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
481 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
482 // GC_TODO: EFI_SUCCESS - add return value to function comment
485 RTC_REGISTER_B RegisterB
;
486 RTC_REGISTER_C RegisterC
;
490 // Check paramters for null pointers
492 if ((Enabled
== NULL
) || (Pending
== NULL
) || (Time
== NULL
)) {
493 return EFI_INVALID_PARAMETER
;
497 // Acquire RTC Lock to make access to RTC atomic
499 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
500 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
501 if (!EfiAtRuntime ()) {
502 EfiAcquireLock (&Global
->RtcLock
);
505 // Wait for up to 0.1 seconds for the RTC to be updated
507 Status
= RtcWaitToUpdate (100000);
508 if (EFI_ERROR (Status
)) {
509 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
510 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
511 if (!EfiAtRuntime ()) {
512 EfiReleaseLock (&Global
->RtcLock
);
514 return EFI_DEVICE_ERROR
;
517 // Read Register B and Register C
519 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
520 RegisterC
.Data
= RtcRead (RTC_ADDRESS_REGISTER_C
);
523 // Get the Time/Date/Daylight Savings values.
525 *Enabled
= RegisterB
.Bits
.AIE
;
527 Time
->Second
= RtcRead (RTC_ADDRESS_SECONDS_ALARM
);
528 Time
->Minute
= RtcRead (RTC_ADDRESS_MINUTES_ALARM
);
529 Time
->Hour
= RtcRead (RTC_ADDRESS_HOURS_ALARM
);
530 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
531 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
532 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
537 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
538 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
539 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
542 ConvertRtcTimeToEfiTime (Time
, RegisterB
);
544 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
545 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
547 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
550 Time
->Year
= (UINT16
) (Century
* 100 + Time
->Year
);
555 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
556 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
557 if (!EfiAtRuntime ()) {
558 EfiReleaseLock (&Global
->RtcLock
);
561 // Make sure all field values are in correct range
563 Status
= RtcTimeFieldsValid (Time
);
564 if (EFI_ERROR (Status
)) {
565 return EFI_DEVICE_ERROR
;
568 *Pending
= RegisterC
.Bits
.AF
;
577 IN PC_RTC_MODULE_GLOBALS
*Global
589 // GC_TODO: Enable - add argument and description to function comment
590 // GC_TODO: Time - add argument and description to function comment
591 // GC_TODO: Global - add argument and description to function comment
592 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
593 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
594 // GC_TODO: EFI_UNSUPPORTED - add return value to function comment
595 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
596 // GC_TODO: EFI_SUCCESS - add return value to function comment
600 RTC_REGISTER_B RegisterB
;
602 EFI_TIME_CAPABILITIES Capabilities
;
607 return EFI_INVALID_PARAMETER
;
610 // Make sure that the time fields are valid
612 Status
= RtcTimeFieldsValid (Time
);
613 if (EFI_ERROR (Status
)) {
614 return EFI_INVALID_PARAMETER
;
617 // Just support set alarm time within 24 hours
619 PcRtcGetTime (&RtcTime
, &Capabilities
, Global
);
620 if (!IsWithinOneDay (&RtcTime
, Time
)) {
621 return EFI_UNSUPPORTED
;
624 // Make a local copy of the time and date
626 CopyMem (&RtcTime
, Time
, sizeof (EFI_TIME
));
630 // Acquire RTC Lock to make access to RTC atomic
632 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
633 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
634 if (!EfiAtRuntime ()) {
635 EfiAcquireLock (&Global
->RtcLock
);
638 // Wait for up to 0.1 seconds for the RTC to be updated
640 Status
= RtcWaitToUpdate (100000);
641 if (EFI_ERROR (Status
)) {
642 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
643 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
644 if (!EfiAtRuntime ()) {
645 EfiReleaseLock (&Global
->RtcLock
);
647 return EFI_DEVICE_ERROR
;
650 // Read Register B, and inhibit updates of the RTC
652 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
654 RegisterB
.Bits
.SET
= 1;
655 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
658 ConvertEfiTimeToRtcTime (&RtcTime
, RegisterB
, &Century
);
661 // Set RTC alarm time
663 RtcWrite (RTC_ADDRESS_SECONDS_ALARM
, RtcTime
.Second
);
664 RtcWrite (RTC_ADDRESS_MINUTES_ALARM
, RtcTime
.Minute
);
665 RtcWrite (RTC_ADDRESS_HOURS_ALARM
, RtcTime
.Hour
);
667 RegisterB
.Bits
.AIE
= 1;
670 RegisterB
.Bits
.AIE
= 0;
673 // Allow updates of the RTC registers
675 RegisterB
.Bits
.SET
= 0;
676 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
681 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
682 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
683 if (!EfiAtRuntime ()) {
684 EfiReleaseLock (&Global
->RtcLock
);
690 RtcTestCenturyRegister (
703 // GC_TODO: EFI_SUCCESS - add return value to function comment
704 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
709 Century
= RtcRead (RTC_ADDRESS_CENTURY
);
711 // RtcWrite (RTC_ADDRESS_CENTURY, 0x00);
713 Temp
= (UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f);
714 RtcWrite (RTC_ADDRESS_CENTURY
, Century
);
715 if (Temp
== 0x19 || Temp
== 0x20) {
719 return EFI_DEVICE_ERROR
;
723 ConvertRtcTimeToEfiTime (
725 IN RTC_REGISTER_B RegisterB
737 // GC_TODO: Time - add argument and description to function comment
738 // GC_TODO: RegisterB - add argument and description to function comment
742 if ((Time
->Hour
) & 0x80) {
748 Time
->Hour
= (UINT8
) (Time
->Hour
& 0x7f);
750 if (RegisterB
.Bits
.DM
== 0) {
751 Time
->Year
= BcdToDecimal8 ((UINT8
) Time
->Year
);
752 Time
->Month
= BcdToDecimal8 (Time
->Month
);
753 Time
->Day
= BcdToDecimal8 (Time
->Day
);
754 Time
->Hour
= BcdToDecimal8 (Time
->Hour
);
755 Time
->Minute
= BcdToDecimal8 (Time
->Minute
);
756 Time
->Second
= BcdToDecimal8 (Time
->Second
);
759 // If time is in 12 hour format, convert it to 24 hour format
761 if (RegisterB
.Bits
.MIL
== 0) {
762 if (PM
&& Time
->Hour
< 12) {
763 Time
->Hour
= (UINT8
) (Time
->Hour
+ 12);
766 if (!PM
&& Time
->Hour
== 12) {
771 Time
->Nanosecond
= 0;
772 Time
->TimeZone
= EFI_UNSPECIFIED_TIMEZONE
;
789 // GC_TODO: Timeout - add argument and description to function comment
790 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
791 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
792 // GC_TODO: EFI_SUCCESS - add return value to function comment
794 RTC_REGISTER_A RegisterA
;
795 RTC_REGISTER_D RegisterD
;
798 // See if the RTC is functioning correctly
800 RegisterD
.Data
= RtcRead (RTC_ADDRESS_REGISTER_D
);
802 if (RegisterD
.Bits
.VRT
== 0) {
803 return EFI_DEVICE_ERROR
;
806 // Wait for up to 0.1 seconds for the RTC to be ready.
808 Timeout
= (Timeout
/ 10) + 1;
809 RegisterA
.Data
= RtcRead (RTC_ADDRESS_REGISTER_A
);
810 while (RegisterA
.Bits
.UIP
== 1 && Timeout
> 0) {
811 MicroSecondDelay (10);
812 RegisterA
.Data
= RtcRead (RTC_ADDRESS_REGISTER_A
);
816 RegisterD
.Data
= RtcRead (RTC_ADDRESS_REGISTER_D
);
817 if (Timeout
== 0 || RegisterD
.Bits
.VRT
== 0) {
818 return EFI_DEVICE_ERROR
;
836 // GC_TODO: Time - add argument and description to function comment
837 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
838 // GC_TODO: EFI_SUCCESS - add return value to function comment
840 if (Time
->Year
< 1998 ||
844 (!DayValid (Time
)) ||
848 Time
->Nanosecond
> 999999999 ||
849 (!(Time
->TimeZone
== EFI_UNSPECIFIED_TIMEZONE
|| (Time
->TimeZone
>= -1440 && Time
->TimeZone
<= 1440))) ||
850 (Time
->Daylight
& (~(EFI_TIME_ADJUST_DAYLIGHT
| EFI_TIME_IN_DAYLIGHT
)))
852 return EFI_INVALID_PARAMETER
;
866 GC_TODO: Add function description
870 Time - GC_TODO: add argument description
874 GC_TODO: add return values
894 Time
->Day
> DayOfMonth
[Time
->Month
- 1] ||
895 (Time
->Month
== 2 && (!IsLeapYear (Time
) && Time
->Day
> 28))
911 GC_TODO: Add function description
915 Time - GC_TODO: add argument description
919 GC_TODO: add return values
923 if (Time
->Year
% 4 == 0) {
924 if (Time
->Year
% 100 == 0) {
925 if (Time
->Year
% 400 == 0) {
939 ConvertEfiTimeToRtcTime (
941 IN RTC_REGISTER_B RegisterB
,
953 // GC_TODO: Time - add argument and description to function comment
954 // GC_TODO: RegisterB - add argument and description to function comment
955 // GC_TODO: Century - add argument and description to function comment
961 // Adjust hour field if RTC in in 12 hour mode
963 if (RegisterB
.Bits
.MIL
== 0) {
964 if (Time
->Hour
< 12) {
968 if (Time
->Hour
>= 13) {
969 Time
->Hour
= (UINT8
) (Time
->Hour
- 12);
970 } else if (Time
->Hour
== 0) {
975 // Set the Time/Date/Daylight Savings values.
977 *Century
= DecimalToBcd8 ((UINT8
) (Time
->Year
/ 100));
979 Time
->Year
= (UINT16
) (Time
->Year
% 100);
981 if (RegisterB
.Bits
.DM
== 0) {
982 Time
->Year
= DecimalToBcd8 ((UINT8
) Time
->Year
);
983 Time
->Month
= DecimalToBcd8 (Time
->Month
);
984 Time
->Day
= DecimalToBcd8 (Time
->Day
);
985 Time
->Hour
= DecimalToBcd8 (Time
->Hour
);
986 Time
->Minute
= DecimalToBcd8 (Time
->Minute
);
987 Time
->Second
= DecimalToBcd8 (Time
->Second
);
990 // If we are in 12 hour mode and PM is set, then set bit 7 of the Hour field.
992 if (RegisterB
.Bits
.MIL
== 0 && PM
) {
993 Time
->Hour
= (UINT8
) (Time
->Hour
| 0x80);
1005 Routine Description:
1007 Compare the Hour, Minute and Second of the 'From' time and the 'To' time.
1008 Only compare H/M/S in EFI_TIME and ignore other fields here.
1012 From - the first time
1013 To - the second time
1017 >0 : The H/M/S of the 'From' time is later than those of 'To' time
1018 ==0 : The H/M/S of the 'From' time is same as those of 'To' time
1019 <0 : The H/M/S of the 'From' time is earlier than those of 'To' time
1023 if ((From
->Hour
> To
->Hour
) ||
1024 ((From
->Hour
== To
->Hour
) && (From
->Minute
> To
->Minute
)) ||
1025 ((From
->Hour
== To
->Hour
) && (From
->Minute
== To
->Minute
) && (From
->Second
> To
->Second
))) {
1027 } else if ((From
->Hour
== To
->Hour
) && (From
->Minute
== To
->Minute
) && (From
->Second
== To
->Second
)) {
1042 Routine Description:
1044 Judge whether two days are adjacent.
1048 From - the first day
1053 TRUE - The interval of two days are within one day.
1054 FALSE - The interval of two days exceed ony day or parameter error.
1058 UINT8 DayOfMonth
[12];
1071 DayOfMonth
[10] = 30;
1072 DayOfMonth
[11] = 31;
1076 if (From
->Year
== To
->Year
) {
1077 if (From
->Month
== To
->Month
) {
1078 if ((From
->Day
+ 1) == To
->Day
) {
1079 if ((CompareHMS(From
, To
) >= 0)) {
1082 } else if (From
->Day
== To
->Day
) {
1083 if ((CompareHMS(From
, To
) <= 0)) {
1087 } else if (((From
->Month
+ 1) == To
->Month
) && (To
->Day
== 1)) {
1088 if ((From
->Month
== 2) && !IsLeapYear(From
)) {
1089 if (From
->Day
== 28) {
1090 if ((CompareHMS(From
, To
) >= 0)) {
1094 } else if (From
->Day
== DayOfMonth
[From
->Month
- 1]) {
1095 if ((CompareHMS(From
, To
) >= 0)) {
1100 } else if (((From
->Year
+ 1) == To
->Year
) &&
1101 (From
->Month
== 12) &&
1102 (From
->Day
== 31) &&
1105 if ((CompareHMS(From
, To
) >= 0)) {