# Aint13
**Index:** 0223 | **Size:** 4,608 bytes (9,216 body) | **Phase:** DXE

## Overview
UEFI DXE driver providing legacy INT 13h disk I/O service compatibility for AHCI/SATA controllers. Discovers AHCI mass storage controllers via PCI I/O protocol, enumerates attached block devices (ATA and ATAPI), and wires them into real-mode INT 13h dispatch infrastructure. Parses MBR/EBR partition tables for CHS geometry optimization and programs INT 13h vector tables into legacy BIOS real-mode memory. Supports up to 8 disks with both native ATA and ATAPI (CD/DVD) devices.

## Key Functions
- **_ModuleEntryPoint** -- DXE entry: saves globals, calls `sub_18FC`, installs protocol interface with `sub_624` callback.
- **ModuleEntryPoint** -- Compatibility alias of `_ModuleEntryPoint`.
- **sub_624** -- Module init: PCI enumeration via PciIo protocol, memory allocation, timer registration (`88ms`).
- **sub_10CC** -- Core dispatcher: opens PCI bridge, locates chipset-specific protocols, calls geometry setup per disk.
- **sub_18BC** -- ASSERT/debug helper used in entry/init validation.
- **sub_18FC** -- HOB table initialization helper.
- **sub_1634** -- Chipset-specific INT 13h vector programming (`AInt13Csp.c` split file).
- **sub_BD4** -- Per-disk geometry setup: 42-byte descriptor builder.
- **sub_A50** -- ATA geometry extraction from identify data.
- **sub_86C** -- MBR/EBR CHS geometry adjustment.
- **sub_794** -- CHS geometry calculation helper.
- **sub_E88** -- INT 13h handler registration record builder.
- **sub_52C** -- Timer callback that reprograms chipset INT13h vectors.
- **sub_480** -- PCI/ATA device enumeration helper.
- **sub_17F4** -- Lazy debug protocol acquisition.
- **sub_1874** -- Conditional debug print helper.
- **sub_19D4** -- CMOS debug-level fetch.
- **sub_1A24** -- GUID compare helper.
- **sub_1A94** -- Unaligned 64-bit read helper.

## File split

- `Aint13.c`: module entry, protocol install, and shared INT13h helper scaffolding (discovery, timer refresh, utility helpers).
- `AInt13Csp.c`: chipset-specific `sub_1634` flow that programs INT13h controller registers and chip-level vectoring behavior.

## Recovered Variables
- `mImageHandle`
- `mSystemTable`
- `mBootServices`
- `mRuntimeServices`
- `mAint13ProtocolGuid`
- `byte_2149` (`mAint13InitDone`)
- `n8_2148` (`mAint13DiskCount`)
- `mAint13ProtocolThunk` (`psub_624`)
- `qword_2140` (`mInt13VectorTableBase`)
- `qword_2150` (`mPciIoCached`)
- `dword_21C0` (`mPciMmrAddress`)
- `qword_21B8` (`mPciWindowBase`)
- `qword_21C8` (`mAtapiMbrReadBuffer`)
- `qword_21D0` (`mInt13WorkBuffer`)
- `unk_21E0` (`mAint13DriveIdMap`)
- `qword_2180` (`mDebugProtocol`)
- `qword_2188` (`mCachedHobList`)
- `mAint13ChipsetProtocol` (chipset dependency protocol cache, DB9A1E3D-...)
- `mAint13AuxProtocol` (auxiliary dependency protocol cache, 8E008510-...)

## File split

- `Aint13.c`: entry point, protocol install, and generic INT13h helper scaffolding (discovery, timer refresh, utility helpers).
- `AInt13Csp.c`: chipset-specific `sub_1634` path that programs INT13h controller registers and chip-specific vectoring behavior.

## Protocols/Dependencies
- PCI I/O Protocol (B2FA4764-...), UEFI Boot Services
- Chipset-specific protocol A (DB9A1E3D-...) for PCI bridge config / low-level INT13h register I/O
- Unknown protocol B (8E008510-...) for supplemental controller operations
- CMOS/RTC I/O (ports 0x70/0x71) for debug level

## Platform
Intel Purley (Xeon Scalable), HR650X -- AMI AmiModulePkg/CSM/Aint13/
