Add shell script to copy files to source tree
[eleutheria.git] / cdev / mydev.c
blob4d84376e19575658a3dd8a0922e450c895fad615
1 #include <sys/param.h>
2 #include <sys/systm.h>
3 #include <sys/proc.h>
4 #include <sys/errno.h>
5 #include <sys/ioctl.h>
6 #include <sys/device.h>
7 #include <sys/conf.h>
8 #include <sys/mydev.h>
10 struct mydev_softc {
11 struct device mydev_dev;
14 /* Autoconfiguration glue */
15 void mydevattach(struct device *parent, struct device *self, void *aux);
16 int mydevopen(dev_t device, int flags, int fmt, struct lwp *process);
17 int mydevclose(dev_t device, int flags, int fmt, struct lwp *process);
18 int mydevioctl(dev_t device, u_long command, caddr_t data,
19 int flags, struct lwp *process);
21 /* Just define the character device handlers because that is all we need */
22 const struct cdevsw mydev_cdevsw = {
23 mydevopen,
24 mydevclose,
25 noread,
26 nowrite,
27 mydevioctl,
28 nostop,
29 notty,
30 nopoll,
31 nommap,
32 nokqfilter,
33 0 /* int d_type; */
37 * Attach for autoconfig to find.
39 void
40 mydevattach(struct device *parent, struct device *self, void *aux)
43 * Nothing to do for mydev, this is where resources that
44 * need to be allocated/initialised before open is called
45 * can be set up.
50 * Handle an open request on the device.
52 int
53 mydevopen(dev_t device, int flags, int fmt, struct lwp *process)
55 return 0; /* This always succeeds */
59 * Handle the close request for the device.
61 int
62 mydevclose(dev_t device, int flags, int fmt, struct lwp *process)
64 return 0; /* Again this always succeeds */
68 * Handle the ioctl for the device.
70 int
71 mydevioctl(dev_t device, u_long command, caddr_t data, int flags,
72 struct lwp *process)
74 int error;
75 struct mydev_params *params = (struct mydev_params *)data;
77 error = 0;
78 switch (command) {
79 case MYDEVTEST:
80 printf("Got number of %d and string of %s\n",
81 params->number, params->string);
82 break;
84 default:
85 error = ENODEV;
88 return error;