ed_mca.c revision 1.7.2.5 1 1.7.2.5 nathanw /* $NetBSD: ed_mca.c,v 1.7.2.5 2002/01/08 00:30:40 nathanw Exp $ */
2 1.7.2.2 nathanw
3 1.7.2.2 nathanw /*
4 1.7.2.2 nathanw * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.7.2.2 nathanw *
6 1.7.2.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
7 1.7.2.2 nathanw * by Jaromir Dolecek.
8 1.7.2.2 nathanw *
9 1.7.2.2 nathanw * Redistribution and use in source and binary forms, with or without
10 1.7.2.2 nathanw * modification, are permitted provided that the following conditions
11 1.7.2.2 nathanw * are met:
12 1.7.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
13 1.7.2.2 nathanw * notice, this list of conditions and the following disclaimer.
14 1.7.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
15 1.7.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
16 1.7.2.2 nathanw * documentation and/or other materials provided with the distribution.
17 1.7.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
18 1.7.2.2 nathanw * must display the following acknowledgement:
19 1.7.2.2 nathanw * This product includes software developed by the NetBSD
20 1.7.2.2 nathanw * Foundation, Inc. and its contributors.
21 1.7.2.2 nathanw * 4. The name of the author may not be used to endorse or promote products
22 1.7.2.2 nathanw * derived from this software without specific prior written permission.
23 1.7.2.2 nathanw *
24 1.7.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 1.7.2.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 1.7.2.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 1.7.2.2 nathanw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 1.7.2.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 1.7.2.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 1.7.2.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 1.7.2.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 1.7.2.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 1.7.2.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 1.7.2.2 nathanw */
35 1.7.2.2 nathanw
36 1.7.2.2 nathanw /*
37 1.7.2.5 nathanw * Disk drive goo for MCA ESDI controller driver.
38 1.7.2.2 nathanw */
39 1.7.2.2 nathanw
40 1.7.2.4 nathanw #include <sys/cdefs.h>
41 1.7.2.5 nathanw __KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.7.2.5 2002/01/08 00:30:40 nathanw Exp $");
42 1.7.2.4 nathanw
43 1.7.2.2 nathanw #include "rnd.h"
44 1.7.2.5 nathanw #include "locators.h"
45 1.7.2.2 nathanw
46 1.7.2.2 nathanw #include <sys/param.h>
47 1.7.2.2 nathanw #include <sys/systm.h>
48 1.7.2.2 nathanw #include <sys/kernel.h>
49 1.7.2.2 nathanw #include <sys/conf.h>
50 1.7.2.2 nathanw #include <sys/file.h>
51 1.7.2.2 nathanw #include <sys/stat.h>
52 1.7.2.2 nathanw #include <sys/ioctl.h>
53 1.7.2.2 nathanw #include <sys/buf.h>
54 1.7.2.2 nathanw #include <sys/uio.h>
55 1.7.2.2 nathanw #include <sys/malloc.h>
56 1.7.2.2 nathanw #include <sys/device.h>
57 1.7.2.2 nathanw #include <sys/disklabel.h>
58 1.7.2.2 nathanw #include <sys/disk.h>
59 1.7.2.2 nathanw #include <sys/syslog.h>
60 1.7.2.2 nathanw #include <sys/proc.h>
61 1.7.2.2 nathanw #include <sys/vnode.h>
62 1.7.2.2 nathanw #if NRND > 0
63 1.7.2.2 nathanw #include <sys/rnd.h>
64 1.7.2.2 nathanw #endif
65 1.7.2.2 nathanw
66 1.7.2.2 nathanw #include <machine/intr.h>
67 1.7.2.2 nathanw #include <machine/bus.h>
68 1.7.2.2 nathanw
69 1.7.2.2 nathanw #include <dev/mca/mcavar.h>
70 1.7.2.2 nathanw
71 1.7.2.2 nathanw #include <dev/mca/edcreg.h>
72 1.7.2.2 nathanw #include <dev/mca/edvar.h>
73 1.7.2.2 nathanw #include <dev/mca/edcvar.h>
74 1.7.2.2 nathanw
75 1.7.2.2 nathanw /* #define WDCDEBUG */
76 1.7.2.2 nathanw
77 1.7.2.2 nathanw #ifdef WDCDEBUG
78 1.7.2.2 nathanw #define WDCDEBUG_PRINT(args, level) printf args
79 1.7.2.2 nathanw #else
80 1.7.2.2 nathanw #define WDCDEBUG_PRINT(args, level)
81 1.7.2.2 nathanw #endif
82 1.7.2.2 nathanw
83 1.7.2.2 nathanw #define EDLABELDEV(dev) (MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART))
84 1.7.2.2 nathanw
85 1.7.2.2 nathanw /* XXX: these should go elsewhere */
86 1.7.2.2 nathanw cdev_decl(edmca);
87 1.7.2.2 nathanw bdev_decl(edmca);
88 1.7.2.2 nathanw
89 1.7.2.2 nathanw static int ed_mca_probe __P((struct device *, struct cfdata *, void *));
90 1.7.2.2 nathanw static void ed_mca_attach __P((struct device *, struct device *, void *));
91 1.7.2.2 nathanw
92 1.7.2.2 nathanw struct cfattach ed_mca_ca = {
93 1.7.2.2 nathanw sizeof(struct ed_softc), ed_mca_probe, ed_mca_attach
94 1.7.2.2 nathanw };
95 1.7.2.2 nathanw
96 1.7.2.2 nathanw extern struct cfdriver ed_cd;
97 1.7.2.2 nathanw
98 1.7.2.5 nathanw static int ed_get_params __P((struct ed_softc *, int *));
99 1.7.2.2 nathanw static int ed_lock __P((struct ed_softc *));
100 1.7.2.2 nathanw static void ed_unlock __P((struct ed_softc *));
101 1.7.2.5 nathanw static void edgetdisklabel __P((dev_t, struct ed_softc *));
102 1.7.2.2 nathanw static void edgetdefaultlabel __P((struct ed_softc *, struct disklabel *));
103 1.7.2.2 nathanw
104 1.7.2.2 nathanw static struct dkdriver eddkdriver = { edmcastrategy };
105 1.7.2.2 nathanw
106 1.7.2.2 nathanw /*
107 1.7.2.2 nathanw * Just check if it's possible to identify the disk.
108 1.7.2.2 nathanw */
109 1.7.2.2 nathanw static int
110 1.7.2.5 nathanw ed_mca_probe(parent, cf, aux)
111 1.7.2.2 nathanw struct device *parent;
112 1.7.2.5 nathanw struct cfdata *cf;
113 1.7.2.2 nathanw void *aux;
114 1.7.2.2 nathanw {
115 1.7.2.2 nathanw u_int16_t cmd_args[2];
116 1.7.2.2 nathanw struct edc_mca_softc *sc = (void *) parent;
117 1.7.2.5 nathanw struct ed_attach_args *eda = (struct ed_attach_args *) aux;
118 1.7.2.2 nathanw int found = 1;
119 1.7.2.2 nathanw
120 1.7.2.2 nathanw /*
121 1.7.2.5 nathanw * Check we match hardwired config.
122 1.7.2.5 nathanw */
123 1.7.2.5 nathanw if (cf->edccf_unit != EDCCF_DRIVE_DEFAULT &&
124 1.7.2.5 nathanw cf->edccf_unit != eda->edc_drive)
125 1.7.2.5 nathanw return (0);
126 1.7.2.5 nathanw
127 1.7.2.5 nathanw /*
128 1.7.2.2 nathanw * Get Device Configuration (09).
129 1.7.2.2 nathanw */
130 1.7.2.2 nathanw cmd_args[0] = 14; /* Options: 00s110, s: 0=Physical 1=Pseudo */
131 1.7.2.2 nathanw cmd_args[1] = 0;
132 1.7.2.5 nathanw if (edc_run_cmd(sc, CMD_GET_DEV_CONF, eda->edc_drive, cmd_args, 2, 1))
133 1.7.2.2 nathanw found = 0;
134 1.7.2.2 nathanw
135 1.7.2.2 nathanw return (found);
136 1.7.2.2 nathanw }
137 1.7.2.2 nathanw
138 1.7.2.2 nathanw static void
139 1.7.2.2 nathanw ed_mca_attach(parent, self, aux)
140 1.7.2.2 nathanw struct device *parent, *self;
141 1.7.2.2 nathanw void *aux;
142 1.7.2.2 nathanw {
143 1.7.2.2 nathanw struct ed_softc *ed = (void *) self;
144 1.7.2.2 nathanw struct edc_mca_softc *sc = (void *) parent;
145 1.7.2.5 nathanw struct ed_attach_args *eda = (struct ed_attach_args *) aux;
146 1.7.2.5 nathanw char pbuf[8], lckname[10];
147 1.7.2.5 nathanw int drv_flags;
148 1.7.2.2 nathanw
149 1.7.2.2 nathanw ed->edc_softc = sc;
150 1.7.2.5 nathanw ed->sc_devno = eda->edc_drive;
151 1.7.2.5 nathanw edc_add_disk(sc, ed);
152 1.7.2.2 nathanw
153 1.7.2.2 nathanw BUFQ_INIT(&ed->sc_q);
154 1.7.2.3 nathanw simple_lock_init(&ed->sc_q_lock);
155 1.7.2.5 nathanw snprintf(lckname, sizeof(lckname), "%slck", ed->sc_dev.dv_xname);
156 1.7.2.5 nathanw lockinit(&ed->sc_lock, PRIBIO | PCATCH, lckname, 0, 0);
157 1.7.2.2 nathanw
158 1.7.2.5 nathanw if (ed_get_params(ed, &drv_flags)) {
159 1.7.2.2 nathanw printf(": IDENTIFY failed, no disk found\n");
160 1.7.2.2 nathanw return;
161 1.7.2.2 nathanw }
162 1.7.2.2 nathanw
163 1.7.2.2 nathanw format_bytes(pbuf, sizeof(pbuf),
164 1.7.2.2 nathanw (u_int64_t) ed->sc_capacity * DEV_BSIZE);
165 1.7.2.2 nathanw printf(": %s, %u cyl, %u head, %u sec, 512 bytes/sect x %u sectors\n",
166 1.7.2.2 nathanw pbuf,
167 1.7.2.2 nathanw ed->cyl, ed->heads, ed->sectors,
168 1.7.2.2 nathanw ed->sc_capacity);
169 1.7.2.2 nathanw
170 1.7.2.2 nathanw printf("%s: %u spares/cyl, %s, %s, %s, %s, %s\n",
171 1.7.2.2 nathanw ed->sc_dev.dv_xname, ed->spares,
172 1.7.2.5 nathanw (drv_flags & (1 << 0)) ? "NoRetries" : "Retries",
173 1.7.2.5 nathanw (drv_flags & (1 << 1)) ? "Removable" : "Fixed",
174 1.7.2.5 nathanw (drv_flags & (1 << 2)) ? "SkewedFormat" : "NoSkew",
175 1.7.2.5 nathanw (drv_flags & (1 << 3)) ? "ZeroDefect" : "Defects",
176 1.7.2.5 nathanw (drv_flags & (1 << 4)) ? "InvalidSecondary" : "SecondaryOK"
177 1.7.2.2 nathanw );
178 1.7.2.3 nathanw
179 1.7.2.2 nathanw /*
180 1.7.2.2 nathanw * Initialize and attach the disk structure.
181 1.7.2.2 nathanw */
182 1.7.2.2 nathanw ed->sc_dk.dk_driver = &eddkdriver;
183 1.7.2.2 nathanw ed->sc_dk.dk_name = ed->sc_dev.dv_xname;
184 1.7.2.2 nathanw disk_attach(&ed->sc_dk);
185 1.7.2.2 nathanw #if NRND > 0
186 1.7.2.2 nathanw rnd_attach_source(&ed->rnd_source, ed->sc_dev.dv_xname,
187 1.7.2.2 nathanw RND_TYPE_DISK, 0);
188 1.7.2.2 nathanw #endif
189 1.7.2.2 nathanw
190 1.7.2.2 nathanw ed->sc_flags |= EDF_INIT;
191 1.7.2.2 nathanw }
192 1.7.2.2 nathanw
193 1.7.2.2 nathanw /*
194 1.7.2.2 nathanw * Read/write routine for a buffer. Validates the arguments and schedules the
195 1.7.2.2 nathanw * transfer. Does not wait for the transfer to complete.
196 1.7.2.2 nathanw */
197 1.7.2.2 nathanw void
198 1.7.2.2 nathanw edmcastrategy(bp)
199 1.7.2.2 nathanw struct buf *bp;
200 1.7.2.2 nathanw {
201 1.7.2.5 nathanw struct ed_softc *ed = device_lookup(&ed_cd, DISKUNIT(bp->b_dev));
202 1.7.2.5 nathanw struct disklabel *lp = ed->sc_dk.dk_label;
203 1.7.2.2 nathanw daddr_t blkno;
204 1.7.2.2 nathanw int s;
205 1.7.2.2 nathanw
206 1.7.2.5 nathanw WDCDEBUG_PRINT(("edmcastrategy (%s)\n", ed->sc_dev.dv_xname),
207 1.7.2.2 nathanw DEBUG_XFERS);
208 1.7.2.3 nathanw
209 1.7.2.2 nathanw /* Valid request? */
210 1.7.2.2 nathanw if (bp->b_blkno < 0 ||
211 1.7.2.2 nathanw (bp->b_bcount % lp->d_secsize) != 0 ||
212 1.7.2.2 nathanw (bp->b_bcount / lp->d_secsize) >= (1 << NBBY)) {
213 1.7.2.2 nathanw bp->b_error = EINVAL;
214 1.7.2.2 nathanw goto bad;
215 1.7.2.2 nathanw }
216 1.7.2.3 nathanw
217 1.7.2.2 nathanw /* If device invalidated (e.g. media change, door open), error. */
218 1.7.2.5 nathanw if ((ed->sc_flags & WDF_LOADED) == 0) {
219 1.7.2.2 nathanw bp->b_error = EIO;
220 1.7.2.2 nathanw goto bad;
221 1.7.2.2 nathanw }
222 1.7.2.2 nathanw
223 1.7.2.2 nathanw /* If it's a null transfer, return immediately. */
224 1.7.2.2 nathanw if (bp->b_bcount == 0)
225 1.7.2.2 nathanw goto done;
226 1.7.2.2 nathanw
227 1.7.2.2 nathanw /*
228 1.7.2.2 nathanw * Do bounds checking, adjust transfer. if error, process.
229 1.7.2.2 nathanw * If end of partition, just return.
230 1.7.2.2 nathanw */
231 1.7.2.2 nathanw if (DISKPART(bp->b_dev) != RAW_PART &&
232 1.7.2.5 nathanw bounds_check_with_label(bp, ed->sc_dk.dk_label,
233 1.7.2.5 nathanw (ed->sc_flags & (WDF_WLABEL|WDF_LABELLING)) != 0) <= 0)
234 1.7.2.2 nathanw goto done;
235 1.7.2.2 nathanw
236 1.7.2.2 nathanw /*
237 1.7.2.2 nathanw * Now convert the block number to absolute and put it in
238 1.7.2.2 nathanw * terms of the device's logical block size.
239 1.7.2.2 nathanw */
240 1.7.2.2 nathanw if (lp->d_secsize >= DEV_BSIZE)
241 1.7.2.2 nathanw blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
242 1.7.2.2 nathanw else
243 1.7.2.2 nathanw blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
244 1.7.2.2 nathanw
245 1.7.2.2 nathanw if (DISKPART(bp->b_dev) != RAW_PART)
246 1.7.2.2 nathanw blkno += lp->d_partitions[DISKPART(bp->b_dev)].p_offset;
247 1.7.2.2 nathanw
248 1.7.2.2 nathanw bp->b_rawblkno = blkno;
249 1.7.2.2 nathanw
250 1.7.2.2 nathanw /* Queue transfer on drive, activate drive and controller if idle. */
251 1.7.2.2 nathanw s = splbio();
252 1.7.2.5 nathanw simple_lock(&ed->sc_q_lock);
253 1.7.2.5 nathanw disksort_blkno(&ed->sc_q, bp);
254 1.7.2.5 nathanw simple_unlock(&ed->sc_q_lock);
255 1.7.2.2 nathanw
256 1.7.2.2 nathanw /* Ring the worker thread */
257 1.7.2.5 nathanw wakeup_one(ed->edc_softc);
258 1.7.2.2 nathanw
259 1.7.2.2 nathanw splx(s);
260 1.7.2.2 nathanw return;
261 1.7.2.2 nathanw bad:
262 1.7.2.2 nathanw bp->b_flags |= B_ERROR;
263 1.7.2.2 nathanw done:
264 1.7.2.2 nathanw /* Toss transfer; we're done early. */
265 1.7.2.2 nathanw bp->b_resid = bp->b_bcount;
266 1.7.2.2 nathanw biodone(bp);
267 1.7.2.2 nathanw }
268 1.7.2.2 nathanw
269 1.7.2.2 nathanw int
270 1.7.2.2 nathanw edmcaread(dev, uio, flags)
271 1.7.2.2 nathanw dev_t dev;
272 1.7.2.2 nathanw struct uio *uio;
273 1.7.2.2 nathanw int flags;
274 1.7.2.2 nathanw {
275 1.7.2.2 nathanw WDCDEBUG_PRINT(("edread\n"), DEBUG_XFERS);
276 1.7.2.2 nathanw return (physio(edmcastrategy, NULL, dev, B_READ, minphys, uio));
277 1.7.2.2 nathanw }
278 1.7.2.2 nathanw
279 1.7.2.2 nathanw int
280 1.7.2.2 nathanw edmcawrite(dev, uio, flags)
281 1.7.2.2 nathanw dev_t dev;
282 1.7.2.2 nathanw struct uio *uio;
283 1.7.2.2 nathanw int flags;
284 1.7.2.2 nathanw {
285 1.7.2.2 nathanw WDCDEBUG_PRINT(("edwrite\n"), DEBUG_XFERS);
286 1.7.2.2 nathanw return (physio(edmcastrategy, NULL, dev, B_WRITE, minphys, uio));
287 1.7.2.2 nathanw }
288 1.7.2.2 nathanw
289 1.7.2.2 nathanw /*
290 1.7.2.2 nathanw * Wait interruptibly for an exclusive lock.
291 1.7.2.2 nathanw */
292 1.7.2.2 nathanw static int
293 1.7.2.2 nathanw ed_lock(ed)
294 1.7.2.2 nathanw struct ed_softc *ed;
295 1.7.2.2 nathanw {
296 1.7.2.2 nathanw int error;
297 1.7.2.2 nathanw int s;
298 1.7.2.2 nathanw
299 1.7.2.2 nathanw WDCDEBUG_PRINT(("ed_lock\n"), DEBUG_FUNCS);
300 1.7.2.2 nathanw
301 1.7.2.2 nathanw s = splbio();
302 1.7.2.2 nathanw error = lockmgr(&ed->sc_lock, LK_EXCLUSIVE, NULL);
303 1.7.2.2 nathanw splx(s);
304 1.7.2.2 nathanw
305 1.7.2.2 nathanw return (error);
306 1.7.2.2 nathanw }
307 1.7.2.2 nathanw
308 1.7.2.2 nathanw /*
309 1.7.2.2 nathanw * Unlock and wake up any waiters.
310 1.7.2.2 nathanw */
311 1.7.2.2 nathanw static void
312 1.7.2.2 nathanw ed_unlock(ed)
313 1.7.2.2 nathanw struct ed_softc *ed;
314 1.7.2.2 nathanw {
315 1.7.2.2 nathanw WDCDEBUG_PRINT(("ed_unlock\n"), DEBUG_FUNCS);
316 1.7.2.2 nathanw
317 1.7.2.2 nathanw (void) lockmgr(&ed->sc_lock, LK_RELEASE, NULL);
318 1.7.2.2 nathanw }
319 1.7.2.2 nathanw
320 1.7.2.2 nathanw int
321 1.7.2.2 nathanw edmcaopen(dev, flag, fmt, p)
322 1.7.2.2 nathanw dev_t dev;
323 1.7.2.2 nathanw int flag, fmt;
324 1.7.2.2 nathanw struct proc *p;
325 1.7.2.2 nathanw {
326 1.7.2.2 nathanw struct ed_softc *wd;
327 1.7.2.2 nathanw int part, error;
328 1.7.2.2 nathanw
329 1.7.2.2 nathanw WDCDEBUG_PRINT(("edopen\n"), DEBUG_FUNCS);
330 1.7.2.2 nathanw wd = device_lookup(&ed_cd, DISKUNIT(dev));
331 1.7.2.2 nathanw if (wd == NULL || (wd->sc_flags & EDF_INIT) == 0)
332 1.7.2.2 nathanw return (ENXIO);
333 1.7.2.2 nathanw
334 1.7.2.2 nathanw if ((error = ed_lock(wd)) != 0)
335 1.7.2.2 nathanw goto bad4;
336 1.7.2.2 nathanw
337 1.7.2.2 nathanw if (wd->sc_dk.dk_openmask != 0) {
338 1.7.2.2 nathanw /*
339 1.7.2.2 nathanw * If any partition is open, but the disk has been invalidated,
340 1.7.2.2 nathanw * disallow further opens.
341 1.7.2.2 nathanw */
342 1.7.2.2 nathanw if ((wd->sc_flags & WDF_LOADED) == 0) {
343 1.7.2.2 nathanw error = EIO;
344 1.7.2.2 nathanw goto bad3;
345 1.7.2.2 nathanw }
346 1.7.2.2 nathanw } else {
347 1.7.2.2 nathanw if ((wd->sc_flags & WDF_LOADED) == 0) {
348 1.7.2.5 nathanw int s;
349 1.7.2.5 nathanw
350 1.7.2.2 nathanw wd->sc_flags |= WDF_LOADED;
351 1.7.2.2 nathanw
352 1.7.2.2 nathanw /* Load the physical device parameters. */
353 1.7.2.5 nathanw s = splbio();
354 1.7.2.5 nathanw ed_get_params(wd, NULL);
355 1.7.2.5 nathanw splx(s);
356 1.7.2.2 nathanw
357 1.7.2.2 nathanw /* Load the partition info if not already loaded. */
358 1.7.2.5 nathanw edgetdisklabel(dev, wd);
359 1.7.2.2 nathanw }
360 1.7.2.2 nathanw }
361 1.7.2.2 nathanw
362 1.7.2.2 nathanw part = DISKPART(dev);
363 1.7.2.2 nathanw
364 1.7.2.2 nathanw /* Check that the partition exists. */
365 1.7.2.2 nathanw if (part != RAW_PART &&
366 1.7.2.2 nathanw (part >= wd->sc_dk.dk_label->d_npartitions ||
367 1.7.2.2 nathanw wd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
368 1.7.2.2 nathanw error = ENXIO;
369 1.7.2.2 nathanw goto bad;
370 1.7.2.2 nathanw }
371 1.7.2.3 nathanw
372 1.7.2.2 nathanw /* Insure only one open at a time. */
373 1.7.2.2 nathanw switch (fmt) {
374 1.7.2.2 nathanw case S_IFCHR:
375 1.7.2.2 nathanw wd->sc_dk.dk_copenmask |= (1 << part);
376 1.7.2.2 nathanw break;
377 1.7.2.2 nathanw case S_IFBLK:
378 1.7.2.2 nathanw wd->sc_dk.dk_bopenmask |= (1 << part);
379 1.7.2.2 nathanw break;
380 1.7.2.2 nathanw }
381 1.7.2.2 nathanw wd->sc_dk.dk_openmask =
382 1.7.2.2 nathanw wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
383 1.7.2.2 nathanw
384 1.7.2.2 nathanw ed_unlock(wd);
385 1.7.2.2 nathanw return 0;
386 1.7.2.2 nathanw
387 1.7.2.2 nathanw bad:
388 1.7.2.2 nathanw if (wd->sc_dk.dk_openmask == 0) {
389 1.7.2.2 nathanw }
390 1.7.2.2 nathanw
391 1.7.2.2 nathanw bad3:
392 1.7.2.2 nathanw ed_unlock(wd);
393 1.7.2.2 nathanw bad4:
394 1.7.2.2 nathanw return (error);
395 1.7.2.2 nathanw }
396 1.7.2.2 nathanw
397 1.7.2.2 nathanw int
398 1.7.2.2 nathanw edmcaclose(dev, flag, fmt, p)
399 1.7.2.2 nathanw dev_t dev;
400 1.7.2.2 nathanw int flag, fmt;
401 1.7.2.2 nathanw struct proc *p;
402 1.7.2.2 nathanw {
403 1.7.2.2 nathanw struct ed_softc *wd = device_lookup(&ed_cd, DISKUNIT(dev));
404 1.7.2.2 nathanw int part = DISKPART(dev);
405 1.7.2.2 nathanw int error;
406 1.7.2.3 nathanw
407 1.7.2.2 nathanw WDCDEBUG_PRINT(("edmcaclose\n"), DEBUG_FUNCS);
408 1.7.2.2 nathanw if ((error = ed_lock(wd)) != 0)
409 1.7.2.2 nathanw return error;
410 1.7.2.2 nathanw
411 1.7.2.2 nathanw switch (fmt) {
412 1.7.2.2 nathanw case S_IFCHR:
413 1.7.2.2 nathanw wd->sc_dk.dk_copenmask &= ~(1 << part);
414 1.7.2.2 nathanw break;
415 1.7.2.2 nathanw case S_IFBLK:
416 1.7.2.2 nathanw wd->sc_dk.dk_bopenmask &= ~(1 << part);
417 1.7.2.2 nathanw break;
418 1.7.2.2 nathanw }
419 1.7.2.2 nathanw wd->sc_dk.dk_openmask =
420 1.7.2.2 nathanw wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
421 1.7.2.2 nathanw
422 1.7.2.2 nathanw if (wd->sc_dk.dk_openmask == 0) {
423 1.7.2.2 nathanw #if 0
424 1.7.2.2 nathanw wd_flushcache(wd, AT_WAIT);
425 1.7.2.2 nathanw #endif
426 1.7.2.2 nathanw /* XXXX Must wait for I/O to complete! */
427 1.7.2.2 nathanw
428 1.7.2.2 nathanw if (! (wd->sc_flags & WDF_KLABEL))
429 1.7.2.2 nathanw wd->sc_flags &= ~WDF_LOADED;
430 1.7.2.2 nathanw }
431 1.7.2.2 nathanw
432 1.7.2.2 nathanw ed_unlock(wd);
433 1.7.2.2 nathanw
434 1.7.2.2 nathanw return 0;
435 1.7.2.2 nathanw }
436 1.7.2.2 nathanw
437 1.7.2.2 nathanw static void
438 1.7.2.5 nathanw edgetdefaultlabel(ed, lp)
439 1.7.2.5 nathanw struct ed_softc *ed;
440 1.7.2.2 nathanw struct disklabel *lp;
441 1.7.2.2 nathanw {
442 1.7.2.2 nathanw WDCDEBUG_PRINT(("edgetdefaultlabel\n"), DEBUG_FUNCS);
443 1.7.2.2 nathanw memset(lp, 0, sizeof(struct disklabel));
444 1.7.2.2 nathanw
445 1.7.2.2 nathanw lp->d_secsize = DEV_BSIZE;
446 1.7.2.5 nathanw lp->d_ntracks = ed->heads;
447 1.7.2.5 nathanw lp->d_nsectors = ed->sectors;
448 1.7.2.5 nathanw lp->d_ncylinders = ed->cyl;
449 1.7.2.2 nathanw lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
450 1.7.2.2 nathanw
451 1.7.2.2 nathanw lp->d_type = DTYPE_ESDI;
452 1.7.2.2 nathanw
453 1.7.2.2 nathanw strncpy(lp->d_typename, "ESDI", 16);
454 1.7.2.2 nathanw strncpy(lp->d_packname, "fictitious", 16);
455 1.7.2.5 nathanw lp->d_secperunit = ed->sc_capacity;
456 1.7.2.2 nathanw lp->d_rpm = 3600;
457 1.7.2.2 nathanw lp->d_interleave = 1;
458 1.7.2.2 nathanw lp->d_flags = 0;
459 1.7.2.2 nathanw
460 1.7.2.2 nathanw lp->d_partitions[RAW_PART].p_offset = 0;
461 1.7.2.2 nathanw lp->d_partitions[RAW_PART].p_size =
462 1.7.2.2 nathanw lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
463 1.7.2.2 nathanw lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
464 1.7.2.2 nathanw lp->d_npartitions = RAW_PART + 1;
465 1.7.2.2 nathanw
466 1.7.2.2 nathanw lp->d_magic = DISKMAGIC;
467 1.7.2.2 nathanw lp->d_magic2 = DISKMAGIC;
468 1.7.2.2 nathanw lp->d_checksum = dkcksum(lp);
469 1.7.2.2 nathanw }
470 1.7.2.2 nathanw
471 1.7.2.2 nathanw /*
472 1.7.2.2 nathanw * Fabricate a default disk label, and try to read the correct one.
473 1.7.2.2 nathanw */
474 1.7.2.2 nathanw static void
475 1.7.2.5 nathanw edgetdisklabel(dev, ed)
476 1.7.2.5 nathanw dev_t dev;
477 1.7.2.5 nathanw struct ed_softc *ed;
478 1.7.2.2 nathanw {
479 1.7.2.5 nathanw struct disklabel *lp = ed->sc_dk.dk_label;
480 1.7.2.2 nathanw char *errstring;
481 1.7.2.2 nathanw
482 1.7.2.2 nathanw WDCDEBUG_PRINT(("edgetdisklabel\n"), DEBUG_FUNCS);
483 1.7.2.2 nathanw
484 1.7.2.5 nathanw memset(ed->sc_dk.dk_cpulabel, 0, sizeof(struct cpu_disklabel));
485 1.7.2.2 nathanw
486 1.7.2.5 nathanw edgetdefaultlabel(ed, lp);
487 1.7.2.2 nathanw
488 1.7.2.5 nathanw errstring = readdisklabel(
489 1.7.2.5 nathanw EDLABELDEV(dev), edmcastrategy, lp, ed->sc_dk.dk_cpulabel);
490 1.7.2.2 nathanw if (errstring) {
491 1.7.2.2 nathanw /*
492 1.7.2.2 nathanw * This probably happened because the drive's default
493 1.7.2.2 nathanw * geometry doesn't match the DOS geometry. We
494 1.7.2.2 nathanw * assume the DOS geometry is now in the label and try
495 1.7.2.2 nathanw * again. XXX This is a kluge.
496 1.7.2.2 nathanw */
497 1.7.2.2 nathanw #if 0
498 1.7.2.2 nathanw if (wd->drvp->state > RECAL)
499 1.7.2.2 nathanw wd->drvp->drive_flags |= DRIVE_RESET;
500 1.7.2.2 nathanw #endif
501 1.7.2.5 nathanw errstring = readdisklabel(EDLABELDEV(dev),
502 1.7.2.5 nathanw edmcastrategy, lp, ed->sc_dk.dk_cpulabel);
503 1.7.2.2 nathanw }
504 1.7.2.2 nathanw if (errstring) {
505 1.7.2.5 nathanw printf("%s: %s\n", ed->sc_dev.dv_xname, errstring);
506 1.7.2.2 nathanw return;
507 1.7.2.2 nathanw }
508 1.7.2.2 nathanw }
509 1.7.2.2 nathanw
510 1.7.2.2 nathanw int
511 1.7.2.2 nathanw edmcaioctl(dev, xfer, addr, flag, p)
512 1.7.2.2 nathanw dev_t dev;
513 1.7.2.2 nathanw u_long xfer;
514 1.7.2.2 nathanw caddr_t addr;
515 1.7.2.2 nathanw int flag;
516 1.7.2.2 nathanw struct proc *p;
517 1.7.2.2 nathanw {
518 1.7.2.5 nathanw struct ed_softc *ed = device_lookup(&ed_cd, DISKUNIT(dev));
519 1.7.2.2 nathanw int error;
520 1.7.2.2 nathanw
521 1.7.2.2 nathanw WDCDEBUG_PRINT(("edioctl\n"), DEBUG_FUNCS);
522 1.7.2.2 nathanw
523 1.7.2.5 nathanw if ((ed->sc_flags & WDF_LOADED) == 0)
524 1.7.2.2 nathanw return EIO;
525 1.7.2.2 nathanw
526 1.7.2.2 nathanw switch (xfer) {
527 1.7.2.2 nathanw case DIOCGDINFO:
528 1.7.2.5 nathanw *(struct disklabel *)addr = *(ed->sc_dk.dk_label);
529 1.7.2.2 nathanw return 0;
530 1.7.2.2 nathanw
531 1.7.2.2 nathanw case DIOCGPART:
532 1.7.2.5 nathanw ((struct partinfo *)addr)->disklab = ed->sc_dk.dk_label;
533 1.7.2.2 nathanw ((struct partinfo *)addr)->part =
534 1.7.2.5 nathanw &ed->sc_dk.dk_label->d_partitions[DISKPART(dev)];
535 1.7.2.2 nathanw return 0;
536 1.7.2.3 nathanw
537 1.7.2.2 nathanw case DIOCWDINFO:
538 1.7.2.2 nathanw case DIOCSDINFO:
539 1.7.2.2 nathanw {
540 1.7.2.2 nathanw struct disklabel *lp;
541 1.7.2.2 nathanw
542 1.7.2.2 nathanw lp = (struct disklabel *)addr;
543 1.7.2.2 nathanw
544 1.7.2.2 nathanw if ((flag & FWRITE) == 0)
545 1.7.2.2 nathanw return EBADF;
546 1.7.2.2 nathanw
547 1.7.2.5 nathanw if ((error = ed_lock(ed)) != 0)
548 1.7.2.2 nathanw return error;
549 1.7.2.5 nathanw ed->sc_flags |= WDF_LABELLING;
550 1.7.2.2 nathanw
551 1.7.2.5 nathanw error = setdisklabel(ed->sc_dk.dk_label,
552 1.7.2.2 nathanw lp, /*wd->sc_dk.dk_openmask : */0,
553 1.7.2.5 nathanw ed->sc_dk.dk_cpulabel);
554 1.7.2.2 nathanw if (error == 0) {
555 1.7.2.2 nathanw #if 0
556 1.7.2.2 nathanw if (wd->drvp->state > RECAL)
557 1.7.2.2 nathanw wd->drvp->drive_flags |= DRIVE_RESET;
558 1.7.2.2 nathanw #endif
559 1.7.2.5 nathanw if (xfer == DIOCWDINFO)
560 1.7.2.2 nathanw error = writedisklabel(EDLABELDEV(dev),
561 1.7.2.5 nathanw edmcastrategy, ed->sc_dk.dk_label,
562 1.7.2.5 nathanw ed->sc_dk.dk_cpulabel);
563 1.7.2.2 nathanw }
564 1.7.2.2 nathanw
565 1.7.2.5 nathanw ed->sc_flags &= ~WDF_LABELLING;
566 1.7.2.5 nathanw ed_unlock(ed);
567 1.7.2.5 nathanw return (error);
568 1.7.2.2 nathanw }
569 1.7.2.2 nathanw
570 1.7.2.2 nathanw case DIOCKLABEL:
571 1.7.2.2 nathanw if (*(int *)addr)
572 1.7.2.5 nathanw ed->sc_flags |= WDF_KLABEL;
573 1.7.2.2 nathanw else
574 1.7.2.5 nathanw ed->sc_flags &= ~WDF_KLABEL;
575 1.7.2.2 nathanw return 0;
576 1.7.2.3 nathanw
577 1.7.2.2 nathanw case DIOCWLABEL:
578 1.7.2.2 nathanw if ((flag & FWRITE) == 0)
579 1.7.2.2 nathanw return EBADF;
580 1.7.2.2 nathanw if (*(int *)addr)
581 1.7.2.5 nathanw ed->sc_flags |= WDF_WLABEL;
582 1.7.2.2 nathanw else
583 1.7.2.5 nathanw ed->sc_flags &= ~WDF_WLABEL;
584 1.7.2.2 nathanw return 0;
585 1.7.2.2 nathanw
586 1.7.2.2 nathanw case DIOCGDEFLABEL:
587 1.7.2.5 nathanw edgetdefaultlabel(ed, (struct disklabel *)addr);
588 1.7.2.2 nathanw return 0;
589 1.7.2.2 nathanw
590 1.7.2.5 nathanw #if 0
591 1.7.2.2 nathanw case DIOCWFORMAT:
592 1.7.2.2 nathanw if ((flag & FWRITE) == 0)
593 1.7.2.2 nathanw return EBADF;
594 1.7.2.2 nathanw {
595 1.7.2.2 nathanw register struct format_op *fop;
596 1.7.2.2 nathanw struct iovec aiov;
597 1.7.2.2 nathanw struct uio auio;
598 1.7.2.3 nathanw
599 1.7.2.2 nathanw fop = (struct format_op *)addr;
600 1.7.2.2 nathanw aiov.iov_base = fop->df_buf;
601 1.7.2.2 nathanw aiov.iov_len = fop->df_count;
602 1.7.2.2 nathanw auio.uio_iov = &aiov;
603 1.7.2.2 nathanw auio.uio_iovcnt = 1;
604 1.7.2.2 nathanw auio.uio_resid = fop->df_count;
605 1.7.2.2 nathanw auio.uio_segflg = 0;
606 1.7.2.2 nathanw auio.uio_offset =
607 1.7.2.2 nathanw fop->df_startblk * wd->sc_dk.dk_label->d_secsize;
608 1.7.2.2 nathanw auio.uio_procp = p;
609 1.7.2.2 nathanw error = physio(wdformat, NULL, dev, B_WRITE, minphys,
610 1.7.2.2 nathanw &auio);
611 1.7.2.2 nathanw fop->df_count -= auio.uio_resid;
612 1.7.2.2 nathanw fop->df_reg[0] = wdc->sc_status;
613 1.7.2.2 nathanw fop->df_reg[1] = wdc->sc_error;
614 1.7.2.2 nathanw return error;
615 1.7.2.2 nathanw }
616 1.7.2.2 nathanw #endif
617 1.7.2.2 nathanw
618 1.7.2.2 nathanw default:
619 1.7.2.2 nathanw return ENOTTY;
620 1.7.2.2 nathanw }
621 1.7.2.2 nathanw
622 1.7.2.2 nathanw #ifdef DIAGNOSTIC
623 1.7.2.2 nathanw panic("edioctl: impossible");
624 1.7.2.2 nathanw #endif
625 1.7.2.2 nathanw }
626 1.7.2.2 nathanw
627 1.7.2.2 nathanw int
628 1.7.2.2 nathanw edmcasize(dev)
629 1.7.2.2 nathanw dev_t dev;
630 1.7.2.2 nathanw {
631 1.7.2.2 nathanw struct ed_softc *wd;
632 1.7.2.2 nathanw int part, omask;
633 1.7.2.2 nathanw int size;
634 1.7.2.2 nathanw
635 1.7.2.2 nathanw WDCDEBUG_PRINT(("edsize\n"), DEBUG_FUNCS);
636 1.7.2.2 nathanw
637 1.7.2.2 nathanw wd = device_lookup(&ed_cd, DISKUNIT(dev));
638 1.7.2.2 nathanw if (wd == NULL)
639 1.7.2.2 nathanw return (-1);
640 1.7.2.2 nathanw
641 1.7.2.2 nathanw part = DISKPART(dev);
642 1.7.2.2 nathanw omask = wd->sc_dk.dk_openmask & (1 << part);
643 1.7.2.2 nathanw
644 1.7.2.2 nathanw if (omask == 0 && edmcaopen(dev, 0, S_IFBLK, NULL) != 0)
645 1.7.2.2 nathanw return (-1);
646 1.7.2.2 nathanw if (wd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
647 1.7.2.2 nathanw size = -1;
648 1.7.2.2 nathanw else
649 1.7.2.2 nathanw size = wd->sc_dk.dk_label->d_partitions[part].p_size *
650 1.7.2.2 nathanw (wd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
651 1.7.2.2 nathanw if (omask == 0 && edmcaclose(dev, 0, S_IFBLK, NULL) != 0)
652 1.7.2.2 nathanw return (-1);
653 1.7.2.2 nathanw return (size);
654 1.7.2.2 nathanw }
655 1.7.2.2 nathanw
656 1.7.2.2 nathanw /* #define WD_DUMP_NOT_TRUSTED if you just want to watch */
657 1.7.2.2 nathanw static int eddoingadump = 0;
658 1.7.2.2 nathanw static int eddumprecalibrated = 0;
659 1.7.2.2 nathanw static int eddumpmulti = 1;
660 1.7.2.2 nathanw
661 1.7.2.2 nathanw /*
662 1.7.2.2 nathanw * Dump core after a system crash.
663 1.7.2.2 nathanw */
664 1.7.2.2 nathanw int
665 1.7.2.2 nathanw edmcadump(dev, blkno, va, size)
666 1.7.2.2 nathanw dev_t dev;
667 1.7.2.2 nathanw daddr_t blkno;
668 1.7.2.2 nathanw caddr_t va;
669 1.7.2.2 nathanw size_t size;
670 1.7.2.2 nathanw {
671 1.7.2.2 nathanw struct ed_softc *ed; /* disk unit to do the I/O */
672 1.7.2.2 nathanw struct disklabel *lp; /* disk's disklabel */
673 1.7.2.2 nathanw int part;
674 1.7.2.2 nathanw int nblks; /* total number of sectors left to write */
675 1.7.2.5 nathanw int error;
676 1.7.2.2 nathanw
677 1.7.2.2 nathanw /* Check if recursive dump; if so, punt. */
678 1.7.2.2 nathanw if (eddoingadump)
679 1.7.2.2 nathanw return EFAULT;
680 1.7.2.2 nathanw eddoingadump = 1;
681 1.7.2.2 nathanw
682 1.7.2.2 nathanw ed = device_lookup(&ed_cd, DISKUNIT(dev));
683 1.7.2.2 nathanw if (ed == NULL)
684 1.7.2.2 nathanw return (ENXIO);
685 1.7.2.2 nathanw
686 1.7.2.2 nathanw part = DISKPART(dev);
687 1.7.2.2 nathanw
688 1.7.2.2 nathanw /* Make sure it was initialized. */
689 1.7.2.2 nathanw if ((ed->sc_flags & EDF_INIT) == 0)
690 1.7.2.2 nathanw return ENXIO;
691 1.7.2.2 nathanw
692 1.7.2.2 nathanw /* Convert to disk sectors. Request must be a multiple of size. */
693 1.7.2.2 nathanw lp = ed->sc_dk.dk_label;
694 1.7.2.2 nathanw if ((size % lp->d_secsize) != 0)
695 1.7.2.2 nathanw return EFAULT;
696 1.7.2.2 nathanw nblks = size / lp->d_secsize;
697 1.7.2.2 nathanw blkno = blkno / (lp->d_secsize / DEV_BSIZE);
698 1.7.2.2 nathanw
699 1.7.2.2 nathanw /* Check transfer bounds against partition size. */
700 1.7.2.2 nathanw if ((blkno < 0) || ((blkno + nblks) > lp->d_partitions[part].p_size))
701 1.7.2.3 nathanw return EINVAL;
702 1.7.2.2 nathanw
703 1.7.2.2 nathanw /* Offset block number to start of partition. */
704 1.7.2.2 nathanw blkno += lp->d_partitions[part].p_offset;
705 1.7.2.2 nathanw
706 1.7.2.2 nathanw /* Recalibrate, if first dump transfer. */
707 1.7.2.2 nathanw if (eddumprecalibrated == 0) {
708 1.7.2.2 nathanw eddumprecalibrated = 1;
709 1.7.2.2 nathanw eddumpmulti = 8;
710 1.7.2.2 nathanw #if 0
711 1.7.2.2 nathanw wd->drvp->state = RESET;
712 1.7.2.2 nathanw #endif
713 1.7.2.2 nathanw }
714 1.7.2.3 nathanw
715 1.7.2.2 nathanw while (nblks > 0) {
716 1.7.2.5 nathanw error = edc_bio(ed->edc_softc, ed, va, blkno,
717 1.7.2.5 nathanw min(nblks, eddumpmulti) * lp->d_secsize, 0, 1);
718 1.7.2.5 nathanw if (error)
719 1.7.2.5 nathanw return (error);
720 1.7.2.2 nathanw
721 1.7.2.2 nathanw /* update block count */
722 1.7.2.2 nathanw nblks -= min(nblks, eddumpmulti);
723 1.7.2.2 nathanw blkno += min(nblks, eddumpmulti);
724 1.7.2.2 nathanw va += min(nblks, eddumpmulti) * lp->d_secsize;
725 1.7.2.2 nathanw }
726 1.7.2.2 nathanw
727 1.7.2.2 nathanw eddoingadump = 0;
728 1.7.2.2 nathanw return (0);
729 1.7.2.2 nathanw }
730 1.7.2.2 nathanw
731 1.7.2.2 nathanw static int
732 1.7.2.5 nathanw ed_get_params(ed, drv_flags)
733 1.7.2.2 nathanw struct ed_softc *ed;
734 1.7.2.5 nathanw int *drv_flags;
735 1.7.2.2 nathanw {
736 1.7.2.2 nathanw u_int16_t cmd_args[2];
737 1.7.2.2 nathanw
738 1.7.2.2 nathanw /*
739 1.7.2.2 nathanw * Get Device Configuration (09).
740 1.7.2.2 nathanw */
741 1.7.2.2 nathanw cmd_args[0] = 14; /* Options: 00s110, s: 0=Physical 1=Pseudo */
742 1.7.2.2 nathanw cmd_args[1] = 0;
743 1.7.2.2 nathanw if (edc_run_cmd(ed->edc_softc, CMD_GET_DEV_CONF, ed->sc_devno,
744 1.7.2.5 nathanw cmd_args, 2, 1))
745 1.7.2.2 nathanw return (1);
746 1.7.2.2 nathanw
747 1.7.2.5 nathanw ed->spares = ed->sense_data[1] >> 8;
748 1.7.2.5 nathanw if (drv_flags)
749 1.7.2.5 nathanw *drv_flags = ed->sense_data[1] & 0x1f;
750 1.7.2.5 nathanw ed->rba = ed->sense_data[2] | (ed->sense_data[3] << 16);
751 1.7.2.2 nathanw /* Instead of using:
752 1.7.2.5 nathanw ed->cyl = ed->sense_data[4];
753 1.7.2.5 nathanw ed->heads = ed->sense_data[5] & 0xff;
754 1.7.2.5 nathanw ed->sectors = ed->sense_data[5] >> 8;
755 1.7.2.2 nathanw * we fabricate the numbers from RBA count, so that
756 1.7.2.2 nathanw * number of sectors is 32 and heads 64. This seems
757 1.7.2.2 nathanw * to be necessary for integrated ESDI controller.
758 1.7.2.2 nathanw */
759 1.7.2.2 nathanw ed->sectors = 32;
760 1.7.2.2 nathanw ed->heads = 64;
761 1.7.2.2 nathanw ed->cyl = ed->rba / (ed->heads * ed->sectors);
762 1.7.2.2 nathanw ed->sc_capacity = ed->rba;
763 1.7.2.2 nathanw
764 1.7.2.2 nathanw return (0);
765 1.7.2.2 nathanw }
766