summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg
diff options
context:
space:
mode:
authorNhi Pham <nhi@os.amperecomputing.com>2021-01-06 23:09:03 +0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-01-07 16:43:48 +0000
commit55ee36b0c490d9a6582e083bb3ac78a22d33053f (patch)
tree09b116ea323b8e1df0f5f75a47fd84d0d54158a6 /EmbeddedPkg
parente31dc4717c75d8e771dfa5c9b1648fa20d88ab0d (diff)
downloadedk2-55ee36b0c490d9a6582e083bb3ac78a22d33053f.tar.gz
edk2-55ee36b0c490d9a6582e083bb3ac78a22d33053f.tar.bz2
edk2-55ee36b0c490d9a6582e083bb3ac78a22d33053f.zip
EmbeddedPkg/RealTimeClockRuntimeDxe: Use helper functions from TimeBaseLib
This patch replaces all time checking functions and leverage the helper functions in TimeBaseLib library. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com> Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Diffstat (limited to 'EmbeddedPkg')
-rw-r--r--EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c88
-rw-r--r--EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf2
2 files changed, 4 insertions, 86 deletions
diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
index 20f1fa640e..e59036badc 100644
--- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
+++ b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
@@ -3,6 +3,7 @@
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
+ Copyright (c) 2021, Ampere Computing LLC. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -11,6 +12,7 @@
#include <PiDxe.h>
#include <Library/DebugLib.h>
#include <Library/RealTimeClockLib.h>
+#include <Library/TimeBaseLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
@@ -31,92 +33,6 @@ typedef struct {
STATIC CONST CHAR16 mTimeSettingsVariableName[] = L"RtcTimeSettings";
STATIC NON_VOLATILE_TIME_SETTINGS mTimeSettings;
-STATIC
-BOOLEAN
-IsValidTimeZone (
- IN INT16 TimeZone
- )
-{
- return TimeZone == EFI_UNSPECIFIED_TIMEZONE ||
- (TimeZone >= -1440 && TimeZone <= 1440);
-}
-
-STATIC
-BOOLEAN
-IsValidDaylight (
- IN INT8 Daylight
- )
-{
- return Daylight == 0 ||
- Daylight == EFI_TIME_ADJUST_DAYLIGHT ||
- Daylight == (EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT);
-}
-
-STATIC
-BOOLEAN
-EFIAPI
-IsLeapYear (
- IN EFI_TIME *Time
- )
-{
- if (Time->Year % 4 == 0) {
- if (Time->Year % 100 == 0) {
- if (Time->Year % 400 == 0) {
- return TRUE;
- } else {
- return FALSE;
- }
- } else {
- return TRUE;
- }
- } else {
- return FALSE;
- }
-}
-
-STATIC CONST INTN mDayOfMonth[12] = {
- 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-STATIC
-BOOLEAN
-EFIAPI
-IsDayValid (
- IN EFI_TIME *Time
- )
-{
- if (Time->Day < 1 ||
- Time->Day > mDayOfMonth[Time->Month - 1] ||
- (Time->Month == 2 && !IsLeapYear (Time) && Time->Day > 28)) {
- return FALSE;
- }
- return TRUE;
-}
-
-STATIC
-BOOLEAN
-EFIAPI
-IsTimeValid(
- IN EFI_TIME *Time
- )
-{
- // Check the input parameters are within the range specified by UEFI
- if (Time->Year < 1900 ||
- Time->Year > 9999 ||
- Time->Month < 1 ||
- Time->Month > 12 ||
- !IsDayValid (Time) ||
- Time->Hour > 23 ||
- Time->Minute > 59 ||
- Time->Second > 59 ||
- Time->Nanosecond > 999999999 ||
- !IsValidTimeZone (Time->TimeZone) ||
- !IsValidDaylight (Time->Daylight)) {
- return FALSE;
- }
- return TRUE;
-}
-
/**
Returns the current time and date information, and the time-keeping capabilities
of the hardware platform.
diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
index c9cd052ade..fec53c79d3 100644
--- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
+++ b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
@@ -3,6 +3,7 @@
#
# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
+# Copyright (c) 2021, Ampere Computing LLC. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -28,6 +29,7 @@
[LibraryClasses]
DebugLib
RealTimeClockLib
+ TimeBaseLib
UefiBootServicesTableLib
UefiDriverEntryPoint
UefiRuntimeLib