2 ResetSystemLib implementation using PSCI calls
4 Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/ArmMmuLib.h>
19 #include <Library/ArmSmcLib.h>
20 #include <Library/BaseLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/ResetSystemLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/UefiRuntimeLib.h>
26 #include <IndustryStandard/ArmStdSmc.h>
29 This function causes a system-wide reset (cold reset), in which
30 all circuitry within the system returns to its initial state. This type of reset
31 is asynchronous to system operation and operates without regard to
34 If this function returns, it means that the system does not support cold reset.
42 ARM_SMC_ARGS ArmSmcArgs
;
44 // Send a PSCI 0.2 SYSTEM_RESET command
45 ArmSmcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_RESET
;
46 ArmCallSmc (&ArmSmcArgs
);
50 This function causes a system-wide initialization (warm reset), in which all processors
51 are set to their initial state. Pending cycles are not corrupted.
53 If this function returns, it means that the system does not support warm reset.
61 // Map a warm reset into a cold reset
66 This function causes the system to enter a power state equivalent
67 to the ACPI G2/S5 or G3 states.
69 If this function returns, it means that the system does not support shutdown reset.
77 ARM_SMC_ARGS ArmSmcArgs
;
79 // Send a PSCI 0.2 SYSTEM_OFF command
80 ArmSmcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_OFF
;
81 ArmCallSmc (&ArmSmcArgs
);
85 This function causes the system to enter S3 and then wake up immediately.
87 If this function returns, it means that the system does not support S3 feature.
91 EnterS3WithImmediateWake (
97 if (FeaturePcdGet (PcdArmReenterPeiForCapsuleWarmReboot
) &&
100 // At boot time, we are the only core running, so we can implement the
101 // immediate wake (which is used by capsule update) by disabling the MMU
102 // and interrupts, and jumping to the PEI entry point.
104 Reset
= (VOID (*)(VOID
))(UINTN
)FixedPcdGet64 (PcdFvBaseAddress
);
106 gBS
->RaiseTPL (TPL_HIGH_LEVEL
);
113 This function causes a systemwide reset. The exact type of the reset is
114 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
115 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
116 the platform must pick a supported reset type to perform.The platform may
117 optionally log the parameters from any non-normal reset that occurs.
119 @param[in] DataSize The size, in bytes, of ResetData.
120 @param[in] ResetData The data buffer starts with a Null-terminated string,
121 followed by the EFI_GUID.
125 ResetPlatformSpecific (
130 // Map the platform specific reset as reboot