# MainErrorHandler
**Index:** 0216 | **Size:** 25,584 bytes (152,960 body) | **Phase:** DXE/SMM

## Overview
Top-level UEFI error handler dispatcher for the Intel Purley platform. This module initializes the error handling subsystem by calling library constructors, then registers error sources and notification callbacks. It serves as the main entry point that chains into PlatformErrorHandler, ProcessorErrorHandler, and other per-domain error handlers.

## Recovered Module Split
- **MainErrorHandler.c**: contains `ModuleEntryPoint()` wrapper and dispatches initialization results.
- **Library/registration/cleanup units**: `InitMainErrorHandlerLibraries()`, `RegisterMainErrorHandlerCallbacks()`, and `UnregisterMainErrorHandlerCallbacks()` are split into linked units (recovered from decompiler artifacts).

## Key Functions
- **ModuleEntryPoint** -- UEFI entry point; initializes libraries via `InitMainErrorHandlerLibraries()`, calls `RegisterMainErrorHandlerCallbacks()`, and falls back to `UnregisterMainErrorHandlerCallbacks()` on failure.
- **InitMainErrorHandlerLibraries** (recovered from `sub_2398`) -- library constructor chain initialization (`gST`/`gBS`/`gRT`/`gSmst` setup).
- **RegisterMainErrorHandlerCallbacks** (recovered from `sub_2774`) -- main error handler registration logic.
- **UnregisterMainErrorHandlerCallbacks** (recovered from `sub_2704`) -- cleanup/unload handler on initialization failure.

## Recovered Symbol Mapping
- `sub_2398` -> `InitMainErrorHandlerLibraries`
- `sub_2774` -> `RegisterMainErrorHandlerCallbacks`
- `sub_2704` -> `UnregisterMainErrorHandlerCallbacks`

## Protocols/Dependencies
- UEFI Boot Services (gBS), Runtime Services (gRT), SMM System Table (gSmst)
- EFI_SMM_BASE2_PROTOCOL, EFI_SMM_SW_DISPATCH2_PROTOCOL
- EMCA Platform Protocol and MP Sync Data protocols

## Platform
Intel Purley (Skylake-SP Xeon), HR650X
Source: PurleyPlatPkg/Ras/Smm/ErrHandling/MainErrorHandler/
