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.1 2003/07/22 17:03:34 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
46 * int d_open(dev_t dev, int oflags, int devtype, thread_t td)
56 * int d_close(dev_t dev, int fflag, int devtype, thread_t td)
58 struct cdevmsg_close {
66 * void d_strategy(struct buf *bp)
68 struct cdevmsg_strategy {
74 * int d_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, thread_t td)
76 struct cdevmsg_ioctl {
85 * void d_dump(dev_t dev)
92 * int d_psize(dev_t dev)
94 struct cdevmsg_psize {
100 * int d_read(dev_t dev, struct uio *uio, int ioflag)
102 struct cdevmsg_read {
109 * int d_write(dev_t dev, struct uio *uio, int ioflag)
111 struct cdevmsg_write {
118 * int d_poll(dev_t dev, int events, thread_t td)
120 struct cdevmsg_poll {
127 * int d_kqfilter(dev_t dev, struct knote *kn)
129 struct cdevmsg_kqfilter {
136 * int d_mmap(dev_t dev, vm_offset_t offset, int nprot)
138 struct cdevmsg_mmap {
142 int result; /* page number */
146 struct lwkt_msg am_lmsg;
147 struct cdevmsg am_msg;
148 struct cdevmsg_open am_open;
149 struct cdevmsg_close am_close;
150 struct cdevmsg_strategy am_strategy;
151 struct cdevmsg_ioctl am_ioctl;
152 struct cdevmsg_dump am_dump;
153 struct cdevmsg_psize am_psize;
154 struct cdevmsg_read am_read;
155 struct cdevmsg_write am_write;
156 struct cdevmsg_poll am_poll;
157 struct cdevmsg_kqfilter am_kqfilter;
158 struct cdevmsg_mmap am_mmap;
161 typedef union cdevallmsg *cdevallmsg_t;
162 typedef struct cdevmsg *cdevmsg_t;
163 typedef struct cdevmsg_open *cdevmsg_open_t;
164 typedef struct cdevmsg_close *cdevmsg_close_t;
165 typedef struct cdevmsg_strategy *cdevmsg_strategy_t;
166 typedef struct cdevmsg_ioctl *cdevmsg_ioctl_t;
167 typedef struct cdevmsg_dump *cdevmsg_dump_t;
168 typedef struct cdevmsg_psize *cdevmsg_psize_t;
169 typedef struct cdevmsg_read *cdevmsg_read_t;
170 typedef struct cdevmsg_write *cdevmsg_write_t;
171 typedef struct cdevmsg_poll *cdevmsg_poll_t;
172 typedef struct cdevmsg_kqfilter *cdevmsg_kqfilter_t;
173 typedef struct cdevmsg_mmap *cdevmsg_mmap_t;
175 #define CDEV_CMD_OPEN (MSG_CMD_CDEV|0x0001)
176 #define CDEV_CMD_CLOSE (MSG_CMD_CDEV|0x0002)
177 #define CDEV_CMD_STRATEGY (MSG_CMD_CDEV|0x0003)
178 #define CDEV_CMD_IOCTL (MSG_CMD_CDEV|0x0004)
179 #define CDEV_CMD_DUMP (MSG_CMD_CDEV|0x0005)
180 #define CDEV_CMD_PSIZE (MSG_CMD_CDEV|0x0006)
181 #define CDEV_CMD_READ (MSG_CMD_CDEV|0x0007)
182 #define CDEV_CMD_WRITE (MSG_CMD_CDEV|0x0008)
183 #define CDEV_CMD_POLL (MSG_CMD_CDEV|0x0009)
184 #define CDEV_CMD_KQFILTER (MSG_CMD_CDEV|0x000A)
185 #define CDEV_CMD_MMAP (MSG_CMD_CDEV|0x000B)
191 const char *dev_dname(dev_t dev);
192 struct lwkt_port *dev_dport(dev_t dev);
193 int dev_dflags(dev_t dev);
194 int dev_dmaj(dev_t dev);
195 int dev_dopen(dev_t dev, int oflags, int devtype, struct thread *td);
196 int dev_dclose(dev_t dev, int fflag, int devtype, struct thread *td);
197 void dev_dstrategy(dev_t dev, struct buf *bp);
198 int dev_dioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td);
199 int dev_ddump(dev_t dev);
200 int dev_dpsize(dev_t dev);
201 int dev_dread(dev_t dev, struct uio *uio, int ioflag);
202 int dev_dwrite(dev_t dev, struct uio *uio, int ioflag);
203 int dev_dpoll(dev_t dev, int events, struct thread *td);
204 int dev_dkqfilter(dev_t dev, struct knote *kn);
205 int dev_dmmap(dev_t dev, vm_offset_t offset, int nprot);
207 int dev_port_dopen(lwkt_port_t port, dev_t dev, int oflags, int devtype, struct thread *td);
208 int dev_port_dclose(lwkt_port_t port, dev_t dev, int fflag, int devtype, struct thread *td);
209 void dev_port_dstrategy(lwkt_port_t port, dev_t dev, struct buf *bp);
210 int dev_port_dioctl(lwkt_port_t port, dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td);
211 int dev_port_ddump(lwkt_port_t port, dev_t dev);
212 int dev_port_dpsize(lwkt_port_t port, dev_t dev);
213 int dev_port_dread(lwkt_port_t port, dev_t dev, struct uio *uio, int ioflag);
214 int dev_port_dwrite(lwkt_port_t port, dev_t dev, struct uio *uio, int ioflag);
215 int dev_port_dpoll(lwkt_port_t port, dev_t dev, int events, struct thread *td);
216 int dev_port_dkqfilter(lwkt_port_t port, dev_t dev, struct knote *kn);
217 int dev_port_dmmap(lwkt_port_t port, dev_t dev, vm_offset_t offset, int nprot);