1 | Index: PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
|
---|
2 | ===================================================================
|
---|
3 | --- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c (revision 9330)
|
---|
4 | +++ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c (working copy)
|
---|
5 | @@ -243,6 +243,7 @@
|
---|
6 | EFI_STATUS Status;
|
---|
7 | RTC_REGISTER_B RegisterB;
|
---|
8 | UINT8 Century;
|
---|
9 | + EFI_TIME TimeCopy;
|
---|
10 |
|
---|
11 | //
|
---|
12 | // Check parameters for null pointer
|
---|
13 | @@ -275,15 +276,15 @@
|
---|
14 | //
|
---|
15 | // Get the Time/Date/Daylight Savings values.
|
---|
16 | //
|
---|
17 | - Time->Second = RtcRead (RTC_ADDRESS_SECONDS);
|
---|
18 | - Time->Minute = RtcRead (RTC_ADDRESS_MINUTES);
|
---|
19 | - Time->Hour = RtcRead (RTC_ADDRESS_HOURS);
|
---|
20 | - Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
---|
21 | - Time->Month = RtcRead (RTC_ADDRESS_MONTH);
|
---|
22 | - Time->Year = RtcRead (RTC_ADDRESS_YEAR);
|
---|
23 | + TimeCopy.Second = RtcRead (RTC_ADDRESS_SECONDS);
|
---|
24 | + TimeCopy.Minute = RtcRead (RTC_ADDRESS_MINUTES);
|
---|
25 | + TimeCopy.Hour = RtcRead (RTC_ADDRESS_HOURS);
|
---|
26 | + TimeCopy.Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
|
---|
27 | + TimeCopy.Month = RtcRead (RTC_ADDRESS_MONTH);
|
---|
28 | + TimeCopy.Year = RtcRead (RTC_ADDRESS_YEAR);
|
---|
29 |
|
---|
30 | - Century = RtcRead (RTC_ADDRESS_CENTURY);
|
---|
31 | -
|
---|
32 | + Century = RtcRead (RTC_ADDRESS_CENTURY);
|
---|
33 | +
|
---|
34 | //
|
---|
35 | // Release RTC Lock.
|
---|
36 | //
|
---|
37 | @@ -294,16 +295,18 @@
|
---|
38 | //
|
---|
39 | // Get the variable that contains the TimeZone and Daylight fields
|
---|
40 | //
|
---|
41 | - Time->TimeZone = Global->SavedTimeZone;
|
---|
42 | - Time->Daylight = Global->Daylight;
|
---|
43 | + TimeCopy.TimeZone = Global->SavedTimeZone;
|
---|
44 | + TimeCopy.Daylight = Global->Daylight;
|
---|
45 |
|
---|
46 | //
|
---|
47 | // Make sure all field values are in correct range
|
---|
48 | //
|
---|
49 | - Status = ConvertRtcTimeToEfiTime (Time, Century, RegisterB);
|
---|
50 | + Status = ConvertRtcTimeToEfiTime (&TimeCopy, Century, RegisterB);
|
---|
51 | + //DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, Status));
|
---|
52 | if (!EFI_ERROR (Status)) {
|
---|
53 | - Status = RtcTimeFieldsValid (Time);
|
---|
54 | + Status = RtcTimeFieldsValid (&TimeCopy);
|
---|
55 | }
|
---|
56 | + //DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, Status));
|
---|
57 | if (EFI_ERROR (Status)) {
|
---|
58 | return EFI_DEVICE_ERROR;
|
---|
59 | }
|
---|
60 | @@ -323,6 +326,8 @@
|
---|
61 | Capabilities->SetsToZero = FALSE;
|
---|
62 | }
|
---|
63 |
|
---|
64 | + CopyMem(Time, &TimeCopy, sizeof(*Time));
|
---|
65 | +
|
---|
66 | return EFI_SUCCESS;
|
---|
67 | }
|
---|
68 |
|
---|
69 | @@ -800,8 +805,9 @@
|
---|
70 | IN EFI_TIME *Time
|
---|
71 | )
|
---|
72 | {
|
---|
73 | - if (Time->Year < 1998 ||
|
---|
74 | - Time->Year > 2099 ||
|
---|
75 | + if (
|
---|
76 | + //Time->Year < 1998 ||
|
---|
77 | + //Time->Year > 2099 ||
|
---|
78 | Time->Month < 1 ||
|
---|
79 | Time->Month > 12 ||
|
---|
80 | (!DayValid (Time)) ||
|
---|
81 | @@ -848,12 +854,12 @@
|
---|
82 | //
|
---|
83 | // The validity of Time->Month field should be checked before
|
---|
84 | //
|
---|
85 | - ASSERT (Time->Month >=1);
|
---|
86 | - ASSERT (Time->Month <=12);
|
---|
87 | - if (Time->Day < 1 ||
|
---|
88 | - Time->Day > DayOfMonth[Time->Month - 1] ||
|
---|
89 | + ASSERT (Time->Month >= 1 && Time->Month <= 12);
|
---|
90 | +
|
---|
91 | + if ( Time->Day > DayOfMonth[Time->Month - 1] ||
|
---|
92 | (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
|
---|
93 | ) {
|
---|
94 | + DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, EFI_INVALID_PARAMETER));
|
---|
95 | return FALSE;
|
---|
96 | }
|
---|
97 |
|
---|