6 #include <sys/device.h>
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
= {
37 * Attach for autoconfig to find.
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
50 * Handle an open request on the device.
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.
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.
71 mydevioctl(dev_t device
, u_long command
, caddr_t data
, int flags
,
75 struct mydev_params
*params
= (struct mydev_params
*)data
;
80 printf("Got number of %d and string of %s\n",
81 params
->number
, params
->string
);