]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
2ef2b01e
A
13#include <PiDxe.h>\r
14\r
15#include <Library/BaseLib.h>\r
16#include <Library/IoLib.h>\r
17#include <Library/EfiResetSystemLib.h>\r
18\r
2ef2b01e
A
19/**\r
20 Resets the entire platform.\r
21\r
22 @param ResetType The type of reset to perform.\r
23 @param ResetStatus The status code for the reset.\r
24 @param DataSize The size, in bytes, of WatchdogData.\r
25 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r
26 EfiResetShutdown the data buffer starts with a Null-terminated\r
27 Unicode string, optionally followed by additional binary data.\r
28\r
29**/\r
30EFI_STATUS\r
31EFIAPI\r
32LibResetSystem (\r
e7108d0e
MK
33 IN EFI_RESET_TYPE ResetType,\r
34 IN EFI_STATUS ResetStatus,\r
35 IN UINTN DataSize,\r
36 IN CHAR16 *ResetData OPTIONAL\r
2ef2b01e
A
37 )\r
38{\r
e7108d0e
MK
39 UINTN Address;\r
40 UINT8 Data;\r
3402aac7 41\r
2ef2b01e 42 switch (ResetType) {\r
e7108d0e
MK
43 case EfiResetCold:\r
44 // system power cycle\r
3402aac7 45\r
e7108d0e
MK
46 // Example using IoLib functions to do IO.\r
47 Address = 0x12345678;\r
48 Data = MmioRead8 (Address);\r
49 MmioWrite8 (Address, Data | 0x01);\r
3402aac7 50\r
e7108d0e
MK
51 // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing\r
52 break;\r
3402aac7 53\r
e7108d0e
MK
54 case EfiResetWarm:\r
55 // not a full power cycle, maybe memory stays around.\r
56 // if not support do the same thing as EfiResetCold.\r
57 break;\r
3402aac7 58\r
e7108d0e
MK
59 case EfiResetShutdown:\r
60 // turn off the system.\r
61 // if not support do the same thing as EfiResetCold.\r
62 break;\r
3402aac7 63\r
e7108d0e
MK
64 default:\r
65 return EFI_INVALID_PARAMETER;\r
2ef2b01e
A
66 }\r
67\r
68 //\r
69 // If we reset, we would not have returned...\r
70 //\r
71 return EFI_DEVICE_ERROR;\r
72}\r
3402aac7 73\r
2ef2b01e
A
74/**\r
75 Initialize any infrastructure required for LibResetSystem () to function.\r
76\r
77 @param ImageHandle The firmware allocated handle for the EFI image.\r
78 @param SystemTable A pointer to the EFI System Table.\r
3402aac7 79\r
2ef2b01e
A
80 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
81\r
82**/\r
83EFI_STATUS\r
84EFIAPI\r
85LibInitializeResetSystem (\r
86 IN EFI_HANDLE ImageHandle,\r
87 IN EFI_SYSTEM_TABLE *SystemTable\r
88 )\r
89{\r
90 return EFI_SUCCESS;\r
91}\r