2 This module provides an implementation of the SMM Control PPI for use with
5 Copyright (c) 2013-2015 Intel Corporation.
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Ppi/SmmControl.h>
21 #include <Library/DebugLib.h>
22 #include <Library/HobLib.h>
23 #include <Library/PeiServicesLib.h>
24 #include <Library/PcdLib.h>
25 #include <Library/IoLib.h>
26 #include <Library/PciLib.h>
28 #include <IntelQNCPeim.h>
29 #include <Library/QNCAccessLib.h>
30 #include <Uefi/UefiBaseType.h>
33 Generates an SMI using the parameters passed in.
35 @param PeiServices Describes the list of possible PEI Services.
36 @param This A pointer to an instance of
38 @param ArgumentBuffer The argument buffer
39 @param ArgumentBufferSize The size of the argument buffer
40 @param Periodic TRUE to indicate a periodical SMI
41 @param ActivationInterval Interval of the periodical SMI
43 @retval EFI_INVALID_PARAMETER Periodic is TRUE or ArgumentBufferSize > 1
44 @retval EFI_SUCCESS SMI generated
50 IN EFI_PEI_SERVICES
**PeiServices
,
51 IN PEI_SMM_CONTROL_PPI
*This
,
52 IN OUT INT8
*ArgumentBuffer OPTIONAL
,
53 IN OUT UINTN
*ArgumentBufferSize OPTIONAL
,
54 IN BOOLEAN Periodic OPTIONAL
,
55 IN UINTN ActivationInterval OPTIONAL
61 @param PeiServices Describes the list of possible PEI Services.
62 @param This Pointer to an instance of EFI_SMM_CONTROL_PPI
63 @param Periodic TRUE to indicate a periodical SMI
65 @return Return value from SmmClear()
71 IN EFI_PEI_SERVICES
**PeiServices
,
72 IN PEI_SMM_CONTROL_PPI
*This
,
73 IN BOOLEAN Periodic OPTIONAL
76 PEI_SMM_CONTROL_PPI mSmmControlPpi
= {
81 EFI_PEI_PPI_DESCRIPTOR mPpiList
= {
82 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
83 &gPeiSmmControlPpiGuid
,
88 Clear SMI related chipset status and re-enable SMI by setting the EOS bit.
90 @retval EFI_SUCCESS The requested operation has been carried out successfully
91 @retval EFI_DEVICE_ERROR The EOS bit could not be set.
103 // Get PM1BLK_Base & GPE0BLK_Base
105 PM1BLK_Base
= PcdGet16 (PcdPm1blkIoBaseAddress
);
106 GPE0BLK_Base
= PcdGet16 (PcdGpe0blkIoBaseAddress
);
109 // Clear the Power Button Override Status Bit, it gates EOS from being set.
110 // In QuarkNcSocId - Bit is read only. Handled by external SMC, do nothing.
114 // Clear the APM SMI Status Bit
116 IoWrite32 ((GPE0BLK_Base
+ R_QNC_GPE0BLK_SMIS
), B_QNC_GPE0BLK_SMIS_APM
);
121 IoOr32 ((GPE0BLK_Base
+ R_QNC_GPE0BLK_SMIS
), B_QNC_GPE0BLK_SMIS_EOS
);
136 Trigger the software SMI
140 Data The value to be set on the software SMI data port
144 EFI_SUCCESS Function completes successfully
154 GPE0BLK_Base
= PcdGet16 (PcdGpe0blkIoBaseAddress
);
157 // Enable the APMC SMI
159 IoOr32 (GPE0BLK_Base
+ R_QNC_GPE0BLK_SMIE
, B_QNC_GPE0BLK_SMIE_APM
);
162 // Enable SMI globally
164 NewValue
= QNCPortRead (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
);
166 QNCPortWrite (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
, NewValue
);
170 // Generate the APMC SMI
172 IoWrite8 (PcdGet16 (PcdSmmActivationPort
), Data
);
178 Generates an SMI using the parameters passed in.
180 @param PeiServices Describes the list of possible PEI Services.
181 @param This A pointer to an instance of
183 @param ArgumentBuffer The argument buffer
184 @param ArgumentBufferSize The size of the argument buffer
185 @param Periodic TRUE to indicate a periodical SMI
186 @param ActivationInterval Interval of the periodical SMI
188 @retval EFI_INVALID_PARAMETER Periodic is TRUE or ArgumentBufferSize > 1
189 @retval EFI_SUCCESS SMI generated
195 IN EFI_PEI_SERVICES
**PeiServices
,
196 IN PEI_SMM_CONTROL_PPI
*This
,
197 IN OUT INT8
*ArgumentBuffer OPTIONAL
,
198 IN OUT UINTN
*ArgumentBufferSize OPTIONAL
,
199 IN BOOLEAN Periodic OPTIONAL
,
200 IN UINTN ActivationInterval OPTIONAL
206 // Periodic SMI not supported.
209 DEBUG ((DEBUG_WARN
, "Invalid parameter\n"));
210 return EFI_INVALID_PARAMETER
;
213 if (ArgumentBuffer
== NULL
) {
216 if (ArgumentBufferSize
== NULL
|| *ArgumentBufferSize
!= 1) {
217 return EFI_INVALID_PARAMETER
;
220 Data
= *ArgumentBuffer
;
223 // Clear any pending the APM SMI
225 Status
= SmmClear ();
226 if (EFI_ERROR (Status
)) {
230 return SmmTrigger (Data
);
236 @param PeiServices Describes the list of possible PEI Services.
237 @param This Pointer to an instance of EFI_SMM_CONTROL_PPI
238 @param Periodic TRUE to indicate a periodical SMI
240 @return Return value from SmmClear()
246 IN EFI_PEI_SERVICES
**PeiServices
,
247 IN PEI_SMM_CONTROL_PPI
*This
,
248 IN BOOLEAN Periodic OPTIONAL
252 return EFI_INVALID_PARAMETER
;
258 This is the constructor for the SMM Control Ppi.
260 This function installs EFI_SMM_CONTROL_PPI.
262 @param FileHandle Handle of the file being invoked.
263 @param PeiServices Describes the list of possible PEI Services.
265 @retval EFI_UNSUPPORTED There's no Intel ICH on this platform
266 @return The status returned from InstallPpi().
272 IN EFI_PEI_FILE_HANDLE FileHandle
,
273 IN CONST EFI_PEI_SERVICES
**PeiServices
278 Status
= (**PeiServices
).InstallPpi (PeiServices
, &mPpiList
);
279 ASSERT_EFI_ERROR (Status
);