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