xref: /freebsd-13.1/share/examples/drivers/README (revision 2fe7440f)
102aa3ed4SBill Fumerola$FreeBSD$
2bffe3895SJulian Elischer
302aa3ed4SBill FumerolaAuthor: Julian Elischer
402aa3ed4SBill Fumerola
502aa3ed4SBill FumerolaThe files in this directory are shell scripts.
6bffe3895SJulian Elischer
7bffe3895SJulian ElischerThey will, when run, create an example skeleton driver
8bffe3895SJulian Elischerfor you. You can use this driver as a starting point for
9bffe3895SJulian Elischerwriting drivers for your own devices. They have all the hooks needed
1002aa3ed4SBill Fumerolafor initialization, probing, attaching, as well as DEVFS
11bffe3895SJulian Elischernode creation. They also create sample ioctl commands and a sample
12bffe3895SJulian Elischerioctl definition .h file in /sys/sys. In other words they are fully
13bffe3895SJulian Elischerfunctional in a 'skeleton' sort of a way. They support multiple devices
1402aa3ed4SBill Fumerolaso that you may have several of your 'foobar' devices probed and attached
15bffe3895SJulian Elischerat once.
16bffe3895SJulian Elischer
17bffe3895SJulian ElischerI expect that these scripts will improve with time.
18bffe3895SJulian Elischer
19bffe3895SJulian ElischerAt present these scripts also link the newly created driver into
20bffe3895SJulian Elischerthe kernel sources in /sys. Possibly a better way would be
21bffe3895SJulian Elischerto make them interactive. (and ask what kernel tree to use as well as
22bffe3895SJulian Elischera name for the driver.).
23bffe3895SJulian Elischer
24bffe3895SJulian ElischerThere are presently two scripts.
25bffe3895SJulian ElischerOne for making a real device driver for ISA devices, and
26bffe3895SJulian Elischerone for making a device driver for pseudo devices (e.g. /dev/null).
27bffe3895SJulian ElischerHopefully they will be joined by similar scripts for creating
28*2fe7440fSWarner Loshskeletons for PCI devices as well.
29bffe3895SJulian Elischer
30bffe3895SJulian ElischerGive them a single argument: the name of the driver.
31bffe3895SJulian ElischerThey will use this given name in many places within the driver,
32bffe3895SJulian Elischerboth in lower and upper case form.  (conforming to normal usage).
33bffe3895SJulian Elischer
34bffe3895SJulian ElischerThe skeleton driver should already link with the kernel
35bffe3895SJulian Elischerand in fact the shell script will compile a kernel with the new
36bffe3895SJulian Elischerdrive linked in..  The new kernel should still be
37bffe3895SJulian Elischerrunnable and the new driver should be
38bffe3895SJulian Elischerfully callable (once you get your device to probe).
39bffe3895SJulian ElischerYou should simply edit the driver and continue to use
40bffe3895SJulian Elischer'make' (as done in the script) until your driver does what you want.
41bffe3895SJulian Elischer
42bffe3895SJulian ElischerThe driver will end up in /sys/i386/isa for the device driver script,
43bffe3895SJulian Elischerand in /sys/dev for the pseudo driver script.
44