]>
Commit | Line | Data |
---|---|---|
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 | |
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 | |
ca3026d3 AB |
28 | \r |
29 | #include <IndustryStandard/ArmStdSmc.h>\r | |
30 | \r | |
31 | /**\r | |
32 | Resets the entire platform.\r | |
33 | \r | |
34 | @param ResetType The type of reset to perform.\r | |
35 | @param ResetStatus The status code for the reset.\r | |
36 | @param DataSize The size, in bytes, of WatchdogData.\r | |
37 | @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r | |
38 | EfiResetShutdown the data buffer starts with a Null-terminated\r | |
39 | Unicode string, optionally followed by additional binary data.\r | |
40 | \r | |
41 | **/\r | |
42 | EFI_STATUS\r | |
43 | EFIAPI\r | |
44 | LibResetSystem (\r | |
45 | IN EFI_RESET_TYPE ResetType,\r | |
46 | IN EFI_STATUS ResetStatus,\r | |
47 | IN UINTN DataSize,\r | |
48 | IN CHAR16 *ResetData OPTIONAL\r | |
49 | )\r | |
50 | {\r | |
51 | ARM_SMC_ARGS ArmSmcArgs;\r | |
ca3026d3 AB |
52 | \r |
53 | switch (ResetType) {\r | |
ca3026d3 AB |
54 | case EfiResetPlatformSpecific:\r |
55 | // Map the platform specific reset as reboot\r | |
56 | case EfiResetWarm:\r | |
57 | // Map a warm reset into a cold reset\r | |
58 | case EfiResetCold:\r | |
59 | // Send a PSCI 0.2 SYSTEM_RESET command\r | |
60 | ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;\r | |
ca3026d3 AB |
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 | |
ca3026d3 AB |
65 | break;\r |
66 | default:\r | |
67 | ASSERT (FALSE);\r | |
68 | return EFI_UNSUPPORTED;\r | |
69 | }\r | |
70 | \r | |
9180ab73 | 71 | ArmCallSmc (&ArmSmcArgs);\r |
ca3026d3 AB |
72 | \r |
73 | // We should never be here\r | |
74 | DEBUG ((EFI_D_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));\r | |
75 | CpuDeadLoop ();\r | |
76 | return EFI_UNSUPPORTED;\r | |
77 | }\r | |
78 | \r | |
79 | /**\r | |
80 | Initialize any infrastructure required for LibResetSystem () to function.\r | |
81 | \r | |
82 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
83 | @param SystemTable A pointer to the EFI System Table.\r | |
84 | \r | |
85 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
86 | \r | |
87 | **/\r | |
88 | EFI_STATUS\r | |
89 | EFIAPI\r | |
90 | LibInitializeResetSystem (\r | |
91 | IN EFI_HANDLE ImageHandle,\r | |
92 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
93 | )\r | |
94 | {\r | |
95 | return EFI_SUCCESS;\r | |
96 | }\r |