DEVICE_GET_IVARS(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… DEVICE_GET_IVARS(9) β€” the kernel dev manual, bestie edition πŸŽ€

okay so this is device_get_ivars(9) from the Kernel Developer's Manual, and it's literally the tiniest little page about peeking at a device's private bus business. let's get into it ✨


🌸 NAME 🌸

device_get_ivars, device_set_ivars β€” access bus private variables

like, you're grabbing and setting the bus-private instance variables. that's the whole vibe. 🫢


✨ SYNOPSIS ✨

#include <sys/param.h>
#include <sys/bus.h>

void *
device_get_ivars(device_t dev);

void
device_set_ivars(device_t dev, void *ivar);

both of these take a device_t dev, and the setter also takes a void *ivar. that's it. that's the API. slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

The device_get_ivars() function returns the bus-specific instance variables of a device. πŸŽ€

The device_set_ivars() function sets the bus-specific instance variables of a device. πŸŽ€

so it's giving "getter and setter, but make it kernel." iconic, honestly.

Typically, only bus drivers will use these functions. like, if you're a regular client driver, this is not your main character moment β€” read the room, not the ivars. πŸ™ˆ

The kernel assumes that the bus driver will manage this memory, and no automatic memory allocation or deallocation happens. no cap: nothing is gonna malloc for you, nothing is gonna free for you. the bus driver is holding the whole memory situation down, and the kernel is just trusting them fr fr. πŸ”₯

⚠️ heads up bestie: Client drivers should access ivars through the BUS_READ_IVAR(9) interface instead. so if you're a client driver, take the scenic route through BUS_READ_IVAR(9) and leave the raw device_get_ivars() / device_set_ivars() to the bus drivers. iykyk πŸ’―

πŸ‘‘ SEE ALSO πŸ‘‘

  • device(9) β€” go read this too, bestie, it's the whole device situation 🌈

πŸ’– AUTHORS πŸ’–

This manual page was written by Doug Rabson. thank you Doug, we appreciate you, absolute legend ⭐


and that's the whole page!! short, sweet, and every single detail preserved, because we don't skip facts in this group chat. mwah πŸ’œ

~ cute sign-off ~ this gem comes from the Debian side of things, dated June 16, 1998, and yes the header/footer said DEVICE_GET_IVARS(9) both times β€” consistent queen. πŸŽ€πŸ¦‹πŸ“

πŸ“¦ where this page comes from