PBIO(4)

πŸ’– PBIO(4) πŸ’–

okay so bestie, welcome to the i386 Kernel Interfaces Manual β€” yes this is a kernel page, and yes we're gonna make it cute. it's giving "hardware driver but make it a group chat". let's go ✨


🌸 NAME 🌸

pbio β€” the 8255 parallel peripheral interface basic I/O driver. that's it, that's the name, slay πŸŽ€


✨ SYNOPSIS ✨

device pbio

and in /boot/device.hints:

hint.pbio.0.at="isa"
hint.pbio.0.port="0x360"

plus you gotta pull in the header, like:

#include <dev/pbio/pbioio.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

so the pbio driver gives you direct access to the Intel 8255A programmable peripheral interface (PPI) chip, running in mode 0 (that's the simple I/O mode, no drama). this kind of interface hands you 24 digital I/O lines and honestly? iconic.

the driver is built for doing I/O under program control, using peripherals like the Advantech PCL-724 card, which emulates the Intel 8255A PPI in mode 0. and get this β€” other 8255A-based peripherals, like the BMC Messsysteme PIO24II card, have also been reported to work. no cap πŸ’…

the PPI has:

  • two 8-bit ports β€” port A and port B 🫢
  • two 4-bit ports β€” port C upper and port C lower ✨

each port can be individually programmed for input and (latched) output, and each one shows up at a different offset of the device's base I/O address. cute, organized, we love that for us.

a separate register is what lets you configure ports for input or output. now here's the tea 😭 β€” the device is so simple that reliably probing for it when input data arrives at its terminals is impossible. so the kernel configuration has to specify the device's base address. no guessing, bestie.

the driver provides four character devices, one for each of the peripheral's I/O ports. opening a device for read or write automatically configures the corresponding hardware port for input or output. and at boot time, all ports are set configured for input β€” specifically to avoid damaging external circuitry. protecting the hardware first? main character energy πŸ‘‘

the ioctl(2) glow-up

a set of ioctl(2) requests let you do polled input and paced output efficiently at the driver level, without expensive user/kernel context switching. literally so efficient.

the driver can do I/O in three different ways:

  • Basic β€” the read or write operation returns immediately after reading or writing the data to the port, at bus speed. fast, no chill, we stan.
  • Paced β€” data is transferred from or to the port at intervals specified by a separate ioctl(2) call. patient. deliberate. gorgeous.
  • Differential β€” (input only!) only port values that differ from the previous port value are returned. it's giving "only the news that's actually new".

the pacing interval is specified in Hz unit increments. setting a pace of n seconds will result in no more than one value being read or written every n seconds. and single byte read/write operations will take at least n seconds to complete. so yeah, don't be in a rush 🐒

πŸŽ€ the ioctl(2) calls we support πŸŽ€

  • PBIO_SETDIFF β€” takes a pointer to an integer as the third argument, and sets the driver for differential input if that integer is non-zero. the input pace speed is what determines the periodic interval the driver uses to check the port for a changed value.
  • PBIO_GETDIFF β€” takes a pointer to an integer as the third argument, and sets that integer to the last set value for differential input.
  • PBIO_SETIPACE β€” takes a pointer to an integer as the third argument, and sets the driver's input pacing speed to the value of that integer.
  • PBIO_GETIPACE β€” takes a pointer to an integer as the third argument, and sets that integer to the last set value for the input pace.
  • PBIO_SETOPACE β€” takes a pointer to an integer as the third argument, and sets the driver's output pacing speed to the value of that integer.
  • PBIO_GETOPACE β€” takes a pointer to an integer as the third argument, and sets that integer to the last set value for the output pace.

πŸ“ FILES πŸ“

  • /dev/pbio0a β€” Port A (8 bit I/O).
  • /dev/pbio0b β€” Port B (8 bit I/O).
  • /dev/pbio0ch β€” Port C upper (4 bit I/O).
  • /dev/pbio0cl β€” Port C lower (4 bit I/O).

🌈 SEE ALSO 🌈

Diomidis Spinellis, β€œThe information furnace: Consolidated home control”, Personal and Ubiquitous Computing, 1, 7, 53-69, 2003.


πŸ’œ HISTORY πŸ’œ

the pbio device was first used under FreeBSD 4.1. a vintage queen πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

Diomidis D. Spinellis <dds@aueb.gr> β€” thank you for your service, king 🫢


πŸ’€ BUGS πŸ’€

one of the PCL-724 card's inputs can optionally be wired to generate an interrupt. > this feature is not supported. 😭 so close, yet so far.


and that's the whole page bestie!! this one came from the Debian crew, dated January 14, 2005 β€” so if you're reading this in the year of our lord 2005, hi, hope the PPI is treating you well πŸ’– mwah, bye!! βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from