Changeset 108794 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.c
- Timestamp:
- Mar 31, 2025 11:31:09 AM (2 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168237
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-164365 /vendor/edk2/current 103735-103757,103769-103776,129194-168232
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.c
r101291 r108794 2 2 Support ResetSystem Runtime call using PSCI calls 3 3 4 Note: A similar library is implemented in5 ArmVirtPkg/Library/ArmVirtualizationPsciResetSystemLib6 So similar issues might exist in this implementation too.7 8 4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> 9 Copyright (c) 2013 -2015, ARM Ltd. All rights reserved.<BR>5 Copyright (c) 2013, ARM Ltd. All rights reserved.<BR> 10 6 Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR> 7 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 8 Copyright (c) 2024, Google Llc. All rights reserved.<BR> 11 9 12 10 SPDX-License-Identifier: BSD-2-Clause-Patent … … 16 14 #include <PiDxe.h> 17 15 16 #include <IndustryStandard/ArmStdSmc.h> 17 18 #include <Library/ArmMonitorLib.h> 18 19 #include <Library/BaseLib.h> 19 20 #include <Library/DebugLib.h> 20 #include <Library/EfiResetSystemLib.h> 21 #include <Library/ArmSmcLib.h> 22 23 #include <IndustryStandard/ArmStdSmc.h> 21 #include <Library/ResetSystemLib.h> 22 #include <Library/UefiBootServicesTableLib.h> 24 23 25 24 /** 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 25 Library constructor. This function does nothing, but this library may depend 26 on other libraries that do have a non-trivial constructor, which the 27 BaseToools fail to account for if a library has no constructor at all. 28 **/ 29 RETURN_STATUS 37 30 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", __func__)); 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 31 ArmPsciResetSystemLibConstructor ( 32 VOID 87 33 ) 88 34 { 89 35 return EFI_SUCCESS; 90 36 } 37 38 /** 39 This function causes a system-wide reset (cold reset), in which 40 all circuitry within the system returns to its initial state. This type of reset 41 is asynchronous to system operation and operates without regard to 42 cycle boundaries. 43 44 If this function returns, it means that the system does not support cold reset. 45 **/ 46 VOID 47 EFIAPI 48 ResetCold ( 49 VOID 50 ) 51 { 52 ARM_MONITOR_ARGS Args; 53 54 // Send a PSCI 0.2 SYSTEM_RESET command 55 Args.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET; 56 57 ArmMonitorCall (&Args); 58 } 59 60 /** 61 This function causes a system-wide initialization (warm reset), in which all processors 62 are set to their initial state. Pending cycles are not corrupted. 63 64 If this function returns, it means that the system does not support warm reset. 65 **/ 66 VOID 67 EFIAPI 68 ResetWarm ( 69 VOID 70 ) 71 { 72 ARM_MONITOR_ARGS Args; 73 74 Args.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET2_AARCH64; 75 76 // Is SYSTEM_RESET2 supported? 77 ArmMonitorCall (&Args); 78 if (Args.Arg0 == ARM_SMC_PSCI_RET_SUCCESS) { 79 // Send PSCI SYSTEM_RESET2 command 80 Args.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET2_AARCH64; 81 82 ArmMonitorCall (&Args); 83 } else { 84 // Map a warm reset into a cold reset 85 DEBUG (( 86 DEBUG_INFO, 87 "Warm reboot not supported by platform, issuing cold reboot\n" 88 )); 89 ResetCold (); 90 } 91 } 92 93 /** 94 This function causes the system to enter a power state equivalent 95 to the ACPI G2/S5 or G3 states. 96 97 If this function returns, it means that the system does not support shutdown reset. 98 **/ 99 VOID 100 EFIAPI 101 ResetShutdown ( 102 VOID 103 ) 104 { 105 ARM_MONITOR_ARGS Args; 106 107 // Send a PSCI 0.2 SYSTEM_RESET command 108 Args.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF; 109 110 ArmMonitorCall (&Args); 111 } 112 113 /** 114 This function causes a systemwide reset. The exact type of the reset is 115 defined by the EFI_GUID that follows the Null-terminated Unicode string passed 116 into ResetData. If the platform does not recognize the EFI_GUID in ResetData 117 the platform must pick a supported reset type to perform.The platform may 118 optionally log the parameters from any non-normal reset that occurs. 119 120 @param[in] DataSize The size, in bytes, of ResetData. 121 @param[in] ResetData The data buffer starts with a Null-terminated string, 122 followed by the EFI_GUID. 123 **/ 124 VOID 125 EFIAPI 126 ResetPlatformSpecific ( 127 IN UINTN DataSize, 128 IN VOID *ResetData 129 ) 130 { 131 // Map the platform specific reset as reboot 132 ResetCold (); 133 } 134 135 /** 136 The ResetSystem function resets the entire platform. 137 138 @param[in] ResetType The type of reset to perform. 139 @param[in] ResetStatus The status code for the reset. 140 @param[in] DataSize The size, in bytes, of ResetData. 141 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown 142 the data buffer starts with a Null-terminated string, optionally 143 followed by additional binary data. The string is a description 144 that the caller may use to further indicate the reason for the 145 system reset. 146 **/ 147 VOID 148 EFIAPI 149 ResetSystem ( 150 IN EFI_RESET_TYPE ResetType, 151 IN EFI_STATUS ResetStatus, 152 IN UINTN DataSize, 153 IN VOID *ResetData OPTIONAL 154 ) 155 { 156 switch (ResetType) { 157 case EfiResetWarm: 158 ResetWarm (); 159 break; 160 161 case EfiResetCold: 162 ResetCold (); 163 break; 164 165 case EfiResetShutdown: 166 ResetShutdown (); 167 return; 168 169 case EfiResetPlatformSpecific: 170 ResetPlatformSpecific (DataSize, ResetData); 171 return; 172 173 default: 174 return; 175 } 176 }
Note:
See TracChangeset
for help on using the changeset viewer.