> 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/man9/bus_read_ivar.9.md).

# BUS\_READ\_IVAR.9

`BUS_READ_IVAR` — 操作总线特定的设备实例变量

## 名称

`BUS_READ_IVAR`, `BUS_WRITE_IVAR`

## 概要

```c
#include <sys/param.h>
#include <sys/bus.h>
```

```c
int
BUS_READ_IVAR(device_t dev, device_t child, int index,
    uintptr_t *result);

int
BUS_WRITE_IVAR(device_t dev, device_t child, int index,
    uintptr_t value);
```

## 描述

这两个方法管理子设备的总线特定实例变量集合。其设计意图是每种不同类型的总线定义一组适当的实例变量（例如 ISA 总线的端口和 IRQ 等）。

这些信息可以作为结构体传递给子设备，但这使得总线难以在不强制编辑和重新编译所有驱动程序的情况下添加或删除变量，而对于厂商提供的二进制驱动程序来说，这可能无法实现。

## 返回值

成功时返回零，否则返回适当的错误码。

## 参见

[device(9)](/man/man9/device.9.md), [driver(9)](/man/man9/driver.9.md)

## 作者

本手册页由 Doug Rabson 编写。


---

# 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/man9/bus_read_ivar.9.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.
