DEVICE(9)
β¨ 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 unit number (see
device_get_unit(9)) - a verbose description, normally supplied by the driver (see
device_set_desc(9)anddevice_get_desc(9)) - a set of bus-specific variables (see
device_get_ivars(9)) - a set of driver-specific variables (see
device_get_softc(9))
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 yetDS_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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1998 Doug Rabson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms