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
)
42 /* nothing to do for mydev, this is where resources that
43 need to be allocated/initialised before open is called
48 * Handle an open request on the device.
51 mydevopen(dev_t device
, int flags
, int fmt
, struct lwp
*process
)
53 return 0; /* this always succeeds */
57 * Handle the close request for the device.
60 mydevclose(dev_t device
, int flags
, int fmt
, struct lwp
*process
)
62 return 0; /* again this always succeeds */
66 * Handle the ioctl for the device
69 mydevioctl(dev_t device
, u_long command
, caddr_t data
, int flags
,
73 struct mydev_params
*params
= (struct mydev_params
*)data
;
78 printf("Got number of %d and string of %s\n",
79 params
->number
, params
->string
);