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

# ppi.4

`ppi` — ppbus 并行“极客”端口的用户空间接口

## 名称

`ppi`

## 概要

`device ppi`

`次编号：单元号直接对应于 ppbus 编号。`

`#include <dev/ppbus/ppi.h>`

`#include <dev/ppbus/ppbconf.h>`

## 描述

`ppi` 驱动为用户应用程序提供了操纵并口状态的便捷手段，可轻松进行低速 I/O 操作，而不会带来使用 `/dev/io` 接口固有的安全问题。

## 编程接口

`ppi` 接口上的所有 I/O 都使用 Fn ioctl 调用执行。每个命令接受一个 Ft uint8\_t 参数，传输一字节数据。以下命令可用：

**`STROBE`** **`AUTOFEED`** **`nINIT`** **`SELECTIN`** **`PCD`**

**`PPIGDATA , PPISDATA`** 获取和设置数据寄存器的内容。

**`PPIGSTATUS , PPISSTATUS`** 获取和设置状态寄存器的内容。

**`PPIGCTRL , PPISCTRL`** 获取和设置控制寄存器的内容。以下定义对应于此寄存器中的位。在控制寄存器中设置某位会驱动相应输出为低电平。

**`PPIGEPP , PPISEPP`** 获取和设置 EPP 控制寄存器的内容。

**`PPIGECR , PPISECR`** 获取和设置 ECP 控制寄存器的内容。

**`PPIGFIFO , PPISFIFO`** 读取和写入 ECP FIFO（仅 8 位操作）。

## 实例

要将值 0x5a 呈现到数据端口，驱动 STROBE 为低电平然后再为高电平，可使用以下代码片段：

```
int		fd;
uint8_t		val;
val = 0x5a;
ioctl(fd, PPISDATA, &val);
ioctl(fd, PPIGCTRL, &val);
val |= STROBE;
ioctl(fd, PPISCTRL, &val);
val &= ~STROBE;
ioctl(fd, PPISCTRL, &val);
```

## 缺陷

信号的反相意义容易引起混淆。

Fn ioctl 接口较慢，并且（目前）无法将多个操作链接在一起。

用户应用程序所需的头文件未作为标准系统的一部分安装。


---

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