Now you must edit ``/usr/src/sys/i386/i386/conf.c'' to make an entry for your driver. Somewhere near the top, you need to declare your entry points. The entry for the joystick driver is:
#include "joy.h" #if NJOY > 0 d_open_t joyopen; d_close_t joyclose; d_rdwr_t joyread; d_ioctl_t joyioctl; #else #define joyopen nxopen #define joyclose nxclose #define joyread nxread #define joyioctl nxioctl #endif
This either defines your entry points, or null entry points which will return ENXIO when called (the #else clause).
The include file ``joy.h'' is automatically generated by config(8) when the kernel build tree is created. This usually has only one line like:
#define NJOY 1
#define NJOY 0
You must additionally add a slot to either cdevsw[], or to bdevsw[], depending on whether it is a character device or a block device, or both if it is a block device with a raw interface. The entry for the joystick driver is:
/* open, close, read, write, ioctl, stop, reset, ttys, select, mmap, strat */ struct cdevsw cdevsw[] = { ... { joyopen, joyclose, joyread, nowrite, /*51*/ joyioctl, nostop, nullreset, nodevtotty,/*joystick */ seltrue, nommap, NULL}, ... }
Order is what determines the major number of your device. Which is why there will always be an entry for your driver, either null entry points, or actual entry points. It is probably worth noting that this is significantly different from SCO and other system V derivatives, where any device can (in theory) have any major number. This is largely a convenience on FreeBSD, due to the way device nodes are created. More on this later.