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