Commit | Line | Data |
---|---|---|
fb6eeb38 C |
1 | /* ht.c 6.2 83/09/26 */ |
2 | ||
3 | #include "tu.h" | |
4 | #if NHT > 0 | |
5 | /* | |
6 | * TM03/TU?? tape driver | |
7 | * | |
8 | * TODO: | |
9 | * cleanup messages on errors | |
10 | * test ioctl's | |
11 | * see how many rewind interrups we get if we kick when not at BOT | |
12 | * fixup rle error on block tape code | |
13 | */ | |
14 | #include "../machine/pte.h" | |
15 | ||
16 | #include "../h/param.h" | |
17 | #include "../h/systm.h" | |
18 | #include "../h/buf.h" | |
19 | #include "../h/conf.h" | |
20 | #include "../h/dir.h" | |
21 | #include "../h/file.h" | |
22 | #include "../h/user.h" | |
23 | #include "../h/map.h" | |
24 | #include "../h/ioctl.h" | |
25 | #include "../h/mtio.h" | |
26 | #include "../h/cmap.h" | |
27 | #include "../h/uio.h" | |
28 | ||
29 | #include "../vax/cpu.h" | |
30 | #include "../vaxmba/mbareg.h" | |
31 | #include "../vaxmba/mbavar.h" | |
32 | #include "../vaxmba/htreg.h" | |
33 | ||
34 | struct buf rhtbuf[NHT]; | |
35 | struct buf chtbuf[NHT]; | |
36 | ||
37 | short httypes[] = | |
38 | { MBDT_TM03, MBDT_TE16, MBDT_TU45, MBDT_TU77, 0 }; | |
39 | struct mba_device *htinfo[NHT]; | |
40 | int htattach(), htslave(), htustart(), htndtint(), htdtint(); | |
41 | struct mba_driver htdriver = | |
42 | { htattach, htslave, htustart, 0, htdtint, htndtint, | |
43 | httypes, "ht", "tu", htinfo }; | |
44 | ||
45 | #define MASKREG(r) ((r) & 0xffff) | |
46 | ||
47 | /* bits in minor device */ | |
48 | #define TUUNIT(dev) (minor(dev)&03) | |
49 | #define H_NOREWIND 04 | |
50 | #define H_1600BPI 08 | |
51 | ||
52 | #define HTUNIT(dev) (tutoht[TUUNIT(dev)]) | |
53 | ||
54 | #define INF (daddr_t)1000000L /* a block number that wont exist */ | |
55 | ||
56 | struct tu_softc { | |
57 | char sc_openf; | |
58 | char sc_flags; | |
59 | daddr_t sc_blkno; | |
60 | daddr_t sc_nxrec; | |
61 | u_short sc_erreg; | |
62 | u_short sc_dsreg; | |
63 | short sc_resid; | |
64 | short sc_dens; | |
65 | struct mba_device *sc_mi; | |
66 | int sc_slave; | |
67 | } tu_softc[NTU]; | |
68 | short tutoht[NTU]; | |
69 | ||
70 | /* | |
71 | * Bits for sc_flags. | |
72 | */ | |
73 | #define H_WRITTEN 1 /* last operation was a write */ | |
74 | #define H_ERASED 2 /* last write retry was an erase gap */ | |
75 | #define H_REWIND 4 /* last unit start was a rewind */ | |
76 | ||
77 | char hter_bits[] = HTER_BITS; | |
78 | char htds_bits[] = HTDS_BITS; | |
79 | ||
80 | /*ARGSUSED*/ | |
81 | htattach(mi) | |
82 | struct mba_device *mi; | |
83 | { | |
84 | ||
85 | } | |
86 | ||
87 | htslave(mi, ms, sn) | |
88 | struct mba_device *mi; | |
89 | struct mba_slave *ms; | |
90 | int sn; | |
91 | { | |
92 | register struct tu_softc *sc = &tu_softc[ms->ms_unit]; | |
93 | register struct htdevice *htaddr = (struct htdevice *)mi->mi_drv; | |
94 | ||
95 | htaddr->httc = sn; | |
96 | if (htaddr->htdt & HTDT_SPR) { | |
97 | sc->sc_mi = mi; | |
98 | sc->sc_slave = sn; | |
99 | tutoht[ms->ms_unit] = mi->mi_unit; | |
100 | return (1); | |
101 | } else | |
102 | return (0); | |
103 | } | |
104 | ||
105 | htopen(dev, flag) | |
106 | dev_t dev; | |
107 | int flag; | |
108 | { | |
109 | register int tuunit; | |
110 | register struct mba_device *mi; | |
111 | register struct tu_softc *sc; | |
112 | int olddens, dens; | |
113 | ||
114 | tuunit = TUUNIT(dev); | |
115 | if (tuunit >= NTU || (sc = &tu_softc[tuunit])->sc_openf || | |
116 | (mi = htinfo[HTUNIT(dev)]) == 0 || mi->mi_alive == 0) | |
117 | return (ENXIO); | |
118 | olddens = sc->sc_dens; | |
119 | dens = sc->sc_dens = | |
120 | ((minor(dev)&H_1600BPI)?HTTC_1600BPI:HTTC_800BPI)| | |
121 | HTTC_PDP11|sc->sc_slave; | |
122 | htcommand(dev, HT_SENSE, 1); | |
123 | sc->sc_dens = olddens; | |
124 | if ((sc->sc_dsreg & HTDS_MOL) == 0) { | |
125 | uprintf("tu%d: not online\n", tuunit); | |
126 | return (EIO); | |
127 | } | |
128 | if ((flag&FWRITE) && (sc->sc_dsreg&HTDS_WRL)) { | |
129 | uprintf("tu%d: no write ring\n", tuunit); | |
130 | return (EIO); | |
131 | } | |
132 | if ((sc->sc_dsreg & HTDS_BOT) == 0 && (flag&FWRITE) && | |
133 | dens != sc->sc_dens) { | |
134 | uprintf("tu%d: can't change density in mid-tape\n", tuunit); | |
135 | return (EIO); | |
136 | } | |
137 | sc->sc_openf = 1; | |
138 | sc->sc_blkno = (daddr_t)0; | |
139 | sc->sc_nxrec = INF; | |
140 | sc->sc_flags = 0; | |
141 | sc->sc_dens = dens; | |
142 | return (0); | |
143 | } | |
144 | ||
145 | htclose(dev, flag) | |
146 | register dev_t dev; | |
147 | register flag; | |
148 | { | |
149 | register struct tu_softc *sc = &tu_softc[TUUNIT(dev)]; | |
150 | ||
151 | if (flag == FWRITE || ((flag&FWRITE) && (sc->sc_flags&H_WRITTEN))) { | |
152 | htcommand(dev, HT_WEOF, 1); | |
153 | htcommand(dev, HT_WEOF, 1); | |
154 | htcommand(dev, HT_SREV, 1); | |
155 | } | |
156 | if ((minor(dev)&H_NOREWIND) == 0) | |
157 | htcommand(dev, HT_REW, 0); | |
158 | sc->sc_openf = 0; | |
159 | } | |
160 | ||
161 | htcommand(dev, com, count) | |
162 | dev_t dev; | |
163 | int com, count; | |
164 | { | |
165 | register struct buf *bp; | |
166 | register int s; | |
167 | ||
168 | bp = &chtbuf[HTUNIT(dev)]; | |
169 | s = spl5(); | |
170 | while (bp->b_flags&B_BUSY) { | |
171 | if(bp->b_repcnt == 0 && (bp->b_flags&B_DONE)) | |
172 | break; | |
173 | bp->b_flags |= B_WANTED; | |
174 | sleep((caddr_t)bp, PRIBIO); | |
175 | } | |
176 | bp->b_flags = B_BUSY|B_READ; | |
177 | splx(s); | |
178 | bp->b_dev = dev; | |
179 | bp->b_command = com; | |
180 | bp->b_repcnt = count; | |
181 | bp->b_blkno = 0; | |
182 | htstrategy(bp); | |
183 | if (count == 0) | |
184 | return; | |
185 | iowait(bp); | |
186 | if (bp->b_flags&B_WANTED) | |
187 | wakeup((caddr_t)bp); | |
188 | bp->b_flags &= B_ERROR; | |
189 | } | |
190 | ||
191 | htstrategy(bp) | |
192 | register struct buf *bp; | |
193 | { | |
194 | register struct mba_device *mi = htinfo[HTUNIT(bp->b_dev)]; | |
195 | register struct buf *dp; | |
196 | register int s; | |
197 | ||
198 | bp->av_forw = NULL; | |
199 | dp = &mi->mi_tab; | |
200 | s = spl5(); | |
201 | if (dp->b_actf == NULL) | |
202 | dp->b_actf = bp; | |
203 | else | |
204 | dp->b_actl->av_forw = bp; | |
205 | dp->b_actl = bp; | |
206 | if (dp->b_active == 0) | |
207 | mbustart(mi); | |
208 | splx(s); | |
209 | } | |
210 | ||
211 | htustart(mi) | |
212 | register struct mba_device *mi; | |
213 | { | |
214 | register struct htdevice *htaddr = | |
215 | (struct htdevice *)mi->mi_drv; | |
216 | register struct buf *bp = mi->mi_tab.b_actf; | |
217 | register struct tu_softc *sc = &tu_softc[TUUNIT(bp->b_dev)]; | |
218 | daddr_t blkno; | |
219 | ||
220 | htaddr->httc = sc->sc_dens; | |
221 | #ifdef notdef | |
222 | /* unneeded, may hang controller */ | |
223 | if (bp == &chtbuf[HTUNIT(bp->b_dev)] && bp->b_command == HT_SENSE) { | |
224 | htaddr->htcs1 = HT_SENSE|HT_GO; | |
225 | mbclrattn(mi); | |
226 | } | |
227 | #endif | |
228 | sc->sc_dsreg = htaddr->htds; | |
229 | sc->sc_erreg = htaddr->hter; | |
230 | sc->sc_resid = htaddr->htfc; | |
231 | sc->sc_flags &= ~(H_WRITTEN|H_REWIND); | |
232 | if ((htaddr->htdt & HTDT_SPR) == 0 || (htaddr->htds & HTDS_MOL) == 0) | |
233 | if (sc->sc_openf > 0) | |
234 | sc->sc_openf = -1; | |
235 | if (sc->sc_openf < 0) { | |
236 | bp->b_flags |= B_ERROR; | |
237 | return (MBU_NEXT); | |
238 | } | |
239 | if (bp != &chtbuf[HTUNIT(bp->b_dev)]) { | |
240 | if (bdbtofsb(bp->b_blkno) > sc->sc_nxrec) { | |
241 | bp->b_flags |= B_ERROR; | |
242 | bp->b_error = ENXIO; | |
243 | return (MBU_NEXT); | |
244 | } | |
245 | if (bdbtofsb(bp->b_blkno) == sc->sc_nxrec && | |
246 | bp->b_flags&B_READ) { | |
247 | bp->b_resid = bp->b_bcount; | |
248 | clrbuf(bp); | |
249 | return (MBU_NEXT); | |
250 | } | |
251 | if ((bp->b_flags&B_READ)==0) | |
252 | sc->sc_nxrec = bdbtofsb(bp->b_blkno) + 1; | |
253 | } else { | |
254 | if (bp->b_command == HT_SENSE) | |
255 | return (MBU_NEXT); | |
256 | if (bp->b_command == HT_REW) | |
257 | sc->sc_flags |= H_REWIND; | |
258 | else | |
259 | htaddr->htfc = -bp->b_bcount; | |
260 | htaddr->htcs1 = bp->b_command|HT_GO; | |
261 | return (MBU_STARTED); | |
262 | } | |
263 | if ((blkno = sc->sc_blkno) == bdbtofsb(bp->b_blkno)) { | |
264 | htaddr->htfc = -bp->b_bcount; | |
265 | if ((bp->b_flags&B_READ) == 0) { | |
266 | if (mi->mi_tab.b_errcnt) { | |
267 | if ((sc->sc_flags & H_ERASED) == 0) { | |
268 | sc->sc_flags |= H_ERASED; | |
269 | htaddr->htcs1 = HT_ERASE | HT_GO; | |
270 | return (MBU_STARTED); | |
271 | } | |
272 | sc->sc_flags &= ~H_ERASED; | |
273 | } | |
274 | if (htaddr->htds & HTDS_EOT) { | |
275 | bp->b_resid = bp->b_bcount; | |
276 | bp->b_flags |= B_ERROR; | |
277 | return (MBU_NEXT); | |
278 | } | |
279 | } | |
280 | return (MBU_DODATA); | |
281 | } | |
282 | if (blkno < bdbtofsb(bp->b_blkno)) { | |
283 | htaddr->htfc = blkno - bdbtofsb(bp->b_blkno); | |
284 | htaddr->htcs1 = HT_SFORW|HT_GO; | |
285 | } else { | |
286 | htaddr->htfc = bdbtofsb(bp->b_blkno) - blkno; | |
287 | htaddr->htcs1 = HT_SREV|HT_GO; | |
288 | } | |
289 | return (MBU_STARTED); | |
290 | } | |
291 | ||
292 | htdtint(mi, mbsr) | |
293 | register struct mba_device *mi; | |
294 | int mbsr; | |
295 | { | |
296 | register struct htdevice *htaddr = (struct htdevice *)mi->mi_drv; | |
297 | register struct buf *bp = mi->mi_tab.b_actf; | |
298 | register struct tu_softc *sc; | |
299 | int ds, er, mbs; | |
300 | ||
301 | sc = &tu_softc[TUUNIT(bp->b_dev)]; | |
302 | ds = sc->sc_dsreg = MASKREG(htaddr->htds); | |
303 | er = sc->sc_erreg = MASKREG(htaddr->hter); | |
304 | sc->sc_resid = MASKREG(htaddr->htfc); | |
305 | mbs = mbsr; | |
306 | sc->sc_blkno++; | |
307 | if((bp->b_flags & B_READ) == 0) | |
308 | sc->sc_flags |= H_WRITTEN; | |
309 | if ((ds&(HTDS_ERR|HTDS_MOL)) != HTDS_MOL || mbs & MBSR_EBITS) { | |
310 | htaddr->htcs1 = HT_DCLR|HT_GO; | |
311 | mbclrattn(mi); | |
312 | if (bp == &rhtbuf[HTUNIT(bp->b_dev)]) { | |
313 | er &= ~HTER_FCE; | |
314 | mbs &= ~(MBSR_DTABT|MBSR_MBEXC); | |
315 | } | |
316 | if (bp->b_flags & B_READ && ds & HTDS_PES) | |
317 | er &= ~(HTER_CSITM|HTER_CORCRC); | |
318 | if (er&HTER_HARD || mbs&MBSR_EBITS || (ds&HTDS_MOL) == 0 || | |
319 | er && ++mi->mi_tab.b_errcnt >= 7) { | |
320 | if ((ds & HTDS_MOL) == 0 && sc->sc_openf > 0) | |
321 | sc->sc_openf = -1; | |
322 | if ((er&HTER_HARD) == HTER_FCE && | |
323 | (mbs&MBSR_EBITS) == (MBSR_DTABT|MBSR_MBEXC) && | |
324 | (ds&HTDS_MOL)) | |
325 | goto noprint; | |
326 | printf("tu%d: hard error bn%d mbsr=%b er=%b ds=%b\n", | |
327 | TUUNIT(bp->b_dev), bp->b_blkno, | |
328 | mbsr, mbsr_bits, | |
329 | sc->sc_erreg, hter_bits, | |
330 | sc->sc_dsreg, htds_bits); | |
331 | noprint: | |
332 | bp->b_flags |= B_ERROR; | |
333 | return (MBD_DONE); | |
334 | } | |
335 | if (er) | |
336 | return (MBD_RETRY); | |
337 | } | |
338 | bp->b_resid = 0; | |
339 | if (bp->b_flags & B_READ) | |
340 | if (ds&HTDS_TM) { /* must be a read, right? */ | |
341 | bp->b_resid = bp->b_bcount; | |
342 | sc->sc_nxrec = bdbtofsb(bp->b_blkno); | |
343 | } else if(bp->b_bcount > MASKREG(htaddr->htfc)) | |
344 | bp->b_resid = bp->b_bcount - MASKREG(htaddr->htfc); | |
345 | return (MBD_DONE); | |
346 | } | |
347 | ||
348 | htndtint(mi) | |
349 | register struct mba_device *mi; | |
350 | { | |
351 | register struct htdevice *htaddr = (struct htdevice *)mi->mi_drv; | |
352 | register struct buf *bp = mi->mi_tab.b_actf; | |
353 | register struct tu_softc *sc; | |
354 | int er, ds, fc; | |
355 | ||
356 | ds = MASKREG(htaddr->htds); | |
357 | er = MASKREG(htaddr->hter); | |
358 | fc = MASKREG(htaddr->htfc); | |
359 | if (er) { | |
360 | htaddr->htcs1 = HT_DCLR|HT_GO; | |
361 | mbclrattn(mi); | |
362 | } | |
363 | if (bp == 0) | |
364 | return (MBN_SKIP); | |
365 | sc = &tu_softc[TUUNIT(bp->b_dev)]; | |
366 | sc->sc_dsreg = ds; | |
367 | sc->sc_erreg = er; | |
368 | sc->sc_resid = fc; | |
369 | if (bp == &chtbuf[HTUNIT(bp->b_dev)]) { | |
370 | switch (bp->b_command) { | |
371 | case HT_REWOFFL: | |
372 | /* offline is on purpose; don't do anything special */ | |
373 | ds |= HTDS_MOL; | |
374 | break; | |
375 | case HT_SREV: | |
376 | /* if backspace file hit bot, its not an error */ | |
377 | if (er == (HTER_NEF|HTER_FCE) && ds&HTDS_BOT && | |
378 | bp->b_repcnt == INF) | |
379 | er &= ~HTER_NEF; | |
380 | break; | |
381 | } | |
382 | er &= ~HTER_FCE; | |
383 | if (er == 0) | |
384 | ds &= ~HTDS_ERR; | |
385 | } | |
386 | if ((ds & (HTDS_ERR|HTDS_MOL)) != HTDS_MOL) { | |
387 | if ((ds & HTDS_MOL) == 0 && sc->sc_openf > 0) | |
388 | sc->sc_openf = -1; | |
389 | printf("tu%d: hard error bn%d er=%b ds=%b\n", | |
390 | TUUNIT(bp->b_dev), bp->b_blkno, | |
391 | sc->sc_erreg, hter_bits, sc->sc_dsreg, htds_bits); | |
392 | bp->b_flags |= B_ERROR; | |
393 | return (MBN_DONE); | |
394 | } | |
395 | if (bp == &chtbuf[HTUNIT(bp->b_dev)]) { | |
396 | if (sc->sc_flags & H_REWIND) | |
397 | return (ds & HTDS_BOT ? MBN_DONE : MBN_RETRY); | |
398 | bp->b_resid = -sc->sc_resid; | |
399 | return (MBN_DONE); | |
400 | } | |
401 | if (ds & HTDS_TM) | |
402 | if (sc->sc_blkno > bdbtofsb(bp->b_blkno)) { | |
403 | sc->sc_nxrec = bdbtofsb(bp->b_blkno) - fc; | |
404 | sc->sc_blkno = sc->sc_nxrec; | |
405 | } else { | |
406 | sc->sc_blkno = bdbtofsb(bp->b_blkno) + fc; | |
407 | sc->sc_nxrec = sc->sc_blkno - 1; | |
408 | } | |
409 | else | |
410 | sc->sc_blkno = bdbtofsb(bp->b_blkno); | |
411 | return (MBN_RETRY); | |
412 | } | |
413 | ||
414 | htread(dev, uio) | |
415 | dev_t dev; | |
416 | struct uio *uio; | |
417 | { | |
418 | int errno; | |
419 | ||
420 | errno = htphys(dev, uio); | |
421 | if (errno) | |
422 | return (errno); | |
423 | return (physio(htstrategy, &rhtbuf[HTUNIT(dev)], dev, B_READ, minphys, uio)); | |
424 | } | |
425 | ||
426 | htwrite(dev, uio) | |
427 | dev_t dev; | |
428 | struct uio *uio; | |
429 | { | |
430 | int errno; | |
431 | ||
432 | errno = htphys(dev, uio); | |
433 | if (errno) | |
434 | return (errno); | |
435 | return (physio(htstrategy, &rhtbuf[HTUNIT(dev)], dev, B_WRITE, minphys, uio)); | |
436 | } | |
437 | ||
438 | htphys(dev, uio) | |
439 | dev_t dev; | |
440 | struct uio *uio; | |
441 | { | |
442 | register int htunit; | |
443 | register struct tu_softc *sc; | |
444 | register struct mba_device *mi; | |
445 | daddr_t a; | |
446 | ||
447 | htunit = HTUNIT(dev); | |
448 | if (htunit >= NHT || (mi = htinfo[htunit]) == 0 || mi->mi_alive == 0) | |
449 | return (ENXIO); | |
450 | a = uio->uio_offset >> 9; | |
451 | sc = &tu_softc[TUUNIT(dev)]; | |
452 | sc->sc_blkno = bdbtofsb(a); | |
453 | sc->sc_nxrec = bdbtofsb(a)+1; | |
454 | return (0); | |
455 | } | |
456 | ||
457 | /*ARGSUSED*/ | |
458 | htioctl(dev, cmd, data, flag) | |
459 | dev_t dev; | |
460 | int cmd; | |
461 | caddr_t data; | |
462 | int flag; | |
463 | { | |
464 | register struct tu_softc *sc = &tu_softc[TUUNIT(dev)]; | |
465 | register struct buf *bp = &chtbuf[HTUNIT(dev)]; | |
466 | register callcount; | |
467 | int fcount; | |
468 | struct mtop *mtop; | |
469 | struct mtget *mtget; | |
470 | /* we depend of the values and order of the MT codes here */ | |
471 | static htops[] = | |
472 | {HT_WEOF,HT_SFORW,HT_SREV,HT_SFORW,HT_SREV,HT_REW,HT_REWOFFL,HT_SENSE}; | |
473 | ||
474 | switch (cmd) { | |
475 | ||
476 | case MTIOCTOP: /* tape operation */ | |
477 | mtop = (struct mtop *)data; | |
478 | switch (mtop->mt_op) { | |
479 | ||
480 | case MTWEOF: | |
481 | callcount = mtop->mt_count; | |
482 | fcount = 1; | |
483 | break; | |
484 | ||
485 | case MTFSF: case MTBSF: | |
486 | callcount = mtop->mt_count; | |
487 | fcount = INF; | |
488 | break; | |
489 | ||
490 | case MTFSR: case MTBSR: | |
491 | callcount = 1; | |
492 | fcount = mtop->mt_count; | |
493 | break; | |
494 | ||
495 | case MTREW: case MTOFFL: | |
496 | callcount = 1; | |
497 | fcount = 1; | |
498 | break; | |
499 | ||
500 | default: | |
501 | return (ENXIO); | |
502 | } | |
503 | if (callcount <= 0 || fcount <= 0) | |
504 | return (EINVAL); | |
505 | while (--callcount >= 0) { | |
506 | htcommand(dev, htops[mtop->mt_op], fcount); | |
507 | if ((mtop->mt_op == MTFSR || mtop->mt_op == MTBSR) && | |
508 | bp->b_resid) | |
509 | return (EIO); | |
510 | if ((bp->b_flags&B_ERROR) || sc->sc_dsreg&HTDS_BOT) | |
511 | break; | |
512 | } | |
513 | return (geterror(bp)); | |
514 | ||
515 | case MTIOCGET: | |
516 | mtget = (struct mtget *)data; | |
517 | mtget->mt_dsreg = sc->sc_dsreg; | |
518 | mtget->mt_erreg = sc->sc_erreg; | |
519 | mtget->mt_resid = sc->sc_resid; | |
520 | mtget->mt_type = MT_ISHT; | |
521 | break; | |
522 | ||
523 | default: | |
524 | return (ENXIO); | |
525 | } | |
526 | return (0); | |
527 | } | |
528 | ||
529 | #define DBSIZE 20 | |
530 | ||
531 | htdump() | |
532 | { | |
533 | register struct mba_device *mi; | |
534 | register struct mba_regs *mp; | |
535 | register struct htdevice *htaddr; | |
536 | int blk, num; | |
537 | int start; | |
538 | ||
539 | start = 0; | |
540 | num = maxfree; | |
541 | #define phys(a,b) ((b)((int)(a)&0x7fffffff)) | |
542 | if (htinfo[0] == 0) | |
543 | return (ENXIO); | |
544 | mi = phys(htinfo[0], struct mba_device *); | |
545 | mp = phys(mi->mi_hd, struct mba_hd *)->mh_physmba; | |
546 | mp->mba_cr = MBCR_IE; | |
547 | htaddr = (struct htdevice *)&mp->mba_drv[mi->mi_drive]; | |
548 | htaddr->httc = HTTC_PDP11|HTTC_1600BPI; | |
549 | htaddr->htcs1 = HT_DCLR|HT_GO; | |
550 | while (num > 0) { | |
551 | blk = num > DBSIZE ? DBSIZE : num; | |
552 | htdwrite(start, blk, htaddr, mp); | |
553 | start += blk; | |
554 | num -= blk; | |
555 | } | |
556 | hteof(htaddr); | |
557 | hteof(htaddr); | |
558 | htwait(htaddr); | |
559 | if (htaddr->htds&HTDS_ERR) | |
560 | return (EIO); | |
561 | htaddr->htcs1 = HT_REW|HT_GO; | |
562 | return (0); | |
563 | } | |
564 | ||
565 | htdwrite(dbuf, num, htaddr, mp) | |
566 | register dbuf, num; | |
567 | register struct htdevice *htaddr; | |
568 | struct mba_regs *mp; | |
569 | { | |
570 | register struct pte *io; | |
571 | register int i; | |
572 | ||
573 | htwait(htaddr); | |
574 | io = mp->mba_map; | |
575 | for (i = 0; i < num; i++) | |
576 | *(int *)io++ = dbuf++ | PG_V; | |
577 | htaddr->htfc = -(num*NBPG); | |
578 | mp->mba_sr = -1; | |
579 | mp->mba_bcr = -(num*NBPG); | |
580 | mp->mba_var = 0; | |
581 | htaddr->htcs1 = HT_WCOM|HT_GO; | |
582 | } | |
583 | ||
584 | htwait(htaddr) | |
585 | struct htdevice *htaddr; | |
586 | { | |
587 | register s; | |
588 | ||
589 | do | |
590 | s = htaddr->htds; | |
591 | while ((s & HTDS_DRY) == 0); | |
592 | } | |
593 | ||
594 | hteof(htaddr) | |
595 | struct htdevice *htaddr; | |
596 | { | |
597 | ||
598 | htwait(htaddr); | |
599 | htaddr->htcs1 = HT_WEOF|HT_GO; | |
600 | } | |
601 | #endif |