# AhciSmm

## Index
0188

## Size
33E4h (13,284 bytes)

## Phase
DXE SMM (System Management Mode driver)

## Source Package
AmiModulePkg/AHCI/AhciSmm

## Overview
AhciSmm is an SMM driver that manages AHCI (Advanced Host Controller Interface) SATA controllers within System Management Mode. It provides SMI handling for SATA controller events including port errors, hot-plug events, and device interrupts. This driver is essential for proper error recovery and management of SATA storage devices during platform runtime management scenarios.

## Key Functions
- **_ModuleEntryPoint** (0x470): Canonical entry point; initializes AHCI SMM context and dispatches SMI registration.
- **AhciSmmPreInit** (`sub_49C`): Pre-initialization routine that reads AHCI base address registers.
- **AhciSmmRegisterSmiHandlers** (`sub_5DC`): Main SMM entry; registers the SMI handler for SATA/AHCI controller interrupts.
- **AhciPortStartStop** (`sub_E30`): Port-level start/stop control used by command and reset execution.
- **AhciPmpRegisterAccess** (`sub_1274`): Internal AHCI command execution path for PMP register read/write.
- **AhciPollForCommandCompletion** (`sub_7D0`): Port command completion and error-status polling helper.

### Recovered Naming Notes
- `_ModuleEntryPoint` is the canonical entry point name from decompilation notes.
- `ModuleEntryPoint` is kept as a compatibility wrapper name used by existing module wrappers.

### Module/File Split Notes
- `AhciSmm.c` carries the recovered runtime symbols and entrypoint flow stubs for this module snapshot.
- `AhciSmm.h` carries canonical symbol declarations: globals, handler signatures, and compatibility `sub_*` aliases.

## Recovered Variable Naming
- `gImageHandle` (0x2E80)
- `gST` (0x2E70)
- `gBS` (0x2E78)
- `gRT` (0x2E88)
- `gSmst` (0x2E90)
- `mPcd` (0x2EA0)
- `gSmmCpuIo2Protocol` (0x2EB0)
- `mSmmMode` (0x2EB8)
- `gSmmServicesTableBase2` (0x2EE8)
- `gSmmChildProtocol` (0x2EC0)
- `gDxeProtocol` (0x2ED8)
- `gSmiHandlerProtocol` (0x2ED0)
- `gDxeSmiHandlerProtocol` (0x2EF0)
- `gSmmProtocolReady` (0x2EC8)
- `gBuf` (0x2E68)
- `gAhciSavedPxClb` (0x3010)
- `gAhciSavedPxFb` (0x3018)
- `gAhciReturnStatus` (0x3008)
- `gPortCompletionInProgress` (0x2E60)
- `gSoftResetInProgress` (0x2E61)
- `gSmiCallbackHandle` (0x3020)
- `gAhciCommandList` (0x3038)
- `gAhciReceiveArea` (0x3030)
- `gAhciCommandTable` (0x3028)

## Strings
- "AHCI_SMM : PxSERR Port Serial ATA Error Data32_SERR:%x Data32_IS :%x"
- "AHCI : GenerateSoftReset Status : %r"
- "AhciBaseAddr"
- Build path: `AmiModulePkg\AHCI\AhciSmm\AhciSmm.c`

## Platform
Intel Purley (HR650X server platform)
