3 Copyright (c) 2006 - 2007 Intel Corporation. <BR>
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.
20 RTC Architectural Protocol GUID as defined in DxeCis 0.96
49 GC_TODO: Add function description
53 Address - GC_TODO: add argument description
57 GC_TODO: add return values
61 IoWrite8 (PCAT_RTC_ADDRESS_REGISTER
, (UINT8
) (Address
| (UINT8
) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER
) & 0x80)));
62 return IoRead8 (PCAT_RTC_DATA_REGISTER
);
75 GC_TODO: Add function description
79 Address - GC_TODO: add argument description
80 Data - GC_TODO: add argument description
84 GC_TODO: add return values
88 IoWrite8 (PCAT_RTC_ADDRESS_REGISTER
, (UINT8
) (Address
| (UINT8
) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER
) & 0x80)));
89 IoWrite8 (PCAT_RTC_DATA_REGISTER
, Data
);
94 IN PC_RTC_MODULE_GLOBALS
*Global
100 GC_TODO: Add function description
104 Global - GC_TODO: add argument description
108 EFI_DEVICE_ERROR - GC_TODO: Add description for return value
109 EFI_SUCCESS - GC_TODO: Add description for return value
114 RTC_REGISTER_A RegisterA
;
115 RTC_REGISTER_B RegisterB
;
116 RTC_REGISTER_D RegisterD
;
121 // Acquire RTC Lock to make access to RTC atomic
123 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
124 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
125 if (!EfiAtRuntime ()) {
126 EfiAcquireLock (&Global
->RtcLock
);
129 // Initialize RTC Register
131 // Make sure Division Chain is properly configured,
132 // or RTC clock won't "tick" -- time won't increment
134 RegisterA
.Data
= RTC_INIT_REGISTER_A
;
135 RtcWrite (RTC_ADDRESS_REGISTER_A
, RegisterA
.Data
);
140 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
143 // Clear RTC flag register
145 RtcRead (RTC_ADDRESS_REGISTER_C
);
148 // Clear RTC register D
150 RegisterD
.Data
= RTC_INIT_REGISTER_D
;
151 RtcWrite (RTC_ADDRESS_REGISTER_D
, RegisterD
.Data
);
154 // Wait for up to 0.1 seconds for the RTC to be updated
156 Status
= RtcWaitToUpdate (100000);
157 if (EFI_ERROR (Status
)) {
158 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
159 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
160 if (!EfiAtRuntime ()) {
161 EfiReleaseLock (&Global
->RtcLock
);
163 return EFI_DEVICE_ERROR
;
166 // Get the Time/Date/Daylight Savings values.
168 Time
.Second
= RtcRead (RTC_ADDRESS_SECONDS
);
169 Time
.Minute
= RtcRead (RTC_ADDRESS_MINUTES
);
170 Time
.Hour
= RtcRead (RTC_ADDRESS_HOURS
);
171 Time
.Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
172 Time
.Month
= RtcRead (RTC_ADDRESS_MONTH
);
173 Time
.Year
= RtcRead (RTC_ADDRESS_YEAR
);
175 ConvertRtcTimeToEfiTime (&Time
, RegisterB
);
177 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
178 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
180 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
183 Time
.Year
= (UINT16
) (Century
* 100 + Time
.Year
);
186 // Set RTC configuration after get original time
188 RtcWrite (RTC_ADDRESS_REGISTER_B
, RTC_INIT_REGISTER_B
);
193 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
194 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
195 if (!EfiAtRuntime ()) {
196 EfiReleaseLock (&Global
->RtcLock
);
199 // Validate time fields
201 Status
= RtcTimeFieldsValid (&Time
);
202 if (EFI_ERROR (Status
)) {
203 Time
.Second
= RTC_INIT_SECOND
;
204 Time
.Minute
= RTC_INIT_MINUTE
;
205 Time
.Hour
= RTC_INIT_HOUR
;
206 Time
.Day
= RTC_INIT_DAY
;
207 Time
.Month
= RTC_INIT_MONTH
;
208 Time
.Year
= RTC_INIT_YEAR
;
211 // Reset time value according to new RTC configuration
213 PcRtcSetTime (&Time
, Global
);
221 IN EFI_TIME_CAPABILITIES
*Capabilities
,
222 IN PC_RTC_MODULE_GLOBALS
*Global
232 // GC_TODO: Time - add argument and description to function comment
233 // GC_TODO: Capabilities - add argument and description to function comment
234 // GC_TODO: Global - add argument and description to function comment
235 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
236 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
237 // GC_TODO: EFI_SUCCESS - add return value to function comment
240 RTC_REGISTER_B RegisterB
;
244 // Check parameters for null pointer
247 return EFI_INVALID_PARAMETER
;
251 // Acquire RTC Lock to make access to RTC atomic
253 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
254 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
255 if (!EfiAtRuntime ()) {
256 EfiAcquireLock (&Global
->RtcLock
);
259 // Wait for up to 0.1 seconds for the RTC to be updated
261 Status
= RtcWaitToUpdate (100000);
262 if (EFI_ERROR (Status
)) {
263 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
264 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
265 if (!EfiAtRuntime ()) {
266 EfiReleaseLock (&Global
->RtcLock
);
273 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
276 // Get the Time/Date/Daylight Savings values.
278 Time
->Second
= RtcRead (RTC_ADDRESS_SECONDS
);
279 Time
->Minute
= RtcRead (RTC_ADDRESS_MINUTES
);
280 Time
->Hour
= RtcRead (RTC_ADDRESS_HOURS
);
281 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
282 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
283 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
285 ConvertRtcTimeToEfiTime (Time
, RegisterB
);
287 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
288 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
290 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
293 Time
->Year
= (UINT16
) (Century
* 100 + Time
->Year
);
298 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
299 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
300 if (!EfiAtRuntime ()) {
301 EfiReleaseLock (&Global
->RtcLock
);
304 // Get the variable that containts the TimeZone and Daylight fields
306 Time
->TimeZone
= Global
->SavedTimeZone
;
307 Time
->Daylight
= Global
->Daylight
;
310 // Make sure all field values are in correct range
312 Status
= RtcTimeFieldsValid (Time
);
313 if (EFI_ERROR (Status
)) {
314 return EFI_DEVICE_ERROR
;
317 // Fill in Capabilities if it was passed in
320 Capabilities
->Resolution
= 1;
324 Capabilities
->Accuracy
= 50000000;
328 Capabilities
->SetsToZero
= FALSE
;
337 IN PC_RTC_MODULE_GLOBALS
*Global
347 // GC_TODO: Time - add argument and description to function comment
348 // GC_TODO: Global - add argument and description to function comment
349 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
353 RTC_REGISTER_B RegisterB
;
357 return EFI_INVALID_PARAMETER
;
360 // Make sure that the time fields are valid
362 Status
= RtcTimeFieldsValid (Time
);
363 if (EFI_ERROR (Status
)) {
367 CopyMem (&RtcTime
, Time
, sizeof (EFI_TIME
));
370 // Acquire RTC Lock to make access to RTC atomic
372 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
373 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
374 if (!EfiAtRuntime ()) {
375 EfiAcquireLock (&Global
->RtcLock
);
378 // Wait for up to 0.1 seconds for the RTC to be updated
380 Status
= RtcWaitToUpdate (100000);
381 if (EFI_ERROR (Status
)) {
382 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
383 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
384 if (!EfiAtRuntime ()) {
385 EfiReleaseLock (&Global
->RtcLock
);
390 // Read Register B, and inhibit updates of the RTC
392 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
393 RegisterB
.Bits
.SET
= 1;
394 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
396 ConvertEfiTimeToRtcTime (&RtcTime
, RegisterB
, &Century
);
398 RtcWrite (RTC_ADDRESS_SECONDS
, RtcTime
.Second
);
399 RtcWrite (RTC_ADDRESS_MINUTES
, RtcTime
.Minute
);
400 RtcWrite (RTC_ADDRESS_HOURS
, RtcTime
.Hour
);
401 RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH
, RtcTime
.Day
);
402 RtcWrite (RTC_ADDRESS_MONTH
, RtcTime
.Month
);
403 RtcWrite (RTC_ADDRESS_YEAR
, (UINT8
) RtcTime
.Year
);
404 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
405 Century
= (UINT8
) ((Century
& 0x7f) | (RtcRead (RTC_ADDRESS_CENTURY
) & 0x80));
408 RtcWrite (RTC_ADDRESS_CENTURY
, Century
);
411 // Allow updates of the RTC registers
413 RegisterB
.Bits
.SET
= 0;
414 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
419 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
420 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
421 if (!EfiAtRuntime ()) {
422 EfiReleaseLock (&Global
->RtcLock
);
425 // Set the variable that containts the TimeZone and Daylight fields
427 Global
->SavedTimeZone
= Time
->TimeZone
;
428 Global
->Daylight
= Time
->Daylight
;
434 OUT BOOLEAN
*Enabled
,
435 OUT BOOLEAN
*Pending
,
437 IN PC_RTC_MODULE_GLOBALS
*Global
449 // GC_TODO: Enabled - add argument and description to function comment
450 // GC_TODO: Pending - add argument and description to function comment
451 // GC_TODO: Time - add argument and description to function comment
452 // GC_TODO: Global - add argument and description to function comment
453 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
454 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
455 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
456 // GC_TODO: EFI_SUCCESS - add return value to function comment
459 RTC_REGISTER_B RegisterB
;
460 RTC_REGISTER_C RegisterC
;
464 // Check paramters for null pointers
466 if ((Enabled
== NULL
) || (Pending
== NULL
) || (Time
== NULL
)) {
467 return EFI_INVALID_PARAMETER
;
471 // Acquire RTC Lock to make access to RTC atomic
473 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
474 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
475 if (!EfiAtRuntime ()) {
476 EfiAcquireLock (&Global
->RtcLock
);
479 // Wait for up to 0.1 seconds for the RTC to be updated
481 Status
= RtcWaitToUpdate (100000);
482 if (EFI_ERROR (Status
)) {
483 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
484 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
485 if (!EfiAtRuntime ()) {
486 EfiReleaseLock (&Global
->RtcLock
);
488 return EFI_DEVICE_ERROR
;
491 // Read Register B and Register C
493 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
494 RegisterC
.Data
= RtcRead (RTC_ADDRESS_REGISTER_C
);
497 // Get the Time/Date/Daylight Savings values.
499 *Enabled
= RegisterB
.Bits
.AIE
;
501 Time
->Second
= RtcRead (RTC_ADDRESS_SECONDS_ALARM
);
502 Time
->Minute
= RtcRead (RTC_ADDRESS_MINUTES_ALARM
);
503 Time
->Hour
= RtcRead (RTC_ADDRESS_HOURS_ALARM
);
504 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
505 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
506 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
511 Time
->Day
= RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH
);
512 Time
->Month
= RtcRead (RTC_ADDRESS_MONTH
);
513 Time
->Year
= RtcRead (RTC_ADDRESS_YEAR
);
516 ConvertRtcTimeToEfiTime (Time
, RegisterB
);
518 if (RtcTestCenturyRegister () == EFI_SUCCESS
) {
519 Century
= BcdToDecimal8 ((UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f));
521 Century
= BcdToDecimal8 (RtcRead (RTC_ADDRESS_CENTURY
));
524 Time
->Year
= (UINT16
) (Century
* 100 + Time
->Year
);
529 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
530 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
531 if (!EfiAtRuntime ()) {
532 EfiReleaseLock (&Global
->RtcLock
);
535 // Make sure all field values are in correct range
537 Status
= RtcTimeFieldsValid (Time
);
538 if (EFI_ERROR (Status
)) {
539 return EFI_DEVICE_ERROR
;
542 *Pending
= RegisterC
.Bits
.AF
;
551 IN PC_RTC_MODULE_GLOBALS
*Global
563 // GC_TODO: Enable - add argument and description to function comment
564 // GC_TODO: Time - add argument and description to function comment
565 // GC_TODO: Global - add argument and description to function comment
566 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
567 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
568 // GC_TODO: EFI_UNSUPPORTED - add return value to function comment
569 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
570 // GC_TODO: EFI_SUCCESS - add return value to function comment
574 RTC_REGISTER_B RegisterB
;
576 EFI_TIME_CAPABILITIES Capabilities
;
581 return EFI_INVALID_PARAMETER
;
584 // Make sure that the time fields are valid
586 Status
= RtcTimeFieldsValid (Time
);
587 if (EFI_ERROR (Status
)) {
588 return EFI_INVALID_PARAMETER
;
591 // Just support set alarm time within 24 hours
593 PcRtcGetTime (&RtcTime
, &Capabilities
, Global
);
594 if (!IsWithinOneDay (&RtcTime
, Time
)) {
595 return EFI_UNSUPPORTED
;
598 // Make a local copy of the time and date
600 CopyMem (&RtcTime
, Time
, sizeof (EFI_TIME
));
604 // Acquire RTC Lock to make access to RTC atomic
606 //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or
607 // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock
608 if (!EfiAtRuntime ()) {
609 EfiAcquireLock (&Global
->RtcLock
);
612 // Wait for up to 0.1 seconds for the RTC to be updated
614 Status
= RtcWaitToUpdate (100000);
615 if (EFI_ERROR (Status
)) {
616 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
617 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
618 if (!EfiAtRuntime ()) {
619 EfiReleaseLock (&Global
->RtcLock
);
621 return EFI_DEVICE_ERROR
;
624 // Read Register B, and inhibit updates of the RTC
626 RegisterB
.Data
= RtcRead (RTC_ADDRESS_REGISTER_B
);
628 RegisterB
.Bits
.SET
= 1;
629 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
632 ConvertEfiTimeToRtcTime (&RtcTime
, RegisterB
, &Century
);
635 // Set RTC alarm time
637 RtcWrite (RTC_ADDRESS_SECONDS_ALARM
, RtcTime
.Second
);
638 RtcWrite (RTC_ADDRESS_MINUTES_ALARM
, RtcTime
.Minute
);
639 RtcWrite (RTC_ADDRESS_HOURS_ALARM
, RtcTime
.Hour
);
641 RegisterB
.Bits
.AIE
= 1;
644 RegisterB
.Bits
.AIE
= 0;
647 // Allow updates of the RTC registers
649 RegisterB
.Bits
.SET
= 0;
650 RtcWrite (RTC_ADDRESS_REGISTER_B
, RegisterB
.Data
);
655 //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or
656 // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock
657 if (!EfiAtRuntime ()) {
658 EfiReleaseLock (&Global
->RtcLock
);
664 RtcTestCenturyRegister (
677 // GC_TODO: EFI_SUCCESS - add return value to function comment
678 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
683 Century
= RtcRead (RTC_ADDRESS_CENTURY
);
685 // RtcWrite (RTC_ADDRESS_CENTURY, 0x00);
687 Temp
= (UINT8
) (RtcRead (RTC_ADDRESS_CENTURY
) & 0x7f);
688 RtcWrite (RTC_ADDRESS_CENTURY
, Century
);
689 if (Temp
== 0x19 || Temp
== 0x20) {
693 return EFI_DEVICE_ERROR
;
697 ConvertRtcTimeToEfiTime (
699 IN RTC_REGISTER_B RegisterB
711 // GC_TODO: Time - add argument and description to function comment
712 // GC_TODO: RegisterB - add argument and description to function comment
716 if ((Time
->Hour
) & 0x80) {
722 Time
->Hour
= (UINT8
) (Time
->Hour
& 0x7f);
724 if (RegisterB
.Bits
.DM
== 0) {
725 Time
->Year
= BcdToDecimal8 ((UINT8
) Time
->Year
);
726 Time
->Month
= BcdToDecimal8 (Time
->Month
);
727 Time
->Day
= BcdToDecimal8 (Time
->Day
);
728 Time
->Hour
= BcdToDecimal8 (Time
->Hour
);
729 Time
->Minute
= BcdToDecimal8 (Time
->Minute
);
730 Time
->Second
= BcdToDecimal8 (Time
->Second
);
733 // If time is in 12 hour format, convert it to 24 hour format
735 if (RegisterB
.Bits
.MIL
== 0) {
736 if (PM
&& Time
->Hour
< 12) {
737 Time
->Hour
= (UINT8
) (Time
->Hour
+ 12);
740 if (!PM
&& Time
->Hour
== 12) {
745 Time
->Nanosecond
= 0;
746 Time
->TimeZone
= EFI_UNSPECIFIED_TIMEZONE
;
763 // GC_TODO: Timeout - add argument and description to function comment
764 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
765 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
766 // GC_TODO: EFI_SUCCESS - add return value to function comment
768 RTC_REGISTER_A RegisterA
;
769 RTC_REGISTER_D RegisterD
;
772 // See if the RTC is functioning correctly
774 RegisterD
.Data
= RtcRead (RTC_ADDRESS_REGISTER_D
);
776 if (RegisterD
.Bits
.VRT
== 0) {
777 return EFI_DEVICE_ERROR
;
780 // Wait for up to 0.1 seconds for the RTC to be ready.
782 Timeout
= (Timeout
/ 10) + 1;
783 RegisterA
.Data
= RtcRead (RTC_ADDRESS_REGISTER_A
);
784 while (RegisterA
.Bits
.UIP
== 1 && Timeout
> 0) {
785 MicroSecondDelay (10);
786 RegisterA
.Data
= RtcRead (RTC_ADDRESS_REGISTER_A
);
790 RegisterD
.Data
= RtcRead (RTC_ADDRESS_REGISTER_D
);
791 if (Timeout
== 0 || RegisterD
.Bits
.VRT
== 0) {
792 return EFI_DEVICE_ERROR
;
810 // GC_TODO: Time - add argument and description to function comment
811 // GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
812 // GC_TODO: EFI_SUCCESS - add return value to function comment
814 if (Time
->Year
< 1998 ||
818 (!DayValid (Time
)) ||
822 Time
->Nanosecond
> 999999999 ||
823 (!(Time
->TimeZone
== EFI_UNSPECIFIED_TIMEZONE
|| (Time
->TimeZone
>= -1440 && Time
->TimeZone
<= 1440))) ||
824 (Time
->Daylight
& (~(EFI_TIME_ADJUST_DAYLIGHT
| EFI_TIME_IN_DAYLIGHT
)))
826 return EFI_INVALID_PARAMETER
;
840 GC_TODO: Add function description
844 Time - GC_TODO: add argument description
848 GC_TODO: add return values
868 Time
->Day
> DayOfMonth
[Time
->Month
- 1] ||
869 (Time
->Month
== 2 && (!IsLeapYear (Time
) && Time
->Day
> 28))
885 GC_TODO: Add function description
889 Time - GC_TODO: add argument description
893 GC_TODO: add return values
897 if (Time
->Year
% 4 == 0) {
898 if (Time
->Year
% 100 == 0) {
899 if (Time
->Year
% 400 == 0) {
913 ConvertEfiTimeToRtcTime (
915 IN RTC_REGISTER_B RegisterB
,
927 // GC_TODO: Time - add argument and description to function comment
928 // GC_TODO: RegisterB - add argument and description to function comment
929 // GC_TODO: Century - add argument and description to function comment
935 // Adjust hour field if RTC in in 12 hour mode
937 if (RegisterB
.Bits
.MIL
== 0) {
938 if (Time
->Hour
< 12) {
942 if (Time
->Hour
>= 13) {
943 Time
->Hour
= (UINT8
) (Time
->Hour
- 12);
944 } else if (Time
->Hour
== 0) {
949 // Set the Time/Date/Daylight Savings values.
951 *Century
= DecimalToBcd8 ((UINT8
) (Time
->Year
/ 100));
953 Time
->Year
= (UINT16
) (Time
->Year
% 100);
955 if (RegisterB
.Bits
.DM
== 0) {
956 Time
->Year
= DecimalToBcd8 ((UINT8
) Time
->Year
);
957 Time
->Month
= DecimalToBcd8 (Time
->Month
);
958 Time
->Day
= DecimalToBcd8 (Time
->Day
);
959 Time
->Hour
= DecimalToBcd8 (Time
->Hour
);
960 Time
->Minute
= DecimalToBcd8 (Time
->Minute
);
961 Time
->Second
= DecimalToBcd8 (Time
->Second
);
964 // If we are in 12 hour mode and PM is set, then set bit 7 of the Hour field.
966 if (RegisterB
.Bits
.MIL
== 0 && PM
) {
967 Time
->Hour
= (UINT8
) (Time
->Hour
| 0x80);
981 Compare the Hour, Minute and Second of the 'From' time and the 'To' time.
982 Only compare H/M/S in EFI_TIME and ignore other fields here.
986 From - the first time
991 >0 : The H/M/S of the 'From' time is later than those of 'To' time
992 ==0 : The H/M/S of the 'From' time is same as those of 'To' time
993 <0 : The H/M/S of the 'From' time is earlier than those of 'To' time
997 if ((From
->Hour
> To
->Hour
) ||
998 ((From
->Hour
== To
->Hour
) && (From
->Minute
> To
->Minute
)) ||
999 ((From
->Hour
== To
->Hour
) && (From
->Minute
== To
->Minute
) && (From
->Second
> To
->Second
))) {
1001 } else if ((From
->Hour
== To
->Hour
) && (From
->Minute
== To
->Minute
) && (From
->Second
== To
->Second
)) {
1016 Routine Description:
1018 Judge whether two days are adjacent.
1022 From - the first day
1027 TRUE - The interval of two days are within one day.
1028 FALSE - The interval of two days exceed ony day or parameter error.
1032 UINT8 DayOfMonth
[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
1033 BOOLEAN Adjacent
= FALSE
;
1035 if (From
->Year
== To
->Year
) {
1036 if (From
->Month
== To
->Month
) {
1037 if ((From
->Day
+ 1) == To
->Day
) {
1038 if ((CompareHMS(From
, To
) >= 0)) {
1041 } else if (From
->Day
== To
->Day
) {
1042 if ((CompareHMS(From
, To
) <= 0)) {
1046 } else if (((From
->Month
+ 1) == To
->Month
) && (To
->Day
== 1)) {
1047 if ((From
->Month
== 2) && !IsLeapYear(From
)) {
1048 if (From
->Day
== 28) {
1049 if ((CompareHMS(From
, To
) >= 0)) {
1053 } else if (From
->Day
== DayOfMonth
[From
->Month
- 1]) {
1054 if ((CompareHMS(From
, To
) >= 0)) {
1059 } else if (((From
->Year
+ 1) == To
->Year
) &&
1060 (From
->Month
== 12) &&
1061 (From
->Day
== 31) &&
1064 if ((CompareHMS(From
, To
) >= 0)) {