# StatusCodePei
**Index:** 0404 | **Size:** 20,800 bytes | **Phase:** PEI | **Format:** PE32 (Ia32)

## Overview
Status code reporting and dispatch PEI module. Manages a linked-list PPI-based callback registration system for status code notifications, formats status messages (error strings, debug asserts, progress codes) and outputs them via serial port. Provides the ReportStatusCode PPI service for PEI-phase components to report progress, errors, and debug assertions.

## Key Functions
- **StatusCodePeiEntry** -- Module entry: locates and installs ReportStatusCode and SerialPort PPIs, registers PPI descriptors
- **StatusCodeReport** -- Main report handler: dispatches callbacks then writes to serial port
- **StatusCodeRegisterCallback** -- Registers a callback node in the PPI-linked callback list
- **StatusCodeRemoveCallback** -- Removes a callback from the list
- **StatusCodeDispatchCallbacks** -- Walks the PPI-linked list and invokes all registered callbacks
- **StatusCodeSerialReport** -- Formats status code with AsciiSPrint and dispatches to serial handler chain
- **StatusCodeDebugAssert** -- Formats ASSERT strings ("ASSERT %a(%d): %a") and dispatches
- **StatusCodeFormatMsg** -- Formats status code data into human-readable buffer (wide/ascii string types)
- **StatusCodeToErrorStr** -- Resolves error code to error description string, or fallback hex format
- **DebugAssertMsgs** -- Formats ASSERT in source file:%i:%s form
- **SerialPortWrite** -- Serial output via ComPort, filters by HandlerTable dispatch
- **SetMem16** -- Memory-to-serial port streaming with CR/LF translation
- **PeiServicesInstallPpi** -- Installs PPIs with serial output chain

## Dependencies
- EFI_PEI_REPORT_STATUS_CODE_PPI -- Status code reporting PPI
- EFI_PEI_SERIAL_PORT_PPI -- Serial port PPI
- PEI Services (LocatePpi, InstallPpi, RegisterNotifyPpi)
- Serial Port (I/O mapped COM port)

## Platform
Intel Purley (Skylake-SP Xeon), HR650X
Source: AmiModulePkg/AmiStatusCode/StatusCodePei.c