/** @file SMM PPAM support @copyright INTEL CONFIDENTIAL Copyright 2018 Intel Corporation. The source code contained or described herein and all documents related to the source code ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or its suppliers and licensors. The Material may contain trade secrets and proprietary and confidential information of Intel Corporation and its suppliers and licensors, and is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without Intel's prior express written permission. No license under any patent, copyright, trade secret or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel or otherwise. Any license under such intellectual property rights must be express and approved by Intel in writing. Unless otherwise agreed by Intel in writing, you may not remove or alter this notice or any other notice embedded in Materials by Intel or Intel's suppliers or licensors in any way. This file contains an 'Intel Peripheral Driver' and is uniquely identified as "Intel Reference Module" and is licensed for Intel CPUs and chipsets under the terms of your license agreement with Intel or your vendor. This file may be modified by the user, subject to additional terms of the license agreement. @par Specification Reference: **/ #ifndef _SMM_PPAM_H_ #define _SMM_PPAM_H_ #include #include /** Create 4G page table for PPAM. 2M PAE page table in X64 version. @param PageTableBase The page table base in MSEG **/ VOID PpamGen4GPageTable ( IN UINTN PageTableBase ); /** Initializes MsegBase and MsegSize variables **/ VOID GetMsegInfo( VOID ); /** Get PPAM state. @return PPAM state **/ EFI_SM_MONITOR_STATE EFIAPI PpamGetMonitorState ( VOID ); /** Load PPAM image to MSEG. @param PpamImage PPAM image @param PpamImageSize PPAM image size @retval EFI_SUCCESS Load PPAM to MSEG successfully @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of PPAM image **/ EFI_STATUS EFIAPI PpamLoadMonitor ( IN EFI_PHYSICAL_ADDRESS PpamImage, IN UINTN PpamImageSize ); /** Add resources in list to database. Allocate new memory areas as needed. @param ResourceList A pointer to resource list to be added @param NumEntries Optional number of entries. If 0, list must be terminated by END_OF_RESOURCES. @retval EFI_SUCCESS If resources are added @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas. **/ EFI_STATUS EFIAPI PpamAddPiResource ( IN STM_RSC *ResourceList, IN UINT32 NumEntries OPTIONAL ); /** Delete resources in list to database. @param ResourceList A pointer to resource list to be deleted NULL means delete all resources. @param NumEntries Optional number of entries. If 0, list must be terminated by END_OF_RESOURCES. @retval EFI_SUCCESS If resources are deleted @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer **/ EFI_STATUS EFIAPI PpamDeletePiResource ( IN STM_RSC *ResourceList, IN UINT32 NumEntries OPTIONAL ); /** Get BIOS resources. @param ResourceList A pointer to resource list to be filled @param ResourceSize On input it means size of resource list input. On output it means size of resource list filled, or the size of resource list to be filled if size of too small. @retval EFI_SUCCESS If resources are returned. @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources. **/ EFI_STATUS EFIAPI PpamGetPiResource ( OUT STM_RSC *ResourceList, IN OUT UINT32 *ResourceSize ); /** Internal worker function that is called to complete CPU initialization at the end of SmmCpuFeaturesInitializeProcessor(). **/ VOID FinishSmmCpuFeaturesInitializeProcessor( VOID ); /** Constructor for PPAM. **/ VOID PpamConstructor ( VOID ); /** Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is returned, then a custom SMI handler is not provided by this library, and the default SMI handler must be used. @retval 0 Use the default SMI handler. @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() The caller is required to allocate enough SMRAM for each CPU to support the size of the custom SMI handler. **/ UINTN EFIAPI SmmCpuFeaturesGetSmiHandlerSizePpam ( VOID ); /** Install a custom SMI handler for the CPU specified by CpuIndex. This function is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater than zero and is called by the CPU that was elected as monarch during System Management Mode initialization. @param[in] CpuIndex The index of the CPU to install the custom SMI handler. The value must be between 0 and the NumberOfCpus field in the System Management System Table (SMST). @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. @param[in] SmiStack The stack to use when an SMI is processed by the the CPU specified by CpuIndex. @param[in] StackSize The size, in bytes, if the stack used when an SMI is processed by the CPU specified by CpuIndex. @param[in] GdtBase The base address of the GDT to use when an SMI is processed by the CPU specified by CpuIndex. @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is processed by the CPU specified by CpuIndex. @param[in] IdtBase The base address of the IDT to use when an SMI is processed by the CPU specified by CpuIndex. @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is processed by the CPU specified by CpuIndex. @param[in] Cr3 The base address of the page tables to use when an SMI is processed by the CPU specified by CpuIndex. **/ VOID EFIAPI SmmCpuFeaturesInstallSmiHandlerPpam ( IN UINTN CpuIndex, IN UINT32 SmBase, IN VOID *SmiStack, IN UINTN StackSize, IN UINTN GdtBase, IN UINTN GdtSize, IN UINTN IdtBase, IN UINTN IdtSize, IN UINT32 Cr3 ); VOID PatchSmmEntryPoint ( IN VOID *SmmEntryPointHeader, IN UINT8 Type, IN VOID *Data, IN UINT8 DataSize ); #endif