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