From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.groups.io with SMTP id smtpd.web09.7549.1609938323061180972 for ; Wed, 06 Jan 2021 05:05:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=l7JZJn1Q; spf=pass (domain: nuviainc.com, ip: 209.85.128.44, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f44.google.com with SMTP id y23so2582375wmi.1 for ; Wed, 06 Jan 2021 05:05:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Blr5mt3cYivJnCYcLdbrPtmOYzEZXvjNFwk3ZsRAZ3g=; b=l7JZJn1QMcKrf7N6XiJzya2d5hGlqbHPn8KpAOyZlQbgzh+30UV1G5nhLuMDly69ct TY/WXScKzajPLvKF8Ep0Xc3IwleQJ1Om0YYDqGbvpJOsZZaMnqqZF0+xOj0bhrMoFqAW KwhG0oWEFkdepXEExK7hr90brCFo/qTOrnLEP0R72tzaxDpUXAvotTYnnfv5l/6/9X4x lLRDTYuWoVrBptm/IWF3Evczz5yuCDGgjYnqvSdb9rWYzCXLs6FS5bFzyg1USKhYwAWU ZcvWPibNSMXwl1UKGocP24+ITXcYbDLmsMlg0nk1yk3DZghY0BfRkPTL/ztngvd3bWrM sbmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Blr5mt3cYivJnCYcLdbrPtmOYzEZXvjNFwk3ZsRAZ3g=; b=oKwFoJIj8/GICDVHX4JcE1ucb1tCWyUOHP555sqtsAmQP8sF5PQV2fYsabxui4hpJb dTvmgU/ZjNN/khIPn1gi/oWOXh3rAdNic/DsignoDjvtqKKd5AXH8kDat9v+K3A6SFHk ZTDNHpZ6QjQe9HZbRADQGLuDJZQoI5dvvZr3HPO/ci5fRosL4qdUwOza7xjSwVwl+5pV rDFk68c/GvmVyx0T9UtOdPEVWtssgFwh2AMREa3zwJOS8+WwD/0vCMXHAII0JHGgVj/I 4L/xVsm5Af7UgM73rRdWg6TOzbKvt5ly3PQP6eDE/CbPaY1QBCxbxJMF2QyzQaMKm1eV CcqA== X-Gm-Message-State: AOAM530mvn8qRd/Y9uVDe82BJpCcw7W16U16L01kcpt3WZV6hqvcr1Hy eYeNNh4cYoDhDlOetPWxa1fgpL3XZOm9Iqkm X-Google-Smtp-Source: ABdhPJwQPgEVCFiWpltTa2EYha+EQvQoiaha/RYTW59t2sJKHrxqeXbBugOZCdqxAt7eRZH0rXQcWg== X-Received: by 2002:a1c:770d:: with SMTP id t13mr3742977wmi.153.1609938321687; Wed, 06 Jan 2021 05:05:21 -0800 (PST) Return-Path: Received: from vanye (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id z13sm9306227wmz.3.2021.01.06.05.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 05:05:21 -0800 (PST) Date: Wed, 6 Jan 2021 13:05:19 +0000 From: "Leif Lindholm" To: Nhi Pham Cc: devel@edk2.groups.io, Ard Biesheuvel Subject: Re: [PATCH 2/2] EmbeddedPkg/RealTimeClockRuntimeDxe: Use helper functions from TimeBaseLib Message-ID: <20210106130519.GC1664@vanye> References: <20210106105558.9582-1-nhi@os.amperecomputing.com> <20210106105558.9582-3-nhi@os.amperecomputing.com> MIME-Version: 1.0 In-Reply-To: <20210106105558.9582-3-nhi@os.amperecomputing.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jan 06, 2021 at 17:55:58 +0700, Nhi Pham wrote: > This patch replaces all time checking functions and leverage the helper > functions in TimeBaseLib library. > > Cc: Leif Lindholm > Cc: Ard Biesheuvel > Signed-off-by: Nhi Pham > --- > EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf | 2 + > EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c | 88 +------------------- > 2 files changed, 4 insertions(+), 86 deletions(-) > > diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf > index c9cd052adef4..c0e44033af3a 100644 > --- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf > +++ b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf > @@ -3,6 +3,7 @@ > # > # Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
> # Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> +# Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
2021? > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -31,6 +32,7 @@ [LibraryClasses] > UefiBootServicesTableLib > UefiDriverEntryPoint > UefiRuntimeLib > + TimeBaseLib Please insert alphabetically sorted. > > [Protocols] > gEfiRealTimeClockArchProtocolGuid > diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c > index 20f1fa640ecc..8ae4e9315be5 100644 > --- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c > +++ b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c > @@ -3,6 +3,7 @@ > > Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
2021? > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -14,6 +15,7 @@ > #include > #include > #include > +#include Please insert alphabetically sorted. This set looks a nice bit of cleanup, though - thanks! / Leif > #include > > EFI_HANDLE mHandle = NULL; > @@ -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. > -- > 2.17.1 >