TianoCore EDK2 master
Loading...
Searching...
No Matches
Tcg2Acpi.c File Reference

Go to the source code of this file.

Data Structures

struct  EFI_TPM2_ACPI_TABLE_V4
 

Macros

#define PHYSICAL_PRESENCE_VERSION_TAG   "$PV"
 
#define PHYSICAL_PRESENCE_VERSION_SIZE   4
 
#define TPM_HID_TAG   "NNNN0000"
 
#define TPM_HID_PNP_SIZE   8
 
#define TPM_HID_ACPI_SIZE   9
 
#define TPM_PRS_RESL   "RESL"
 
#define TPM_PRS_RESS   "RESS"
 
#define TPM_PRS_RES_NAME_SIZE   4
 
#define TPM_POS_RES_TEMPLATE_MIN_SIZE   (1 + 1 + 2 + 12 + 5 + 2)
 
#define MAX_PRS_INT_BUF_SIZE   (15*4)
 

Functions

VOID * AssignOpRegion (EFI_ACPI_DESCRIPTION_HEADER *Table, UINT32 Name, UINT16 Size)
 
EFI_STATUS EFIAPI ExchangeCommonBuffer (IN OUT TCG_NVS *TcgNvs)
 
EFI_STATUS UpdatePPVersion (EFI_ACPI_DESCRIPTION_HEADER *Table, CHAR8 *PPVer)
 
EFI_STATUS UpdatePossibleResource (IN OUT EFI_ACPI_DESCRIPTION_HEADER *Table, IN UINT32 *IrqBuffer, IN UINT32 IrqBuffserSize, OUT BOOLEAN *IsShortFormPkgLength)
 
EFI_STATUS UpdateHID (EFI_ACPI_DESCRIPTION_HEADER *Table)
 
EFI_STATUS PublishAcpiTable (VOID)
 
EFI_STATUS PublishTpm2 (VOID)
 
EFI_STATUS EFIAPI InitializeTcgAcpi (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_TPM2_ACPI_TABLE_V4 mTpm2AcpiTemplate
 
TCG_NVSmTcgNvs
 

Detailed Description

This driver implements TPM 2.0 definition block in ACPI table and populates registered SMI callback functions for Tcg2 physical presence and MemoryClear to handle the requests for ACPI method. It needs to be used together with Tcg2 MM drivers to exchange information on registered SwSmiValue and allocated NVS region address.

Caution: This module requires additional review when modified. This driver will have external input - variable and ACPINvs data in SMM mode. This external input must be validated carefully to avoid security issue.

Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Tcg2Acpi.c.

Macro Definition Documentation

◆ MAX_PRS_INT_BUF_SIZE

#define MAX_PRS_INT_BUF_SIZE   (15*4)

Definition at line 75 of file Tcg2Acpi.c.

◆ PHYSICAL_PRESENCE_VERSION_SIZE

#define PHYSICAL_PRESENCE_VERSION_SIZE   4

Definition at line 48 of file Tcg2Acpi.c.

◆ PHYSICAL_PRESENCE_VERSION_TAG

#define PHYSICAL_PRESENCE_VERSION_TAG   "$PV"

Definition at line 47 of file Tcg2Acpi.c.

◆ TPM_HID_ACPI_SIZE

#define TPM_HID_ACPI_SIZE   9

Definition at line 55 of file Tcg2Acpi.c.

◆ TPM_HID_PNP_SIZE

#define TPM_HID_PNP_SIZE   8

Definition at line 54 of file Tcg2Acpi.c.

◆ TPM_HID_TAG

#define TPM_HID_TAG   "NNNN0000"

Definition at line 53 of file Tcg2Acpi.c.

◆ TPM_POS_RES_TEMPLATE_MIN_SIZE

#define TPM_POS_RES_TEMPLATE_MIN_SIZE   (1 + 1 + 2 + 12 + 5 + 2)

Definition at line 69 of file Tcg2Acpi.c.

◆ TPM_PRS_RES_NAME_SIZE

#define TPM_PRS_RES_NAME_SIZE   4

Definition at line 59 of file Tcg2Acpi.c.

◆ TPM_PRS_RESL

#define TPM_PRS_RESL   "RESL"

Definition at line 57 of file Tcg2Acpi.c.

◆ TPM_PRS_RESS

#define TPM_PRS_RESS   "RESS"

Definition at line 58 of file Tcg2Acpi.c.

Function Documentation

◆ AssignOpRegion()

VOID * AssignOpRegion ( EFI_ACPI_DESCRIPTION_HEADER Table,
UINT32  Name,
UINT16  Size 
)

Find the operation region in TCG ACPI table by given Name and Size, and initialize it if the region is found.

Parameters
[in,out]TableThe TPM item in ACPI table.
[in]NameThe name string to find in TPM table.
[in]SizeThe size of the region to find.
Returns
The Acpi Communicate Buffer for the found region.

Definition at line 124 of file Tcg2Acpi.c.

◆ ExchangeCommonBuffer()

EFI_STATUS EFIAPI ExchangeCommonBuffer ( IN OUT TCG_NVS TcgNvs)

Locate the MM communication buffer and protocol, then use it to exchange information with Tcg2StandaloneMmm on NVS address and SMI value.

Parameters
[in,out]TcgNvsThe NVS subject to send to MM environment.
Returns
The status for locating MM common buffer, communicate to MM, etc.

Definition at line 178 of file Tcg2Acpi.c.

◆ InitializeTcgAcpi()

EFI_STATUS EFIAPI InitializeTcgAcpi ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The driver's entry point.

It patches and installs ACPI tables used for handling TPM physical presence and Memory Clear requests through ACPI method.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
OthersSome error occurs when executing this entry point.

Definition at line 887 of file Tcg2Acpi.c.

◆ PublishAcpiTable()

EFI_STATUS PublishAcpiTable ( VOID  )

Initialize and publish TPM items in ACPI table.

Return values
EFI_SUCCESSThe TCG ACPI table is published successfully.
OthersThe TCG ACPI table is not published.

Definition at line 662 of file Tcg2Acpi.c.

◆ PublishTpm2()

EFI_STATUS PublishTpm2 ( VOID  )

Publish TPM2 ACPI table

Return values
EFI_SUCCESSThe TPM2 ACPI table is published successfully.
OthersThe TPM2 ACPI table is not published.

Definition at line 779 of file Tcg2Acpi.c.

◆ UpdateHID()

EFI_STATUS UpdateHID ( EFI_ACPI_DESCRIPTION_HEADER Table)

Patch TPM2 device HID string. The initial string tag in TPM2 ACPI table is "NNN0000".

Parameters
[in,out]TableThe TPM2 SSDT ACPI table.
Returns
HID Update status.

Definition at line 559 of file Tcg2Acpi.c.

◆ UpdatePossibleResource()

EFI_STATUS UpdatePossibleResource ( IN OUT EFI_ACPI_DESCRIPTION_HEADER Table,
IN UINT32 *  IrqBuffer,
IN UINT32  IrqBuffserSize,
OUT BOOLEAN *  IsShortFormPkgLength 
)

Patch interrupt resources returned by TPM _PRS. ResourceTemplate to patch is determined by input interrupt buffer size. BufferSize, PkgLength and interrupt descriptor in ByteList need to be patched

Parameters
[in,out]TableThe TPM item in ACPI table.
[in]IrqBufferInput new IRQ buffer.
[in]IrqBuffserSizeInput new IRQ buffer size.
[out]IsShortFormPkgLengthIf _PRS returns Short length Package(ACPI spec 20.2.4).
Returns
patch status.

Definition at line 313 of file Tcg2Acpi.c.

◆ UpdatePPVersion()

EFI_STATUS UpdatePPVersion ( EFI_ACPI_DESCRIPTION_HEADER Table,
CHAR8 *  PPVer 
)

Patch version string of Physical Presence interface supported by platform. The initial string tag in TPM ACPI table is "$PV".

Parameters
[in,out]TableThe TPM item in ACPI table.
[in]PPVerVersion string of Physical Presence interface supported by platform.
Returns
The allocated address for the found region.

Definition at line 275 of file Tcg2Acpi.c.

Variable Documentation

◆ mTcgNvs

TCG_NVS* mTcgNvs

Definition at line 110 of file Tcg2Acpi.c.

◆ mTpm2AcpiTemplate

EFI_TPM2_ACPI_TABLE_V4 mTpm2AcpiTemplate
Initial value:
= {
{
sizeof (mTpm2AcpiTemplate),
EFI_TPM2_ACPI_TABLE_REVISION,
},
0,
0,
EFI_TPM2_ACPI_TABLE_START_METHOD_TIS,
}
#define EFI_ACPI_5_0_TRUSTED_COMPUTING_PLATFORM_2_TABLE_SIGNATURE
Definition: Acpi50.h:2100

Definition at line 94 of file Tcg2Acpi.c.