]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
EmbeddedPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmbeddedPkg / Library / TemplateResetSystemLib / ResetSystemLib.c
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 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11 **/
12
13
14 #include <PiDxe.h>
15
16 #include <Library/BaseLib.h>
17 #include <Library/IoLib.h>
18 #include <Library/EfiResetSystemLib.h>
19
20
21 /**
22 Resets the entire platform.
23
24 @param ResetType The type of reset to perform.
25 @param ResetStatus The status code for the reset.
26 @param DataSize The size, in bytes, of WatchdogData.
27 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
28 EfiResetShutdown the data buffer starts with a Null-terminated
29 Unicode string, optionally followed by additional binary data.
30
31 **/
32 EFI_STATUS
33 EFIAPI
34 LibResetSystem (
35 IN EFI_RESET_TYPE ResetType,
36 IN EFI_STATUS ResetStatus,
37 IN UINTN DataSize,
38 IN CHAR16 *ResetData OPTIONAL
39 )
40 {
41 UINTN Address;
42 UINT8 Data;
43
44
45 switch (ResetType) {
46 case EfiResetCold:
47 // system power cycle
48
49 // Example using IoLib functions to do IO.
50 Address = 0x12345678;
51 Data = MmioRead8 (Address);
52 MmioWrite8 (Address, Data | 0x01);
53
54 // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing
55 break;
56
57 case EfiResetWarm:
58 // not a full power cycle, maybe memory stays around.
59 // if not support do the same thing as EfiResetCold.
60 break;
61
62 case EfiResetShutdown:
63 // turn off the system.
64 // if not support do the same thing as EfiResetCold.
65 break;
66
67 default:
68 return EFI_INVALID_PARAMETER;
69 }
70
71 //
72 // If we reset, we would not have returned...
73 //
74 return EFI_DEVICE_ERROR;
75 }
76
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 }
97