2 * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/sys/device.h,v 1.4 2006/02/17 19:18:07 dillon Exp $
37 #ifndef _SYS_DEVICE_H_
38 #define _SYS_DEVICE_H_
40 #ifndef _SYS_MSGPORT_H_
41 #include <sys/msgport.h>
45 * This structure is at the base of every CDEVSW port message
53 * int d_open(dev_t dev, int oflags, int devtype, thread_t td)
63 * int d_close(dev_t dev, int fflag, int devtype, thread_t td)
65 struct cdevmsg_close
{
73 * void d_strategy(dev_t dev, struct bio *bio)
75 struct cdevmsg_strategy
{
81 * int d_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, thread_t td)
83 struct cdevmsg_ioctl
{
92 * void d_dump(dev_t dev)
102 * int d_psize(dev_t dev)
104 struct cdevmsg_psize
{
110 * int d_read(dev_t dev, struct uio *uio, int ioflag)
112 struct cdevmsg_read
{
119 * int d_write(dev_t dev, struct uio *uio, int ioflag)
121 struct cdevmsg_write
{
128 * int d_poll(dev_t dev, int events, thread_t td)
130 struct cdevmsg_poll
{
137 * int d_kqfilter(dev_t dev, struct knote *kn)
139 struct cdevmsg_kqfilter
{
146 * int d_mmap(dev_t dev, vm_offset_t offset, int nprot)
148 struct cdevmsg_mmap
{
152 int result
; /* page number */
156 struct lwkt_msg am_lmsg
;
157 struct cdevmsg am_msg
;
158 struct cdevmsg_open am_open
;
159 struct cdevmsg_close am_close
;
160 struct cdevmsg_strategy am_strategy
;
161 struct cdevmsg_ioctl am_ioctl
;
162 struct cdevmsg_dump am_dump
;
163 struct cdevmsg_psize am_psize
;
164 struct cdevmsg_read am_read
;
165 struct cdevmsg_write am_write
;
166 struct cdevmsg_poll am_poll
;
167 struct cdevmsg_kqfilter am_kqfilter
;
168 struct cdevmsg_mmap am_mmap
;
171 typedef union cdevallmsg
*cdevallmsg_t
;
172 typedef struct cdevmsg
*cdevmsg_t
;
173 typedef struct cdevmsg_open
*cdevmsg_open_t
;
174 typedef struct cdevmsg_close
*cdevmsg_close_t
;
175 typedef struct cdevmsg_strategy
*cdevmsg_strategy_t
;
176 typedef struct cdevmsg_ioctl
*cdevmsg_ioctl_t
;
177 typedef struct cdevmsg_dump
*cdevmsg_dump_t
;
178 typedef struct cdevmsg_psize
*cdevmsg_psize_t
;
179 typedef struct cdevmsg_read
*cdevmsg_read_t
;
180 typedef struct cdevmsg_write
*cdevmsg_write_t
;
181 typedef struct cdevmsg_poll
*cdevmsg_poll_t
;
182 typedef struct cdevmsg_kqfilter
*cdevmsg_kqfilter_t
;
183 typedef struct cdevmsg_mmap
*cdevmsg_mmap_t
;
185 #define CDEV_CMD_OPEN (MSG_CMD_CDEV|0x0001)
186 #define CDEV_CMD_CLOSE (MSG_CMD_CDEV|0x0002)
187 #define CDEV_CMD_STRATEGY (MSG_CMD_CDEV|0x0003)
188 #define CDEV_CMD_IOCTL (MSG_CMD_CDEV|0x0004)
189 #define CDEV_CMD_DUMP (MSG_CMD_CDEV|0x0005)
190 #define CDEV_CMD_PSIZE (MSG_CMD_CDEV|0x0006)
191 #define CDEV_CMD_READ (MSG_CMD_CDEV|0x0007)
192 #define CDEV_CMD_WRITE (MSG_CMD_CDEV|0x0008)
193 #define CDEV_CMD_POLL (MSG_CMD_CDEV|0x0009)
194 #define CDEV_CMD_KQFILTER (MSG_CMD_CDEV|0x000A)
195 #define CDEV_CMD_MMAP (MSG_CMD_CDEV|0x000B)
201 const char *dev_dname(dev_t dev
);
202 struct lwkt_port
*dev_dport(dev_t dev
);
203 int dev_dflags(dev_t dev
);
204 int dev_dmaj(dev_t dev
);
205 int dev_dopen(dev_t dev
, int oflags
, int devtype
, struct thread
*td
);
206 int dev_dclose(dev_t dev
, int fflag
, int devtype
, struct thread
*td
);
207 void dev_dstrategy(dev_t dev
, struct bio
*bio
);
208 void dev_dstrategy_chain(dev_t dev
, struct bio
*bio
);
209 int dev_dioctl(dev_t dev
, u_long cmd
, caddr_t data
, int fflag
, struct thread
*td
);
210 int dev_ddump(dev_t dev
);
211 int dev_dpsize(dev_t dev
);
212 int dev_dread(dev_t dev
, struct uio
*uio
, int ioflag
);
213 int dev_dwrite(dev_t dev
, struct uio
*uio
, int ioflag
);
214 int dev_dpoll(dev_t dev
, int events
, struct thread
*td
);
215 int dev_dkqfilter(dev_t dev
, struct knote
*kn
);
216 int dev_dmmap(dev_t dev
, vm_offset_t offset
, int nprot
);