FreeBSD/Linux Kernel Cross Reference
sys/dev/dkvar.h
1 /* $NetBSD: dkvar.h,v 1.9.24.1 2007/07/01 17:09:25 bouyer Exp $ */
2
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Roland C. Dowdeswell.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 struct dk_geom {
40 u_int32_t pdg_secsize;
41 u_int32_t pdg_nsectors;
42 u_int32_t pdg_ntracks;
43 u_int32_t pdg_ncylinders;
44 };
45
46 /* literally this is not a softc, but is intended to be included in
47 * the pseudo-disk's softc and passed to calls in dksubr.c. It
48 * should include the common elements of the pseudo-disk's softc.
49 * All elements that are included here should describe the external
50 * representation of the disk to the higher layers, and flags that
51 * are common to each of the pseudo-disk drivers.
52 */
53 struct dk_softc {
54 void *sc_osc; /* the softc of the underlying
55 * driver */
56 u_int32_t sc_flags; /* flags */
57 size_t sc_size; /* size of disk */
58 struct dk_geom sc_geom; /* geometry info */
59 #define DK_XNAME_SIZE 8
60 char sc_xname[DK_XNAME_SIZE]; /* external name */
61 struct disk sc_dkdev; /* generic disk info */
62 struct bufq_state *sc_bufq; /* buffer queue */
63 };
64
65 /* sc_flags:
66 * We separate the flags into two varieties, those that dksubr.c
67 * understands and manipulates and those that it does not.
68 */
69
70 #define DKF_INITED 0x00010000 /* unit has been initialised */
71 #define DKF_WLABEL 0x00020000 /* label area is writable */
72 #define DKF_LABELLING 0x00040000 /* unit is currently being labeled */
73 #define DKF_WARNLABEL 0x00080000 /* warn if disklabel not present */
74 #define DKF_LABELSANITY 0x00100000 /* warn if disklabel not sane */
75 #define DKF_TAKEDUMP 0x00200000 /* allow dumping */
76
77 /* Mask of flags that dksubr.c understands, other flags are fair game */
78 #define DK_FLAGMASK 0xffff0000
79
80 /*
81 * This defines the interface to the routines in dksubr.c. This
82 * should be a single static structure per pseudo-disk driver.
83 * We only define the functions that we currently need.
84 */
85 struct dk_intf {
86 int di_dtype; /* disk type */
87 const char *di_dkname; /* disk type name */
88 int (*di_open)(dev_t, int, int, struct lwp *);
89 int (*di_close)(dev_t, int, int, struct lwp *);
90 void (*di_strategy)(struct buf *);
91 int (*di_diskstart)(struct dk_softc *, struct buf *);
92 };
93
94 #define DK_BUSY(_dksc, _pmask) \
95 ((_dksc)->sc_dkdev.dk_openmask & ~(_pmask)) || \
96 ((_dksc)->sc_dkdev.dk_bopenmask & (_pmask) && \
97 ((_dksc)->sc_dkdev.dk_copenmask & (_pmask)))
98
99 /*
100 * Functions that are exported to the pseudo disk implementations:
101 */
102
103 void dk_sc_init(struct dk_softc *, void *, char *);
104
105 int dk_open(struct dk_intf *, struct dk_softc *, dev_t,
106 int, int, struct lwp *);
107 int dk_close(struct dk_intf *, struct dk_softc *, dev_t,
108 int, int, struct lwp *);
109 void dk_strategy(struct dk_intf *, struct dk_softc *, struct buf *);
110 void dk_start(struct dk_intf *, struct dk_softc *);
111 void dk_iodone(struct dk_intf *, struct dk_softc *);
112 int dk_size(struct dk_intf *, struct dk_softc *, dev_t);
113 int dk_ioctl(struct dk_intf *, struct dk_softc *, dev_t,
114 u_long, caddr_t, int, struct lwp *);
115 int dk_dump(struct dk_intf *, struct dk_softc *, dev_t,
116 daddr_t, caddr_t, size_t);
117 void dk_getdisklabel(struct dk_intf *, struct dk_softc *, dev_t);
118 void dk_getdefaultlabel(struct dk_intf *, struct dk_softc *,
119 struct disklabel *);
120
121 int dk_lookup(const char *, struct lwp *, struct vnode **, enum uio_seg);
Cache object: db81d5412d8caad6253a6e3ff444a047
|