]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
d6d26bce5009905f368099aa157af43b501cbbb3
[mirror_edk2.git] / ArmPkg / Library / ArmSmcPsciResetSystemLib / ArmSmcPsciResetSystemLib.c
1 /** @file
2 ResetSystemLib implementation using PSCI calls
3
4 Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
5
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
10
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.
13
14 **/
15
16 #include <PiDxe.h>
17
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/ResetSystemLib.h>
21 #include <Library/ArmSmcLib.h>
22
23 #include <IndustryStandard/ArmStdSmc.h>
24
25 /**
26 This function causes a system-wide reset (cold reset), in which
27 all circuitry within the system returns to its initial state. This type of reset
28 is asynchronous to system operation and operates without regard to
29 cycle boundaries.
30
31 If this function returns, it means that the system does not support cold reset.
32 **/
33 VOID
34 EFIAPI
35 ResetCold (
36 VOID
37 )
38 {
39 ARM_SMC_ARGS ArmSmcArgs;
40
41 // Send a PSCI 0.2 SYSTEM_RESET command
42 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
43 ArmCallSmc (&ArmSmcArgs);
44 }
45
46 /**
47 This function causes a system-wide initialization (warm reset), in which all processors
48 are set to their initial state. Pending cycles are not corrupted.
49
50 If this function returns, it means that the system does not support warm reset.
51 **/
52 VOID
53 EFIAPI
54 ResetWarm (
55 VOID
56 )
57 {
58 // Map a warm reset into a cold reset
59 ResetCold ();
60 }
61
62 /**
63 This function causes the system to enter a power state equivalent
64 to the ACPI G2/S5 or G3 states.
65
66 If this function returns, it means that the system does not support shutdown reset.
67 **/
68 VOID
69 EFIAPI
70 ResetShutdown (
71 VOID
72 )
73 {
74 ARM_SMC_ARGS ArmSmcArgs;
75
76 // Send a PSCI 0.2 SYSTEM_OFF command
77 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
78 ArmCallSmc (&ArmSmcArgs);
79 }
80
81 /**
82 This function causes the system to enter S3 and then wake up immediately.
83
84 If this function returns, it means that the system does not support S3 feature.
85 **/
86 VOID
87 EFIAPI
88 EnterS3WithImmediateWake (
89 VOID
90 )
91 {
92 // Not implemented
93 }
94
95 /**
96 This function causes a systemwide reset. The exact type of the reset is
97 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
98 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
99 the platform must pick a supported reset type to perform.The platform may
100 optionally log the parameters from any non-normal reset that occurs.
101
102 @param[in] DataSize The size, in bytes, of ResetData.
103 @param[in] ResetData The data buffer starts with a Null-terminated string,
104 followed by the EFI_GUID.
105 **/
106 VOID
107 EFIAPI
108 ResetPlatformSpecific (
109 IN UINTN DataSize,
110 IN VOID *ResetData
111 )
112 {
113 // Map the platform specific reset as reboot
114 ResetCold ();
115 }