diff options
author | arr <arr@FreeBSD.org> | 2001-11-13 17:58:14 +0000 |
---|---|---|
committer | arr <arr@FreeBSD.org> | 2001-11-13 17:58:14 +0000 |
commit | 32b75878ad16ecfaefad1cfcb1aaacfbaaae8aee (patch) | |
tree | bb0920c58e1bd749f432295f9bbf346518c5d2ac /share/examples | |
parent | c20d0cf9eb1d9aaa5acd91f5bd3a4d5011d7b3e3 (diff) | |
download | FreeBSD-src-32b75878ad16ecfaefad1cfcb1aaacfbaaae8aee.zip FreeBSD-src-32b75878ad16ecfaefad1cfcb1aaacfbaaae8aee.tar.gz |
- Modify to make the generated device driver code work with current.
- Use M_ZERO instead of another call to bzero().
Inspired by: misc/31905
Diffstat (limited to 'share/examples')
-rwxr-xr-x | share/examples/drivers/make_device_driver.sh | 9 | ||||
-rw-r--r-- | share/examples/drivers/make_pseudo_driver.sh | 12 |
2 files changed, 11 insertions, 10 deletions
diff --git a/share/examples/drivers/make_device_driver.sh b/share/examples/drivers/make_device_driver.sh index 501bbbf..360679f 100755 --- a/share/examples/drivers/make_device_driver.sh +++ b/share/examples/drivers/make_device_driver.sh @@ -155,6 +155,7 @@ cat >${TOP}/dev/${1}/${1}.c <<DONE #include <sys/malloc.h> /* malloc region definitions */ #include <sys/module.h> #include <sys/bus.h> +#include <sys/proc.h> #include <machine/bus.h> #include <machine/resource.h> #include <machine/bus_pio.h> @@ -847,7 +848,7 @@ ${1}intr(void *arg) } static int -${1}ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +${1}ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct ${1}_softc *scp = DEV2SOFTC(dev); @@ -868,7 +869,7 @@ ${1}ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) * This should get you started */ static int -${1}open(dev_t dev, int oflags, int devtype, struct proc *p) +${1}open(dev_t dev, int oflags, int devtype, struct thread *td) { struct ${1}_softc *scp = DEV2SOFTC(dev); @@ -879,7 +880,7 @@ ${1}open(dev_t dev, int oflags, int devtype, struct proc *p) } static int -${1}close(dev_t dev, int fflag, int devtype, struct proc *p) +${1}close(dev_t dev, int fflag, int devtype, struct thread *td) { struct ${1}_softc *scp = DEV2SOFTC(dev); @@ -938,7 +939,7 @@ ${1}mmap(dev_t dev, vm_offset_t offset, int nprot) } static int -${1}poll(dev_t dev, int which, struct proc *p) +${1}poll(dev_t dev, int which, struct thread *td) { struct ${1}_softc *scp = DEV2SOFTC(dev); diff --git a/share/examples/drivers/make_pseudo_driver.sh b/share/examples/drivers/make_pseudo_driver.sh index 19c4acc..00cd519 100644 --- a/share/examples/drivers/make_pseudo_driver.sh +++ b/share/examples/drivers/make_pseudo_driver.sh @@ -47,6 +47,7 @@ cat >../../dev/${1}.c <<DONE #include <sys/kernel.h> /* SYSINIT stuff */ #include <sys/conf.h> /* cdevsw stuff */ #include <sys/malloc.h> /* malloc region definitions */ +#include <sys/proc.h> #include <machine/clock.h> /* DELAY() */ #include <sys/${1}io.h> /* ${1} IOCTL definitions */ #ifdef DEVFS @@ -126,7 +127,7 @@ do { /* the do-while is a safe way to do this grouping */ \ #define CHECKUNIT_DIAG(RETVAL) #endif /* DIAGNOSTIC */ -int ${1}ioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +int ${1}ioctl (dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) { int unit = UNIT (dev); sc_p scp = sca[unit]; @@ -148,7 +149,7 @@ int ${1}ioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) * This should get you started */ static int -${1}open(dev_t dev, int oflags, int devtype, struct proc *p) +${1}open(dev_t dev, int oflags, int devtype, struct thread *td) { int unit = UNIT (dev); sc_p scp = sca[unit]; @@ -162,7 +163,7 @@ ${1}open(dev_t dev, int oflags, int devtype, struct proc *p) } static int -${1}close(dev_t dev, int fflag, int devtype, struct proc *p) +${1}close(dev_t dev, int fflag, int devtype, struct thread *td) { int unit = UNIT (dev); sc_p scp = sca[unit]; @@ -232,7 +233,7 @@ ${1}mmap(dev_t dev, int offset, int nprot) } static int -${1}poll(dev_t dev, int which, struct proc *p) +${1}poll(dev_t dev, int which, struct thread *td) { int unit = UNIT (dev); sc_p scp = sca[unit]; @@ -262,12 +263,11 @@ ${1}_drvinit(void *unused) /* * Allocate storage for this instance . */ - scp = malloc(sizeof(*scp), M_DEVBUF, M_NOWAIT); + scp = malloc(sizeof(*scp), M_DEVBUF, M_NOWAIT | M_ZERO); if( scp == NULL) { printf("${1}%d failed to allocate strorage\n", unit); return ; } - bzero(scp, sizeof(*scp)); sca[unit] = scp; #if DEVFS scp->devfs_token = devfs_add_devswf(&${1}_cdevsw, unit, DV_CHR, |