2 Support ResetSystem Runtime call using PSCI calls
4 Note: A similar library is implemented in
5 ArmPkg/Library/ArmPsciResetSystemLib. Similar issues might
6 exist in this implementation too.
8 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
9 Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
10 Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
12 This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #include <Library/BaseLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/EfiResetSystemLib.h>
27 #include <Library/ArmSmcLib.h>
28 #include <Library/ArmHvcLib.h>
30 #include <IndustryStandard/ArmStdSmc.h>
32 STATIC UINT32 mArmPsciMethod
;
36 ArmPsciResetSystemLibConstructor (
40 mArmPsciMethod
= PcdGet32 (PcdArmPsciMethod
);
41 return RETURN_SUCCESS
;
45 Resets the entire platform.
47 @param ResetType The type of reset to perform.
48 @param ResetStatus The status code for the reset.
49 @param DataSize The size, in bytes, of WatchdogData.
50 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
51 EfiResetShutdown the data buffer starts with a Null-terminated
52 Unicode string, optionally followed by additional binary data.
58 IN EFI_RESET_TYPE ResetType
,
59 IN EFI_STATUS ResetStatus
,
61 IN CHAR16
*ResetData OPTIONAL
64 ARM_SMC_ARGS ArmSmcArgs
;
65 ARM_HVC_ARGS ArmHvcArgs
;
69 case EfiResetPlatformSpecific
:
70 // Map the platform specific reset as reboot
72 // Map a warm reset into a cold reset
74 // Send a PSCI 0.2 SYSTEM_RESET command
75 ArmSmcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_RESET
;
76 ArmHvcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_RESET
;
78 case EfiResetShutdown
:
79 // Send a PSCI 0.2 SYSTEM_OFF command
80 ArmSmcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_OFF
;
81 ArmHvcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_OFF
;
85 return EFI_UNSUPPORTED
;
88 switch (mArmPsciMethod
) {
90 ArmCallHvc (&ArmHvcArgs
);
94 ArmCallSmc (&ArmSmcArgs
);
98 DEBUG ((EFI_D_ERROR
, "%a: no PSCI method defined\n", __FUNCTION__
));
99 return EFI_UNSUPPORTED
;
102 // We should never be here
103 DEBUG ((EFI_D_ERROR
, "%a: PSCI Reset failed\n", __FUNCTION__
));
105 return EFI_UNSUPPORTED
;
109 Initialize any infrastructure required for LibResetSystem () to function.
111 @param ImageHandle The firmware allocated handle for the EFI image.
112 @param SystemTable A pointer to the EFI System Table.
114 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
119 LibInitializeResetSystem (
120 IN EFI_HANDLE ImageHandle
,
121 IN EFI_SYSTEM_TABLE
*SystemTable