diff --git a/share/examples/drivers/make_device_driver.sh b/share/examples/drivers/make_device_driver.sh index 7d1776d686a..e8249770a07 100755 --- a/share/examples/drivers/make_device_driver.sh +++ b/share/examples/drivers/make_device_driver.sh @@ -2,6 +2,9 @@ # This writes a skeleton driver and puts it into the kernel tree for you #arg1 is lowercase "foo" # +# It also creates a directory under /usr/src/lkm to help you create +#loadable kernel modules, though without much use except for development. +# # Trust me, RUN THIS SCRIPT :) # #-------cut here------------------ @@ -13,6 +16,11 @@ then exit 1 fi +if [ -d /usr/src/lkm ] +then + mkdir /usr/src/lkm/${1} +fi + UPPER=`echo ${1} |tr "[:lower:]" "[:upper:]"` cat >files.${UPPER} <${UPPER} <>${UPPER} @@ -37,7 +45,7 @@ cat >../isa/${1}.c < +#include +#include + +MOD_DEV (${1}, LM_DT_CHAR, CDEV_MAJOR, &${1}_cdevsw); + +static struct isa_device dev = {0, &${1}driver, BASE_IO, IRQ, DMA, (caddr_t) PHYS_IO, PHYS_IO_SIZE, INT_INT, 0, FLAGS, 0, 0, 0, 0, 1, 0, 0}; + +static int +${1}_load (struct lkm_table *lkmtp, int cmd) +{ + if (${1}probe (&dev)) { + ${1}attach (&dev); + uprintf ("${1} driver loaded\n"); + uprintf ("${1}: interrupts not hooked\n"); + return 0; + } else { + uprintf ("${1} driver: probe failed\n"); + return 1; + } +} + +static int +${1}_unload (struct lkm_table *lkmtp, int cmd) +{ + uprintf ("${1} driver unloaded\n"); + return 0; +} + +static int +${1}_stat (struct lkm_table *lkmtp, int cmd) +{ + return 0; +} + +int +${1}_mod (struct lkm_table *lkmtp, int cmd, int ver) +{ + MOD_DISPATCH(${1}, lkmtp, cmd, ver, + ${1}_load, ${1}_unload, ${1}_stat); +} + +#endif /* ${UPPER}_MODULE */ DONE @@ -379,6 +438,45 @@ cat >../../sys/${1}io.h </usr/src/lkm/${1}/Makefile < ${1}.h + +afterinstall: + \${INSTALL} -c -o \${BINOWN} -g \${BINGRP} -m \${BINMODE} \ + \${.CURDIR}/${1} \${DESTDIR}/usr/bin + +.include +DONE +fi + config ${UPPER} cd ../../compile/${UPPER} make depend @@ -388,9 +486,6 @@ exit #--------------end of script--------------- # -#you also need to add an entry into the cdevsw[] -#array in conf.c, but it's too hard to do in a script.. -# #edit to your taste.. # #