]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
ArmPkg/ArmSmcPsciResetSystemLib: remove EnterS3WithImmediateWake ()
[mirror_edk2.git] / ArmPkg / Library / ArmSmcPsciResetSystemLib / ArmSmcPsciResetSystemLib.c
CommitLineData
b2c55e73
AB
1/** @file\r
2 ResetSystemLib implementation using PSCI calls\r
3\r
6556224e 4 Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved.<BR>\r
bda4d5be 5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
b2c55e73 6\r
4059386c 7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
b2c55e73
AB
8\r
9**/\r
10\r
11#include <PiDxe.h>\r
12\r
dde2dd64 13#include <Library/ArmSmcLib.h>\r
b2c55e73
AB
14#include <Library/BaseLib.h>\r
15#include <Library/DebugLib.h>\r
16#include <Library/ResetSystemLib.h>\r
b2c55e73
AB
17\r
18#include <IndustryStandard/ArmStdSmc.h>\r
19\r
20/**\r
21 This function causes a system-wide reset (cold reset), in which\r
22 all circuitry within the system returns to its initial state. This type of reset\r
23 is asynchronous to system operation and operates without regard to\r
24 cycle boundaries.\r
25\r
26 If this function returns, it means that the system does not support cold reset.\r
27**/\r
28VOID\r
29EFIAPI\r
30ResetCold (\r
31 VOID\r
32 )\r
33{\r
34 ARM_SMC_ARGS ArmSmcArgs;\r
35\r
36 // Send a PSCI 0.2 SYSTEM_RESET command\r
37 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;\r
38 ArmCallSmc (&ArmSmcArgs);\r
39}\r
40\r
41/**\r
42 This function causes a system-wide initialization (warm reset), in which all processors\r
43 are set to their initial state. Pending cycles are not corrupted.\r
44\r
45 If this function returns, it means that the system does not support warm reset.\r
46**/\r
47VOID\r
48EFIAPI\r
49ResetWarm (\r
50 VOID\r
51 )\r
52{\r
53 // Map a warm reset into a cold reset\r
54 ResetCold ();\r
55}\r
56\r
57/**\r
58 This function causes the system to enter a power state equivalent\r
59 to the ACPI G2/S5 or G3 states.\r
60\r
61 If this function returns, it means that the system does not support shutdown reset.\r
62**/\r
63VOID\r
64EFIAPI\r
65ResetShutdown (\r
66 VOID\r
67 )\r
68{\r
69 ARM_SMC_ARGS ArmSmcArgs;\r
70\r
71 // Send a PSCI 0.2 SYSTEM_OFF command\r
72 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;\r
73 ArmCallSmc (&ArmSmcArgs);\r
74}\r
75\r
b2c55e73
AB
76/**\r
77 This function causes a systemwide reset. The exact type of the reset is\r
78 defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r
79 into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r
80 the platform must pick a supported reset type to perform.The platform may\r
81 optionally log the parameters from any non-normal reset that occurs.\r
82\r
83 @param[in] DataSize The size, in bytes, of ResetData.\r
84 @param[in] ResetData The data buffer starts with a Null-terminated string,\r
85 followed by the EFI_GUID.\r
86**/\r
87VOID\r
88EFIAPI\r
89ResetPlatformSpecific (\r
90 IN UINTN DataSize,\r
91 IN VOID *ResetData\r
92 )\r
93{\r
94 // Map the platform specific reset as reboot\r
95 ResetCold ();\r
96}\r
bda4d5be
ZG
97\r
98/**\r
99 The ResetSystem function resets the entire platform.\r
100\r
101 @param[in] ResetType The type of reset to perform.\r
102 @param[in] ResetStatus The status code for the reset.\r
103 @param[in] DataSize The size, in bytes, of ResetData.\r
104 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
105 the data buffer starts with a Null-terminated string, optionally\r
106 followed by additional binary data. The string is a description\r
107 that the caller may use to further indicate the reason for the\r
108 system reset.\r
109**/\r
110VOID\r
111EFIAPI\r
112ResetSystem (\r
113 IN EFI_RESET_TYPE ResetType,\r
114 IN EFI_STATUS ResetStatus,\r
115 IN UINTN DataSize,\r
116 IN VOID *ResetData OPTIONAL\r
117 )\r
118{\r
119 switch (ResetType) {\r
120 case EfiResetWarm:\r
121 ResetWarm ();\r
122 break;\r
123\r
124 case EfiResetCold:\r
125 ResetCold ();\r
126 break;\r
127\r
128 case EfiResetShutdown:\r
129 ResetShutdown ();\r
130 return;\r
131\r
132 case EfiResetPlatformSpecific:\r
133 ResetPlatformSpecific (DataSize, ResetData);\r
134 return;\r
135\r
136 default:\r
137 return;\r
138 }\r
139}\r