summaryrefslogtreecommitdiffstats
path: root/PcAtChipsetPkg
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2023-03-29 14:22:38 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-30 16:49:05 +0000
commite9e61671237e10f7d7672ff74e8907941a954c1d (patch)
tree844758066d7876b25cec668885fc6f2eb681ac32 /PcAtChipsetPkg
parent6f0c65cdb073eb8ee8c1cb6fad5d0060ec86f3cc (diff)
downloadedk2-e9e61671237e10f7d7672ff74e8907941a954c1d.tar.gz
edk2-e9e61671237e10f7d7672ff74e8907941a954c1d.tar.bz2
edk2-e9e61671237e10f7d7672ff74e8907941a954c1d.zip
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe: PcdRtcDefaultYear bounds
Add bounds checks of PcdRtcDefaultYear to guarantee that the year is always between PcdMinimalValidYear and PcdMaximalValidYear. This is required to make the following commit a backwards compatible change and guarantee and invalid year is never set. https://github.com/tianocore/edk2/commit/d55d73152ebf5c793b645d6ec5bc517d219881cd This is required because use of an expression in the DEC file PCD default value is only used to determine the DEC default values. If an INF/DSC overrides PcdRtcDefaultYear, then the DEC expression for PcdMinimalValidYear is not applied again. Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'PcAtChipsetPkg')
-rw-r--r--PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
index b059e92f02..15759463f2 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
@@ -317,7 +317,8 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = PcdGet16 (PcdRtcDefaultYear);
+ Time.Year = MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMinimalValidYear));
+ Time.Year = MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));
Time.Nanosecond = 0;
Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
Time.Daylight = 0;
@@ -357,7 +358,8 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = PcdGet16 (PcdRtcDefaultYear);
+ Time.Year = MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16 (PcdMinimalValidYear));
+ Time.Year = MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));
Time.Nanosecond = 0;
Time.TimeZone = Global->SavedTimeZone;
Time.Daylight = Global->Daylight;