public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Scott Telford <stelford@cadence.com>
To: <edk2-devel@ml01.01.org>, <leif.lindholm@linaro.org>,
	<afish@apple.com>, <michael.d.kinney@intel.com>
Subject: [staging/cadence-aarch64 PATCH] CadencePkg: switch to to generic ResetSystemRuntimeDxe
Date: Tue, 25 Jul 2017 17:23:31 +0100	[thread overview]
Message-ID: <1500999811-22999-1-git-send-email-stelford@cadence.com> (raw)

Change CadenceCspResetSystemLib to implement ResetSystemLib, consumed by
MdeModulePkg/Universal/ResetSystemRuntimeDxe.

Wire all reset variants to ResetCold, except for ResetShutdown and
EnterS3WithImmediateWake, which return immediately.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Scott Telford <stelford@cadence.com>
---
 CadencePkg/CadenceCsp.dsc                          |   4 +-
 CadencePkg/CadenceCsp.fdf                          |   2 +-
 .../CadenceCspResetSystemLib.c                     | 121 +++++++++++++--------
 .../CadenceCspResetSystemLib.inf                   |  13 +--
 4 files changed, 84 insertions(+), 56 deletions(-)

diff --git a/CadencePkg/CadenceCsp.dsc b/CadencePkg/CadenceCsp.dsc
index 3711b7b..ee4327d 100644
--- a/CadencePkg/CadenceCsp.dsc
+++ b/CadencePkg/CadenceCsp.dsc
@@ -103,7 +103,7 @@
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
 
   PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
-  EfiResetSystemLib|CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.inf
+  ResetSystemLib|CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.inf
 
   RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
 
@@ -620,7 +620,7 @@
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
   MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
   MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
-  EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
+  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
   EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
 
diff --git a/CadencePkg/CadenceCsp.fdf b/CadencePkg/CadenceCsp.fdf
index 8a9acbd..6fb1478 100644
--- a/CadencePkg/CadenceCsp.fdf
+++ b/CadencePkg/CadenceCsp.fdf
@@ -152,7 +152,7 @@ FvNameGuid         = b1e2a5cf-5357-4fc8-9532-49f3ce327bd3
 !endif
   INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
   INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
-  INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
+  INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
   INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
 
diff --git a/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.c b/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.c
index 20ea1a6..1996adc 100644
--- a/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.c
+++ b/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.c
@@ -1,8 +1,8 @@
 /** @file
-  Library to support ResetSystem Runtime call.
+  ResetSystemLib implementation for Cadence CSP.
 
-  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
+  Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
   Copyright (c) 2017, Cadence Design Systems, Inc. All rights reserved.
 
   This program and the accompanying materials
@@ -15,68 +15,97 @@
 
 **/
 
-#include <PiDxe.h>
 
-#include <Library/BaseLib.h>
+#include <Uefi.h>
+
 #include <Library/CspSysReg.h>
-#include <Library/DebugLib.h>
-#include <Library/EfiResetSystemLib.h>
 #include <Library/IoLib.h>
-#include <Library/PcdLib.h>
+#include <Library/ResetSystemLib.h>
+
 
 /**
-  Resets the entire platform.
+  This function causes a system-wide reset (cold reset), in which
+  all circuitry within the system returns to its initial state. This type of
+  reset is asynchronous to system operation and operates without regard to
+  cycle boundaries.
+
+  If this function returns, it means that the system does not support cold
+  reset.
+**/
+VOID
+EFIAPI
+ResetCold (
+  VOID
+  )
+{
+  //Perform cold reset of the system using CSP System Registers.
+  MmioWrite32 ((PcdGet64(PcdCspSysRegBase) + CSP_SYSREG_SW_RESET), 0xDEAD);
+}
 
-  @param  ResetType             The type of reset to perform.
-  @param  ResetStatus           The status code for the reset.
-  @param  DataSize              The size, in bytes, of WatchdogData.
-  @param  ResetData             For a ResetType of EfiResetCold, EfiResetWarm, or
-                                EfiResetShutdown the data buffer starts with a Null-terminated
-                                Unicode string, optionally followed by additional binary data.
+/**
+  This function causes a system-wide initialization (warm reset), in which all
+  processors are set to their initial state. Pending cycles are not corrupted.
 
+  If this function returns, it means that the system does not support warm
+  reset.
 **/
-EFI_STATUS
+VOID
 EFIAPI
-LibResetSystem (
-  IN EFI_RESET_TYPE   ResetType,
-  IN EFI_STATUS       ResetStatus,
-  IN UINTN            DataSize,
-  IN CHAR16           *ResetData OPTIONAL
+ResetWarm (
+  VOID
   )
 {
-  switch (ResetType) {
-  case EfiResetPlatformSpecific:
-    // Map the platform specific reset as reboot
-  case EfiResetWarm:
-    // Map a warm reset into a cold reset
-  case EfiResetShutdown:
-    // Map a shutdown into a cold reset
-  case EfiResetCold:
-    MmioWrite16((PcdGet64(PcdCspSysRegBase) + CSP_SYSREG_SW_RESET), 0xDEAD);
-    break;
-  default:
-    return EFI_INVALID_PARAMETER;
-  }
-
-  ASSERT(FALSE);
-  return EFI_UNSUPPORTED;
+  ResetCold ();
 }
 
 /**
-  Initialize any infrastructure required for LibResetSystem () to function.
+  This function causes the system to enter a power state equivalent
+  to the ACPI G2/S5 or G3 states.
 
-  @param  ImageHandle   The firmware allocated handle for the EFI image.
-  @param  SystemTable   A pointer to the EFI System Table.
+  If this function returns, it means that the system does not support shut down
+  reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+  VOID
+  )
+{
+  // not implemented
+}
+
+/**
+  This function causes the system to enter S3 and then wake up immediately.
 
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
+  If this function returns, it means that the system does not support S3
+  feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+  VOID
+  )
+{
+  // not implemented
+}
+
+/**
+  This function causes a systemwide reset. The exact type of the reset is
+  defined by the EFI_GUID that follows the Null-terminated Unicode string passed
+  into ResetData. If the platform does not recognize the EFI_GUID in ResetData
+  the platform must pick a supported reset type to perform.The platform may
+  optionally log the parameters from any non-normal reset that occurs.
 
+  @param[in]  DataSize   The size, in bytes, of ResetData.
+  @param[in]  ResetData  The data buffer starts with a Null-terminated string,
+                         followed by the EFI_GUID.
 **/
-EFI_STATUS
+VOID
 EFIAPI
-LibInitializeResetSystem (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
+ResetPlatformSpecific (
+  IN UINTN   DataSize,
+  IN VOID    *ResetData
   )
 {
-  return EFI_SUCCESS;
+  ResetCold ();
 }
diff --git a/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.inf b/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.inf
index 66491ee..949f9e2 100644
--- a/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.inf
+++ b/CadencePkg/Library/CadenceCspResetSystemLib/CadenceCspResetSystemLib.inf
@@ -1,7 +1,7 @@
 #/** @file
-# Library to support ResetSystem Runtime call.
+# ResetSystemLib implementation for Cadence CSP.
 #
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
 # Copyright (c) 2017, Cadence Design Systems, Inc. All rights reserved.
 #
 #  This program and the accompanying materials
@@ -20,21 +20,20 @@
   FILE_GUID                      = 4b1bc734-7534-4baa-b33f-7f5caa743996
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = EfiResetSystemLib
+  LIBRARY_CLASS                  = ResetSystemLib
 
 
 [Sources.common]
   CadenceCspResetSystemLib.c
 
 [Packages]
-  CadencePkg/CadenceCspPkg.dec
-  EmbeddedPkg/EmbeddedPkg.dec
+  ArmPkg/ArmPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
+  CadencePkg/CadenceCspPkg.dec
 
 [LibraryClasses]
   IoLib
-  DebugLib
-  PcdLib
 
 [FixedPcd]
   gCadenceCspTokenSpaceGuid.PcdCspSysRegBase
-- 
2.2.2



             reply	other threads:[~2017-07-25 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 16:23 Scott Telford [this message]
2017-07-31 16:38 ` [staging/cadence-aarch64 PATCH] CadencePkg: switch to to generic ResetSystemRuntimeDxe Leif Lindholm

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=1500999811-22999-1-git-send-email-stelford@cadence.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