2 Support ResetSystem Runtime call using PSCI calls
4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5 Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
6 Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <Library/BaseLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/EfiResetSystemLib.h>
23 #include <Library/ArmSmcLib.h>
24 #include <Library/ArmHvcLib.h>
26 #include <IndustryStandard/ArmStdSmc.h>
28 STATIC UINT32 mArmPsciMethod
;
32 ArmPsciResetSystemLibConstructor (
36 mArmPsciMethod
= PcdGet32 (PcdArmPsciMethod
);
37 return RETURN_SUCCESS
;
41 Resets the entire platform.
43 @param ResetType The type of reset to perform.
44 @param ResetStatus The status code for the reset.
45 @param DataSize The size, in bytes, of WatchdogData.
46 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
47 EfiResetShutdown the data buffer starts with a Null-terminated
48 Unicode string, optionally followed by additional binary data.
54 IN EFI_RESET_TYPE ResetType
,
55 IN EFI_STATUS ResetStatus
,
57 IN CHAR16
*ResetData OPTIONAL
60 ARM_SMC_ARGS ArmSmcArgs
;
61 ARM_HVC_ARGS ArmHvcArgs
;
65 case EfiResetPlatformSpecific
:
66 // Map the platform specific reset as reboot
68 // Map a warm reset into a cold reset
70 // Send a PSCI 0.2 SYSTEM_RESET command
71 ArmSmcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_RESET
;
72 ArmHvcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_RESET
;
74 case EfiResetShutdown
:
75 // Send a PSCI 0.2 SYSTEM_OFF command
76 ArmSmcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_OFF
;
77 ArmHvcArgs
.Arg0
= ARM_SMC_ID_PSCI_SYSTEM_OFF
;
81 return EFI_UNSUPPORTED
;
84 switch (mArmPsciMethod
) {
86 ArmCallHvc (&ArmHvcArgs
);
90 ArmCallSmc (&ArmSmcArgs
);
94 DEBUG ((EFI_D_ERROR
, "%a: no PSCI method defined\n", __FUNCTION__
));
95 return EFI_UNSUPPORTED
;
98 // We should never be here
99 DEBUG ((EFI_D_ERROR
, "%a: PSCI Reset failed\n", __FUNCTION__
));
101 return EFI_UNSUPPORTED
;
105 Initialize any infrastructure required for LibResetSystem () to function.
107 @param ImageHandle The firmware allocated handle for the EFI image.
108 @param SystemTable A pointer to the EFI System Table.
110 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
115 LibInitializeResetSystem (
116 IN EFI_HANDLE ImageHandle
,
117 IN EFI_SYSTEM_TABLE
*SystemTable