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