2 * Copyright (c) 2003 Matthew Dillon <dillon@backplane.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $DragonFly: src/sys/sys/device.h,v 1.2 2004/05/19 22:53:02 dillon Exp $
29 #ifndef _SYS_DEVICE_H_
30 #define _SYS_DEVICE_H_
32 #ifndef _SYS_MSGPORT_H_
33 #include <sys/msgport.h>
37 * This structure is at the base of every CDEVSW port message
45 * int d_open(dev_t dev, int oflags, int devtype, thread_t td)
55 * int d_close(dev_t dev, int fflag, int devtype, thread_t td)
57 struct cdevmsg_close {
65 * void d_strategy(struct buf *bp)
67 struct cdevmsg_strategy {
73 * int d_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, thread_t td)
75 struct cdevmsg_ioctl {
84 * void d_dump(dev_t dev)
94 * int d_psize(dev_t dev)
96 struct cdevmsg_psize {
102 * int d_read(dev_t dev, struct uio *uio, int ioflag)
104 struct cdevmsg_read {
111 * int d_write(dev_t dev, struct uio *uio, int ioflag)
113 struct cdevmsg_write {
120 * int d_poll(dev_t dev, int events, thread_t td)
122 struct cdevmsg_poll {
129 * int d_kqfilter(dev_t dev, struct knote *kn)
131 struct cdevmsg_kqfilter {
138 * int d_mmap(dev_t dev, vm_offset_t offset, int nprot)
140 struct cdevmsg_mmap {
144 int result; /* page number */
148 struct lwkt_msg am_lmsg;
149 struct cdevmsg am_msg;
150 struct cdevmsg_open am_open;
151 struct cdevmsg_close am_close;
152 struct cdevmsg_strategy am_strategy;
153 struct cdevmsg_ioctl am_ioctl;
154 struct cdevmsg_dump am_dump;
155 struct cdevmsg_psize am_psize;
156 struct cdevmsg_read am_read;
157 struct cdevmsg_write am_write;
158 struct cdevmsg_poll am_poll;
159 struct cdevmsg_kqfilter am_kqfilter;
160 struct cdevmsg_mmap am_mmap;
163 typedef union cdevallmsg *cdevallmsg_t;
164 typedef struct cdevmsg *cdevmsg_t;
165 typedef struct cdevmsg_open *cdevmsg_open_t;
166 typedef struct cdevmsg_close *cdevmsg_close_t;
167 typedef struct cdevmsg_strategy *cdevmsg_strategy_t;
168 typedef struct cdevmsg_ioctl *cdevmsg_ioctl_t;
169 typedef struct cdevmsg_dump *cdevmsg_dump_t;
170 typedef struct cdevmsg_psize *cdevmsg_psize_t;
171 typedef struct cdevmsg_read *cdevmsg_read_t;
172 typedef struct cdevmsg_write *cdevmsg_write_t;
173 typedef struct cdevmsg_poll *cdevmsg_poll_t;
174 typedef struct cdevmsg_kqfilter *cdevmsg_kqfilter_t;
175 typedef struct cdevmsg_mmap *cdevmsg_mmap_t;
177 #define CDEV_CMD_OPEN (MSG_CMD_CDEV|0x0001)
178 #define CDEV_CMD_CLOSE (MSG_CMD_CDEV|0x0002)
179 #define CDEV_CMD_STRATEGY (MSG_CMD_CDEV|0x0003)
180 #define CDEV_CMD_IOCTL (MSG_CMD_CDEV|0x0004)
181 #define CDEV_CMD_DUMP (MSG_CMD_CDEV|0x0005)
182 #define CDEV_CMD_PSIZE (MSG_CMD_CDEV|0x0006)
183 #define CDEV_CMD_READ (MSG_CMD_CDEV|0x0007)
184 #define CDEV_CMD_WRITE (MSG_CMD_CDEV|0x0008)
185 #define CDEV_CMD_POLL (MSG_CMD_CDEV|0x0009)
186 #define CDEV_CMD_KQFILTER (MSG_CMD_CDEV|0x000A)
187 #define CDEV_CMD_MMAP (MSG_CMD_CDEV|0x000B)
193 const char *dev_dname(dev_t dev);
194 struct lwkt_port *dev_dport(dev_t dev);
195 int dev_dflags(dev_t dev);
196 int dev_dmaj(dev_t dev);
197 int dev_dopen(dev_t dev, int oflags, int devtype, struct thread *td);
198 int dev_dclose(dev_t dev, int fflag, int devtype, struct thread *td);
199 void dev_dstrategy(dev_t dev, struct buf *bp);
200 int dev_dioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td);
201 int dev_ddump(dev_t dev);
202 int dev_dpsize(dev_t dev);
203 int dev_dread(dev_t dev, struct uio *uio, int ioflag);
204 int dev_dwrite(dev_t dev, struct uio *uio, int ioflag);
205 int dev_dpoll(dev_t dev, int events, struct thread *td);
206 int dev_dkqfilter(dev_t dev, struct knote *kn);
207 int dev_dmmap(dev_t dev, vm_offset_t offset, int nprot);