From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web10.26887.1574355778027486217 for ; Thu, 21 Nov 2019 09:02:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=X17Y1LV7; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: leif.lindholm@linaro.org) Received: by mail-wr1-f68.google.com with SMTP id y11so2230126wrt.6 for ; Thu, 21 Nov 2019 09:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1+bEjoNvmFU3MSU2y2G7acupHhkc0z6594l2w50Jtj4=; b=X17Y1LV79/hTklu6Lzn7Gbdb+Miba2yOWQE2y3kFW3mH2QnUSE9SDYC1pLMI6EVS64 tididDKMrtJOdklzMdr6KAAzCI7/Po3y7+vh3d9FWNYahqCRo7/0E0LYqxmELDGBeJOI msy8gKJ2/dXKewR9R2KMwA+Ngoc1rom5vqAQmcP/wpZEoDsVzlDWPAdWIcOArKoVmFO9 cG7bbfAXBjQ4B9iI97E4O/N1h6QFtafyIlNEM60kHrdVka5yu3bzQTr/STTU9ctF5D+i wndLcYzSmMdj4RkzGmKypmZw5xq4CGdavpZDulkAS9hE5cPPgDkpBB6aefHljU5mzYCy EGBg== 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=1+bEjoNvmFU3MSU2y2G7acupHhkc0z6594l2w50Jtj4=; b=KsxWiOuKHe+pv3VOIGCu9L+SW71ZWbJnhAlblHFDKgxhE2pTWzwgSUPGZJtG5N1Gbr Hkr0o8kRGA+2+Xyib7ogVk1Z2E4CLiyiTWIXlciHQ5WB8eaaoK+vv5Amx1pjLHYW8Eco TlPJQo2qWrUPJ41TIWzOcE/D83535GGSM0CfEQH5hVtDbqWFyEpNBIkI8cRrpGoe88WH ilb/SgZobjW7CR6Ucr3I0Ipd7hQrIpn4gPc6zXbcmcPwkbeqoMqitH39gav/R8jxo9gv hVmx32J5wMJ/GGaUFgILRWnoU9CdPA0by24Yd5QE/3kz066JzsqQdt5R4dW0HY9N/RTJ S6KA== X-Gm-Message-State: APjAAAXBxoEWoFmTgWxegn9IHsejkaJD0DjVeygJnpAnrNzGa80HmfO3 D684bhSCt9GITkvS5CsbYAjSpA== X-Google-Smtp-Source: APXvYqygoE9VWtFyfqffc9jTdKRfIuSTDHpjf+GH2OlbDF/MemnsNHuzKlzVzsu+anJ9OhrTfTvhCQ== X-Received: by 2002:a5d:448a:: with SMTP id j10mr12866758wrq.79.1574355776480; Thu, 21 Nov 2019 09:02:56 -0800 (PST) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id r2sm231145wma.44.2019.11.21.09.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 09:02:55 -0800 (PST) Date: Thu, 21 Nov 2019 17:02:54 +0000 From: "Leif Lindholm" To: Abner Chang Cc: devel@edk2.groups.io, Gilbert Chen Subject: Re: [edk2-staging/RISC-V-V2 PATCH v3 29/39] RiscVPlatformPkg/RealTimeClockLibNull: Null instance of RTC lib. Message-ID: <20191121170254.GP7359@bivouac.eciton.net> References: <1572227957-13169-1-git-send-email-abner.chang@hpe.com> <1572227957-13169-30-git-send-email-abner.chang@hpe.com> MIME-Version: 1.0 In-Reply-To: <1572227957-13169-30-git-send-email-abner.chang@hpe.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Oct 28, 2019 at 09:59:07 +0800, Abner Chang wrote: > Null instance of Real Time Clock lib for RISC-V platform. > > Signed-off-by: Abner Chang > > Cc: Leif Lindholm > Cc: Gilbert Chen Can you drop this one in favour of EmbeddedPkg/Library/VirtualRealTimeClockLib/ ? / Leif > --- > .../RealTimeClockLibNull/RealTimeClockLibNull.inf | 30 +++ > .../RealTimeClockLibNull/RealTimeClockLibNull.c | 204 +++++++++++++++++++++ > 2 files changed, 234 insertions(+) > create mode 100644 RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.inf > create mode 100644 RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.c > > diff --git a/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.inf b/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.inf > new file mode 100644 > index 0000000..b9bffa1 > --- /dev/null > +++ b/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.inf > @@ -0,0 +1,30 @@ > +#/** @file > +# > +# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +#**/ > + > +[Defines] > + INF_VERSION = 0x0001001b > + BASE_NAME = RealTimeClockLibNull > + FILE_GUID = BFC3E25A-8AD0-4201-8A75-F00DE7964370 > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = RealTimeClockLib > + > +[Sources.common] > + RealTimeClockLibNull.c > + > +[Packages] > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + UefiLib > + DebugLib > +# Use EFiAtRuntime to check stage > + UefiRuntimeLib > + > +[Pcd] > + > diff --git a/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.c b/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.c > new file mode 100644 > index 0000000..904e7e7 > --- /dev/null > +++ b/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.c > @@ -0,0 +1,204 @@ > +/** @file > + EFI RealTimeClock NULL library > + > + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +// Use EfiAtRuntime to check stage > +#include > +#include > +#include > +#include > + > + > +/** > + Returns the current time and date information, and the time-keeping capabilities > + of the hardware platform. > + > + @param Time A pointer to storage to receive a snapshot of the current time. > + @param Capabilities An optional pointer to a buffer to receive the real time clock > + device's capabilities. > + > + @retval EFI_SUCCESS The operation completed successfully. > + @retval EFI_INVALID_PARAMETER Time is NULL. > + @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error. > + @retval EFI_SECURITY_VIOLATION The time could not be retrieved due to an authentication failure. > +**/ > +EFI_STATUS > +EFIAPI > +LibGetTime ( > + OUT EFI_TIME *Time, > + OUT EFI_TIME_CAPABILITIES *Capabilities > + ) > +{ > + EFI_STATUS Status = EFI_SUCCESS; > + > + return Status; > + > +} > + > + > +/** > + Sets the current local time and date information. > + > + @param Time A pointer to the current time. > + > + @retval EFI_SUCCESS The operation completed successfully. > + @retval EFI_INVALID_PARAMETER A time field is out of range. > + @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibSetTime ( > + IN EFI_TIME *Time > + ) > +{ > + > + EFI_STATUS Status = EFI_SUCCESS; > + > + > + return Status; > +} > + > + > +/** > + Returns the current wakeup alarm clock setting. > + > + @param Enabled Indicates if the alarm is currently enabled or disabled. > + @param Pending Indicates if the alarm signal is pending and requires acknowledgement. > + @param Time The current alarm setting. > + > + @retval EFI_SUCCESS The alarm settings were returned. > + @retval EFI_INVALID_PARAMETER Any parameter is NULL. > + @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibGetWakeupTime ( > + OUT BOOLEAN *Enabled, > + OUT BOOLEAN *Pending, > + OUT EFI_TIME *Time > + ) > +{ > + // Not a required feature > + return EFI_UNSUPPORTED; > +} > + > + > +/** > + Sets the system wakeup alarm clock time. > + > + @param Enabled Enable or disable the wakeup alarm. > + @param Time If Enable is TRUE, the time to set the wakeup alarm for. > + > + @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If > + Enable is FALSE, then the wakeup alarm was disabled. > + @retval EFI_INVALID_PARAMETER A time field is out of range. > + @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error. > + @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibSetWakeupTime ( > + IN BOOLEAN Enabled, > + OUT EFI_TIME *Time > + ) > +{ > + // Not a required feature > + return EFI_UNSUPPORTED; > +} > + > + > + > +/** > + This is the declaration of an EFI image entry point. This can be the entry point to an application > + written to this specification, an EFI boot service driver, or an EFI runtime driver. > + > + @param ImageHandle Handle that identifies the loaded image. > + @param SystemTable System Table for this image. > + > + @retval EFI_SUCCESS The operation completed successfully. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibRtcInitialize ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE Handle; > + > + > + EFI_TIME EfiTime; > + > + // Setup the setters and getters > + gRT->GetTime = LibGetTime; > + gRT->SetTime = LibSetTime; > + gRT->GetWakeupTime = LibGetWakeupTime; > + gRT->SetWakeupTime = LibSetWakeupTime; > + > + > + (VOID)gRT->GetTime (&EfiTime, NULL); > + if((EfiTime.Year < 2015) || (EfiTime.Year > 2099)){ > + EfiTime.Year = 2015; > + EfiTime.Month = 1; > + EfiTime.Day = 1; > + EfiTime.Hour = 0; > + EfiTime.Minute = 0; > + EfiTime.Second = 0; > + EfiTime.Nanosecond = 0; > + Status = gRT->SetTime(&EfiTime); > + if (EFI_ERROR(Status)) > + { > + DEBUG((DEBUG_ERROR, "[%a]:[%dL] Status : %r\n", __FUNCTION__, __LINE__, Status)); > + } > + } > + > + // Install the protocol > + Handle = NULL; > + Status = gBS->InstallMultipleProtocolInterfaces ( > + &Handle, > + &gEfiRealTimeClockArchProtocolGuid, NULL, > + NULL > + ); > + > + return Status; > +} > + > + > +/** > + Fixup internal data so that EFI can be call in virtual mode. > + Call the passed in Child Notify event and convert any pointers in > + lib to virtual mode. > + > + @param[in] Event The Event that is being processed > + @param[in] Context Event Context > +**/ > +VOID > +EFIAPI > +LibRtcVirtualNotifyEvent ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + // > + // Only needed if you are going to support the OS calling RTC functions in virtual mode. > + // You will need to call EfiConvertPointer (). To convert any stored physical addresses > + // to virtual address. After the OS transitions to calling in virtual mode, all future > + // runtime calls will be made in virtual mode. > + // > + return; > +} > -- > 2.7.4 >