]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.c
ArmPkg: Change use of EFI_D_* to DEBUG_*
[mirror_edk2.git] / ArmPkg / Library / ArmPsciResetSystemLib / ArmPsciResetSystemLib.c
CommitLineData
ca3026d3
AB
1/** @file\r
2 Support ResetSystem Runtime call using PSCI calls\r
3\r
9180ab73 4 Note: A similar library is implemented in\r
7fbd1eb2 5 ArmVirtPkg/Library/ArmVirtualizationPsciResetSystemLib\r
9180ab73
OM
6 So similar issues might exist in this implementation too.\r
7\r
ca3026d3 8 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
7fbd1eb2 9 Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR>\r
ca3026d3
AB
10 Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
11\r
4059386c 12 SPDX-License-Identifier: BSD-2-Clause-Patent\r
ca3026d3
AB
13\r
14**/\r
15\r
16#include <PiDxe.h>\r
17\r
18#include <Library/BaseLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/EfiResetSystemLib.h>\r
21#include <Library/ArmSmcLib.h>\r
ca3026d3
AB
22\r
23#include <IndustryStandard/ArmStdSmc.h>\r
24\r
25/**\r
26 Resets the entire platform.\r
27\r
28 @param ResetType The type of reset to perform.\r
29 @param ResetStatus The status code for the reset.\r
30 @param DataSize The size, in bytes, of WatchdogData.\r
31 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r
32 EfiResetShutdown the data buffer starts with a Null-terminated\r
33 Unicode string, optionally followed by additional binary data.\r
34\r
35**/\r
36EFI_STATUS\r
37EFIAPI\r
38LibResetSystem (\r
39 IN EFI_RESET_TYPE ResetType,\r
40 IN EFI_STATUS ResetStatus,\r
41 IN UINTN DataSize,\r
42 IN CHAR16 *ResetData OPTIONAL\r
43 )\r
44{\r
45 ARM_SMC_ARGS ArmSmcArgs;\r
ca3026d3
AB
46\r
47 switch (ResetType) {\r
ca3026d3
AB
48 case EfiResetPlatformSpecific:\r
49 // Map the platform specific reset as reboot\r
50 case EfiResetWarm:\r
51 // Map a warm reset into a cold reset\r
52 case EfiResetCold:\r
53 // Send a PSCI 0.2 SYSTEM_RESET command\r
54 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;\r
ca3026d3
AB
55 break;\r
56 case EfiResetShutdown:\r
57 // Send a PSCI 0.2 SYSTEM_OFF command\r
58 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;\r
ca3026d3
AB
59 break;\r
60 default:\r
61 ASSERT (FALSE);\r
62 return EFI_UNSUPPORTED;\r
63 }\r
64\r
9180ab73 65 ArmCallSmc (&ArmSmcArgs);\r
ca3026d3
AB
66\r
67 // We should never be here\r
a4a582e1 68 DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));\r
ca3026d3
AB
69 CpuDeadLoop ();\r
70 return EFI_UNSUPPORTED;\r
71}\r
72\r
73/**\r
74 Initialize any infrastructure required for LibResetSystem () to function.\r
75\r
76 @param ImageHandle The firmware allocated handle for the EFI image.\r
77 @param SystemTable A pointer to the EFI System Table.\r
78\r
79 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
80\r
81**/\r
82EFI_STATUS\r
83EFIAPI\r
84LibInitializeResetSystem (\r
85 IN EFI_HANDLE ImageHandle,\r
86 IN EFI_SYSTEM_TABLE *SystemTable\r
87 )\r
88{\r
89 return EFI_SUCCESS;\r
90}\r