# FlashDriver

| Index | Module | Size | Phase |
|-------|--------|------|-------|
| 0256  | FlashDriver | 24,064 bytes | DXE (Runtime Driver) |

FlashDriver is a UEFI DXE Runtime Driver from AmiModulePkg that manages SPI flash programming for BIOS flash chips. It detects flash devices, maps them to MMIO, and provides a protocol interface for read, write, and erase operations. The driver handles virtual address change notifications for runtime services, manages PCIe segment/bus caching, and implements SPI flash command sequencing including the Spinel communication protocol.

## Key Functions

- **ModuleEntryPoint** -- UEFI entry point; dispatches to FlashDriverInit
- **FlashDriverInit** -- Driver initialization; detects SPI flash controllers and enumerates flash devices
- **FlashDriverEntry** -- Registers the flash protocol interface
- **FlashDriverUnload** -- Driver unload handler; cleans up flash protocol registration
- **FlashProtocolInstall** -- Installs the flash protocol on a new handle
- **FlashSpinelHandler** -- Processes SPI Spinel protocol commands for flash status/control
- **FlashVirtualAddressNotify** -- Handles virtual address mapping change for runtime services
- **FlashFreePciExpressMmio** -- Releases PCI Express MMIO allocations

## Dependencies

- UEFI Boot Services (`gBS`)
- UEFI Runtime Services (`gRT`)
- DXE Services (`gDS`)
- PCI Express MMIO Base
- SPI Flash Protocol
- Flash Region Table (descriptor-based flash layout)
- Spinel Protocol

## Platform

- **Format:** PE32+
- **Machine:** x86-64
- **Subsystem:** EFI Runtime Driver (0x0C)
- **Sections:** .text, .rdata, .data, section_3, .xdata, .reloc
- **Source:** AmiModulePkg\FlashDriver
- **Build:** VS2015 DEBUG, X64