]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/Reset/Reset.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Reset / Reset.c
1 /** @file
2 Pei Core Reset System Support
3
4 Copyright (c) 2006 - 2019, 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.
76
77 **/
78 VOID
79 EFIAPI
80 PeiResetSystem2 (
81 IN EFI_RESET_TYPE ResetType,
82 IN EFI_STATUS ResetStatus,
83 IN UINTN DataSize,
84 IN VOID *ResetData OPTIONAL
85 )
86 {
87 EFI_STATUS Status;
88 EFI_PEI_RESET2_PPI *Reset2Ppi;
89
90 //
91 // Look for PEI Reset System 2 PPI
92 //
93 Status = PeiServicesLocatePpi (
94 &gEfiPeiReset2PpiGuid,
95 0,
96 NULL,
97 (VOID **)&Reset2Ppi
98 );
99 if (!EFI_ERROR (Status)) {
100 Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
101 return;
102 }
103
104 //
105 // Report Status Code that Reset2 PPI is not available.
106 //
107 REPORT_STATUS_CODE (
108 EFI_ERROR_CODE | EFI_ERROR_MINOR,
109 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)
110 );
111 }