# CapsulePei

| Field       | Value                                         |
|-------------|-----------------------------------------------|
| Index       | 389                                           |
| Module      | CapsulePei                                    |
| Size        | 17632 bytes (0x44E0)                          |
| Phase       | PEI                                           |
| Format      | PE32                                          |
| Machine     | x86 (0x014C)                                  |
| Sections    | .text, .rdata, .data, .reloc                  |
| Entry Point | 0x368                                         |
| Functions   | 61                                            |
| Source      | MdeModulePkg/Universal/CapsulePei             |

## Overview

CapsulePei implements the UEFI capsule update processing during the PEI phase. It discovers capsules passed from the DXE phase (or via the update mechanism), coalesces fragmented capsule data into contiguous memory, validates capsule headers, and exposes the coalesced capsule via the EFI_PEI_CAPSULE_PPI for consumption by the capsule runtime DXE driver.

This module supports both UEFI specification capsule updates and platform-specific vendor capsule formats. It handles flash-based and memory-based capsule delivery mechanisms, ensuring that firmware update payloads are available to the flash write protocol after memory initialization.

## Key Functions

- **ModuleEntryPoint** -- Main entry; initializes capsule PPI and begins discovery.
- **CapsuleCoalesce** -- Core coalescing algorithm that merges capsule fragments into a contiguous buffer.
- **CapsuleDataCoalesce** -- Handles specific UEFI capsule data coalescing for PEI phase consumption.
- **InternalCopyMem / InternalZeroMem / InternalSetMem** -- Memory primitives for capsule data manipulation.

## Dependencies

- EFI_PEI_CAPSULE_PPI
- Capsule vendor GUIDs (gEfiCapsuleVendorGuid)
- PEI services
- HOB creation for capsule data handoff
- BaseLib memory primitives

## Platform

UEFI-compliant firmware (MdeModulePkg), 32-bit PEI phase, supports UEFI 2.x capsule update specification.