# 15.3.Device Hints

在系统初始启动期间，boot [loader(8)](https://man.freebsd.org/cgi/man.cgi?query=loader\&sektion=8\&format=html) 会读取 [device.hints(5)](https://man.freebsd.org/cgi/man.cgi?query=device.hints\&sektion=5\&format=html)。这个文件储存了称为变量的内核启动信息，有时也被称为“设备提示（device hints）”。这些“设备提示”被设备驱动程序用于设备配置。

设备提示也可以在第 3 阶段引导加载器提示符处指定，详见 [Stage Three](https://docs.freebsd.org/en/books/handbook/boot/#boot-loader) 一节。可以使用 `set` 添加变量，用 `unset` 删除变量，用 `show` 查看变量。写在 **/boot/device.hints** 中的变量也可以被覆盖。在引导加载器中输入的设备提示不是永久性的，并且在下一次重启时不会生效。

系统启动完成后，可以使用 [kenv(1)](https://man.freebsd.org/cgi/man.cgi?query=kenv\&sektion=1\&format=html) 来输出所有变量。

**/boot/device.hints** 的语法是一行一个变量，使用井号（`#`）作为注释标记。每一行的格式如下：

```ini
hint.driver.unit.keyword="value"
```

第 3 阶段引导加载器的语法为：

```sh
set hint.driver.unit.keyword=value
```

其中 `driver` 是设备驱动程序名称，`unit` 是设备驱动程序的单元编号，`keyword` 是提示关键字。关键字可以包括以下选项：

* `at`：指定设备所连接的总线。
* `port`：指定要使用的 I/O 起始地址。
* `irq`：指定要使用的中断请求号。
* `drq`：指定 DMA 通道号。
* `maddr`：指定设备所占用的物理内存地址。
* `flags`：为设备设置各种标志位。
* `disabled`：如果设置为 `1`，则禁用该设备。

由于设备驱动程序可能会接受或需要更多未在此列出的提示，建议查看相关驱动程序的手册页。欲了解更多信息，请参考 [device.hints(5)](https://man.freebsd.org/cgi/man.cgi?query=device.hints\&sektion=5\&format=html)、[kenv(1)](https://man.freebsd.org/cgi/man.cgi?query=kenv\&sektion=1\&format=html)、[loader.conf(5)](https://man.freebsd.org/cgi/man.cgi?query=loader.conf\&sektion=5\&format=html) 和 [loader(8)](https://man.freebsd.org/cgi/man.cgi?query=loader\&sektion=8\&format=html)。


---

# Agent Instructions: 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:

```
GET https://handbook.bsdcn.org/di-15-zhang-freebsd-de-yin-dao-guo-cheng/15.3.-device-hints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
