pciconfig_read(2)

๐Ÿ’– pciconfig_read(2) โ€” the manual, but make it slay ๐Ÿ’–

okay bestie, gather round, because today we're talking about three syscalls from the System Calls Manual: pciconfig_read, pciconfig_write, and pciconfig_iobase ๐Ÿซถ They're all about pci device information handling, and ngl, most of you will never need them. But knowledge is free, so let's go ๐Ÿ’…


๐ŸŒธ LIBRARY ๐ŸŒธ

Standard C library (libc, -lc) โ€” yes queen, it's just libc, we love a basic-in-a-good-way moment โœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <pci.h>

int pciconfig_read(unsigned long bus, unsigned long dfn,
                   unsigned long off, unsigned long size,
                   unsigned char *buf);
int pciconfig_write(unsigned long bus, unsigned long dfn,
                   unsigned long off, unsigned long size,
                   unsigned char *buf);
int pciconfig_iobase(int which, unsigned long bus,
                   unsigned long devfn);

look at those signatures, they're giving very โœจ low-level โœจ energy, and honestly? iconic ๐Ÿ‘‘


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So here's the tea ๐Ÿ“: most of the talking-to-PCI-devices business is already handled by the kernel PCI layer. Which means these calls should not normally need to be accessed from user space. Like, they exist, but they're not the main characters โ€” they're the background extras, iykyk.

pciconfig_read()

Reads to buf from device dev at offset off value. That's the whole vibe: you point at a device, an offset, and a buffer, and the info flows into your buf ๐Ÿงš

pciconfig_write()

Writes from buf to device dev at offset off value. Same energy, opposite direction ๐Ÿ’ซ

pciconfig_iobase()

You hand it a bus/devfn pair and you get back a physical address for whichever of these you asked about:

  • the memory offset (for things like prep, this is 0xc0000000 ๐Ÿ‘€)
  • the IO base for PIO cycles
  • or the ISA holes, if any

๐Ÿ’€ RETURN VALUE ๐Ÿ’€

pciconfig_read()

On success, zero is returned. On error, -1 is returned and errno is set to indicate the error.

pciconfig_write()

On success, zero is returned. On error, -1 is returned and errno is set to indicate the error.

pciconfig_iobase()

Returns information on locations of various I/O regions in physical memory according to the which value. The values for which are: IOBASE_BRIDGE_NUMBER, IOBASE_MEMORY, IOBASE_IO, IOBASE_ISA_IO, IOBASE_ISA_MEM. Pick your fighter, bestie ๐ŸŒˆ


๐Ÿ˜ญ ERRORS ๐Ÿ˜ญ

  • EINVAL โ€” the size value is invalid. This does not apply to pciconfig_iobase().
  • EIO โ€” I/O error. classic.
  • ENODEV โ€” for pciconfig_iobase(), the "hose" value is NULL. For the other calls, it means the slot could not be found ๐Ÿ”
  • ENOSYS โ€” the system has not implemented these calls (CONFIG_PCI not defined). the kernel said "not today" ๐Ÿ™ˆ
  • EOPNOTSUPP โ€” this return value is valid only for pciconfig_iobase(). It's returned if the value for which is invalid.
  • EPERM โ€” the user does not have the CAP_SYS_ADMIN capability. This does not apply to pciconfig_iobase().
fr fr kings and queens, CAP_SYS_ADMIN is not a vibe you can just manifest. either you have it or you don't ๐Ÿ’…

๐ŸŒŸ STANDARDS ๐ŸŒŸ

Linux. that's it, that's the standard ๐Ÿ‡ซ๐Ÿ‡ฎโœจ


๐Ÿ“œ HISTORY ๐Ÿ“œ

Linux 2.0.26 / 2.1.11. ancient. vintage. lowkey a museum piece ๐Ÿ›๏ธ


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


and that's the whole page, bestie โ€” go forth and don't casually poke at PCI devices from user space, the kernel's got it ๐Ÿซถ

mwah ๐Ÿ’– stay slay, stay on the physical memory,

โœจ Linux man-pages 6.20 โ€” 2026-02-08 โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms