mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
2.2 KiB
2.2 KiB
APIs by Driver Lifecycle Phase
A reverse index to Appendix A. When you are writing or auditing a particular phase of a driver, these are the APIs that usually belong there.
Module load
MODULE_VERSION,MODULE_DEPEND- Static
MALLOC_DEFINE - Static
SYSCTL_NODE SDT_PROVIDER_DEFINE- One-time event-handler registration
Probe
device_get_parent,device_get_nameunit- Match-scoring return values:
BUS_PROBE_DEFAULT,BUS_PROBE_GENERIC,BUS_PROBE_SPECIFIC,BUS_PROBE_LOW_PRIORITY,ENXIO
Attach
device_get_softcmallocandMALLOC_DEFINEtagsmtx_init,sx_init,rm_init,cv_init,sema_initbus_alloc_resourceorbus_alloc_resource_anybus_spacesetup throughrman_get_bustagandrman_get_bushandlebus_dma_tag_create,bus_dmamap_createcallout_init,TASK_INIT,taskqueue_createwhen neededbus_setup_intr(as the last attach step)make_dev_sdevice_get_sysctl_ctx,SYSCTL_ADD_*uma_zcreate- Driver-specific event-handler registration
Normal operation
d_open,d_close,d_read,d_write,d_ioctl,d_poll,d_kqfilteruiomove,copyin,copyout,copyinstrbus_space_read_N,bus_space_write_N,bus_space_barrierbus_dmamap_load,bus_dmamap_sync,bus_dmamap_unloadmtx_lock,mtx_unlock,sx_slock,sx_xlockcv_wait,cv_signal,cv_broadcastatomic_*callout_reset,taskqueue_enqueuedevice_printf,log,KASSERT,SDT_PROBE
Detach (reverse of attach)
bus_teardown_intr(first)destroy_devcallout_draintaskqueue_drain_allandtaskqueue_freefor private queuesbus_dmamap_unload,bus_dmamap_destroy,bus_dma_tag_destroybus_release_resourcefor every resource from attachcv_destroy,sx_destroy,mtx_destroy,rm_destroy,sema_destroyuma_zdestroy- Driver-specific event-handler deregistration
- Final
freeandcontigfree
Module unload
- Refuse unload if state remains (Newbus usually handles this for you)
- Static resources declared at module load clean themselves up
Print this page
This index is intentionally short. Keep it next to your monitor, or export it to a single-page PDF. It should fit on one printed page in almost any font.