# TcgPei

## Module Metadata

| Field       | Value                                         |
|-------------|-----------------------------------------------|
| Index       | 386                                           |
| Module      | TcgPei                                        |
| Size        | 13888 bytes (0x3640)                          |
| Phase       | PEI                                           |
| Format      | PE32                                          |
| Machine     | x86 (0x014C)                                  |
| Sections    | .text, .rdata, .data, .reloc                  |
| Entry Point | 0x3C0                                         |

## Overview

`TcgPei` is a recovered Trusted Computing Group PEI module.  It initializes TPM
access, exposes TCG/TPM PPIs, and measures early firmware data into TPM PCRs
before control transfers to DXE.

This directory contains decompiler output, not original vendor source.  The
recovered function names are useful for navigation, but decompiled types and
local variable names should be verified before they are treated as authoritative.

## Key Functions

- **ModuleEntryPoint** -- PEIM entry point; locates required PPIs and starts TPM/TCG initialization.
- **TpmPeiInit** -- Installs TPM device support and checks TPM presence/configuration.
- **Tpm12Transmit / Tpm12Receive** -- TPM 1.2 command transport path.
- **Tpm12Command_Extend / Tpm12Command_ExtendAll** -- PCR measurement and event-log extension path.
- **Sha1Init / Sha1Update / Sha1Final** -- Local SHA-1 implementation used for TPM 1.2 measurements.
- **memcmp_v2 / memmove_v2 / memset_v2** -- Internal memory primitives for measurement operations.
- **SetMem32 / memset32_v2** -- 32-bit memory fill utilities.

## Dependencies

- TPM device PPI (gPeiTpmPpiGuid)
- TCG physical presence interface
- PEI services (PPI database, HOB management)
- EFI_PEI_TCG_PROTOCOL

## Platform

Intel Purley platform, IA32 PEI phase, TCG PC Client style measured boot.

## Files

- `TcgPei.c` - combined decompiler listing with recovered labels.
- `TcgPei.h` - compact navigation index for recovered functions.
- `TcgPei.md` - raw function table generated from the decompile pass.
- `decompile_*.txt`, `all_*.json` - source extraction and analysis artifacts.
