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
;
112 // Acquire RTC Lock to make access to RTC atomic
114 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
115 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
116 if (!EfiAtRuntime ()) {
117 EfiAcquireLock (&Global
->RtcLock
);
120 // Initialize RTC Register
122 // Make sure Division Chain is properly configured,
123 // or RTC clock won't "tick" -- time won't increment
125 RegisterA
.Data
= RTC_INIT_REGISTER_A
;
126 RtcWrite (RTC_ADDRESS_REGISTER_A
, RegisterA
.Data
);
131 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
134 // Clear RTC flag register
136 RtcRead (RTC_ADDRESS_REGISTER_C
);
139 // Clear RTC register D
141 RegisterD
.Data
= RTC_INIT_REGISTER_D
;
142 RtcWrite (RTC_ADDRESS_REGISTER_D
, RegisterD
.Data
);
145 // Wait for up to 0.1 seconds for the RTC to be updated
147 Status
= RtcWaitToUpdate (100000);
148 if (EFI_ERROR (Status
)) {
149 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
150 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
151 if (!EfiAtRuntime ()) {
152 EfiReleaseLock (&Global
->RtcLock
);
154 return EFI_DEVICE_ERROR
;
157 // Get the Time/Date/Daylight Savings values.
159 Time
.Second
= RtcRead (RTC_ADDRESS_SECONDS
);
160 Time
.Minute
= RtcRead (RTC_ADDRESS_MINUTES
);
161 Time
.Hour
= RtcRead (RTC_ADDRESS_HOURS
);
162 Time
.Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
163 Time
.Month
= RtcRead (RTC_ADDRESS_MONTH
);
164 Time
.Year
= RtcRead (RTC_ADDRESS_YEAR
);
166 ConvertRtcTimeToEfiTime (&Time
, RegisterB
);
168 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
169 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
171 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
174 Time
.Year
= (UINT16
) (Century
* 100 + Time
.Year
);
177 // Set RTC configuration after get original time
179 RtcWrite (RTC_ADDRESS_REGISTER_B
, RTC_INIT_REGISTER_B
);
184 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
185 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
186 if (!EfiAtRuntime ()) {
187 EfiReleaseLock (&Global
->RtcLock
);
190 // Validate time fields
192 Status
= RtcTimeFieldsValid (&Time
);
193 if (EFI_ERROR (Status
)) {
194 Time
.Second
= RTC_INIT_SECOND
;
195 Time
.Minute
= RTC_INIT_MINUTE
;
196 Time
.Hour
= RTC_INIT_HOUR
;
197 Time
.Day
= RTC_INIT_DAY
;
198 Time
.Month
= RTC_INIT_MONTH
;
199 Time
.Year
= RTC_INIT_YEAR
;
202 // Reset time value according to new RTC configuration
204 PcRtcSetTime (&Time
, Global
);
212 IN EFI_TIME_CAPABILITIES
*Capabilities
,
213 IN PC_RTC_MODULE_GLOBALS
*Global
223 // GC_TODO: Time - add argument and description to function comment
224 // GC_TODO: Capabilities - add argument and description to function comment
225 // GC_TODO: Global - add argument and description to function comment
226 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
227 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
228 // GC_TODO: EFI_SUCCESS - add return value to function comment
231 RTC_REGISTER_B RegisterB
;
235 // Check parameters for null pointer
238 return EFI_INVALID_PARAMETER
;
242 // Acquire RTC Lock to make access to RTC atomic
244 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
245 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
246 if (!EfiAtRuntime ()) {
247 EfiAcquireLock (&Global
->RtcLock
);
250 // Wait for up to 0.1 seconds for the RTC to be updated
252 Status
= RtcWaitToUpdate (100000);
253 if (EFI_ERROR (Status
)) {
254 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
255 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
256 if (!EfiAtRuntime ()) {
257 EfiReleaseLock (&Global
->RtcLock
);
264 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
267 // Get the Time/Date/Daylight Savings values.
269 Time
->Second
= RtcRead (RTC_ADDRESS_SECONDS
);
270 Time
->Minute
= RtcRead (RTC_ADDRESS_MINUTES
);
271 Time
->Hour
= RtcRead (RTC_ADDRESS_HOURS
);
272 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
273 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
274 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
276 ConvertRtcTimeToEfiTime (Time
, RegisterB
);
278 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
279 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
281 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
284 Time
->Year
= (UINT16
) (Century
* 100 + Time
->Year
);
289 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
290 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
291 if (!EfiAtRuntime ()) {
292 EfiReleaseLock (&Global
->RtcLock
);
295 // Get the variable that containts the TimeZone and Daylight fields
297 Time
->TimeZone
= Global
->SavedTimeZone
;
298 Time
->Daylight
= Global
->Daylight
;
301 // Make sure all field values are in correct range
303 Status
= RtcTimeFieldsValid (Time
);
304 if (EFI_ERROR (Status
)) {
305 return EFI_DEVICE_ERROR
;
308 // Fill in Capabilities if it was passed in
311 Capabilities
->Resolution
= 1;
315 Capabilities
->Accuracy
= 50000000;
319 Capabilities
->SetsToZero
= FALSE
;
328 IN PC_RTC_MODULE_GLOBALS
*Global
338 // GC_TODO: Time - add argument and description to function comment
339 // GC_TODO: Global - add argument and description to function comment
340 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
344 RTC_REGISTER_B RegisterB
;
348 return EFI_INVALID_PARAMETER
;
351 // Make sure that the time fields are valid
353 Status
= RtcTimeFieldsValid (Time
);
354 if (EFI_ERROR (Status
)) {
358 CopyMem (&RtcTime
, Time
, sizeof (EFI_TIME
));
361 // Acquire RTC Lock to make access to RTC atomic
363 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
364 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
365 if (!EfiAtRuntime ()) {
366 EfiAcquireLock (&Global
->RtcLock
);
369 // Wait for up to 0.1 seconds for the RTC to be updated
371 Status
= RtcWaitToUpdate (100000);
372 if (EFI_ERROR (Status
)) {
373 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
374 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
375 if (!EfiAtRuntime ()) {
376 EfiReleaseLock (&Global
->RtcLock
);
381 // Read Register B, and inhibit updates of the RTC
383 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
384 RegisterB
.Bits
.SET
= 1;
385 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
387 ConvertEfiTimeToRtcTime (&RtcTime
, RegisterB
, &Century
);
389 RtcWrite (RTC_ADDRESS_SECONDS
, RtcTime
.Second
);
390 RtcWrite (RTC_ADDRESS_MINUTES
, RtcTime
.Minute
);
391 RtcWrite (RTC_ADDRESS_HOURS
, RtcTime
.Hour
);
392 RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH
, RtcTime
.Day
);
393 RtcWrite (RTC_ADDRESS_MONTH
, RtcTime
.Month
);
394 RtcWrite (RTC_ADDRESS_YEAR
, (UINT8
) RtcTime
.Year
);
395 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
396 Century
= (UINT8
) ((Century
& 0x7f) | (RtcRead (RTC_ADDRESS_CENTURY
) & 0x80));
399 RtcWrite (RTC_ADDRESS_CENTURY
, Century
);
402 // Allow updates of the RTC registers
404 RegisterB
.Bits
.SET
= 0;
405 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
410 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
411 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
412 if (!EfiAtRuntime ()) {
413 EfiReleaseLock (&Global
->RtcLock
);
416 // Set the variable that containts the TimeZone and Daylight fields
418 Global
->SavedTimeZone
= Time
->TimeZone
;
419 Global
->Daylight
= Time
->Daylight
;
425 OUT BOOLEAN
*Enabled
,
426 OUT BOOLEAN
*Pending
,
428 IN PC_RTC_MODULE_GLOBALS
*Global
440 // GC_TODO: Enabled - add argument and description to function comment
441 // GC_TODO: Pending - add argument and description to function comment
442 // GC_TODO: Time - add argument and description to function comment
443 // GC_TODO: Global - add argument and description to function comment
444 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
445 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
446 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
447 // GC_TODO: EFI_SUCCESS - add return value to function comment
450 RTC_REGISTER_B RegisterB
;
451 RTC_REGISTER_C RegisterC
;
455 // Check paramters for null pointers
457 if ((Enabled
== NULL
) || (Pending
== NULL
) || (Time
== NULL
)) {
458 return EFI_INVALID_PARAMETER
;
462 // Acquire RTC Lock to make access to RTC atomic
464 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
465 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
466 if (!EfiAtRuntime ()) {
467 EfiAcquireLock (&Global
->RtcLock
);
470 // Wait for up to 0.1 seconds for the RTC to be updated
472 Status
= RtcWaitToUpdate (100000);
473 if (EFI_ERROR (Status
)) {
474 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
475 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
476 if (!EfiAtRuntime ()) {
477 EfiReleaseLock (&Global
->RtcLock
);
479 return EFI_DEVICE_ERROR
;
482 // Read Register B and Register C
484 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
485 RegisterC
.Data
= RtcRead (RTC_ADDRESS_REGISTER_C
);
488 // Get the Time/Date/Daylight Savings values.
490 *Enabled
= RegisterB
.Bits
.AIE
;
492 Time
->Second
= RtcRead (RTC_ADDRESS_SECONDS_ALARM
);
493 Time
->Minute
= RtcRead (RTC_ADDRESS_MINUTES_ALARM
);
494 Time
->Hour
= RtcRead (RTC_ADDRESS_HOURS_ALARM
);
495 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
496 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
497 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
502 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
503 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
504 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
507 ConvertRtcTimeToEfiTime (Time
, RegisterB
);
509 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
510 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
512 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
515 Time
->Year
= (UINT16
) (Century
* 100 + Time
->Year
);
520 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
521 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
522 if (!EfiAtRuntime ()) {
523 EfiReleaseLock (&Global
->RtcLock
);
526 // Make sure all field values are in correct range
528 Status
= RtcTimeFieldsValid (Time
);
529 if (EFI_ERROR (Status
)) {
530 return EFI_DEVICE_ERROR
;
533 *Pending
= RegisterC
.Bits
.AF
;
542 IN PC_RTC_MODULE_GLOBALS
*Global
554 // GC_TODO: Enable - add argument and description to function comment
555 // GC_TODO: Time - add argument and description to function comment
556 // GC_TODO: Global - add argument and description to function comment
557 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
558 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
559 // GC_TODO: EFI_UNSUPPORTED - add return value to function comment
560 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
561 // GC_TODO: EFI_SUCCESS - add return value to function comment
565 RTC_REGISTER_B RegisterB
;
567 EFI_TIME_CAPABILITIES Capabilities
;
572 return EFI_INVALID_PARAMETER
;
575 // Make sure that the time fields are valid
577 Status
= RtcTimeFieldsValid (Time
);
578 if (EFI_ERROR (Status
)) {
579 return EFI_INVALID_PARAMETER
;
582 // Just support set alarm time within 24 hours
584 PcRtcGetTime (&RtcTime
, &Capabilities
, Global
);
585 if (!IsWithinOneDay (&RtcTime
, Time
)) {
586 return EFI_UNSUPPORTED
;
589 // Make a local copy of the time and date
591 CopyMem (&RtcTime
, Time
, sizeof (EFI_TIME
));
595 // Acquire RTC Lock to make access to RTC atomic
597 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
598 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
599 if (!EfiAtRuntime ()) {
600 EfiAcquireLock (&Global
->RtcLock
);
603 // Wait for up to 0.1 seconds for the RTC to be updated
605 Status
= RtcWaitToUpdate (100000);
606 if (EFI_ERROR (Status
)) {
607 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
608 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
609 if (!EfiAtRuntime ()) {
610 EfiReleaseLock (&Global
->RtcLock
);
612 return EFI_DEVICE_ERROR
;
615 // Read Register B, and inhibit updates of the RTC
617 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
619 RegisterB
.Bits
.SET
= 1;
620 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
623 ConvertEfiTimeToRtcTime (&RtcTime
, RegisterB
, &Century
);
626 // Set RTC alarm time
628 RtcWrite (RTC_ADDRESS_SECONDS_ALARM
, RtcTime
.Second
);
629 RtcWrite (RTC_ADDRESS_MINUTES_ALARM
, RtcTime
.Minute
);
630 RtcWrite (RTC_ADDRESS_HOURS_ALARM
, RtcTime
.Hour
);
632 RegisterB
.Bits
.AIE
= 1;
635 RegisterB
.Bits
.AIE
= 0;
638 // Allow updates of the RTC registers
640 RegisterB
.Bits
.SET
= 0;
641 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
646 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
647 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
648 if (!EfiAtRuntime ()) {
649 EfiReleaseLock (&Global
->RtcLock
);
655 RtcTestCenturyRegister (
668 // GC_TODO: EFI_SUCCESS - add return value to function comment
669 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
674 Century
= RtcRead (RTC_ADDRESS_CENTURY
);
676 // RtcWrite (RTC_ADDRESS_CENTURY, 0x00);
678 Temp
= (UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f);
679 RtcWrite (RTC_ADDRESS_CENTURY
, Century
);
680 if (Temp
== 0x19 || Temp
== 0x20) {
684 return EFI_DEVICE_ERROR
;
688 ConvertRtcTimeToEfiTime (
690 IN RTC_REGISTER_B RegisterB
702 // GC_TODO: Time - add argument and description to function comment
703 // GC_TODO: RegisterB - add argument and description to function comment
707 if ((Time
->Hour
) & 0x80) {
713 Time
->Hour
= (UINT8
) (Time
->Hour
& 0x7f);
715 if (RegisterB
.Bits
.DM
== 0) {
716 Time
->Year
= BcdToDecimal8 ((UINT8
) Time
->Year
);
717 Time
->Month
= BcdToDecimal8 (Time
->Month
);
718 Time
->Day
= BcdToDecimal8 (Time
->Day
);
719 Time
->Hour
= BcdToDecimal8 (Time
->Hour
);
720 Time
->Minute
= BcdToDecimal8 (Time
->Minute
);
721 Time
->Second
= BcdToDecimal8 (Time
->Second
);
724 // If time is in 12 hour format, convert it to 24 hour format
726 if (RegisterB
.Bits
.MIL
== 0) {
727 if (PM
&& Time
->Hour
< 12) {
728 Time
->Hour
= (UINT8
) (Time
->Hour
+ 12);
731 if (!PM
&& Time
->Hour
== 12) {
736 Time
->Nanosecond
= 0;
737 Time
->TimeZone
= EFI_UNSPECIFIED_TIMEZONE
;
754 // GC_TODO: Timeout - add argument and description to function comment
755 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
756 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
757 // GC_TODO: EFI_SUCCESS - add return value to function comment
759 RTC_REGISTER_A RegisterA
;
760 RTC_REGISTER_D RegisterD
;
763 // See if the RTC is functioning correctly
765 RegisterD
.Data
= RtcRead (RTC_ADDRESS_REGISTER_D
);
767 if (RegisterD
.Bits
.VRT
== 0) {
768 return EFI_DEVICE_ERROR
;
771 // Wait for up to 0.1 seconds for the RTC to be ready.
773 Timeout
= (Timeout
/ 10) + 1;
774 RegisterA
.Data
= RtcRead (RTC_ADDRESS_REGISTER_A
);
775 while (RegisterA
.Bits
.UIP
== 1 && Timeout
> 0) {
776 MicroSecondDelay (10);
777 RegisterA
.Data
= RtcRead (RTC_ADDRESS_REGISTER_A
);
781 RegisterD
.Data
= RtcRead (RTC_ADDRESS_REGISTER_D
);
782 if (Timeout
== 0 || RegisterD
.Bits
.VRT
== 0) {
783 return EFI_DEVICE_ERROR
;
801 // GC_TODO: Time - add argument and description to function comment
802 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
803 // GC_TODO: EFI_SUCCESS - add return value to function comment
805 if (Time
->Year
< 1998 ||
809 (!DayValid (Time
)) ||
813 Time
->Nanosecond
> 999999999 ||
814 (!(Time
->TimeZone
== EFI_UNSPECIFIED_TIMEZONE
|| (Time
->TimeZone
>= -1440 && Time
->TimeZone
<= 1440))) ||
815 (Time
->Daylight
& (~(EFI_TIME_ADJUST_DAYLIGHT
| EFI_TIME_IN_DAYLIGHT
)))
817 return EFI_INVALID_PARAMETER
;
831 GC_TODO: Add function description
835 Time - GC_TODO: add argument description
839 GC_TODO: add return values
859 Time
->Day
> DayOfMonth
[Time
->Month
- 1] ||
860 (Time
->Month
== 2 && (!IsLeapYear (Time
) && Time
->Day
> 28))
876 GC_TODO: Add function description
880 Time - GC_TODO: add argument description
884 GC_TODO: add return values
888 if (Time
->Year
% 4 == 0) {
889 if (Time
->Year
% 100 == 0) {
890 if (Time
->Year
% 400 == 0) {
904 ConvertEfiTimeToRtcTime (
906 IN RTC_REGISTER_B RegisterB
,
918 // GC_TODO: Time - add argument and description to function comment
919 // GC_TODO: RegisterB - add argument and description to function comment
920 // GC_TODO: Century - add argument and description to function comment
926 // Adjust hour field if RTC in in 12 hour mode
928 if (RegisterB
.Bits
.MIL
== 0) {
929 if (Time
->Hour
< 12) {
933 if (Time
->Hour
>= 13) {
934 Time
->Hour
= (UINT8
) (Time
->Hour
- 12);
935 } else if (Time
->Hour
== 0) {
940 // Set the Time/Date/Daylight Savings values.
942 *Century
= DecimalToBcd8 ((UINT8
) (Time
->Year
/ 100));
944 Time
->Year
= (UINT16
) (Time
->Year
% 100);
946 if (RegisterB
.Bits
.DM
== 0) {
947 Time
->Year
= DecimalToBcd8 ((UINT8
) Time
->Year
);
948 Time
->Month
= DecimalToBcd8 (Time
->Month
);
949 Time
->Day
= DecimalToBcd8 (Time
->Day
);
950 Time
->Hour
= DecimalToBcd8 (Time
->Hour
);
951 Time
->Minute
= DecimalToBcd8 (Time
->Minute
);
952 Time
->Second
= DecimalToBcd8 (Time
->Second
);
955 // If we are in 12 hour mode and PM is set, then set bit 7 of the Hour field.
957 if (RegisterB
.Bits
.MIL
== 0 && PM
) {
958 Time
->Hour
= (UINT8
) (Time
->Hour
| 0x80);
972 Compare the Hour, Minute and Second of the 'From' time and the 'To' time.
973 Only compare H/M/S in EFI_TIME and ignore other fields here.
977 From - the first time
982 >0 : The H/M/S of the 'From' time is later than those of 'To' time
983 ==0 : The H/M/S of the 'From' time is same as those of 'To' time
984 <0 : The H/M/S of the 'From' time is earlier than those of 'To' time
988 if ((From
->Hour
> To
->Hour
) ||
989 ((From
->Hour
== To
->Hour
) && (From
->Minute
> To
->Minute
)) ||
990 ((From
->Hour
== To
->Hour
) && (From
->Minute
== To
->Minute
) && (From
->Second
> To
->Second
))) {
992 } else if ((From
->Hour
== To
->Hour
) && (From
->Minute
== To
->Minute
) && (From
->Second
== To
->Second
)) {
1007 Routine Description:
1009 Judge whether two days are adjacent.
1013 From - the first day
1018 TRUE - The interval of two days are within one day.
1019 FALSE - The interval of two days exceed ony day or parameter error.
1023 UINT8 DayOfMonth
[12];
1036 DayOfMonth
[10] = 30;
1037 DayOfMonth
[11] = 31;
1041 if (From
->Year
== To
->Year
) {
1042 if (From
->Month
== To
->Month
) {
1043 if ((From
->Day
+ 1) == To
->Day
) {
1044 if ((CompareHMS(From
, To
) >= 0)) {
1047 } else if (From
->Day
== To
->Day
) {
1048 if ((CompareHMS(From
, To
) <= 0)) {
1052 } else if (((From
->Month
+ 1) == To
->Month
) && (To
->Day
== 1)) {
1053 if ((From
->Month
== 2) && !IsLeapYear(From
)) {
1054 if (From
->Day
== 28) {
1055 if ((CompareHMS(From
, To
) >= 0)) {
1059 } else if (From
->Day
== DayOfMonth
[From
->Month
- 1]) {
1060 if ((CompareHMS(From
, To
) >= 0)) {
1065 } else if (((From
->Year
+ 1) == To
->Year
) &&
1066 (From
->Month
== 12) &&
1067 (From
->Day
== 31) &&
1070 if ((CompareHMS(From
, To
) >= 0)) {