# SataController

## Function Table

| Address | Name | Description |
|---------|------|-------------|
| 0000 | **SataGetDeviceCount** | Return total channels and maximum devices per channel |
| 0000 | **SataGetDevice** | Validate channel index and device presence |
| 0000 | **SataIdentifyDevice** | Copy 512-byte IDENTIFY DEVICE payload for a channel |
| 0000 | **SataModifyDevice** | Copy 44-byte `EFI_IDE_CHANNEL_INFO` for the selected channel |
| 0000 | **SataSubmitAsyncCommand** | Build caller result buffer and return negotiated PIO/DMA modes |
| 0000 | **SataStopDevice** | No-op stop routine |
| 0000 | **SataCalculateBestPioMode** | Compute preferred PIO mode from IDENTIFY Field103/128/136 |
| 0000 | **PchGetPchSeries** | Detect PCH family (SPT, CNP, fallback) from LPC device ID |
| 0000 | **S3BootScriptLibInit** | Initialize S3 boot-script save context and callback registrations |
| 0000 | **S3BootScriptEventNotify** | SMM/DXE finalization notify handler |
| 0000 | **S3BootScriptFinalize** | Append S3 boot-script terminator |
| 0000 | **S3ReadyToLockNotify** | Copy boot-script state into ready-to-lock SMM context |
| 0000 | **S3BootScriptCloseEvent** | Persist boot-script close metadata into S3 LockBox |
| 0000 | **S3BootScriptCloseNotify** | Handle boot-script close event, save entries and mark completion |
| 0000 | **SaveBootScriptDataToLockBox** | Save boot script and qualifying memory ranges into LockBox |
| 0000 | **SmmLockBoxSave** | Write an entry into SMM LockBox communication buffer |
| 0000 | **SmmLockBoxSetAttributes** | Apply LockBox attributes to an entry |
| 0000 | **SmmLockBoxRestore** | Restore a LockBox entry |
| 0000 | **S3BootScriptLibDeinit** | Release events, protocol state, and reserved pages |
| 0000 | **SataComponentNameGetDriverName** | Return component driver name |
| 0000 | **SataComponentNameGetControllerName** | Return controller-specific component name |
| 0000 | **LookupStringTable** | Resolve ISO-639-2 / RFC-4646 localized strings |
| 0000 | **GetSmmLockBoxProtocol** | Cached getter for `gEfiSmmLockBoxProtocolGuid` |
| 0000 | **SmmLockBoxGetCommBuffer** | Resolve/return Pi SMM communication region buffer |

## Recovered Naming Notes

- `SmmLockBoxSave`, `SmmLockBoxSetAttributes`, and `SmmLockBoxRestore` are canonical names used by the LockBox wrapper layer in this module.
- `SmmBootScript`-related callbacks are recovered as distinct notify/finalize/close entry points:
  `S3BootScriptEventNotify`, `S3BootScriptFinalize`, `S3ReadyToLockNotify`,
  `S3BootScriptCloseEvent`, `S3BootScriptCloseNotify`.
- `PchGetPchSeries` return values are interpreted as:
  - `1`: SPT
  - `2`: CNP / Cannon Point family
  - `3`: unknown/default path

## Module/File Split Notes

- `SataController.c` contains the recovered implementations for protocol handlers, S3 management flows, and LockBox plumbing.
- `SataController.h` now contains normalized function prototypes and types derived from decompiled usage:
  `SataGetDeviceCount`, `SataGetDevice`, `SataIdentifyDevice`, `SataModifyDevice`,
  `SataSubmitAsyncCommand`, `SataStopDevice`, `SataCalculateBestPioMode`,
  `S3BootScript*`, `SmmLockBox*`, and component-name lookup helpers.

## Recovered Variable Naming

- `gPchSeries`
- `gBootScriptContext`
- `gAltBootScriptContext`
- `gBootScriptAllocated`
- `gBootScriptCloseGuid`
- `gBootScriptFinalGuid`
- `gEventExitBootSvc`
- `gEventSetVirtualAddrMap`
- `gEventReadyToLock`
- `gDxeSmmReadyToLockEvent`
- `gSmst`
- `gSmstAllocated`
- `gLockBoxCommBuffer`
- `gControllerHandle`
- `gBootScriptContext->MemoryRanges`
