Tying Everything Together

Now that you’re familiar with the usb_* structures and their management routines, let’s dissect a real-world USB driver.

Example 15-1 provides a terse, source-level overview of ulpt(4), the USB printer driver.

Note

To improve readability, some of the variables and functions presented in this section have been renamed and restructured from their counterparts in the FreeBSD source.

Example 15-1. ulpt.c

#include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> #include <sys/conf.h> #include <sys/bus.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/syslog.h> #include <sys/fcntl.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> #include <dev/usb/usbdi_util.h> #define ULPT_BUF_SIZE ...

Get FreeBSD Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.