O'Reilly logo

FreeBSD Device Drivers by Joseph Kong

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required