]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.c
ArmPkg: Introduced ArmPsciResetSystemLib
[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
4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
5 Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>\r
6 Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
7\r
8 This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#include <PiDxe.h>\r
19\r
20#include <Library/BaseLib.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/EfiResetSystemLib.h>\r
23#include <Library/ArmSmcLib.h>\r
24#include <Library/ArmHvcLib.h>\r
25\r
26#include <IndustryStandard/ArmStdSmc.h>\r
27\r
28/**\r
29 Resets the entire platform.\r
30\r
31 @param ResetType The type of reset to perform.\r
32 @param ResetStatus The status code for the reset.\r
33 @param DataSize The size, in bytes, of WatchdogData.\r
34 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r
35 EfiResetShutdown the data buffer starts with a Null-terminated\r
36 Unicode string, optionally followed by additional binary data.\r
37\r
38**/\r
39EFI_STATUS\r
40EFIAPI\r
41LibResetSystem (\r
42 IN EFI_RESET_TYPE ResetType,\r
43 IN EFI_STATUS ResetStatus,\r
44 IN UINTN DataSize,\r
45 IN CHAR16 *ResetData OPTIONAL\r
46 )\r
47{\r
48 ARM_SMC_ARGS ArmSmcArgs;\r
49 ARM_HVC_ARGS ArmHvcArgs;\r
50\r
51 switch (ResetType) {\r
52\r
53 case EfiResetPlatformSpecific:\r
54 // Map the platform specific reset as reboot\r
55 case EfiResetWarm:\r
56 // Map a warm reset into a cold reset\r
57 case EfiResetCold:\r
58 // Send a PSCI 0.2 SYSTEM_RESET command\r
59 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;\r
60 ArmHvcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;\r
61 break;\r
62 case EfiResetShutdown:\r
63 // Send a PSCI 0.2 SYSTEM_OFF command\r
64 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;\r
65 ArmHvcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;\r
66 break;\r
67 default:\r
68 ASSERT (FALSE);\r
69 return EFI_UNSUPPORTED;\r
70 }\r
71\r
72 switch (PcdGet32 (PcdArmPsciMethod)) {\r
73 case 1:\r
74 ArmCallHvc (&ArmHvcArgs);\r
75 break;\r
76\r
77 case 2:\r
78 ArmCallSmc (&ArmSmcArgs);\r
79 break;\r
80\r
81 default:\r
82 DEBUG ((EFI_D_ERROR, "%a: no PSCI method defined\n", __FUNCTION__));\r
83 return EFI_UNSUPPORTED;\r
84 }\r
85\r
86 // We should never be here\r
87 DEBUG ((EFI_D_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));\r
88 CpuDeadLoop ();\r
89 return EFI_UNSUPPORTED;\r
90}\r
91\r
92/**\r
93 Initialize any infrastructure required for LibResetSystem () to function.\r
94\r
95 @param ImageHandle The firmware allocated handle for the EFI image.\r
96 @param SystemTable A pointer to the EFI System Table.\r
97\r
98 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
99\r
100**/\r
101EFI_STATUS\r
102EFIAPI\r
103LibInitializeResetSystem (\r
104 IN EFI_HANDLE ImageHandle,\r
105 IN EFI_SYSTEM_TABLE *SystemTable\r
106 )\r
107{\r
108 return EFI_SUCCESS;\r
109}\r