PPI(4)

πŸ’– PPI(4) πŸ’–

okay bestie so this is a page from the Kernel Interfaces Manual, and it's about the ppi driver β€” no cap, it's the whole user-space interface to the ppbus parallel 'geek' port. let's get into it πŸ¦‹


✨ NAME ✨

ppi β€” user-space interface to ppbus parallel 'geek' port


🌸 SYNOPSIS 🌸

device ppi

Minor numbering: unit numbers correspond directly to ppbus numbers.

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

πŸ’… DESCRIPTION πŸ’…

The ppi driver is literally the moment for user applications that wanna mess with the state of the parallel port. it gives you easy low-speed I/O operations without the security problems that come as a free gift with using the /dev/io interface. periodt.


πŸ‘‘ PROGRAMMING INTERFACE πŸ‘‘

so every single I/O operation on the ppi interface happens through ioctl() calls. each command takes a single uint8_t argument and transfers exactly one byte of data. here's the full roster, no skips:

  • PPIGDATA, PPISDATA β€” get and set the contents of the data register. iconic duo πŸ’–
  • PPIGSTATUS, PPISSTATUS β€” get and set the contents of the status register.
  • PPIGCTRL, PPISCTRL β€” get and set the contents of the control register. the following defines correspond to bits in this register. and heads up bestie: setting a bit in the control register drives the corresponding output low.
    • STROBE
    • AUTOFEED
    • nINIT
    • SELECTIN
    • PCD
  • PPIGEPP, PPISEPP β€” get and set the contents of the EPP control register.
  • PPIGECR, PPISECR β€” get and set the contents of the ECP control register.
  • PPIGFIFO, PPISFIFO β€” read and write the ECP FIFO (8-bit operations only, don't try anything fancy 🫢).

🌈 EXAMPLES 🌈

say you wanna present the value 0x5a to the data port, drive STROBE low and then high again β€” this code fragment right here is your girl:

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);

😭 BUGS 😭

  • The inverse sense of signals is confusing. not me having to think about it twice every time πŸ’€
  • The ioctl() interface is slow, and there is no way (yet) to chain multiple operations together. fr fr, one byte at a time bestie.
  • The headers required for user applications are not installed as part of the standard system. so you're gonna have to go find them yourself, sorry πŸ₯Ί

okay that's the whole page!! this came from the <strong>Debian</strong> folks, dated <strong>January 2, 1998</strong> β€” yes she's an older queen but she still ate πŸ’…βœ¨ byeeee πŸŽ€

πŸ“¦ where this page comes from