# 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.
- **sub_624** -- Module init: PCI enumeration via PciIo protocol, memory allocation, timer registration (`88ms`).
- **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_10CC** -- Core dispatcher: opens PCI bridge, locates chipset-specific protocols, calls geometry setup per disk.
- **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.

## Module split

- `Aint13.c` contains module entry/recovery scaffolding.
- `AInt13Csp.c` contains platform chipset behavior, including `sub_1634` and hardware programming details.

## Recovered Variables
- `mImageHandle`
- `mSystemTable`
- `mBootServices`
- `mRuntimeServices`
- `mAint13ProtocolGuid`
- `byte_2149` (`mAint13InitDone`)
- `n8_2148` (`mAint13DiskCount`)
- `psub_624` (`mModuleProtocolThunk`)
- `qword_2140` (`mInt13VectorTableBase`)
- `dword_21C0` (`mPciMmrAddress`)

## Protocols/Dependencies
- PCI I/O Protocol (B2FA4764-...), UEFI Boot Services
- Chipset-specific protocol A (DB9A1E3D-...) for PCI bridge config
- CMOS/RTC I/O (ports 0x70/0x71) for debug level

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