From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.12717.1632611154579587875 for ; Sat, 25 Sep 2021 16:05:54 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: guo.dong@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10118"; a="285311510" X-IronPort-AV: E=Sophos;i="5.85,322,1624345200"; d="scan'208";a="285311510" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2021 16:05:53 -0700 X-IronPort-AV: E=Sophos;i="5.85,322,1624345200"; d="scan'208";a="586418299" Received: from gdong1-mobl1.amr.corp.intel.com ([10.255.67.241]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2021 16:05:52 -0700 From: "Guo Dong" To: devel@edk2.groups.io Cc: ray.ni@intel.com, maurice.ma@intel.com, benjamin.you@intel.com, Guo Dong Subject: [`edk2-devel][PATCH 7/8] UefiPayloadPkg: Add a SMM dispatch module Date: Sat, 25 Sep 2021 16:05:29 -0700 Message-Id: <20210925230530.861-8-guo.dong@intel.com> X-Mailer: git-send-email 2.32.0.windows.2 In-Reply-To: <20210925230530.861-1-guo.dong@intel.com> References: <20210925230530.861-1-guo.dong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Guo Dong PCH SMM module would install SMM SW dispatch2 protocol. And it supports to register SMI handlers based on SMI APM interrupt from the bootloader information gSmmRegisterInfoGuid. It is possible to extend bootloader HOB to pass other information to support more SMI sources. If this module is not required by bootloader for some reason, the bootloader could skip this HOB or build a HOB without EOS info. Signed-off-by: Guo Dong --- .../PchSmiDispatchSmm/PchSmiDispatchSmm.c | 455 ++++++++++++++++++ .../PchSmiDispatchSmm/PchSmiDispatchSmm.h | 39 ++ .../PchSmiDispatchSmm/PchSmiDispatchSmm.inf | 51 ++ 3 files changed, 545 insertions(+) create mode 100644 UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.c create mode 100644 UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.h create mode 100644 UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf diff --git a/UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.c b/UefiPay= loadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.c new file mode 100644 index 0000000000..5e9ae0db7c --- /dev/null +++ b/UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.c @@ -0,0 +1,455 @@ +/** @file=0D + SMM SwDispatch2 Protocol.=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +=0D +=0D +**/=0D +=0D +#include "PchSmiDispatchSmm.h"=0D +=0D +typedef struct {=0D + UINT8 EosBitOffset;=0D + UINT8 ApmBitOffset;=0D + UINT32 SmiEosAddr;=0D + UINT32 SmiApmStsAddr;=0D +} SMM_PCH_REGISTER;=0D +=0D +SMM_PCH_REGISTER mSmiPchReg;=0D +=0D +EFI_SMM_CPU_PROTOCOL *mSmmCpuProtocol;=0D +LIST_ENTRY mSmmSwDispatch2Queue =3D INITIALIZE_LIST_HEAD_VARIA= BLE (mSmmSwDispatch2Queue);=0D +=0D +/**=0D + Find SmmSwDispatch2Context by SwSmiInputValue.=0D +=0D + @param[in] SwSmiInputValue The value to indentify the SmmSwDispatch= 2 context=0D +=0D + @return Pointer to EFI_SMM_SW_DISPATCH2_CONTEXT context=0D +**/=0D +EFI_SMM_SW_DISPATCH2_CONTEXT *=0D +FindContextBySwSmiInputValue (=0D + IN UINTN SwSmiInputValue=0D + )=0D +{=0D + LIST_ENTRY *Node;=0D + EFI_SMM_SW_DISPATCH2_CONTEXT *Dispatch2Context;=0D +=0D + Node =3D mSmmSwDispatch2Queue.ForwardLink;=0D + for (; Node !=3D &mSmmSwDispatch2Queue; Node =3D Node->ForwardLink) {=0D + Dispatch2Context =3D BASE_CR (Node, EFI_SMM_SW_DISPATCH2_CONTEXT, Link= );=0D + if (Dispatch2Context->SwSmiInputValue =3D=3D SwSmiInputValue) {=0D + return Dispatch2Context;=0D + }=0D + }=0D + return NULL;=0D +}=0D +=0D +/**=0D + Find SmmSwDispatch2Context by DispatchHandle.=0D +=0D + @param DispatchHandle The handle to indentify the SmmSwDispatch2 cont= ext=0D +=0D + @return Pointer to EFI_SMM_SW_DISPATCH2_CONTEXT context=0D +**/=0D +EFI_SMM_SW_DISPATCH2_CONTEXT *=0D +FindContextByDispatchHandle (=0D + IN EFI_HANDLE DispatchHandle=0D + )=0D +{=0D + LIST_ENTRY *Node;=0D + EFI_SMM_SW_DISPATCH2_CONTEXT *Dispatch2Context;=0D +=0D + Node =3D mSmmSwDispatch2Queue.ForwardLink;=0D + for (; Node !=3D &mSmmSwDispatch2Queue; Node =3D Node->ForwardLink) {=0D + Dispatch2Context =3D BASE_CR (Node, EFI_SMM_SW_DISPATCH2_CONTEXT, Link= );=0D + if (Dispatch2Context->DispatchHandle =3D=3D DispatchHandle) {=0D + return Dispatch2Context;=0D + }=0D + }=0D + return NULL;=0D +}=0D +=0D +/**=0D + Dispatch registered SMM handlers=0D +=0D + @param DispatchHandle The unique handle assigned to this handler by Sm= iHandlerRegister().=0D + @param RegisterContext Points to an optional handler context which was = specified when the handler was registered.=0D + @param CommBuffer A pointer to a collection of data in memory that= will=0D + be conveyed from a non-SMM environment into an S= MM environment.=0D + @param CommBufferSize The size of the CommBuffer.=0D +=0D + @return Status Code=0D +=0D +**/=0D +EFI_STATUS=0D +SmmSwDispatcher (=0D + IN EFI_HANDLE DispatchHandle,=0D + IN CONST VOID *RegisterContext,=0D + IN OUT VOID *CommBuffer,=0D + IN OUT UINTN *CommBufferSize=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_SMM_SW_CONTEXT SwContext;=0D + UINTN Index;=0D + EFI_SMM_SW_DISPATCH2_CONTEXT *Context;=0D + EFI_SMM_HANDLER_ENTRY_POINT2 DispatchFunction;=0D + EFI_SMM_SW_REGISTER_CONTEXT DispatchContext;=0D + UINTN Size;=0D + EFI_SMM_SAVE_STATE_IO_INFO IoInfo;=0D +=0D + //=0D + // Construct new context=0D + //=0D + SwContext.SwSmiCpuIndex =3D 0;=0D + SwContext.CommandPort =3D IoRead8 (SMM_CONTROL_PORT);=0D + SwContext.DataPort =3D IoRead8 (SMM_DATA_PORT);=0D +=0D + //=0D + // Try to find which CPU trigger SWSMI=0D + //=0D + for (Index =3D 0; Index < gSmst->NumberOfCpus; Index++) {=0D + Status =3D mSmmCpuProtocol->ReadSaveState (=0D + mSmmCpuProtocol,=0D + sizeof(IoInfo),=0D + EFI_SMM_SAVE_STATE_REGISTER_IO,=0D + Index,=0D + &IoInfo=0D + );=0D + if (EFI_ERROR (Status)) {=0D + continue;=0D + }=0D + if (IoInfo.IoPort =3D=3D SMM_CONTROL_PORT) {=0D + //=0D + // Great! Find it.=0D + //=0D + SwContext.SwSmiCpuIndex =3D Index;=0D + DEBUG ((DEBUG_VERBOSE, "CPU index =3D 0x%x/0x%x\n", Index, gSmst->Nu= mberOfCpus));=0D + break;=0D + }=0D + }=0D +=0D + if (SwContext.CommandPort =3D=3D 0) {=0D + DEBUG ((DEBUG_VERBOSE, "NOT SW SMI\n"));=0D + Status =3D EFI_SUCCESS;=0D + goto End;=0D + }=0D +=0D + //=0D + // Search context=0D + //=0D + Context =3D FindContextBySwSmiInputValue (SwContext.CommandPort);=0D + if (Context =3D=3D NULL) {=0D + DEBUG ((DEBUG_INFO, "No handler for SMI value 0x%x\n", SwContext.Comma= ndPort));=0D + Status =3D EFI_SUCCESS;=0D + goto End;=0D + }=0D + DEBUG ((DEBUG_VERBOSE, "Prepare to call handler for 0x%x\n", SwContext.C= ommandPort));=0D +=0D + //=0D + // Dispatch=0D + //=0D + DispatchContext.SwSmiInputValue =3D SwContext.CommandPort;=0D + Size =3D sizeof(SwContext);=0D + DispatchFunction =3D (EFI_SMM_HANDLER_ENTRY_POINT2)Context->DispatchFunc= tion;=0D + Status =3D DispatchFunction (DispatchHandle, &DispatchContext, &SwContex= t, &Size);=0D +=0D +End:=0D + //=0D + // Clear SMI APM status=0D + //=0D + IoOr32 (mSmiPchReg.SmiApmStsAddr, 1 << mSmiPchReg.ApmBitOffset);=0D +=0D +=0D + //=0D + // Set EOS bit=0D + //=0D + IoOr32 (mSmiPchReg.SmiEosAddr, 1 << mSmiPchReg.EosBitOffset);=0D +=0D + return Status;=0D +}=0D +=0D +=0D +/**=0D +Check the SwSmiInputValue is already used=0D +=0D +@param[in] SwSmiInputValue To indentify the SmmSwDispatch2 context=0D +=0D +@retval EFI_SUCCESS SwSmiInputValue could be used.=0D +@retval EFI_INVALID_PARAMETER SwSmiInputValue is already be used.=0D +=0D +**/=0D +EFI_STATUS=0D +SmiInputValueCheck (=0D + IN UINTN SwSmiInputValue=0D + )=0D +{=0D + LIST_ENTRY *Node;=0D + EFI_SMM_SW_DISPATCH2_CONTEXT *Dispatch2Context;=0D +=0D + Node =3D mSmmSwDispatch2Queue.ForwardLink;=0D + for (; Node !=3D &mSmmSwDispatch2Queue; Node =3D Node->ForwardLink) {=0D + Dispatch2Context =3D BASE_CR (Node, EFI_SMM_SW_DISPATCH2_CONTEXT, Link= );=0D + if (Dispatch2Context->SwSmiInputValue =3D=3D SwSmiInputValue) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +/**=0D + Register a child SMI source dispatch function for the specified software= SMI.=0D +=0D + This service registers a function (DispatchFunction) which will be calle= d when the software=0D + SMI source specified by RegContext->SwSmiCpuIndex is detected. On return= , DispatchHandle=0D + contains a unique handle which may be used later to unregister the funct= ion using UnRegister().=0D +=0D + @param[in] This Pointer to the EFI_SMM_SW_DISPATCH2_PROTO= COL instance.=0D + @param[in] DispatchFunction Function to register for handler when the= specified software=0D + SMI is generated.=0D + @param[in, out] RegContext Pointer to the dispatch function's contex= t.=0D + The caller fills this context in before c= alling=0D + the register function to indicate to the = register=0D + function which Software SMI input value t= he=0D + dispatch function should be invoked for.= =0D + @param[out] DispatchHandle Handle generated by the dispatcher to tra= ck the=0D + function instance.=0D +=0D + @retval EFI_SUCCESS The dispatch function has been successful= ly=0D + registered and the SMI source has been en= abled.=0D + @retval EFI_DEVICE_ERROR The SW driver was unable to enable the SM= I source.=0D + @retval EFI_INVALID_PARAMETER RegisterContext is invalid. The SW SMI in= put value=0D + is not within valid range.=0D + @retval EFI_OUT_OF_RESOURCES There is not enough memory (system or SMM= ) to manage this=0D + child.=0D + @retval EFI_OUT_OF_RESOURCES A unique software SMI value could not be = assigned=0D + for this dispatch.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SmmSwDispatch2Register (=0D + IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This,=0D + IN EFI_SMM_HANDLER_ENTRY_POINT2 DispatchFunction,=0D + IN OUT EFI_SMM_SW_REGISTER_CONTEXT *RegContext,=0D + OUT EFI_HANDLE *DispatchHandle=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN Index;=0D + EFI_SMM_SW_DISPATCH2_CONTEXT *Context;=0D +=0D + if (RegContext->SwSmiInputValue =3D=3D (UINTN)-1) {=0D + //=0D + // If SwSmiInputValue is set to (UINTN) -1 then a unique value=0D + // will be assigned and returned in the structure.=0D + //=0D + Status =3D EFI_NOT_FOUND;=0D + for (Index =3D 1; Index < MAXIMUM_SWI_VALUE; Index++) {=0D + Status =3D SmiInputValueCheck (Index);=0D + if (!EFI_ERROR (Status)) {=0D + RegContext->SwSmiInputValue =3D Index;=0D + break;=0D + }=0D + }=0D + if (RegContext->SwSmiInputValue =3D=3D (UINTN)-1) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + }=0D +=0D + if ((RegContext->SwSmiInputValue > MAXIMUM_SWI_VALUE) || (RegContext->Sw= SmiInputValue =3D=3D 0)) {=0D + DEBUG ((DEBUG_ERROR, "ERROR: SMI value range (1 ~ 0x%x)\n", MAXIMUM_SW= I_VALUE));=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + //=0D + // Register=0D + //=0D + Status =3D gSmst->SmmAllocatePool (EfiRuntimeServicesData, sizeof(*Conte= xt), (VOID **)&Context);=0D + ASSERT_EFI_ERROR (Status);=0D + if (EFI_ERROR (Status)) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + *DispatchHandle =3D (EFI_HANDLE )Context;=0D + Context->Signature =3D SMI_SW_HANDLER_SIGNATURE;=0D + Context->SwSmiInputValue =3D RegContext->SwSmiInputValue;=0D + Context->DispatchFunction =3D (UINTN)DispatchFunction;=0D + Context->DispatchHandle =3D *DispatchHandle;=0D + InsertTailList (&mSmmSwDispatch2Queue, &Context->Link);=0D +=0D + return Status;=0D +}=0D +=0D +=0D +/**=0D + Unregister a child SMI source dispatch function for the specified softwa= re SMI.=0D +=0D + This service removes the handler associated with DispatchHandle so that = it will no longer be=0D + called in response to a software SMI.=0D +=0D + @param[in] This Pointer to the EFI_SMM_SW_DISPATCH2_PROTO= COL instance.=0D + @param[in] DispatchHandle Handle of dispatch function to deregister= .=0D +=0D + @retval EFI_SUCCESS The dispatch function has been successful= ly unregistered.=0D + @retval EFI_INVALID_PARAMETER The DispatchHandle was not valid.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SmmSwDispatch2UnRegister (=0D + IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This,=0D + IN EFI_HANDLE DispatchHandle=0D + )=0D +{=0D + EFI_SMM_SW_DISPATCH2_CONTEXT *Context;=0D +=0D + //=0D + // Unregister=0D + //=0D + Context =3D FindContextByDispatchHandle (DispatchHandle);=0D + ASSERT (Context !=3D NULL);=0D + if (Context !=3D NULL) {=0D + RemoveEntryList (&Context->Link);=0D + gSmst->SmmFreePool (Context);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +EFI_SMM_SW_DISPATCH2_PROTOCOL gSmmSwDispatch2 =3D {=0D + SmmSwDispatch2Register,=0D + SmmSwDispatch2UnRegister,=0D + MAXIMUM_SWI_VALUE=0D +};=0D +=0D +=0D +/**=0D + Get specified SMI register based on given register ID=0D +=0D + @param[in] SmmRegister SMI related register array from bootloader=0D + @param[in] Id The register ID to get.=0D +=0D + @retval NULL The register is not found or the format is not = expected.=0D + @return smi register=0D +=0D +**/=0D +PLD_GENERIC_REGISTER *=0D +GetSmmCtrlRegById (=0D + IN PLD_SMM_REGISTERS *SmmRegister,=0D + IN UINT32 Id=0D + )=0D +{=0D + UINT32 Index;=0D + PLD_GENERIC_REGISTER *PldReg;=0D +=0D + PldReg =3D NULL;=0D + for (Index =3D 0; Index < SmmRegister->Count; Index++) {=0D + if (SmmRegister->Registers[Index].Id =3D=3D Id) {=0D + PldReg =3D &SmmRegister->Registers[Index];=0D + break;=0D + }=0D + }=0D +=0D + if (PldReg =3D=3D NULL) {=0D + DEBUG ((DEBUG_INFO, "Register %d not found.\n", Id));=0D + return NULL;=0D + }=0D +=0D + //=0D + // Checking the register if it is expected.=0D + //=0D + if ((PldReg->Address.AccessSize !=3D EFI_ACPI_3_0_DWORD) ||=0D + (PldReg->Address.Address =3D=3D 0) ||=0D + (PldReg->Address.RegisterBitWidth !=3D 1) ||=0D + (PldReg->Address.AddressSpaceId !=3D EFI_ACPI_3_0_SYSTEM_IO) ||=0D + (PldReg->Value !=3D 1)) {=0D + DEBUG ((DEBUG_INFO, "Unexpected SMM register.\n"));=0D + DEBUG ((DEBUG_INFO, "AddressSpaceId=3D 0x%x\n", PldReg->Address.Addres= sSpaceId));=0D + DEBUG ((DEBUG_INFO, "RegBitWidth =3D 0x%x\n", PldReg->Address.Regist= erBitWidth));=0D + DEBUG ((DEBUG_INFO, "RegBitOffset =3D 0x%x\n", PldReg->Address.Regist= erBitOffset));=0D + DEBUG ((DEBUG_INFO, "AccessSize =3D 0x%x\n", PldReg->Address.Access= Size));=0D + DEBUG ((DEBUG_INFO, "Address =3D 0x%lx\n",PldReg->Address.Addres= s ));=0D + return NULL;=0D + }=0D +=0D + return PldReg;=0D +}=0D +=0D +=0D +/**=0D + Entry Point for this driver.=0D +=0D + @param[in] ImageHandle Image handle of this driver.=0D + @param[in] SystemTable A Pointer to the EFI System Table.=0D +=0D + @retval EFI_SUCCESS The entry point is executed successfully.=0D + @retval other Some error occurred when executing this entry point= .=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +PchSmiDispatchEntryPoint (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_HANDLE DispatchHandle;=0D + EFI_HOB_GUID_TYPE *GuidHob;=0D + PLD_SMM_REGISTERS *SmmRegister;=0D + PLD_GENERIC_REGISTER *SmiEosReg;=0D + PLD_GENERIC_REGISTER *SmiApmStsReg;=0D +=0D + GuidHob =3D GetFirstGuidHob (&gSmmRegisterInfoGuid);=0D + if (GuidHob =3D=3D NULL) {=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + SmmRegister =3D (PLD_SMM_REGISTERS *) GET_GUID_HOB_DATA(GuidHob);=0D + SmiEosReg =3D GetSmmCtrlRegById (SmmRegister, REGISTER_ID_SMI_EOS);=0D + if (SmiEosReg =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "SMI EOS reg not found.\n"));=0D + return EFI_NOT_FOUND;=0D + }=0D + mSmiPchReg.SmiEosAddr =3D (UINT32)SmiEosReg->Address.Address;=0D + mSmiPchReg.EosBitOffset =3D SmiEosReg->Address.RegisterBitOffset;=0D +=0D + SmiApmStsReg =3D GetSmmCtrlRegById (SmmRegister, REGISTER_ID_SMI_APM_STS= );=0D + if (SmiApmStsReg =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "SMI APM status reg not found.\n"));=0D + return EFI_NOT_FOUND;=0D + }=0D + mSmiPchReg.SmiApmStsAddr =3D (UINT32)SmiApmStsReg->Address.Address;=0D + mSmiPchReg.ApmBitOffset =3D SmiApmStsReg->Address.RegisterBitOffset;=0D +=0D + //=0D + // Locate PI SMM CPU protocol=0D + //=0D + Status =3D gSmst->SmmLocateProtocol (&gEfiSmmCpuProtocolGuid, NULL, (VOI= D **)&mSmmCpuProtocol);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + //=0D + // Register a SMM handler to handle subsequent SW SMIs.=0D + //=0D + Status =3D gSmst->SmiHandlerRegister ((EFI_MM_HANDLER_ENTRY_POINT)SmmSwD= ispatcher, NULL, &DispatchHandle);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + //=0D + // Publish PI SMM SwDispatch2 Protocol=0D + //=0D + ImageHandle =3D NULL;=0D + Status =3D gSmst->SmmInstallProtocolInterface (=0D + &ImageHandle,=0D + &gEfiSmmSwDispatch2ProtocolGuid,=0D + EFI_NATIVE_INTERFACE,=0D + &gSmmSwDispatch2=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + return Status;=0D +}=0D +=0D diff --git a/UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.h b/UefiPay= loadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.h new file mode 100644 index 0000000000..fd1d3a3368 --- /dev/null +++ b/UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.h @@ -0,0 +1,39 @@ +/** @file=0D + The header file for SMM SwDispatch2 module.=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +=0D +=0D +**/=0D +=0D +#ifndef _SMM_SW_DISPATCH2_H=0D +#define _SMM_SW_DISPATCH2_H=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#define SMI_SW_HANDLER_SIGNATURE SIGNATURE_32('s','s','w','h')=0D +#define MAXIMUM_SWI_VALUE 0xFF=0D +#define SMM_CONTROL_PORT 0xB2=0D +#define SMM_DATA_PORT 0xB3=0D +=0D +typedef struct {=0D + UINTN Signature;=0D + LIST_ENTRY Link;=0D + EFI_HANDLE DispatchHandle;=0D + UINTN SwSmiInputValue;=0D + UINTN DispatchFunction;=0D +} EFI_SMM_SW_DISPATCH2_CONTEXT;=0D +=0D +#endif=0D +=0D diff --git a/UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf b/UefiP= ayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf new file mode 100644 index 0000000000..96a154e888 --- /dev/null +++ b/UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf @@ -0,0 +1,51 @@ +## @file=0D +# PCH SMM SMI Software dispatch module.=0D +#=0D +# Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D PchSmiDispatchSmm=0D + FILE_GUID =3D 60F343E3-2AE2-4AA7-B01E-BF9BD5C04A3B= =0D + MODULE_TYPE =3D DXE_SMM_DRIVER=0D + VERSION_STRING =3D 1.0=0D + PI_SPECIFICATION_VERSION =3D 0x0001000A=0D + ENTRY_POINT =3D PchSmiDispatchEntryPoint=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[Sources]=0D + PchSmiDispatchSmm.c=0D + PchSmiDispatchSmm.h=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +[LibraryClasses]=0D + UefiDriverEntryPoint=0D + MemoryAllocationLib=0D + DebugLib=0D + UefiBootServicesTableLib=0D + SmmServicesTableLib=0D + BaseLib=0D + IoLib=0D + HobLib=0D +=0D +[Protocols]=0D + gEfiSmmCpuProtocolGuid # PROTOCOL ALWAYS_CONSUMED=0D + gEfiSmmSwDispatch2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED=0D +=0D +[Guids]=0D + gSmmRegisterInfoGuid=0D +=0D +[Depex]=0D + gEfiSmmCpuProtocolGuid=0D --=20 2.32.0.windows.2