ed_mca.c revision 1.2.2.3 1 1.2.2.3 bouyer /* $NetBSD: ed_mca.c,v 1.2.2.3 2001/04/23 09:42:22 bouyer Exp $ */
2 1.2.2.2 bouyer
3 1.2.2.2 bouyer /*
4 1.2.2.2 bouyer * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.2.2.2 bouyer *
6 1.2.2.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
7 1.2.2.2 bouyer * by Jaromir Dolecek.
8 1.2.2.2 bouyer *
9 1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
10 1.2.2.2 bouyer * modification, are permitted provided that the following conditions
11 1.2.2.2 bouyer * are met:
12 1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
13 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer.
14 1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
15 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
16 1.2.2.2 bouyer * documentation and/or other materials provided with the distribution.
17 1.2.2.2 bouyer * 3. All advertising materials mentioning features or use of this software
18 1.2.2.2 bouyer * must display the following acknowledgement:
19 1.2.2.2 bouyer * This product includes software developed by the NetBSD
20 1.2.2.2 bouyer * Foundation, Inc. and its contributors.
21 1.2.2.2 bouyer * 4. The name of the author may not be used to endorse or promote products
22 1.2.2.2 bouyer * derived from this software without specific prior written permission.
23 1.2.2.2 bouyer *
24 1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 1.2.2.2 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 1.2.2.2 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 1.2.2.2 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 1.2.2.2 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 1.2.2.2 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 1.2.2.2 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 1.2.2.2 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 1.2.2.2 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 1.2.2.2 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 1.2.2.2 bouyer */
35 1.2.2.2 bouyer
36 1.2.2.2 bouyer /*
37 1.2.2.2 bouyer * Disk goo for MCA ESDI controller driver.
38 1.2.2.2 bouyer */
39 1.2.2.2 bouyer
40 1.2.2.2 bouyer #include "rnd.h"
41 1.2.2.2 bouyer
42 1.2.2.2 bouyer #include <sys/param.h>
43 1.2.2.2 bouyer #include <sys/systm.h>
44 1.2.2.2 bouyer #include <sys/kernel.h>
45 1.2.2.2 bouyer #include <sys/conf.h>
46 1.2.2.2 bouyer #include <sys/file.h>
47 1.2.2.2 bouyer #include <sys/stat.h>
48 1.2.2.2 bouyer #include <sys/ioctl.h>
49 1.2.2.2 bouyer #include <sys/buf.h>
50 1.2.2.2 bouyer #include <sys/uio.h>
51 1.2.2.2 bouyer #include <sys/malloc.h>
52 1.2.2.2 bouyer #include <sys/device.h>
53 1.2.2.2 bouyer #include <sys/disklabel.h>
54 1.2.2.2 bouyer #include <sys/disk.h>
55 1.2.2.2 bouyer #include <sys/syslog.h>
56 1.2.2.2 bouyer #include <sys/proc.h>
57 1.2.2.2 bouyer #include <sys/vnode.h>
58 1.2.2.2 bouyer #include <sys/kthread.h>
59 1.2.2.2 bouyer #if NRND > 0
60 1.2.2.2 bouyer #include <sys/rnd.h>
61 1.2.2.2 bouyer #endif
62 1.2.2.2 bouyer
63 1.2.2.2 bouyer #include <machine/intr.h>
64 1.2.2.2 bouyer #include <machine/bus.h>
65 1.2.2.2 bouyer
66 1.2.2.3 bouyer #include <dev/mca/mcavar.h>
67 1.2.2.3 bouyer
68 1.2.2.3 bouyer #include <dev/mca/edcreg.h>
69 1.2.2.2 bouyer #include <dev/mca/edvar.h>
70 1.2.2.3 bouyer #include <dev/mca/edcvar.h>
71 1.2.2.2 bouyer
72 1.2.2.2 bouyer /* #define WDCDEBUG */
73 1.2.2.2 bouyer
74 1.2.2.2 bouyer #ifdef WDCDEBUG
75 1.2.2.2 bouyer #define WDCDEBUG_PRINT(args, level) printf args
76 1.2.2.2 bouyer #else
77 1.2.2.2 bouyer #define WDCDEBUG_PRINT(args, level)
78 1.2.2.2 bouyer #endif
79 1.2.2.2 bouyer
80 1.2.2.2 bouyer #define EDLABELDEV(dev) (MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART))
81 1.2.2.2 bouyer
82 1.2.2.2 bouyer /* XXX: these should go elsewhere */
83 1.2.2.2 bouyer cdev_decl(edmca);
84 1.2.2.2 bouyer bdev_decl(edmca);
85 1.2.2.2 bouyer
86 1.2.2.2 bouyer static int ed_mca_probe __P((struct device *, struct cfdata *, void *));
87 1.2.2.2 bouyer static void ed_mca_attach __P((struct device *, struct device *, void *));
88 1.2.2.2 bouyer
89 1.2.2.2 bouyer struct cfattach ed_mca_ca = {
90 1.2.2.2 bouyer sizeof(struct ed_softc), ed_mca_probe, ed_mca_attach
91 1.2.2.2 bouyer };
92 1.2.2.2 bouyer
93 1.2.2.2 bouyer extern struct cfdriver ed_cd;
94 1.2.2.2 bouyer
95 1.2.2.2 bouyer static int ed_get_params __P((struct ed_softc *));
96 1.2.2.2 bouyer static int ed_lock __P((struct ed_softc *));
97 1.2.2.2 bouyer static void ed_unlock __P((struct ed_softc *));
98 1.2.2.2 bouyer static void edgetdisklabel __P((struct ed_softc *));
99 1.2.2.2 bouyer static void edgetdefaultlabel __P((struct ed_softc *, struct disklabel *));
100 1.2.2.2 bouyer static void ed_shutdown __P((void*));
101 1.2.2.2 bouyer static void __edstart __P((struct ed_softc*, struct buf *));
102 1.2.2.2 bouyer static void bad144intern __P((struct ed_softc *));
103 1.2.2.2 bouyer static void edworker __P((void *));
104 1.2.2.2 bouyer static void ed_spawn_worker __P((void *));
105 1.2.2.2 bouyer static void edmcadone __P((struct ed_softc *));
106 1.2.2.2 bouyer
107 1.2.2.2 bouyer static struct dkdriver eddkdriver = { edmcastrategy };
108 1.2.2.2 bouyer
109 1.2.2.2 bouyer /*
110 1.2.2.2 bouyer * Just check if it's possible to identify the disk.
111 1.2.2.2 bouyer */
112 1.2.2.2 bouyer static int
113 1.2.2.2 bouyer ed_mca_probe(parent, match, aux)
114 1.2.2.2 bouyer struct device *parent;
115 1.2.2.2 bouyer struct cfdata *match;
116 1.2.2.2 bouyer void *aux;
117 1.2.2.2 bouyer {
118 1.2.2.2 bouyer u_int16_t cmd_args[2];
119 1.2.2.3 bouyer struct edc_mca_softc *sc = (void *) parent;
120 1.2.2.2 bouyer struct ed_attach_args *eda = (void *) aux;
121 1.2.2.2 bouyer
122 1.2.2.2 bouyer /*
123 1.2.2.2 bouyer * Get Device Configuration (09).
124 1.2.2.2 bouyer */
125 1.2.2.2 bouyer cmd_args[0] = 6; /* Options: 00s110, s: 0=Physical 1=Pseudo */
126 1.2.2.2 bouyer cmd_args[1] = 0;
127 1.2.2.3 bouyer if (edc_run_cmd(sc, CMD_GET_DEV_CONF, eda->sc_devno, cmd_args, 2, 0))
128 1.2.2.2 bouyer return (0);
129 1.2.2.2 bouyer
130 1.2.2.2 bouyer return (1);
131 1.2.2.2 bouyer }
132 1.2.2.2 bouyer
133 1.2.2.2 bouyer static void
134 1.2.2.2 bouyer ed_mca_attach(parent, self, aux)
135 1.2.2.2 bouyer struct device *parent, *self;
136 1.2.2.2 bouyer void *aux;
137 1.2.2.2 bouyer {
138 1.2.2.2 bouyer struct ed_softc *ed = (void *) self;
139 1.2.2.3 bouyer struct edc_mca_softc *sc = (void *) parent;
140 1.2.2.2 bouyer struct ed_attach_args *eda = (void *) aux;
141 1.2.2.2 bouyer char pbuf[8];
142 1.2.2.2 bouyer int error, nsegs;
143 1.2.2.2 bouyer
144 1.2.2.3 bouyer ed->edc_softc = sc;
145 1.2.2.2 bouyer ed->sc_dmat = eda->sc_dmat;
146 1.2.2.2 bouyer ed->sc_devno = eda->sc_devno;
147 1.2.2.3 bouyer edc_add_disk(sc, ed, eda->sc_devno);
148 1.2.2.2 bouyer
149 1.2.2.2 bouyer BUFQ_INIT(&ed->sc_q);
150 1.2.2.2 bouyer spinlockinit(&ed->sc_q_lock, "edbqlock", 0);
151 1.2.2.3 bouyer lockinit(&ed->sc_lock, PRIBIO | PCATCH, "edlck", 0, 0);
152 1.2.2.2 bouyer
153 1.2.2.2 bouyer if (ed_get_params(ed)) {
154 1.2.2.2 bouyer printf(": IDENTIFY failed, no disk found\n");
155 1.2.2.2 bouyer return;
156 1.2.2.2 bouyer }
157 1.2.2.2 bouyer
158 1.2.2.2 bouyer format_bytes(pbuf, sizeof(pbuf),
159 1.2.2.2 bouyer (u_int64_t) ed->sc_capacity * DEV_BSIZE);
160 1.2.2.2 bouyer printf(": %s, %u cyl, %u head, %u sec, 512 bytes/sect x %u sectors\n",
161 1.2.2.2 bouyer pbuf,
162 1.2.2.2 bouyer ed->cyl, ed->heads, ed->sectors,
163 1.2.2.2 bouyer ed->sc_capacity);
164 1.2.2.2 bouyer
165 1.2.2.2 bouyer printf("%s: %u spares/cyl, %s.%s.%s.%s.%s\n",
166 1.2.2.2 bouyer ed->sc_dev.dv_xname, ed->spares,
167 1.2.2.2 bouyer (ed->drv_flags & (1 << 0)) ? "NoRetries" : "Retries",
168 1.2.2.2 bouyer (ed->drv_flags & (1 << 1)) ? "Removable" : "Fixed",
169 1.2.2.2 bouyer (ed->drv_flags & (1 << 2)) ? "SkewedFormat" : "NoSkew",
170 1.2.2.2 bouyer (ed->drv_flags & (1 << 3)) ? "ZeroDefect" : "Defects",
171 1.2.2.2 bouyer (ed->drv_flags & (1 << 4)) ? "InvalidSecondary" : "SeconOK"
172 1.2.2.2 bouyer );
173 1.2.2.2 bouyer
174 1.2.2.2 bouyer /* Create a DMA map for mapping individual transfer bufs */
175 1.2.2.2 bouyer if ((error = bus_dmamap_create(ed->sc_dmat, 65536, 1,
176 1.2.2.3 bouyer 65536, 65536, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
177 1.2.2.2 bouyer &ed->dmamap_xfer)) != 0) {
178 1.2.2.2 bouyer printf("%s: unable to create xfer DMA map, error=%d\n",
179 1.2.2.2 bouyer ed->sc_dev.dv_xname, error);
180 1.2.2.2 bouyer return;
181 1.2.2.2 bouyer }
182 1.2.2.2 bouyer
183 1.2.2.2 bouyer /*
184 1.2.2.2 bouyer * Allocate DMA memory used in case where passed buf isn't
185 1.2.2.2 bouyer * physically contiguous.
186 1.2.2.2 bouyer */
187 1.2.2.3 bouyer ed->sc_dmam_sz = MAXPHYS;
188 1.2.2.2 bouyer if ((error = bus_dmamem_alloc(ed->sc_dmat, ed->sc_dmam_sz,
189 1.2.2.3 bouyer ed->sc_dmam_sz, 65536, ed->sc_dmam, 1, &nsegs,
190 1.2.2.2 bouyer BUS_DMA_WAITOK|BUS_DMA_STREAMING)) != 0) {
191 1.2.2.2 bouyer printf("%s: unable to allocate DMA memory for xfer, errno=%d\n",
192 1.2.2.2 bouyer ed->sc_dev.dv_xname, error);
193 1.2.2.2 bouyer bus_dmamap_destroy(ed->sc_dmat, ed->dmamap_xfer);
194 1.2.2.2 bouyer return;
195 1.2.2.2 bouyer }
196 1.2.2.2 bouyer /*
197 1.2.2.2 bouyer * Map the memory.
198 1.2.2.2 bouyer */
199 1.2.2.2 bouyer if ((error = bus_dmamem_map(ed->sc_dmat, ed->sc_dmam, 1,
200 1.2.2.2 bouyer ed->sc_dmam_sz, &ed->sc_dmamkva, BUS_DMA_WAITOK)) != 0) {
201 1.2.2.2 bouyer printf("%s: unable to map DMA memory, error=%d\n",
202 1.2.2.2 bouyer ed->sc_dev.dv_xname, error);
203 1.2.2.2 bouyer bus_dmamem_free(ed->sc_dmat, ed->sc_dmam, 1);
204 1.2.2.2 bouyer bus_dmamap_destroy(ed->sc_dmat, ed->dmamap_xfer);
205 1.2.2.2 bouyer return;
206 1.2.2.2 bouyer }
207 1.2.2.2 bouyer
208 1.2.2.2 bouyer
209 1.2.2.2 bouyer /*
210 1.2.2.2 bouyer * Initialize and attach the disk structure.
211 1.2.2.2 bouyer */
212 1.2.2.2 bouyer ed->sc_dk.dk_driver = &eddkdriver;
213 1.2.2.2 bouyer ed->sc_dk.dk_name = ed->sc_dev.dv_xname;
214 1.2.2.2 bouyer disk_attach(&ed->sc_dk);
215 1.2.2.2 bouyer #if 0
216 1.2.2.2 bouyer wd->sc_wdc_bio.lp = wd->sc_dk.dk_label;
217 1.2.2.2 bouyer #endif
218 1.2.2.2 bouyer ed->sc_sdhook = shutdownhook_establish(ed_shutdown, ed);
219 1.2.2.2 bouyer if (ed->sc_sdhook == NULL)
220 1.2.2.2 bouyer printf("%s: WARNING: unable to establish shutdown hook\n",
221 1.2.2.2 bouyer ed->sc_dev.dv_xname);
222 1.2.2.2 bouyer #if NRND > 0
223 1.2.2.2 bouyer rnd_attach_source(&ed->rnd_source, ed->sc_dev.dv_xname,
224 1.2.2.2 bouyer RND_TYPE_DISK, 0);
225 1.2.2.2 bouyer #endif
226 1.2.2.2 bouyer
227 1.2.2.2 bouyer config_pending_incr();
228 1.2.2.2 bouyer kthread_create(ed_spawn_worker, (void *) ed);
229 1.2.2.2 bouyer }
230 1.2.2.2 bouyer
231 1.2.2.2 bouyer void
232 1.2.2.2 bouyer ed_spawn_worker(arg)
233 1.2.2.2 bouyer void *arg;
234 1.2.2.2 bouyer {
235 1.2.2.2 bouyer struct ed_softc *ed = (struct ed_softc *) arg;
236 1.2.2.2 bouyer int error;
237 1.2.2.2 bouyer
238 1.2.2.2 bouyer /* Now, everything is ready, start a kthread */
239 1.2.2.2 bouyer if ((error = kthread_create1(edworker, ed, &ed->sc_worker,
240 1.2.2.2 bouyer "%s", ed->sc_dev.dv_xname))) {
241 1.2.2.2 bouyer printf("%s: cannot spawn worker thread: errno=%d\n",
242 1.2.2.2 bouyer ed->sc_dev.dv_xname, error);
243 1.2.2.2 bouyer panic("ed_spawn_worker");
244 1.2.2.2 bouyer }
245 1.2.2.2 bouyer }
246 1.2.2.2 bouyer
247 1.2.2.2 bouyer /*
248 1.2.2.2 bouyer * Read/write routine for a buffer. Validates the arguments and schedules the
249 1.2.2.2 bouyer * transfer. Does not wait for the transfer to complete.
250 1.2.2.2 bouyer */
251 1.2.2.2 bouyer void
252 1.2.2.2 bouyer edmcastrategy(bp)
253 1.2.2.2 bouyer struct buf *bp;
254 1.2.2.2 bouyer {
255 1.2.2.2 bouyer struct ed_softc *wd = device_lookup(&ed_cd, DISKUNIT(bp->b_dev));
256 1.2.2.2 bouyer struct disklabel *lp = wd->sc_dk.dk_label;
257 1.2.2.2 bouyer daddr_t blkno;
258 1.2.2.2 bouyer int s;
259 1.2.2.2 bouyer
260 1.2.2.2 bouyer WDCDEBUG_PRINT(("edmcastrategy (%s)\n", wd->sc_dev.dv_xname),
261 1.2.2.2 bouyer DEBUG_XFERS);
262 1.2.2.2 bouyer
263 1.2.2.2 bouyer /* Valid request? */
264 1.2.2.2 bouyer if (bp->b_blkno < 0 ||
265 1.2.2.2 bouyer (bp->b_bcount % lp->d_secsize) != 0 ||
266 1.2.2.2 bouyer (bp->b_bcount / lp->d_secsize) >= (1 << NBBY)) {
267 1.2.2.2 bouyer bp->b_error = EINVAL;
268 1.2.2.2 bouyer goto bad;
269 1.2.2.2 bouyer }
270 1.2.2.2 bouyer
271 1.2.2.2 bouyer /* If device invalidated (e.g. media change, door open), error. */
272 1.2.2.2 bouyer if ((wd->sc_flags & WDF_LOADED) == 0) {
273 1.2.2.2 bouyer bp->b_error = EIO;
274 1.2.2.2 bouyer goto bad;
275 1.2.2.2 bouyer }
276 1.2.2.2 bouyer
277 1.2.2.2 bouyer /* If it's a null transfer, return immediately. */
278 1.2.2.2 bouyer if (bp->b_bcount == 0)
279 1.2.2.2 bouyer goto done;
280 1.2.2.2 bouyer
281 1.2.2.2 bouyer /*
282 1.2.2.2 bouyer * Do bounds checking, adjust transfer. if error, process.
283 1.2.2.2 bouyer * If end of partition, just return.
284 1.2.2.2 bouyer */
285 1.2.2.2 bouyer if (DISKPART(bp->b_dev) != RAW_PART &&
286 1.2.2.2 bouyer bounds_check_with_label(bp, wd->sc_dk.dk_label,
287 1.2.2.2 bouyer (wd->sc_flags & (WDF_WLABEL|WDF_LABELLING)) != 0) <= 0)
288 1.2.2.2 bouyer goto done;
289 1.2.2.2 bouyer
290 1.2.2.2 bouyer /*
291 1.2.2.2 bouyer * Now convert the block number to absolute and put it in
292 1.2.2.2 bouyer * terms of the device's logical block size.
293 1.2.2.2 bouyer */
294 1.2.2.2 bouyer if (lp->d_secsize >= DEV_BSIZE)
295 1.2.2.2 bouyer blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
296 1.2.2.2 bouyer else
297 1.2.2.2 bouyer blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
298 1.2.2.2 bouyer
299 1.2.2.2 bouyer if (DISKPART(bp->b_dev) != RAW_PART)
300 1.2.2.2 bouyer blkno += lp->d_partitions[DISKPART(bp->b_dev)].p_offset;
301 1.2.2.2 bouyer
302 1.2.2.2 bouyer bp->b_rawblkno = blkno;
303 1.2.2.2 bouyer
304 1.2.2.2 bouyer /* Queue transfer on drive, activate drive and controller if idle. */
305 1.2.2.2 bouyer s = splbio();
306 1.2.2.2 bouyer simple_lock(&wd->sc_q_lock);
307 1.2.2.2 bouyer disksort_blkno(&wd->sc_q, bp);
308 1.2.2.2 bouyer simple_unlock(&wd->sc_q_lock);
309 1.2.2.2 bouyer
310 1.2.2.2 bouyer /* Ring the worker thread */
311 1.2.2.2 bouyer wd->sc_flags |= EDF_PROCESS_QUEUE;
312 1.2.2.2 bouyer wakeup_one(&wd->sc_q);
313 1.2.2.2 bouyer
314 1.2.2.2 bouyer splx(s);
315 1.2.2.2 bouyer return;
316 1.2.2.2 bouyer bad:
317 1.2.2.2 bouyer bp->b_flags |= B_ERROR;
318 1.2.2.2 bouyer done:
319 1.2.2.2 bouyer /* Toss transfer; we're done early. */
320 1.2.2.2 bouyer bp->b_resid = bp->b_bcount;
321 1.2.2.2 bouyer biodone(bp);
322 1.2.2.2 bouyer }
323 1.2.2.2 bouyer
324 1.2.2.2 bouyer static void
325 1.2.2.2 bouyer __edstart(ed, bp)
326 1.2.2.2 bouyer struct ed_softc *ed;
327 1.2.2.2 bouyer struct buf *bp;
328 1.2.2.2 bouyer {
329 1.2.2.2 bouyer u_int16_t cmd_args[4];
330 1.2.2.3 bouyer int error=0;
331 1.2.2.2 bouyer u_int16_t track;
332 1.2.2.2 bouyer u_int16_t cyl;
333 1.2.2.2 bouyer u_int8_t head;
334 1.2.2.2 bouyer u_int8_t sector;
335 1.2.2.2 bouyer
336 1.2.2.3 bouyer WDCDEBUG_PRINT(("__edstart %s (%s): %lu %lu %u\n", ed->sc_dev.dv_xname,
337 1.2.2.3 bouyer (bp->b_flags & B_READ) ? "read" : "write",
338 1.2.2.2 bouyer bp->b_bcount, bp->b_resid, bp->b_rawblkno),
339 1.2.2.2 bouyer DEBUG_XFERS);
340 1.2.2.2 bouyer
341 1.2.2.2 bouyer ed->sc_bp = bp;
342 1.2.2.2 bouyer
343 1.2.2.3 bouyer /* Get physical bus mapping for buf. */
344 1.2.2.3 bouyer if (bus_dmamap_load(ed->sc_dmat, ed->dmamap_xfer,
345 1.2.2.2 bouyer bp->b_data, bp->b_bcount, NULL,
346 1.2.2.3 bouyer BUS_DMA_WAITOK|BUS_DMA_STREAMING) != 0) {
347 1.2.2.2 bouyer
348 1.2.2.2 bouyer /*
349 1.2.2.2 bouyer * Use our DMA safe memory to get data to/from device.
350 1.2.2.2 bouyer */
351 1.2.2.2 bouyer if ((error = bus_dmamap_load(ed->sc_dmat, ed->dmamap_xfer,
352 1.2.2.2 bouyer ed->sc_dmamkva, bp->b_bcount, NULL,
353 1.2.2.2 bouyer BUS_DMA_WAITOK|BUS_DMA_STREAMING)) != 0) {
354 1.2.2.2 bouyer printf("%s: unable to load raw data for xfer, errno=%d\n",
355 1.2.2.2 bouyer ed->sc_dev.dv_xname, error);
356 1.2.2.2 bouyer goto out;
357 1.2.2.2 bouyer }
358 1.2.2.2 bouyer ed->sc_flags |= EDF_BOUNCEBUF;
359 1.2.2.2 bouyer
360 1.2.2.2 bouyer /* If data write, copy the data to our bounce buffer. */
361 1.2.2.2 bouyer if ((bp->b_flags & B_READ) == 0)
362 1.2.2.2 bouyer memcpy(ed->sc_dmamkva, bp->b_data, bp->b_bcount);
363 1.2.2.2 bouyer }
364 1.2.2.3 bouyer
365 1.2.2.2 bouyer ed->sc_flags |= EDF_DMAMAP_LOADED;
366 1.2.2.2 bouyer
367 1.2.2.2 bouyer track = bp->b_rawblkno / ed->sectors;
368 1.2.2.2 bouyer head = track % ed->heads;
369 1.2.2.2 bouyer cyl = track / ed->heads;
370 1.2.2.2 bouyer sector = bp->b_rawblkno % ed->sectors;
371 1.2.2.2 bouyer
372 1.2.2.2 bouyer WDCDEBUG_PRINT(("__edstart %s: map: %u %u %u\n", ed->sc_dev.dv_xname,
373 1.2.2.2 bouyer cyl, sector, head),
374 1.2.2.2 bouyer DEBUG_XFERS);
375 1.2.2.2 bouyer
376 1.2.2.2 bouyer /* Instrumentation. */
377 1.2.2.2 bouyer disk_busy(&ed->sc_dk);
378 1.2.2.3 bouyer ed->sc_flags |= EDF_DK_BUSY;
379 1.2.2.3 bouyer mca_disk_busy();
380 1.2.2.2 bouyer
381 1.2.2.2 bouyer /* Read or Write Data command */
382 1.2.2.2 bouyer cmd_args[0] = 2; /* Options 0000010 */
383 1.2.2.2 bouyer cmd_args[1] = bp->b_bcount / DEV_BSIZE;
384 1.2.2.2 bouyer cmd_args[2] = ((cyl & 0x1f) << 11) | (head << 5) | sector;
385 1.2.2.2 bouyer cmd_args[3] = ((cyl & 0x3E0) >> 5);
386 1.2.2.3 bouyer if (edc_run_cmd(ed->edc_softc,
387 1.2.2.2 bouyer (bp->b_flags & B_READ) ? CMD_READ_DATA : CMD_WRITE_DATA,
388 1.2.2.2 bouyer ed->sc_devno, cmd_args, 4, 1)) {
389 1.2.2.2 bouyer printf("%s: data i/o command failed\n", ed->sc_dev.dv_xname);
390 1.2.2.2 bouyer error = EIO;
391 1.2.2.2 bouyer }
392 1.2.2.2 bouyer
393 1.2.2.2 bouyer out:
394 1.2.2.2 bouyer if (error)
395 1.2.2.2 bouyer ed->sc_error = error;
396 1.2.2.2 bouyer }
397 1.2.2.2 bouyer
398 1.2.2.2 bouyer
399 1.2.2.2 bouyer static void
400 1.2.2.2 bouyer edmcadone(ed)
401 1.2.2.2 bouyer struct ed_softc *ed;
402 1.2.2.2 bouyer {
403 1.2.2.2 bouyer struct buf *bp = ed->sc_bp;
404 1.2.2.2 bouyer
405 1.2.2.2 bouyer WDCDEBUG_PRINT(("eddone %s\n", ed->sc_dev.dv_xname),
406 1.2.2.2 bouyer DEBUG_XFERS);
407 1.2.2.2 bouyer
408 1.2.2.2 bouyer if (ed->sc_error) {
409 1.2.2.2 bouyer bp->b_error = ed->sc_error;
410 1.2.2.2 bouyer bp->b_flags |= B_ERROR;
411 1.2.2.3 bouyer } else {
412 1.2.2.3 bouyer /* Set resid, most commonly to zero. */
413 1.2.2.3 bouyer bp->b_resid = ed->sc_status_block[SB_RESBLKCNT_IDX] * DEV_BSIZE;
414 1.2.2.2 bouyer }
415 1.2.2.2 bouyer
416 1.2.2.3 bouyer /*
417 1.2.2.3 bouyer * If read transfer finished without error and using a bounce
418 1.2.2.3 bouyer * buffer, copy the data to buf.
419 1.2.2.3 bouyer */
420 1.2.2.2 bouyer if ((bp->b_flags & B_ERROR) == 0 && (ed->sc_flags & EDF_BOUNCEBUF)
421 1.2.2.2 bouyer && (bp->b_flags & B_READ)) {
422 1.2.2.2 bouyer memcpy(bp->b_data, ed->sc_dmamkva, bp->b_bcount);
423 1.2.2.2 bouyer }
424 1.2.2.3 bouyer ed->sc_flags &= ~EDF_BOUNCEBUF;
425 1.2.2.2 bouyer
426 1.2.2.2 bouyer /* Unload buf from DMA map */
427 1.2.2.2 bouyer if (ed->sc_flags & EDF_DMAMAP_LOADED) {
428 1.2.2.2 bouyer bus_dmamap_unload(ed->sc_dmat, ed->dmamap_xfer);
429 1.2.2.2 bouyer ed->sc_flags &= ~EDF_DMAMAP_LOADED;
430 1.2.2.2 bouyer }
431 1.2.2.2 bouyer
432 1.2.2.2 bouyer /* If disk was busied, unbusy it now */
433 1.2.2.3 bouyer if (ed->sc_flags & EDF_DK_BUSY) {
434 1.2.2.2 bouyer disk_unbusy(&ed->sc_dk, (bp->b_bcount - bp->b_resid));
435 1.2.2.3 bouyer ed->sc_flags &= ~EDF_DK_BUSY;
436 1.2.2.3 bouyer mca_disk_unbusy();
437 1.2.2.2 bouyer }
438 1.2.2.2 bouyer
439 1.2.2.3 bouyer ed->sc_flags &= ~EDF_IODONE;
440 1.2.2.3 bouyer
441 1.2.2.2 bouyer #if NRND > 0
442 1.2.2.2 bouyer rnd_add_uint32(&ed->rnd_source, bp->b_blkno);
443 1.2.2.2 bouyer #endif
444 1.2.2.2 bouyer biodone(bp);
445 1.2.2.2 bouyer }
446 1.2.2.2 bouyer
447 1.2.2.2 bouyer int
448 1.2.2.2 bouyer edmcaread(dev, uio, flags)
449 1.2.2.2 bouyer dev_t dev;
450 1.2.2.2 bouyer struct uio *uio;
451 1.2.2.2 bouyer int flags;
452 1.2.2.2 bouyer {
453 1.2.2.2 bouyer WDCDEBUG_PRINT(("edread\n"), DEBUG_XFERS);
454 1.2.2.2 bouyer return (physio(edmcastrategy, NULL, dev, B_READ, minphys, uio));
455 1.2.2.2 bouyer }
456 1.2.2.2 bouyer
457 1.2.2.2 bouyer int
458 1.2.2.2 bouyer edmcawrite(dev, uio, flags)
459 1.2.2.2 bouyer dev_t dev;
460 1.2.2.2 bouyer struct uio *uio;
461 1.2.2.2 bouyer int flags;
462 1.2.2.2 bouyer {
463 1.2.2.2 bouyer WDCDEBUG_PRINT(("edwrite\n"), DEBUG_XFERS);
464 1.2.2.2 bouyer return (physio(edmcastrategy, NULL, dev, B_WRITE, minphys, uio));
465 1.2.2.2 bouyer }
466 1.2.2.2 bouyer
467 1.2.2.2 bouyer /*
468 1.2.2.2 bouyer * Wait interruptibly for an exclusive lock.
469 1.2.2.2 bouyer */
470 1.2.2.2 bouyer static int
471 1.2.2.3 bouyer ed_lock(ed)
472 1.2.2.3 bouyer struct ed_softc *ed;
473 1.2.2.2 bouyer {
474 1.2.2.2 bouyer int error;
475 1.2.2.2 bouyer int s;
476 1.2.2.2 bouyer
477 1.2.2.2 bouyer WDCDEBUG_PRINT(("ed_lock\n"), DEBUG_FUNCS);
478 1.2.2.2 bouyer
479 1.2.2.2 bouyer s = splbio();
480 1.2.2.3 bouyer error = lockmgr(&ed->sc_lock, LK_EXCLUSIVE, NULL);
481 1.2.2.2 bouyer splx(s);
482 1.2.2.3 bouyer
483 1.2.2.3 bouyer return (error);
484 1.2.2.2 bouyer }
485 1.2.2.2 bouyer
486 1.2.2.2 bouyer /*
487 1.2.2.2 bouyer * Unlock and wake up any waiters.
488 1.2.2.2 bouyer */
489 1.2.2.2 bouyer static void
490 1.2.2.3 bouyer ed_unlock(ed)
491 1.2.2.3 bouyer struct ed_softc *ed;
492 1.2.2.2 bouyer {
493 1.2.2.2 bouyer WDCDEBUG_PRINT(("ed_unlock\n"), DEBUG_FUNCS);
494 1.2.2.2 bouyer
495 1.2.2.3 bouyer (void) lockmgr(&ed->sc_lock, LK_RELEASE, NULL);
496 1.2.2.2 bouyer }
497 1.2.2.2 bouyer
498 1.2.2.2 bouyer int
499 1.2.2.2 bouyer edmcaopen(dev, flag, fmt, p)
500 1.2.2.2 bouyer dev_t dev;
501 1.2.2.2 bouyer int flag, fmt;
502 1.2.2.2 bouyer struct proc *p;
503 1.2.2.2 bouyer {
504 1.2.2.2 bouyer struct ed_softc *wd;
505 1.2.2.2 bouyer int part, error;
506 1.2.2.2 bouyer
507 1.2.2.2 bouyer WDCDEBUG_PRINT(("edopen\n"), DEBUG_FUNCS);
508 1.2.2.2 bouyer wd = device_lookup(&ed_cd, DISKUNIT(dev));
509 1.2.2.2 bouyer if (wd == NULL)
510 1.2.2.2 bouyer return (ENXIO);
511 1.2.2.2 bouyer
512 1.2.2.2 bouyer if ((error = ed_lock(wd)) != 0)
513 1.2.2.2 bouyer goto bad4;
514 1.2.2.2 bouyer
515 1.2.2.2 bouyer if (wd->sc_dk.dk_openmask != 0) {
516 1.2.2.2 bouyer /*
517 1.2.2.2 bouyer * If any partition is open, but the disk has been invalidated,
518 1.2.2.2 bouyer * disallow further opens.
519 1.2.2.2 bouyer */
520 1.2.2.2 bouyer if ((wd->sc_flags & WDF_LOADED) == 0) {
521 1.2.2.2 bouyer error = EIO;
522 1.2.2.2 bouyer goto bad3;
523 1.2.2.2 bouyer }
524 1.2.2.2 bouyer } else {
525 1.2.2.2 bouyer if ((wd->sc_flags & WDF_LOADED) == 0) {
526 1.2.2.2 bouyer wd->sc_flags |= WDF_LOADED;
527 1.2.2.2 bouyer
528 1.2.2.2 bouyer /* Load the physical device parameters. */
529 1.2.2.2 bouyer ed_get_params(wd);
530 1.2.2.2 bouyer
531 1.2.2.2 bouyer /* Load the partition info if not already loaded. */
532 1.2.2.2 bouyer edgetdisklabel(wd);
533 1.2.2.2 bouyer }
534 1.2.2.2 bouyer }
535 1.2.2.2 bouyer
536 1.2.2.2 bouyer part = DISKPART(dev);
537 1.2.2.2 bouyer
538 1.2.2.2 bouyer /* Check that the partition exists. */
539 1.2.2.2 bouyer if (part != RAW_PART &&
540 1.2.2.2 bouyer (part >= wd->sc_dk.dk_label->d_npartitions ||
541 1.2.2.2 bouyer wd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
542 1.2.2.2 bouyer error = ENXIO;
543 1.2.2.2 bouyer goto bad;
544 1.2.2.2 bouyer }
545 1.2.2.2 bouyer
546 1.2.2.2 bouyer /* Insure only one open at a time. */
547 1.2.2.2 bouyer switch (fmt) {
548 1.2.2.2 bouyer case S_IFCHR:
549 1.2.2.2 bouyer wd->sc_dk.dk_copenmask |= (1 << part);
550 1.2.2.2 bouyer break;
551 1.2.2.2 bouyer case S_IFBLK:
552 1.2.2.2 bouyer wd->sc_dk.dk_bopenmask |= (1 << part);
553 1.2.2.2 bouyer break;
554 1.2.2.2 bouyer }
555 1.2.2.2 bouyer wd->sc_dk.dk_openmask =
556 1.2.2.2 bouyer wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
557 1.2.2.2 bouyer
558 1.2.2.2 bouyer ed_unlock(wd);
559 1.2.2.2 bouyer return 0;
560 1.2.2.2 bouyer
561 1.2.2.2 bouyer bad:
562 1.2.2.2 bouyer if (wd->sc_dk.dk_openmask == 0) {
563 1.2.2.2 bouyer }
564 1.2.2.2 bouyer
565 1.2.2.2 bouyer bad3:
566 1.2.2.2 bouyer ed_unlock(wd);
567 1.2.2.2 bouyer bad4:
568 1.2.2.2 bouyer return (error);
569 1.2.2.2 bouyer }
570 1.2.2.2 bouyer
571 1.2.2.2 bouyer int
572 1.2.2.2 bouyer edmcaclose(dev, flag, fmt, p)
573 1.2.2.2 bouyer dev_t dev;
574 1.2.2.2 bouyer int flag, fmt;
575 1.2.2.2 bouyer struct proc *p;
576 1.2.2.2 bouyer {
577 1.2.2.2 bouyer struct ed_softc *wd = device_lookup(&ed_cd, DISKUNIT(dev));
578 1.2.2.2 bouyer int part = DISKPART(dev);
579 1.2.2.2 bouyer int error;
580 1.2.2.2 bouyer
581 1.2.2.2 bouyer WDCDEBUG_PRINT(("edmcaclose\n"), DEBUG_FUNCS);
582 1.2.2.2 bouyer if ((error = ed_lock(wd)) != 0)
583 1.2.2.2 bouyer return error;
584 1.2.2.2 bouyer
585 1.2.2.2 bouyer switch (fmt) {
586 1.2.2.2 bouyer case S_IFCHR:
587 1.2.2.2 bouyer wd->sc_dk.dk_copenmask &= ~(1 << part);
588 1.2.2.2 bouyer break;
589 1.2.2.2 bouyer case S_IFBLK:
590 1.2.2.2 bouyer wd->sc_dk.dk_bopenmask &= ~(1 << part);
591 1.2.2.2 bouyer break;
592 1.2.2.2 bouyer }
593 1.2.2.2 bouyer wd->sc_dk.dk_openmask =
594 1.2.2.2 bouyer wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
595 1.2.2.2 bouyer
596 1.2.2.2 bouyer if (wd->sc_dk.dk_openmask == 0) {
597 1.2.2.2 bouyer #if 0
598 1.2.2.2 bouyer wd_flushcache(wd, AT_WAIT);
599 1.2.2.2 bouyer #endif
600 1.2.2.2 bouyer /* XXXX Must wait for I/O to complete! */
601 1.2.2.2 bouyer
602 1.2.2.2 bouyer if (! (wd->sc_flags & WDF_KLABEL))
603 1.2.2.2 bouyer wd->sc_flags &= ~WDF_LOADED;
604 1.2.2.2 bouyer }
605 1.2.2.2 bouyer
606 1.2.2.2 bouyer ed_unlock(wd);
607 1.2.2.2 bouyer
608 1.2.2.2 bouyer return 0;
609 1.2.2.2 bouyer }
610 1.2.2.2 bouyer
611 1.2.2.2 bouyer static void
612 1.2.2.2 bouyer edgetdefaultlabel(wd, lp)
613 1.2.2.2 bouyer struct ed_softc *wd;
614 1.2.2.2 bouyer struct disklabel *lp;
615 1.2.2.2 bouyer {
616 1.2.2.2 bouyer WDCDEBUG_PRINT(("edgetdefaultlabel\n"), DEBUG_FUNCS);
617 1.2.2.2 bouyer memset(lp, 0, sizeof(struct disklabel));
618 1.2.2.2 bouyer
619 1.2.2.2 bouyer lp->d_secsize = DEV_BSIZE;
620 1.2.2.2 bouyer lp->d_ntracks = wd->heads;
621 1.2.2.2 bouyer lp->d_nsectors = wd->sectors;
622 1.2.2.2 bouyer lp->d_ncylinders = wd->cyl;
623 1.2.2.2 bouyer lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
624 1.2.2.2 bouyer
625 1.2.2.2 bouyer lp->d_type = DTYPE_ESDI;
626 1.2.2.2 bouyer
627 1.2.2.2 bouyer strncpy(lp->d_typename, "ESDI", 16);
628 1.2.2.2 bouyer strncpy(lp->d_packname, "fictitious", 16);
629 1.2.2.2 bouyer lp->d_secperunit = wd->sc_capacity;
630 1.2.2.2 bouyer lp->d_rpm = 3600;
631 1.2.2.2 bouyer lp->d_interleave = 1;
632 1.2.2.2 bouyer lp->d_flags = 0;
633 1.2.2.2 bouyer
634 1.2.2.2 bouyer lp->d_partitions[RAW_PART].p_offset = 0;
635 1.2.2.2 bouyer lp->d_partitions[RAW_PART].p_size =
636 1.2.2.2 bouyer lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
637 1.2.2.2 bouyer lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
638 1.2.2.2 bouyer lp->d_npartitions = RAW_PART + 1;
639 1.2.2.2 bouyer
640 1.2.2.2 bouyer lp->d_magic = DISKMAGIC;
641 1.2.2.2 bouyer lp->d_magic2 = DISKMAGIC;
642 1.2.2.2 bouyer lp->d_checksum = dkcksum(lp);
643 1.2.2.2 bouyer }
644 1.2.2.2 bouyer
645 1.2.2.2 bouyer /*
646 1.2.2.2 bouyer * Fabricate a default disk label, and try to read the correct one.
647 1.2.2.2 bouyer */
648 1.2.2.2 bouyer static void
649 1.2.2.2 bouyer edgetdisklabel(wd)
650 1.2.2.2 bouyer struct ed_softc *wd;
651 1.2.2.2 bouyer {
652 1.2.2.2 bouyer struct disklabel *lp = wd->sc_dk.dk_label;
653 1.2.2.2 bouyer char *errstring;
654 1.2.2.2 bouyer
655 1.2.2.2 bouyer WDCDEBUG_PRINT(("edgetdisklabel\n"), DEBUG_FUNCS);
656 1.2.2.2 bouyer
657 1.2.2.2 bouyer memset(wd->sc_dk.dk_cpulabel, 0, sizeof(struct cpu_disklabel));
658 1.2.2.2 bouyer
659 1.2.2.2 bouyer edgetdefaultlabel(wd, lp);
660 1.2.2.2 bouyer
661 1.2.2.2 bouyer #if 0
662 1.2.2.2 bouyer wd->sc_badsect[0] = -1;
663 1.2.2.2 bouyer
664 1.2.2.2 bouyer if (wd->drvp->state > RECAL)
665 1.2.2.2 bouyer wd->drvp->drive_flags |= DRIVE_RESET;
666 1.2.2.2 bouyer #endif
667 1.2.2.2 bouyer errstring = readdisklabel(MAKEDISKDEV(0, wd->sc_dev.dv_unit, RAW_PART),
668 1.2.2.2 bouyer edmcastrategy, lp, wd->sc_dk.dk_cpulabel);
669 1.2.2.2 bouyer if (errstring) {
670 1.2.2.2 bouyer /*
671 1.2.2.2 bouyer * This probably happened because the drive's default
672 1.2.2.2 bouyer * geometry doesn't match the DOS geometry. We
673 1.2.2.2 bouyer * assume the DOS geometry is now in the label and try
674 1.2.2.2 bouyer * again. XXX This is a kluge.
675 1.2.2.2 bouyer */
676 1.2.2.2 bouyer #if 0
677 1.2.2.2 bouyer if (wd->drvp->state > RECAL)
678 1.2.2.2 bouyer wd->drvp->drive_flags |= DRIVE_RESET;
679 1.2.2.2 bouyer #endif
680 1.2.2.2 bouyer errstring = readdisklabel(MAKEDISKDEV(0, wd->sc_dev.dv_unit,
681 1.2.2.2 bouyer RAW_PART), edmcastrategy, lp, wd->sc_dk.dk_cpulabel);
682 1.2.2.2 bouyer }
683 1.2.2.2 bouyer if (errstring) {
684 1.2.2.2 bouyer printf("%s: %s\n", wd->sc_dev.dv_xname, errstring);
685 1.2.2.2 bouyer return;
686 1.2.2.2 bouyer }
687 1.2.2.2 bouyer
688 1.2.2.2 bouyer #if 0
689 1.2.2.2 bouyer if (wd->drvp->state > RECAL)
690 1.2.2.2 bouyer wd->drvp->drive_flags |= DRIVE_RESET;
691 1.2.2.2 bouyer #endif
692 1.2.2.2 bouyer #ifdef HAS_BAD144_HANDLING
693 1.2.2.2 bouyer if ((lp->d_flags & D_BADSECT) != 0)
694 1.2.2.2 bouyer bad144intern(wd);
695 1.2.2.2 bouyer #endif
696 1.2.2.2 bouyer }
697 1.2.2.2 bouyer
698 1.2.2.2 bouyer int
699 1.2.2.2 bouyer edmcaioctl(dev, xfer, addr, flag, p)
700 1.2.2.2 bouyer dev_t dev;
701 1.2.2.2 bouyer u_long xfer;
702 1.2.2.2 bouyer caddr_t addr;
703 1.2.2.2 bouyer int flag;
704 1.2.2.2 bouyer struct proc *p;
705 1.2.2.2 bouyer {
706 1.2.2.2 bouyer struct ed_softc *wd = device_lookup(&ed_cd, DISKUNIT(dev));
707 1.2.2.2 bouyer int error;
708 1.2.2.2 bouyer #ifdef __HAVE_OLD_DISKLABEL
709 1.2.2.2 bouyer struct disklabel newlabel;
710 1.2.2.2 bouyer #endif
711 1.2.2.2 bouyer
712 1.2.2.3 bouyer WDCDEBUG_PRINT(("edioctl\n"), DEBUG_FUNCS);
713 1.2.2.2 bouyer
714 1.2.2.2 bouyer if ((wd->sc_flags & WDF_LOADED) == 0)
715 1.2.2.2 bouyer return EIO;
716 1.2.2.2 bouyer
717 1.2.2.2 bouyer switch (xfer) {
718 1.2.2.2 bouyer #ifdef HAS_BAD144_HANDLING
719 1.2.2.2 bouyer case DIOCSBAD:
720 1.2.2.2 bouyer if ((flag & FWRITE) == 0)
721 1.2.2.2 bouyer return EBADF;
722 1.2.2.2 bouyer wd->sc_dk.dk_cpulabel->bad = *(struct dkbad *)addr;
723 1.2.2.2 bouyer wd->sc_dk.dk_label->d_flags |= D_BADSECT;
724 1.2.2.2 bouyer bad144intern(wd);
725 1.2.2.2 bouyer return 0;
726 1.2.2.2 bouyer #endif
727 1.2.2.2 bouyer
728 1.2.2.2 bouyer case DIOCGDINFO:
729 1.2.2.2 bouyer *(struct disklabel *)addr = *(wd->sc_dk.dk_label);
730 1.2.2.2 bouyer return 0;
731 1.2.2.2 bouyer #ifdef __HAVE_OLD_DISKLABEL
732 1.2.2.2 bouyer case ODIOCGDINFO:
733 1.2.2.2 bouyer newlabel = *(wd->sc_dk.dk_label);
734 1.2.2.2 bouyer if (newlabel.d_npartitions > OLDMAXPARTITIONS)
735 1.2.2.2 bouyer return ENOTTY;
736 1.2.2.2 bouyer memcpy(addr, &newlabel, sizeof (struct olddisklabel));
737 1.2.2.2 bouyer return 0;
738 1.2.2.2 bouyer #endif
739 1.2.2.2 bouyer
740 1.2.2.2 bouyer case DIOCGPART:
741 1.2.2.2 bouyer ((struct partinfo *)addr)->disklab = wd->sc_dk.dk_label;
742 1.2.2.2 bouyer ((struct partinfo *)addr)->part =
743 1.2.2.2 bouyer &wd->sc_dk.dk_label->d_partitions[DISKPART(dev)];
744 1.2.2.2 bouyer return 0;
745 1.2.2.2 bouyer
746 1.2.2.2 bouyer case DIOCWDINFO:
747 1.2.2.2 bouyer case DIOCSDINFO:
748 1.2.2.2 bouyer #ifdef __HAVE_OLD_DISKLABEL
749 1.2.2.2 bouyer case ODIOCWDINFO:
750 1.2.2.2 bouyer case ODIOCSDINFO:
751 1.2.2.2 bouyer #endif
752 1.2.2.2 bouyer {
753 1.2.2.2 bouyer struct disklabel *lp;
754 1.2.2.2 bouyer
755 1.2.2.2 bouyer #ifdef __HAVE_OLD_DISKLABEL
756 1.2.2.2 bouyer if (xfer == ODIOCSDINFO || xfer == ODIOCWDINFO) {
757 1.2.2.2 bouyer memset(&newlabel, 0, sizeof newlabel);
758 1.2.2.2 bouyer memcpy(&newlabel, addr, sizeof (struct olddisklabel));
759 1.2.2.2 bouyer lp = &newlabel;
760 1.2.2.2 bouyer } else
761 1.2.2.2 bouyer #endif
762 1.2.2.2 bouyer lp = (struct disklabel *)addr;
763 1.2.2.2 bouyer
764 1.2.2.2 bouyer if ((flag & FWRITE) == 0)
765 1.2.2.2 bouyer return EBADF;
766 1.2.2.2 bouyer
767 1.2.2.2 bouyer if ((error = ed_lock(wd)) != 0)
768 1.2.2.2 bouyer return error;
769 1.2.2.2 bouyer wd->sc_flags |= WDF_LABELLING;
770 1.2.2.2 bouyer
771 1.2.2.2 bouyer error = setdisklabel(wd->sc_dk.dk_label,
772 1.2.2.2 bouyer lp, /*wd->sc_dk.dk_openmask : */0,
773 1.2.2.2 bouyer wd->sc_dk.dk_cpulabel);
774 1.2.2.2 bouyer if (error == 0) {
775 1.2.2.2 bouyer #if 0
776 1.2.2.2 bouyer if (wd->drvp->state > RECAL)
777 1.2.2.2 bouyer wd->drvp->drive_flags |= DRIVE_RESET;
778 1.2.2.2 bouyer #endif
779 1.2.2.2 bouyer if (xfer == DIOCWDINFO
780 1.2.2.2 bouyer #ifdef __HAVE_OLD_DISKLABEL
781 1.2.2.2 bouyer || xfer == ODIOCWDINFO
782 1.2.2.2 bouyer #endif
783 1.2.2.2 bouyer )
784 1.2.2.2 bouyer error = writedisklabel(EDLABELDEV(dev),
785 1.2.2.2 bouyer edmcastrategy, wd->sc_dk.dk_label,
786 1.2.2.2 bouyer wd->sc_dk.dk_cpulabel);
787 1.2.2.2 bouyer }
788 1.2.2.2 bouyer
789 1.2.2.2 bouyer wd->sc_flags &= ~WDF_LABELLING;
790 1.2.2.2 bouyer ed_unlock(wd);
791 1.2.2.2 bouyer return error;
792 1.2.2.2 bouyer }
793 1.2.2.2 bouyer
794 1.2.2.2 bouyer case DIOCKLABEL:
795 1.2.2.2 bouyer if (*(int *)addr)
796 1.2.2.2 bouyer wd->sc_flags |= WDF_KLABEL;
797 1.2.2.2 bouyer else
798 1.2.2.2 bouyer wd->sc_flags &= ~WDF_KLABEL;
799 1.2.2.2 bouyer return 0;
800 1.2.2.2 bouyer
801 1.2.2.2 bouyer case DIOCWLABEL:
802 1.2.2.2 bouyer if ((flag & FWRITE) == 0)
803 1.2.2.2 bouyer return EBADF;
804 1.2.2.2 bouyer if (*(int *)addr)
805 1.2.2.2 bouyer wd->sc_flags |= WDF_WLABEL;
806 1.2.2.2 bouyer else
807 1.2.2.2 bouyer wd->sc_flags &= ~WDF_WLABEL;
808 1.2.2.2 bouyer return 0;
809 1.2.2.2 bouyer
810 1.2.2.2 bouyer case DIOCGDEFLABEL:
811 1.2.2.2 bouyer edgetdefaultlabel(wd, (struct disklabel *)addr);
812 1.2.2.2 bouyer return 0;
813 1.2.2.2 bouyer #ifdef __HAVE_OLD_DISKLABEL
814 1.2.2.2 bouyer case ODIOCGDEFLABEL:
815 1.2.2.2 bouyer edgetdefaultlabel(wd, &newlabel);
816 1.2.2.2 bouyer if (newlabel.d_npartitions > OLDMAXPARTITIONS)
817 1.2.2.2 bouyer return ENOTTY;
818 1.2.2.2 bouyer memcpy(addr, &newlabel, sizeof (struct olddisklabel));
819 1.2.2.2 bouyer return 0;
820 1.2.2.2 bouyer #endif
821 1.2.2.2 bouyer
822 1.2.2.2 bouyer #ifdef notyet
823 1.2.2.2 bouyer case DIOCWFORMAT:
824 1.2.2.2 bouyer if ((flag & FWRITE) == 0)
825 1.2.2.2 bouyer return EBADF;
826 1.2.2.2 bouyer {
827 1.2.2.2 bouyer register struct format_op *fop;
828 1.2.2.2 bouyer struct iovec aiov;
829 1.2.2.2 bouyer struct uio auio;
830 1.2.2.2 bouyer
831 1.2.2.2 bouyer fop = (struct format_op *)addr;
832 1.2.2.2 bouyer aiov.iov_base = fop->df_buf;
833 1.2.2.2 bouyer aiov.iov_len = fop->df_count;
834 1.2.2.2 bouyer auio.uio_iov = &aiov;
835 1.2.2.2 bouyer auio.uio_iovcnt = 1;
836 1.2.2.2 bouyer auio.uio_resid = fop->df_count;
837 1.2.2.2 bouyer auio.uio_segflg = 0;
838 1.2.2.2 bouyer auio.uio_offset =
839 1.2.2.2 bouyer fop->df_startblk * wd->sc_dk.dk_label->d_secsize;
840 1.2.2.2 bouyer auio.uio_procp = p;
841 1.2.2.2 bouyer error = physio(wdformat, NULL, dev, B_WRITE, minphys,
842 1.2.2.2 bouyer &auio);
843 1.2.2.2 bouyer fop->df_count -= auio.uio_resid;
844 1.2.2.2 bouyer fop->df_reg[0] = wdc->sc_status;
845 1.2.2.2 bouyer fop->df_reg[1] = wdc->sc_error;
846 1.2.2.2 bouyer return error;
847 1.2.2.2 bouyer }
848 1.2.2.2 bouyer #endif
849 1.2.2.2 bouyer
850 1.2.2.2 bouyer default:
851 1.2.2.2 bouyer return ENOTTY;
852 1.2.2.2 bouyer }
853 1.2.2.2 bouyer
854 1.2.2.2 bouyer #ifdef DIAGNOSTIC
855 1.2.2.3 bouyer panic("edioctl: impossible");
856 1.2.2.2 bouyer #endif
857 1.2.2.2 bouyer }
858 1.2.2.2 bouyer
859 1.2.2.2 bouyer #if 0
860 1.2.2.2 bouyer #ifdef B_FORMAT
861 1.2.2.2 bouyer int
862 1.2.2.2 bouyer edmcaformat(struct buf *bp)
863 1.2.2.2 bouyer {
864 1.2.2.2 bouyer
865 1.2.2.2 bouyer bp->b_flags |= B_FORMAT;
866 1.2.2.2 bouyer return edmcastrategy(bp);
867 1.2.2.2 bouyer }
868 1.2.2.2 bouyer #endif
869 1.2.2.2 bouyer #endif
870 1.2.2.2 bouyer
871 1.2.2.2 bouyer int
872 1.2.2.2 bouyer edmcasize(dev)
873 1.2.2.2 bouyer dev_t dev;
874 1.2.2.2 bouyer {
875 1.2.2.2 bouyer struct ed_softc *wd;
876 1.2.2.2 bouyer int part, omask;
877 1.2.2.2 bouyer int size;
878 1.2.2.2 bouyer
879 1.2.2.2 bouyer WDCDEBUG_PRINT(("edsize\n"), DEBUG_FUNCS);
880 1.2.2.2 bouyer
881 1.2.2.2 bouyer wd = device_lookup(&ed_cd, DISKUNIT(dev));
882 1.2.2.2 bouyer if (wd == NULL)
883 1.2.2.2 bouyer return (-1);
884 1.2.2.2 bouyer
885 1.2.2.2 bouyer part = DISKPART(dev);
886 1.2.2.2 bouyer omask = wd->sc_dk.dk_openmask & (1 << part);
887 1.2.2.2 bouyer
888 1.2.2.2 bouyer if (omask == 0 && edmcaopen(dev, 0, S_IFBLK, NULL) != 0)
889 1.2.2.2 bouyer return (-1);
890 1.2.2.2 bouyer if (wd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
891 1.2.2.2 bouyer size = -1;
892 1.2.2.2 bouyer else
893 1.2.2.2 bouyer size = wd->sc_dk.dk_label->d_partitions[part].p_size *
894 1.2.2.2 bouyer (wd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
895 1.2.2.2 bouyer if (omask == 0 && edmcaclose(dev, 0, S_IFBLK, NULL) != 0)
896 1.2.2.2 bouyer return (-1);
897 1.2.2.2 bouyer return (size);
898 1.2.2.2 bouyer }
899 1.2.2.2 bouyer
900 1.2.2.2 bouyer /* #define WD_DUMP_NOT_TRUSTED if you just want to watch */
901 1.2.2.2 bouyer static int wddoingadump = 0;
902 1.2.2.2 bouyer static int wddumprecalibrated = 0;
903 1.2.2.2 bouyer
904 1.2.2.2 bouyer /*
905 1.2.2.2 bouyer * Dump core after a system crash.
906 1.2.2.2 bouyer */
907 1.2.2.2 bouyer int
908 1.2.2.2 bouyer edmcadump(dev, blkno, va, size)
909 1.2.2.2 bouyer dev_t dev;
910 1.2.2.2 bouyer daddr_t blkno;
911 1.2.2.2 bouyer caddr_t va;
912 1.2.2.2 bouyer size_t size;
913 1.2.2.2 bouyer {
914 1.2.2.2 bouyer struct ed_softc *wd; /* disk unit to do the I/O */
915 1.2.2.2 bouyer struct disklabel *lp; /* disk's disklabel */
916 1.2.2.2 bouyer int part; // , err;
917 1.2.2.2 bouyer int nblks; /* total number of sectors left to write */
918 1.2.2.2 bouyer
919 1.2.2.2 bouyer /* Check if recursive dump; if so, punt. */
920 1.2.2.2 bouyer if (wddoingadump)
921 1.2.2.2 bouyer return EFAULT;
922 1.2.2.2 bouyer wddoingadump = 1;
923 1.2.2.2 bouyer
924 1.2.2.2 bouyer wd = device_lookup(&ed_cd, DISKUNIT(dev));
925 1.2.2.2 bouyer if (wd == NULL)
926 1.2.2.2 bouyer return (ENXIO);
927 1.2.2.2 bouyer
928 1.2.2.2 bouyer part = DISKPART(dev);
929 1.2.2.2 bouyer
930 1.2.2.2 bouyer #if 0
931 1.2.2.2 bouyer /* Make sure it was initialized. */
932 1.2.2.2 bouyer if (wd->drvp->state < READY)
933 1.2.2.2 bouyer return ENXIO;
934 1.2.2.2 bouyer #endif
935 1.2.2.2 bouyer
936 1.2.2.2 bouyer /* Convert to disk sectors. Request must be a multiple of size. */
937 1.2.2.2 bouyer lp = wd->sc_dk.dk_label;
938 1.2.2.2 bouyer if ((size % lp->d_secsize) != 0)
939 1.2.2.2 bouyer return EFAULT;
940 1.2.2.2 bouyer nblks = size / lp->d_secsize;
941 1.2.2.2 bouyer blkno = blkno / (lp->d_secsize / DEV_BSIZE);
942 1.2.2.2 bouyer
943 1.2.2.2 bouyer /* Check transfer bounds against partition size. */
944 1.2.2.2 bouyer if ((blkno < 0) || ((blkno + nblks) > lp->d_partitions[part].p_size))
945 1.2.2.2 bouyer return EINVAL;
946 1.2.2.2 bouyer
947 1.2.2.2 bouyer /* Offset block number to start of partition. */
948 1.2.2.2 bouyer blkno += lp->d_partitions[part].p_offset;
949 1.2.2.2 bouyer
950 1.2.2.2 bouyer /* Recalibrate, if first dump transfer. */
951 1.2.2.2 bouyer if (wddumprecalibrated == 0) {
952 1.2.2.2 bouyer wddumprecalibrated = 1;
953 1.2.2.2 bouyer #if 0
954 1.2.2.2 bouyer wd->drvp->state = RESET;
955 1.2.2.2 bouyer #endif
956 1.2.2.2 bouyer }
957 1.2.2.2 bouyer
958 1.2.2.2 bouyer while (nblks > 0) {
959 1.2.2.2 bouyer #if 0
960 1.2.2.2 bouyer wd->sc_wdc_bio.blkno = blkno;
961 1.2.2.2 bouyer wd->sc_wdc_bio.flags = ATA_POLL;
962 1.2.2.2 bouyer wd->sc_wdc_bio.bcount = lp->d_secsize;
963 1.2.2.2 bouyer wd->sc_wdc_bio.databuf = va;
964 1.2.2.2 bouyer #ifndef WD_DUMP_NOT_TRUSTED
965 1.2.2.2 bouyer switch (wdc_ata_bio(wd->drvp, &wd->sc_wdc_bio)) {
966 1.2.2.2 bouyer case WDC_TRY_AGAIN:
967 1.2.2.2 bouyer panic("wddump: try again");
968 1.2.2.2 bouyer break;
969 1.2.2.2 bouyer case WDC_QUEUED:
970 1.2.2.2 bouyer panic("wddump: polled command has been queued");
971 1.2.2.2 bouyer break;
972 1.2.2.2 bouyer case WDC_COMPLETE:
973 1.2.2.2 bouyer break;
974 1.2.2.2 bouyer }
975 1.2.2.2 bouyer if (err != 0) {
976 1.2.2.2 bouyer printf("\n");
977 1.2.2.2 bouyer return err;
978 1.2.2.2 bouyer }
979 1.2.2.2 bouyer #else /* WD_DUMP_NOT_TRUSTED */
980 1.2.2.2 bouyer /* Let's just talk about this first... */
981 1.2.2.2 bouyer printf("ed%d: dump addr 0x%x, cylin %d, head %d, sector %d\n",
982 1.2.2.2 bouyer unit, va, cylin, head, sector);
983 1.2.2.2 bouyer delay(500 * 1000); /* half a second */
984 1.2.2.2 bouyer #endif
985 1.2.2.2 bouyer #endif /* 0 */
986 1.2.2.2 bouyer
987 1.2.2.2 bouyer /* update block count */
988 1.2.2.2 bouyer nblks -= 1;
989 1.2.2.2 bouyer blkno += 1;
990 1.2.2.2 bouyer va += lp->d_secsize;
991 1.2.2.2 bouyer }
992 1.2.2.2 bouyer
993 1.2.2.2 bouyer wddoingadump = 0;
994 1.2.2.2 bouyer return (ESPIPE);
995 1.2.2.2 bouyer }
996 1.2.2.2 bouyer
997 1.2.2.2 bouyer #ifdef HAS_BAD144_HANDLING
998 1.2.2.2 bouyer /*
999 1.2.2.2 bouyer * Internalize the bad sector table.
1000 1.2.2.2 bouyer */
1001 1.2.2.2 bouyer static void
1002 1.2.2.2 bouyer bad144intern(wd)
1003 1.2.2.2 bouyer struct ed_softc *wd;
1004 1.2.2.2 bouyer {
1005 1.2.2.2 bouyer struct dkbad *bt = &wd->sc_dk.dk_cpulabel->bad;
1006 1.2.2.2 bouyer struct disklabel *lp = wd->sc_dk.dk_label;
1007 1.2.2.2 bouyer int i = 0;
1008 1.2.2.2 bouyer
1009 1.2.2.2 bouyer WDCDEBUG_PRINT(("bad144intern\n"), DEBUG_XFERS);
1010 1.2.2.2 bouyer
1011 1.2.2.2 bouyer for (; i < NBT_BAD; i++) {
1012 1.2.2.2 bouyer if (bt->bt_bad[i].bt_cyl == 0xffff)
1013 1.2.2.2 bouyer break;
1014 1.2.2.2 bouyer wd->sc_badsect[i] =
1015 1.2.2.2 bouyer bt->bt_bad[i].bt_cyl * lp->d_secpercyl +
1016 1.2.2.2 bouyer (bt->bt_bad[i].bt_trksec >> 8) * lp->d_nsectors +
1017 1.2.2.2 bouyer (bt->bt_bad[i].bt_trksec & 0xff);
1018 1.2.2.2 bouyer }
1019 1.2.2.2 bouyer for (; i < NBT_BAD+1; i++)
1020 1.2.2.2 bouyer wd->sc_badsect[i] = -1;
1021 1.2.2.2 bouyer }
1022 1.2.2.2 bouyer #endif
1023 1.2.2.2 bouyer
1024 1.2.2.2 bouyer static int
1025 1.2.2.2 bouyer ed_get_params(ed)
1026 1.2.2.2 bouyer struct ed_softc *ed;
1027 1.2.2.2 bouyer {
1028 1.2.2.2 bouyer u_int16_t cmd_args[2];
1029 1.2.2.2 bouyer
1030 1.2.2.2 bouyer /*
1031 1.2.2.2 bouyer * Get Device Configuration (09).
1032 1.2.2.2 bouyer */
1033 1.2.2.3 bouyer cmd_args[0] = 14; /* Options: 00s110, s: 0=Physical 1=Pseudo */
1034 1.2.2.2 bouyer cmd_args[1] = 0;
1035 1.2.2.3 bouyer if (edc_run_cmd(ed->edc_softc, CMD_GET_DEV_CONF, ed->sc_devno, cmd_args, 2, 0))
1036 1.2.2.2 bouyer return (1);
1037 1.2.2.2 bouyer
1038 1.2.2.2 bouyer ed->spares = ed->sc_status_block[1] >> 8;
1039 1.2.2.2 bouyer ed->drv_flags = ed->sc_status_block[1] & 0x1f;
1040 1.2.2.2 bouyer ed->rba = ed->sc_status_block[2] |
1041 1.2.2.2 bouyer (ed->sc_status_block[3] << 16);
1042 1.2.2.2 bouyer /* Instead of using:
1043 1.2.2.2 bouyer ed->cyl = ed->sc_status_block[4];
1044 1.2.2.2 bouyer ed->heads = ed->sc_status_block[5] & 0xff;
1045 1.2.2.2 bouyer ed->sectors = ed->sc_status_block[5] >> 8;
1046 1.2.2.2 bouyer * we fabricate the numbers from RBA count, so that
1047 1.2.2.2 bouyer * number of sectors is 32 and heads 64. This seems
1048 1.2.2.2 bouyer * to be necessary for integrated ESDI controller.
1049 1.2.2.2 bouyer */
1050 1.2.2.2 bouyer ed->sectors = 32;
1051 1.2.2.2 bouyer ed->heads = 64;
1052 1.2.2.2 bouyer ed->cyl = ed->rba / (ed->heads * ed->sectors);
1053 1.2.2.2 bouyer ed->sc_capacity = ed->rba;
1054 1.2.2.2 bouyer
1055 1.2.2.2 bouyer return (0);
1056 1.2.2.2 bouyer }
1057 1.2.2.2 bouyer
1058 1.2.2.2 bouyer /*
1059 1.2.2.2 bouyer * Our shutdown hook. We attempt to park disk's head only.
1060 1.2.2.2 bouyer */
1061 1.2.2.2 bouyer void
1062 1.2.2.2 bouyer ed_shutdown(arg)
1063 1.2.2.2 bouyer void *arg;
1064 1.2.2.2 bouyer {
1065 1.2.2.2 bouyer #if 0
1066 1.2.2.2 bouyer struct ed_softc *ed = arg;
1067 1.2.2.2 bouyer u_int16_t cmd_args[2];
1068 1.2.2.2 bouyer
1069 1.2.2.2 bouyer /* Issue Park Head command */
1070 1.2.2.2 bouyer cmd_args[0] = 6; /* Options: 000110 */
1071 1.2.2.2 bouyer cmd_args[1] = 0;
1072 1.2.2.3 bouyer (void) edc_run_cmd(ed->edc_softc, CMD_PARK_HEAD, ed->sc_devno,
1073 1.2.2.2 bouyer cmd_args, 2, 0);
1074 1.2.2.2 bouyer #endif
1075 1.2.2.2 bouyer }
1076 1.2.2.2 bouyer
1077 1.2.2.2 bouyer /*
1078 1.2.2.2 bouyer * Main worker thread function.
1079 1.2.2.2 bouyer */
1080 1.2.2.2 bouyer void
1081 1.2.2.2 bouyer edworker(arg)
1082 1.2.2.2 bouyer void *arg;
1083 1.2.2.2 bouyer {
1084 1.2.2.2 bouyer struct ed_softc *ed = (struct ed_softc *) arg;
1085 1.2.2.2 bouyer struct buf *bp;
1086 1.2.2.2 bouyer int s;
1087 1.2.2.2 bouyer
1088 1.2.2.2 bouyer config_pending_decr();
1089 1.2.2.2 bouyer
1090 1.2.2.2 bouyer for(;;) {
1091 1.2.2.2 bouyer /* Wait until awakened */
1092 1.2.2.2 bouyer (void) tsleep(&ed->sc_q, PRIBIO, "edidle", 0);
1093 1.2.2.2 bouyer
1094 1.2.2.2 bouyer if ((ed->sc_flags & EDF_PROCESS_QUEUE) == 0)
1095 1.2.2.2 bouyer panic("edworker: expecting process queue");
1096 1.2.2.2 bouyer ed->sc_flags &= ~EDF_PROCESS_QUEUE;
1097 1.2.2.2 bouyer
1098 1.2.2.2 bouyer for(;;) {
1099 1.2.2.2 bouyer /* Is there a buf for us ? */
1100 1.2.2.2 bouyer simple_lock(&ed->sc_q_lock);
1101 1.2.2.2 bouyer if ((bp = BUFQ_FIRST(&ed->sc_q)) == NULL) {
1102 1.2.2.2 bouyer simple_unlock(&ed->sc_q_lock);
1103 1.2.2.2 bouyer break;
1104 1.2.2.2 bouyer }
1105 1.2.2.2 bouyer BUFQ_REMOVE(&ed->sc_q, bp);
1106 1.2.2.2 bouyer simple_unlock(&ed->sc_q_lock);
1107 1.2.2.2 bouyer
1108 1.2.2.2 bouyer /* Schedule i/o operation */
1109 1.2.2.3 bouyer ed->sc_error = 0;
1110 1.2.2.2 bouyer s = splbio();
1111 1.2.2.2 bouyer __edstart(ed, bp);
1112 1.2.2.2 bouyer splx(s);
1113 1.2.2.2 bouyer
1114 1.2.2.2 bouyer /*
1115 1.2.2.3 bouyer * Wait until the command executes; edc_intr() wakes
1116 1.2.2.3 bouyer * us up.
1117 1.2.2.2 bouyer */
1118 1.2.2.3 bouyer if (ed->sc_error == 0
1119 1.2.2.3 bouyer && (ed->sc_flags & EDF_IODONE) == 0) {
1120 1.2.2.3 bouyer (void)tsleep(&ed->edc_softc, PRIBIO, "edwrk",0);
1121 1.2.2.3 bouyer edc_cmd_wait(ed->edc_softc, ed->sc_devno, 5);
1122 1.2.2.3 bouyer }
1123 1.2.2.2 bouyer
1124 1.2.2.2 bouyer /* Handle i/o results */
1125 1.2.2.2 bouyer s = splbio();
1126 1.2.2.2 bouyer edmcadone(ed);
1127 1.2.2.2 bouyer splx(s);
1128 1.2.2.2 bouyer }
1129 1.2.2.2 bouyer }
1130 1.2.2.2 bouyer }
1131