# AmiErrorHandlerMain
**Index:** 0219 | **Size:** 39,812 bytes (163,456 body) | **Phase:** SMM

## Overview
SMM error handler from American Megatrends (AMI) that receives error notifications via SMM communication protocol, classifies them by error source type (1-9), and dispatches to platform-specific handlers. Manages CPU topology tracking (socket/core/thread) for error source correlation and reports Configuration Status Register (CSR) data to BMC via IPMI/SMM communicate. Handles MCA errors, PCIe AER errors, and generic bus/memory/I/O errors.

## Module split
- `AmiErrorHandlerMain.c` / `AmiErrorHandlerMain.h`: module entrypoint and split-boundary shims that bind recovered names to linked `sub_*` implementation symbols.
- Remaining implementation units (registration/dispatch/reporting/initialization primitives) are referenced through the preserved `sub_*` entrypoints documented in analysis notes.

## Key Functions
- **ModuleEntryPoint** -- Recovered entrypoint that calls `AmiErrorHandlerAutoGenInit`, `AmiErrorHandlerInitialize`, then `AmiErrorHandlerInitFail` on registration failure.
- **AmiErrorHandlerAutoGenInit** (`sub_3E24`) -- Performs AutoGen-generated init routine before main initialization.
- **AmiErrorHandlerInitialize** (`sub_42EC`) -- Main initialization; registers the SMM dispatch handlers.
- **AmiErrorHandlerInitFail** (`sub_427C`) -- Error path invoked when SMM initialization returns failure.
- **sub_27E4** -- Core error dispatch: switch(error_source=1..9) routes to domain-specific handlers
- **sub_2724** -- MCA error severity classification (corrected/uncorrected/fatal/deferred)
- **sub_2F2C** -- Report CSR info to BMC via SmmCommunication with formatted 12-byte record
- **sub_1500** -- MP sync data init: builds 3D topology (socket x core x thread) indexed by APIC ID
- **sub_1BE4** -- MC bank list population based on CPU model selection

## Protocols/Dependencies
- EFI_SMM_BASE2_PROTOCOL, EFI_SMM_ACCESS2_PROTOCOL, EFI_SMM_MP_PROTOCOL
- AMI EMCA_PLATFORM_HOOKS protocol, MP_SYNC_DATA protocol
- SMM CSR Report Protocol (1DBD1503-...) for BMC communication

## Platform
Intel Purley (Xeon Scalable), HR650X
Source: PurleyPlatPkg/Ras/Smm/ErrHandling/AmiErrorHandlerMain/
