Fix "ls: not found" problem during buildworld. mdate.sh script
[dragonfly.git] / sys / sys / device.h
blobcff7597422d3bb4b9a2add91ff6402633a26b1e9
1 /*
2 * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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
16 * distribution.
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
32 * SUCH DAMAGE.
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>
42 #endif
45 * This structure is at the base of every CDEVSW port message
47 struct cdevmsg {
48 lwkt_msg msg;
49 dev_t dev;
53 * int d_open(dev_t dev, int oflags, int devtype, thread_t td)
55 struct cdevmsg_open {
56 struct cdevmsg msg;
57 int oflags;
58 int devtype;
59 struct thread *td;
63 * int d_close(dev_t dev, int fflag, int devtype, thread_t td)
65 struct cdevmsg_close {
66 struct cdevmsg msg;
67 int fflag;
68 int devtype;
69 struct thread *td;
73 * void d_strategy(dev_t dev, struct bio *bio)
75 struct cdevmsg_strategy {
76 struct cdevmsg msg;
77 struct bio *bio;
81 * int d_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, thread_t td)
83 struct cdevmsg_ioctl {
84 struct cdevmsg msg;
85 u_long cmd;
86 caddr_t data;
87 int fflag;
88 struct thread *td;
92 * void d_dump(dev_t dev)
94 struct cdevmsg_dump {
95 struct cdevmsg msg;
96 u_int count;
97 u_int blkno;
98 u_int secsize;
102 * int d_psize(dev_t dev)
104 struct cdevmsg_psize {
105 struct cdevmsg msg;
106 int result;
110 * int d_read(dev_t dev, struct uio *uio, int ioflag)
112 struct cdevmsg_read {
113 struct cdevmsg msg;
114 struct uio *uio;
115 int ioflag;
119 * int d_write(dev_t dev, struct uio *uio, int ioflag)
121 struct cdevmsg_write {
122 struct cdevmsg msg;
123 struct uio *uio;
124 int ioflag;
128 * int d_poll(dev_t dev, int events, thread_t td)
130 struct cdevmsg_poll {
131 struct cdevmsg msg;
132 int events;
133 struct thread *td;
137 * int d_kqfilter(dev_t dev, struct knote *kn)
139 struct cdevmsg_kqfilter {
140 struct cdevmsg msg;
141 struct knote *kn;
142 int result;
146 * int d_mmap(dev_t dev, vm_offset_t offset, int nprot)
148 struct cdevmsg_mmap {
149 struct cdevmsg msg;
150 vm_offset_t offset;
151 int nprot;
152 int result; /* page number */
155 union cdevallmsg {
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)
197 #ifdef _KERNEL
199 struct disk;
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);
218 #endif
220 #endif