]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
CorebootPayloadPkg/ResetSystemLib: Implement ResetPlatformSpecific
[mirror_edk2.git] / CorebootPayloadPkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
9c228fb0
MM
1/** @file\r
2 Reset System Library functions for coreboot\r
3\r
adb6c39a 4 Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
9c228fb0
MM
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiDxe.h>\r
16#include <Library/BaseLib.h>\r
17#include <Library/DebugLib.h>\r
18#include <Library/IoLib.h>\r
19#include <Library/HobLib.h>\r
20\r
21#include <Guid/AcpiBoardInfoGuid.h>\r
22\r
23VOID\r
24AcpiPmControl (\r
25 UINTN SuspendType\r
26 )\r
27{\r
28 EFI_HOB_GUID_TYPE *GuidHob;\r
29 ACPI_BOARD_INFO *pAcpiBoardInfo; \r
30 UINTN PmCtrlReg = 0;\r
31 \r
32 ASSERT (SuspendType <= 7); \r
33 //\r
34 // Find the acpi board information guid hob\r
35 //\r
36 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
37 ASSERT (GuidHob != NULL);\r
38 pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
39 \r
40 PmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase; \r
41 IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (SuspendType << 10));\r
42 IoOr16 (PmCtrlReg, BIT13);\r
43 CpuDeadLoop ();\r
44}\r
45\r
46/**\r
47 Calling this function causes a system-wide reset. This sets\r
48 all circuitry within the system to its initial state. This type of reset\r
49 is asynchronous to system operation and operates without regard to\r
50 cycle boundaries.\r
51\r
52 System reset should not return, if it returns, it means the system does\r
53 not support cold reset.\r
54**/\r
55VOID\r
56EFIAPI\r
57ResetCold (\r
58 VOID\r
59 )\r
60{\r
61 EFI_HOB_GUID_TYPE *GuidHob;\r
62 ACPI_BOARD_INFO *pAcpiBoardInfo; \r
63 \r
64 //\r
65 // Find the acpi board information guid hob\r
66 //\r
67 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
68 ASSERT (GuidHob != NULL);\r
69 pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
70 \r
71 IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r
72 CpuDeadLoop ();\r
73}\r
74\r
75/**\r
76 Calling this function causes a system-wide initialization. The processors\r
77 are set to their initial state, and pending cycles are not corrupted.\r
78\r
79 System reset should not return, if it returns, it means the system does\r
80 not support warm reset.\r
81**/\r
82VOID\r
83EFIAPI\r
84ResetWarm (\r
85 VOID\r
86 )\r
87{\r
88 EFI_HOB_GUID_TYPE *GuidHob;\r
89 ACPI_BOARD_INFO *pAcpiBoardInfo; \r
90 \r
91 //\r
92 // Find the acpi board information guid hob\r
93 //\r
94 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
95 ASSERT (GuidHob != NULL);\r
96 pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
97 \r
98 IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r
99 CpuDeadLoop ();\r
100}\r
101\r
102/**\r
103 Calling this function causes the system to enter a power state equivalent\r
104 to the ACPI G2/S5 or G3 states.\r
105\r
106 System shutdown should not return, if it returns, it means the system does\r
107 not support shut down reset.\r
108**/\r
109VOID\r
110EFIAPI\r
111ResetShutdown (\r
112 VOID\r
113 )\r
114{\r
24467749
GD
115 EFI_HOB_GUID_TYPE *GuidHob;\r
116 ACPI_BOARD_INFO *pAcpiBoardInfo;\r
117 UINTN PmCtrlReg;\r
118\r
119 //\r
120 // Find the acpi board information guid hob\r
121 //\r
122 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
123 ASSERT (GuidHob != NULL);\r
124 pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
125 \r
126 //\r
127 // GPE0_EN should be disabled to avoid any GPI waking up the system from S5\r
128 //\r
129 IoWrite16 ((UINTN)pAcpiBoardInfo->PmGpeEnBase, 0);\r
130\r
131 //\r
132 // Clear Power Button Status\r
133 //\r
134 IoWrite16((UINTN) pAcpiBoardInfo->PmEvtBase, BIT8);\r
135 \r
136 //\r
137 // Transform system into S5 sleep state\r
138 //\r
139 PmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase; \r
140 IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (7 << 10));\r
141 IoOr16 (PmCtrlReg, BIT13);\r
142 CpuDeadLoop ();\r
143\r
9c228fb0
MM
144 ASSERT (FALSE);\r
145}\r
146\r
9c228fb0
MM
147/**\r
148 Calling this function causes the system to enter a power state for capsule\r
149 update.\r
150\r
151 Reset update should not return, if it returns, it means the system does\r
152 not support capsule update.\r
153\r
154**/\r
155VOID\r
156EFIAPI\r
157EnterS3WithImmediateWake (\r
158 VOID\r
159 )\r
160{\r
161 AcpiPmControl (5);\r
162 ASSERT (FALSE);\r
163}\r
adb6c39a
RN
164\r
165/**\r
166 This function causes a systemwide reset. The exact type of the reset is\r
167 defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r
168 into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r
169 the platform must pick a supported reset type to perform.The platform may\r
170 optionally log the parameters from any non-normal reset that occurs.\r
171\r
172 @param[in] DataSize The size, in bytes, of ResetData.\r
173 @param[in] ResetData The data buffer starts with a Null-terminated string,\r
174 followed by the EFI_GUID.\r
175**/\r
176VOID\r
177EFIAPI\r
178ResetPlatformSpecific (\r
179 IN UINTN DataSize,\r
180 IN VOID *ResetData\r
181 )\r
182{\r
183 ResetCold ();\r
184}\r