]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/Reset/Reset.c
MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c
[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
c8721bb2 4Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
8f86d67d
MK
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
192f6d4c 12\r
b1f6a7c6 13**/\r
192f6d4c 14\r
0d516397 15#include "PeiMain.h"\r
192f6d4c 16\r
b1f6a7c6 17/**\r
192f6d4c 18\r
b1f6a7c6 19 Core version of the Reset System\r
192f6d4c 20\r
192f6d4c 21\r
dc857d56 22 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
192f6d4c 23\r
b1f6a7c6 24 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
25 @retval EFI_DEVICE_ERROR Did not reset system.\r
26 Otherwise, resets the system.\r
192f6d4c 27\r
b1f6a7c6 28**/\r
192f6d4c 29EFI_STATUS\r
30EFIAPI\r
31PeiResetSystem (\r
8f86d67d 32 IN CONST EFI_PEI_SERVICES **PeiServices\r
192f6d4c 33 )\r
192f6d4c 34{\r
8f86d67d
MK
35 EFI_STATUS Status;\r
36 EFI_PEI_RESET_PPI *ResetPpi;\r
192f6d4c 37\r
7072a185
MK
38 //\r
39 // Attempt to use newer ResetSystem2(). If this returns, then ResetSystem2()\r
40 // is not available.\r
41 //\r
42 PeiResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
192f6d4c 43\r
44 //\r
7072a185 45 // Look for PEI Reset System PPI\r
192f6d4c 46 //\r
7072a185
MK
47 Status = PeiServicesLocatePpi (\r
48 &gEfiPeiResetPpiGuid,\r
49 0,\r
50 NULL,\r
51 (VOID **)&ResetPpi\r
52 );\r
192f6d4c 53 if (!EFI_ERROR (Status)) {\r
54 return ResetPpi->ResetSystem (PeiServices);\r
8f86d67d
MK
55 }\r
56\r
37623a5c 57 //\r
8f86d67d 58 // Report Status Code that Reset PPI is not available.\r
37623a5c 59 //\r
60 REPORT_STATUS_CODE (\r
61 EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
62 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)\r
63 );\r
7072a185
MK
64\r
65 //\r
66 // No reset PPIs are available yet.\r
67 //\r
192f6d4c 68 return EFI_NOT_AVAILABLE_YET;\r
69}\r
70\r
672473ea
SZ
71/**\r
72 Resets the entire platform.\r
73\r
74 @param[in] ResetType The type of reset to perform.\r
75 @param[in] ResetStatus The status code for the reset.\r
c8721bb2 76 @param[in] DataSize The size, in bytes, of ResetData.\r
672473ea
SZ
77 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
78 the data buffer starts with a Null-terminated string, optionally\r
79 followed by additional binary data. The string is a description\r
80 that the caller may use to further indicate the reason for the\r
81 system reset. ResetData is only valid if ResetStatus is something\r
82 other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
83 where a minimum amount of ResetData is always required.\r
84\r
85**/\r
86VOID\r
87EFIAPI\r
88PeiResetSystem2 (\r
8f86d67d
MK
89 IN EFI_RESET_TYPE ResetType,\r
90 IN EFI_STATUS ResetStatus,\r
91 IN UINTN DataSize,\r
92 IN VOID *ResetData OPTIONAL\r
672473ea
SZ
93 )\r
94{\r
8f86d67d
MK
95 EFI_STATUS Status;\r
96 EFI_PEI_RESET2_PPI *Reset2Ppi;\r
672473ea 97\r
7072a185
MK
98 //\r
99 // Look for PEI Reset System 2 PPI\r
100 //\r
672473ea
SZ
101 Status = PeiServicesLocatePpi (\r
102 &gEfiPeiReset2PpiGuid,\r
103 0,\r
104 NULL,\r
105 (VOID **)&Reset2Ppi\r
106 );\r
672473ea
SZ
107 if (!EFI_ERROR (Status)) {\r
108 Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
109 return;\r
110 }\r
111\r
112 //\r
113 // Report Status Code that Reset2 PPI is not available.\r
114 //\r
115 REPORT_STATUS_CODE (\r
116 EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
117 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)\r
118 );\r
119}\r