]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
ArmPkg: Apply uncrustify changes
[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 ARM_SMC_ARGS ArmSmcArgs;
35
36 // Send a PSCI 0.2 SYSTEM_RESET command
37 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
38 ArmCallSmc (&ArmSmcArgs);
39 }
40
41 /**
42 This function causes a system-wide initialization (warm reset), in which all processors
43 are set to their initial state. Pending cycles are not corrupted.
44
45 If this function returns, it means that the system does not support warm reset.
46 **/
47 VOID
48 EFIAPI
49 ResetWarm (
50 VOID
51 )
52 {
53 // Map a warm reset into a cold reset
54 ResetCold ();
55 }
56
57 /**
58 This function causes the system to enter a power state equivalent
59 to the ACPI G2/S5 or G3 states.
60
61 If this function returns, it means that the system does not support shutdown reset.
62 **/
63 VOID
64 EFIAPI
65 ResetShutdown (
66 VOID
67 )
68 {
69 ARM_SMC_ARGS ArmSmcArgs;
70
71 // Send a PSCI 0.2 SYSTEM_OFF command
72 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
73 ArmCallSmc (&ArmSmcArgs);
74 }
75
76 /**
77 This function causes a systemwide reset. The exact type of the reset is
78 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
79 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
80 the platform must pick a supported reset type to perform.The platform may
81 optionally log the parameters from any non-normal reset that occurs.
82
83 @param[in] DataSize The size, in bytes, of ResetData.
84 @param[in] ResetData The data buffer starts with a Null-terminated string,
85 followed by the EFI_GUID.
86 **/
87 VOID
88 EFIAPI
89 ResetPlatformSpecific (
90 IN UINTN DataSize,
91 IN VOID *ResetData
92 )
93 {
94 // Map the platform specific reset as reboot
95 ResetCold ();
96 }
97
98 /**
99 The ResetSystem function resets the entire platform.
100
101 @param[in] ResetType The type of reset to perform.
102 @param[in] ResetStatus The status code for the reset.
103 @param[in] DataSize The size, in bytes, of ResetData.
104 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
105 the data buffer starts with a Null-terminated string, optionally
106 followed by additional binary data. The string is a description
107 that the caller may use to further indicate the reason for the
108 system reset.
109 **/
110 VOID
111 EFIAPI
112 ResetSystem (
113 IN EFI_RESET_TYPE ResetType,
114 IN EFI_STATUS ResetStatus,
115 IN UINTN DataSize,
116 IN VOID *ResetData OPTIONAL
117 )
118 {
119 switch (ResetType) {
120 case EfiResetWarm:
121 ResetWarm ();
122 break;
123
124 case EfiResetCold:
125 ResetCold ();
126 break;
127
128 case EfiResetShutdown:
129 ResetShutdown ();
130 return;
131
132 case EfiResetPlatformSpecific:
133 ResetPlatformSpecific (DataSize, ResetData);
134 return;
135
136 default:
137 return;
138 }
139 }