]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/Library/ResetSystemLib/ResetSystemLib.c
MdeModulePkg/SmmCore: Add Context in SmiHandlerProfileUnregister.
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
3cbfba02
DW
1/** @file\r
2\r
cdd1ae1f 3 Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
3cbfba02
DW
4 This program and the accompanying materials are licensed and made available under\r\r
5 the terms and conditions of the BSD License that accompanies this distribution. \r\r
6 The full text of the license may be found at \r\r
7 http://opensource.org/licenses/bsd-license.php. \r\r
8 \r\r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r
11 \r\r
12\r
13\r
14Module Name:\r
15\r
16 IdeBus.h\r
17\r
18Abstract:\r
19\r
20 System reset Library Services. This library class provides a set of\r
21 methods to reset whole system with manipulate ICH.\r
22\r
23**/\r
24\r
25\r
26#include <Base.h>\r
27\r
28\r
29#include <Library/ResetSystemLib.h>\r
30#include <Library/BaseLib.h>\r
31#include <Library/IoLib.h>\r
32#include <Library/DebugLib.h>\r
33#include <Library/PciLib.h>\r
34\r
35#include "PchRegs.h"\r
36#include "Rsci.h"\r
37#include "Platform.h"\r
38\r
39#define RESET_GENERATOR_PORT R_PCH_RST_CNT\r
40\r
41VOID\r
42EFIAPI\r
43PlatformResetHook (\r
44 UINT8 ResetType\r
45 )\r
46{\r
47 //\r
48 // Platform need to save OS reset request/types for next Android boot\r
49 //\r
50 IoWrite8 (0x72, CMOS_RESET_TYPE_BY_OS);\r
51 IoWrite8 (0x73, ResetType);\r
52}\r
53\r
54/**\r
55 Calling this function causes a system-wide reset. This sets\r
56 all circuitry within the system to its initial state. This type of reset\r
57 is asynchronous to system operation and operates without regard to\r
58 cycle boundaries.\r
59\r
60 System reset should not return, if it returns, it means the system does\r
61 not support cold reset.\r
62**/\r
63VOID\r
64EFIAPI\r
65ResetCold (\r
66 VOID\r
67 )\r
68{\r
69 PlatformResetHook(COLD_RESET);\r
70 IoWrite8 (RESET_GENERATOR_PORT, 0x2);\r
71 IoWrite8 (RESET_GENERATOR_PORT, 0x6);\r
72}\r
73\r
74/**\r
75 Calling this function causes a system-wide initialization. The processors\r
76 are set to their initial state, and pending cycles are not corrupted.\r
77\r
78 System reset should not return, if it returns, it means the system does\r
79 not support warm reset.\r
80**/\r
81VOID\r
82EFIAPI\r
83ResetWarm (\r
84 VOID\r
85 )\r
86{\r
87 PlatformResetHook(WARM_RESET);\r
88 IoWrite8 (RESET_GENERATOR_PORT, 0x0);\r
89 IoWrite8 (RESET_GENERATOR_PORT, 0x4);\r
90}\r
91\r
92/**\r
93 Calling this function causes the system to enter a power state equivalent\r
94 to the ACPI G2/S5 or G3 states.\r
95\r
96 System shutdown should not return, if it returns, it means the system does\r
97 not support shut down reset.\r
98**/\r
99VOID\r
100EFIAPI\r
101ResetShutdown (\r
102 VOID\r
103 )\r
104{\r
105 UINT16 PchPmioBase;\r
106 UINT16 Data16;\r
107 UINT32 Data32;\r
108\r
109 PchPmioBase = (UINT16) (PciRead16 (PCI_LIB_ADDRESS(0, PCI_DEVICE_NUMBER_PCH_LPC, 0, R_PCH_LPC_ACPI_BASE)) & ~BIT0);\r
110\r
111 //\r
112 // Then, GPE0_EN should be disabled to avoid any GPI waking up the system from S5\r
113 //\r
114 Data16 = 0;\r
115 IoWrite16 (\r
116 (UINTN)(PchPmioBase + R_PCH_ACPI_GPE0a_EN),\r
117 (UINT16)Data16\r
118 );\r
119\r
120 //\r
121 // Clear Sleep SMI Status\r
122 //\r
123 IoWrite16 (PchPmioBase + R_PCH_SMI_STS,\r
124 (UINT16)(IoRead16 (PchPmioBase + R_PCH_SMI_STS) | B_PCH_SMI_STS_ON_SLP_EN));\r
125 //\r
126 // Clear Sleep Type Enable\r
127 //\r
128 IoWrite16 (PchPmioBase + R_PCH_SMI_EN,\r
129 (UINT16)(IoRead16 (PchPmioBase + R_PCH_SMI_EN) & (~B_PCH_SMI_EN_ON_SLP_EN)));\r
130 //\r
131 // Clear Power Button Status\r
132 //\r
133 IoWrite16(PchPmioBase + R_PCH_ACPI_PM1_STS, B_PCH_ACPI_PM1_STS_PWRBTN);\r
134\r
135 //\r
136 // Secondly, Power Button Status bit must be cleared\r
137 //\r
138 // Write a "1" to bit[8] of power button status register at\r
139 // (ABASE + PM1_STS) to clear this bit\r
140 // Clear it through SMI Status register\r
141 //\r
142 Data16 = B_PCH_SMI_STS_PM1_STS_REG;\r
143 IoWrite16 ((UINTN) (PchPmioBase + R_PCH_SMI_STS), Data16);\r
144\r
145 //\r
146 // Finally, transform system into S5 sleep state\r
147 //\r
148 Data32 = IoRead32 ((UINTN) (PchPmioBase + R_PCH_ACPI_PM1_CNT));\r
149\r
150 Data32 = (UINT32) ((Data32 &~(B_PCH_ACPI_PM1_CNT_SLP_TYP + B_PCH_ACPI_PM1_CNT_SLP_EN)) | V_PCH_ACPI_PM1_CNT_S5);\r
151\r
152 IoWrite32 ((UINTN) (PchPmioBase + R_PCH_ACPI_PM1_CNT), Data32);\r
153\r
154 Data32 = Data32 | B_PCH_ACPI_PM1_CNT_SLP_EN;\r
155\r
156 IoWrite32 ((UINTN) (PchPmioBase + R_PCH_ACPI_PM1_CNT), Data32);\r
157\r
158 return;\r
159}\r
160\r
161/**\r
162 Calling this function causes the system to enter a power state for capsule\r
163 update.\r
164\r
165 Reset update should not return, if it returns, it means the system does\r
166 not support capsule update.\r
167\r
168**/\r
169VOID\r
170EFIAPI\r
171EnterS3WithImmediateWake (\r
172 VOID\r
173 )\r
174{\r
175 ASSERT (FALSE);\r
176}\r
177\r
cdd1ae1f
RN
178/**\r
179 This function causes a systemwide reset. The exact type of the reset is\r
180 defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r
181 into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r
182 the platform must pick a supported reset type to perform.The platform may\r
183 optionally log the parameters from any non-normal reset that occurs.\r
184\r
185 @param[in] DataSize The size, in bytes, of ResetData.\r
186 @param[in] ResetData The data buffer starts with a Null-terminated string,\r
187 followed by the EFI_GUID.\r
188**/\r
189VOID\r
190EFIAPI\r
191ResetPlatformSpecific (\r
192 IN UINTN DataSize,\r
193 IN VOID *ResetData\r
194 )\r
195{\r
196 ResetCold ();\r
197}\r