2 ResetSystemLib implementation using PSCI calls
4 Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved.<BR>
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
6 Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/ArmSmcLib.h>
15 #include <Library/BaseLib.h>
16 #include <Library/DebugLib.h>
17 #include <Library/ResetSystemLib.h>
19 #include <IndustryStandard/ArmStdSmc.h>
22 This function causes a system-wide reset (cold reset), in which
23 all circuitry within the system returns to its initial state. This type of reset
24 is asynchronous to system operation and operates without regard to
27 If this function returns, it means that the system does not support cold reset.
35 // Send a PSCI 0.2 SYSTEM_RESET command
36 ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_RESET
, NULL
, NULL
, NULL
);
40 This function causes a system-wide initialization (warm reset), in which all processors
41 are set to their initial state. Pending cycles are not corrupted.
43 If this function returns, it means that the system does not support warm reset.
54 Arg1
= ARM_SMC_ID_PSCI_SYSTEM_RESET2_AARCH64
;
56 // Is SYSTEM_RESET2 supported?
57 Ret
= ArmCallSmc0 (ARM_SMC_ID_PSCI_FEATURES
, &Arg1
, NULL
, NULL
);
58 if (Ret
== ARM_SMC_PSCI_RET_SUCCESS
) {
59 // Send PSCI SYSTEM_RESET2 command
60 ArmCallSmc0 (Arg1
, NULL
, NULL
, NULL
);
62 // Map a warm reset into a cold reset
65 "Warm reboot not supported by platform, issuing cold reboot\n"
72 This function causes the system to enter a power state equivalent
73 to the ACPI G2/S5 or G3 states.
75 If this function returns, it means that the system does not support shutdown reset.
83 // Send a PSCI 0.2 SYSTEM_OFF command
84 ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_OFF
, NULL
, NULL
, NULL
);
88 This function causes a systemwide reset. The exact type of the reset is
89 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
90 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
91 the platform must pick a supported reset type to perform.The platform may
92 optionally log the parameters from any non-normal reset that occurs.
94 @param[in] DataSize The size, in bytes, of ResetData.
95 @param[in] ResetData The data buffer starts with a Null-terminated string,
96 followed by the EFI_GUID.
100 ResetPlatformSpecific (
105 // Map the platform specific reset as reboot
110 The ResetSystem function resets the entire platform.
112 @param[in] ResetType The type of reset to perform.
113 @param[in] ResetStatus The status code for the reset.
114 @param[in] DataSize The size, in bytes, of ResetData.
115 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
116 the data buffer starts with a Null-terminated string, optionally
117 followed by additional binary data. The string is a description
118 that the caller may use to further indicate the reason for the
124 IN EFI_RESET_TYPE ResetType
,
125 IN EFI_STATUS ResetStatus
,
127 IN VOID
*ResetData OPTIONAL
139 case EfiResetShutdown
:
143 case EfiResetPlatformSpecific
:
144 ResetPlatformSpecific (DataSize
, ResetData
);