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