# TimestampDxe

| Attribute     | Value                                                             |
|---------------|-------------------------------------------------------------------|
| Index         | 0001                                                              |
| Module        | TimestampDxe                                                      |
| Size (EFI)    | 4,928 bytes (1340h)                                               |
| Phase         | DXE                                                               |
| Platform      | All (common UEFI driver)                                          |
| Framework     | UEFI Standard                                                     |
| Source Lines  | 1,459 (2 files)                                                   |

## Overview

TimestampDxe implements the EFI_TIMESTAMP_PROTOCOL by calibrating the x86 Time-Stamp Counter (TSC) against a hardware reference counter at I/O port 0x508. It enables the TCO/REF counter via PCIe configuration space, performs a spin-wait calibration loop with interrupts disabled, computes TSC frequency in Hz, and publishes GetTimestamp and GetProperties protocol services. This driver is sourced from MdeModulePkg/Universal/TimestampDxe in the EDK II tree.

## Key Functions

- `ModuleEntryPoint` -- Entry point; calibrates TSC frequency and installs EFI_TIMESTAMP_PROTOCOL
- `CalibrateTscFrequency` -- Core calibration routine using TIMESTAMP_CALIBRATION_PORT (0x508)
- `GetTimestamp` -- Returns the current TSC value from RDTSC
- `GetProperties` -- Returns timestamp counter properties (frequency, end value)
- `DebugPrint` -- Debug output via DebugLib protocol
- `DebugAssert` -- Assertion handler via DebugLib protocol
- `GetHobList` -- Locates HOB list from system configuration table
- `LocateProtocol` -- Wraps gBS->LocateProtocol()
- `IsGuidEqual` -- GUID comparison using two 64-bit unaligned reads

## Dependencies

- UEFI Boot Services (gBS->LocateProtocol, gBS->AllocatePool)
- EFI_TIMESTAMP_PROTOCOL (published service)
- DebugLib Protocol ({36232936-0E76-31C8-A13A-3AF2FC1C3932})
- PCD Protocol
- I/O port 0x508: 32-bit free-running reference counter (masked to 24 bits)
- PCIe ECAM configuration space (TCO/REF counter enable)
- RTC CMOS index 0x4B: Platform identifier byte

## Platform

- Architecture: x86-64 (PE32+)
- Machine: 0x8664
- Subsystem: EFI Boot Service Driver (0x000B)
- Toolchain: VS2015, X64 DEBUG
- Sections: 6 (.text, .rdata, .data, .idata, .reloc)
- Entry Point: 0x3E0