* [PATCH 01/10] MdePkg/PeiServicesLib: Add PeiServicesResetSystem2()
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 11:37 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 02/10] MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first Ruiyu Ni
` (8 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Liming Gao
From: Michael D Kinney <michael.d.kinney@intel.com>
Add the PeiServicesResetSytstem2() function to the PeiServiesLib
to call the ResetSystem2() services in the PEI Services Table.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
MdePkg/Include/Library/PeiServicesLib.h | 24 ++++++++++++++++++++++++
MdePkg/Library/PeiServicesLib/PeiServicesLib.c | 26 ++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/MdePkg/Include/Library/PeiServicesLib.h b/MdePkg/Include/Library/PeiServicesLib.h
index 9fc22a10c1..0be72237f2 100644
--- a/MdePkg/Include/Library/PeiServicesLib.h
+++ b/MdePkg/Include/Library/PeiServicesLib.h
@@ -540,4 +540,28 @@ PeiServicesInstallFvInfo2Ppi (
IN UINT32 AuthenticationStatus
);
+/**
+ Resets the entire platform.
+
+ @param[in] ResetType The type of reset to perform.
+ @param[in] ResetStatus The 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. ResetData is only valid if ResetStatus is something
+ other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific
+ where a minimum amount of ResetData is always required.
+
+**/
+VOID
+EFIAPI
+PeiServicesResetSystem2 (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
+ );
+
#endif
diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
index 89166ccd38..d0838ed709 100644
--- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
+++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
@@ -789,3 +789,29 @@ PeiServicesInstallFvInfo2Ppi (
InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);
}
+/**
+ Resets the entire platform.
+
+ @param[in] ResetType The type of reset to perform.
+ @param[in] ResetStatus The 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. ResetData is only valid if ResetStatus is something
+ other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific
+ where a minimum amount of ResetData is always required.
+
+**/
+VOID
+EFIAPI
+PeiServicesResetSystem2 (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
+ )
+{
+ (*GetPeiServicesTablePointer())->ResetSystem2 (ResetType, ResetStatus, DataSize, ResetData);
+}
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 01/10] MdePkg/PeiServicesLib: Add PeiServicesResetSystem2()
2018-02-02 6:45 ` [PATCH 01/10] MdePkg/PeiServicesLib: Add PeiServicesResetSystem2() Ruiyu Ni
@ 2018-02-07 11:37 ` Zeng, Star
0 siblings, 0 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 11:37 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> From: Michael D Kinney <michael.d.kinney@intel.com>
>
> Add the PeiServicesResetSytstem2() function to the PeiServiesLib
> to call the ResetSystem2() services in the PEI Services Table.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Thanks,
Star
> ---
> MdePkg/Include/Library/PeiServicesLib.h | 24 ++++++++++++++++++++++++
> MdePkg/Library/PeiServicesLib/PeiServicesLib.c | 26 ++++++++++++++++++++++++++
> 2 files changed, 50 insertions(+)
>
> diff --git a/MdePkg/Include/Library/PeiServicesLib.h b/MdePkg/Include/Library/PeiServicesLib.h
> index 9fc22a10c1..0be72237f2 100644
> --- a/MdePkg/Include/Library/PeiServicesLib.h
> +++ b/MdePkg/Include/Library/PeiServicesLib.h
> @@ -540,4 +540,28 @@ PeiServicesInstallFvInfo2Ppi (
> IN UINT32 AuthenticationStatus
> );
>
> +/**
> + Resets the entire platform.
> +
> + @param[in] ResetType The type of reset to perform.
> + @param[in] ResetStatus The 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. ResetData is only valid if ResetStatus is something
> + other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific
> + where a minimum amount of ResetData is always required.
> +
> +**/
> +VOID
> +EFIAPI
> +PeiServicesResetSystem2 (
> + IN EFI_RESET_TYPE ResetType,
> + IN EFI_STATUS ResetStatus,
> + IN UINTN DataSize,
> + IN VOID *ResetData OPTIONAL
> + );
> +
> #endif
> diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
> index 89166ccd38..d0838ed709 100644
> --- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
> +++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
> @@ -789,3 +789,29 @@ PeiServicesInstallFvInfo2Ppi (
> InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);
> }
>
> +/**
> + Resets the entire platform.
> +
> + @param[in] ResetType The type of reset to perform.
> + @param[in] ResetStatus The 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. ResetData is only valid if ResetStatus is something
> + other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific
> + where a minimum amount of ResetData is always required.
> +
> +**/
> +VOID
> +EFIAPI
> +PeiServicesResetSystem2 (
> + IN EFI_RESET_TYPE ResetType,
> + IN EFI_STATUS ResetStatus,
> + IN UINTN DataSize,
> + IN VOID *ResetData OPTIONAL
> + )
> +{
> + (*GetPeiServicesTablePointer())->ResetSystem2 (ResetType, ResetStatus, DataSize, ResetData);
> +}
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 02/10] MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
2018-02-02 6:45 ` [PATCH 01/10] MdePkg/PeiServicesLib: Add PeiServicesResetSystem2() Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 11:37 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 03/10] MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c Ruiyu Ni
` (7 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Liming Gao, Star Zeng
From: Michael D Kinney <michael.d.kinney@intel.com>
Update PEI Service ResetSystem() to always attempt to use
the Reset2 PPI before looking for the Reset PPI.
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
MdeModulePkg/Core/Pei/Reset/Reset.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c b/MdeModulePkg/Core/Pei/Reset/Reset.c
index 7440eefd78..cd36c526b5 100644
--- a/MdeModulePkg/Core/Pei/Reset/Reset.c
+++ b/MdeModulePkg/Core/Pei/Reset/Reset.c
@@ -35,16 +35,21 @@ PeiResetSystem (
EFI_STATUS Status;
EFI_PEI_RESET_PPI *ResetPpi;
- Status = PeiServicesLocatePpi (
- &gEfiPeiResetPpiGuid,
- 0,
- NULL,
- (VOID **)&ResetPpi
- );
+ //
+ // Attempt to use newer ResetSystem2(). If this returns, then ResetSystem2()
+ // is not available.
+ //
+ PeiResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);
//
- // LocatePpi returns EFI_NOT_FOUND on error
+ // Look for PEI Reset System PPI
//
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiResetPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ResetPpi
+ );
if (!EFI_ERROR (Status)) {
return ResetPpi->ResetSystem (PeiServices);
}
@@ -55,6 +60,10 @@ PeiResetSystem (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)
);
+
+ //
+ // No reset PPIs are available yet.
+ //
return EFI_NOT_AVAILABLE_YET;
}
@@ -85,6 +94,9 @@ PeiResetSystem2 (
EFI_STATUS Status;
EFI_PEI_RESET2_PPI *Reset2Ppi;
+ //
+ // Look for PEI Reset System 2 PPI
+ //
Status = PeiServicesLocatePpi (
&gEfiPeiReset2PpiGuid,
0,
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 02/10] MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first
2018-02-02 6:45 ` [PATCH 02/10] MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first Ruiyu Ni
@ 2018-02-07 11:37 ` Zeng, Star
0 siblings, 0 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 11:37 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> From: Michael D Kinney <michael.d.kinney@intel.com>
>
> Update PEI Service ResetSystem() to always attempt to use
> the Reset2 PPI before looking for the Reset PPI.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Thanks,
Star
> ---
> MdeModulePkg/Core/Pei/Reset/Reset.c | 26 +++++++++++++++++++-------
> 1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c b/MdeModulePkg/Core/Pei/Reset/Reset.c
> index 7440eefd78..cd36c526b5 100644
> --- a/MdeModulePkg/Core/Pei/Reset/Reset.c
> +++ b/MdeModulePkg/Core/Pei/Reset/Reset.c
> @@ -35,16 +35,21 @@ PeiResetSystem (
> EFI_STATUS Status;
> EFI_PEI_RESET_PPI *ResetPpi;
>
> - Status = PeiServicesLocatePpi (
> - &gEfiPeiResetPpiGuid,
> - 0,
> - NULL,
> - (VOID **)&ResetPpi
> - );
> + //
> + // Attempt to use newer ResetSystem2(). If this returns, then ResetSystem2()
> + // is not available.
> + //
> + PeiResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);
>
> //
> - // LocatePpi returns EFI_NOT_FOUND on error
> + // Look for PEI Reset System PPI
> //
> + Status = PeiServicesLocatePpi (
> + &gEfiPeiResetPpiGuid,
> + 0,
> + NULL,
> + (VOID **)&ResetPpi
> + );
> if (!EFI_ERROR (Status)) {
> return ResetPpi->ResetSystem (PeiServices);
> }
> @@ -55,6 +60,10 @@ PeiResetSystem (
> EFI_ERROR_CODE | EFI_ERROR_MINOR,
> (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)
> );
> +
> + //
> + // No reset PPIs are available yet.
> + //
> return EFI_NOT_AVAILABLE_YET;
> }
>
> @@ -85,6 +94,9 @@ PeiResetSystem2 (
> EFI_STATUS Status;
> EFI_PEI_RESET2_PPI *Reset2Ppi;
>
> + //
> + // Look for PEI Reset System 2 PPI
> + //
> Status = PeiServicesLocatePpi (
> &gEfiPeiReset2PpiGuid,
> 0,
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 03/10] MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
2018-02-02 6:45 ` [PATCH 01/10] MdePkg/PeiServicesLib: Add PeiServicesResetSystem2() Ruiyu Ni
2018-02-02 6:45 ` [PATCH 02/10] MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 11:39 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler Ruiyu Ni
` (6 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Liming Gao, Star Zeng
From: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
MdeModulePkg/Core/Pei/Reset/Reset.c | 41 ++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c b/MdeModulePkg/Core/Pei/Reset/Reset.c
index cd36c526b5..e6d7899ef7 100644
--- a/MdeModulePkg/Core/Pei/Reset/Reset.c
+++ b/MdeModulePkg/Core/Pei/Reset/Reset.c
@@ -1,14 +1,14 @@
/** @file
Pei Core Reset System Support
-
+
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
@@ -29,11 +29,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
EFI_STATUS
EFIAPI
PeiResetSystem (
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- EFI_PEI_RESET_PPI *ResetPpi;
+ EFI_STATUS Status;
+ EFI_PEI_RESET_PPI *ResetPpi;
//
// Attempt to use newer ResetSystem2(). If this returns, then ResetSystem2()
@@ -52,9 +52,10 @@ PeiResetSystem (
);
if (!EFI_ERROR (Status)) {
return ResetPpi->ResetSystem (PeiServices);
- }
+ }
+
//
- // Report Status Code that Reset PPI is not available
+ // Report Status Code that Reset PPI is not available.
//
REPORT_STATUS_CODE (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
@@ -85,14 +86,14 @@ PeiResetSystem (
VOID
EFIAPI
PeiResetSystem2 (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_PEI_RESET2_PPI *Reset2Ppi;
+ EFI_STATUS Status;
+ EFI_PEI_RESET2_PPI *Reset2Ppi;
//
// Look for PEI Reset System 2 PPI
@@ -103,7 +104,6 @@ PeiResetSystem2 (
NULL,
(VOID **)&Reset2Ppi
);
-
if (!EFI_ERROR (Status)) {
Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
return;
@@ -117,4 +117,3 @@ PeiResetSystem2 (
(EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)
);
}
-
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 03/10] MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c
2018-02-02 6:45 ` [PATCH 03/10] MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c Ruiyu Ni
@ 2018-02-07 11:39 ` Zeng, Star
0 siblings, 0 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 11:39 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> From: Michael D Kinney <michael.d.kinney@intel.com>
>
> Cc: Liming Gao <liming.gao@intel.com>
> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Thanks,
Star
> ---
> MdeModulePkg/Core/Pei/Reset/Reset.c | 41 ++++++++++++++++++-------------------
> 1 file changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c b/MdeModulePkg/Core/Pei/Reset/Reset.c
> index cd36c526b5..e6d7899ef7 100644
> --- a/MdeModulePkg/Core/Pei/Reset/Reset.c
> +++ b/MdeModulePkg/Core/Pei/Reset/Reset.c
> @@ -1,14 +1,14 @@
> /** @file
> Pei Core Reset System Support
> -
> +
> Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD License
> -which accompanies this distribution. The full text of the license may be found at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD License
> +which accompanies this distribution. The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>
> **/
>
> @@ -29,11 +29,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> EFI_STATUS
> EFIAPI
> PeiResetSystem (
> - IN CONST EFI_PEI_SERVICES **PeiServices
> + IN CONST EFI_PEI_SERVICES **PeiServices
> )
> {
> - EFI_STATUS Status;
> - EFI_PEI_RESET_PPI *ResetPpi;
> + EFI_STATUS Status;
> + EFI_PEI_RESET_PPI *ResetPpi;
>
> //
> // Attempt to use newer ResetSystem2(). If this returns, then ResetSystem2()
> @@ -52,9 +52,10 @@ PeiResetSystem (
> );
> if (!EFI_ERROR (Status)) {
> return ResetPpi->ResetSystem (PeiServices);
> - }
> + }
> +
> //
> - // Report Status Code that Reset PPI is not available
> + // Report Status Code that Reset PPI is not available.
> //
> REPORT_STATUS_CODE (
> EFI_ERROR_CODE | EFI_ERROR_MINOR,
> @@ -85,14 +86,14 @@ PeiResetSystem (
> VOID
> EFIAPI
> PeiResetSystem2 (
> - IN EFI_RESET_TYPE ResetType,
> - IN EFI_STATUS ResetStatus,
> - IN UINTN DataSize,
> - IN VOID *ResetData OPTIONAL
> + IN EFI_RESET_TYPE ResetType,
> + IN EFI_STATUS ResetStatus,
> + IN UINTN DataSize,
> + IN VOID *ResetData OPTIONAL
> )
> {
> - EFI_STATUS Status;
> - EFI_PEI_RESET2_PPI *Reset2Ppi;
> + EFI_STATUS Status;
> + EFI_PEI_RESET2_PPI *Reset2Ppi;
>
> //
> // Look for PEI Reset System 2 PPI
> @@ -103,7 +104,6 @@ PeiResetSystem2 (
> NULL,
> (VOID **)&Reset2Ppi
> );
> -
> if (!EFI_ERROR (Status)) {
> Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
> return;
> @@ -117,4 +117,3 @@ PeiResetSystem2 (
> (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)
> );
> }
> -
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
` (2 preceding siblings ...)
2018-02-02 6:45 ` [PATCH 03/10] MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-02 13:46 ` Laszlo Ersek
2018-02-07 11:44 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message Ruiyu Ni
` (5 subsequent siblings)
9 siblings, 2 replies; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Liming Gao, Star Zeng
From: Michael D Kinney <michael.d.kinney@intel.com>
Add support for platform specific reset filters and platform
specific reset handlers to ResetSystem(). A filter may modify
the reset type and reset data and call ResetSystem() with the
modified parameters. A handler performs the reset action.
The support for platform specific filters and platform specific
handlers is based on the Reset Notification feature added to the
UEFI 2.7 Specification.
Platform specific reset filters are processed first so the final
reset type and reset data can be determined. In the DXE Phase
The UEFI Reset Notifications are processed second so all UEFI
Drivers that have registered for a Reset Notification can perform
any required clean up actions. The platform specific reset
handlers are processed third. If there are no registered
platform specific reset handlers or none of them reset the
platform, then the default reset action based on the
ResetSystemLib is performed.
In the PEI Phase, filters are handlers are registered through
the folloiwng 2 PPIs that are based on
EFI_RESET_NOTIFICATION_PROTOCOL.
* gEdkiiPlatformSpecificResetFilterPpiGuid
* gEdkiiPlatformSpecificResetFilterPpiGuid
In the DXE Phase, filters are handlers are registered through
the folloiwng 2 Protocols that are based on
EFI_RESET_NOTIFICATION_PROTOCOL.
* gEdkiiPlatformSpecificResetFilterProtocolGuid
* gEdkiiPlatformSpecificResetFilterProtocolGuid
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
.../Include/Ppi/PlatformSpecificResetFilter.h | 31 +++++++++
.../Include/Ppi/PlatformSpecificResetHandler.h | 29 +++++++++
.../Include/Protocol/PlatformSpecificResetFilter.h | 31 +++++++++
.../Protocol/PlatformSpecificResetHandler.h | 29 +++++++++
MdeModulePkg/MdeModulePkg.dec | 10 +++
.../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 75 ++++++++++++++++++++--
.../Universal/ResetSystemRuntimeDxe/ResetSystem.h | 7 ++
.../ResetSystemRuntimeDxe.inf | 7 +-
8 files changed, 212 insertions(+), 7 deletions(-)
create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h
create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h
create mode 100644 MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h
create mode 100644 MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h
diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h b/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h
new file mode 100644
index 0000000000..0f1432f5f8
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h
@@ -0,0 +1,31 @@
+/** @file
+ This PPI provides services to register a platform specific reset filter
+ for ResetSystem(). A reset filter evaluates the parameters passed to
+ ResetSystem() and converts a ResetType of EfiResetPlatformSpecific to a
+ non-platform specific reset type. The registered filters are processed before
+ EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI handlers.
+
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_SPECIFIC_RESET_FILTER_PPI_H_
+#define _PLATFORM_SPECIFIC_RESET_FILTER_PPI_H_
+
+#include <Protocol/ResetNotification.h>
+
+#define EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI_GUID \
+ { 0x8c9f4de3, 0x7b90, 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }
+
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI;
+
+extern EFI_GUID gEdkiiPlatformSpecificResetFilterPpiGuid;
+
+#endif
diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h b/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h
new file mode 100644
index 0000000000..d5f1350c69
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h
@@ -0,0 +1,29 @@
+/** @file
+ This PPI provides services to register a platform specific handler for
+ ResetSystem(). The registered handlers are processed after
+ EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications.
+
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_SPECIFIC_RESET_HANDLER_PPI_H_
+#define _PLATFORM_SPECIFIC_RESET_HANDLER_PPI_H_
+
+#include <Protocol/ResetNotification.h>
+
+#define EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI_GUID \
+ { 0x75cf14ae, 0x3441, 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }
+
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI;
+
+extern EFI_GUID gEdkiiPlatformSpecificResetHandlerPpiGuid;
+
+#endif
diff --git a/MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h b/MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h
new file mode 100644
index 0000000000..ff5ca48fdd
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h
@@ -0,0 +1,31 @@
+/** @file
+ This Protocol provides services to register a platform specific reset filter
+ for ResetSystem(). A reset filter evaluates the parameters passed to
+ ResetSystem() and converts a ResetType of EfiResetPlatformSpecific to a
+ non-platform specific reset type. The registered filters are processed before
+ the UEFI 2.7 Reset Notifications.
+
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_H_
+#define _PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_H_
+
+#include <Protocol/ResetNotification.h>
+
+#define EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_GUID \
+ { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } }
+
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL;
+
+extern EFI_GUID gEdkiiPlatformSpecificResetFilterProtocolGuid;
+
+#endif
diff --git a/MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h b/MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h
new file mode 100644
index 0000000000..8a44e860b2
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h
@@ -0,0 +1,29 @@
+/** @file
+ This protocol provides services to register a platform specific handler for
+ ResetSystem(). The registered handlers are called after the UEFI 2.7 Reset
+ Notifications are processed
+
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_H_
+#define _PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_H_
+
+#include <Protocol/ResetNotification.h>
+
+#define EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_GUID \
+ { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } }
+
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL;
+
+extern EFI_GUID gEdkiiPlatformSpecificResetHandlerProtocolGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 61d034fba8..1cc9bc8ea1 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -441,6 +441,12 @@ [Ppis]
## Include/Ppi/IoMmu.h
gEdkiiIoMmuPpiGuid = { 0x70b0af26, 0xf847, 0x4bb6, { 0xaa, 0xb9, 0xcd, 0xe8, 0x4f, 0xc6, 0x14, 0x31 } }
+ ## Include/Ppi/PlatformSpecificResetFilter.h
+ gEdkiiPlatformSpecificResetFilterPpiGuid = { 0x8c9f4de3, 0x7b90, 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }
+
+ ## Include/Ppi/PlatformSpecificResetHandler.h
+ gEdkiiPlatformSpecificResetHandlerPpiGuid = { 0x75cf14ae, 0x3441, 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }
+
[Protocols]
## Load File protocol provides capability to load and unload EFI image into memory and execute it.
# Include/Protocol/LoadPe32Image.h
@@ -565,6 +571,10 @@ [Protocols]
## Include/Protocol/SdMmcOverride.h
gEdkiiSdMmcOverrideProtocolGuid = { 0xeaf9e3c1, 0xc9cd, 0x46db, { 0xa5, 0xe5, 0x5a, 0x12, 0x4c, 0x83, 0x23, 0x23 } }
+ ## Include/Protocol/PlatformSpecificResetFilter.h
+ gEdkiiPlatformSpecificResetFilterProtocolGuid = { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } }
+ ## Include/Protocol/PlatformSpecificResetHandler.h
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid = { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } }
#
# [Error.gEfiMdeModulePkgTokenSpaceGuid]
# 0x80000001 | Invalid value provided.
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
index 75cff37773..43400e1338 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
@@ -15,6 +15,11 @@
#include "ResetSystem.h"
+//
+// The current ResetSystem() notification recursion depth
+//
+UINTN mResetNotifyDepth = 0;
+
/**
Register a notification function to be called when ResetSystem() is called.
@@ -130,6 +135,24 @@ RESET_NOTIFICATION_INSTANCE mResetNotification = {
INITIALIZE_LIST_HEAD_VARIABLE (mResetNotification.ResetNotifies)
};
+RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetFilter = {
+ RESET_NOTIFICATION_INSTANCE_SIGNATURE,
+ {
+ RegisterResetNotify,
+ UnregisterResetNotify
+ },
+ INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetFilter.ResetNotifies)
+};
+
+RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetHandler = {
+ RESET_NOTIFICATION_INSTANCE_SIGNATURE,
+ {
+ RegisterResetNotify,
+ UnregisterResetNotify
+ },
+ INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetHandler.ResetNotifies)
+};
+
/**
The driver's entry point.
@@ -170,6 +193,8 @@ InitializeResetSystem (
&Handle,
&gEfiResetArchProtocolGuid, NULL,
&gEfiResetNotificationProtocolGuid, &mResetNotification.ResetNotification,
+ &gEdkiiPlatformSpecificResetFilterProtocolGuid, &mPlatformSpecificResetFilter.ResetNotification,
+ &gEdkiiPlatformSpecificResetHandlerProtocolGuid, &mPlatformSpecificResetHandler.ResetNotification,
NULL
);
ASSERT_EFI_ERROR (Status);
@@ -225,13 +250,44 @@ ResetSystem (
UINTN CapsuleDataPtr;
LIST_ENTRY *Link;
RESET_NOTIFY_ENTRY *Entry;
-
+
+ //
+ // Above the maximum recursion depth, so do the smallest amount of
+ // work to perform a cold reset.
+ //
+ if (mResetNotifyDepth >= MAX_RESET_NOTIFY_DEPTH) {
+ ResetCold ();
+ ASSERT (FALSE);
+ return;
+ }
+
//
- // Indicate reset system runtime service is called.
+ // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
//
- REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
+ if (mResetNotifyDepth == 0) {
+ //
+ // Indicate reset system runtime service is called.
+ //
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
+ }
- if (!EfiAtRuntime ()) {
+ mResetNotifyDepth++;
+ if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) {
+ //
+ // Call reset notification functions registered through the
+ // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
+ //
+ for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
+ ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
+ ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link)
+ ) {
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+ }
+ //
+ // Call reset notification functions registered through the
+ // EFI_RESET_NOTIFICATION_PROTOCOL.
+ //
for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
; !IsNull (&mResetNotification.ResetNotifies, Link)
; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
@@ -239,6 +295,17 @@ ResetSystem (
Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
}
+ //
+ // call reset notification functions registered through the
+ // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
+ //
+ for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
+ ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+ ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+ ) {
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+ }
}
switch (ResetType) {
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
index 75cdd88896..ea5660274b 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
@@ -20,6 +20,8 @@
#include <Protocol/Reset.h>
#include <Protocol/ResetNotification.h>
+#include <Protocol/PlatformSpecificResetFilter.h>
+#include <Protocol/PlatformSpecificResetHandler.h>
#include <Guid/CapsuleVendor.h>
#include <Library/BaseLib.h>
@@ -34,6 +36,11 @@
#include <Library/ReportStatusCodeLib.h>
#include <Library/MemoryAllocationLib.h>
+//
+// The maximum recurstion depth to ResetSystem() by reset notification handlers
+//
+#define MAX_RESET_NOTIFY_DEPTH 10
+
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
index 11233757c2..da9e8e118b 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
@@ -55,9 +55,10 @@ [Guids]
[Protocols]
- gEfiResetArchProtocolGuid ## PRODUCES
- gEfiResetNotificationProtocolGuid ## PRODUCES
-
+ gEfiResetArchProtocolGuid ## PRODUCES
+ gEfiResetNotificationProtocolGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetFilterProtocolGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid ## PRODUCES
[Depex]
TRUE
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler
2018-02-02 6:45 ` [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler Ruiyu Ni
@ 2018-02-02 13:46 ` Laszlo Ersek
2018-02-06 2:56 ` Ni, Ruiyu
2018-02-07 11:44 ` Zeng, Star
1 sibling, 1 reply; 31+ messages in thread
From: Laszlo Ersek @ 2018-02-02 13:46 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Star Zeng, Liming Gao
On 02/02/18 07:45, Ruiyu Ni wrote:
> From: Michael D Kinney <michael.d.kinney@intel.com>
>
> Add support for platform specific reset filters and platform
> specific reset handlers to ResetSystem(). A filter may modify
> the reset type and reset data and call ResetSystem() with the
> modified parameters. A handler performs the reset action.
>
> The support for platform specific filters and platform specific
> handlers is based on the Reset Notification feature added to the
> UEFI 2.7 Specification.
>
> Platform specific reset filters are processed first so the final
> reset type and reset data can be determined. In the DXE Phase
> The UEFI Reset Notifications are processed second so all UEFI
> Drivers that have registered for a Reset Notification can perform
> any required clean up actions. The platform specific reset
> handlers are processed third. If there are no registered
> platform specific reset handlers or none of them reset the
> platform, then the default reset action based on the
> ResetSystemLib is performed.
>
> In the PEI Phase, filters are handlers are registered through
> the folloiwng 2 PPIs that are based on
> EFI_RESET_NOTIFICATION_PROTOCOL.
> * gEdkiiPlatformSpecificResetFilterPpiGuid
> * gEdkiiPlatformSpecificResetFilterPpiGuid
The second entry should be "gEdkiiPlatformSpecificResetHandlerPpiGuid".
>
> In the DXE Phase, filters are handlers are registered through
> the folloiwng 2 Protocols that are based on
> EFI_RESET_NOTIFICATION_PROTOCOL.
> * gEdkiiPlatformSpecificResetFilterProtocolGuid
> * gEdkiiPlatformSpecificResetFilterProtocolGuid
The second entry should be "gEdkiiPlatformSpecificResetHandlerProtocolGuid".
[...]
Thanks
Laszlo
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler
2018-02-02 13:46 ` Laszlo Ersek
@ 2018-02-06 2:56 ` Ni, Ruiyu
0 siblings, 0 replies; 31+ messages in thread
From: Ni, Ruiyu @ 2018-02-06 2:56 UTC (permalink / raw)
To: Laszlo Ersek, edk2-devel@lists.01.org
Cc: Kinney, Michael D, Zeng, Star, Gao, Liming
On 2/2/2018 9:46 PM, Laszlo Ersek wrote:
> On 02/02/18 07:45, Ruiyu Ni wrote:
>> From: Michael D Kinney <michael.d.kinney@intel.com>
>>
>> Add support for platform specific reset filters and platform
>> specific reset handlers to ResetSystem(). A filter may modify
>> the reset type and reset data and call ResetSystem() with the
>> modified parameters. A handler performs the reset action.
>>
>> The support for platform specific filters and platform specific
>> handlers is based on the Reset Notification feature added to the
>> UEFI 2.7 Specification.
>>
>> Platform specific reset filters are processed first so the final
>> reset type and reset data can be determined. In the DXE Phase
>> The UEFI Reset Notifications are processed second so all UEFI
>> Drivers that have registered for a Reset Notification can perform
>> any required clean up actions. The platform specific reset
>> handlers are processed third. If there are no registered
>> platform specific reset handlers or none of them reset the
>> platform, then the default reset action based on the
>> ResetSystemLib is performed.
>>
>> In the PEI Phase, filters are handlers are registered through
>> the folloiwng 2 PPIs that are based on
>> EFI_RESET_NOTIFICATION_PROTOCOL.
>> * gEdkiiPlatformSpecificResetFilterPpiGuid
>> * gEdkiiPlatformSpecificResetFilterPpiGuid
>
> The second entry should be "gEdkiiPlatformSpecificResetHandlerPpiGuid".
>
>>
>> In the DXE Phase, filters are handlers are registered through
>> the folloiwng 2 Protocols that are based on
>> EFI_RESET_NOTIFICATION_PROTOCOL.
>> * gEdkiiPlatformSpecificResetFilterProtocolGuid
>> * gEdkiiPlatformSpecificResetFilterProtocolGuid
>
> The second entry should be "gEdkiiPlatformSpecificResetHandlerProtocolGuid".
>
> [...]
>
> Thanks
> Laszlo
>
Thanks. I will change the commit message when checking in.
--
Thanks,
Ray
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler
2018-02-02 6:45 ` [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler Ruiyu Ni
2018-02-02 13:46 ` Laszlo Ersek
@ 2018-02-07 11:44 ` Zeng, Star
1 sibling, 0 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 11:44 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
Some minor comments added below except Laszlo's.
With them handled, Reviewed-by: Star Zeng <star.zeng@intel.com>
On 2018/2/2 14:45, Ruiyu Ni wrote:
> From: Michael D Kinney <michael.d.kinney@intel.com>
>
> Add support for platform specific reset filters and platform
> specific reset handlers to ResetSystem(). A filter may modify
> the reset type and reset data and call ResetSystem() with the
> modified parameters. A handler performs the reset action.
>
> The support for platform specific filters and platform specific
> handlers is based on the Reset Notification feature added to the
> UEFI 2.7 Specification.
>
> Platform specific reset filters are processed first so the final
> reset type and reset data can be determined. In the DXE Phase
> The UEFI Reset Notifications are processed second so all UEFI
> Drivers that have registered for a Reset Notification can perform
> any required clean up actions. The platform specific reset
> handlers are processed third. If there are no registered
> platform specific reset handlers or none of them reset the
> platform, then the default reset action based on the
> ResetSystemLib is performed.
>
> In the PEI Phase, filters are handlers are registered through
Should be "filters and handlers"?
> the folloiwng 2 PPIs that are based on
> EFI_RESET_NOTIFICATION_PROTOCOL.
> * gEdkiiPlatformSpecificResetFilterPpiGuid
> * gEdkiiPlatformSpecificResetFilterPpiGuid
>
> In the DXE Phase, filters are handlers are registered through
Should be "filters and handlers"?
> the folloiwng 2 Protocols that are based on
> EFI_RESET_NOTIFICATION_PROTOCOL.
> * gEdkiiPlatformSpecificResetFilterProtocolGuid
> * gEdkiiPlatformSpecificResetFilterProtocolGuid
>
> Cc: Liming Gao <liming.gao@intel.com>
> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
[...]
> + //
> + // call reset notification functions registered through the
> + // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
Should be EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL?
Thanks,
Star
> + //
> + for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
> + ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
> + ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)
> + ) {
> + Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
> + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
> + }
> }
>
> switch (ResetType) {
> diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
> index 75cdd88896..ea5660274b 100644
> --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
> +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
> @@ -20,6 +20,8 @@
>
> #include <Protocol/Reset.h>
> #include <Protocol/ResetNotification.h>
> +#include <Protocol/PlatformSpecificResetFilter.h>
> +#include <Protocol/PlatformSpecificResetHandler.h>
> #include <Guid/CapsuleVendor.h>
>
> #include <Library/BaseLib.h>
> @@ -34,6 +36,11 @@
> #include <Library/ReportStatusCodeLib.h>
> #include <Library/MemoryAllocationLib.h>
>
> +//
> +// The maximum recurstion depth to ResetSystem() by reset notification handlers
> +//
> +#define MAX_RESET_NOTIFY_DEPTH 10
> +
> typedef struct {
> UINT32 Signature;
> LIST_ENTRY Link;
> diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
> index 11233757c2..da9e8e118b 100644
> --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
> +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
> @@ -55,9 +55,10 @@ [Guids]
>
>
> [Protocols]
> - gEfiResetArchProtocolGuid ## PRODUCES
> - gEfiResetNotificationProtocolGuid ## PRODUCES
> -
> + gEfiResetArchProtocolGuid ## PRODUCES
> + gEfiResetNotificationProtocolGuid ## PRODUCES
> + gEdkiiPlatformSpecificResetFilterProtocolGuid ## PRODUCES
> + gEdkiiPlatformSpecificResetHandlerProtocolGuid ## PRODUCES
>
> [Depex]
> TRUE
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
` (3 preceding siblings ...)
2018-02-02 6:45 ` [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 12:04 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services Ruiyu Ni
` (4 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Michael D Kinney, Star Zeng
The patch adds more debug message in ResetSystem().
It also removes unnecessary check of mResetNotifyDepth.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
.../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 88 +++++++++++-----------
1 file changed, 44 insertions(+), 44 deletions(-)
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
index 43400e1338..4b5af76999 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
@@ -15,6 +15,10 @@
#include "ResetSystem.h"
+GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
+ L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
+};
+
//
// The current ResetSystem() notification recursion depth
//
@@ -251,16 +255,6 @@ ResetSystem (
LIST_ENTRY *Link;
RESET_NOTIFY_ENTRY *Entry;
- //
- // Above the maximum recursion depth, so do the smallest amount of
- // work to perform a cold reset.
- //
- if (mResetNotifyDepth >= MAX_RESET_NOTIFY_DEPTH) {
- ResetCold ();
- ASSERT (FALSE);
- return;
- }
-
//
// Only do REPORT_STATUS_CODE() on first call to ResetSystem()
//
@@ -272,40 +266,47 @@ ResetSystem (
}
mResetNotifyDepth++;
- if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) {
- //
- // Call reset notification functions registered through the
- // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
- //
- for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
- ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
- ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link)
- ) {
- Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
- Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
- }
- //
- // Call reset notification functions registered through the
- // EFI_RESET_NOTIFICATION_PROTOCOL.
- //
- for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
- ; !IsNull (&mResetNotification.ResetNotifies, Link)
- ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
- ) {
- Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
- Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
- }
- //
- // call reset notification functions registered through the
- // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
- //
- for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
- ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
- ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)
- ) {
- Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
- Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+ DEBUG ((DEBUG_INFO, "DXE ResetSystem2: Reset call depth = %d.\n", mResetNotifyDepth));
+
+ if (mResetNotifyDepth <= MAX_RESET_NOTIFY_DEPTH) {
+ if (!EfiAtRuntime ()) {
+ //
+ // Call reset notification functions registered through the
+ // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
+ //
+ for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
+ ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
+ ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link)
+ ) {
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+ }
+ //
+ // Call reset notification functions registered through the
+ // EFI_RESET_NOTIFICATION_PROTOCOL.
+ //
+ for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
+ ; !IsNull (&mResetNotification.ResetNotifies, Link)
+ ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
+ ) {
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+ }
+ //
+ // call reset notification functions registered through the
+ // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
+ //
+ for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
+ ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+ ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+ ) {
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+ }
}
+ } else {
+ ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
+ DEBUG ((DEBUG_ERROR, "DXE ResetSystem2: Maximum reset call depth is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));
}
switch (ResetType) {
@@ -331,7 +332,6 @@ ResetSystem (
}
ResetWarm ();
-
break;
case EfiResetCold:
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message
2018-02-02 6:45 ` [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message Ruiyu Ni
@ 2018-02-07 12:04 ` Zeng, Star
2018-02-09 3:01 ` Ni, Ruiyu
0 siblings, 1 reply; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 12:04 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> The patch adds more debug message in ResetSystem().
> It also removes unnecessary check of mResetNotifyDepth.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> ---
> .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 88 +++++++++++-----------
> 1 file changed, 44 insertions(+), 44 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> index 43400e1338..4b5af76999 100644
> --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
> @@ -15,6 +15,10 @@
>
> #include "ResetSystem.h"
>
> +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
> + L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
> +};
> +
> //
> // The current ResetSystem() notification recursion depth
> //
> @@ -251,16 +255,6 @@ ResetSystem (
> LIST_ENTRY *Link;
> RESET_NOTIFY_ENTRY *Entry;
>
> - //
> - // Above the maximum recursion depth, so do the smallest amount of
> - // work to perform a cold reset.
> - //
> - if (mResetNotifyDepth >= MAX_RESET_NOTIFY_DEPTH) {
> - ResetCold ();
> - ASSERT (FALSE);
> - return;
> - }
> -
> //
> // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
> //
> @@ -272,40 +266,47 @@ ResetSystem (
> }
>
> mResetNotifyDepth++;
> - if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) {
> - //
> - // Call reset notification functions registered through the
> - // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
> - //
> - for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
> - ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
> - ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link)
> - ) {
> - Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
> - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
> - }
> - //
> - // Call reset notification functions registered through the
> - // EFI_RESET_NOTIFICATION_PROTOCOL.
> - //
> - for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
> - ; !IsNull (&mResetNotification.ResetNotifies, Link)
> - ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
> - ) {
> - Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
> - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
> - }
> - //
> - // call reset notification functions registered through the
> - // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
> - //
> - for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
> - ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
> - ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)
> - ) {
> - Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
> - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
> + DEBUG ((DEBUG_INFO, "DXE ResetSystem2: Reset call depth = %d.\n", mResetNotifyDepth));
> +
> + if (mResetNotifyDepth <= MAX_RESET_NOTIFY_DEPTH) {
Should be mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH?
Thanks,
Star
> + if (!EfiAtRuntime ()) {
> + //
> + // Call reset notification functions registered through the
> + // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
> + //
> + for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
> + ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
> + ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link)
> + ) {
> + Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
> + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
> + }
> + //
> + // Call reset notification functions registered through the
> + // EFI_RESET_NOTIFICATION_PROTOCOL.
> + //
> + for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
> + ; !IsNull (&mResetNotification.ResetNotifies, Link)
> + ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
> + ) {
> + Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
> + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
> + }
> + //
> + // call reset notification functions registered through the
> + // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
> + //
> + for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
> + ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
> + ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)
> + ) {
> + Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
> + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
> + }
> }
> + } else {
> + ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
> + DEBUG ((DEBUG_ERROR, "DXE ResetSystem2: Maximum reset call depth is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));
> }
>
> switch (ResetType) {
> @@ -331,7 +332,6 @@ ResetSystem (
> }
>
> ResetWarm ();
> -
> break;
>
> case EfiResetCold:
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message
2018-02-07 12:04 ` Zeng, Star
@ 2018-02-09 3:01 ` Ni, Ruiyu
0 siblings, 0 replies; 31+ messages in thread
From: Ni, Ruiyu @ 2018-02-09 3:01 UTC (permalink / raw)
To: Zeng, Star, edk2-devel; +Cc: Michael D Kinney, Liming Gao
On 2/7/2018 8:04 PM, Zeng, Star wrote:
> On 2018/2/2 14:45, Ruiyu Ni wrote:
>> The patch adds more debug message in ResetSystem().
>> It also removes unnecessary check of mResetNotifyDepth.
>>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>> ---
>> .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 88
>> +++++++++++-----------
>> 1 file changed, 44 insertions(+), 44 deletions(-)
>>
>> diff --git
>> a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
>> b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
>> index 43400e1338..4b5af76999 100644
>> --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
>> +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
>> @@ -15,6 +15,10 @@
>> #include "ResetSystem.h"
>> +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
>> + L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
>> +};
>> +
>> //
>> // The current ResetSystem() notification recursion depth
>> //
>> @@ -251,16 +255,6 @@ ResetSystem (
>> LIST_ENTRY *Link;
>> RESET_NOTIFY_ENTRY *Entry;
>> - //
>> - // Above the maximum recursion depth, so do the smallest amount of
>> - // work to perform a cold reset.
>> - //
>> - if (mResetNotifyDepth >= MAX_RESET_NOTIFY_DEPTH) {
>> - ResetCold ();
>> - ASSERT (FALSE);
>> - return;
>> - }
>> -
>> //
>> // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
>> //
>> @@ -272,40 +266,47 @@ ResetSystem (
>> }
>> mResetNotifyDepth++;
>> - if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) {
>> - //
>> - // Call reset notification functions registered through the
>> - // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
>> - //
>> - for ( Link = GetFirstNode
>> (&mPlatformSpecificResetFilter.ResetNotifies)
>> - ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
>> - ; Link = GetNextNode
>> (&mPlatformSpecificResetFilter.ResetNotifies, Link)
>> - ) {
>> - Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
>> - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
>> - }
>> - //
>> - // Call reset notification functions registered through the
>> - // EFI_RESET_NOTIFICATION_PROTOCOL.
>> - //
>> - for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
>> - ; !IsNull (&mResetNotification.ResetNotifies, Link)
>> - ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
>> - ) {
>> - Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
>> - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
>> - }
>> - //
>> - // call reset notification functions registered through the
>> - // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
>> - //
>> - for ( Link = GetFirstNode
>> (&mPlatformSpecificResetHandler.ResetNotifies)
>> - ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
>> - ; Link = GetNextNode
>> (&mPlatformSpecificResetHandler.ResetNotifies, Link)
>> - ) {
>> - Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
>> - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
>> + DEBUG ((DEBUG_INFO, "DXE ResetSystem2: Reset call depth = %d.\n",
>> mResetNotifyDepth));
>> +
>> + if (mResetNotifyDepth <= MAX_RESET_NOTIFY_DEPTH) {
>
> Should be mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH?
No. The intention is the MAX_RESET_NOTIFY_DEPTH times of call is
permitted.
>
> Thanks,
> Star
>
>> + if (!EfiAtRuntime ()) {
>> + //
>> + // Call reset notification functions registered through the
>> + // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
>> + //
>> + for ( Link = GetFirstNode
>> (&mPlatformSpecificResetFilter.ResetNotifies)
>> + ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
>> + ; Link = GetNextNode
>> (&mPlatformSpecificResetFilter.ResetNotifies, Link)
>> + ) {
>> + Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
>> + Entry->ResetNotify (ResetType, ResetStatus, DataSize,
>> ResetData);
>> + }
>> + //
>> + // Call reset notification functions registered through the
>> + // EFI_RESET_NOTIFICATION_PROTOCOL.
>> + //
>> + for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
>> + ; !IsNull (&mResetNotification.ResetNotifies, Link)
>> + ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
>> + ) {
>> + Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
>> + Entry->ResetNotify (ResetType, ResetStatus, DataSize,
>> ResetData);
>> + }
>> + //
>> + // call reset notification functions registered through the
>> + // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
>> + //
>> + for ( Link = GetFirstNode
>> (&mPlatformSpecificResetHandler.ResetNotifies)
>> + ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
>> + ; Link = GetNextNode
>> (&mPlatformSpecificResetHandler.ResetNotifies, Link)
>> + ) {
>> + Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
>> + Entry->ResetNotify (ResetType, ResetStatus, DataSize,
>> ResetData);
>> + }
>> }
>> + } else {
>> + ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
>> + DEBUG ((DEBUG_ERROR, "DXE ResetSystem2: Maximum reset call depth
>> is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));
>> }
>> switch (ResetType) {
>> @@ -331,7 +332,6 @@ ResetSystem (
>> }
>> ResetWarm ();
>> -
>> break;
>> case EfiResetCold:
>>
>
--
Thanks,
Ray
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
` (4 preceding siblings ...)
2018-02-02 6:45 ` [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 12:20 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance Ruiyu Ni
` (3 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Liming Gao, Star Zeng
From: Michael D Kinney <michael.d.kinney@intel.com>
Add a PEI instance of ResetSystemLib that calls the ResetSystem2()
service in the PEI Services Table.
Add a DXE instance of ResetSystemLib that calls the ResetSystem()
service in the UEFI Runtime Services Table.
These 2 library instances should be the default ResetSystemLib
mapping for most PEIMs and DXE drivers so all reset system requests
go through the core service.
Only the implementation of the core servies should use the
platform specific instance of the ResetSystemLib that actually
performs the hardware actions to reset the platform.
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
.../Library/DxeResetSystemLib/DxeResetSystemLib.c | 100 +++++++++++++++++++++
.../DxeResetSystemLib/DxeResetSystemLib.inf | 40 +++++++++
.../DxeResetSystemLib/DxeResetSystemLib.uni | 21 +++++
.../Library/PeiResetSystemLib/PeiResetSystemLib.c | 100 +++++++++++++++++++++
.../PeiResetSystemLib/PeiResetSystemLib.inf | 40 +++++++++
.../PeiResetSystemLib/PeiResetSystemLib.uni | 21 +++++
6 files changed, 322 insertions(+)
create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
new file mode 100644
index 0000000000..70ee1175d5
--- /dev/null
+++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
@@ -0,0 +1,100 @@
+/** @file
+ DXE Reset System Library instance that calls gRT->ResetSystem().
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiDxe.h>
+
+#include <Library/ResetSystemLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeLib.h>
+
+/**
+ 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
+ )
+{
+ EfiResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+ 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.
+**/
+VOID
+EFIAPI
+ResetWarm (
+ VOID
+ )
+{
+ EfiResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+ This function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ If this function returns, it means that the system does not support shut down reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+ EfiResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+ This function causes the system to enter S3 and then wake up immediately.
+
+ If this function returns, it means that the system does not support S3 feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+ VOID
+ )
+{
+}
+
+/**
+ 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.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+ IN UINTN DataSize,
+ IN VOID *ResetData
+ )
+{
+ EfiResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
+}
diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
new file mode 100644
index 0000000000..f2e04cfd00
--- /dev/null
+++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
@@ -0,0 +1,40 @@
+## @file
+# DXE Reset System Library instance that calls gRT->ResetSystem().
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeResetSystemLib
+ MODULE_UNI_FILE = DxeResetSystemLib.uni
+ FILE_GUID = C2BDE4F6-65EE-440B-87B5-83ABF10EF45B
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ResetSystemLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ DxeResetSystemLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ DebugLib
+ UefiRuntimeLib
+
diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
new file mode 100644
index 0000000000..7c51ce0713
--- /dev/null
+++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
@@ -0,0 +1,21 @@
+// /** @file
+// DXE Reset System Library instance that calls gRT->ResetSystem().
+//
+// DXE Reset System Library instance that calls gRT->ResetSystem().
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT #language en-US "DXE Reset System Library instance that calls gRT->ResetSystem()"
+
+#string STR_MODULE_DESCRIPTION #language en-US "DXE Reset System Library instance that calls gRT->ResetSystem()."
+
diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
new file mode 100644
index 0000000000..b7e10110b0
--- /dev/null
+++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
@@ -0,0 +1,100 @@
+/** @file
+ PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiPei.h>
+
+#include <Library/ResetSystemLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+
+/**
+ 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
+ )
+{
+ PeiServicesResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+ 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.
+**/
+VOID
+EFIAPI
+ResetWarm (
+ VOID
+ )
+{
+ PeiServicesResetSystem2 (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+ This function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ If this function returns, it means that the system does not support shut down reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+ PeiServicesResetSystem2 (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+ This function causes the system to enter S3 and then wake up immediately.
+
+ If this function returns, it means that the system does not support S3 feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+ VOID
+ )
+{
+}
+
+/**
+ 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.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+ IN UINTN DataSize,
+ IN VOID *ResetData
+ )
+{
+ PeiServicesResetSystem2 (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
+}
diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
new file mode 100644
index 0000000000..e82ec6b2b6
--- /dev/null
+++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
@@ -0,0 +1,40 @@
+## @file
+# PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiResetSystemLib
+ MODULE_UNI_FILE = PeiResetSystemLib.uni
+ FILE_GUID = 3198FF36-FC72-42E7-B98A-A080D823AFBF
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ResetSystemLib|PEI_CORE PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ PeiResetSystemLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ DebugLib
+ PeiServicesLib
+
diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
new file mode 100644
index 0000000000..ac996b3cc8
--- /dev/null
+++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
@@ -0,0 +1,21 @@
+// /** @file
+// PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
+//
+// PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT #language en-US "PEI Reset System Library instance that calls the ResetSystem2() PEI Service"
+
+#string STR_MODULE_DESCRIPTION #language en-US "PEI Reset System Library instance that calls the ResetSystem2() PEI Service."
+
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services
2018-02-02 6:45 ` [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services Ruiyu Ni
@ 2018-02-07 12:20 ` Zeng, Star
2018-02-09 3:00 ` Ni, Ruiyu
0 siblings, 1 reply; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 12:20 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> From: Michael D Kinney <michael.d.kinney@intel.com>
>
> Add a PEI instance of ResetSystemLib that calls the ResetSystem2()
> service in the PEI Services Table.
>
> Add a DXE instance of ResetSystemLib that calls the ResetSystem()
> service in the UEFI Runtime Services Table.
>
> These 2 library instances should be the default ResetSystemLib
> mapping for most PEIMs and DXE drivers so all reset system requests
> go through the core service.
>
> Only the implementation of the core servies should use the
> platform specific instance of the ResetSystemLib that actually
> performs the hardware actions to reset the platform.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Could we remove DebugLib in *.inf and #include <Library/DebugLib.h> in
*.c as the code seems not using any DebugLib interface at all?
Thanks,
Star
> ---
> .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 100 +++++++++++++++++++++
> .../DxeResetSystemLib/DxeResetSystemLib.inf | 40 +++++++++
> .../DxeResetSystemLib/DxeResetSystemLib.uni | 21 +++++
> .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 100 +++++++++++++++++++++
> .../PeiResetSystemLib/PeiResetSystemLib.inf | 40 +++++++++
> .../PeiResetSystemLib/PeiResetSystemLib.uni | 21 +++++
> 6 files changed, 322 insertions(+)
> create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
> create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
> create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
> create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
> create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
> create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
>
> diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
> new file mode 100644
> index 0000000000..70ee1175d5
> --- /dev/null
> +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
> @@ -0,0 +1,100 @@
> +/** @file
> + DXE Reset System Library instance that calls gRT->ResetSystem().
> +
> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <PiDxe.h>
> +
> +#include <Library/ResetSystemLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiRuntimeLib.h>
> +
> +/**
> + 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
> + )
> +{
> + EfiResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
> +}
> +
> +/**
> + 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.
> +**/
> +VOID
> +EFIAPI
> +ResetWarm (
> + VOID
> + )
> +{
> + EfiResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
> +}
> +
> +/**
> + This function causes the system to enter a power state equivalent
> + to the ACPI G2/S5 or G3 states.
> +
> + If this function returns, it means that the system does not support shut down reset.
> +**/
> +VOID
> +EFIAPI
> +ResetShutdown (
> + VOID
> + )
> +{
> + EfiResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
> +}
> +
> +/**
> + This function causes the system to enter S3 and then wake up immediately.
> +
> + If this function returns, it means that the system does not support S3 feature.
> +**/
> +VOID
> +EFIAPI
> +EnterS3WithImmediateWake (
> + VOID
> + )
> +{
> +}
> +
> +/**
> + 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.
> +**/
> +VOID
> +EFIAPI
> +ResetPlatformSpecific (
> + IN UINTN DataSize,
> + IN VOID *ResetData
> + )
> +{
> + EfiResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
> +}
> diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
> new file mode 100644
> index 0000000000..f2e04cfd00
> --- /dev/null
> +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
> @@ -0,0 +1,40 @@
> +## @file
> +# DXE Reset System Library instance that calls gRT->ResetSystem().
> +#
> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = DxeResetSystemLib
> + MODULE_UNI_FILE = DxeResetSystemLib.uni
> + FILE_GUID = C2BDE4F6-65EE-440B-87B5-83ABF10EF45B
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ResetSystemLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 IPF EBC
> +#
> +
> +[Sources]
> + DxeResetSystemLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> + DebugLib
> + UefiRuntimeLib
> +
> diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
> new file mode 100644
> index 0000000000..7c51ce0713
> --- /dev/null
> +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
> @@ -0,0 +1,21 @@
> +// /** @file
> +// DXE Reset System Library instance that calls gRT->ResetSystem().
> +//
> +// DXE Reset System Library instance that calls gRT->ResetSystem().
> +//
> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials
> +// are licensed and made available under the terms and conditions of the BSD License
> +// which accompanies this distribution. The full text of the license may be found at
> +// http://opensource.org/licenses/bsd-license.php
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT #language en-US "DXE Reset System Library instance that calls gRT->ResetSystem()"
> +
> +#string STR_MODULE_DESCRIPTION #language en-US "DXE Reset System Library instance that calls gRT->ResetSystem()."
> +
> diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
> new file mode 100644
> index 0000000000..b7e10110b0
> --- /dev/null
> +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
> @@ -0,0 +1,100 @@
> +/** @file
> + PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
> +
> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <PiPei.h>
> +
> +#include <Library/ResetSystemLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/PeiServicesLib.h>
> +
> +/**
> + 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
> + )
> +{
> + PeiServicesResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);
> +}
> +
> +/**
> + 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.
> +**/
> +VOID
> +EFIAPI
> +ResetWarm (
> + VOID
> + )
> +{
> + PeiServicesResetSystem2 (EfiResetWarm, EFI_SUCCESS, 0, NULL);
> +}
> +
> +/**
> + This function causes the system to enter a power state equivalent
> + to the ACPI G2/S5 or G3 states.
> +
> + If this function returns, it means that the system does not support shut down reset.
> +**/
> +VOID
> +EFIAPI
> +ResetShutdown (
> + VOID
> + )
> +{
> + PeiServicesResetSystem2 (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
> +}
> +
> +/**
> + This function causes the system to enter S3 and then wake up immediately.
> +
> + If this function returns, it means that the system does not support S3 feature.
> +**/
> +VOID
> +EFIAPI
> +EnterS3WithImmediateWake (
> + VOID
> + )
> +{
> +}
> +
> +/**
> + 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.
> +**/
> +VOID
> +EFIAPI
> +ResetPlatformSpecific (
> + IN UINTN DataSize,
> + IN VOID *ResetData
> + )
> +{
> + PeiServicesResetSystem2 (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
> +}
> diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
> new file mode 100644
> index 0000000000..e82ec6b2b6
> --- /dev/null
> +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
> @@ -0,0 +1,40 @@
> +## @file
> +# PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
> +#
> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = PeiResetSystemLib
> + MODULE_UNI_FILE = PeiResetSystemLib.uni
> + FILE_GUID = 3198FF36-FC72-42E7-B98A-A080D823AFBF
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ResetSystemLib|PEI_CORE PEIM
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 IPF EBC
> +#
> +
> +[Sources]
> + PeiResetSystemLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> + DebugLib
> + PeiServicesLib
> +
> diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
> new file mode 100644
> index 0000000000..ac996b3cc8
> --- /dev/null
> +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
> @@ -0,0 +1,21 @@
> +// /** @file
> +// PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
> +//
> +// PEI Reset System Library instance that calls the ResetSystem2() PEI Service.
> +//
> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials
> +// are licensed and made available under the terms and conditions of the BSD License
> +// which accompanies this distribution. The full text of the license may be found at
> +// http://opensource.org/licenses/bsd-license.php
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT #language en-US "PEI Reset System Library instance that calls the ResetSystem2() PEI Service"
> +
> +#string STR_MODULE_DESCRIPTION #language en-US "PEI Reset System Library instance that calls the ResetSystem2() PEI Service."
> +
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services
2018-02-07 12:20 ` Zeng, Star
@ 2018-02-09 3:00 ` Ni, Ruiyu
0 siblings, 0 replies; 31+ messages in thread
From: Ni, Ruiyu @ 2018-02-09 3:00 UTC (permalink / raw)
To: Zeng, Star, edk2-devel; +Cc: Michael D Kinney, Liming Gao
On 2/7/2018 8:20 PM, Zeng, Star wrote:
> On 2018/2/2 14:45, Ruiyu Ni wrote:
>> From: Michael D Kinney <michael.d.kinney@intel.com>
>>
>> Add a PEI instance of ResetSystemLib that calls the ResetSystem2()
>> service in the PEI Services Table.
>>
>> Add a DXE instance of ResetSystemLib that calls the ResetSystem()
>> service in the UEFI Runtime Services Table.
>>
>> These 2 library instances should be the default ResetSystemLib
>> mapping for most PEIMs and DXE drivers so all reset system requests
>> go through the core service.
>>
>> Only the implementation of the core servies should use the
>> platform specific instance of the ResetSystemLib that actually
>> performs the hardware actions to reset the platform.
>>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
>
> Could we remove DebugLib in *.inf and #include <Library/DebugLib.h> in
> *.c as the code seems not using any DebugLib interface at all?
Yes you are correct.
I will remove DebugLib and inclusion of DebugLib.h from both library
instances.
>
>
> Thanks,
> Star
>
>> ---
>> .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 100
>> +++++++++++++++++++++
>> .../DxeResetSystemLib/DxeResetSystemLib.inf | 40 +++++++++
>> .../DxeResetSystemLib/DxeResetSystemLib.uni | 21 +++++
>> .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 100
>> +++++++++++++++++++++
>> .../PeiResetSystemLib/PeiResetSystemLib.inf | 40 +++++++++
>> .../PeiResetSystemLib/PeiResetSystemLib.uni | 21 +++++
>> 6 files changed, 322 insertions(+)
>> create mode 100644
>> MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
>> create mode 100644
>> MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
>> create mode 100644
>> MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
>> create mode 100644
>> MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
>> create mode 100644
>> MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
>> create mode 100644
>> MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
>>
>> diff --git
>> a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
>> b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
>> new file mode 100644
>> index 0000000000..70ee1175d5
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
>> @@ -0,0 +1,100 @@
>> +/** @file
>> + DXE Reset System Library instance that calls gRT->ResetSystem().
>> +
>> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> + This program and the accompanying materials
>> + are licensed and made available under the terms and conditions of
>> the BSD License
>> + which accompanies this distribution. The full text of the license
>> may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#include <PiDxe.h>
>> +
>> +#include <Library/ResetSystemLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/UefiRuntimeLib.h>
>> +
>> +/**
>> + 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
>> + )
>> +{
>> + EfiResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
>> +}
>> +
>> +/**
>> + 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.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetWarm (
>> + VOID
>> + )
>> +{
>> + EfiResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
>> +}
>> +
>> +/**
>> + This function causes the system to enter a power state equivalent
>> + to the ACPI G2/S5 or G3 states.
>> +
>> + If this function returns, it means that the system does not support
>> shut down reset.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetShutdown (
>> + VOID
>> + )
>> +{
>> + EfiResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
>> +}
>> +
>> +/**
>> + This function causes the system to enter S3 and then wake up
>> immediately.
>> +
>> + If this function returns, it means that the system does not support
>> S3 feature.
>> +**/
>> +VOID
>> +EFIAPI
>> +EnterS3WithImmediateWake (
>> + VOID
>> + )
>> +{
>> +}
>> +
>> +/**
>> + 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.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetPlatformSpecific (
>> + IN UINTN DataSize,
>> + IN VOID *ResetData
>> + )
>> +{
>> + EfiResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize,
>> ResetData);
>> +}
>> diff --git
>> a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
>> b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
>> new file mode 100644
>> index 0000000000..f2e04cfd00
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
>> @@ -0,0 +1,40 @@
>> +## @file
>> +# DXE Reset System Library instance that calls gRT->ResetSystem().
>> +#
>> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +#
>> +# This program and the accompanying materials
>> +# are licensed and made available under the terms and conditions of
>> the BSD License
>> +# which accompanies this distribution. The full text of the license
>> may be found at
>> +# http://opensource.org/licenses/bsd-license.php
>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +#
>> +##
>> +
>> +[Defines]
>> + INF_VERSION = 0x00010005
>> + BASE_NAME = DxeResetSystemLib
>> + MODULE_UNI_FILE = DxeResetSystemLib.uni
>> + FILE_GUID = C2BDE4F6-65EE-440B-87B5-83ABF10EF45B
>> + MODULE_TYPE = DXE_DRIVER
>> + VERSION_STRING = 1.0
>> + LIBRARY_CLASS = ResetSystemLib|DXE_CORE DXE_DRIVER
>> DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION
>> UEFI_DRIVER
>> +
>> +#
>> +# The following information is for reference only and not required by
>> the build tools.
>> +#
>> +# VALID_ARCHITECTURES = IA32 X64 IPF EBC
>> +#
>> +
>> +[Sources]
>> + DxeResetSystemLib.c
>> +
>> +[Packages]
>> + MdePkg/MdePkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> +
>> +[LibraryClasses]
>> + DebugLib
>> + UefiRuntimeLib
>> +
>> diff --git
>> a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
>> b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
>> new file mode 100644
>> index 0000000000..7c51ce0713
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
>> @@ -0,0 +1,21 @@
>> +// /** @file
>> +// DXE Reset System Library instance that calls gRT->ResetSystem().
>> +//
>> +// DXE Reset System Library instance that calls gRT->ResetSystem().
>> +//
>> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +//
>> +// This program and the accompanying materials
>> +// are licensed and made available under the terms and conditions of
>> the BSD License
>> +// which accompanies this distribution. The full text of the license
>> may be found at
>> +// http://opensource.org/licenses/bsd-license.php
>> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +//
>> +// **/
>> +
>> +
>> +#string STR_MODULE_ABSTRACT #language en-US "DXE Reset
>> System Library instance that calls gRT->ResetSystem()"
>> +
>> +#string STR_MODULE_DESCRIPTION #language en-US "DXE Reset
>> System Library instance that calls gRT->ResetSystem()."
>> +
>> diff --git
>> a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
>> b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
>> new file mode 100644
>> index 0000000000..b7e10110b0
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
>> @@ -0,0 +1,100 @@
>> +/** @file
>> + PEI Reset System Library instance that calls the ResetSystem2() PEI
>> Service.
>> +
>> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> + This program and the accompanying materials
>> + are licensed and made available under the terms and conditions of
>> the BSD License
>> + which accompanies this distribution. The full text of the license
>> may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#include <PiPei.h>
>> +
>> +#include <Library/ResetSystemLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/PeiServicesLib.h>
>> +
>> +/**
>> + 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
>> + )
>> +{
>> + PeiServicesResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);
>> +}
>> +
>> +/**
>> + 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.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetWarm (
>> + VOID
>> + )
>> +{
>> + PeiServicesResetSystem2 (EfiResetWarm, EFI_SUCCESS, 0, NULL);
>> +}
>> +
>> +/**
>> + This function causes the system to enter a power state equivalent
>> + to the ACPI G2/S5 or G3 states.
>> +
>> + If this function returns, it means that the system does not support
>> shut down reset.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetShutdown (
>> + VOID
>> + )
>> +{
>> + PeiServicesResetSystem2 (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
>> +}
>> +
>> +/**
>> + This function causes the system to enter S3 and then wake up
>> immediately.
>> +
>> + If this function returns, it means that the system does not support
>> S3 feature.
>> +**/
>> +VOID
>> +EFIAPI
>> +EnterS3WithImmediateWake (
>> + VOID
>> + )
>> +{
>> +}
>> +
>> +/**
>> + 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.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetPlatformSpecific (
>> + IN UINTN DataSize,
>> + IN VOID *ResetData
>> + )
>> +{
>> + PeiServicesResetSystem2 (EfiResetPlatformSpecific, EFI_SUCCESS,
>> DataSize, ResetData);
>> +}
>> diff --git
>> a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
>> b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
>> new file mode 100644
>> index 0000000000..e82ec6b2b6
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
>> @@ -0,0 +1,40 @@
>> +## @file
>> +# PEI Reset System Library instance that calls the ResetSystem2()
>> PEI Service.
>> +#
>> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +#
>> +# This program and the accompanying materials
>> +# are licensed and made available under the terms and conditions of
>> the BSD License
>> +# which accompanies this distribution. The full text of the license
>> may be found at
>> +# http://opensource.org/licenses/bsd-license.php
>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +#
>> +##
>> +
>> +[Defines]
>> + INF_VERSION = 0x00010005
>> + BASE_NAME = PeiResetSystemLib
>> + MODULE_UNI_FILE = PeiResetSystemLib.uni
>> + FILE_GUID = 3198FF36-FC72-42E7-B98A-A080D823AFBF
>> + MODULE_TYPE = PEIM
>> + VERSION_STRING = 1.0
>> + LIBRARY_CLASS = ResetSystemLib|PEI_CORE PEIM
>> +
>> +#
>> +# The following information is for reference only and not required by
>> the build tools.
>> +#
>> +# VALID_ARCHITECTURES = IA32 X64 IPF EBC
>> +#
>> +
>> +[Sources]
>> + PeiResetSystemLib.c
>> +
>> +[Packages]
>> + MdePkg/MdePkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> +
>> +[LibraryClasses]
>> + DebugLib
>> + PeiServicesLib
>> +
>> diff --git
>> a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
>> b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
>> new file mode 100644
>> index 0000000000..ac996b3cc8
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni
>> @@ -0,0 +1,21 @@
>> +// /** @file
>> +// PEI Reset System Library instance that calls the ResetSystem2()
>> PEI Service.
>> +//
>> +// PEI Reset System Library instance that calls the ResetSystem2()
>> PEI Service.
>> +//
>> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +//
>> +// This program and the accompanying materials
>> +// are licensed and made available under the terms and conditions of
>> the BSD License
>> +// which accompanies this distribution. The full text of the license
>> may be found at
>> +// http://opensource.org/licenses/bsd-license.php
>> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +//
>> +// **/
>> +
>> +
>> +#string STR_MODULE_ABSTRACT #language en-US "PEI Reset
>> System Library instance that calls the ResetSystem2() PEI Service"
>> +
>> +#string STR_MODULE_DESCRIPTION #language en-US "PEI Reset
>> System Library instance that calls the ResetSystem2() PEI Service."
>> +
>>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
--
Thanks,
Ray
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
` (5 preceding siblings ...)
2018-02-02 6:45 ` [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 12:28 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types Ruiyu Ni
` (2 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Liming Gao, Star Zeng
From: Michael D Kinney <michael.d.kinney@intel.com>
The library class that provides services to generate a GUID specific
reset, parse the GUID from a GUID specific reset, and build the
ResetData buffer for any type of reset that requires extra data.
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++++++++++
.../Library/ResetUtilityLib/ResetUtility.c | 221 +++++++++++++++++++++
.../Library/ResetUtilityLib/ResetUtilityLib.inf | 43 ++++
MdeModulePkg/MdeModulePkg.dsc | 7 +
4 files changed, 382 insertions(+)
create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h
create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h b/MdeModulePkg/Include/Library/ResetUtilityLib.h
new file mode 100644
index 0000000000..94828785e2
--- /dev/null
+++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h
@@ -0,0 +1,111 @@
+/** @file
+ This header describes various helper functions for resetting the system.
+
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
+
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef _RESET_UTILITY_LIB_H_
+#define _RESET_UTILITY_LIB_H_
+
+/**
+ This is a shorthand helper function to reset with a subtype so that
+ the caller doesn't have to bother with a function that has half a dozen
+ parameters.
+
+ This will generate a reset with status EFI_SUCCESS, a NULL string, and
+ no custom data. The subtype will be formatted in such a way that it can be
+ picked up by notification registrations and custom handlers.
+
+ NOTE: This call will fail if the architectural ResetSystem underpinnings
+ are not initialized. For DXE, you can add gEfiResetArchProtocolGuid
+ to your DEPEX.
+
+ @param[in] ResetType Base reset type as defined in UEFI spec.
+ @param[in] ResetSubtype GUID pointer for the reset subtype to be used.
+
+**/
+VOID
+EFIAPI
+ResetPlatformSpecificGuid (
+ IN CONST GUID *ResetSubtype
+ );
+
+/**
+ This function examines the DataSize and ResetData parameters passed to
+ to ResetSystem() and detemrines if the ResetData contains a Null-terminated
+ Unicode string followed by a GUID specific subtype. If the GUID specific
+ subtype is present, then a pointer to the GUID value in ResetData is returned.
+
+ @param[in] DataSize The size, in bytes, of ResetData.
+ @param[in] ResetData Pointer to the data buffer passed into ResetSystem().
+
+ @retval Pointer Pointer to the GUID value in ResetData.
+ @retval NULL ResetData is NULL.
+ @retval NULL ResetData does not start with a Null-terminated
+ Unicode string.
+ @retval NULL A Null-terminated Unicode string is present, but there
+ are less than sizeof (GUID) bytes after the string.
+ @retval NULL No subtype is found.
+
+**/
+GUID *
+EFIAPI
+GetResetPlatformSpecificGuid (
+ IN UINTN DataSize,
+ IN CONST VOID *ResetData
+ );
+
+/**
+ This is a helper function that creates the reset data buffer that can be
+ passed into ResetSystem().
+
+ The reset data buffer is returned in ResetData and contains ResetString
+ followed by the ResetSubtype GUID followed by the ExtraData.
+
+ NOTE: Strings are internally limited by MAX_UINT16.
+
+ @param[in, out] ResetDataSize On input, the size of the ResetData buffer. On
+ output, either the total number of bytes
+ copied, or the required buffer size.
+ @param[in, out] ResetData A pointer to the buffer in which to place the
+ final structure.
+ @param[in] ResetSubtype Pointer to the GUID specific subtype. This
+ parameter is optional and may be NULL.
+ @param[in] ResetString Pointer to a Null-terminated Unicode string
+ that describes the reset. This parameter is
+ optional and may be NULL.
+ @param[in] ExtraDataSize The size, in bytes, of ExtraData buffer.
+ @param[in] ExtraData Pointer to a buffer of extra data. This
+ parameter is optional and may be NULL.
+
+ @retval RETURN_SUCCESS ResetDataSize and ResetData are updated.
+ @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
+ @retval RETURN_INVALID_PARAMETER ResetData is NULL.
+ @retval RETURN_INVALID_PARAMETER ExtraData was provided without a
+ ResetSubtype. This is not supported by the
+ UEFI spec.
+ @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was provided.
+ ResetDataSize is updated with minimum size
+ required.
+**/
+RETURN_STATUS
+EFIAPI
+BuildResetData (
+ IN OUT UINTN *ResetDataSize,
+ IN OUT VOID *ResetData,
+ IN CONST GUID *ResetSubtype OPTIONAL,
+ IN CONST CHAR16 *ResetString OPTIONAL,
+ IN UINTN ExtraDataSize OPTIONAL,
+ IN CONST VOID *ExtraData OPTIONAL
+ );
+
+#endif // _RESET_UTILITY_LIB_H_
diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
new file mode 100644
index 0000000000..5bbe002be0
--- /dev/null
+++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
@@ -0,0 +1,221 @@
+/** @file
+ This contains the business logic for the module-specific Reset Helper functions.
+
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
+
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/ResetSystemLib.h>
+
+typedef struct {
+ CHAR16 NullTerminator;
+ GUID ResetSubtype;
+} RESET_UTILITY_GUID_SPECIFIC_RESET_DATA;
+
+/**
+ This is a shorthand helper function to reset with a subtype so that
+ the caller doesn't have to bother with a function that has half a dozen
+ parameters.
+
+ This will generate a reset with status EFI_SUCCESS, a NULL string, and
+ no custom data. The subtype will be formatted in such a way that it can be
+ picked up by notification registrations and custom handlers.
+
+ NOTE: This call will fail if the architectural ResetSystem underpinnings
+ are not initialized. For DXE, you can add gEfiResetArchProtocolGuid
+ to your DEPEX.
+
+ @param[in] ResetType Base reset type as defined in UEFI spec.
+ @param[in] ResetSubtype GUID pointer for the reset subtype to be used.
+
+**/
+VOID
+EFIAPI
+ResetPlatformSpecificGuid (
+ IN CONST GUID *ResetSubtype
+ )
+{
+ RESET_UTILITY_GUID_SPECIFIC_RESET_DATA ResetData;
+
+ ResetData.NullTerminator = CHAR_NULL;
+ CopyGuid (&ResetData.ResetSubtype, ResetSubtype);
+ ResetPlatformSpecific (sizeof (ResetData), &ResetData);
+}
+
+/**
+ This function examines the DataSize and ResetData parameters passed to
+ to ResetSystem() and detemrines if the ResetData contains a Null-terminated
+ Unicode string followed by a GUID specific subtype. If the GUID specific
+ subtype is present, then a pointer to the GUID value in ResetData is returned.
+
+ @param[in] DataSize The size, in bytes, of ResetData.
+ @param[in] ResetData Pointer to the data buffer passed into ResetSystem().
+
+ @retval Pointer Pointer to the GUID value in ResetData.
+ @retval NULL ResetData is NULL.
+ @retval NULL ResetData does not start with a Null-terminated
+ Unicode string.
+ @retval NULL A Null-terminated Unicode string is present, but there
+ are less than sizeof (GUID) bytes after the string.
+ @retval NULL No subtype is found.
+
+**/
+GUID *
+EFIAPI
+GetResetPlatformSpecificGuid (
+ IN UINTN DataSize,
+ IN CONST VOID *ResetData
+ )
+{
+ UINTN ResetDataStringSize;
+ GUID *ResetSubtypeGuid;
+
+ //
+ // Make sure parameters are valid
+ //
+ if ((ResetData == NULL) || (DataSize < sizeof (GUID))) {
+ return NULL;
+ }
+
+ //
+ // Determine the number of bytes in in the Null-terminated Unicode string
+ // at the beginning of ResetData including the Null terminator.
+ //
+ ResetDataStringSize = StrnSizeS (ResetData, (DataSize / sizeof (CHAR16)));
+
+ //
+ // Now, assuming that we have enough data for a GUID after the string, the
+ // GUID should be immediately after the string itself.
+ //
+ if ((ResetDataStringSize < DataSize) && (DataSize - ResetDataStringSize) >= sizeof (GUID)) {
+ ResetSubtypeGuid = (GUID *)((UINT8 *)ResetData + ResetDataStringSize);
+ DEBUG ((DEBUG_VERBOSE, __FUNCTION__" - Detected reset subtype %g...\n", ResetSubtypeGuid));
+ return ResetSubtypeGuid;
+ }
+ return NULL;
+}
+
+/**
+ This is a helper function that creates the reset data buffer that can be
+ passed into ResetSystem().
+
+ The reset data buffer is returned in ResetData and contains ResetString
+ followed by the ResetSubtype GUID followed by the ExtraData.
+
+ NOTE: Strings are internally limited by MAX_UINT16.
+
+ @param[in, out] ResetDataSize On input, the size of the ResetData buffer. On
+ output, either the total number of bytes
+ copied, or the required buffer size.
+ @param[in, out] ResetData A pointer to the buffer in which to place the
+ final structure.
+ @param[in] ResetSubtype Pointer to the GUID specific subtype. This
+ parameter is optional and may be NULL.
+ @param[in] ResetString Pointer to a Null-terminated Unicode string
+ that describes the reset. This parameter is
+ optional and may be NULL.
+ @param[in] ExtraDataSize The size, in bytes, of ExtraData buffer.
+ @param[in] ExtraData Pointer to a buffer of extra data. This
+ parameter is optional and may be NULL.
+
+ @retval RETURN_SUCCESS ResetDataSize and ResetData are updated.
+ @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
+ @retval RETURN_INVALID_PARAMETER ResetData is NULL.
+ @retval RETURN_INVALID_PARAMETER ExtraData was provided without a
+ ResetSubtype. This is not supported by the
+ UEFI spec.
+ @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was provided.
+ ResetDataSize is updated with minimum size
+ required.
+**/
+RETURN_STATUS
+EFIAPI
+BuildResetData (
+ IN OUT UINTN *ResetDataSize,
+ IN OUT VOID *ResetData,
+ IN CONST GUID *ResetSubtype OPTIONAL,
+ IN CONST CHAR16 *ResetString OPTIONAL,
+ IN UINTN ExtraDataSize OPTIONAL,
+ IN CONST VOID *ExtraData OPTIONAL
+ )
+{
+ UINTN ResetStringSize;
+ UINTN ResetDataBufferSize;
+ UINT8 *Data;
+
+ //
+ // If the size return pointer is NULL.
+ //
+ if (ResetDataSize == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+ //
+ // If extra data is indicated, but pointer is NULL.
+ //
+ if (ExtraDataSize > 0 && ExtraData == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+ //
+ // If extra data is indicated, but no subtype GUID is supplied.
+ //
+ if (ResetSubtype == NULL && ExtraDataSize > 0) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ //
+ // Determine the final string.
+ //
+ if (ResetString == NULL) {
+ ResetString = L""; // Use an empty string.
+ }
+
+ //
+ // Calculate the total buffer required for ResetData.
+ //
+ ResetStringSize = StrnSizeS (ResetString, MAX_UINT16);
+ ResetDataBufferSize = ResetStringSize + ExtraDataSize;
+ if (ResetSubtype != NULL) {
+ ResetDataBufferSize += sizeof (GUID);
+ }
+
+ //
+ // At this point, if the buffer isn't large enough (or if
+ // the buffer is NULL) we cannot proceed.
+ //
+ if (*ResetDataSize < ResetDataBufferSize) {
+ *ResetDataSize = ResetDataBufferSize;
+ return RETURN_BUFFER_TOO_SMALL;
+ }
+ *ResetDataSize = ResetDataBufferSize;
+ if (ResetData == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ //
+ // Fill in ResetData with ResetString, the ResetSubtype GUID, and extra data
+ //
+ Data = (UINT8 *)ResetData;
+ CopyMem (Data, ResetString, ResetStringSize);
+ Data += ResetStringSize;
+ if (ResetSubtype != NULL) {
+ CopyMem (Data, ResetSubtype, sizeof (GUID));
+ Data += sizeof (GUID);
+ }
+ if (ExtraDataSize > 0) {
+ CopyMem (Data, ExtraData, ExtraDataSize);
+ }
+
+ return RETURN_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
new file mode 100644
index 0000000000..7a403749c5
--- /dev/null
+++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
@@ -0,0 +1,43 @@
+## @file
+# This file contains the Reset Utility functions.
+#
+# The application pops up a menu showing all the boot options referenced by
+# BootOrder NV variable and user can choose to boot from one of them.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = ResetUtilityLib
+ FILE_GUID = CAFC3CA1-3E32-449F-9B0E-40BA3CB73A12
+ VERSION_STRING = 1.0
+ MODULE_TYPE = BASE
+ LIBRARY_CLASS = ResetUtilityLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ ResetUtility.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ BaseMemoryLib
+ ResetSystemLib
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index dd7e9d5988..d96bff90b0 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -285,13 +285,16 @@ [Components]
MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
+ MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.inf
MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
+ MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+ MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
@@ -358,6 +361,10 @@ [Components]
MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
MdeModulePkg/Universal/Metronome/Metronome.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+ MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf {
+ <LibraryClasses>
+ ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
+ }
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance
2018-02-02 6:45 ` [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance Ruiyu Ni
@ 2018-02-07 12:28 ` Zeng, Star
2018-02-08 1:36 ` Zeng, Star
0 siblings, 1 reply; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 12:28 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> From: Michael D Kinney <michael.d.kinney@intel.com>
>
> The library class that provides services to generate a GUID specific
> reset, parse the GUID from a GUID specific reset, and build the
> ResetData buffer for any type of reset that requires extra data.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Should we also add below lines in MdeModulePkg.dec?
## @libraryclass Defines a set of helper functions for resetting
the system
ResetUtilityLib|Include/Library/ResetUtilityLib.h
Thanks,
Star
> ---
> MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++++++++++
> .../Library/ResetUtilityLib/ResetUtility.c | 221 +++++++++++++++++++++
> .../Library/ResetUtilityLib/ResetUtilityLib.inf | 43 ++++
> MdeModulePkg/MdeModulePkg.dsc | 7 +
> 4 files changed, 382 insertions(+)
> create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h
> create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
> create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>
> diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h b/MdeModulePkg/Include/Library/ResetUtilityLib.h
> new file mode 100644
> index 0000000000..94828785e2
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h
> @@ -0,0 +1,111 @@
> +/** @file
> + This header describes various helper functions for resetting the system.
> +
> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
> +
> + 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
> + http://opensource.org/licenses/bsd-license.php.
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +#ifndef _RESET_UTILITY_LIB_H_
> +#define _RESET_UTILITY_LIB_H_
> +
> +/**
> + This is a shorthand helper function to reset with a subtype so that
> + the caller doesn't have to bother with a function that has half a dozen
> + parameters.
> +
> + This will generate a reset with status EFI_SUCCESS, a NULL string, and
> + no custom data. The subtype will be formatted in such a way that it can be
> + picked up by notification registrations and custom handlers.
> +
> + NOTE: This call will fail if the architectural ResetSystem underpinnings
> + are not initialized. For DXE, you can add gEfiResetArchProtocolGuid
> + to your DEPEX.
> +
> + @param[in] ResetType Base reset type as defined in UEFI spec.
> + @param[in] ResetSubtype GUID pointer for the reset subtype to be used.
> +
> +**/
> +VOID
> +EFIAPI
> +ResetPlatformSpecificGuid (
> + IN CONST GUID *ResetSubtype
> + );
> +
> +/**
> + This function examines the DataSize and ResetData parameters passed to
> + to ResetSystem() and detemrines if the ResetData contains a Null-terminated
> + Unicode string followed by a GUID specific subtype. If the GUID specific
> + subtype is present, then a pointer to the GUID value in ResetData is returned.
> +
> + @param[in] DataSize The size, in bytes, of ResetData.
> + @param[in] ResetData Pointer to the data buffer passed into ResetSystem().
> +
> + @retval Pointer Pointer to the GUID value in ResetData.
> + @retval NULL ResetData is NULL.
> + @retval NULL ResetData does not start with a Null-terminated
> + Unicode string.
> + @retval NULL A Null-terminated Unicode string is present, but there
> + are less than sizeof (GUID) bytes after the string.
> + @retval NULL No subtype is found.
> +
> +**/
> +GUID *
> +EFIAPI
> +GetResetPlatformSpecificGuid (
> + IN UINTN DataSize,
> + IN CONST VOID *ResetData
> + );
> +
> +/**
> + This is a helper function that creates the reset data buffer that can be
> + passed into ResetSystem().
> +
> + The reset data buffer is returned in ResetData and contains ResetString
> + followed by the ResetSubtype GUID followed by the ExtraData.
> +
> + NOTE: Strings are internally limited by MAX_UINT16.
> +
> + @param[in, out] ResetDataSize On input, the size of the ResetData buffer. On
> + output, either the total number of bytes
> + copied, or the required buffer size.
> + @param[in, out] ResetData A pointer to the buffer in which to place the
> + final structure.
> + @param[in] ResetSubtype Pointer to the GUID specific subtype. This
> + parameter is optional and may be NULL.
> + @param[in] ResetString Pointer to a Null-terminated Unicode string
> + that describes the reset. This parameter is
> + optional and may be NULL.
> + @param[in] ExtraDataSize The size, in bytes, of ExtraData buffer.
> + @param[in] ExtraData Pointer to a buffer of extra data. This
> + parameter is optional and may be NULL.
> +
> + @retval RETURN_SUCCESS ResetDataSize and ResetData are updated.
> + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
> + @retval RETURN_INVALID_PARAMETER ResetData is NULL.
> + @retval RETURN_INVALID_PARAMETER ExtraData was provided without a
> + ResetSubtype. This is not supported by the
> + UEFI spec.
> + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was provided.
> + ResetDataSize is updated with minimum size
> + required.
> +**/
> +RETURN_STATUS
> +EFIAPI
> +BuildResetData (
> + IN OUT UINTN *ResetDataSize,
> + IN OUT VOID *ResetData,
> + IN CONST GUID *ResetSubtype OPTIONAL,
> + IN CONST CHAR16 *ResetString OPTIONAL,
> + IN UINTN ExtraDataSize OPTIONAL,
> + IN CONST VOID *ExtraData OPTIONAL
> + );
> +
> +#endif // _RESET_UTILITY_LIB_H_
> diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
> new file mode 100644
> index 0000000000..5bbe002be0
> --- /dev/null
> +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
> @@ -0,0 +1,221 @@
> +/** @file
> + This contains the business logic for the module-specific Reset Helper functions.
> +
> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
> +
> + 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
> + http://opensource.org/licenses/bsd-license.php.
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +#include <Uefi.h>
> +#include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/ResetSystemLib.h>
> +
> +typedef struct {
> + CHAR16 NullTerminator;
> + GUID ResetSubtype;
> +} RESET_UTILITY_GUID_SPECIFIC_RESET_DATA;
> +
> +/**
> + This is a shorthand helper function to reset with a subtype so that
> + the caller doesn't have to bother with a function that has half a dozen
> + parameters.
> +
> + This will generate a reset with status EFI_SUCCESS, a NULL string, and
> + no custom data. The subtype will be formatted in such a way that it can be
> + picked up by notification registrations and custom handlers.
> +
> + NOTE: This call will fail if the architectural ResetSystem underpinnings
> + are not initialized. For DXE, you can add gEfiResetArchProtocolGuid
> + to your DEPEX.
> +
> + @param[in] ResetType Base reset type as defined in UEFI spec.
> + @param[in] ResetSubtype GUID pointer for the reset subtype to be used.
> +
> +**/
> +VOID
> +EFIAPI
> +ResetPlatformSpecificGuid (
> + IN CONST GUID *ResetSubtype
> + )
> +{
> + RESET_UTILITY_GUID_SPECIFIC_RESET_DATA ResetData;
> +
> + ResetData.NullTerminator = CHAR_NULL;
> + CopyGuid (&ResetData.ResetSubtype, ResetSubtype);
> + ResetPlatformSpecific (sizeof (ResetData), &ResetData);
> +}
> +
> +/**
> + This function examines the DataSize and ResetData parameters passed to
> + to ResetSystem() and detemrines if the ResetData contains a Null-terminated
> + Unicode string followed by a GUID specific subtype. If the GUID specific
> + subtype is present, then a pointer to the GUID value in ResetData is returned.
> +
> + @param[in] DataSize The size, in bytes, of ResetData.
> + @param[in] ResetData Pointer to the data buffer passed into ResetSystem().
> +
> + @retval Pointer Pointer to the GUID value in ResetData.
> + @retval NULL ResetData is NULL.
> + @retval NULL ResetData does not start with a Null-terminated
> + Unicode string.
> + @retval NULL A Null-terminated Unicode string is present, but there
> + are less than sizeof (GUID) bytes after the string.
> + @retval NULL No subtype is found.
> +
> +**/
> +GUID *
> +EFIAPI
> +GetResetPlatformSpecificGuid (
> + IN UINTN DataSize,
> + IN CONST VOID *ResetData
> + )
> +{
> + UINTN ResetDataStringSize;
> + GUID *ResetSubtypeGuid;
> +
> + //
> + // Make sure parameters are valid
> + //
> + if ((ResetData == NULL) || (DataSize < sizeof (GUID))) {
> + return NULL;
> + }
> +
> + //
> + // Determine the number of bytes in in the Null-terminated Unicode string
> + // at the beginning of ResetData including the Null terminator.
> + //
> + ResetDataStringSize = StrnSizeS (ResetData, (DataSize / sizeof (CHAR16)));
> +
> + //
> + // Now, assuming that we have enough data for a GUID after the string, the
> + // GUID should be immediately after the string itself.
> + //
> + if ((ResetDataStringSize < DataSize) && (DataSize - ResetDataStringSize) >= sizeof (GUID)) {
> + ResetSubtypeGuid = (GUID *)((UINT8 *)ResetData + ResetDataStringSize);
> + DEBUG ((DEBUG_VERBOSE, __FUNCTION__" - Detected reset subtype %g...\n", ResetSubtypeGuid));
> + return ResetSubtypeGuid;
> + }
> + return NULL;
> +}
> +
> +/**
> + This is a helper function that creates the reset data buffer that can be
> + passed into ResetSystem().
> +
> + The reset data buffer is returned in ResetData and contains ResetString
> + followed by the ResetSubtype GUID followed by the ExtraData.
> +
> + NOTE: Strings are internally limited by MAX_UINT16.
> +
> + @param[in, out] ResetDataSize On input, the size of the ResetData buffer. On
> + output, either the total number of bytes
> + copied, or the required buffer size.
> + @param[in, out] ResetData A pointer to the buffer in which to place the
> + final structure.
> + @param[in] ResetSubtype Pointer to the GUID specific subtype. This
> + parameter is optional and may be NULL.
> + @param[in] ResetString Pointer to a Null-terminated Unicode string
> + that describes the reset. This parameter is
> + optional and may be NULL.
> + @param[in] ExtraDataSize The size, in bytes, of ExtraData buffer.
> + @param[in] ExtraData Pointer to a buffer of extra data. This
> + parameter is optional and may be NULL.
> +
> + @retval RETURN_SUCCESS ResetDataSize and ResetData are updated.
> + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
> + @retval RETURN_INVALID_PARAMETER ResetData is NULL.
> + @retval RETURN_INVALID_PARAMETER ExtraData was provided without a
> + ResetSubtype. This is not supported by the
> + UEFI spec.
> + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was provided.
> + ResetDataSize is updated with minimum size
> + required.
> +**/
> +RETURN_STATUS
> +EFIAPI
> +BuildResetData (
> + IN OUT UINTN *ResetDataSize,
> + IN OUT VOID *ResetData,
> + IN CONST GUID *ResetSubtype OPTIONAL,
> + IN CONST CHAR16 *ResetString OPTIONAL,
> + IN UINTN ExtraDataSize OPTIONAL,
> + IN CONST VOID *ExtraData OPTIONAL
> + )
> +{
> + UINTN ResetStringSize;
> + UINTN ResetDataBufferSize;
> + UINT8 *Data;
> +
> + //
> + // If the size return pointer is NULL.
> + //
> + if (ResetDataSize == NULL) {
> + return RETURN_INVALID_PARAMETER;
> + }
> + //
> + // If extra data is indicated, but pointer is NULL.
> + //
> + if (ExtraDataSize > 0 && ExtraData == NULL) {
> + return RETURN_INVALID_PARAMETER;
> + }
> + //
> + // If extra data is indicated, but no subtype GUID is supplied.
> + //
> + if (ResetSubtype == NULL && ExtraDataSize > 0) {
> + return RETURN_INVALID_PARAMETER;
> + }
> +
> + //
> + // Determine the final string.
> + //
> + if (ResetString == NULL) {
> + ResetString = L""; // Use an empty string.
> + }
> +
> + //
> + // Calculate the total buffer required for ResetData.
> + //
> + ResetStringSize = StrnSizeS (ResetString, MAX_UINT16);
> + ResetDataBufferSize = ResetStringSize + ExtraDataSize;
> + if (ResetSubtype != NULL) {
> + ResetDataBufferSize += sizeof (GUID);
> + }
> +
> + //
> + // At this point, if the buffer isn't large enough (or if
> + // the buffer is NULL) we cannot proceed.
> + //
> + if (*ResetDataSize < ResetDataBufferSize) {
> + *ResetDataSize = ResetDataBufferSize;
> + return RETURN_BUFFER_TOO_SMALL;
> + }
> + *ResetDataSize = ResetDataBufferSize;
> + if (ResetData == NULL) {
> + return RETURN_INVALID_PARAMETER;
> + }
> +
> + //
> + // Fill in ResetData with ResetString, the ResetSubtype GUID, and extra data
> + //
> + Data = (UINT8 *)ResetData;
> + CopyMem (Data, ResetString, ResetStringSize);
> + Data += ResetStringSize;
> + if (ResetSubtype != NULL) {
> + CopyMem (Data, ResetSubtype, sizeof (GUID));
> + Data += sizeof (GUID);
> + }
> + if (ExtraDataSize > 0) {
> + CopyMem (Data, ExtraData, ExtraDataSize);
> + }
> +
> + return RETURN_SUCCESS;
> +}
> diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
> new file mode 100644
> index 0000000000..7a403749c5
> --- /dev/null
> +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
> @@ -0,0 +1,43 @@
> +## @file
> +# This file contains the Reset Utility functions.
> +#
> +# The application pops up a menu showing all the boot options referenced by
> +# BootOrder NV variable and user can choose to boot from one of them.
> +#
> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +##
> +[Defines]
> + INF_VERSION = 0x00010017
> + BASE_NAME = ResetUtilityLib
> + FILE_GUID = CAFC3CA1-3E32-449F-9B0E-40BA3CB73A12
> + VERSION_STRING = 1.0
> + MODULE_TYPE = BASE
> + LIBRARY_CLASS = ResetUtilityLib
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources]
> + ResetUtility.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + DebugLib
> + BaseMemoryLib
> + ResetSystemLib
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index dd7e9d5988..d96bff90b0 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -285,13 +285,16 @@ [Components]
> MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
> MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
> MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
> + MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
> MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
> MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
> MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.inf
> MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
> MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
> + MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
> MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
> MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
> + MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
> MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
> MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
> MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
> @@ -358,6 +361,10 @@ [Components]
> MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
> MdeModulePkg/Universal/Metronome/Metronome.inf
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
> + MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf {
> + <LibraryClasses>
> + ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
> + }
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance
2018-02-07 12:28 ` Zeng, Star
@ 2018-02-08 1:36 ` Zeng, Star
2018-02-08 2:07 ` Zeng, Star
0 siblings, 1 reply; 31+ messages in thread
From: Zeng, Star @ 2018-02-08 1:36 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
Another minor comments is to remove below sentences in ResetUtilityLib.inf.
> +# The application pops up a menu showing all the boot options
referenced by
> +# BootOrder NV variable and user can choose to boot from one of them.
Thanks,
Star
On 2018/2/7 20:28, Zeng, Star wrote:
> On 2018/2/2 14:45, Ruiyu Ni wrote:
>> From: Michael D Kinney <michael.d.kinney@intel.com>
>>
>> The library class that provides services to generate a GUID specific
>> reset, parse the GUID from a GUID specific reset, and build the
>> ResetData buffer for any type of reset that requires extra data.
>>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>
> Should we also add below lines in MdeModulePkg.dec?
>
> ## @libraryclass Defines a set of helper functions for resetting
> the system
> ResetUtilityLib|Include/Library/ResetUtilityLib.h
>
>
> Thanks,
> Star
>
>> ---
>> MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++++++++++
>> .../Library/ResetUtilityLib/ResetUtility.c | 221
>> +++++++++++++++++++++
>> .../Library/ResetUtilityLib/ResetUtilityLib.inf | 43 ++++
>> MdeModulePkg/MdeModulePkg.dsc | 7 +
>> 4 files changed, 382 insertions(+)
>> create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h
>> create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>> create mode 100644
>> MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>>
>> diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h
>> b/MdeModulePkg/Include/Library/ResetUtilityLib.h
>> new file mode 100644
>> index 0000000000..94828785e2
>> --- /dev/null
>> +++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h
>> @@ -0,0 +1,111 @@
>> +/** @file
>> + This header describes various helper functions for resetting the
>> system.
>> +
>> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
>> + Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
>> +
>> + 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
>> + http://opensource.org/licenses/bsd-license.php.
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +#ifndef _RESET_UTILITY_LIB_H_
>> +#define _RESET_UTILITY_LIB_H_
>> +
>> +/**
>> + This is a shorthand helper function to reset with a subtype so that
>> + the caller doesn't have to bother with a function that has half a
>> dozen
>> + parameters.
>> +
>> + This will generate a reset with status EFI_SUCCESS, a NULL string, and
>> + no custom data. The subtype will be formatted in such a way that it
>> can be
>> + picked up by notification registrations and custom handlers.
>> +
>> + NOTE: This call will fail if the architectural ResetSystem
>> underpinnings
>> + are not initialized. For DXE, you can add
>> gEfiResetArchProtocolGuid
>> + to your DEPEX.
>> +
>> + @param[in] ResetType Base reset type as defined in UEFI spec.
>> + @param[in] ResetSubtype GUID pointer for the reset subtype to be
>> used.
>> +
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetPlatformSpecificGuid (
>> + IN CONST GUID *ResetSubtype
>> + );
>> +
>> +/**
>> + This function examines the DataSize and ResetData parameters passed to
>> + to ResetSystem() and detemrines if the ResetData contains a
>> Null-terminated
>> + Unicode string followed by a GUID specific subtype. If the GUID
>> specific
>> + subtype is present, then a pointer to the GUID value in ResetData
>> is returned.
>> +
>> + @param[in] DataSize The size, in bytes, of ResetData.
>> + @param[in] ResetData Pointer to the data buffer passed into
>> ResetSystem().
>> +
>> + @retval Pointer Pointer to the GUID value in ResetData.
>> + @retval NULL ResetData is NULL.
>> + @retval NULL ResetData does not start with a
>> Null-terminated
>> + Unicode string.
>> + @retval NULL A Null-terminated Unicode string is
>> present, but there
>> + are less than sizeof (GUID) bytes after the
>> string.
>> + @retval NULL No subtype is found.
>> +
>> +**/
>> +GUID *
>> +EFIAPI
>> +GetResetPlatformSpecificGuid (
>> + IN UINTN DataSize,
>> + IN CONST VOID *ResetData
>> + );
>> +
>> +/**
>> + This is a helper function that creates the reset data buffer that
>> can be
>> + passed into ResetSystem().
>> +
>> + The reset data buffer is returned in ResetData and contains
>> ResetString
>> + followed by the ResetSubtype GUID followed by the ExtraData.
>> +
>> + NOTE: Strings are internally limited by MAX_UINT16.
>> +
>> + @param[in, out] ResetDataSize On input, the size of the ResetData
>> buffer. On
>> + output, either the total number of
>> bytes
>> + copied, or the required buffer size.
>> + @param[in, out] ResetData A pointer to the buffer in which to
>> place the
>> + final structure.
>> + @param[in] ResetSubtype Pointer to the GUID specific
>> subtype. This
>> + parameter is optional and may be NULL.
>> + @param[in] ResetString Pointer to a Null-terminated Unicode
>> string
>> + that describes the reset. This
>> parameter is
>> + optional and may be NULL.
>> + @param[in] ExtraDataSize The size, in bytes, of ExtraData
>> buffer.
>> + @param[in] ExtraData Pointer to a buffer of extra data.
>> This
>> + parameter is optional and may be NULL.
>> +
>> + @retval RETURN_SUCCESS ResetDataSize and ResetData
>> are updated.
>> + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
>> + @retval RETURN_INVALID_PARAMETER ResetData is NULL.
>> + @retval RETURN_INVALID_PARAMETER ExtraData was provided
>> without a
>> + ResetSubtype. This is not
>> supported by the
>> + UEFI spec.
>> + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was
>> provided.
>> + ResetDataSize is updated
>> with minimum size
>> + required.
>> +**/
>> +RETURN_STATUS
>> +EFIAPI
>> +BuildResetData (
>> + IN OUT UINTN *ResetDataSize,
>> + IN OUT VOID *ResetData,
>> + IN CONST GUID *ResetSubtype OPTIONAL,
>> + IN CONST CHAR16 *ResetString OPTIONAL,
>> + IN UINTN ExtraDataSize OPTIONAL,
>> + IN CONST VOID *ExtraData OPTIONAL
>> + );
>> +
>> +#endif // _RESET_UTILITY_LIB_H_
>> diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>> b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>> new file mode 100644
>> index 0000000000..5bbe002be0
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>> @@ -0,0 +1,221 @@
>> +/** @file
>> + This contains the business logic for the module-specific Reset
>> Helper functions.
>> +
>> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
>> + Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
>> +
>> + 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
>> + http://opensource.org/licenses/bsd-license.php.
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +#include <Uefi.h>
>> +#include <Library/BaseLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/BaseMemoryLib.h>
>> +#include <Library/ResetSystemLib.h>
>> +
>> +typedef struct {
>> + CHAR16 NullTerminator;
>> + GUID ResetSubtype;
>> +} RESET_UTILITY_GUID_SPECIFIC_RESET_DATA;
>> +
>> +/**
>> + This is a shorthand helper function to reset with a subtype so that
>> + the caller doesn't have to bother with a function that has half a
>> dozen
>> + parameters.
>> +
>> + This will generate a reset with status EFI_SUCCESS, a NULL string, and
>> + no custom data. The subtype will be formatted in such a way that it
>> can be
>> + picked up by notification registrations and custom handlers.
>> +
>> + NOTE: This call will fail if the architectural ResetSystem
>> underpinnings
>> + are not initialized. For DXE, you can add
>> gEfiResetArchProtocolGuid
>> + to your DEPEX.
>> +
>> + @param[in] ResetType Base reset type as defined in UEFI spec.
>> + @param[in] ResetSubtype GUID pointer for the reset subtype to be
>> used.
>> +
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetPlatformSpecificGuid (
>> + IN CONST GUID *ResetSubtype
>> + )
>> +{
>> + RESET_UTILITY_GUID_SPECIFIC_RESET_DATA ResetData;
>> +
>> + ResetData.NullTerminator = CHAR_NULL;
>> + CopyGuid (&ResetData.ResetSubtype, ResetSubtype);
>> + ResetPlatformSpecific (sizeof (ResetData), &ResetData);
>> +}
>> +
>> +/**
>> + This function examines the DataSize and ResetData parameters passed to
>> + to ResetSystem() and detemrines if the ResetData contains a
>> Null-terminated
>> + Unicode string followed by a GUID specific subtype. If the GUID
>> specific
>> + subtype is present, then a pointer to the GUID value in ResetData
>> is returned.
>> +
>> + @param[in] DataSize The size, in bytes, of ResetData.
>> + @param[in] ResetData Pointer to the data buffer passed into
>> ResetSystem().
>> +
>> + @retval Pointer Pointer to the GUID value in ResetData.
>> + @retval NULL ResetData is NULL.
>> + @retval NULL ResetData does not start with a
>> Null-terminated
>> + Unicode string.
>> + @retval NULL A Null-terminated Unicode string is
>> present, but there
>> + are less than sizeof (GUID) bytes after the
>> string.
>> + @retval NULL No subtype is found.
>> +
>> +**/
>> +GUID *
>> +EFIAPI
>> +GetResetPlatformSpecificGuid (
>> + IN UINTN DataSize,
>> + IN CONST VOID *ResetData
>> + )
>> +{
>> + UINTN ResetDataStringSize;
>> + GUID *ResetSubtypeGuid;
>> +
>> + //
>> + // Make sure parameters are valid
>> + //
>> + if ((ResetData == NULL) || (DataSize < sizeof (GUID))) {
>> + return NULL;
>> + }
>> +
>> + //
>> + // Determine the number of bytes in in the Null-terminated Unicode
>> string
>> + // at the beginning of ResetData including the Null terminator.
>> + //
>> + ResetDataStringSize = StrnSizeS (ResetData, (DataSize / sizeof
>> (CHAR16)));
>> +
>> + //
>> + // Now, assuming that we have enough data for a GUID after the
>> string, the
>> + // GUID should be immediately after the string itself.
>> + //
>> + if ((ResetDataStringSize < DataSize) && (DataSize -
>> ResetDataStringSize) >= sizeof (GUID)) {
>> + ResetSubtypeGuid = (GUID *)((UINT8 *)ResetData +
>> ResetDataStringSize);
>> + DEBUG ((DEBUG_VERBOSE, __FUNCTION__" - Detected reset subtype
>> %g...\n", ResetSubtypeGuid));
>> + return ResetSubtypeGuid;
>> + }
>> + return NULL;
>> +}
>> +
>> +/**
>> + This is a helper function that creates the reset data buffer that
>> can be
>> + passed into ResetSystem().
>> +
>> + The reset data buffer is returned in ResetData and contains
>> ResetString
>> + followed by the ResetSubtype GUID followed by the ExtraData.
>> +
>> + NOTE: Strings are internally limited by MAX_UINT16.
>> +
>> + @param[in, out] ResetDataSize On input, the size of the ResetData
>> buffer. On
>> + output, either the total number of
>> bytes
>> + copied, or the required buffer size.
>> + @param[in, out] ResetData A pointer to the buffer in which to
>> place the
>> + final structure.
>> + @param[in] ResetSubtype Pointer to the GUID specific
>> subtype. This
>> + parameter is optional and may be NULL.
>> + @param[in] ResetString Pointer to a Null-terminated Unicode
>> string
>> + that describes the reset. This
>> parameter is
>> + optional and may be NULL.
>> + @param[in] ExtraDataSize The size, in bytes, of ExtraData
>> buffer.
>> + @param[in] ExtraData Pointer to a buffer of extra data.
>> This
>> + parameter is optional and may be NULL.
>> +
>> + @retval RETURN_SUCCESS ResetDataSize and ResetData
>> are updated.
>> + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
>> + @retval RETURN_INVALID_PARAMETER ResetData is NULL.
>> + @retval RETURN_INVALID_PARAMETER ExtraData was provided
>> without a
>> + ResetSubtype. This is not
>> supported by the
>> + UEFI spec.
>> + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was
>> provided.
>> + ResetDataSize is updated
>> with minimum size
>> + required.
>> +**/
>> +RETURN_STATUS
>> +EFIAPI
>> +BuildResetData (
>> + IN OUT UINTN *ResetDataSize,
>> + IN OUT VOID *ResetData,
>> + IN CONST GUID *ResetSubtype OPTIONAL,
>> + IN CONST CHAR16 *ResetString OPTIONAL,
>> + IN UINTN ExtraDataSize OPTIONAL,
>> + IN CONST VOID *ExtraData OPTIONAL
>> + )
>> +{
>> + UINTN ResetStringSize;
>> + UINTN ResetDataBufferSize;
>> + UINT8 *Data;
>> +
>> + //
>> + // If the size return pointer is NULL.
>> + //
>> + if (ResetDataSize == NULL) {
>> + return RETURN_INVALID_PARAMETER;
>> + }
>> + //
>> + // If extra data is indicated, but pointer is NULL.
>> + //
>> + if (ExtraDataSize > 0 && ExtraData == NULL) {
>> + return RETURN_INVALID_PARAMETER;
>> + }
>> + //
>> + // If extra data is indicated, but no subtype GUID is supplied.
>> + //
>> + if (ResetSubtype == NULL && ExtraDataSize > 0) {
>> + return RETURN_INVALID_PARAMETER;
>> + }
>> +
>> + //
>> + // Determine the final string.
>> + //
>> + if (ResetString == NULL) {
>> + ResetString = L""; // Use an empty string.
>> + }
>> +
>> + //
>> + // Calculate the total buffer required for ResetData.
>> + //
>> + ResetStringSize = StrnSizeS (ResetString, MAX_UINT16);
>> + ResetDataBufferSize = ResetStringSize + ExtraDataSize;
>> + if (ResetSubtype != NULL) {
>> + ResetDataBufferSize += sizeof (GUID);
>> + }
>> +
>> + //
>> + // At this point, if the buffer isn't large enough (or if
>> + // the buffer is NULL) we cannot proceed.
>> + //
>> + if (*ResetDataSize < ResetDataBufferSize) {
>> + *ResetDataSize = ResetDataBufferSize;
>> + return RETURN_BUFFER_TOO_SMALL;
>> + }
>> + *ResetDataSize = ResetDataBufferSize;
>> + if (ResetData == NULL) {
>> + return RETURN_INVALID_PARAMETER;
>> + }
>> +
>> + //
>> + // Fill in ResetData with ResetString, the ResetSubtype GUID, and
>> extra data
>> + //
>> + Data = (UINT8 *)ResetData;
>> + CopyMem (Data, ResetString, ResetStringSize);
>> + Data += ResetStringSize;
>> + if (ResetSubtype != NULL) {
>> + CopyMem (Data, ResetSubtype, sizeof (GUID));
>> + Data += sizeof (GUID);
>> + }
>> + if (ExtraDataSize > 0) {
>> + CopyMem (Data, ExtraData, ExtraDataSize);
>> + }
>> +
>> + return RETURN_SUCCESS;
>> +}
>> diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>> b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>> new file mode 100644
>> index 0000000000..7a403749c5
>> --- /dev/null
>> +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>> @@ -0,0 +1,43 @@
>> +## @file
>> +# This file contains the Reset Utility functions.
>> +#
>> +# The application pops up a menu showing all the boot options
>> referenced by
>> +# BootOrder NV variable and user can choose to boot from one of them.
>> +#
>> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +# Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
>> +# This program and the accompanying materials
>> +# are licensed and made available under the terms and conditions of
>> the BSD License
>> +# which accompanies this distribution. The full text of the license
>> may be found at
>> +# http://opensource.org/licenses/bsd-license.php
>> +#
>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +#
>> +##
>> +[Defines]
>> + INF_VERSION = 0x00010017
>> + BASE_NAME = ResetUtilityLib
>> + FILE_GUID = CAFC3CA1-3E32-449F-9B0E-40BA3CB73A12
>> + VERSION_STRING = 1.0
>> + MODULE_TYPE = BASE
>> + LIBRARY_CLASS = ResetUtilityLib
>> +
>> +#
>> +# The following information is for reference only and not required by
>> the build tools.
>> +#
>> +# VALID_ARCHITECTURES = IA32 X64
>> +#
>> +
>> +[Sources]
>> + ResetUtility.c
>> +
>> +[Packages]
>> + MdePkg/MdePkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> +
>> +[LibraryClasses]
>> + BaseLib
>> + DebugLib
>> + BaseMemoryLib
>> + ResetSystemLib
>> diff --git a/MdeModulePkg/MdeModulePkg.dsc
>> b/MdeModulePkg/MdeModulePkg.dsc
>> index dd7e9d5988..d96bff90b0 100644
>> --- a/MdeModulePkg/MdeModulePkg.dsc
>> +++ b/MdeModulePkg/MdeModulePkg.dsc
>> @@ -285,13 +285,16 @@ [Components]
>> MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
>> MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
>> MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
>> + MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
>> MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
>>
>> MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
>>
>>
>> MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.inf
>>
>> MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
>> MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
>> + MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
>> MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
>> MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
>> + MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>>
>> MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
>>
>> MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
>>
>>
>> MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
>>
>> @@ -358,6 +361,10 @@ [Components]
>>
>> MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
>> MdeModulePkg/Universal/Metronome/Metronome.inf
>>
>> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>>
>> + MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf {
>> + <LibraryClasses>
>> +
>> ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
>>
>> + }
>>
>> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
>> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
>> MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
>>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance
2018-02-08 1:36 ` Zeng, Star
@ 2018-02-08 2:07 ` Zeng, Star
0 siblings, 0 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-08 2:07 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
Sorry for the trivial comments.
"@param[in] ResetType Base reset type as defined in UEFI spec."
needs to be removed for ResetPlatformSpecificGuid.
There is "in in" in the comments for the implementation of
GetResetPlatformSpecificGuid(). May should be one "in" only?
Thanks,
Star
On 2018/2/8 9:36, Zeng, Star wrote:
> Another minor comments is to remove below sentences in ResetUtilityLib.inf.
>
> > +# The application pops up a menu showing all the boot options
> referenced by
> > +# BootOrder NV variable and user can choose to boot from one of them.
>
>
> Thanks,
> Star
>
> On 2018/2/7 20:28, Zeng, Star wrote:
>> On 2018/2/2 14:45, Ruiyu Ni wrote:
>>> From: Michael D Kinney <michael.d.kinney@intel.com>
>>>
>>> The library class that provides services to generate a GUID specific
>>> reset, parse the GUID from a GUID specific reset, and build the
>>> ResetData buffer for any type of reset that requires extra data.
>>>
>>> Cc: Liming Gao <liming.gao@intel.com>
>>> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
>>> Cc: Star Zeng <star.zeng@intel.com>
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
>>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>>
>> Should we also add below lines in MdeModulePkg.dec?
>>
>> ## @libraryclass Defines a set of helper functions for resetting
>> the system
>> ResetUtilityLib|Include/Library/ResetUtilityLib.h
>>
>>
>> Thanks,
>> Star
>>
>>> ---
>>> MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++++++++++
>>> .../Library/ResetUtilityLib/ResetUtility.c | 221
>>> +++++++++++++++++++++
>>> .../Library/ResetUtilityLib/ResetUtilityLib.inf | 43 ++++
>>> MdeModulePkg/MdeModulePkg.dsc | 7 +
>>> 4 files changed, 382 insertions(+)
>>> create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h
>>> create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>>> create mode 100644
>>> MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>>>
>>> diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h
>>> b/MdeModulePkg/Include/Library/ResetUtilityLib.h
>>> new file mode 100644
>>> index 0000000000..94828785e2
>>> --- /dev/null
>>> +++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h
>>> @@ -0,0 +1,111 @@
>>> +/** @file
>>> + This header describes various helper functions for resetting the
>>> system.
>>> +
>>> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
>>> + Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
>>> +
>>> + 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
>>> + http://opensource.org/licenses/bsd-license.php.
>>> +
>>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>>> OR IMPLIED.
>>> +
>>> +**/
>>> +#ifndef _RESET_UTILITY_LIB_H_
>>> +#define _RESET_UTILITY_LIB_H_
>>> +
>>> +/**
>>> + This is a shorthand helper function to reset with a subtype so that
>>> + the caller doesn't have to bother with a function that has half a
>>> dozen
>>> + parameters.
>>> +
>>> + This will generate a reset with status EFI_SUCCESS, a NULL string,
>>> and
>>> + no custom data. The subtype will be formatted in such a way that
>>> it can be
>>> + picked up by notification registrations and custom handlers.
>>> +
>>> + NOTE: This call will fail if the architectural ResetSystem
>>> underpinnings
>>> + are not initialized. For DXE, you can add
>>> gEfiResetArchProtocolGuid
>>> + to your DEPEX.
>>> +
>>> + @param[in] ResetType Base reset type as defined in UEFI spec.
>>> + @param[in] ResetSubtype GUID pointer for the reset subtype to be
>>> used.
>>> +
>>> +**/
>>> +VOID
>>> +EFIAPI
>>> +ResetPlatformSpecificGuid (
>>> + IN CONST GUID *ResetSubtype
>>> + );
>>> +
>>> +/**
>>> + This function examines the DataSize and ResetData parameters
>>> passed to
>>> + to ResetSystem() and detemrines if the ResetData contains a
>>> Null-terminated
>>> + Unicode string followed by a GUID specific subtype. If the GUID
>>> specific
>>> + subtype is present, then a pointer to the GUID value in ResetData
>>> is returned.
>>> +
>>> + @param[in] DataSize The size, in bytes, of ResetData.
>>> + @param[in] ResetData Pointer to the data buffer passed into
>>> ResetSystem().
>>> +
>>> + @retval Pointer Pointer to the GUID value in ResetData.
>>> + @retval NULL ResetData is NULL.
>>> + @retval NULL ResetData does not start with a
>>> Null-terminated
>>> + Unicode string.
>>> + @retval NULL A Null-terminated Unicode string is
>>> present, but there
>>> + are less than sizeof (GUID) bytes after
>>> the string.
>>> + @retval NULL No subtype is found.
>>> +
>>> +**/
>>> +GUID *
>>> +EFIAPI
>>> +GetResetPlatformSpecificGuid (
>>> + IN UINTN DataSize,
>>> + IN CONST VOID *ResetData
>>> + );
>>> +
>>> +/**
>>> + This is a helper function that creates the reset data buffer that
>>> can be
>>> + passed into ResetSystem().
>>> +
>>> + The reset data buffer is returned in ResetData and contains
>>> ResetString
>>> + followed by the ResetSubtype GUID followed by the ExtraData.
>>> +
>>> + NOTE: Strings are internally limited by MAX_UINT16.
>>> +
>>> + @param[in, out] ResetDataSize On input, the size of the ResetData
>>> buffer. On
>>> + output, either the total number of
>>> bytes
>>> + copied, or the required buffer size.
>>> + @param[in, out] ResetData A pointer to the buffer in which to
>>> place the
>>> + final structure.
>>> + @param[in] ResetSubtype Pointer to the GUID specific
>>> subtype. This
>>> + parameter is optional and may be NULL.
>>> + @param[in] ResetString Pointer to a Null-terminated
>>> Unicode string
>>> + that describes the reset. This
>>> parameter is
>>> + optional and may be NULL.
>>> + @param[in] ExtraDataSize The size, in bytes, of ExtraData
>>> buffer.
>>> + @param[in] ExtraData Pointer to a buffer of extra data.
>>> This
>>> + parameter is optional and may be NULL.
>>> +
>>> + @retval RETURN_SUCCESS ResetDataSize and ResetData
>>> are updated.
>>> + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
>>> + @retval RETURN_INVALID_PARAMETER ResetData is NULL.
>>> + @retval RETURN_INVALID_PARAMETER ExtraData was provided
>>> without a
>>> + ResetSubtype. This is not
>>> supported by the
>>> + UEFI spec.
>>> + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was
>>> provided.
>>> + ResetDataSize is updated
>>> with minimum size
>>> + required.
>>> +**/
>>> +RETURN_STATUS
>>> +EFIAPI
>>> +BuildResetData (
>>> + IN OUT UINTN *ResetDataSize,
>>> + IN OUT VOID *ResetData,
>>> + IN CONST GUID *ResetSubtype OPTIONAL,
>>> + IN CONST CHAR16 *ResetString OPTIONAL,
>>> + IN UINTN ExtraDataSize OPTIONAL,
>>> + IN CONST VOID *ExtraData OPTIONAL
>>> + );
>>> +
>>> +#endif // _RESET_UTILITY_LIB_H_
>>> diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>>> b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>>> new file mode 100644
>>> index 0000000000..5bbe002be0
>>> --- /dev/null
>>> +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
>>> @@ -0,0 +1,221 @@
>>> +/** @file
>>> + This contains the business logic for the module-specific Reset
>>> Helper functions.
>>> +
>>> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
>>> + Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
>>> +
>>> + 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
>>> + http://opensource.org/licenses/bsd-license.php.
>>> +
>>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>>> OR IMPLIED.
>>> +
>>> +**/
>>> +#include <Uefi.h>
>>> +#include <Library/BaseLib.h>
>>> +#include <Library/DebugLib.h>
>>> +#include <Library/BaseMemoryLib.h>
>>> +#include <Library/ResetSystemLib.h>
>>> +
>>> +typedef struct {
>>> + CHAR16 NullTerminator;
>>> + GUID ResetSubtype;
>>> +} RESET_UTILITY_GUID_SPECIFIC_RESET_DATA;
>>> +
>>> +/**
>>> + This is a shorthand helper function to reset with a subtype so that
>>> + the caller doesn't have to bother with a function that has half a
>>> dozen
>>> + parameters.
>>> +
>>> + This will generate a reset with status EFI_SUCCESS, a NULL string,
>>> and
>>> + no custom data. The subtype will be formatted in such a way that
>>> it can be
>>> + picked up by notification registrations and custom handlers.
>>> +
>>> + NOTE: This call will fail if the architectural ResetSystem
>>> underpinnings
>>> + are not initialized. For DXE, you can add
>>> gEfiResetArchProtocolGuid
>>> + to your DEPEX.
>>> +
>>> + @param[in] ResetType Base reset type as defined in UEFI spec.
>>> + @param[in] ResetSubtype GUID pointer for the reset subtype to be
>>> used.
>>> +
>>> +**/
>>> +VOID
>>> +EFIAPI
>>> +ResetPlatformSpecificGuid (
>>> + IN CONST GUID *ResetSubtype
>>> + )
>>> +{
>>> + RESET_UTILITY_GUID_SPECIFIC_RESET_DATA ResetData;
>>> +
>>> + ResetData.NullTerminator = CHAR_NULL;
>>> + CopyGuid (&ResetData.ResetSubtype, ResetSubtype);
>>> + ResetPlatformSpecific (sizeof (ResetData), &ResetData);
>>> +}
>>> +
>>> +/**
>>> + This function examines the DataSize and ResetData parameters
>>> passed to
>>> + to ResetSystem() and detemrines if the ResetData contains a
>>> Null-terminated
>>> + Unicode string followed by a GUID specific subtype. If the GUID
>>> specific
>>> + subtype is present, then a pointer to the GUID value in ResetData
>>> is returned.
>>> +
>>> + @param[in] DataSize The size, in bytes, of ResetData.
>>> + @param[in] ResetData Pointer to the data buffer passed into
>>> ResetSystem().
>>> +
>>> + @retval Pointer Pointer to the GUID value in ResetData.
>>> + @retval NULL ResetData is NULL.
>>> + @retval NULL ResetData does not start with a
>>> Null-terminated
>>> + Unicode string.
>>> + @retval NULL A Null-terminated Unicode string is
>>> present, but there
>>> + are less than sizeof (GUID) bytes after
>>> the string.
>>> + @retval NULL No subtype is found.
>>> +
>>> +**/
>>> +GUID *
>>> +EFIAPI
>>> +GetResetPlatformSpecificGuid (
>>> + IN UINTN DataSize,
>>> + IN CONST VOID *ResetData
>>> + )
>>> +{
>>> + UINTN ResetDataStringSize;
>>> + GUID *ResetSubtypeGuid;
>>> +
>>> + //
>>> + // Make sure parameters are valid
>>> + //
>>> + if ((ResetData == NULL) || (DataSize < sizeof (GUID))) {
>>> + return NULL;
>>> + }
>>> +
>>> + //
>>> + // Determine the number of bytes in in the Null-terminated Unicode
>>> string
>>> + // at the beginning of ResetData including the Null terminator.
>>> + //
>>> + ResetDataStringSize = StrnSizeS (ResetData, (DataSize / sizeof
>>> (CHAR16)));
>>> +
>>> + //
>>> + // Now, assuming that we have enough data for a GUID after the
>>> string, the
>>> + // GUID should be immediately after the string itself.
>>> + //
>>> + if ((ResetDataStringSize < DataSize) && (DataSize -
>>> ResetDataStringSize) >= sizeof (GUID)) {
>>> + ResetSubtypeGuid = (GUID *)((UINT8 *)ResetData +
>>> ResetDataStringSize);
>>> + DEBUG ((DEBUG_VERBOSE, __FUNCTION__" - Detected reset subtype
>>> %g...\n", ResetSubtypeGuid));
>>> + return ResetSubtypeGuid;
>>> + }
>>> + return NULL;
>>> +}
>>> +
>>> +/**
>>> + This is a helper function that creates the reset data buffer that
>>> can be
>>> + passed into ResetSystem().
>>> +
>>> + The reset data buffer is returned in ResetData and contains
>>> ResetString
>>> + followed by the ResetSubtype GUID followed by the ExtraData.
>>> +
>>> + NOTE: Strings are internally limited by MAX_UINT16.
>>> +
>>> + @param[in, out] ResetDataSize On input, the size of the ResetData
>>> buffer. On
>>> + output, either the total number of
>>> bytes
>>> + copied, or the required buffer size.
>>> + @param[in, out] ResetData A pointer to the buffer in which to
>>> place the
>>> + final structure.
>>> + @param[in] ResetSubtype Pointer to the GUID specific
>>> subtype. This
>>> + parameter is optional and may be NULL.
>>> + @param[in] ResetString Pointer to a Null-terminated
>>> Unicode string
>>> + that describes the reset. This
>>> parameter is
>>> + optional and may be NULL.
>>> + @param[in] ExtraDataSize The size, in bytes, of ExtraData
>>> buffer.
>>> + @param[in] ExtraData Pointer to a buffer of extra data.
>>> This
>>> + parameter is optional and may be NULL.
>>> +
>>> + @retval RETURN_SUCCESS ResetDataSize and ResetData
>>> are updated.
>>> + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
>>> + @retval RETURN_INVALID_PARAMETER ResetData is NULL.
>>> + @retval RETURN_INVALID_PARAMETER ExtraData was provided
>>> without a
>>> + ResetSubtype. This is not
>>> supported by the
>>> + UEFI spec.
>>> + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was
>>> provided.
>>> + ResetDataSize is updated
>>> with minimum size
>>> + required.
>>> +**/
>>> +RETURN_STATUS
>>> +EFIAPI
>>> +BuildResetData (
>>> + IN OUT UINTN *ResetDataSize,
>>> + IN OUT VOID *ResetData,
>>> + IN CONST GUID *ResetSubtype OPTIONAL,
>>> + IN CONST CHAR16 *ResetString OPTIONAL,
>>> + IN UINTN ExtraDataSize OPTIONAL,
>>> + IN CONST VOID *ExtraData OPTIONAL
>>> + )
>>> +{
>>> + UINTN ResetStringSize;
>>> + UINTN ResetDataBufferSize;
>>> + UINT8 *Data;
>>> +
>>> + //
>>> + // If the size return pointer is NULL.
>>> + //
>>> + if (ResetDataSize == NULL) {
>>> + return RETURN_INVALID_PARAMETER;
>>> + }
>>> + //
>>> + // If extra data is indicated, but pointer is NULL.
>>> + //
>>> + if (ExtraDataSize > 0 && ExtraData == NULL) {
>>> + return RETURN_INVALID_PARAMETER;
>>> + }
>>> + //
>>> + // If extra data is indicated, but no subtype GUID is supplied.
>>> + //
>>> + if (ResetSubtype == NULL && ExtraDataSize > 0) {
>>> + return RETURN_INVALID_PARAMETER;
>>> + }
>>> +
>>> + //
>>> + // Determine the final string.
>>> + //
>>> + if (ResetString == NULL) {
>>> + ResetString = L""; // Use an empty string.
>>> + }
>>> +
>>> + //
>>> + // Calculate the total buffer required for ResetData.
>>> + //
>>> + ResetStringSize = StrnSizeS (ResetString, MAX_UINT16);
>>> + ResetDataBufferSize = ResetStringSize + ExtraDataSize;
>>> + if (ResetSubtype != NULL) {
>>> + ResetDataBufferSize += sizeof (GUID);
>>> + }
>>> +
>>> + //
>>> + // At this point, if the buffer isn't large enough (or if
>>> + // the buffer is NULL) we cannot proceed.
>>> + //
>>> + if (*ResetDataSize < ResetDataBufferSize) {
>>> + *ResetDataSize = ResetDataBufferSize;
>>> + return RETURN_BUFFER_TOO_SMALL;
>>> + }
>>> + *ResetDataSize = ResetDataBufferSize;
>>> + if (ResetData == NULL) {
>>> + return RETURN_INVALID_PARAMETER;
>>> + }
>>> +
>>> + //
>>> + // Fill in ResetData with ResetString, the ResetSubtype GUID, and
>>> extra data
>>> + //
>>> + Data = (UINT8 *)ResetData;
>>> + CopyMem (Data, ResetString, ResetStringSize);
>>> + Data += ResetStringSize;
>>> + if (ResetSubtype != NULL) {
>>> + CopyMem (Data, ResetSubtype, sizeof (GUID));
>>> + Data += sizeof (GUID);
>>> + }
>>> + if (ExtraDataSize > 0) {
>>> + CopyMem (Data, ExtraData, ExtraDataSize);
>>> + }
>>> +
>>> + return RETURN_SUCCESS;
>>> +}
>>> diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>>> b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>>> new file mode 100644
>>> index 0000000000..7a403749c5
>>> --- /dev/null
>>> +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>>> @@ -0,0 +1,43 @@
>>> +## @file
>>> +# This file contains the Reset Utility functions.
>>> +#
>>> +# The application pops up a menu showing all the boot options
>>> referenced by
>>> +# BootOrder NV variable and user can choose to boot from one of them.
>>> +#
>>> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>>> +# Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
>>> +# This program and the accompanying materials
>>> +# are licensed and made available under the terms and conditions of
>>> the BSD License
>>> +# which accompanies this distribution. The full text of the
>>> license may be found at
>>> +# http://opensource.org/licenses/bsd-license.php
>>> +#
>>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
>>> BASIS,
>>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>>> OR IMPLIED.
>>> +#
>>> +##
>>> +[Defines]
>>> + INF_VERSION = 0x00010017
>>> + BASE_NAME = ResetUtilityLib
>>> + FILE_GUID = CAFC3CA1-3E32-449F-9B0E-40BA3CB73A12
>>> + VERSION_STRING = 1.0
>>> + MODULE_TYPE = BASE
>>> + LIBRARY_CLASS = ResetUtilityLib
>>> +
>>> +#
>>> +# The following information is for reference only and not required
>>> by the build tools.
>>> +#
>>> +# VALID_ARCHITECTURES = IA32 X64
>>> +#
>>> +
>>> +[Sources]
>>> + ResetUtility.c
>>> +
>>> +[Packages]
>>> + MdePkg/MdePkg.dec
>>> + MdeModulePkg/MdeModulePkg.dec
>>> +
>>> +[LibraryClasses]
>>> + BaseLib
>>> + DebugLib
>>> + BaseMemoryLib
>>> + ResetSystemLib
>>> diff --git a/MdeModulePkg/MdeModulePkg.dsc
>>> b/MdeModulePkg/MdeModulePkg.dsc
>>> index dd7e9d5988..d96bff90b0 100644
>>> --- a/MdeModulePkg/MdeModulePkg.dsc
>>> +++ b/MdeModulePkg/MdeModulePkg.dsc
>>> @@ -285,13 +285,16 @@ [Components]
>>> MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
>>> MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
>>> MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
>>> + MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
>>> MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
>>> MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
>>>
>>> MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.inf
>>>
>>> MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
>>> MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
>>> + MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
>>> MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
>>> MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
>>> + MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
>>> MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
>>> MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
>>>
>>> MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
>>>
>>> @@ -358,6 +361,10 @@ [Components]
>>> MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
>>>
>>> MdeModulePkg/Universal/Metronome/Metronome.inf
>>> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>>>
>>> + MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf {
>>> + <LibraryClasses>
>>> +
>>> ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
>>>
>>> + }
>>> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
>>> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
>>> MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
>>>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types.
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
` (6 preceding siblings ...)
2018-02-02 6:45 ` [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 12:24 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM Ruiyu Ni
2018-02-02 6:45 ` [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI Ruiyu Ni
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Michael D Kinney, Star Zeng
Because DxeResetSystemLib links to this library to provide
reset system services, change UefiRuntimeLib to support
the same set of module types as what DxeResetSystemLib does.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
index 8f46495fc5..d053da545a 100644
--- a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+++ b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
@@ -5,7 +5,7 @@
# EVT_SIGNAL_EXIT_BOOT_SERVICES event, to provide runtime services.
# This instance also supports SAL drivers for better performance.
#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -24,7 +24,7 @@ [Defines]
FILE_GUID = b1ee6c28-54aa-4d17-b705-3e28ccb27b2e
MODULE_TYPE = DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = UefiRuntimeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER
+ LIBRARY_CLASS = UefiRuntimeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_CORE DXE_DRIVER DXE_SMM_DRIVER
CONSTRUCTOR = RuntimeDriverLibConstruct
DESTRUCTOR = RuntimeDriverLibDeconstruct
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types.
2018-02-02 6:45 ` [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types Ruiyu Ni
@ 2018-02-07 12:24 ` Zeng, Star
2018-02-09 3:06 ` Ni, Ruiyu
0 siblings, 1 reply; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 12:24 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> Because DxeResetSystemLib links to this library to provide
> reset system services, change UefiRuntimeLib to support
> the same set of module types as what DxeResetSystemLib does.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Do you think it is ok or not to let DxeResetSystemLib consume
UefiRuntimeServicesTableLib and use gRT->ResetSystem? Then this patch
will be not needed.
If we still prefer to let DxeResetSystemLib consume UefiRuntimeLib, I am
also ok. Reviewed-by: Star Zeng <star.zeng@intel.com>
Thanks,
Star
> ---
> MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
> index 8f46495fc5..d053da545a 100644
> --- a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
> +++ b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
> @@ -5,7 +5,7 @@
> # EVT_SIGNAL_EXIT_BOOT_SERVICES event, to provide runtime services.
> # This instance also supports SAL drivers for better performance.
> #
> -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> @@ -24,7 +24,7 @@ [Defines]
> FILE_GUID = b1ee6c28-54aa-4d17-b705-3e28ccb27b2e
> MODULE_TYPE = DXE_RUNTIME_DRIVER
> VERSION_STRING = 1.0
> - LIBRARY_CLASS = UefiRuntimeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER
> + LIBRARY_CLASS = UefiRuntimeLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_CORE DXE_DRIVER DXE_SMM_DRIVER
>
> CONSTRUCTOR = RuntimeDriverLibConstruct
> DESTRUCTOR = RuntimeDriverLibDeconstruct
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types.
2018-02-07 12:24 ` Zeng, Star
@ 2018-02-09 3:06 ` Ni, Ruiyu
0 siblings, 0 replies; 31+ messages in thread
From: Ni, Ruiyu @ 2018-02-09 3:06 UTC (permalink / raw)
To: Zeng, Star, edk2-devel; +Cc: Michael D Kinney, Liming Gao
On 2/7/2018 8:24 PM, Zeng, Star wrote:
> On 2018/2/2 14:45, Ruiyu Ni wrote:
>> Because DxeResetSystemLib links to this library to provide
>> reset system services, change UefiRuntimeLib to support
>> the same set of module types as what DxeResetSystemLib does.
>>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>
> Do you think it is ok or not to let DxeResetSystemLib consume
> UefiRuntimeServicesTableLib and use gRT->ResetSystem? Then this patch
> will be not needed.
RuntimeLib handles the gRT pointer conversion when entering RT phase.
DxeResetSystemLib actually can also be used by a RT driver.
Directly calling gRT->ResetSystem from DxeResetSystemLib loses the
capability.
>
> If we still prefer to let DxeResetSystemLib consume UefiRuntimeLib, I am
> also ok. Reviewed-by: Star Zeng <star.zeng@intel.com>
>
> Thanks,
> Star
>
>> ---
>> MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
>> b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
>> index 8f46495fc5..d053da545a 100644
>> --- a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
>> +++ b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
>> @@ -5,7 +5,7 @@
>> # EVT_SIGNAL_EXIT_BOOT_SERVICES event, to provide runtime services.
>> # This instance also supports SAL drivers for better performance.
>> #
>> -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
>> +# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
>> #
>> # This program and the accompanying materials
>> # are licensed and made available under the terms and conditions of
>> the BSD License
>> @@ -24,7 +24,7 @@ [Defines]
>> FILE_GUID = b1ee6c28-54aa-4d17-b705-3e28ccb27b2e
>> MODULE_TYPE = DXE_RUNTIME_DRIVER
>> VERSION_STRING = 1.0
>> - LIBRARY_CLASS = UefiRuntimeLib|DXE_RUNTIME_DRIVER
>> DXE_SAL_DRIVER
>> + LIBRARY_CLASS = UefiRuntimeLib|DXE_RUNTIME_DRIVER
>> DXE_SAL_DRIVER DXE_CORE DXE_DRIVER DXE_SMM_DRIVER
>> CONSTRUCTOR = RuntimeDriverLibConstruct
>> DESTRUCTOR = RuntimeDriverLibDeconstruct
>>
>
--
Thanks,
Ray
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
` (7 preceding siblings ...)
2018-02-02 6:45 ` [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 12:35 ` Zeng, Star
2018-02-02 6:45 ` [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI Ruiyu Ni
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Michael D Kinney, Star Zeng
This driver implements Reset2, ResetFilter and ResetHandler PPIs.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
MdeModulePkg/MdeModulePkg.dec | 4 +
.../Universal/ResetSystemPei/ResetSystem.c | 355 +++++++++++++++++++++
.../Universal/ResetSystemPei/ResetSystem.h | 129 ++++++++
.../Universal/ResetSystemPei/ResetSystemPei.inf | 62 ++++
.../Universal/ResetSystemPei/ResetSystemPei.uni | 20 ++
| 20 ++
6 files changed, 590 insertions(+)
create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 1cc9bc8ea1..1b971d599f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1419,6 +1419,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
# @Prompt CapsuleMax value in capsule report variable.
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0xFFFF|UINT16|0x00000107
+ ## Indicates the allowable maximum number of Reset Filters or Reset Handlers in PEI phase.
+ # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x00000109
+
[PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This PCD defines the Console output row. The default value is 25 according to UEFI spec.
# This PCD could be set to 0 then console output would be at max column and max row.
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
new file mode 100644
index 0000000000..720593de6a
--- /dev/null
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
@@ -0,0 +1,355 @@
+/** @file
+ Implementation of Reset2, ResetFilter and ResetHandler PPIs.
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "ResetSystem.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
+ L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
+};
+
+EFI_PEI_RESET2_PPI mPpiReset2 = {
+ ResetSystem2
+};
+
+EFI_GUID *mProcessingOrder[] = {
+ &gEdkiiPlatformSpecificResetFilterPpiGuid,
+ &gEdkiiPlatformSpecificResetHandlerPpiGuid
+};
+
+RESET_FILTER_INSTANCE mResetFilter = {
+ {
+ RegisterResetNotify,
+ UnregisterResetNotify
+ },
+ &gEdkiiPlatformSpecificResetFilterPpiGuid
+};
+
+RESET_FILTER_INSTANCE mResetHandler = {
+ {
+ RegisterResetNotify,
+ UnregisterResetNotify
+ },
+ &gEdkiiPlatformSpecificResetHandlerPpiGuid
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
+ {
+ EFI_PEI_PPI_DESCRIPTOR_PPI,
+ &gEfiPeiReset2PpiGuid,
+ &mPpiReset2
+ },
+ {
+ EFI_PEI_PPI_DESCRIPTOR_PPI,
+ &gEdkiiPlatformSpecificResetFilterPpiGuid,
+ &mResetFilter.ResetFilter
+ },
+ {
+ EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ &gEdkiiPlatformSpecificResetHandlerPpiGuid,
+ &mResetHandler.ResetFilter
+ }
+};
+
+/**
+ Register a notification function to be called when ResetSystem() is called.
+
+ The RegisterResetNotify() function registers a notification function that is called when
+ ResetSystem()is called and prior to completing the reset of the platform.
+ The registered functions must not perform a platform reset themselves. These
+ notifications are intended only for the notification of components which may need some
+ special-purpose maintenance prior to the platform resetting.
+ The list of registered reset notification functions are processed if ResetSystem()is called
+ before ExitBootServices(). The list of registered reset notification functions is ignored if
+ ResetSystem()is called after ExitBootServices().
+
+ @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance.
+ @param[in] ResetFunction Points to the function to be called when a ResetSystem() is executed.
+
+ @retval EFI_SUCCESS The reset notification function was successfully registered.
+ @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources available to register the reset notification function.
+ @retval EFI_ALREADY_STARTED The reset notification function specified by ResetFunction has already been registered.
+
+**/
+EFI_STATUS
+EFIAPI
+RegisterResetNotify (
+ IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
+ IN EFI_RESET_SYSTEM ResetFunction
+ )
+{
+ RESET_FILTER_INSTANCE *ResetFilter;
+ RESET_FILTER_LIST *List;
+ VOID *Hob;
+ UINTN Index;
+
+ if (ResetFunction == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ResetFilter = (RESET_FILTER_INSTANCE *) This;
+ ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
+ CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
+ );
+
+ Hob = GetFirstGuidHob (ResetFilter->Guid);
+ if (Hob == NULL) {
+ //
+ // When the GUIDed HOB doesn't exist, create it.
+ //
+ List = (RESET_FILTER_LIST *)BuildGuidHob (
+ ResetFilter->Guid,
+ sizeof (RESET_FILTER_LIST) + sizeof (EFI_RESET_SYSTEM) * PcdGet32 (PcdMaximumPeiResetNotifies)
+ );
+ if (List == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ List->Signature = RESET_FILTER_LIST_SIGNATURE;
+ List->Count = PcdGet32 (PcdMaximumPeiResetNotifies);
+ ZeroMem (List->ResetFilters, sizeof (EFI_RESET_SYSTEM) * List->Count);
+ List->ResetFilters[0] = ResetFunction;
+ return EFI_SUCCESS;
+ } else {
+ List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
+ ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
+ //
+ // Firstly check whether the ResetFunction is already registerred.
+ //
+ for (Index = 0; Index < List->Count; Index++) {
+ if (List->ResetFilters[Index] == ResetFunction) {
+ break;
+ }
+ }
+ if (Index != List->Count) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ //
+ // Secondly find the first free slot.
+ //
+ for (Index = 0; Index < List->Count; Index++) {
+ if (List->ResetFilters[Index] == NULL) {
+ break;
+ }
+ }
+
+ if (Index == List->Count) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ List->ResetFilters[Index] = ResetFunction;
+ return EFI_SUCCESS;
+ }
+}
+
+/**
+ Unregister a notification function.
+
+ The UnregisterResetNotify() function removes the previously registered
+ notification using RegisterResetNotify().
+
+ @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance.
+ @param[in] ResetFunction The pointer to the ResetFunction being unregistered.
+
+ @retval EFI_SUCCESS The reset notification function was unregistered.
+ @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
+ @retval EFI_INVALID_PARAMETER The reset notification function specified by ResetFunction was not previously
+ registered using RegisterResetNotify().
+
+**/
+EFI_STATUS
+EFIAPI
+UnregisterResetNotify (
+ IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
+ IN EFI_RESET_SYSTEM ResetFunction
+ )
+{
+
+ RESET_FILTER_INSTANCE *ResetFilter;
+ RESET_FILTER_LIST *List;
+ VOID *Hob;
+ UINTN Index;
+
+ if (ResetFunction == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ResetFilter = (RESET_FILTER_INSTANCE *)This;
+ ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
+ CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
+ );
+
+ Hob = GetFirstGuidHob (ResetFilter->Guid);
+ if (Hob == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
+ ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
+ for (Index = 0; Index < List->Count; Index++) {
+ if (List->ResetFilters[Index] == ResetFunction) {
+ break;
+ }
+ }
+
+ if (Index == List->Count) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ List->ResetFilters[Index] = NULL;
+ return EFI_SUCCESS;
+}
+
+
+/**
+ The PEIM's entry point.
+
+ It initializes the Reset2, ResetFilter and ResetHandler PPIs.
+
+ @param[in] FileHandle Handle of the file being invoked.
+ @param[in] PeiServices Describes the list of possible PEI Services.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval EFI_ALREADY_STARTED The Reset2 PPI was already installed.
+ @retval others Status code returned from PeiServicesInstallPpi().
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeResetSystem (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+ VOID *Ppi;
+
+ Status = PeiServicesLocatePpi (&gEfiPeiReset2PpiGuid, 0, NULL, (VOID **)&Ppi);
+ if (Status != EFI_NOT_FOUND) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ PeiServicesInstallPpi (mPpiListReset);
+
+ return Status;
+}
+
+/**
+ Resets the entire platform.
+
+ @param[in] ResetType The type of reset to perform.
+ @param[in] ResetStatus The 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. ResetData is only
+ valid if ResetStatus is something other than EFI_SUCCESS
+ unless the ResetType is EfiResetPlatformSpecific
+ where a minimum amount of ResetData is always required.
+ For a ResetType of EfiResetPlatformSpecific the data buffer
+ also starts with a Null-terminated string that is followed
+ by an EFI_GUID that describes the specific type of reset to perform.
+**/
+VOID
+EFIAPI
+ResetSystem2 (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
+ )
+{
+ VOID *Hob;
+ UINTN Index;
+ RESET_FILTER_LIST *List;
+ UINTN OrderIndex;
+ UINT8 RecursionDepth;
+ UINT8 *RecursionDepthPointer;
+
+ //
+ // The recursion depth is stored in GUIDed HOB using gEfiCallerIdGuid.
+ //
+ Hob = GetFirstGuidHob (&gEfiCallerIdGuid);
+ if (Hob == NULL) {
+ RecursionDepth = 0;
+ RecursionDepthPointer = BuildGuidDataHob (&gEfiCallerIdGuid, &RecursionDepth, sizeof (RecursionDepth));
+ } else {
+ RecursionDepthPointer = (UINT8 *)GET_GUID_HOB_DATA (Hob);
+ }
+ //
+ // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
+ //
+ if (*RecursionDepthPointer == 0) {
+ //
+ // Indicate reset system runtime service is called.
+ //
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
+ }
+
+ //
+ // Increase the call depth
+ //
+ (*RecursionDepthPointer)++;
+ DEBUG ((DEBUG_INFO, "PEI ResetSystem2: Reset call depth = %d.\n", *RecursionDepthPointer));
+
+ if (*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH) {
+ //
+ // Iteratively call Reset Filters and Reset Handlers.
+ //
+ for (OrderIndex = 0; OrderIndex < ARRAY_SIZE (mProcessingOrder); OrderIndex++) {
+ Hob = GetFirstGuidHob (mProcessingOrder[OrderIndex]);
+ if (Hob != NULL) {
+ List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
+ ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
+
+ for (Index = 0; Index < List->Count; Index++) {
+ if (List->ResetFilters[Index] != NULL) {
+ List->ResetFilters[Index] (ResetType, ResetStatus, DataSize, ResetData);
+ }
+ }
+ }
+ }
+ } else {
+ ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
+ DEBUG ((DEBUG_ERROR, "PEI ResetSystem2: Maximum reset call depth is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));
+ }
+
+ switch (ResetType) {
+ case EfiResetWarm:
+ ResetWarm ();
+ break;
+
+ case EfiResetCold:
+ ResetCold ();
+ break;
+
+ case EfiResetShutdown:
+ ResetShutdown ();
+ return ;
+
+ case EfiResetPlatformSpecific:
+ ResetPlatformSpecific (DataSize, ResetData);
+ return;
+
+ default:
+ return ;
+ }
+
+ //
+ // Given we should have reset getting here would be bad
+ //
+ ASSERT (FALSE);
+}
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
new file mode 100644
index 0000000000..2fcc3592b6
--- /dev/null
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
@@ -0,0 +1,129 @@
+/** @file
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _RESET_SYSTEM2_H_
+#define _RESET_SYSTEM2_H_
+
+
+#include <Uefi.h>
+#include <PiPei.h>
+
+#include <Ppi/Reset2.h>
+#include <Ppi/PlatformSpecificResetFilter.h>
+#include <Ppi/PlatformSpecificResetHandler.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/HobLib.h>
+#include <Library/ResetSystemLib.h>
+#include <Library/ReportStatusCodeLib.h>
+
+
+//
+// The maximum recurstion depth to ResetSystem() by reset notification handlers
+//
+#define MAX_RESET_NOTIFY_DEPTH 10
+
+//
+// Data to put in GUIDed HOB
+//
+typedef struct {
+ UINT32 Signature;
+ UINT32 Count;
+ EFI_RESET_SYSTEM ResetFilters[0]; // ResetFilters[PcdGet32 (PcdMaximumResetNotifies)]
+} RESET_FILTER_LIST;
+#define RESET_FILTER_LIST_SIGNATURE SIGNATURE_32('r', 's', 't', 'l')
+
+
+typedef struct {
+ EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI ResetFilter;
+ EFI_GUID *Guid;
+} RESET_FILTER_INSTANCE;
+
+/**
+ Resets the entire platform.
+
+ @param[in] ResetType The type of reset to perform.
+ @param[in] ResetStatus The 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. ResetData is only
+ valid if ResetStatus is something other than EFI_SUCCESS
+ unless the ResetType is EfiResetPlatformSpecific
+ where a minimum amount of ResetData is always required.
+ For a ResetType of EfiResetPlatformSpecific the data buffer
+ also starts with a Null-terminated string that is followed
+ by an EFI_GUID that describes the specific type of reset to perform.
+
+**/
+VOID
+EFIAPI
+ResetSystem2 (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
+ );
+/**
+ Register a notification function to be called when ResetSystem() is called.
+
+ The RegisterResetNotify() function registers a notification function that is called when
+ ResetSystem()is called and prior to completing the reset of the platform.
+ The registered functions must not perform a platform reset themselves. These
+ notifications are intended only for the notification of components which may need some
+ special-purpose maintenance prior to the platform resetting.
+
+ @param[in] This A pointer to the EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI instance.
+ @param[in] ResetFunction Points to the function to be called when a ResetSystem() is executed.
+
+ @retval EFI_SUCCESS The reset notification function was successfully registered.
+ @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources available to register the reset notification function.
+ @retval EFI_ALREADY_STARTED The reset notification function specified by ResetFunction has already been registered.
+
+**/
+EFI_STATUS
+EFIAPI
+RegisterResetNotify (
+ IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
+ IN EFI_RESET_SYSTEM ResetFunction
+ );
+
+/**
+ Unregister a notification function.
+
+ The UnregisterResetNotify() function removes the previously registered
+ notification using RegisterResetNotify().
+
+ @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance.
+ @param[in] ResetFunction The pointer to the ResetFunction being unregistered.
+
+ @retval EFI_SUCCESS The reset notification function was unregistered.
+ @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
+ @retval EFI_INVALID_PARAMETER The reset notification function specified by ResetFunction was not previously
+ registered using RegisterResetNotify().
+
+**/
+EFI_STATUS
+EFIAPI
+UnregisterResetNotify (
+ IN EFI_RESET_NOTIFICATION_PROTOCOL *This,
+ IN EFI_RESET_SYSTEM ResetFunction
+ );
+#endif
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
new file mode 100644
index 0000000000..38fdd16ceb
--- /dev/null
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
@@ -0,0 +1,62 @@
+## @file
+# This driver implements Reset2, ResetFilter and ResetHandler PPIs.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are
+# licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ResetSystemPei
+ MODULE_UNI_FILE = ResetSystemPei.uni
+ FILE_GUID = 6141E486-7543-4F1A-A579-FF532ED78E75
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+
+ ENTRY_POINT = InitializeResetSystem
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ ResetSystem.h
+ ResetSystem.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ PeiServicesLib
+ HobLib
+ PeimEntryPoint
+ ResetSystemLib
+ ReportStatusCodeLib
+
+[Ppis]
+ gEfiPeiReset2PpiGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies
+
+[Depex]
+ TRUE
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ ResetSystemPeiExtra.uni
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
new file mode 100644
index 0000000000..6d2d650c37
--- /dev/null
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
@@ -0,0 +1,20 @@
+// /** @file
+// This driver implements Reset2, ResetFilter and ResetHandler PPIs.
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials are
+// licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT #language en-US "Implements Reset2, ResetFilter and ResetHandler PPIs"
+
+#string STR_MODULE_DESCRIPTION #language en-US "This driver implements Reset2, ResetFilter and ResetHandler PPIs."
+
--git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
new file mode 100644
index 0000000000..2681afc707
--- /dev/null
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
@@ -0,0 +1,20 @@
+// /** @file
+// ResetSystemPei Localized Strings and Content
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials are
+// licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+#string STR_PROPERTIES_MODULE_NAME
+#language en-US
+"Reset System PEIM"
+
+
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM
2018-02-02 6:45 ` [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM Ruiyu Ni
@ 2018-02-07 12:35 ` Zeng, Star
2018-02-08 2:16 ` Zeng, Star
2018-02-09 3:12 ` Ni, Ruiyu
0 siblings, 2 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 12:35 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> This driver implements Reset2, ResetFilter and ResetHandler PPIs.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Should ResetSystemPei be added in MdeModulePkg.dsc for build coverage?
Same comment has been provided to ResetSystemRuntimeDxe.
Should be (*RecursionDepthPointer < MAX_RESET_NOTIFY_DEPTH) instead of
(*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH)>
Thanks,
Star
> ---
> MdeModulePkg/MdeModulePkg.dec | 4 +
> .../Universal/ResetSystemPei/ResetSystem.c | 355 +++++++++++++++++++++
> .../Universal/ResetSystemPei/ResetSystem.h | 129 ++++++++
> .../Universal/ResetSystemPei/ResetSystemPei.inf | 62 ++++
> .../Universal/ResetSystemPei/ResetSystemPei.uni | 20 ++
> .../ResetSystemPei/ResetSystemPeiExtra.uni | 20 ++
> 6 files changed, 590 insertions(+)
> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index 1cc9bc8ea1..1b971d599f 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1419,6 +1419,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
> # @Prompt CapsuleMax value in capsule report variable.
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0xFFFF|UINT16|0x00000107
>
> + ## Indicates the allowable maximum number of Reset Filters or Reset Handlers in PEI phase.
> + # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers.
> + gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x00000109
> +
> [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
> ## This PCD defines the Console output row. The default value is 25 according to UEFI spec.
> # This PCD could be set to 0 then console output would be at max column and max row.
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
> new file mode 100644
> index 0000000000..720593de6a
> --- /dev/null
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
> @@ -0,0 +1,355 @@
> +/** @file
> + Implementation of Reset2, ResetFilter and ResetHandler PPIs.
> +
> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include "ResetSystem.h"
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
> + L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
> +};
> +
> +EFI_PEI_RESET2_PPI mPpiReset2 = {
> + ResetSystem2
> +};
> +
> +EFI_GUID *mProcessingOrder[] = {
> + &gEdkiiPlatformSpecificResetFilterPpiGuid,
> + &gEdkiiPlatformSpecificResetHandlerPpiGuid
> +};
> +
> +RESET_FILTER_INSTANCE mResetFilter = {
> + {
> + RegisterResetNotify,
> + UnregisterResetNotify
> + },
> + &gEdkiiPlatformSpecificResetFilterPpiGuid
> +};
> +
> +RESET_FILTER_INSTANCE mResetHandler = {
> + {
> + RegisterResetNotify,
> + UnregisterResetNotify
> + },
> + &gEdkiiPlatformSpecificResetHandlerPpiGuid
> +};
> +
> +EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
> + {
> + EFI_PEI_PPI_DESCRIPTOR_PPI,
> + &gEfiPeiReset2PpiGuid,
> + &mPpiReset2
> + },
> + {
> + EFI_PEI_PPI_DESCRIPTOR_PPI,
> + &gEdkiiPlatformSpecificResetFilterPpiGuid,
> + &mResetFilter.ResetFilter
> + },
> + {
> + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> + &gEdkiiPlatformSpecificResetHandlerPpiGuid,
> + &mResetHandler.ResetFilter
> + }
> +};
> +
> +/**
> + Register a notification function to be called when ResetSystem() is called.
> +
> + The RegisterResetNotify() function registers a notification function that is called when
> + ResetSystem()is called and prior to completing the reset of the platform.
> + The registered functions must not perform a platform reset themselves. These
> + notifications are intended only for the notification of components which may need some
> + special-purpose maintenance prior to the platform resetting.
> + The list of registered reset notification functions are processed if ResetSystem()is called
> + before ExitBootServices(). The list of registered reset notification functions is ignored if
> + ResetSystem()is called after ExitBootServices().
> +
> + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance.
> + @param[in] ResetFunction Points to the function to be called when a ResetSystem() is executed.
> +
> + @retval EFI_SUCCESS The reset notification function was successfully registered.
> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
> + @retval EFI_OUT_OF_RESOURCES There are not enough resources available to register the reset notification function.
> + @retval EFI_ALREADY_STARTED The reset notification function specified by ResetFunction has already been registered.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RegisterResetNotify (
> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
> + IN EFI_RESET_SYSTEM ResetFunction
> + )
> +{
> + RESET_FILTER_INSTANCE *ResetFilter;
> + RESET_FILTER_LIST *List;
> + VOID *Hob;
> + UINTN Index;
> +
> + if (ResetFunction == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + ResetFilter = (RESET_FILTER_INSTANCE *) This;
> + ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
> + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
> + );
> +
> + Hob = GetFirstGuidHob (ResetFilter->Guid);
> + if (Hob == NULL) {
> + //
> + // When the GUIDed HOB doesn't exist, create it.
> + //
> + List = (RESET_FILTER_LIST *)BuildGuidHob (
> + ResetFilter->Guid,
> + sizeof (RESET_FILTER_LIST) + sizeof (EFI_RESET_SYSTEM) * PcdGet32 (PcdMaximumPeiResetNotifies)
> + );
> + if (List == NULL) {
> + return EFI_OUT_OF_RESOURCES;
> + }
> + List->Signature = RESET_FILTER_LIST_SIGNATURE;
> + List->Count = PcdGet32 (PcdMaximumPeiResetNotifies);
> + ZeroMem (List->ResetFilters, sizeof (EFI_RESET_SYSTEM) * List->Count);
> + List->ResetFilters[0] = ResetFunction;
> + return EFI_SUCCESS;
> + } else {
> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
> + //
> + // Firstly check whether the ResetFunction is already registerred.
> + //
> + for (Index = 0; Index < List->Count; Index++) {
> + if (List->ResetFilters[Index] == ResetFunction) {
> + break;
> + }
> + }
> + if (Index != List->Count) {
> + return EFI_ALREADY_STARTED;
> + }
> +
> + //
> + // Secondly find the first free slot.
> + //
> + for (Index = 0; Index < List->Count; Index++) {
> + if (List->ResetFilters[Index] == NULL) {
> + break;
> + }
> + }
> +
> + if (Index == List->Count) {
> + return EFI_OUT_OF_RESOURCES;
> + }
> + List->ResetFilters[Index] = ResetFunction;
> + return EFI_SUCCESS;
> + }
> +}
> +
> +/**
> + Unregister a notification function.
> +
> + The UnregisterResetNotify() function removes the previously registered
> + notification using RegisterResetNotify().
> +
> + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance.
> + @param[in] ResetFunction The pointer to the ResetFunction being unregistered.
> +
> + @retval EFI_SUCCESS The reset notification function was unregistered.
> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
> + @retval EFI_INVALID_PARAMETER The reset notification function specified by ResetFunction was not previously
> + registered using RegisterResetNotify().
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +UnregisterResetNotify (
> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
> + IN EFI_RESET_SYSTEM ResetFunction
> + )
> +{
> +
> + RESET_FILTER_INSTANCE *ResetFilter;
> + RESET_FILTER_LIST *List;
> + VOID *Hob;
> + UINTN Index;
> +
> + if (ResetFunction == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + ResetFilter = (RESET_FILTER_INSTANCE *)This;
> + ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
> + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
> + );
> +
> + Hob = GetFirstGuidHob (ResetFilter->Guid);
> + if (Hob == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
> + for (Index = 0; Index < List->Count; Index++) {
> + if (List->ResetFilters[Index] == ResetFunction) {
> + break;
> + }
> + }
> +
> + if (Index == List->Count) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + List->ResetFilters[Index] = NULL;
> + return EFI_SUCCESS;
> +}
> +
> +
> +/**
> + The PEIM's entry point.
> +
> + It initializes the Reset2, ResetFilter and ResetHandler PPIs.
> +
> + @param[in] FileHandle Handle of the file being invoked.
> + @param[in] PeiServices Describes the list of possible PEI Services.
> +
> + @retval EFI_SUCCESS The entry point is executed successfully.
> + @retval EFI_ALREADY_STARTED The Reset2 PPI was already installed.
> + @retval others Status code returned from PeiServicesInstallPpi().
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InitializeResetSystem (
> + IN EFI_PEI_FILE_HANDLE FileHandle,
> + IN CONST EFI_PEI_SERVICES **PeiServices
> + )
> +{
> + EFI_STATUS Status;
> + VOID *Ppi;
> +
> + Status = PeiServicesLocatePpi (&gEfiPeiReset2PpiGuid, 0, NULL, (VOID **)&Ppi);
> + if (Status != EFI_NOT_FOUND) {
> + return EFI_ALREADY_STARTED;
> + }
> +
> + PeiServicesInstallPpi (mPpiListReset);
> +
> + return Status;
> +}
> +
> +/**
> + Resets the entire platform.
> +
> + @param[in] ResetType The type of reset to perform.
> + @param[in] ResetStatus The 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. ResetData is only
> + valid if ResetStatus is something other than EFI_SUCCESS
> + unless the ResetType is EfiResetPlatformSpecific
> + where a minimum amount of ResetData is always required.
> + For a ResetType of EfiResetPlatformSpecific the data buffer
> + also starts with a Null-terminated string that is followed
> + by an EFI_GUID that describes the specific type of reset to perform.
> +**/
> +VOID
> +EFIAPI
> +ResetSystem2 (
> + IN EFI_RESET_TYPE ResetType,
> + IN EFI_STATUS ResetStatus,
> + IN UINTN DataSize,
> + IN VOID *ResetData OPTIONAL
> + )
> +{
> + VOID *Hob;
> + UINTN Index;
> + RESET_FILTER_LIST *List;
> + UINTN OrderIndex;
> + UINT8 RecursionDepth;
> + UINT8 *RecursionDepthPointer;
> +
> + //
> + // The recursion depth is stored in GUIDed HOB using gEfiCallerIdGuid.
> + //
> + Hob = GetFirstGuidHob (&gEfiCallerIdGuid);
> + if (Hob == NULL) {
> + RecursionDepth = 0;
> + RecursionDepthPointer = BuildGuidDataHob (&gEfiCallerIdGuid, &RecursionDepth, sizeof (RecursionDepth));
> + } else {
> + RecursionDepthPointer = (UINT8 *)GET_GUID_HOB_DATA (Hob);
> + }
> + //
> + // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
> + //
> + if (*RecursionDepthPointer == 0) {
> + //
> + // Indicate reset system runtime service is called.
> + //
> + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
> + }
> +
> + //
> + // Increase the call depth
> + //
> + (*RecursionDepthPointer)++;
> + DEBUG ((DEBUG_INFO, "PEI ResetSystem2: Reset call depth = %d.\n", *RecursionDepthPointer));
> +
> + if (*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH) {
> + //
> + // Iteratively call Reset Filters and Reset Handlers.
> + //
> + for (OrderIndex = 0; OrderIndex < ARRAY_SIZE (mProcessingOrder); OrderIndex++) {
> + Hob = GetFirstGuidHob (mProcessingOrder[OrderIndex]);
> + if (Hob != NULL) {
> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
> +
> + for (Index = 0; Index < List->Count; Index++) {
> + if (List->ResetFilters[Index] != NULL) {
> + List->ResetFilters[Index] (ResetType, ResetStatus, DataSize, ResetData);
> + }
> + }
> + }
> + }
> + } else {
> + ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
> + DEBUG ((DEBUG_ERROR, "PEI ResetSystem2: Maximum reset call depth is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));
> + }
> +
> + switch (ResetType) {
> + case EfiResetWarm:
> + ResetWarm ();
> + break;
> +
> + case EfiResetCold:
> + ResetCold ();
> + break;
> +
> + case EfiResetShutdown:
> + ResetShutdown ();
> + return ;
> +
> + case EfiResetPlatformSpecific:
> + ResetPlatformSpecific (DataSize, ResetData);
> + return;
> +
> + default:
> + return ;
> + }
> +
> + //
> + // Given we should have reset getting here would be bad
> + //
> + ASSERT (FALSE);
> +}
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
> new file mode 100644
> index 0000000000..2fcc3592b6
> --- /dev/null
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
> @@ -0,0 +1,129 @@
> +/** @file
> +
> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef _RESET_SYSTEM2_H_
> +#define _RESET_SYSTEM2_H_
> +
> +
> +#include <Uefi.h>
> +#include <PiPei.h>
> +
> +#include <Ppi/Reset2.h>
> +#include <Ppi/PlatformSpecificResetFilter.h>
> +#include <Ppi/PlatformSpecificResetHandler.h>
> +
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/PeiServicesLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/ResetSystemLib.h>
> +#include <Library/ReportStatusCodeLib.h>
> +
> +
> +//
> +// The maximum recurstion depth to ResetSystem() by reset notification handlers
> +//
> +#define MAX_RESET_NOTIFY_DEPTH 10
> +
> +//
> +// Data to put in GUIDed HOB
> +//
> +typedef struct {
> + UINT32 Signature;
> + UINT32 Count;
> + EFI_RESET_SYSTEM ResetFilters[0]; // ResetFilters[PcdGet32 (PcdMaximumResetNotifies)]
> +} RESET_FILTER_LIST;
> +#define RESET_FILTER_LIST_SIGNATURE SIGNATURE_32('r', 's', 't', 'l')
> +
> +
> +typedef struct {
> + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI ResetFilter;
> + EFI_GUID *Guid;
> +} RESET_FILTER_INSTANCE;
> +
> +/**
> + Resets the entire platform.
> +
> + @param[in] ResetType The type of reset to perform.
> + @param[in] ResetStatus The 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. ResetData is only
> + valid if ResetStatus is something other than EFI_SUCCESS
> + unless the ResetType is EfiResetPlatformSpecific
> + where a minimum amount of ResetData is always required.
> + For a ResetType of EfiResetPlatformSpecific the data buffer
> + also starts with a Null-terminated string that is followed
> + by an EFI_GUID that describes the specific type of reset to perform.
> +
> +**/
> +VOID
> +EFIAPI
> +ResetSystem2 (
> + IN EFI_RESET_TYPE ResetType,
> + IN EFI_STATUS ResetStatus,
> + IN UINTN DataSize,
> + IN VOID *ResetData OPTIONAL
> + );
> +/**
> + Register a notification function to be called when ResetSystem() is called.
> +
> + The RegisterResetNotify() function registers a notification function that is called when
> + ResetSystem()is called and prior to completing the reset of the platform.
> + The registered functions must not perform a platform reset themselves. These
> + notifications are intended only for the notification of components which may need some
> + special-purpose maintenance prior to the platform resetting.
> +
> + @param[in] This A pointer to the EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI instance.
> + @param[in] ResetFunction Points to the function to be called when a ResetSystem() is executed.
> +
> + @retval EFI_SUCCESS The reset notification function was successfully registered.
> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
> + @retval EFI_OUT_OF_RESOURCES There are not enough resources available to register the reset notification function.
> + @retval EFI_ALREADY_STARTED The reset notification function specified by ResetFunction has already been registered.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RegisterResetNotify (
> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
> + IN EFI_RESET_SYSTEM ResetFunction
> + );
> +
> +/**
> + Unregister a notification function.
> +
> + The UnregisterResetNotify() function removes the previously registered
> + notification using RegisterResetNotify().
> +
> + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance.
> + @param[in] ResetFunction The pointer to the ResetFunction being unregistered.
> +
> + @retval EFI_SUCCESS The reset notification function was unregistered.
> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
> + @retval EFI_INVALID_PARAMETER The reset notification function specified by ResetFunction was not previously
> + registered using RegisterResetNotify().
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +UnregisterResetNotify (
> + IN EFI_RESET_NOTIFICATION_PROTOCOL *This,
> + IN EFI_RESET_SYSTEM ResetFunction
> + );
> +#endif
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
> new file mode 100644
> index 0000000000..38fdd16ceb
> --- /dev/null
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
> @@ -0,0 +1,62 @@
> +## @file
> +# This driver implements Reset2, ResetFilter and ResetHandler PPIs.
> +#
> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +#
> +# This program and the accompanying materials are
> +# licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = ResetSystemPei
> + MODULE_UNI_FILE = ResetSystemPei.uni
> + FILE_GUID = 6141E486-7543-4F1A-A579-FF532ED78E75
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> +
> + ENTRY_POINT = InitializeResetSystem
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources]
> + ResetSystem.h
> + ResetSystem.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + PeiServicesLib
> + HobLib
> + PeimEntryPoint
> + ResetSystemLib
> + ReportStatusCodeLib
> +
> +[Ppis]
> + gEfiPeiReset2PpiGuid ## PRODUCES
> + gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
> + gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
> +
> +[Pcd]
> + gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies
> +
> +[Depex]
> + TRUE
> +
> +[UserExtensions.TianoCore."ExtraFiles"]
> + ResetSystemPeiExtra.uni
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
> new file mode 100644
> index 0000000000..6d2d650c37
> --- /dev/null
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
> @@ -0,0 +1,20 @@
> +// /** @file
> +// This driver implements Reset2, ResetFilter and ResetHandler PPIs.
> +//
> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials are
> +// licensed and made available under the terms and conditions of the BSD License
> +// which accompanies this distribution. The full text of the license may be found at
> +// http://opensource.org/licenses/bsd-license.php
> +//
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT #language en-US "Implements Reset2, ResetFilter and ResetHandler PPIs"
> +
> +#string STR_MODULE_DESCRIPTION #language en-US "This driver implements Reset2, ResetFilter and ResetHandler PPIs."
> +
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
> new file mode 100644
> index 0000000000..2681afc707
> --- /dev/null
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
> @@ -0,0 +1,20 @@
> +// /** @file
> +// ResetSystemPei Localized Strings and Content
> +//
> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials are
> +// licensed and made available under the terms and conditions of the BSD License
> +// which accompanies this distribution. The full text of the license may be found at
> +// http://opensource.org/licenses/bsd-license.php
> +//
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +#string STR_PROPERTIES_MODULE_NAME
> +#language en-US
> +"Reset System PEIM"
> +
> +
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM
2018-02-07 12:35 ` Zeng, Star
@ 2018-02-08 2:16 ` Zeng, Star
2018-02-09 3:12 ` Ni, Ruiyu
1 sibling, 0 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-08 2:16 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
Sorry for the trivial comments.
1. A typo "recurstion" should be "recursion" is in ResetSystem.h for
both ResetSystemPei and ResetSystemRuntimeDxe.
2. Should "RUNTIME/runtime/RS" be "PEI" in the comments and code like below?
//
// Indicate reset system runtime service is called.
//
REPORT_STATUS_CODE (EFI_PROGRESS_CODE,
(EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
->
//
// Indicate reset system PEI service is called.
//
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_SERVICE |
EFI_SW_PS_PC_RESET_SYSTEM));
3. We need update MdeModulePkg.uni for the new PCD
PcdMaximumPeiResetNotifies accordingly.
Thanks,
Star
On 2018/2/7 20:35, Zeng, Star wrote:
> On 2018/2/2 14:45, Ruiyu Ni wrote:
>> This driver implements Reset2, ResetFilter and ResetHandler PPIs.
>>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>
> Should ResetSystemPei be added in MdeModulePkg.dsc for build coverage?
>
> Same comment has been provided to ResetSystemRuntimeDxe.
> Should be (*RecursionDepthPointer < MAX_RESET_NOTIFY_DEPTH) instead of
> (*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH)>
>
>
> Thanks,
> Star
>
>> ---
>> MdeModulePkg/MdeModulePkg.dec | 4 +
>> .../Universal/ResetSystemPei/ResetSystem.c | 355
>> +++++++++++++++++++++
>> .../Universal/ResetSystemPei/ResetSystem.h | 129 ++++++++
>> .../Universal/ResetSystemPei/ResetSystemPei.inf | 62 ++++
>> .../Universal/ResetSystemPei/ResetSystemPei.uni | 20 ++
>> .../ResetSystemPei/ResetSystemPeiExtra.uni | 20 ++
>> 6 files changed, 590 insertions(+)
>> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> create mode 100644
>> MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> create mode 100644
>> MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> create mode 100644
>> MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>>
>> diff --git a/MdeModulePkg/MdeModulePkg.dec
>> b/MdeModulePkg/MdeModulePkg.dec
>> index 1cc9bc8ea1..1b971d599f 100644
>> --- a/MdeModulePkg/MdeModulePkg.dec
>> +++ b/MdeModulePkg/MdeModulePkg.dec
>> @@ -1419,6 +1419,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
>> # @Prompt CapsuleMax value in capsule report variable.
>> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0xFFFF|UINT16|0x00000107
>> + ## Indicates the allowable maximum number of Reset Filters or Reset
>> Handlers in PEI phase.
>> + # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers.
>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x00000109
>>
>> +
>> [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>> ## This PCD defines the Console output row. The default value is
>> 25 according to UEFI spec.
>> # This PCD could be set to 0 then console output would be at max
>> column and max row.
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> new file mode 100644
>> index 0000000000..720593de6a
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> @@ -0,0 +1,355 @@
>> +/** @file
>> + Implementation of Reset2, ResetFilter and ResetHandler PPIs.
>> +
>> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +
>> + This program and the accompanying materials
>> + are licensed and made available under the terms and conditions of
>> the BSD License
>> + which accompanies this distribution. The full text of the license
>> may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#include "ResetSystem.h"
>> +
>> +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
>> + L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
>> +};
>> +
>> +EFI_PEI_RESET2_PPI mPpiReset2 = {
>> + ResetSystem2
>> +};
>> +
>> +EFI_GUID *mProcessingOrder[] = {
>> + &gEdkiiPlatformSpecificResetFilterPpiGuid,
>> + &gEdkiiPlatformSpecificResetHandlerPpiGuid
>> +};
>> +
>> +RESET_FILTER_INSTANCE mResetFilter = {
>> + {
>> + RegisterResetNotify,
>> + UnregisterResetNotify
>> + },
>> + &gEdkiiPlatformSpecificResetFilterPpiGuid
>> +};
>> +
>> +RESET_FILTER_INSTANCE mResetHandler = {
>> + {
>> + RegisterResetNotify,
>> + UnregisterResetNotify
>> + },
>> + &gEdkiiPlatformSpecificResetHandlerPpiGuid
>> +};
>> +
>> +EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
>> + {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI,
>> + &gEfiPeiReset2PpiGuid,
>> + &mPpiReset2
>> + },
>> + {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI,
>> + &gEdkiiPlatformSpecificResetFilterPpiGuid,
>> + &mResetFilter.ResetFilter
>> + },
>> + {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
>> + &gEdkiiPlatformSpecificResetHandlerPpiGuid,
>> + &mResetHandler.ResetFilter
>> + }
>> +};
>> +
>> +/**
>> + Register a notification function to be called when ResetSystem() is
>> called.
>> +
>> + The RegisterResetNotify() function registers a notification
>> function that is called when
>> + ResetSystem()is called and prior to completing the reset of the
>> platform.
>> + The registered functions must not perform a platform reset
>> themselves. These
>> + notifications are intended only for the notification of components
>> which may need some
>> + special-purpose maintenance prior to the platform resetting.
>> + The list of registered reset notification functions are processed
>> if ResetSystem()is called
>> + before ExitBootServices(). The list of registered reset
>> notification functions is ignored if
>> + ResetSystem()is called after ExitBootServices().
>> +
>> + @param[in] This A pointer to the
>> EFI_RESET_NOTIFICATION_PROTOCOL instance.
>> + @param[in] ResetFunction Points to the function to be called
>> when a ResetSystem() is executed.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> successfully registered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_OUT_OF_RESOURCES There are not enough resources
>> available to register the reset notification function.
>> + @retval EFI_ALREADY_STARTED The reset notification function
>> specified by ResetFunction has already been registered.
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +RegisterResetNotify (
>> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + )
>> +{
>> + RESET_FILTER_INSTANCE *ResetFilter;
>> + RESET_FILTER_LIST *List;
>> + VOID *Hob;
>> + UINTN Index;
>> +
>> + if (ResetFunction == NULL) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + ResetFilter = (RESET_FILTER_INSTANCE *) This;
>> + ASSERT (CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
>> + CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid)
>> + );
>> +
>> + Hob = GetFirstGuidHob (ResetFilter->Guid);
>> + if (Hob == NULL) {
>> + //
>> + // When the GUIDed HOB doesn't exist, create it.
>> + //
>> + List = (RESET_FILTER_LIST *)BuildGuidHob (
>> + ResetFilter->Guid,
>> + sizeof (RESET_FILTER_LIST) + sizeof
>> (EFI_RESET_SYSTEM) * PcdGet32 (PcdMaximumPeiResetNotifies)
>> + );
>> + if (List == NULL) {
>> + return EFI_OUT_OF_RESOURCES;
>> + }
>> + List->Signature = RESET_FILTER_LIST_SIGNATURE;
>> + List->Count = PcdGet32 (PcdMaximumPeiResetNotifies);
>> + ZeroMem (List->ResetFilters, sizeof (EFI_RESET_SYSTEM) *
>> List->Count);
>> + List->ResetFilters[0] = ResetFunction;
>> + return EFI_SUCCESS;
>> + } else {
>> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
>> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
>> + //
>> + // Firstly check whether the ResetFunction is already registerred.
>> + //
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] == ResetFunction) {
>> + break;
>> + }
>> + }
>> + if (Index != List->Count) {
>> + return EFI_ALREADY_STARTED;
>> + }
>> +
>> + //
>> + // Secondly find the first free slot.
>> + //
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] == NULL) {
>> + break;
>> + }
>> + }
>> +
>> + if (Index == List->Count) {
>> + return EFI_OUT_OF_RESOURCES;
>> + }
>> + List->ResetFilters[Index] = ResetFunction;
>> + return EFI_SUCCESS;
>> + }
>> +}
>> +
>> +/**
>> + Unregister a notification function.
>> +
>> + The UnregisterResetNotify() function removes the previously registered
>> + notification using RegisterResetNotify().
>> +
>> + @param[in] This A pointer to the
>> EFI_RESET_NOTIFICATION_PROTOCOL instance.
>> + @param[in] ResetFunction The pointer to the ResetFunction
>> being unregistered.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> unregistered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_INVALID_PARAMETER The reset notification function
>> specified by ResetFunction was not previously
>> + registered using RegisterResetNotify().
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +UnregisterResetNotify (
>> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + )
>> +{
>> +
>> + RESET_FILTER_INSTANCE *ResetFilter;
>> + RESET_FILTER_LIST *List;
>> + VOID *Hob;
>> + UINTN Index;
>> +
>> + if (ResetFunction == NULL) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + ResetFilter = (RESET_FILTER_INSTANCE *)This;
>> + ASSERT (CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
>> + CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid)
>> + );
>> +
>> + Hob = GetFirstGuidHob (ResetFilter->Guid);
>> + if (Hob == NULL) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
>> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] == ResetFunction) {
>> + break;
>> + }
>> + }
>> +
>> + if (Index == List->Count) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + List->ResetFilters[Index] = NULL;
>> + return EFI_SUCCESS;
>> +}
>> +
>> +
>> +/**
>> + The PEIM's entry point.
>> +
>> + It initializes the Reset2, ResetFilter and ResetHandler PPIs.
>> +
>> + @param[in] FileHandle Handle of the file being invoked.
>> + @param[in] PeiServices Describes the list of possible PEI Services.
>> +
>> + @retval EFI_SUCCESS The entry point is executed successfully.
>> + @retval EFI_ALREADY_STARTED The Reset2 PPI was already installed.
>> + @retval others Status code returned from
>> PeiServicesInstallPpi().
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +InitializeResetSystem (
>> + IN EFI_PEI_FILE_HANDLE FileHandle,
>> + IN CONST EFI_PEI_SERVICES **PeiServices
>> + )
>> +{
>> + EFI_STATUS Status;
>> + VOID *Ppi;
>> +
>> + Status = PeiServicesLocatePpi (&gEfiPeiReset2PpiGuid, 0, NULL,
>> (VOID **)&Ppi);
>> + if (Status != EFI_NOT_FOUND) {
>> + return EFI_ALREADY_STARTED;
>> + }
>> +
>> + PeiServicesInstallPpi (mPpiListReset);
>> +
>> + return Status;
>> +}
>> +
>> +/**
>> + Resets the entire platform.
>> +
>> + @param[in] ResetType The type of reset to perform.
>> + @param[in] ResetStatus The 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. ResetData is only
>> + valid if ResetStatus is something
>> other than EFI_SUCCESS
>> + unless the ResetType is
>> EfiResetPlatformSpecific
>> + where a minimum amount of ResetData
>> is always required.
>> + For a ResetType of
>> EfiResetPlatformSpecific the data buffer
>> + also starts with a Null-terminated
>> string that is followed
>> + by an EFI_GUID that describes the
>> specific type of reset to perform.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetSystem2 (
>> + IN EFI_RESET_TYPE ResetType,
>> + IN EFI_STATUS ResetStatus,
>> + IN UINTN DataSize,
>> + IN VOID *ResetData OPTIONAL
>> + )
>> +{
>> + VOID *Hob;
>> + UINTN Index;
>> + RESET_FILTER_LIST *List;
>> + UINTN OrderIndex;
>> + UINT8 RecursionDepth;
>> + UINT8 *RecursionDepthPointer;
>> +
>> + //
>> + // The recursion depth is stored in GUIDed HOB using gEfiCallerIdGuid.
>> + //
>> + Hob = GetFirstGuidHob (&gEfiCallerIdGuid);
>> + if (Hob == NULL) {
>> + RecursionDepth = 0;
>> + RecursionDepthPointer = BuildGuidDataHob (&gEfiCallerIdGuid,
>> &RecursionDepth, sizeof (RecursionDepth));
>> + } else {
>> + RecursionDepthPointer = (UINT8 *)GET_GUID_HOB_DATA (Hob);
>> + }
>> + //
>> + // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
>> + //
>> + if (*RecursionDepthPointer == 0) {
>> + //
>> + // Indicate reset system runtime service is called.
>> + //
>> + REPORT_STATUS_CODE (EFI_PROGRESS_CODE,
>> (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
>> + }
>> +
>> + //
>> + // Increase the call depth
>> + //
>> + (*RecursionDepthPointer)++;
>> + DEBUG ((DEBUG_INFO, "PEI ResetSystem2: Reset call depth = %d.\n",
>> *RecursionDepthPointer));
>> +
>> + if (*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH) {
>> + //
>> + // Iteratively call Reset Filters and Reset Handlers.
>> + //
>> + for (OrderIndex = 0; OrderIndex < ARRAY_SIZE (mProcessingOrder);
>> OrderIndex++) {
>> + Hob = GetFirstGuidHob (mProcessingOrder[OrderIndex]);
>> + if (Hob != NULL) {
>> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
>> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
>> +
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] != NULL) {
>> + List->ResetFilters[Index] (ResetType, ResetStatus,
>> DataSize, ResetData);
>> + }
>> + }
>> + }
>> + }
>> + } else {
>> + ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
>> + DEBUG ((DEBUG_ERROR, "PEI ResetSystem2: Maximum reset call depth
>> is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));
>> + }
>> +
>> + switch (ResetType) {
>> + case EfiResetWarm:
>> + ResetWarm ();
>> + break;
>> +
>> + case EfiResetCold:
>> + ResetCold ();
>> + break;
>> +
>> + case EfiResetShutdown:
>> + ResetShutdown ();
>> + return ;
>> +
>> + case EfiResetPlatformSpecific:
>> + ResetPlatformSpecific (DataSize, ResetData);
>> + return;
>> +
>> + default:
>> + return ;
>> + }
>> +
>> + //
>> + // Given we should have reset getting here would be bad
>> + //
>> + ASSERT (FALSE);
>> +}
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> new file mode 100644
>> index 0000000000..2fcc3592b6
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> @@ -0,0 +1,129 @@
>> +/** @file
>> +
>> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +
>> + This program and the accompanying materials
>> + are licensed and made available under the terms and conditions of
>> the BSD License
>> + which accompanies this distribution. The full text of the license
>> may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#ifndef _RESET_SYSTEM2_H_
>> +#define _RESET_SYSTEM2_H_
>> +
>> +
>> +#include <Uefi.h>
>> +#include <PiPei.h>
>> +
>> +#include <Ppi/Reset2.h>
>> +#include <Ppi/PlatformSpecificResetFilter.h>
>> +#include <Ppi/PlatformSpecificResetHandler.h>
>> +
>> +#include <Library/BaseLib.h>
>> +#include <Library/BaseMemoryLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/PeiServicesLib.h>
>> +#include <Library/HobLib.h>
>> +#include <Library/ResetSystemLib.h>
>> +#include <Library/ReportStatusCodeLib.h>
>> +
>> +
>> +//
>> +// The maximum recurstion depth to ResetSystem() by reset
>> notification handlers
>> +//
>> +#define MAX_RESET_NOTIFY_DEPTH 10
>> +
>> +//
>> +// Data to put in GUIDed HOB
>> +//
>> +typedef struct {
>> + UINT32 Signature;
>> + UINT32 Count;
>> + EFI_RESET_SYSTEM ResetFilters[0]; //
>> ResetFilters[PcdGet32 (PcdMaximumResetNotifies)]
>> +} RESET_FILTER_LIST;
>> +#define RESET_FILTER_LIST_SIGNATURE SIGNATURE_32('r', 's', 't', 'l')
>> +
>> +
>> +typedef struct {
>> + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI ResetFilter;
>> + EFI_GUID *Guid;
>> +} RESET_FILTER_INSTANCE;
>> +
>> +/**
>> + Resets the entire platform.
>> +
>> + @param[in] ResetType The type of reset to perform.
>> + @param[in] ResetStatus The 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. ResetData is only
>> + valid if ResetStatus is something
>> other than EFI_SUCCESS
>> + unless the ResetType is
>> EfiResetPlatformSpecific
>> + where a minimum amount of ResetData
>> is always required.
>> + For a ResetType of
>> EfiResetPlatformSpecific the data buffer
>> + also starts with a Null-terminated
>> string that is followed
>> + by an EFI_GUID that describes the
>> specific type of reset to perform.
>> +
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetSystem2 (
>> + IN EFI_RESET_TYPE ResetType,
>> + IN EFI_STATUS ResetStatus,
>> + IN UINTN DataSize,
>> + IN VOID *ResetData OPTIONAL
>> + );
>> +/**
>> + Register a notification function to be called when ResetSystem() is
>> called.
>> +
>> + The RegisterResetNotify() function registers a notification
>> function that is called when
>> + ResetSystem()is called and prior to completing the reset of the
>> platform.
>> + The registered functions must not perform a platform reset
>> themselves. These
>> + notifications are intended only for the notification of components
>> which may need some
>> + special-purpose maintenance prior to the platform resetting.
>> +
>> + @param[in] This A pointer to the
>> EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI instance.
>> + @param[in] ResetFunction Points to the function to be called
>> when a ResetSystem() is executed.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> successfully registered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_OUT_OF_RESOURCES There are not enough resources
>> available to register the reset notification function.
>> + @retval EFI_ALREADY_STARTED The reset notification function
>> specified by ResetFunction has already been registered.
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +RegisterResetNotify (
>> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + );
>> +
>> +/**
>> + Unregister a notification function.
>> +
>> + The UnregisterResetNotify() function removes the previously registered
>> + notification using RegisterResetNotify().
>> +
>> + @param[in] This A pointer to the
>> EFI_RESET_NOTIFICATION_PROTOCOL instance.
>> + @param[in] ResetFunction The pointer to the ResetFunction
>> being unregistered.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> unregistered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_INVALID_PARAMETER The reset notification function
>> specified by ResetFunction was not previously
>> + registered using RegisterResetNotify().
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +UnregisterResetNotify (
>> + IN EFI_RESET_NOTIFICATION_PROTOCOL *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + );
>> +#endif
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> new file mode 100644
>> index 0000000000..38fdd16ceb
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> @@ -0,0 +1,62 @@
>> +## @file
>> +# This driver implements Reset2, ResetFilter and ResetHandler PPIs.
>> +#
>> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +#
>> +# This program and the accompanying materials are
>> +# licensed and made available under the terms and conditions of the
>> BSD License
>> +# which accompanies this distribution. The full text of the license
>> may be found at
>> +# http://opensource.org/licenses/bsd-license.php
>> +#
>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +#
>> +##
>> +
>> +[Defines]
>> + INF_VERSION = 0x00010005
>> + BASE_NAME = ResetSystemPei
>> + MODULE_UNI_FILE = ResetSystemPei.uni
>> + FILE_GUID = 6141E486-7543-4F1A-A579-FF532ED78E75
>> + MODULE_TYPE = PEIM
>> + VERSION_STRING = 1.0
>> +
>> + ENTRY_POINT = InitializeResetSystem
>> +
>> +#
>> +# The following information is for reference only and not required by
>> the build tools.
>> +#
>> +# VALID_ARCHITECTURES = IA32 X64
>> +#
>> +
>> +[Sources]
>> + ResetSystem.h
>> + ResetSystem.c
>> +
>> +[Packages]
>> + MdePkg/MdePkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> +
>> +[LibraryClasses]
>> + BaseLib
>> + BaseMemoryLib
>> + DebugLib
>> + PeiServicesLib
>> + HobLib
>> + PeimEntryPoint
>> + ResetSystemLib
>> + ReportStatusCodeLib
>> +
>> +[Ppis]
>> + gEfiPeiReset2PpiGuid ## PRODUCES
>> + gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
>> + gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
>> +
>> +[Pcd]
>> + gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies
>> +
>> +[Depex]
>> + TRUE
>> +
>> +[UserExtensions.TianoCore."ExtraFiles"]
>> + ResetSystemPeiExtra.uni
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> new file mode 100644
>> index 0000000000..6d2d650c37
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> @@ -0,0 +1,20 @@
>> +// /** @file
>> +// This driver implements Reset2, ResetFilter and ResetHandler PPIs.
>> +//
>> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +//
>> +// This program and the accompanying materials are
>> +// licensed and made available under the terms and conditions of the
>> BSD License
>> +// which accompanies this distribution. The full text of the license
>> may be found at
>> +// http://opensource.org/licenses/bsd-license.php
>> +//
>> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +//
>> +// **/
>> +
>> +
>> +#string STR_MODULE_ABSTRACT #language en-US "Implements
>> Reset2, ResetFilter and ResetHandler PPIs"
>> +
>> +#string STR_MODULE_DESCRIPTION #language en-US "This driver
>> implements Reset2, ResetFilter and ResetHandler PPIs."
>> +
>> diff --git
>> a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>> new file mode 100644
>> index 0000000000..2681afc707
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>> @@ -0,0 +1,20 @@
>> +// /** @file
>> +// ResetSystemPei Localized Strings and Content
>> +//
>> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +//
>> +// This program and the accompanying materials are
>> +// licensed and made available under the terms and conditions of the
>> BSD License
>> +// which accompanies this distribution. The full text of the license
>> may be found at
>> +// http://opensource.org/licenses/bsd-license.php
>> +//
>> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +//
>> +// **/
>> +
>> +#string STR_PROPERTIES_MODULE_NAME
>> +#language en-US
>> +"Reset System PEIM"
>> +
>> +
>>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM
2018-02-07 12:35 ` Zeng, Star
2018-02-08 2:16 ` Zeng, Star
@ 2018-02-09 3:12 ` Ni, Ruiyu
1 sibling, 0 replies; 31+ messages in thread
From: Ni, Ruiyu @ 2018-02-09 3:12 UTC (permalink / raw)
To: Zeng, Star, edk2-devel; +Cc: Michael D Kinney, Liming Gao
On 2/7/2018 8:35 PM, Zeng, Star wrote:
> On 2018/2/2 14:45, Ruiyu Ni wrote:
>> This driver implements Reset2, ResetFilter and ResetHandler PPIs.
>>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>
> Should ResetSystemPei be added in MdeModulePkg.dsc for build coverage?
Good catch. I just found I wrongly added this module in commit:
* MdeModulePkg: Add ResetUtility librray class and BASE instance
That commit happens before this one. I might introduce this bug
when rebasing the patches.
I will change that commit and this commit to make sure ResetSystemPei
is added in this commit.
>
> Same comment has been provided to ResetSystemRuntimeDxe.
> Should be (*RecursionDepthPointer < MAX_RESET_NOTIFY_DEPTH) instead of
> (*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH)>
As I just replied, "<=" is the intention actually.
>
>
> Thanks,
> Star
>
>> ---
>> MdeModulePkg/MdeModulePkg.dec | 4 +
>> .../Universal/ResetSystemPei/ResetSystem.c | 355
>> +++++++++++++++++++++
>> .../Universal/ResetSystemPei/ResetSystem.h | 129 ++++++++
>> .../Universal/ResetSystemPei/ResetSystemPei.inf | 62 ++++
>> .../Universal/ResetSystemPei/ResetSystemPei.uni | 20 ++
>> .../ResetSystemPei/ResetSystemPeiExtra.uni | 20 ++
>> 6 files changed, 590 insertions(+)
>> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> create mode 100644
>> MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> create mode 100644
>> MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> create mode 100644
>> MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>>
>> diff --git a/MdeModulePkg/MdeModulePkg.dec
>> b/MdeModulePkg/MdeModulePkg.dec
>> index 1cc9bc8ea1..1b971d599f 100644
>> --- a/MdeModulePkg/MdeModulePkg.dec
>> +++ b/MdeModulePkg/MdeModulePkg.dec
>> @@ -1419,6 +1419,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
>> # @Prompt CapsuleMax value in capsule report variable.
>> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0xFFFF|UINT16|0x00000107
>> + ## Indicates the allowable maximum number of Reset Filters or Reset
>> Handlers in PEI phase.
>> + # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers.
>> +
>> gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x00000109
>>
>> +
>> [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>> ## This PCD defines the Console output row. The default value is
>> 25 according to UEFI spec.
>> # This PCD could be set to 0 then console output would be at max
>> column and max row.
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> new file mode 100644
>> index 0000000000..720593de6a
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> @@ -0,0 +1,355 @@
>> +/** @file
>> + Implementation of Reset2, ResetFilter and ResetHandler PPIs.
>> +
>> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +
>> + This program and the accompanying materials
>> + are licensed and made available under the terms and conditions of
>> the BSD License
>> + which accompanies this distribution. The full text of the license
>> may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#include "ResetSystem.h"
>> +
>> +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
>> + L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
>> +};
>> +
>> +EFI_PEI_RESET2_PPI mPpiReset2 = {
>> + ResetSystem2
>> +};
>> +
>> +EFI_GUID *mProcessingOrder[] = {
>> + &gEdkiiPlatformSpecificResetFilterPpiGuid,
>> + &gEdkiiPlatformSpecificResetHandlerPpiGuid
>> +};
>> +
>> +RESET_FILTER_INSTANCE mResetFilter = {
>> + {
>> + RegisterResetNotify,
>> + UnregisterResetNotify
>> + },
>> + &gEdkiiPlatformSpecificResetFilterPpiGuid
>> +};
>> +
>> +RESET_FILTER_INSTANCE mResetHandler = {
>> + {
>> + RegisterResetNotify,
>> + UnregisterResetNotify
>> + },
>> + &gEdkiiPlatformSpecificResetHandlerPpiGuid
>> +};
>> +
>> +EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
>> + {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI,
>> + &gEfiPeiReset2PpiGuid,
>> + &mPpiReset2
>> + },
>> + {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI,
>> + &gEdkiiPlatformSpecificResetFilterPpiGuid,
>> + &mResetFilter.ResetFilter
>> + },
>> + {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
>> + &gEdkiiPlatformSpecificResetHandlerPpiGuid,
>> + &mResetHandler.ResetFilter
>> + }
>> +};
>> +
>> +/**
>> + Register a notification function to be called when ResetSystem() is
>> called.
>> +
>> + The RegisterResetNotify() function registers a notification
>> function that is called when
>> + ResetSystem()is called and prior to completing the reset of the
>> platform.
>> + The registered functions must not perform a platform reset
>> themselves. These
>> + notifications are intended only for the notification of components
>> which may need some
>> + special-purpose maintenance prior to the platform resetting.
>> + The list of registered reset notification functions are processed
>> if ResetSystem()is called
>> + before ExitBootServices(). The list of registered reset
>> notification functions is ignored if
>> + ResetSystem()is called after ExitBootServices().
>> +
>> + @param[in] This A pointer to the
>> EFI_RESET_NOTIFICATION_PROTOCOL instance.
>> + @param[in] ResetFunction Points to the function to be called
>> when a ResetSystem() is executed.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> successfully registered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_OUT_OF_RESOURCES There are not enough resources
>> available to register the reset notification function.
>> + @retval EFI_ALREADY_STARTED The reset notification function
>> specified by ResetFunction has already been registered.
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +RegisterResetNotify (
>> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + )
>> +{
>> + RESET_FILTER_INSTANCE *ResetFilter;
>> + RESET_FILTER_LIST *List;
>> + VOID *Hob;
>> + UINTN Index;
>> +
>> + if (ResetFunction == NULL) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + ResetFilter = (RESET_FILTER_INSTANCE *) This;
>> + ASSERT (CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
>> + CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid)
>> + );
>> +
>> + Hob = GetFirstGuidHob (ResetFilter->Guid);
>> + if (Hob == NULL) {
>> + //
>> + // When the GUIDed HOB doesn't exist, create it.
>> + //
>> + List = (RESET_FILTER_LIST *)BuildGuidHob (
>> + ResetFilter->Guid,
>> + sizeof (RESET_FILTER_LIST) + sizeof
>> (EFI_RESET_SYSTEM) * PcdGet32 (PcdMaximumPeiResetNotifies)
>> + );
>> + if (List == NULL) {
>> + return EFI_OUT_OF_RESOURCES;
>> + }
>> + List->Signature = RESET_FILTER_LIST_SIGNATURE;
>> + List->Count = PcdGet32 (PcdMaximumPeiResetNotifies);
>> + ZeroMem (List->ResetFilters, sizeof (EFI_RESET_SYSTEM) *
>> List->Count);
>> + List->ResetFilters[0] = ResetFunction;
>> + return EFI_SUCCESS;
>> + } else {
>> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
>> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
>> + //
>> + // Firstly check whether the ResetFunction is already registerred.
>> + //
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] == ResetFunction) {
>> + break;
>> + }
>> + }
>> + if (Index != List->Count) {
>> + return EFI_ALREADY_STARTED;
>> + }
>> +
>> + //
>> + // Secondly find the first free slot.
>> + //
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] == NULL) {
>> + break;
>> + }
>> + }
>> +
>> + if (Index == List->Count) {
>> + return EFI_OUT_OF_RESOURCES;
>> + }
>> + List->ResetFilters[Index] = ResetFunction;
>> + return EFI_SUCCESS;
>> + }
>> +}
>> +
>> +/**
>> + Unregister a notification function.
>> +
>> + The UnregisterResetNotify() function removes the previously registered
>> + notification using RegisterResetNotify().
>> +
>> + @param[in] This A pointer to the
>> EFI_RESET_NOTIFICATION_PROTOCOL instance.
>> + @param[in] ResetFunction The pointer to the ResetFunction
>> being unregistered.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> unregistered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_INVALID_PARAMETER The reset notification function
>> specified by ResetFunction was not previously
>> + registered using RegisterResetNotify().
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +UnregisterResetNotify (
>> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + )
>> +{
>> +
>> + RESET_FILTER_INSTANCE *ResetFilter;
>> + RESET_FILTER_LIST *List;
>> + VOID *Hob;
>> + UINTN Index;
>> +
>> + if (ResetFunction == NULL) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + ResetFilter = (RESET_FILTER_INSTANCE *)This;
>> + ASSERT (CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
>> + CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid)
>> + );
>> +
>> + Hob = GetFirstGuidHob (ResetFilter->Guid);
>> + if (Hob == NULL) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
>> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] == ResetFunction) {
>> + break;
>> + }
>> + }
>> +
>> + if (Index == List->Count) {
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + List->ResetFilters[Index] = NULL;
>> + return EFI_SUCCESS;
>> +}
>> +
>> +
>> +/**
>> + The PEIM's entry point.
>> +
>> + It initializes the Reset2, ResetFilter and ResetHandler PPIs.
>> +
>> + @param[in] FileHandle Handle of the file being invoked.
>> + @param[in] PeiServices Describes the list of possible PEI Services.
>> +
>> + @retval EFI_SUCCESS The entry point is executed successfully.
>> + @retval EFI_ALREADY_STARTED The Reset2 PPI was already installed.
>> + @retval others Status code returned from
>> PeiServicesInstallPpi().
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +InitializeResetSystem (
>> + IN EFI_PEI_FILE_HANDLE FileHandle,
>> + IN CONST EFI_PEI_SERVICES **PeiServices
>> + )
>> +{
>> + EFI_STATUS Status;
>> + VOID *Ppi;
>> +
>> + Status = PeiServicesLocatePpi (&gEfiPeiReset2PpiGuid, 0, NULL,
>> (VOID **)&Ppi);
>> + if (Status != EFI_NOT_FOUND) {
>> + return EFI_ALREADY_STARTED;
>> + }
>> +
>> + PeiServicesInstallPpi (mPpiListReset);
>> +
>> + return Status;
>> +}
>> +
>> +/**
>> + Resets the entire platform.
>> +
>> + @param[in] ResetType The type of reset to perform.
>> + @param[in] ResetStatus The 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. ResetData is only
>> + valid if ResetStatus is something
>> other than EFI_SUCCESS
>> + unless the ResetType is
>> EfiResetPlatformSpecific
>> + where a minimum amount of ResetData
>> is always required.
>> + For a ResetType of
>> EfiResetPlatformSpecific the data buffer
>> + also starts with a Null-terminated
>> string that is followed
>> + by an EFI_GUID that describes the
>> specific type of reset to perform.
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetSystem2 (
>> + IN EFI_RESET_TYPE ResetType,
>> + IN EFI_STATUS ResetStatus,
>> + IN UINTN DataSize,
>> + IN VOID *ResetData OPTIONAL
>> + )
>> +{
>> + VOID *Hob;
>> + UINTN Index;
>> + RESET_FILTER_LIST *List;
>> + UINTN OrderIndex;
>> + UINT8 RecursionDepth;
>> + UINT8 *RecursionDepthPointer;
>> +
>> + //
>> + // The recursion depth is stored in GUIDed HOB using gEfiCallerIdGuid.
>> + //
>> + Hob = GetFirstGuidHob (&gEfiCallerIdGuid);
>> + if (Hob == NULL) {
>> + RecursionDepth = 0;
>> + RecursionDepthPointer = BuildGuidDataHob (&gEfiCallerIdGuid,
>> &RecursionDepth, sizeof (RecursionDepth));
>> + } else {
>> + RecursionDepthPointer = (UINT8 *)GET_GUID_HOB_DATA (Hob);
>> + }
>> + //
>> + // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
>> + //
>> + if (*RecursionDepthPointer == 0) {
>> + //
>> + // Indicate reset system runtime service is called.
>> + //
>> + REPORT_STATUS_CODE (EFI_PROGRESS_CODE,
>> (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
>> + }
>> +
>> + //
>> + // Increase the call depth
>> + //
>> + (*RecursionDepthPointer)++;
>> + DEBUG ((DEBUG_INFO, "PEI ResetSystem2: Reset call depth = %d.\n",
>> *RecursionDepthPointer));
>> +
>> + if (*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH) {
>> + //
>> + // Iteratively call Reset Filters and Reset Handlers.
>> + //
>> + for (OrderIndex = 0; OrderIndex < ARRAY_SIZE (mProcessingOrder);
>> OrderIndex++) {
>> + Hob = GetFirstGuidHob (mProcessingOrder[OrderIndex]);
>> + if (Hob != NULL) {
>> + List = (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob);
>> + ASSERT (List->Signature == RESET_FILTER_LIST_SIGNATURE);
>> +
>> + for (Index = 0; Index < List->Count; Index++) {
>> + if (List->ResetFilters[Index] != NULL) {
>> + List->ResetFilters[Index] (ResetType, ResetStatus,
>> DataSize, ResetData);
>> + }
>> + }
>> + }
>> + }
>> + } else {
>> + ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
>> + DEBUG ((DEBUG_ERROR, "PEI ResetSystem2: Maximum reset call depth
>> is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));
>> + }
>> +
>> + switch (ResetType) {
>> + case EfiResetWarm:
>> + ResetWarm ();
>> + break;
>> +
>> + case EfiResetCold:
>> + ResetCold ();
>> + break;
>> +
>> + case EfiResetShutdown:
>> + ResetShutdown ();
>> + return ;
>> +
>> + case EfiResetPlatformSpecific:
>> + ResetPlatformSpecific (DataSize, ResetData);
>> + return;
>> +
>> + default:
>> + return ;
>> + }
>> +
>> + //
>> + // Given we should have reset getting here would be bad
>> + //
>> + ASSERT (FALSE);
>> +}
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> new file mode 100644
>> index 0000000000..2fcc3592b6
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> @@ -0,0 +1,129 @@
>> +/** @file
>> +
>> + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +
>> + This program and the accompanying materials
>> + are licensed and made available under the terms and conditions of
>> the BSD License
>> + which accompanies this distribution. The full text of the license
>> may be found at
>> + http://opensource.org/licenses/bsd-license.php
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#ifndef _RESET_SYSTEM2_H_
>> +#define _RESET_SYSTEM2_H_
>> +
>> +
>> +#include <Uefi.h>
>> +#include <PiPei.h>
>> +
>> +#include <Ppi/Reset2.h>
>> +#include <Ppi/PlatformSpecificResetFilter.h>
>> +#include <Ppi/PlatformSpecificResetHandler.h>
>> +
>> +#include <Library/BaseLib.h>
>> +#include <Library/BaseMemoryLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/PeiServicesLib.h>
>> +#include <Library/HobLib.h>
>> +#include <Library/ResetSystemLib.h>
>> +#include <Library/ReportStatusCodeLib.h>
>> +
>> +
>> +//
>> +// The maximum recurstion depth to ResetSystem() by reset
>> notification handlers
>> +//
>> +#define MAX_RESET_NOTIFY_DEPTH 10
>> +
>> +//
>> +// Data to put in GUIDed HOB
>> +//
>> +typedef struct {
>> + UINT32 Signature;
>> + UINT32 Count;
>> + EFI_RESET_SYSTEM ResetFilters[0]; //
>> ResetFilters[PcdGet32 (PcdMaximumResetNotifies)]
>> +} RESET_FILTER_LIST;
>> +#define RESET_FILTER_LIST_SIGNATURE SIGNATURE_32('r', 's', 't', 'l')
>> +
>> +
>> +typedef struct {
>> + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI ResetFilter;
>> + EFI_GUID *Guid;
>> +} RESET_FILTER_INSTANCE;
>> +
>> +/**
>> + Resets the entire platform.
>> +
>> + @param[in] ResetType The type of reset to perform.
>> + @param[in] ResetStatus The 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. ResetData is only
>> + valid if ResetStatus is something
>> other than EFI_SUCCESS
>> + unless the ResetType is
>> EfiResetPlatformSpecific
>> + where a minimum amount of ResetData
>> is always required.
>> + For a ResetType of
>> EfiResetPlatformSpecific the data buffer
>> + also starts with a Null-terminated
>> string that is followed
>> + by an EFI_GUID that describes the
>> specific type of reset to perform.
>> +
>> +**/
>> +VOID
>> +EFIAPI
>> +ResetSystem2 (
>> + IN EFI_RESET_TYPE ResetType,
>> + IN EFI_STATUS ResetStatus,
>> + IN UINTN DataSize,
>> + IN VOID *ResetData OPTIONAL
>> + );
>> +/**
>> + Register a notification function to be called when ResetSystem() is
>> called.
>> +
>> + The RegisterResetNotify() function registers a notification
>> function that is called when
>> + ResetSystem()is called and prior to completing the reset of the
>> platform.
>> + The registered functions must not perform a platform reset
>> themselves. These
>> + notifications are intended only for the notification of components
>> which may need some
>> + special-purpose maintenance prior to the platform resetting.
>> +
>> + @param[in] This A pointer to the
>> EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI instance.
>> + @param[in] ResetFunction Points to the function to be called
>> when a ResetSystem() is executed.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> successfully registered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_OUT_OF_RESOURCES There are not enough resources
>> available to register the reset notification function.
>> + @retval EFI_ALREADY_STARTED The reset notification function
>> specified by ResetFunction has already been registered.
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +RegisterResetNotify (
>> + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + );
>> +
>> +/**
>> + Unregister a notification function.
>> +
>> + The UnregisterResetNotify() function removes the previously registered
>> + notification using RegisterResetNotify().
>> +
>> + @param[in] This A pointer to the
>> EFI_RESET_NOTIFICATION_PROTOCOL instance.
>> + @param[in] ResetFunction The pointer to the ResetFunction
>> being unregistered.
>> +
>> + @retval EFI_SUCCESS The reset notification function was
>> unregistered.
>> + @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
>> + @retval EFI_INVALID_PARAMETER The reset notification function
>> specified by ResetFunction was not previously
>> + registered using RegisterResetNotify().
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +UnregisterResetNotify (
>> + IN EFI_RESET_NOTIFICATION_PROTOCOL *This,
>> + IN EFI_RESET_SYSTEM ResetFunction
>> + );
>> +#endif
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> new file mode 100644
>> index 0000000000..38fdd16ceb
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> @@ -0,0 +1,62 @@
>> +## @file
>> +# This driver implements Reset2, ResetFilter and ResetHandler PPIs.
>> +#
>> +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +#
>> +# This program and the accompanying materials are
>> +# licensed and made available under the terms and conditions of the
>> BSD License
>> +# which accompanies this distribution. The full text of the license
>> may be found at
>> +# http://opensource.org/licenses/bsd-license.php
>> +#
>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +#
>> +##
>> +
>> +[Defines]
>> + INF_VERSION = 0x00010005
>> + BASE_NAME = ResetSystemPei
>> + MODULE_UNI_FILE = ResetSystemPei.uni
>> + FILE_GUID = 6141E486-7543-4F1A-A579-FF532ED78E75
>> + MODULE_TYPE = PEIM
>> + VERSION_STRING = 1.0
>> +
>> + ENTRY_POINT = InitializeResetSystem
>> +
>> +#
>> +# The following information is for reference only and not required by
>> the build tools.
>> +#
>> +# VALID_ARCHITECTURES = IA32 X64
>> +#
>> +
>> +[Sources]
>> + ResetSystem.h
>> + ResetSystem.c
>> +
>> +[Packages]
>> + MdePkg/MdePkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> +
>> +[LibraryClasses]
>> + BaseLib
>> + BaseMemoryLib
>> + DebugLib
>> + PeiServicesLib
>> + HobLib
>> + PeimEntryPoint
>> + ResetSystemLib
>> + ReportStatusCodeLib
>> +
>> +[Ppis]
>> + gEfiPeiReset2PpiGuid ## PRODUCES
>> + gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
>> + gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
>> +
>> +[Pcd]
>> + gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies
>> +
>> +[Depex]
>> + TRUE
>> +
>> +[UserExtensions.TianoCore."ExtraFiles"]
>> + ResetSystemPeiExtra.uni
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> new file mode 100644
>> index 0000000000..6d2d650c37
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
>> @@ -0,0 +1,20 @@
>> +// /** @file
>> +// This driver implements Reset2, ResetFilter and ResetHandler PPIs.
>> +//
>> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +//
>> +// This program and the accompanying materials are
>> +// licensed and made available under the terms and conditions of the
>> BSD License
>> +// which accompanies this distribution. The full text of the license
>> may be found at
>> +// http://opensource.org/licenses/bsd-license.php
>> +//
>> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +//
>> +// **/
>> +
>> +
>> +#string STR_MODULE_ABSTRACT #language en-US "Implements
>> Reset2, ResetFilter and ResetHandler PPIs"
>> +
>> +#string STR_MODULE_DESCRIPTION #language en-US "This driver
>> implements Reset2, ResetFilter and ResetHandler PPIs."
>> +
>> diff --git
>> a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>> new file mode 100644
>> index 0000000000..2681afc707
>> --- /dev/null
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni
>> @@ -0,0 +1,20 @@
>> +// /** @file
>> +// ResetSystemPei Localized Strings and Content
>> +//
>> +// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
>> +//
>> +// This program and the accompanying materials are
>> +// licensed and made available under the terms and conditions of the
>> BSD License
>> +// which accompanies this distribution. The full text of the license
>> may be found at
>> +// http://opensource.org/licenses/bsd-license.php
>> +//
>> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +//
>> +// **/
>> +
>> +#string STR_PROPERTIES_MODULE_NAME
>> +#language en-US
>> +"Reset System PEIM"
>> +
>> +
>>
>
--
Thanks,
Ray
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI
2018-02-02 6:45 [PATCH 00/10] Formalize the reset system core design Ruiyu Ni
` (8 preceding siblings ...)
2018-02-02 6:45 ` [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM Ruiyu Ni
@ 2018-02-02 6:45 ` Ruiyu Ni
2018-02-07 12:40 ` Zeng, Star
9 siblings, 1 reply; 31+ messages in thread
From: Ruiyu Ni @ 2018-02-02 6:45 UTC (permalink / raw)
To: edk2-devel
Cc: Bret Barkelew, Liming Gao, Michael D Kinney, Star Zeng,
Bret Barkelew
From: Bret Barkelew <brbarkel@microsoft.com>
The Reset Notification protocol is added in UEFI spec to support
reset notification mechanism in the DXE phase.
This patch adds similar EDKII specific Reset Notification PPI to PEI
phase to provide the same support.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
.../Ppi/PlatformSpecificResetNotification.h | 31 ++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.dec | 3 +++
.../Universal/ResetSystemPei/ResetSystem.c | 16 +++++++++++
.../Universal/ResetSystemPei/ResetSystem.h | 1 +
.../Universal/ResetSystemPei/ResetSystemPei.inf | 7 ++---
5 files changed, 55 insertions(+), 3 deletions(-)
create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
new file mode 100644
index 0000000000..ea53e24133
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
@@ -0,0 +1,31 @@
+/** @file
+ This PPI provides services to register a platform specific notification callback for
+ ResetSystem(). The registered handlers are processed after
+ EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications.
+
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2017 Microsoft Corporation. All rights reserved.<BR>
+
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
+#define _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
+
+#include <Protocol/ResetNotification.h>
+
+#define EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_GUID \
+ { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0x0f, 0xdc, 0xf7, 0xcb } }
+
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI;
+
+extern EFI_GUID gEdkiiPlatformSpecificResetNotificationPpiGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 1b971d599f..297b02ffa9 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -444,6 +444,9 @@ [Ppis]
## Include/Ppi/PlatformSpecificResetFilter.h
gEdkiiPlatformSpecificResetFilterPpiGuid = { 0x8c9f4de3, 0x7b90, 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }
+ ## Include/Ppi/PlatformSpecificResetNotification.h
+ gEdkiiPlatformSpecificResetNotificationPpiGuid = { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0xf, 0xdc, 0xf7, 0xcb } }
+
## Include/Ppi/PlatformSpecificResetHandler.h
gEdkiiPlatformSpecificResetHandlerPpiGuid = { 0x75cf14ae, 0x3441, 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
index 720593de6a..4dfe303f77 100644
--- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
@@ -25,6 +25,7 @@ EFI_PEI_RESET2_PPI mPpiReset2 = {
EFI_GUID *mProcessingOrder[] = {
&gEdkiiPlatformSpecificResetFilterPpiGuid,
+ &gEdkiiPlatformSpecificResetNotificationPpiGuid,
&gEdkiiPlatformSpecificResetHandlerPpiGuid
};
@@ -36,6 +37,14 @@ RESET_FILTER_INSTANCE mResetFilter = {
&gEdkiiPlatformSpecificResetFilterPpiGuid
};
+RESET_FILTER_INSTANCE mResetNotification = {
+ {
+ RegisterResetNotify,
+ UnregisterResetNotify
+ },
+ &gEdkiiPlatformSpecificResetNotificationPpiGuid
+};
+
RESET_FILTER_INSTANCE mResetHandler = {
{
RegisterResetNotify,
@@ -55,6 +64,11 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
&gEdkiiPlatformSpecificResetFilterPpiGuid,
&mResetFilter.ResetFilter
},
+ {
+ EFI_PEI_PPI_DESCRIPTOR_PPI,
+ &gEdkiiPlatformSpecificResetNotificationPpiGuid,
+ &mResetNotification.ResetFilter
+ },
{
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEdkiiPlatformSpecificResetHandlerPpiGuid,
@@ -101,6 +115,7 @@ RegisterResetNotify (
ResetFilter = (RESET_FILTER_INSTANCE *) This;
ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
+ CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetNotificationPpiGuid) ||
CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
);
@@ -187,6 +202,7 @@ UnregisterResetNotify (
ResetFilter = (RESET_FILTER_INSTANCE *)This;
ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
+ CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetNotificationPpiGuid) ||
CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
);
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
index 2fcc3592b6..b623a4c381 100644
--- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
@@ -21,6 +21,7 @@
#include <Ppi/Reset2.h>
#include <Ppi/PlatformSpecificResetFilter.h>
+#include <Ppi/PlatformSpecificResetNotification.h>
#include <Ppi/PlatformSpecificResetHandler.h>
#include <Library/BaseLib.h>
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
index 38fdd16ceb..a88e2018b7 100644
--- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
@@ -48,9 +48,10 @@ [LibraryClasses]
ReportStatusCodeLib
[Ppis]
- gEfiPeiReset2PpiGuid ## PRODUCES
- gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
- gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
+ gEfiPeiReset2PpiGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetNotificationPpiGuid ## PRODUCES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI
2018-02-02 6:45 ` [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI Ruiyu Ni
@ 2018-02-07 12:40 ` Zeng, Star
2018-02-08 2:18 ` Zeng, Star
0 siblings, 1 reply; 31+ messages in thread
From: Zeng, Star @ 2018-02-07 12:40 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/2 14:45, Ruiyu Ni wrote:
> From: Bret Barkelew <brbarkel@microsoft.com>
>
> The Reset Notification protocol is added in UEFI spec to support
> reset notification mechanism in the DXE phase.
> This patch adds similar EDKII specific Reset Notification PPI to PEI
> phase to provide the same support.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> ---
> .../Ppi/PlatformSpecificResetNotification.h | 31 ++++++++++++++++++++++
> MdeModulePkg/MdeModulePkg.dec | 3 +++
> .../Universal/ResetSystemPei/ResetSystem.c | 16 +++++++++++
> .../Universal/ResetSystemPei/ResetSystem.h | 1 +
> .../Universal/ResetSystemPei/ResetSystemPei.inf | 7 ++---
> 5 files changed, 55 insertions(+), 3 deletions(-)
> create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
>
> diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
> new file mode 100644
> index 0000000000..ea53e24133
> --- /dev/null
> +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
> @@ -0,0 +1,31 @@
> +/** @file
> + This PPI provides services to register a platform specific notification callback for
> + ResetSystem(). The registered handlers are processed after
> + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications.
How about adding "and after EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI"
at the end of the sentence?
And also need enhance the comments in
MdeModulePkg\Include\Ppi\PlatformSpecificResetFilter.h to state it will
be processed before EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI
instead of EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI.
And also need enhance the comments in
MdeModulePkg\Include\Ppi\PlatformSpecificResetHandler.h to state it will
be processed after EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI
instead of EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI.
Thanks,
Star
> +
> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2017 Microsoft Corporation. All rights reserved.<BR>
> +
> + 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
> + http://opensource.org/licenses/bsd-license.php.
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
> +#define _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
> +
> +#include <Protocol/ResetNotification.h>
> +
> +#define EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_GUID \
> + { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0x0f, 0xdc, 0xf7, 0xcb } }
> +
> +typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI;
> +
> +extern EFI_GUID gEdkiiPlatformSpecificResetNotificationPpiGuid;
> +
> +#endif
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index 1b971d599f..297b02ffa9 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -444,6 +444,9 @@ [Ppis]
> ## Include/Ppi/PlatformSpecificResetFilter.h
> gEdkiiPlatformSpecificResetFilterPpiGuid = { 0x8c9f4de3, 0x7b90, 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }
>
> + ## Include/Ppi/PlatformSpecificResetNotification.h
> + gEdkiiPlatformSpecificResetNotificationPpiGuid = { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0xf, 0xdc, 0xf7, 0xcb } }
> +
> ## Include/Ppi/PlatformSpecificResetHandler.h
> gEdkiiPlatformSpecificResetHandlerPpiGuid = { 0x75cf14ae, 0x3441, 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }
>
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
> index 720593de6a..4dfe303f77 100644
> --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
> @@ -25,6 +25,7 @@ EFI_PEI_RESET2_PPI mPpiReset2 = {
>
> EFI_GUID *mProcessingOrder[] = {
> &gEdkiiPlatformSpecificResetFilterPpiGuid,
> + &gEdkiiPlatformSpecificResetNotificationPpiGuid,
> &gEdkiiPlatformSpecificResetHandlerPpiGuid
> };
>
> @@ -36,6 +37,14 @@ RESET_FILTER_INSTANCE mResetFilter = {
> &gEdkiiPlatformSpecificResetFilterPpiGuid
> };
>
> +RESET_FILTER_INSTANCE mResetNotification = {
> + {
> + RegisterResetNotify,
> + UnregisterResetNotify
> + },
> + &gEdkiiPlatformSpecificResetNotificationPpiGuid
> +};
> +
> RESET_FILTER_INSTANCE mResetHandler = {
> {
> RegisterResetNotify,
> @@ -55,6 +64,11 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
> &gEdkiiPlatformSpecificResetFilterPpiGuid,
> &mResetFilter.ResetFilter
> },
> + {
> + EFI_PEI_PPI_DESCRIPTOR_PPI,
> + &gEdkiiPlatformSpecificResetNotificationPpiGuid,
> + &mResetNotification.ResetFilter
> + },
> {
> EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> &gEdkiiPlatformSpecificResetHandlerPpiGuid,
> @@ -101,6 +115,7 @@ RegisterResetNotify (
>
> ResetFilter = (RESET_FILTER_INSTANCE *) This;
> ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
> + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetNotificationPpiGuid) ||
> CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
> );
>
> @@ -187,6 +202,7 @@ UnregisterResetNotify (
>
> ResetFilter = (RESET_FILTER_INSTANCE *)This;
> ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
> + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetNotificationPpiGuid) ||
> CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpiGuid)
> );
>
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
> index 2fcc3592b6..b623a4c381 100644
> --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
> @@ -21,6 +21,7 @@
>
> #include <Ppi/Reset2.h>
> #include <Ppi/PlatformSpecificResetFilter.h>
> +#include <Ppi/PlatformSpecificResetNotification.h>
> #include <Ppi/PlatformSpecificResetHandler.h>
>
> #include <Library/BaseLib.h>
> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
> index 38fdd16ceb..a88e2018b7 100644
> --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
> @@ -48,9 +48,10 @@ [LibraryClasses]
> ReportStatusCodeLib
>
> [Ppis]
> - gEfiPeiReset2PpiGuid ## PRODUCES
> - gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
> - gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
> + gEfiPeiReset2PpiGuid ## PRODUCES
> + gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
> + gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
> + gEdkiiPlatformSpecificResetNotificationPpiGuid ## PRODUCES
>
> [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI
2018-02-07 12:40 ` Zeng, Star
@ 2018-02-08 2:18 ` Zeng, Star
0 siblings, 0 replies; 31+ messages in thread
From: Zeng, Star @ 2018-02-08 2:18 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Michael D Kinney, Liming Gao, star.zeng
On 2018/2/7 20:40, Zeng, Star wrote:
> On 2018/2/2 14:45, Ruiyu Ni wrote:
>> From: Bret Barkelew <brbarkel@microsoft.com>
>>
>> The Reset Notification protocol is added in UEFI spec to support
>> reset notification mechanism in the DXE phase.
>> This patch adds similar EDKII specific Reset Notification PPI to PEI
>> phase to provide the same support.
>>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>> ---
>> .../Ppi/PlatformSpecificResetNotification.h | 31
>> ++++++++++++++++++++++
>> MdeModulePkg/MdeModulePkg.dec | 3 +++
>> .../Universal/ResetSystemPei/ResetSystem.c | 16 +++++++++++
>> .../Universal/ResetSystemPei/ResetSystem.h | 1 +
>> .../Universal/ResetSystemPei/ResetSystemPei.inf | 7 ++---
>> 5 files changed, 55 insertions(+), 3 deletions(-)
>> create mode 100644
>> MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
>>
>> diff --git
>> a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
>> b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
>> new file mode 100644
>> index 0000000000..ea53e24133
>> --- /dev/null
>> +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
>> @@ -0,0 +1,31 @@
>> +/** @file
>> + This PPI provides services to register a platform specific
>> notification callback for
>> + ResetSystem(). The registered handlers are processed after
>> + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications.
>
> How about adding "and after EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI"
> at the end of the sentence?
>
> And also need enhance the comments in
> MdeModulePkg\Include\Ppi\PlatformSpecificResetFilter.h to state it will
> be processed before EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI
> instead of EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI.
>
> And also need enhance the comments in
> MdeModulePkg\Include\Ppi\PlatformSpecificResetHandler.h to state it will
> be processed after EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI
> instead of EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI.
>
>
> Thanks,
> Star
Please also update the comments for PcdMaximumPeiResetNotifies in
MdeModulePkg.dec and MdeModulePkg.uni accordingly.
Thanks,
Star
>
>> +
>> + Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
>> + Copyright (c) 2017 Microsoft Corporation. All rights reserved.<BR>
>> +
>> + 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
>> + http://opensource.org/licenses/bsd-license.php.
>> +
>> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#ifndef _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
>> +#define _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
>> +
>> +#include <Protocol/ResetNotification.h>
>> +
>> +#define EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_GUID \
>> + { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0x0f, 0xdc,
>> 0xf7, 0xcb } }
>> +
>> +typedef EFI_RESET_NOTIFICATION_PROTOCOL
>> EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI;
>> +
>> +extern EFI_GUID gEdkiiPlatformSpecificResetNotificationPpiGuid;
>> +
>> +#endif
>> diff --git a/MdeModulePkg/MdeModulePkg.dec
>> b/MdeModulePkg/MdeModulePkg.dec
>> index 1b971d599f..297b02ffa9 100644
>> --- a/MdeModulePkg/MdeModulePkg.dec
>> +++ b/MdeModulePkg/MdeModulePkg.dec
>> @@ -444,6 +444,9 @@ [Ppis]
>> ## Include/Ppi/PlatformSpecificResetFilter.h
>> gEdkiiPlatformSpecificResetFilterPpiGuid = { 0x8c9f4de3, 0x7b90,
>> 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }
>> + ## Include/Ppi/PlatformSpecificResetNotification.h
>> + gEdkiiPlatformSpecificResetNotificationPpiGuid = { 0xe09f355d,
>> 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0xf, 0xdc, 0xf7, 0xcb } }
>> +
>> ## Include/Ppi/PlatformSpecificResetHandler.h
>> gEdkiiPlatformSpecificResetHandlerPpiGuid = { 0x75cf14ae, 0x3441,
>> 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> index 720593de6a..4dfe303f77 100644
>> --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
>> @@ -25,6 +25,7 @@ EFI_PEI_RESET2_PPI mPpiReset2 = {
>> EFI_GUID *mProcessingOrder[] = {
>> &gEdkiiPlatformSpecificResetFilterPpiGuid,
>> + &gEdkiiPlatformSpecificResetNotificationPpiGuid,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid
>> };
>> @@ -36,6 +37,14 @@ RESET_FILTER_INSTANCE mResetFilter = {
>> &gEdkiiPlatformSpecificResetFilterPpiGuid
>> };
>> +RESET_FILTER_INSTANCE mResetNotification = {
>> + {
>> + RegisterResetNotify,
>> + UnregisterResetNotify
>> + },
>> + &gEdkiiPlatformSpecificResetNotificationPpiGuid
>> +};
>> +
>> RESET_FILTER_INSTANCE mResetHandler = {
>> {
>> RegisterResetNotify,
>> @@ -55,6 +64,11 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
>> &gEdkiiPlatformSpecificResetFilterPpiGuid,
>> &mResetFilter.ResetFilter
>> },
>> + {
>> + EFI_PEI_PPI_DESCRIPTOR_PPI,
>> + &gEdkiiPlatformSpecificResetNotificationPpiGuid,
>> + &mResetNotification.ResetFilter
>> + },
>> {
>> EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid,
>> @@ -101,6 +115,7 @@ RegisterResetNotify (
>> ResetFilter = (RESET_FILTER_INSTANCE *) This;
>> ASSERT (CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
>> + CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetNotificationPpiGuid) ||
>> CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid)
>> );
>> @@ -187,6 +202,7 @@ UnregisterResetNotify (
>> ResetFilter = (RESET_FILTER_INSTANCE *)This;
>> ASSERT (CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetFilterPpiGuid) ||
>> + CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetNotificationPpiGuid) ||
>> CompareGuid (ResetFilter->Guid,
>> &gEdkiiPlatformSpecificResetHandlerPpiGuid)
>> );
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> index 2fcc3592b6..b623a4c381 100644
>> --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
>> @@ -21,6 +21,7 @@
>> #include <Ppi/Reset2.h>
>> #include <Ppi/PlatformSpecificResetFilter.h>
>> +#include <Ppi/PlatformSpecificResetNotification.h>
>> #include <Ppi/PlatformSpecificResetHandler.h>
>> #include <Library/BaseLib.h>
>> diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> index 38fdd16ceb..a88e2018b7 100644
>> --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
>> @@ -48,9 +48,10 @@ [LibraryClasses]
>> ReportStatusCodeLib
>> [Ppis]
>> - gEfiPeiReset2PpiGuid ## PRODUCES
>> - gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
>> - gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
>> + gEfiPeiReset2PpiGuid ## PRODUCES
>> + gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES
>> + gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES
>> + gEdkiiPlatformSpecificResetNotificationPpiGuid ## PRODUCES
>> [Pcd]
>> gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies
>>
^ permalink raw reply [flat|nested] 31+ messages in thread