> 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/pbio.4.md).

# pbio.4

`pbio` — 8255 并行外设接口基础

## 名称

`pbio` I/O 驱动

## 概要

`device pbio`

`在 /boot/device.hints 中： hint.pbio.0.at="isa" hint.pbio.0.port="0x360"`

`#include <dev/pbio/pbioio.h>`

## 描述

`pbio` 驱动支持直接访问运行在模式 0（简单 I/O）下的 Intel 8255A 可编程外设接口（PPI）芯片。此类接口提供 24 条数字 I/O 线。该驱动设计用于在使用 Advantech PCL-724 卡等外设时，在程序控制下执行 I/O，该卡在模式 0 下模拟 Intel 8255A PPI。据报道，其他基于 8255A 的外设（如 BMC Messsysteme PIO24II 卡）也能工作。

PPI 提供两个 8 位端口（端口 A 和端口 B）和两个 4 位端口（端口 C 上部和端口 C 下部）。每个端口都可以单独编程用于输入和（锁存）输出，并出现在设备基地 I/O 地址的不同偏移处。

一个单独的寄存器允许配置端口用于输入或输出。该设备非常简单，当输入数据到达其端子时无法可靠地探测它；因此内核配置必须指定设备的基地址。设备驱动程序提供四个字符设备，对应外设的 I/O 端口。打开设备进行读或写会自动将相应的硬件端口配置为输入或输出。在引导时，所有端口都设置为输入以避免损坏外部电路。

一组 ioctl(2) 请求允许在驱动级别高效执行轮询输入和定速输出，无需昂贵的用户/内核上下文切换。驱动程序可以以三种不同方式执行 I/O：

**Basic** 读或写操作在以总线速度向端口读或写数据后立即返回。

**Paced** 数据按单独的 ioctl(2) 调用指定的间隔从端口传输或传输到端口。

**Differential** （仅输入。）仅返回与前一个端口值不同的端口值。

定速间隔以 *Hz* 为单位指定。设置 `n` 秒的定速将导致每 `n` 秒最多读取或写入一个值。单字节读/写操作将至少需要 `n` 秒才能完成。

支持以下 ioctl(2) 调用：

**`PBIO_SETDIFF`** 接受指向整数的指针作为第三个参数，如果整数非零，则将驱动设置为差分输入。输入定速速度决定驱动程序检查端口以查找更改值的周期性间隔。

**`PBIO_GETDIFF`** 接受指向整数的指针作为第三个参数，并将整数设置为差分输入的最后设置值。

**`PBIO_SETIPACE`** 接受指向整数的指针作为第三个参数，并将驱动程序的输入定速速度设置为该整数的值。

**`PBIO_GETIPACE`** 接受指向整数的指针作为第三个参数，并将整数设置为输入定速的最后设置值。

**`PBIO_SETOPACE`** 接受指向整数的指针作为第三个参数，并将驱动程序的输出定速速度设置为该整数的值。

**`PBIO_GETOPACE`** 接受指向整数的指针作为第三个参数，并将整数设置为输出定速的最后设置值。

## 文件

**`/dev/pbio0a`** 端口 A（8 位 I/O）。 **`/dev/pbio0b`** 端口 B（8 位 I/O）。 **`/dev/pbio0ch`** 端口 C 上部（4 位 I/O）。 **`/dev/pbio0cl`** 端口 C 下部（4 位 I/O）。

## 参见

> Diomidis Spinellis, "The information furnace: Consolidated home control", *Personal and Ubiquitous Computing*, 7, 1, pp. 53-69, 2003.

## 历史

`pbio` 设备首次用于 FreeBSD 4.1。

## 作者

Diomidis D. Spinellis <dds@aueb.gr>

## 缺陷

PCL-724 卡的输入之一可以选择性地接线以生成中断。不支持此功能。


---

# 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/pbio.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.
