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

A (Somewhat) Simple Example

Now that you’re familiar with the CAM subsystem, let’s work through some code. After that, I’ll detail the different CAM-related functions.

Example 14-1 is a SIM for a pseudo-HBA (taken from the mfi(4) code base).

Note

Take a quick look at this code and try to discern some of its structure. If you don’t understand all of it, don’t worry; an explanation follows.

Example 14-1. mfi_cam.c

#include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> #include <sys/selinfo.h> #include <sys/bus.h> #include <sys/conf.h> #include <sys/bio.h> #include <sys/malloc.h> #include <sys/uio.h> #include <cam/cam.h> #include <cam/cam_ccb.h> #include <cam/cam_debug.h> #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> ...

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