]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
EmbeddedPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmbeddedPkg / Library / TemplateResetSystemLib / ResetSystemLib.c
CommitLineData
2ef2b01e
A
1/** @file\r
2 Template library implementation to support ResetSystem Runtime call.\r
3402aac7 3\r
2ef2b01e
A
4 Fill in the templates with what ever makes you system reset.\r
5\r
6\r
60274cca 7 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
3402aac7 8\r
878b807a 9 SPDX-License-Identifier: BSD-2-Clause-Patent\r
2ef2b01e
A
10\r
11**/\r
12\r
13\r
14#include <PiDxe.h>\r
15\r
16#include <Library/BaseLib.h>\r
17#include <Library/IoLib.h>\r
18#include <Library/EfiResetSystemLib.h>\r
19\r
20\r
21/**\r
22 Resets the entire platform.\r
23\r
24 @param ResetType The type of reset to perform.\r
25 @param ResetStatus The status code for the reset.\r
26 @param DataSize The size, in bytes, of WatchdogData.\r
27 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r
28 EfiResetShutdown the data buffer starts with a Null-terminated\r
29 Unicode string, optionally followed by additional binary data.\r
30\r
31**/\r
32EFI_STATUS\r
33EFIAPI\r
34LibResetSystem (\r
35 IN EFI_RESET_TYPE ResetType,\r
36 IN EFI_STATUS ResetStatus,\r
37 IN UINTN DataSize,\r
38 IN CHAR16 *ResetData OPTIONAL\r
39 )\r
40{\r
41 UINTN Address;\r
42 UINT8 Data;\r
3402aac7
RC
43\r
44\r
2ef2b01e
A
45 switch (ResetType) {\r
46 case EfiResetCold:\r
47 // system power cycle\r
3402aac7 48\r
2ef2b01e
A
49 // Example using IoLib functions to do IO.\r
50 Address = 0x12345678;\r
51 Data = MmioRead8 (Address);\r
52 MmioWrite8 (Address, Data | 0x01);\r
3402aac7 53\r
2ef2b01e
A
54 // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing\r
55 break;\r
3402aac7 56\r
2ef2b01e 57 case EfiResetWarm:\r
3402aac7 58 // not a full power cycle, maybe memory stays around.\r
2ef2b01e
A
59 // if not support do the same thing as EfiResetCold.\r
60 break;\r
3402aac7 61\r
2ef2b01e
A
62 case EfiResetShutdown:\r
63 // turn off the system.\r
64 // if not support do the same thing as EfiResetCold.\r
65 break;\r
3402aac7 66\r
2ef2b01e
A
67 default:\r
68 return EFI_INVALID_PARAMETER;\r
69 }\r
70\r
71 //\r
72 // If we reset, we would not have returned...\r
73 //\r
74 return EFI_DEVICE_ERROR;\r
75}\r
3402aac7 76\r
2ef2b01e
A
77\r
78\r
79/**\r
80 Initialize any infrastructure required for LibResetSystem () to function.\r
81\r
82 @param ImageHandle The firmware allocated handle for the EFI image.\r
83 @param SystemTable A pointer to the EFI System Table.\r
3402aac7 84\r
2ef2b01e
A
85 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
86\r
87**/\r
88EFI_STATUS\r
89EFIAPI\r
90LibInitializeResetSystem (\r
91 IN EFI_HANDLE ImageHandle,\r
92 IN EFI_SYSTEM_TABLE *SystemTable\r
93 )\r
94{\r
95 return EFI_SUCCESS;\r
96}\r
97\r