]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Library / ArmPsciResetSystemLib / ArmPsciResetSystemLib.c
1 /** @file
2 Support ResetSystem Runtime call using PSCI calls
3
4 Note: A similar library is implemented in
5 ArmVirtPkg/Library/ArmVirtualizationPsciResetSystemLib
6 So similar issues might exist in this implementation too.
7
8 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
9 Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR>
10 Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
11
12 SPDX-License-Identifier: BSD-2-Clause-Patent
13
14 **/
15
16 #include <PiDxe.h>
17
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/EfiResetSystemLib.h>
21 #include <Library/ArmSmcLib.h>
22
23 #include <IndustryStandard/ArmStdSmc.h>
24
25 /**
26 Resets the entire platform.
27
28 @param ResetType The type of reset to perform.
29 @param ResetStatus The status code for the reset.
30 @param DataSize The size, in bytes, of WatchdogData.
31 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
32 EfiResetShutdown the data buffer starts with a Null-terminated
33 Unicode string, optionally followed by additional binary data.
34
35 **/
36 EFI_STATUS
37 EFIAPI
38 LibResetSystem (
39 IN EFI_RESET_TYPE ResetType,
40 IN EFI_STATUS ResetStatus,
41 IN UINTN DataSize,
42 IN CHAR16 *ResetData OPTIONAL
43 )
44 {
45 ARM_SMC_ARGS ArmSmcArgs;
46
47 switch (ResetType) {
48 case EfiResetPlatformSpecific:
49 // Map the platform specific reset as reboot
50 case EfiResetWarm:
51 // Map a warm reset into a cold reset
52 case EfiResetCold:
53 // Send a PSCI 0.2 SYSTEM_RESET command
54 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
55 break;
56 case EfiResetShutdown:
57 // Send a PSCI 0.2 SYSTEM_OFF command
58 ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
59 break;
60 default:
61 ASSERT (FALSE);
62 return EFI_UNSUPPORTED;
63 }
64
65 ArmCallSmc (&ArmSmcArgs);
66
67 // We should never be here
68 DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));
69 CpuDeadLoop ();
70 return EFI_UNSUPPORTED;
71 }
72
73 /**
74 Initialize any infrastructure required for LibResetSystem () to function.
75
76 @param ImageHandle The firmware allocated handle for the EFI image.
77 @param SystemTable A pointer to the EFI System Table.
78
79 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
80
81 **/
82 EFI_STATUS
83 EFIAPI
84 LibInitializeResetSystem (
85 IN EFI_HANDLE ImageHandle,
86 IN EFI_SYSTEM_TABLE *SystemTable
87 )
88 {
89 return EFI_SUCCESS;
90 }