# LegacySmmSredir

- **Index:** 0197
- **Size:** 7,428 bytes (7.3 KB)
- **Phase:** SMM (System Management Mode)
- **PE Format:** PE32+ x86-64, 5 sections (.text, .rdata, .data, section_3, .xdata)

## Overview

SMM driver for legacy serial redirection, sourced from AmiModulePkg/LegacySerialRedirection. This driver provides SMM-based I/O access to serial ports for legacy serial console redirection during boot. It installs an SMM communicate handler that services read/write/block-fill commands targeting an I/O base address (serial port registers). The driver includes a CMOS-based platform detection mechanism (CMOS offset 0x4C) to determine whether legacy serial redirect is supported on the board. 20 functions across 0x1080 bytes of .text.

## Key Functions

- **_ModuleEntryPoint / ModuleEntryPoint** (0x420) -- Standard SMM entry; calls init then dispatch
- **LegacySmmSredirAutoGenInit** (0x44C) -- AutoGen library init; locates SmmBase2 and AmiBufferValidationLib
- **LegacySmmSredirDriverEntry** (0x618) -- Main entry; checks board support via CMOS, dispatches to main logic
- **LegacySmmSredirMainDispatch** (0xC58) -- Primary dispatch; opens SMM subsystem, initializes globals
- **LegacySmmSredirRegisterCommunicationServices** (0x9E8) -- Registers communicate handler, SW dispatch, and notification callbacks
- **LegacySmmSredirHandleCommunicate** (0x6CC) -- Core handler: decodes read(1)/write(2)/fill(3) commands with width support
- **LegacySmmSredirDetectPlatform** (0x115C) -- CMOS 0x4C platform detection

## Recovered Name Mapping (current)

- `ModuleEntryPoint` is kept as a compatibility alias to `_ModuleEntryPoint`.
- Legacy decompiler aliases are kept for symbol compatibility: `LegacySmmSredirAutoGenInit` (`sub_44C`), `LegacySmmSredirDriverEntry` (`sub_618`), and `LegacySmmSredirDisableCommunicateHandler` (`sub_93C`).
- `qword_*` and `byte_*` symbols in the decomp notes are now mapped to recovered names in `LegacySmmSredir.c/h` (`gST`, `gBS`, `gSmst`, `gSmmMode`, ...).

## Module/file split notes

- `LegacySmmSredir.md` carries the detailed behavior and control-flow reconstruction.
- `LegacySmmSredir.c/.h` carry the normalized naming surface used for subsequent recovery.

## Protocols

- **SmmBase2** -- SMM entry; **AmiBufferValidationLib** -- buffer security check
- **SmmCommunicate** -- handler registration; **SmmIo** -- I/O space access
- **DebugLib** -- DEBUG/ASSERT support; **SmmSwDispatch** -- software SMI registration

## Platform

- **Build:** HR6N0XMLK DEBUG_VS2015 X64
- **Source:** AmiModulePkg/LegacySerialRedirection
- **Part of:** HR650X BIOS SMM infrastructure (indices 0195-0199, 0201-0203)
