DEVICE(9)

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

✨ DEVICE(9) ✨

okay bestie, buckle up, because we're about to get into device(9) from the Kernel Developer's Manual and honestly it's kind of the main character of the whole kernel πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

typedef struct _device *device_t;

that's it. that's the whole synopsis. a pointer type and a dream ✨


🌸 DESCRIPTION 🌸

so a device object is basically the kernel's abstract representation of an actual piece of hardware attached to the system β€” think an expansion card, the bus that card is plugged into, the disk drives hooked up to that expansion card, like the whole little ecosystem 🫢

the system defines exactly one device for you already, and its name is root_bus. every other device gets created dynamically during autoconfiguration, no cap. normally the devices that represent top-level buses in the system (ISA, PCI etc.) get attached directly to root_bus, and everything else gets added as children of whatever bus it actually belongs to. it's giving family tree 🧚

and speaking of which β€” the devices in a system literally form a tree. every device except root_bus has a parent (peep device_get_parent(9)). and any device can have children attached to it too (see device_add_child(9), device_add_child_ordered(9), device_find_child(9), device_get_children(9), and device_delete_child(9)). iconic hierarchy behavior, we love to see it πŸ‘‘

once a device has been successfully probed and attached to the system, it also gets a driver (see device_get_driver(9) and driver(9)) and a devclass (see device_get_devclass(9) and devclass(9)). the way that a device just collects attributes... obsessed 😭

various other attributes of the device include:

a whole personality, honestly 🌈


πŸ’– the states πŸ’–

devices can be in one of several states, and yes you need to know all of them:

  • DS_NOTPRESENT β€” the device has not been probed for existence, or the probe straight up failed πŸ’€
  • DS_ALIVE β€” the probe succeeded but the device isn't attached yet
  • DS_ATTACHED β€” the device has been successfully attached, slay ✨
  • DS_BUSY β€” the device is currently open

you can find out where a device is at in its little journey by calling device_get_state(9). vibe check for hardware πŸ¦‹


🌟 SEE ALSO 🌟


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Doug Rabson. thank you Doug, king behavior πŸ«‘πŸ’œ


ok that's the whole page bestie, every flag-less detail intact, no cap. go forth and probe responsibly 🌸

Debian Β· January 15, 2017 Β· DEVICE(9) β€” mwah, that's the source, the date, and the section, all accounted for πŸŽ€πŸ’–

πŸ“¦ where this page comes from