]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/Reset/Reset.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Reset / Reset.c
CommitLineData
615c6dd0 1/** @file\r
b1f6a7c6 2 Pei Core Reset System Support\r
8f86d67d 3\r
eac49c83 4Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
192f6d4c 6\r
b1f6a7c6 7**/\r
192f6d4c 8\r
0d516397 9#include "PeiMain.h"\r
192f6d4c 10\r
b1f6a7c6 11/**\r
192f6d4c 12\r
b1f6a7c6 13 Core version of the Reset System\r
192f6d4c 14\r
192f6d4c 15\r
dc857d56 16 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
192f6d4c 17\r
b1f6a7c6 18 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
19 @retval EFI_DEVICE_ERROR Did not reset system.\r
20 Otherwise, resets the system.\r
192f6d4c 21\r
b1f6a7c6 22**/\r
192f6d4c 23EFI_STATUS\r
24EFIAPI\r
25PeiResetSystem (\r
8f86d67d 26 IN CONST EFI_PEI_SERVICES **PeiServices\r
192f6d4c 27 )\r
192f6d4c 28{\r
8f86d67d
MK
29 EFI_STATUS Status;\r
30 EFI_PEI_RESET_PPI *ResetPpi;\r
192f6d4c 31\r
7072a185
MK
32 //\r
33 // Attempt to use newer ResetSystem2(). If this returns, then ResetSystem2()\r
34 // is not available.\r
35 //\r
36 PeiResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
192f6d4c 37\r
38 //\r
7072a185 39 // Look for PEI Reset System PPI\r
192f6d4c 40 //\r
7072a185
MK
41 Status = PeiServicesLocatePpi (\r
42 &gEfiPeiResetPpiGuid,\r
43 0,\r
44 NULL,\r
45 (VOID **)&ResetPpi\r
46 );\r
192f6d4c 47 if (!EFI_ERROR (Status)) {\r
48 return ResetPpi->ResetSystem (PeiServices);\r
8f86d67d
MK
49 }\r
50\r
37623a5c 51 //\r
8f86d67d 52 // Report Status Code that Reset PPI is not available.\r
37623a5c 53 //\r
54 REPORT_STATUS_CODE (\r
55 EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
56 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)\r
57 );\r
7072a185
MK
58\r
59 //\r
60 // No reset PPIs are available yet.\r
61 //\r
1436aea4 62 return EFI_NOT_AVAILABLE_YET;\r
192f6d4c 63}\r
64\r
672473ea
SZ
65/**\r
66 Resets the entire platform.\r
67\r
68 @param[in] ResetType The type of reset to perform.\r
69 @param[in] ResetStatus The status code for the reset.\r
c8721bb2 70 @param[in] DataSize The size, in bytes, of ResetData.\r
672473ea
SZ
71 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
72 the data buffer starts with a Null-terminated string, optionally\r
73 followed by additional binary data. The string is a description\r
74 that the caller may use to further indicate the reason for the\r
eac49c83 75 system reset.\r
672473ea
SZ
76\r
77**/\r
78VOID\r
79EFIAPI\r
80PeiResetSystem2 (\r
8f86d67d
MK
81 IN EFI_RESET_TYPE ResetType,\r
82 IN EFI_STATUS ResetStatus,\r
83 IN UINTN DataSize,\r
84 IN VOID *ResetData OPTIONAL\r
672473ea
SZ
85 )\r
86{\r
8f86d67d
MK
87 EFI_STATUS Status;\r
88 EFI_PEI_RESET2_PPI *Reset2Ppi;\r
672473ea 89\r
7072a185
MK
90 //\r
91 // Look for PEI Reset System 2 PPI\r
92 //\r
672473ea
SZ
93 Status = PeiServicesLocatePpi (\r
94 &gEfiPeiReset2PpiGuid,\r
95 0,\r
96 NULL,\r
97 (VOID **)&Reset2Ppi\r
98 );\r
672473ea
SZ
99 if (!EFI_ERROR (Status)) {\r
100 Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
101 return;\r
102 }\r
103\r
104 //\r
105 // Report Status Code that Reset2 PPI is not available.\r
106 //\r
107 REPORT_STATUS_CODE (\r
108 EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
109 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)\r
110 );\r
111}\r