2 File to contain all the hardware specific stuff for the Smm Sw dispatch protocol.
4 Copyright (c) 2013-2015 Intel Corporation.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 // Include common header file for this module.
20 #include "CommonHeader.h"
22 #include "QNCSmmHelpers.h"
24 EFI_SMM_CPU_PROTOCOL
*mSmmCpu
= NULL
;
26 CONST QNC_SMM_SOURCE_DESC SW_SOURCE_DESC
= {
30 {GPE_ADDR_TYPE
, {R_QNC_GPE0BLK_SMIE
}}, S_QNC_GPE0BLK_SMIE
, N_QNC_GPE0BLK_SMIE_APM
32 NULL_BIT_DESC_INITIALIZER
36 {GPE_ADDR_TYPE
, {R_QNC_GPE0BLK_SMIS
}}, S_QNC_GPE0BLK_SMIS
, N_QNC_GPE0BLK_SMIS_APM
43 IN DATABASE_RECORD
*Record
,
44 OUT QNC_SMM_CONTEXT
*Context
47 Context
->Sw
.SwSmiInputValue
= IoRead8 (R_APM_CNT
);
52 IN QNC_SMM_CONTEXT
*Context1
,
53 IN QNC_SMM_CONTEXT
*Context2
56 return (BOOLEAN
)( Context1
->Sw
.SwSmiInputValue
== Context2
->Sw
.SwSmiInputValue
);
61 IN DATABASE_RECORD
* Record
67 EFI_SMM_SAVE_STATE_IO_INFO IoState
;
70 // Locate SMM CPU protocol to retrieve the CPU save state
72 if (mSmmCpu
== NULL
) {
73 Status
= gSmst
->SmmLocateProtocol (&gEfiSmmCpuProtocolGuid
, NULL
, (VOID
**) &mSmmCpu
);
74 ASSERT_EFI_ERROR (Status
);
78 // Find the CPU which generated the software SMI
81 for (Index
= 0; Index
< gSmst
->NumberOfCpus
; Index
++) {
82 Status
= mSmmCpu
->ReadSaveState (
84 sizeof (EFI_SMM_SAVE_STATE_IO_INFO
),
85 EFI_SMM_SAVE_STATE_REGISTER_IO
,
89 if (!EFI_ERROR (Status
) && (IoState
.IoPort
== R_APM_CNT
)) {
95 Record
->CommBuffer
.Sw
.SwSmiCpuIndex
= CpuIndex
;