public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Abner Chang" <abner.chang@hpe.com>
To: Leif Lindholm <leif.lindholm@linaro.org>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Chen, Gilbert" <gilbert.chen@hpe.com>
Subject: Re: [edk2-staging/RISC-V-V2 PATCH v3 29/39] RiscVPlatformPkg/RealTimeClockLibNull: Null instance of RTC lib.
Date: Fri, 22 Nov 2019 12:28:01 +0000	[thread overview]
Message-ID: <CS1PR8401MB1192C32DF36D1CB7E7FC2AC6FF490@CS1PR8401MB1192.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20191121170254.GP7359@bivouac.eciton.net>



> -----Original Message-----
> From: Leif Lindholm [mailto:leif.lindholm@linaro.org]
> Sent: Friday, November 22, 2019 1:03 AM
> To: Chang, Abner (HPS SW/FW Technologist) <abner.chang@hpe.com>
> Cc: devel@edk2.groups.io; Chen, Gilbert <gilbert.chen@hpe.com>
> Subject: Re: [edk2-staging/RISC-V-V2 PATCH v3 29/39]
> RiscVPlatformPkg/RealTimeClockLibNull: Null instance of RTC lib.
> 
> 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 <abner.chang@hpe.com>
> >
> > Cc: Leif Lindholm <leif.lindholm@linaro.org>
> > Cc: Gilbert Chen <gilbert.chen@hpe.com>
> 
> Can you drop this one in favour of
> EmbeddedPkg/Library/VirtualRealTimeClockLib/

Both U500.dsc and U540.dsc use EmbeddedPkg/Library/VirtualRealTimeClockLib, you can see this in edk2-platform patches.
The NULL one is only used in RiscVplatformPkg for build. I don't think we have to use VirtualRealTimeClockLib in this RiscVplatformPkg  package.

Abner

> ?
> 
> /
>     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.i
> > nf
> > b/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNull.i
> > nf
> > new file mode 100644
> > index 0000000..b9bffa1
> > --- /dev/null
> > +++ b/RiscVPlatformPkg/Library/RealTimeClockLibNull/RealTimeClockLibNu
> > +++ ll.inf
> > @@ -0,0 +1,30 @@
> > +#/** @file
> > +#
> > +#  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All
> > +rights reserved.<BR> # #  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/RealTimeClockLibNu
> > +++ ll.c
> > @@ -0,0 +1,204 @@
> > +/** @file
> > +  EFI RealTimeClock NULL library
> > +
> > +  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All
> > + rights reserved.<BR>
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include <Uefi.h>
> > +#include <PiDxe.h>
> > +#include <Library/BaseLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/UefiLib.h>
> > +// Use EfiAtRuntime to check stage
> > +#include <Library/UefiRuntimeLib.h>
> > +#include <Library/UefiBootServicesTableLib.h>
> > +#include <Library/UefiRuntimeServicesTableLib.h>
> > +#include <Protocol/RealTimeClock.h>
> > +
> > +
> > +/**
> > +  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
> >

  reply	other threads:[~2019-11-22 12:28 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28  1:58 [edk2-staging/RISC-V-V2 PATCH v3 00/39] RISC-V EDK2 Port on Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 01/39] RiscVPkg: RISC-V processor package Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 02/39] RiscVPkg/Include: Add header files of RISC-V CPU package Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 03/39] RiscVPkg/opensbi: EDK2 RISC-V OpenSBI support Abner Chang
2019-11-21 16:24   ` Leif Lindholm
2019-12-19  4:09     ` [edk2-devel] " Abner Chang
2019-12-19 13:21       ` Leif Lindholm
2019-12-19 14:48         ` Abner Chang
     [not found]         ` <15E1CD20DD2FE7F1.29030@groups.io>
2019-12-20  3:04           ` Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 04/39] MdePkg: RISC-V RV64 binding in MdePkg Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 05/39] MdePkg/Include: RISC-V definitions Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 06/39] MdeModulePkg/CapsuleRuntimeDxe: Add RISCV64 arch Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 07/39] MdePkg/BaseLib: BaseLib for RISC-V RV64 Processor Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 08/39] MdePkg/BaseCacheMaintenanceLib: RISC-V cache maintenance implementation Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 09/39] MdePkg/BaseIoLibIntrinsic: RISC-V I/O intrinsic functions Abner Chang
2019-11-21 16:36   ` Leif Lindholm
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 10/39] MdePkg/BasePeCoff: Add RISC-V PE/Coff related code Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 11/39] MdePkg/BaseCpuLib: RISC-V Base CPU library implementation Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 12/39] MdePkg/BaseSynchronizationLib: RISC-V cache related code Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 13/39] MdeModulePkg/Logo Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 14/39] NetworkPkg Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 15/39] RiscVPkg/Library: RISC-V CPU library Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 16/39] RiscVPkg/Library: Add RISC-V exception library Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 17/39] RiscVPkg/Library: Add RISC-V timer library Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 18/39] RiscVPkg/Library: Add EDK2 RISC-V OpenSBI library Abner Chang
2019-11-21 16:48   ` [edk2-devel] " Leif Lindholm
2019-12-19  6:00     ` Abner Chang
2019-12-20 15:04       ` Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 19/39] RiscVPkg/Library: RISC-V platform level DxeIPL libraries Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 20/39] MdeModulePkg/DxeIplPeim : RISC-V platform level DxeIPL Abner Chang
2019-10-28  1:58 ` [edk2-staging/RISC-V-V2 PATCH v3 21/39] RiscVPkg/PeiServicesTablePointerLibOpenSbi: RISC-V PEI Service Table Pointer library Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 22/39] RiscVPlatformPkg/RiscVPlatformTempMemoryInit: RISC-V Platform Temporary Memory library Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 23/39] RiscVPkg/CpuDxe: Add RISC-V CPU DXE driver Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 24/39] BaseTools: BaseTools changes for RISC-V platform Abner Chang
2019-11-21 16:55   ` Leif Lindholm
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 25/39] BaseTools/Scripts Abner Chang
2019-11-19 18:17   ` [edk2-devel] " Mark Salter
2019-11-20  8:23     ` Abner Chang
2019-11-21  7:40       ` Abner Chang
2019-11-21 16:56   ` Leif Lindholm
2019-11-22  3:49     ` Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 26/39] RiscVPkg/SmbiosDxe: Generic SMBIOS DXE driver for RISC-V platforms Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 27/39] RiscVPkg/RiscVOpensbLlib: Add submodule opensbi Abner Chang
2019-11-21 17:00   ` Leif Lindholm
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 28/39] RiscVPlatformPkg/FirmwareContextProcessorSpecificLib:Add FirmwareContextProcessorSpecificLib module Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 29/39] RiscVPlatformPkg/RealTimeClockLibNull: Null instance of RTC lib Abner Chang
2019-11-21 17:02   ` Leif Lindholm
2019-11-22 12:28     ` Abner Chang [this message]
2019-11-22 14:08       ` Leif Lindholm
2019-11-22 14:19         ` Abner Chang
2019-11-22 14:55           ` Leif Lindholm
2019-11-22 16:05             ` [edk2-devel] " Abner Chang
2019-11-22 16:32               ` Leif Lindholm
2019-11-23  7:38                 ` Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 30/39] RiscVPlatformPkg/OpensbiPlatformLibNull: NULL instance of RiscVOpensbiPlatformLib Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 31/39] RiscVPlatformPkg/PlatformMemoryTestLibNull: NULL instance of PlatformMemoryTestLib Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 32/39] RiscVPlatformPkg/PlatformUpdateProgressLibNull: NULL instance of PlatformUpdateProgressLib Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 33/39] RiscVPlatformPkg/PlatformBootManagerLib: Platform Boot Manager library Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 34/39] RiscVPkg/RiscVPlatformTimerLibNull: NULL instance of RISC-V platform timer library Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 35/39] RiscVPlatformPkg/SecMain: RISC-V SecMain module Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 36/39] RiscVPlatformPkg: Add RiscVPlatformPkg Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 37/39] edk2-staging:RISC-V-V2: Add RiscVEdk2Readme.md Abner Chang
2019-11-21 17:09   ` Leif Lindholm
2019-11-22  3:57     ` [edk2-devel] " Abner Chang
2019-11-22  9:34       ` Leif Lindholm
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 38/39] edk2-staging: Revise Maintainers.txt for RISC-V packages Abner Chang
2019-10-29  1:05   ` [edk2-devel] " Laszlo Ersek
2019-10-29  1:31     ` Abner Chang
2019-10-28  1:59 ` [edk2-staging/RISC-V-V2 PATCH v3 39/39] edk2-staging: Revise Readme.md Abner Chang
2019-10-29  1:07   ` [edk2-devel] " Laszlo Ersek
2019-10-29  1:35     ` Abner Chang
2019-10-29  2:01     ` Leif Lindholm
2019-10-31  8:20       ` Laszlo Ersek
2019-11-21 17:15   ` Leif Lindholm
2019-11-22  2:05     ` Abner Chang
2019-11-22  9:42       ` Leif Lindholm
2019-11-22 11:46         ` Abner Chang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CS1PR8401MB1192C32DF36D1CB7E7FC2AC6FF490@CS1PR8401MB1192.NAMPRD84.PROD.OUTLOOK.COM \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox