]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
OvmfPkg: remove EnterS3WithImmediateWake () from ResetSystemLib
[mirror_edk2.git] / OvmfPkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
7ca30a6a 1/** @file\r
2 Reset System Library functions for OVMF\r
3\r
84c0b80d 4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
b26f0cf9 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7ca30a6a 6\r
7**/\r
8\r
9#include <Base.h>\r
10\r
11#include <Library/BaseLib.h>\r
12#include <Library/DebugLib.h>\r
13#include <Library/IoLib.h>\r
aaebea27 14#include <Library/PciLib.h>\r
fb2ae5fd 15#include <Library/TimerLib.h>\r
1466b76f 16#include <OvmfPlatforms.h>\r
7ca30a6a 17\r
18VOID\r
19AcpiPmControl (\r
20 UINTN SuspendType\r
21 )\r
22{\r
1466b76f
LE
23 UINT16 AcpiPmBaseAddress;\r
24 UINT16 HostBridgeDevId;\r
25\r
7ca30a6a 26 ASSERT (SuspendType < 6);\r
27\r
1466b76f
LE
28 AcpiPmBaseAddress = 0;\r
29 HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
30 switch (HostBridgeDevId) {\r
31 case INTEL_82441_DEVICE_ID:\r
32 AcpiPmBaseAddress = PIIX4_PMBA_VALUE;\r
33 break;\r
34 case INTEL_Q35_MCH_DEVICE_ID:\r
35 AcpiPmBaseAddress = ICH9_PMBASE_VALUE;\r
36 break;\r
37 default:\r
38 ASSERT (FALSE);\r
39 CpuDeadLoop ();\r
40 }\r
41\r
42 IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType);\r
43 IoOr16 (AcpiPmBaseAddress + 4, BIT13);\r
7ca30a6a 44 CpuDeadLoop ();\r
45}\r
46\r
47/**\r
48 Calling this function causes a system-wide reset. This sets\r
49 all circuitry within the system to its initial state. This type of reset\r
50 is asynchronous to system operation and operates without regard to\r
51 cycle boundaries.\r
52\r
53 System reset should not return, if it returns, it means the system does\r
54 not support cold reset.\r
55**/\r
56VOID\r
57EFIAPI\r
58ResetCold (\r
59 VOID\r
60 )\r
61{\r
cb7b12ee 62 IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST\r
fb2ae5fd 63 MicroSecondDelay (50);\r
64\r
cb7b12ee 65 IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller\r
fb2ae5fd 66 CpuDeadLoop ();\r
7ca30a6a 67}\r
68\r
69/**\r
70 Calling this function causes a system-wide initialization. The processors\r
71 are set to their initial state, and pending cycles are not corrupted.\r
72\r
73 System reset should not return, if it returns, it means the system does\r
74 not support warm reset.\r
75**/\r
76VOID\r
77EFIAPI\r
78ResetWarm (\r
79 VOID\r
80 )\r
81{\r
82 IoWrite8 (0x64, 0xfe);\r
fb2ae5fd 83 CpuDeadLoop ();\r
7ca30a6a 84}\r
85\r
86/**\r
87 Calling this function causes the system to enter a power state equivalent\r
88 to the ACPI G2/S5 or G3 states.\r
89\r
90 System shutdown should not return, if it returns, it means the system does\r
91 not support shut down reset.\r
92**/\r
93VOID\r
94EFIAPI\r
95ResetShutdown (\r
96 VOID\r
97 )\r
98{\r
99 AcpiPmControl (0);\r
100 ASSERT (FALSE);\r
101}\r
102\r
103\r
2b9020f0
RN
104/**\r
105 This function causes a systemwide reset. The exact type of the reset is\r
106 defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r
107 into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r
108 the platform must pick a supported reset type to perform.The platform may\r
109 optionally log the parameters from any non-normal reset that occurs.\r
110\r
111 @param[in] DataSize The size, in bytes, of ResetData.\r
112 @param[in] ResetData The data buffer starts with a Null-terminated string,\r
113 followed by the EFI_GUID.\r
114**/\r
115VOID\r
116EFIAPI\r
117ResetPlatformSpecific (\r
118 IN UINTN DataSize,\r
119 IN VOID *ResetData\r
120 )\r
121{\r
122 ResetCold ();\r
123}\r
84c0b80d
ZG
124\r
125/**\r
126 The ResetSystem function resets the entire platform.\r
127\r
128 @param[in] ResetType The type of reset to perform.\r
129 @param[in] ResetStatus The status code for the reset.\r
130 @param[in] DataSize The size, in bytes, of ResetData.\r
131 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
132 the data buffer starts with a Null-terminated string, optionally\r
133 followed by additional binary data. The string is a description\r
134 that the caller may use to further indicate the reason for the\r
135 system reset.\r
136**/\r
137VOID\r
138EFIAPI\r
139ResetSystem (\r
140 IN EFI_RESET_TYPE ResetType,\r
141 IN EFI_STATUS ResetStatus,\r
142 IN UINTN DataSize,\r
143 IN VOID *ResetData OPTIONAL\r
144 )\r
145{\r
146 switch (ResetType) {\r
147 case EfiResetWarm:\r
148 ResetWarm ();\r
149 break;\r
150\r
151 case EfiResetCold:\r
152 ResetCold ();\r
153 break;\r
154\r
155 case EfiResetShutdown:\r
156 ResetShutdown ();\r
157 return;\r
158\r
159 case EfiResetPlatformSpecific:\r
160 ResetPlatformSpecific (DataSize, ResetData);\r
161 return;\r
162\r
163 default:\r
164 return;\r
165 }\r
166}\r