]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Reset/Reset.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Reset / Reset.c
index 2788a0e161a2be1ca899fbc08ff16f01c6692286..263eace239ececa5508dd9ef6aea259dd933a632 100644 (file)
-/*++\r
+/** @file\r
+  Pei Core Reset System Support\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
-Module Name:\r
+**/\r
 \r
-  Reset.c\r
+#include "PeiMain.h"\r
 \r
-Abstract:\r
+/**\r
 \r
-  Pei Core Reset System Support\r
+  Core version of the Reset System\r
 \r
-Revision History\r
 \r
---*/\r
+  @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
 \r
-#include <PeiMain.h>\r
+  @retval EFI_NOT_AVAILABLE_YET     PPI not available yet.\r
+  @retval EFI_DEVICE_ERROR          Did not reset system.\r
+                                    Otherwise, resets the system.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiResetSystem (\r
-  IN CONST EFI_PEI_SERVICES         **PeiServices\r
+  IN CONST EFI_PEI_SERVICES  **PeiServices\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Core version of the Reset System\r
+{\r
+  EFI_STATUS         Status;\r
+  EFI_PEI_RESET_PPI  *ResetPpi;\r
 \r
-Arguments:\r
+  //\r
+  // Attempt to use newer ResetSystem2().  If this returns, then ResetSystem2()\r
+  // is not available.\r
+  //\r
+  PeiResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
 \r
-  PeiServices - The PEI core services table.\r
+  //\r
+  // Look for PEI Reset System PPI\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiResetPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&ResetPpi\r
+             );\r
+  if (!EFI_ERROR (Status)) {\r
+    return ResetPpi->ResetSystem (PeiServices);\r
+  }\r
 \r
-Returns:\r
+  //\r
+  // Report Status Code that Reset PPI is not available.\r
+  //\r
+  REPORT_STATUS_CODE (\r
+    EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+    (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)\r
+    );\r
 \r
-  Status  - EFI_NOT_AVAILABLE_YET. PPI not available yet.\r
-          - EFI_DEVICE_ERROR.   Did not reset system.\r
-          \r
-  Otherwise, resets the system. \r
+  //\r
+  // No reset PPIs are available yet.\r
+  //\r
+  return  EFI_NOT_AVAILABLE_YET;\r
+}\r
 \r
---*/\r
+/**\r
+  Resets the entire platform.\r
+\r
+  @param[in] ResetType      The type of reset to perform.\r
+  @param[in] ResetStatus    The status code for the reset.\r
+  @param[in] DataSize       The size, in bytes, of ResetData.\r
+  @param[in] ResetData      For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
+                            the data buffer starts with a Null-terminated string, optionally\r
+                            followed by additional binary data. The string is a description\r
+                            that the caller may use to further indicate the reason for the\r
+                            system reset. ResetData is only valid if ResetStatus is something\r
+                            other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
+                            where a minimum amount of ResetData is always required.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiResetSystem2 (\r
+  IN EFI_RESET_TYPE  ResetType,\r
+  IN EFI_STATUS      ResetStatus,\r
+  IN UINTN           DataSize,\r
+  IN VOID            *ResetData OPTIONAL\r
+  )\r
 {\r
-  EFI_STATUS        Status;\r
-  EFI_PEI_RESET_PPI *ResetPpi;\r
+  EFI_STATUS          Status;\r
+  EFI_PEI_RESET2_PPI  *Reset2Ppi;\r
 \r
+  //\r
+  // Look for PEI Reset System 2 PPI\r
+  //\r
   Status = PeiServicesLocatePpi (\r
-             &gEfiPeiResetPpiGuid,         \r
-             0,                         \r
-             NULL,                      \r
-             (VOID **)&ResetPpi                  \r
+             &gEfiPeiReset2PpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&Reset2Ppi\r
              );\r
+  if (!EFI_ERROR (Status)) {\r
+    Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
+    return;\r
+  }\r
 \r
   //\r
-  // LocatePpi returns EFI_NOT_FOUND on error\r
+  // Report Status Code that Reset2 PPI is not available.\r
   //\r
-  if (!EFI_ERROR (Status)) {\r
-    return ResetPpi->ResetSystem (PeiServices);\r
-  } \r
-  return  EFI_NOT_AVAILABLE_YET;\r
+  REPORT_STATUS_CODE (\r
+    EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+    (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)\r
+    );\r
 }\r
-\r