• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7   Copyright (c) 2008 - 2009, Apple Inc. 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 
20 #include <PiDxe.h>
21 
22 #include <Library/PcdLib.h>
23 #include <Library/ArmLib.h>
24 #include <Library/CacheMaintenanceLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/EfiResetSystemLib.h>
27 
28 
29 /**
30   Resets the entire platform.
31 
32   @param  ResetType             The type of reset to perform.
33   @param  ResetStatus           The status code for the reset.
34   @param  DataSize              The size, in bytes, of WatchdogData.
35   @param  ResetData             For a ResetType of EfiResetCold, EfiResetWarm, or
36                                 EfiResetShutdown the data buffer starts with a Null-terminated
37                                 Unicode string, optionally followed by additional binary data.
38 
39 **/
40 EFI_STATUS
41 EFIAPI
LibResetSystem(IN EFI_RESET_TYPE ResetType,IN EFI_STATUS ResetStatus,IN UINTN DataSize,IN CHAR16 * ResetData OPTIONAL)42 LibResetSystem (
43   IN EFI_RESET_TYPE   ResetType,
44   IN EFI_STATUS       ResetStatus,
45   IN UINTN            DataSize,
46   IN CHAR16           *ResetData OPTIONAL
47   )
48 {
49   if (ResetData != NULL) {
50     DEBUG((EFI_D_ERROR, "%s", ResetData));
51   }
52 
53   switch (ResetType) {
54   case EfiResetWarm:
55     // Map a warm reset into a cold reset
56   case EfiResetCold:
57   case EfiResetShutdown:
58   default:
59     // Perform cold reset of the system.
60     MmioOr32 (PRM_RSTCTRL, RST_DPLL3);
61     while ((MmioRead32 (PRM_RSTST) & GLOBAL_COLD_RST) != 0x1);
62     break;
63   }
64 
65   // If the reset didn't work, return an error.
66   ASSERT (FALSE);
67   return EFI_DEVICE_ERROR;
68 }
69 
70 
71 
72 /**
73   Initialize any infrastructure required for LibResetSystem () to function.
74 
75   @param  ImageHandle   The firmware allocated handle for the EFI image.
76   @param  SystemTable   A pointer to the EFI System Table.
77 
78   @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
79 
80 **/
81 EFI_STATUS
82 EFIAPI
LibInitializeResetSystem(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)83 LibInitializeResetSystem (
84   IN EFI_HANDLE        ImageHandle,
85   IN EFI_SYSTEM_TABLE  *SystemTable
86   )
87 {
88   return EFI_SUCCESS;
89 }
90 
91