Changeset View
Changeset View
Standalone View
Standalone View
share/examples/drivers/make_device_driver.sh
| Show All 28 Lines | |||||
| if [ "X${2}" = "X" ]; then | if [ "X${2}" = "X" ]; then | ||||
| TOP=`cd /sys; pwd -P` | TOP=`cd /sys; pwd -P` | ||||
| echo "Using ${TOP} as the path to the kernel sources!" | echo "Using ${TOP} as the path to the kernel sources!" | ||||
| else | else | ||||
| TOP=${2} | TOP=${2} | ||||
| fi | fi | ||||
| UPPER=`echo ${1} |tr "[:lower:]" "[:upper:]"` | UPPER=`echo ${1} |tr "[:lower:]" "[:upper:]"` | ||||
| RCS_KEYWORD=FreeBSD | |||||
| if [ -d ${TOP}/modules/${1} ]; then | if [ -d ${TOP}/modules/${1} ]; then | ||||
| echo "There appears to already be a module called ${1}" | echo "There appears to already be a module called ${1}" | ||||
| echo -n "Should it be overwritten? [Y]" | echo -n "Should it be overwritten? [Y]" | ||||
| read VAL | read VAL | ||||
| if [ "-z" "$VAL" ]; then | if [ "-z" "$VAL" ]; then | ||||
| VAL=YES | VAL=YES | ||||
| fi | fi | ||||
| case ${VAL} in | case ${VAL} in | ||||
| Show All 38 Lines | |||||
| dev/${1}/${1}.c optional ${1} | dev/${1}/${1}.c optional ${1} | ||||
| DONE | DONE | ||||
| ####################################################################### | ####################################################################### | ||||
| # Then create a configuration file for a kernel that contains this driver. | # Then create a configuration file for a kernel that contains this driver. | ||||
| ####################################################################### | ####################################################################### | ||||
| cat >${TOP}/i386/conf/${UPPER} <<DONE | cat >${TOP}/i386/conf/${UPPER} <<DONE | ||||
| # Configuration file for kernel type: ${UPPER} | # Configuration file for kernel type: ${UPPER} | ||||
| # \$${RCS_KEYWORD}$ | |||||
| files "${TOP}/conf/files.${UPPER}" | files "${TOP}/conf/files.${UPPER}" | ||||
| include GENERIC | include GENERIC | ||||
| ident ${UPPER} | ident ${UPPER} | ||||
| DONE | DONE | ||||
| Show All 35 Lines | |||||
| * SUCH DAMAGE. | * SUCH DAMAGE. | ||||
| */ | */ | ||||
| /* | /* | ||||
| * http://www.daemonnews.org/200008/isa.html is required reading. | * http://www.daemonnews.org/200008/isa.html is required reading. | ||||
| * hopefully it will make it's way into the handbook. | * hopefully it will make it's way into the handbook. | ||||
| */ | */ | ||||
| #include <sys/cdefs.h> | |||||
| __FBSDID("\$${RCS_KEYWORD}$"); | |||||
| #include <sys/param.h> | #include <sys/param.h> | ||||
| #include <sys/systm.h> | #include <sys/systm.h> | ||||
| #include <sys/conf.h> /* cdevsw stuff */ | #include <sys/conf.h> /* cdevsw stuff */ | ||||
| #include <sys/kernel.h> /* SYSINIT stuff */ | #include <sys/kernel.h> /* SYSINIT stuff */ | ||||
| #include <sys/uio.h> /* SYSINIT stuff */ | #include <sys/uio.h> /* SYSINIT stuff */ | ||||
| #include <sys/malloc.h> /* malloc region definitions */ | #include <sys/malloc.h> /* malloc region definitions */ | ||||
| #include <sys/module.h> | #include <sys/module.h> | ||||
| #include <sys/bus.h> | #include <sys/bus.h> | ||||
| ▲ Show 20 Lines • Show All 795 Lines • ▼ Show 20 Lines | |||||
| DONE | DONE | ||||
| if [ ! -d ${TOP}/modules/${1} ]; then | if [ ! -d ${TOP}/modules/${1} ]; then | ||||
| mkdir -p ${TOP}/modules/${1} | mkdir -p ${TOP}/modules/${1} | ||||
| fi | fi | ||||
| cat >${TOP}/modules/${1}/Makefile <<DONE | cat >${TOP}/modules/${1}/Makefile <<DONE | ||||
| # ${UPPER} Loadable Kernel Module | # ${UPPER} Loadable Kernel Module | ||||
| # | |||||
| # \$${RCS_KEYWORD}: $ | |||||
| .PATH: \${.CURDIR}/../../dev/${1} | .PATH: \${.CURDIR}/../../dev/${1} | ||||
| KMOD = ${1} | KMOD = ${1} | ||||
| SRCS = ${1}.c | SRCS = ${1}.c | ||||
| SRCS += opt_inet.h device_if.h bus_if.h pci_if.h isa_if.h | SRCS += opt_inet.h device_if.h bus_if.h pci_if.h isa_if.h | ||||
| # You may need to do this is your device is an if_xxx driver. | # You may need to do this is your device is an if_xxx driver. | ||||
| opt_inet.h: | opt_inet.h: | ||||
| ▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines | |||||