# PlatformErrorHandler
**Index:** 0217 | **Size:** 44,388 bytes (177,536 body) | **Phase:** DXE/SMM

## Overview
SMM platform error handler for the Intel Purley platform, responsible for RAS (Reliability, Availability, Serviceability) error management. Initializes EMCA (Enhanced Machine Check Architecture) platform hooks, populates RAS topology structures (SMBIOS Type 16/17), configures FPGA error handling policies from UEFI setup variables, registers SMM software dispatch callbacks for error notification, and manages per-socket error tracking via linked callbacks.

## Key Functions
- **ModuleEntryPoint** -- DXE/SMM entry, calls constructor dispatcher then main init
- **PlatformErrorHandlerConstructors** -- library constructor path
- **RegisterPlatformErrorHandler** -- main init (calls core logic at `sub_3970`)
- **sub_3970** -- Core logic: reads RAS topology, applies error policy from setup, initializes EMCA platform hooks
- **PlatformErrorHandlerFallbackInit** -- error-path init helper
- **PlatformErrorHandlerSmmEntry** -- secondary SMM path
- **DispatchNotification** / **DispatchWithEarlyOut** -- callback dispatch helpers
- **RegisterErrorNotificationCallback** -- priority-sorted callback registration helper (24-byte node)
- **RegisterErrorSource** -- source-registration linked list insertion

## Recovered Module Variables
- `PlatformErrorHandlerStatus` (`qword_72D8`)
- `ErrorSourceListHead` / `ErrorSourceListTail` (`qword_72E0` / `qword_72E8`)
- `NotificationCallbackHead` / `NotificationCallbackTail` (`qword_72F0` / `qword_72F8`)
- `EmcaPlatformProtocol` (`qword_7368`)
- `SmmIpmiTransportProtocol` (`qword_73C0`)
- `McBankListTable` (`qword_7388`)
- `ErrorPolicyTable` (`qword_7398`)
- `McBankControlTable` (`qword_73A0`)
- `SocketCount` (`qword_73A8`)
- `McBankCount` (`qword_7390`)

## File Split Notes
- `_ModuleEntryPoint` and `PlatformErrorHandlerSmmEntry` entry paths are in this file.
- SMM helper routines for callback registration and dispatch (`RegisterErrorNotificationCallback`,
  `RegisterErrorSource`, `DispatchNotification`, `DispatchWithEarlyOut`) are resolved from
  decompilation evidence and exposed for cross-file linking from this module directory.
- SMM subroutines for MC bank lookup (`sub_1D8C`, `sub_1DE4`, `sub_1E3C`) are documented in
  `emcaplatformhookslib.c`, and this module is expected to consume that API.

## Protocols/Dependencies
- EMCA Platform Protocol ({F4CCBFB7-...}), SMM MC Bank Protocol
- SMM IPMI Transport Protocol, SMM Variable Protocol
- SMM SW Dispatch2 Protocol, FPGA Configuration HOB

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