# KbcEmul

**Index:** 0209
**Size:** 14,532 bytes (38C4h)
**Phase:** SMM (DXE_SMM_DRIVER)
**Source Package:** AmiModulePkg\KbcEmulation\KbcEmul

## Overview
SMM-based Keyboard Controller (KBC) emulation driver. Emulates legacy PS/2 keyboard controller functionality (ports 0x60/0x64) from within SMM context on platforms that lack a physical KBC (e.g., Intel Purley server platforms). Traps IO accesses to the legacy KBC IO ports via SMI and provides emulated responses for keyboard, mouse, and AUX device commands. Includes a DXE counterpart (KbcEmulDxe) for boot-time initialization. Has a .reloc section for runtime relocation.

## Key Functions
- **ModuleEntryPoint** -- Main entry: calls sub_4E8 init, then sub_628 for KBC emulation setup
- **sub_4E8** -- UEFI driver init: caches ImageHandle, SystemTable, BootServices, RuntimeServices
- **sub_628** -- Core KBC emulation: registers SMI IO trap handlers for ports 0x60/0x64
- **sub_1F94 / sub_360** -- KBC emulation notification cleanup/teardown callbacks
- **sub_2074** -- Debug ASSERT handler referencing AutoGen.c

## Protocols
- EFI_SMM_SYSTEM_TABLE2 for SMM services
- EFI_SMM_CPU_IO2 protocol for IO trap registration
- EFI_SMM_BASE2_PROTOCOL
- Legacy 8042/Keyboard controller emulation interfaces

## Platform
HR650X (Purley), built from AmiModulePkg\KbcEmulation, DEBUG VS2015 X64
