> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man4/attimer.4.md).

# attimer.4

`attimer` — i8254 可编程间隔定时器（AT 定时器）驱动

## 名称

`attimer`

## 概要

本驱动是 x86 内核的必备组成部分。

以下可调参数可在 [loader(8)](/man/man8/loader.8.md) 中设置：

**`hint.attimer.X.clock`** 控制事件定时器功能的支持。将此值设置为 0 可禁用该功能。默认值为 1。

**`hint.attimer.X.timecounter`** 控制时间计数器功能的支持。将此值设置为 0 可禁用该功能。默认值为 1。

**`hw.i8254.freq`** 允许覆盖默认的计数器频率。同一值也可在运行时通过 `machdep.i8254_freq` sysctl 获取。

## 描述

本驱动使用 i8254 可编程间隔定时器（AT 定时器）硬件向内核提供一个时间计数器和一个事件定时器，并为系统扬声器生成声音。该硬件包含三个通道。每个通道包含一个 16 位计数器，按已知的、平台相关的频率递减。计数器可以工作在多种不同模式下，包括周期模式和单次模式。每个通道的输出具有平台定义的连线：一个通道连接到中断控制器，可用作事件定时器；一个通道连接到扬声器，用于生成声音；还有一个定时器保留供平台使用。

`attimer` 驱动使用单个硬件通道同时提供时间计数器和事件定时器功能。为使其成为可能，相应计数器必须以周期模式运行。因此，仅当禁用时间计数器功能时才支持单次事件定时器模式。

驱动提供的事件定时器与 CPU 电源状态无关。

## 参见

[apic(4)](/man/man4/apic.4.md), [atrtc(4)](/man/man4/atrtc.4.md), [eventtimers(4)](/man/man4/eventtimers.4.md), [hpet(4)](/man/man4/hpet.4.md), [timecounters(4)](/man/man4/timecounters.4.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man4/attimer.4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
