1 /** @file
2   Template library implementation to support ResetSystem Runtime call.
3 
4   Fill in the templates with what ever makes you system reset.
5 
6   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7   Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
8 
9   This program and the accompanying materials
10   are licensed and made available under the terms and conditions of the BSD License
11   which accompanies this distribution.  The full text of the license may be found at
12   http://opensource.org/licenses/bsd-license.php
13 
14   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 
17 **/
18 
19 #include <PiDxe.h>
20 
21 #include <Library/BaseLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/EfiResetSystemLib.h>
24 #include <Library/ArmPlatformSysConfigLib.h>
25 
26 #include <ArmPlatform.h>
27 
28 /**
29   Resets the entire platform.
30 
31   @param  ResetType             The type of reset to perform.
32   @param  ResetStatus           The status code for the reset.
33   @param  DataSize              The size, in bytes, of WatchdogData.
34   @param  ResetData             For a ResetType of EfiResetCold, EfiResetWarm, or
35                                 EfiResetShutdown the data buffer starts with a Null-terminated
36                                 Unicode string, optionally followed by additional binary data.
37 
38 **/
39 EFI_STATUS
40 EFIAPI
LibResetSystem(IN EFI_RESET_TYPE ResetType,IN EFI_STATUS ResetStatus,IN UINTN DataSize,IN CHAR16 * ResetData OPTIONAL)41 LibResetSystem (
42   IN EFI_RESET_TYPE   ResetType,
43   IN EFI_STATUS       ResetStatus,
44   IN UINTN            DataSize,
45   IN CHAR16           *ResetData OPTIONAL
46   )
47 {
48   switch (ResetType) {
49   case EfiResetPlatformSpecific:
50     // Map the platform specific reset as reboot
51   case EfiResetWarm:
52     // Map a warm reset into a cold reset
53   case EfiResetCold:
54     // Send the REBOOT function to the platform microcontroller
55     ArmPlatformSysConfigSet (SYS_CFG_REBOOT, 0);
56 
57     // We should never be here
58     while(1);
59   case EfiResetShutdown:
60     // Send the SHUTDOWN function to the platform microcontroller
61     ArmPlatformSysConfigSet (SYS_CFG_SHUTDOWN, 0);
62 
63     // We should never be here
64     while(1);
65   }
66 
67   ASSERT(FALSE);
68   return EFI_UNSUPPORTED;
69 }
70 
71 /**
72   Initialize any infrastructure required for LibResetSystem () to function.
73 
74   @param  ImageHandle   The firmware allocated handle for the EFI image.
75   @param  SystemTable   A pointer to the EFI System Table.
76 
77   @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
78 
79 **/
80 EFI_STATUS
81 EFIAPI
LibInitializeResetSystem(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)82 LibInitializeResetSystem (
83   IN EFI_HANDLE        ImageHandle,
84   IN EFI_SYSTEM_TABLE  *SystemTable
85   )
86 {
87   return EFI_SUCCESS;
88 }
89