]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkNorthCluster/Smm/Pei/SmmControlPei/SmmControlPei.c
QuarkSocPkg: SmmControlPei: remove set but unused variables
[mirror_edk2.git] / QuarkSocPkg / QuarkNorthCluster / Smm / Pei / SmmControlPei / SmmControlPei.c
CommitLineData
9b6bbcdb
MK
1/** @file\r
2This module provides an implementation of the SMM Control PPI for use with\r
3the QNC.\r
4\r
5Copyright (c) 2013-2015 Intel Corporation.\r
6\r
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <PiPei.h>\r
18\r
19#include <Ppi/SmmControl.h>\r
20\r
21#include <Library/DebugLib.h>\r
22#include <Library/HobLib.h>\r
23#include <Library/PeiServicesLib.h>\r
24#include <Library/PcdLib.h>\r
25#include <Library/IoLib.h>\r
26#include <Library/PciLib.h>\r
27\r
28#include <IntelQNCPeim.h>\r
29#include <Library/QNCAccessLib.h>\r
30#include <Uefi/UefiBaseType.h>\r
31\r
32/**\r
33 Generates an SMI using the parameters passed in.\r
34\r
35 @param PeiServices Describes the list of possible PEI Services.\r
36 @param This A pointer to an instance of\r
37 EFI_SMM_CONTROL_PPI\r
38 @param ArgumentBuffer The argument buffer\r
39 @param ArgumentBufferSize The size of the argument buffer\r
40 @param Periodic TRUE to indicate a periodical SMI\r
41 @param ActivationInterval Interval of the periodical SMI\r
42\r
43 @retval EFI_INVALID_PARAMETER Periodic is TRUE or ArgumentBufferSize > 1\r
44 @retval EFI_SUCCESS SMI generated\r
45\r
46**/\r
47EFI_STATUS\r
48EFIAPI\r
49PeiActivate (\r
50 IN EFI_PEI_SERVICES **PeiServices,\r
51 IN PEI_SMM_CONTROL_PPI *This,\r
52 IN OUT INT8 *ArgumentBuffer OPTIONAL,\r
53 IN OUT UINTN *ArgumentBufferSize OPTIONAL,\r
54 IN BOOLEAN Periodic OPTIONAL,\r
55 IN UINTN ActivationInterval OPTIONAL\r
56 );\r
57\r
58/**\r
59 Clears an SMI.\r
60\r
61 @param PeiServices Describes the list of possible PEI Services.\r
62 @param This Pointer to an instance of EFI_SMM_CONTROL_PPI\r
63 @param Periodic TRUE to indicate a periodical SMI\r
64\r
65 @return Return value from SmmClear()\r
66\r
67**/\r
68EFI_STATUS\r
69EFIAPI\r
70PeiDeactivate (\r
71 IN EFI_PEI_SERVICES **PeiServices,\r
72 IN PEI_SMM_CONTROL_PPI *This,\r
73 IN BOOLEAN Periodic OPTIONAL\r
74 );\r
75\r
76PEI_SMM_CONTROL_PPI mSmmControlPpi = {\r
77 PeiActivate,\r
78 PeiDeactivate\r
79};\r
80\r
81EFI_PEI_PPI_DESCRIPTOR mPpiList = {\r
82 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
83 &gPeiSmmControlPpiGuid,\r
84 &mSmmControlPpi\r
85};\r
86\r
87/**\r
88 Clear SMI related chipset status and re-enable SMI by setting the EOS bit.\r
89\r
90 @retval EFI_SUCCESS The requested operation has been carried out successfully\r
91 @retval EFI_DEVICE_ERROR The EOS bit could not be set.\r
92\r
93**/\r
94EFI_STATUS\r
95SmmClear (\r
96 VOID\r
97 )\r
98{\r
9b6bbcdb
MK
99 UINT16 GPE0BLK_Base;\r
100\r
101 //\r
0e283ad7 102 // Get GPE0BLK_Base\r
9b6bbcdb 103 //\r
9b6bbcdb
MK
104 GPE0BLK_Base = PcdGet16 (PcdGpe0blkIoBaseAddress);\r
105\r
106 //\r
107 // Clear the Power Button Override Status Bit, it gates EOS from being set.\r
108 // In QuarkNcSocId - Bit is read only. Handled by external SMC, do nothing.\r
109 //\r
110\r
111 //\r
112 // Clear the APM SMI Status Bit\r
113 //\r
114 IoWrite32 ((GPE0BLK_Base + R_QNC_GPE0BLK_SMIS), B_QNC_GPE0BLK_SMIS_APM);\r
115\r
116 //\r
117 // Set the EOS Bit\r
118 //\r
119 IoOr32 ((GPE0BLK_Base + R_QNC_GPE0BLK_SMIS), B_QNC_GPE0BLK_SMIS_EOS);\r
120\r
121 return EFI_SUCCESS;\r
122}\r
123\r
124\r
125EFI_STATUS\r
126EFIAPI\r
127SmmTrigger (\r
128 IN UINT8 Data\r
129 )\r
130/*++\r
131\r
132Routine Description:\r
133\r
134 Trigger the software SMI\r
135\r
136Arguments:\r
137\r
138 Data The value to be set on the software SMI data port\r
139\r
140Returns:\r
141\r
142 EFI_SUCCESS Function completes successfully\r
143\r
144--*/\r
145{\r
146 UINT16 GPE0BLK_Base;\r
147 UINT32 NewValue;\r
148\r
149 //\r
150 // Get GPE0BLK_Base\r
151 //\r
152 GPE0BLK_Base = PcdGet16 (PcdGpe0blkIoBaseAddress);\r
153\r
154 //\r
155 // Enable the APMC SMI\r
156 //\r
157 IoOr32 (GPE0BLK_Base + R_QNC_GPE0BLK_SMIE, B_QNC_GPE0BLK_SMIE_APM);\r
158\r
159 //\r
160 // Enable SMI globally\r
161 //\r
162 NewValue = QNCPortRead (QUARK_NC_HOST_BRIDGE_SB_PORT_ID, QNC_MSG_FSBIC_REG_HMISC);\r
163 NewValue |= SMI_EN;\r
164 QNCPortWrite (QUARK_NC_HOST_BRIDGE_SB_PORT_ID, QNC_MSG_FSBIC_REG_HMISC, NewValue);\r
165\r
166\r
167 //\r
168 // Generate the APMC SMI\r
169 //\r
170 IoWrite8 (PcdGet16 (PcdSmmActivationPort), Data);\r
171\r
172 return EFI_SUCCESS;\r
173}\r
174\r
175/**\r
176 Generates an SMI using the parameters passed in.\r
177\r
178 @param PeiServices Describes the list of possible PEI Services.\r
179 @param This A pointer to an instance of\r
180 EFI_SMM_CONTROL_PPI\r
181 @param ArgumentBuffer The argument buffer\r
182 @param ArgumentBufferSize The size of the argument buffer\r
183 @param Periodic TRUE to indicate a periodical SMI\r
184 @param ActivationInterval Interval of the periodical SMI\r
185\r
186 @retval EFI_INVALID_PARAMETER Periodic is TRUE or ArgumentBufferSize > 1\r
187 @retval EFI_SUCCESS SMI generated\r
188\r
189**/\r
190EFI_STATUS\r
191EFIAPI\r
192PeiActivate (\r
193 IN EFI_PEI_SERVICES **PeiServices,\r
194 IN PEI_SMM_CONTROL_PPI *This,\r
195 IN OUT INT8 *ArgumentBuffer OPTIONAL,\r
196 IN OUT UINTN *ArgumentBufferSize OPTIONAL,\r
197 IN BOOLEAN Periodic OPTIONAL,\r
198 IN UINTN ActivationInterval OPTIONAL\r
199 )\r
200{\r
201 INT8 Data;\r
202 EFI_STATUS Status;\r
203 //\r
204 // Periodic SMI not supported.\r
205 //\r
206 if (Periodic) {\r
207 DEBUG ((DEBUG_WARN, "Invalid parameter\n"));\r
208 return EFI_INVALID_PARAMETER;\r
209 }\r
210\r
211 if (ArgumentBuffer == NULL) {\r
212 Data = 0xFF;\r
213 } else {\r
214 if (ArgumentBufferSize == NULL || *ArgumentBufferSize != 1) {\r
215 return EFI_INVALID_PARAMETER;\r
216 }\r
217\r
218 Data = *ArgumentBuffer;\r
219 }\r
220 //\r
221 // Clear any pending the APM SMI\r
222 //\r
223 Status = SmmClear ();\r
224 if (EFI_ERROR (Status)) {\r
225 return Status;\r
226 }\r
227\r
228 return SmmTrigger (Data);\r
229}\r
230\r
231/**\r
232 Clears an SMI.\r
233\r
234 @param PeiServices Describes the list of possible PEI Services.\r
235 @param This Pointer to an instance of EFI_SMM_CONTROL_PPI\r
236 @param Periodic TRUE to indicate a periodical SMI\r
237\r
238 @return Return value from SmmClear()\r
239\r
240**/\r
241EFI_STATUS\r
242EFIAPI\r
243PeiDeactivate (\r
244 IN EFI_PEI_SERVICES **PeiServices,\r
245 IN PEI_SMM_CONTROL_PPI *This,\r
246 IN BOOLEAN Periodic OPTIONAL\r
247 )\r
248{\r
249 if (Periodic) {\r
250 return EFI_INVALID_PARAMETER;\r
251 }\r
252 return SmmClear ();\r
253}\r
254\r
255/**\r
256 This is the constructor for the SMM Control Ppi.\r
257\r
258 This function installs EFI_SMM_CONTROL_PPI.\r
259\r
260 @param FileHandle Handle of the file being invoked.\r
261 @param PeiServices Describes the list of possible PEI Services.\r
262\r
263 @retval EFI_UNSUPPORTED There's no Intel ICH on this platform\r
264 @return The status returned from InstallPpi().\r
265\r
266--*/\r
267EFI_STATUS\r
268EFIAPI\r
269SmmControlPeiEntry (\r
270 IN EFI_PEI_FILE_HANDLE FileHandle,\r
271 IN CONST EFI_PEI_SERVICES **PeiServices\r
272 )\r
273{\r
274 EFI_STATUS Status;\r
275\r
276 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiList);\r
277 ASSERT_EFI_ERROR (Status);\r
278\r
279 return Status;\r
280}\r