2 This module provides an implementation of the SMM Control PPI for use with
5 Copyright (c) 2013-2015 Intel Corporation.
7 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Ppi/SmmControl.h>
15 #include <Library/DebugLib.h>
16 #include <Library/HobLib.h>
17 #include <Library/PeiServicesLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/IoLib.h>
20 #include <Library/PciLib.h>
22 #include <IntelQNCPeim.h>
23 #include <Library/QNCAccessLib.h>
24 #include <Uefi/UefiBaseType.h>
27 Generates an SMI using the parameters passed in.
29 @param PeiServices Describes the list of possible PEI Services.
30 @param This A pointer to an instance of
32 @param ArgumentBuffer The argument buffer
33 @param ArgumentBufferSize The size of the argument buffer
34 @param Periodic TRUE to indicate a periodical SMI
35 @param ActivationInterval Interval of the periodical SMI
37 @retval EFI_INVALID_PARAMETER Periodic is TRUE or ArgumentBufferSize > 1
38 @retval EFI_SUCCESS SMI generated
44 IN EFI_PEI_SERVICES
**PeiServices
,
45 IN PEI_SMM_CONTROL_PPI
*This
,
46 IN OUT INT8
*ArgumentBuffer OPTIONAL
,
47 IN OUT UINTN
*ArgumentBufferSize OPTIONAL
,
48 IN BOOLEAN Periodic OPTIONAL
,
49 IN UINTN ActivationInterval OPTIONAL
55 @param PeiServices Describes the list of possible PEI Services.
56 @param This Pointer to an instance of EFI_SMM_CONTROL_PPI
57 @param Periodic TRUE to indicate a periodical SMI
59 @return Return value from SmmClear()
65 IN EFI_PEI_SERVICES
**PeiServices
,
66 IN PEI_SMM_CONTROL_PPI
*This
,
67 IN BOOLEAN Periodic OPTIONAL
70 PEI_SMM_CONTROL_PPI mSmmControlPpi
= {
75 EFI_PEI_PPI_DESCRIPTOR mPpiList
= {
76 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
77 &gPeiSmmControlPpiGuid
,
82 Clear SMI related chipset status and re-enable SMI by setting the EOS bit.
84 @retval EFI_SUCCESS The requested operation has been carried out successfully
85 @retval EFI_DEVICE_ERROR The EOS bit could not be set.
98 GPE0BLK_Base
= PcdGet16 (PcdGpe0blkIoBaseAddress
);
101 // Clear the Power Button Override Status Bit, it gates EOS from being set.
102 // In QuarkNcSocId - Bit is read only. Handled by external SMC, do nothing.
106 // Clear the APM SMI Status Bit
108 IoWrite32 ((GPE0BLK_Base
+ R_QNC_GPE0BLK_SMIS
), B_QNC_GPE0BLK_SMIS_APM
);
113 IoOr32 ((GPE0BLK_Base
+ R_QNC_GPE0BLK_SMIS
), B_QNC_GPE0BLK_SMIS_EOS
);
128 Trigger the software SMI
132 Data The value to be set on the software SMI data port
136 EFI_SUCCESS Function completes successfully
146 GPE0BLK_Base
= PcdGet16 (PcdGpe0blkIoBaseAddress
);
149 // Enable the APMC SMI
151 IoOr32 (GPE0BLK_Base
+ R_QNC_GPE0BLK_SMIE
, B_QNC_GPE0BLK_SMIE_APM
);
154 // Enable SMI globally
156 NewValue
= QNCPortRead (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
);
158 QNCPortWrite (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
, NewValue
);
162 // Generate the APMC SMI
164 IoWrite8 (PcdGet16 (PcdSmmActivationPort
), Data
);
170 Generates an SMI using the parameters passed in.
172 @param PeiServices Describes the list of possible PEI Services.
173 @param This A pointer to an instance of
175 @param ArgumentBuffer The argument buffer
176 @param ArgumentBufferSize The size of the argument buffer
177 @param Periodic TRUE to indicate a periodical SMI
178 @param ActivationInterval Interval of the periodical SMI
180 @retval EFI_INVALID_PARAMETER Periodic is TRUE or ArgumentBufferSize > 1
181 @retval EFI_SUCCESS SMI generated
187 IN EFI_PEI_SERVICES
**PeiServices
,
188 IN PEI_SMM_CONTROL_PPI
*This
,
189 IN OUT INT8
*ArgumentBuffer OPTIONAL
,
190 IN OUT UINTN
*ArgumentBufferSize OPTIONAL
,
191 IN BOOLEAN Periodic OPTIONAL
,
192 IN UINTN ActivationInterval OPTIONAL
198 // Periodic SMI not supported.
201 DEBUG ((DEBUG_WARN
, "Invalid parameter\n"));
202 return EFI_INVALID_PARAMETER
;
205 if (ArgumentBuffer
== NULL
) {
208 if (ArgumentBufferSize
== NULL
|| *ArgumentBufferSize
!= 1) {
209 return EFI_INVALID_PARAMETER
;
212 Data
= *ArgumentBuffer
;
215 // Clear any pending the APM SMI
217 Status
= SmmClear ();
218 if (EFI_ERROR (Status
)) {
222 return SmmTrigger (Data
);
228 @param PeiServices Describes the list of possible PEI Services.
229 @param This Pointer to an instance of EFI_SMM_CONTROL_PPI
230 @param Periodic TRUE to indicate a periodical SMI
232 @return Return value from SmmClear()
238 IN EFI_PEI_SERVICES
**PeiServices
,
239 IN PEI_SMM_CONTROL_PPI
*This
,
240 IN BOOLEAN Periodic OPTIONAL
244 return EFI_INVALID_PARAMETER
;
250 This is the constructor for the SMM Control Ppi.
252 This function installs EFI_SMM_CONTROL_PPI.
254 @param FileHandle Handle of the file being invoked.
255 @param PeiServices Describes the list of possible PEI Services.
257 @retval EFI_UNSUPPORTED There's no Intel ICH on this platform
258 @return The status returned from InstallPpi().
264 IN EFI_PEI_FILE_HANDLE FileHandle
,
265 IN CONST EFI_PEI_SERVICES
**PeiServices
270 Status
= (**PeiServices
).InstallPpi (PeiServices
, &mPpiList
);
271 ASSERT_EFI_ERROR (Status
);