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