]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
ArmPkg/ArmSmcPsciResetSystemLib: implement fallback for warm reboot
[mirror_edk2.git] / ArmPkg / Library / ArmSmcPsciResetSystemLib / ArmSmcPsciResetSystemLib.c
CommitLineData
b2c55e73
AB
1/** @file\r
2 ResetSystemLib implementation using PSCI calls\r
3\r
4 Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <PiDxe.h>\r
17\r
dde2dd64
AB
18#include <Library/ArmMmuLib.h>\r
19#include <Library/ArmSmcLib.h>\r
b2c55e73
AB
20#include <Library/BaseLib.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/ResetSystemLib.h>\r
dde2dd64
AB
23#include <Library/UefiBootServicesTableLib.h>\r
24#include <Library/UefiRuntimeLib.h>\r
b2c55e73
AB
25\r
26#include <IndustryStandard/ArmStdSmc.h>\r
27\r
28/**\r
29 This function causes a system-wide reset (cold reset), in which\r
30 all circuitry within the system returns to its initial state. This type of reset\r
31 is asynchronous to system operation and operates without regard to\r
32 cycle boundaries.\r
33\r
34 If this function returns, it means that the system does not support cold reset.\r
35**/\r
36VOID\r
37EFIAPI\r
38ResetCold (\r
39 VOID\r
40 )\r
41{\r
42 ARM_SMC_ARGS ArmSmcArgs;\r
43\r
44 // Send a PSCI 0.2 SYSTEM_RESET command\r
45 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;\r
46 ArmCallSmc (&ArmSmcArgs);\r
47}\r
48\r
49/**\r
50 This function causes a system-wide initialization (warm reset), in which all processors\r
51 are set to their initial state. Pending cycles are not corrupted.\r
52\r
53 If this function returns, it means that the system does not support warm reset.\r
54**/\r
55VOID\r
56EFIAPI\r
57ResetWarm (\r
58 VOID\r
59 )\r
60{\r
61 // Map a warm reset into a cold reset\r
62 ResetCold ();\r
63}\r
64\r
65/**\r
66 This function causes the system to enter a power state equivalent\r
67 to the ACPI G2/S5 or G3 states.\r
68\r
69 If this function returns, it means that the system does not support shutdown reset.\r
70**/\r
71VOID\r
72EFIAPI\r
73ResetShutdown (\r
74 VOID\r
75 )\r
76{\r
77 ARM_SMC_ARGS ArmSmcArgs;\r
78\r
79 // Send a PSCI 0.2 SYSTEM_OFF command\r
80 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;\r
81 ArmCallSmc (&ArmSmcArgs);\r
82}\r
83\r
84/**\r
85 This function causes the system to enter S3 and then wake up immediately.\r
86\r
87 If this function returns, it means that the system does not support S3 feature.\r
88**/\r
89VOID\r
90EFIAPI\r
91EnterS3WithImmediateWake (\r
92 VOID\r
93 )\r
94{\r
dde2dd64
AB
95 VOID (*Reset)(VOID);\r
96\r
97 if (FeaturePcdGet (PcdArmReenterPeiForCapsuleWarmReboot) &&\r
98 !EfiAtRuntime ()) {\r
99 //\r
100 // At boot time, we are the only core running, so we can implement the\r
101 // immediate wake (which is used by capsule update) by disabling the MMU\r
102 // and interrupts, and jumping to the PEI entry point.\r
103 //\r
104 Reset = (VOID (*)(VOID))(UINTN)FixedPcdGet64 (PcdFvBaseAddress);\r
105\r
106 gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
107 ArmDisableMmu ();\r
108 Reset ();\r
109 }\r
b2c55e73
AB
110}\r
111\r
112/**\r
113 This function causes a systemwide reset. The exact type of the reset is\r
114 defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r
115 into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r
116 the platform must pick a supported reset type to perform.The platform may\r
117 optionally log the parameters from any non-normal reset that occurs.\r
118\r
119 @param[in] DataSize The size, in bytes, of ResetData.\r
120 @param[in] ResetData The data buffer starts with a Null-terminated string,\r
121 followed by the EFI_GUID.\r
122**/\r
123VOID\r
124EFIAPI\r
125ResetPlatformSpecific (\r
126 IN UINTN DataSize,\r
127 IN VOID *ResetData\r
128 )\r
129{\r
130 // Map the platform specific reset as reboot\r
131 ResetCold ();\r
132}\r