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