Re: [edk2-devel] [edk2-platforms/devel-MinPlatform][PATCH 4/5] KabylakeSiliconPkg/PeiResetSystemLib: Add a new API ResetSystem

2019-04-15 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 

> -Original Message-
> From: Gao, Zhichao
> Sent: Monday, April 15, 2019 11:08 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel ; Kubacki, Michael A
> ; Gao, Liming 
> Subject: [edk2-platforms/devel-MinPlatform][PATCH 4/5]
> KabylakeSiliconPkg/PeiResetSystemLib: Add a new API ResetSystem
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1460
> 
> Add a new API ResetSystem to this ResetSystemLib instance.
> It only adds the basic functions from ResetSystemRuntimeDxe.
> Lacking of this interface may cause link error, if some drivers use this new 
> API and
> link to this library instance.
> Make the ResetPlatformSpecific's parameters same with the interface in Edk2
> repo.
> Also change the caller and declaration at the same time.
> Notes:
> This library API only provide a basic function of reset. If the consumers 
> want full
> functions, they should use the instance in the MdeModulePkg and make sure the
> depex driver is dispatched.
> 
> Cc: Chasel Chiu 
> Cc: Michael A Kubacki 
> Cc: Liming Gao 
> Signed-off-by: Zhichao Gao 
> ---
>  .../Pch/Library/PeiPchResetLib/PchReset.c |  7 ++-
>  .../PeiResetSystemLib/PeiResetSystemLib.c | 47 +--
>  2 files changed, 47 insertions(+), 7 deletions(-)
> 
> diff --git
> a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchReset.c
> b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchReset.c
> index 79f3f779dc..1a30bf31f6 100644
> --- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchReset.c
> +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchRes
> +++ et.c
> @@ -1,7 +1,7 @@
>  /** @file
>PCH RESET PEIM DRIVER.
> 
> -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
>  This program and the accompanying materials are licensed and made available
> under  the terms and conditions of the BSD License that accompanies this
> distribution.
>  The full text of the license may be found at @@ -27,7 +27,6 @@ WITHOUT
> WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>  VOID
>  EFIAPI
>  ResetPlatformSpecific (
> -  IN EFI_STATUS   ResetStatus,
>IN UINTNDataSize,
>IN VOID *ResetData OPTIONAL
>);
> @@ -67,7 +66,7 @@ ResetSystem (
>  return;
> 
>case EfiResetPlatformSpecific:
> -ResetPlatformSpecific (ResetStatus, DataSize, ResetData);
> +ResetPlatformSpecific (DataSize, ResetData);
>  return;
> 
>default:
> @@ -115,7 +114,7 @@ Reset (
>  case PchGlobalReset:
>CopyMem (, , sizeof (EFI_GUID));
>StrCpyS (ResetData.Description,
> PCH_RESET_DATA_STRING_MAX_LENGTH,
> PCH_PLATFORM_SPECIFIC_RESET_STRING);
> -  ResetPlatformSpecific (EFI_SUCCESS, sizeof (PCH_RESET_DATA),
> );
> +  ResetPlatformSpecific (sizeof (PCH_RESET_DATA), );
>break;
> 
>  default:
> diff --git
> a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/PeiResetSys
> temLib.c
> b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/PeiResetSys
> temLib.c
> index 6a017a40a7..92ce6af5cc 100644
> ---
> a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/PeiResetSys
> temLib.c
> +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/Pei
> +++ ResetSystemLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>System reset library services.
> 
> -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
>  This program and the accompanying materials are licensed and made available
> under  the terms and conditions of the BSD License that accompanies this
> distribution.
>  The full text of the license may be found at @@ -239,7 +239,6 @@
> PeiPchGlobalReset (
>  /**
>Calling this function causes the system to enter a power state for platform
> specific.
> 
> -  @param[in] ResetStatus  The status code for the reset.
>@param[in] DataSize The size of ResetData in bytes.
>@param[in] ResetDataOptional element used to introduce a
> platform specific reset.
>The exact type of the reset is defined by 
> the
> EFI_GUID that follows @@ -249,7 +248,6 @@ PeiPchGlobalReset (  VOID
> EFIAPI  ResetPlatformSpecific (
> -  IN EFI_STATUS   ResetStatus,
>IN UINTNDataSize,
>IN VOID *ResetData OPTIONAL
>)
> @@ -284,3 +282,46 @@ EnterS3WithImmediateWake (
>ASSERT (FALSE);
>  }
> 
> +/**
> +  The ResetSystem function resets the en

[edk2-devel] [edk2-platforms/devel-MinPlatform][PATCH 4/5] KabylakeSiliconPkg/PeiResetSystemLib: Add a new API ResetSystem

2019-04-14 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1460

Add a new API ResetSystem to this ResetSystemLib instance.
It only adds the basic functions from ResetSystemRuntimeDxe.
Lacking of this interface may cause link error, if some drivers
use this new API and link to this library instance.
Make the ResetPlatformSpecific's parameters same with the
interface in Edk2 repo.
Also change the caller and declaration at the same time.
Notes:
This library API only provide a basic function of reset. If
the consumers want full functions, they should use the instance
in the MdeModulePkg and make sure the depex driver is dispatched.

Cc: Chasel Chiu 
Cc: Michael A Kubacki 
Cc: Liming Gao 
Signed-off-by: Zhichao Gao 
---
 .../Pch/Library/PeiPchResetLib/PchReset.c |  7 ++-
 .../PeiResetSystemLib/PeiResetSystemLib.c | 47 +--
 2 files changed, 47 insertions(+), 7 deletions(-)

diff --git 
a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchReset.c 
b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchReset.c
index 79f3f779dc..1a30bf31f6 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchReset.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiPchResetLib/PchReset.c
@@ -1,7 +1,7 @@
 /** @file
   PCH RESET PEIM DRIVER.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
under
 the terms and conditions of the BSD License that accompanies this distribution.
 The full text of the license may be found at
@@ -27,7 +27,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 VOID
 EFIAPI
 ResetPlatformSpecific (
-  IN EFI_STATUS   ResetStatus,
   IN UINTNDataSize,
   IN VOID *ResetData OPTIONAL
   );
@@ -67,7 +66,7 @@ ResetSystem (
 return;
 
   case EfiResetPlatformSpecific:
-ResetPlatformSpecific (ResetStatus, DataSize, ResetData);
+ResetPlatformSpecific (DataSize, ResetData);
 return;
 
   default:
@@ -115,7 +114,7 @@ Reset (
 case PchGlobalReset:
   CopyMem (, , sizeof (EFI_GUID));
   StrCpyS (ResetData.Description, PCH_RESET_DATA_STRING_MAX_LENGTH, 
PCH_PLATFORM_SPECIFIC_RESET_STRING);
-  ResetPlatformSpecific (EFI_SUCCESS, sizeof (PCH_RESET_DATA), );
+  ResetPlatformSpecific (sizeof (PCH_RESET_DATA), );
   break;
 
 default:
diff --git 
a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/PeiResetSystemLib.c
 
b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/PeiResetSystemLib.c
index 6a017a40a7..92ce6af5cc 100644
--- 
a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/PeiResetSystemLib.c
+++ 
b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiResetSystemLib/PeiResetSystemLib.c
@@ -1,7 +1,7 @@
 /** @file
   System reset library services.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
under
 the terms and conditions of the BSD License that accompanies this distribution.
 The full text of the license may be found at
@@ -239,7 +239,6 @@ PeiPchGlobalReset (
 /**
   Calling this function causes the system to enter a power state for platform 
specific.
 
-  @param[in] ResetStatus  The status code for the reset.
   @param[in] DataSize The size of ResetData in bytes.
   @param[in] ResetDataOptional element used to introduce a 
platform specific reset.
   The exact type of the reset is defined by 
the EFI_GUID that follows
@@ -249,7 +248,6 @@ PeiPchGlobalReset (
 VOID
 EFIAPI
 ResetPlatformSpecific (
-  IN EFI_STATUS   ResetStatus,
   IN UINTNDataSize,
   IN VOID *ResetData OPTIONAL
   )
@@ -284,3 +282,46 @@ EnterS3WithImmediateWake (
   ASSERT (FALSE);
 }
 
+/**
+  The ResetSystem function resets the entire platform.
+
+  @param[in] ResetType  The type of reset to perform.
+  @param[in] ResetStatusThe status code for the reset.
+  @param[in] DataSize   The size, in bytes, of ResetData.
+  @param[in] ResetData  For a ResetType of EfiResetCold, EfiResetWarm, or 
EfiResetShutdown
+the data buffer starts with a Null-terminated 
string, optionally
+followed by additional binary data. The string is 
a description
+that the caller may use to further indicate the 
reason for the
+system reset.
+**/
+VOID
+EFIAPI
+ResetSystem (
+  IN EFI_RESET_TYPE   ResetType,
+  IN EFI_STATUS   ResetStatus,
+  IN UINTNDataSize,
+  IN VOID *ResetData OPTIONAL
+  )
+{
+  switch (ResetType) {
+  case EfiResetWarm:
+ResetWarm ();
+