fdc.c (126518a182087cea9597c61dd85fbe4696c50350) | fdc.c (b99f0a4a8d2eddfd8d41ddb49123edaa3b3f783f) |
---|---|
1/*#define DEBUG 1*/ 2/*- 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Don Ahn. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 | 1/*#define DEBUG 1*/ 2/*- 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Don Ahn. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 |
38 * $Id: fd.c,v 1.17 1993/12/19 00:50:33 wollman Exp $ | 38 * $from: fd.c,v 1.18 1993/12/21 05:09:21 ache Exp $ |
39 * 40 */ 41 | 39 * 40 */ 41 |
42#include "ft.h" 43#if NFT < 1 44#undef NFDC 45#endif |
|
42#include "fd.h" | 46#include "fd.h" |
43#if NFD > 0 | |
44 | 47 |
45#include "param.h" 46#include "dkbad.h" 47#include "systm.h" 48#include "kernel.h" 49#include "conf.h" 50#include "file.h" 51#include "ioctl.h" 52#include "machine/ioctl_fd.h" 53#include "disklabel.h" 54#include "buf.h" 55#include "uio.h" 56#include "malloc.h" 57#include "syslog.h" | 48#if NFDC > 0 49 50#include <sys/param.h> 51#include <sys/dkbad.h> 52#include <sys/systm.h> 53#include <sys/kernel.h> 54#include <sys/conf.h> 55#include <sys/file.h> 56#include <sys/ioctl.h> 57#include <machine/ioctl_fd.h> 58#include <sys/disklabel.h> 59#include <sys/buf.h> 60#include <sys/uio.h> 61#include <sys/malloc.h> 62#include <sys/syslog.h> |
58#include "i386/isa/isa.h" 59#include "i386/isa/isa_device.h" 60#include "i386/isa/fdreg.h" 61#include "i386/isa/icu.h" 62#include "i386/isa/rtc.h" | 63#include "i386/isa/isa.h" 64#include "i386/isa/isa_device.h" 65#include "i386/isa/fdreg.h" 66#include "i386/isa/icu.h" 67#include "i386/isa/rtc.h" |
63#undef NFD 64#define NFD 2 | |
65 | 68 |
66#define FDUNIT(s) (((s)>>6)&03) 67#define FDTYPE(s) ((s)&077) | 69#if NFT > 0 70extern int ftopen(), ftintr(), ftattach(), ftclose(), ftioctl(); 71#endif |
68 69#define b_cylin b_resid 70#define FDBLK 512 71 72/* misuse a flag to identify format operation */ 73#define B_FORMAT B_XXX 74 75#define NUMTYPES 14 76#define NUMDENS (NUMTYPES - 6) 77 | 72 73#define b_cylin b_resid 74#define FDBLK 512 75 76/* misuse a flag to identify format operation */ 77#define B_FORMAT B_XXX 78 79#define NUMTYPES 14 80#define NUMDENS (NUMTYPES - 6) 81 |
78/* This defines must match fd_types */ 79#define FD_1720 0 80#define FD_1480 1 81#define FD_1440 2 82#define FD_1200 3 83#define FD_820 4 84#define FD_800 5 85#define FD_720 6 86#define FD_360 7 | 82/* This defines (-1) must match index for fd_types */ 83#define F_TAPE_TYPE 0x020 /* bit for fd_types to indicate tape */ 84#define NO_TYPE 0 /* must match NO_TYPE in ft.c */ 85#define FD_1720 1 86#define FD_1480 2 87#define FD_1440 3 88#define FD_1200 4 89#define FD_820 5 90#define FD_800 6 91#define FD_720 7 92#define FD_360 8 |
87 | 93 |
88#define FD_1480in5_25 8 89#define FD_1440in5_25 9 90#define FD_820in5_25 10 91#define FD_800in5_25 11 92#define FD_720in5_25 12 93#define FD_360in5_25 13 | 94#define FD_1480in5_25 9 95#define FD_1440in5_25 10 96#define FD_820in5_25 11 97#define FD_800in5_25 12 98#define FD_720in5_25 13 99#define FD_360in5_25 14 |
94 | 100 |
101 |
|
95struct fd_type fd_types[NUMTYPES] = 96{ 97{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */ 98{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */ 99{ 18,2,0xFF,0x1B,80,2880,1,FDC_500KBPS,2,0x6C,1 }, /* 1.44M in HD 3.5in */ 100{ 15,2,0xFF,0x1B,80,2400,1,FDC_500KBPS,2,0x54,1 }, /* 1.2M in HD 5.25/3.5 */ 101{ 10,2,0xFF,0x10,82,1640,1,FDC_250KBPS,2,0x2E,1 }, /* 820K in HD 3.5in */ 102{ 10,2,0xFF,0x10,80,1600,1,FDC_250KBPS,2,0x2E,1 }, /* 800K in HD 3.5in */ 103{ 9,2,0xFF,0x20,80,1440,1,FDC_250KBPS,2,0x50,1 }, /* 720K in HD 3.5in */ 104{ 9,2,0xFF,0x2A,40, 720,1,FDC_300KBPS,2,0x50,1 }, /* 360K in DD 5.25in */ 105 106{ 18,2,0xFF,0x02,82,2952,1,FDC_500KBPS,2,0x02,2 }, /* 1.48M in HD 5.25in */ 107{ 18,2,0xFF,0x02,80,2880,1,FDC_500KBPS,2,0x02,2 }, /* 1.44M in HD 5.25in */ 108{ 10,2,0xFF,0x10,82,1640,1,FDC_300KBPS,2,0x2E,1 }, /* 820K in HD 5.25in */ 109{ 10,2,0xFF,0x10,80,1600,1,FDC_300KBPS,2,0x2E,1 }, /* 800K in HD 5.25in */ 110{ 9,2,0xFF,0x20,80,1440,1,FDC_300KBPS,2,0x50,1 }, /* 720K in HD 5.25in */ 111{ 9,2,0xFF,0x23,40, 720,2,FDC_300KBPS,2,0x50,1 }, /* 360K in HD 5.25in */ 112}; 113 | 102struct fd_type fd_types[NUMTYPES] = 103{ 104{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */ 105{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */ 106{ 18,2,0xFF,0x1B,80,2880,1,FDC_500KBPS,2,0x6C,1 }, /* 1.44M in HD 3.5in */ 107{ 15,2,0xFF,0x1B,80,2400,1,FDC_500KBPS,2,0x54,1 }, /* 1.2M in HD 5.25/3.5 */ 108{ 10,2,0xFF,0x10,82,1640,1,FDC_250KBPS,2,0x2E,1 }, /* 820K in HD 3.5in */ 109{ 10,2,0xFF,0x10,80,1600,1,FDC_250KBPS,2,0x2E,1 }, /* 800K in HD 3.5in */ 110{ 9,2,0xFF,0x20,80,1440,1,FDC_250KBPS,2,0x50,1 }, /* 720K in HD 3.5in */ 111{ 9,2,0xFF,0x2A,40, 720,1,FDC_300KBPS,2,0x50,1 }, /* 360K in DD 5.25in */ 112 113{ 18,2,0xFF,0x02,82,2952,1,FDC_500KBPS,2,0x02,2 }, /* 1.48M in HD 5.25in */ 114{ 18,2,0xFF,0x02,80,2880,1,FDC_500KBPS,2,0x02,2 }, /* 1.44M in HD 5.25in */ 115{ 10,2,0xFF,0x10,82,1640,1,FDC_300KBPS,2,0x2E,1 }, /* 820K in HD 5.25in */ 116{ 10,2,0xFF,0x10,80,1600,1,FDC_300KBPS,2,0x2E,1 }, /* 800K in HD 5.25in */ 117{ 9,2,0xFF,0x20,80,1440,1,FDC_300KBPS,2,0x50,1 }, /* 720K in HD 5.25in */ 118{ 9,2,0xFF,0x23,40, 720,2,FDC_300KBPS,2,0x50,1 }, /* 360K in HD 5.25in */ 119}; 120 |
114#define DRVS_PER_CTLR 2 | 121#define DRVS_PER_CTLR 2 /* 2 floppies */ |
115/***********************************************************************\ 116* Per controller structure. * 117\***********************************************************************/ | 122/***********************************************************************\ 123* Per controller structure. * 124\***********************************************************************/ |
118struct fdc_data 119{ 120 int fdcu; /* our unit number */ 121 int baseport; 122 int dmachan; 123 int flags; 124#define FDC_ATTACHED 0x01 125 struct fd_data *fd; 126 int fdu; /* the active drive */ 127 struct buf head; /* Head of buf chain */ 128 struct buf rhead; /* Raw head of buf chain */ 129 int state; 130 int retry; 131 int status[7]; /* copy of the registers */ 132}fdc_data[(NFD+1)/DRVS_PER_CTLR]; | 125struct fdc_data fdc_data[NFDC]; |
133 134/***********************************************************************\ 135* Per drive structure. * | 126 127/***********************************************************************\ 128* Per drive structure. * |
136* N per controller (presently 2) (DRVS_PER_CTLR) * | 129* N per controller (DRVS_PER_CTLR) * |
137\***********************************************************************/ 138struct fd_data { | 130\***********************************************************************/ 131struct fd_data { |
139 struct fdc_data *fdc; 140 int fdu; /* this unit number */ | 132 struct fdc_data *fdc; /* pointer to controller structure */ |
141 int fdsu; /* this units number on this controller */ 142 int type; /* Drive type (HD, DD */ 143 struct fd_type *ft; /* pointer to the type descriptor */ 144 int flags; 145#define FD_OPEN 0x01 /* it's open */ 146#define FD_ACTIVE 0x02 /* it's active */ 147#define FD_MOTOR 0x04 /* motor should be on */ 148#define FD_MOTOR_WAIT 0x08 /* motor coming up */ --- 5 unchanged lines hidden (view full) --- 154/***********************************************************************\ 155* Throughout this file the following conventions will be used: * 156* fd is a pointer to the fd_data struct for the drive in question * 157* fdc is a pointer to the fdc_data struct for the controller * 158* fdu is the floppy drive unit number * 159* fdcu is the floppy controller unit number * 160* fdsu is the floppy drive unit number on that controller. (sub-unit) * 161\***********************************************************************/ | 133 int fdsu; /* this units number on this controller */ 134 int type; /* Drive type (HD, DD */ 135 struct fd_type *ft; /* pointer to the type descriptor */ 136 int flags; 137#define FD_OPEN 0x01 /* it's open */ 138#define FD_ACTIVE 0x02 /* it's active */ 139#define FD_MOTOR 0x04 /* motor should be on */ 140#define FD_MOTOR_WAIT 0x08 /* motor coming up */ --- 5 unchanged lines hidden (view full) --- 146/***********************************************************************\ 147* Throughout this file the following conventions will be used: * 148* fd is a pointer to the fd_data struct for the drive in question * 149* fdc is a pointer to the fdc_data struct for the controller * 150* fdu is the floppy drive unit number * 151* fdcu is the floppy controller unit number * 152* fdsu is the floppy drive unit number on that controller. (sub-unit) * 153\***********************************************************************/ |
162typedef int fdu_t; 163typedef int fdcu_t; 164typedef int fdsu_t; 165typedef struct fd_data *fd_p; 166typedef struct fdc_data *fdc_p; | |
167 | 154 |
155#define id_physid id_scsiid /* this biotab field doubles as a field */ 156 /* for the physical unit number on the controller */ 157 |
|
168static int retrier(fdcu_t); 169 170#define DEVIDLE 0 171#define FINDWORK 1 172#define DOSEEK 2 173#define SEEKCOMPLETE 3 174#define IOCOMPLETE 4 175#define RECALCOMPLETE 5 --- 35 unchanged lines hidden (view full) --- 211static void fd_turnoff(caddr_t, int); 212 213/****************************************************************************/ 214/* autoconfiguration stuff */ 215/****************************************************************************/ 216static int fdprobe(struct isa_device *); 217static int fdattach(struct isa_device *); 218 | 158static int retrier(fdcu_t); 159 160#define DEVIDLE 0 161#define FINDWORK 1 162#define DOSEEK 2 163#define SEEKCOMPLETE 3 164#define IOCOMPLETE 4 165#define RECALCOMPLETE 5 --- 35 unchanged lines hidden (view full) --- 201static void fd_turnoff(caddr_t, int); 202 203/****************************************************************************/ 204/* autoconfiguration stuff */ 205/****************************************************************************/ 206static int fdprobe(struct isa_device *); 207static int fdattach(struct isa_device *); 208 |
219struct isa_driver fddriver = { 220 fdprobe, fdattach, "fd", | 209struct isa_driver fdcdriver = { 210 fdprobe, fdattach, "fdc", |
221}; 222 223/* 224 * probe for existance of controller 225 */ 226int 227fdprobe(dev) 228 struct isa_device *dev; --- 32 unchanged lines hidden (view full) --- 261{ 262 unsigned fdt,st0, cyl; 263 int hdr; 264 fdu_t fdu; 265 fdcu_t fdcu = dev->id_unit; 266 fdc_p fdc = fdc_data + fdcu; 267 fd_p fd; 268 int fdsu; | 211}; 212 213/* 214 * probe for existance of controller 215 */ 216int 217fdprobe(dev) 218 struct isa_device *dev; --- 32 unchanged lines hidden (view full) --- 251{ 252 unsigned fdt,st0, cyl; 253 int hdr; 254 fdu_t fdu; 255 fdcu_t fdcu = dev->id_unit; 256 fdc_p fdc = fdc_data + fdcu; 257 fd_p fd; 258 int fdsu; |
259 struct isa_device *fdup; |
|
269 270 fdc->fdcu = fdcu; 271 fdc->flags |= FDC_ATTACHED; 272 fdc->dmachan = dev->id_drq; 273 fdc->state = DEVIDLE; | 260 261 fdc->fdcu = fdcu; 262 fdc->flags |= FDC_ATTACHED; 263 fdc->dmachan = dev->id_drq; 264 fdc->state = DEVIDLE; |
274 275 fdt = rtcin(RTC_FDISKETTE); | |
276 hdr = 0; | 265 hdr = 0; |
266 printf("fdc%d:", fdcu); |
|
277 278 /* check for each floppy drive */ | 267 268 /* check for each floppy drive */ |
279 for (fdu = (fdcu * DRVS_PER_CTLR),fdsu = 0; 280 ((fdu < NFD) && (fdsu < DRVS_PER_CTLR)); 281 fdu++,fdsu++) 282 { | 269 for (fdup = isa_biotab_fdc; fdup->id_driver != 0; fdup++) { 270 if (fdup->id_iobase != dev->id_iobase) 271 continue; 272 fdu = fdup->id_unit; 273 fd = &fd_data[fdu]; 274 if (fdu >= (NFD+NFT)) 275 continue; 276 fdsu = fdup->id_physid; 277 /* look up what bios thinks we have */ 278 switch (fdu) { 279 case 0: fdt = (rtcin(RTC_FDISKETTE) & 0xf0); 280 break; 281 case 1: fdt = ((rtcin(RTC_FDISKETTE) << 4) & 0xf0); 282 break; 283 default: fdt = RTCFDT_NONE; 284 break; 285 } |
283 /* is there a unit? */ | 286 /* is there a unit? */ |
284 if ((fdt & 0xf0) == RTCFDT_NONE) { 285#define NO_TYPE NUMTYPES 286 fd_data[fdu].type = NO_TYPE; | 287 if ((fdt == RTCFDT_NONE) 288#if NFT > 0 289 || (fdsu >= DRVS_PER_CTLR)) { 290#else 291 ) { 292#endif 293#if NFT > 0 294 /* If BIOS says no floppy, or > 2nd device */ 295 /* Probe for and attach a floppy tape. */ 296 if (ftattach(dev, fdup)) 297 continue; 298 299#endif 300 fd->type = NO_TYPE; |
287 continue; 288 } 289 290#ifdef notyet 291 /* select it */ 292 fd_turnon1(fdu); 293 spinwait(1000); /* 1 sec */ 294 out_fdc(fdcu,NE7CMD_RECAL); /* Recalibrate Function */ 295 out_fdc(fdcu,fdsu); 296 spinwait(1000); /* 1 sec */ 297 298 /* anything responding */ 299 out_fdc(fdcu,NE7CMD_SENSEI); 300 st0 = in_fdc(fdcu); 301 cyl = in_fdc(fdcu); 302 if (st0 & 0xd0) 303 continue; 304 305#endif | 301 continue; 302 } 303 304#ifdef notyet 305 /* select it */ 306 fd_turnon1(fdu); 307 spinwait(1000); /* 1 sec */ 308 out_fdc(fdcu,NE7CMD_RECAL); /* Recalibrate Function */ 309 out_fdc(fdcu,fdsu); 310 spinwait(1000); /* 1 sec */ 311 312 /* anything responding */ 313 out_fdc(fdcu,NE7CMD_SENSEI); 314 st0 = in_fdc(fdcu); 315 cyl = in_fdc(fdcu); 316 if (st0 & 0xd0) 317 continue; 318 319#endif |
306 fd_data[fdu].track = -2; 307 fd_data[fdu].fdc = fdc; 308 fd_data[fdu].fdsu = fdsu; 309 printf("fd%d: unit %d type ", fdcu, fdu); | 320 fd->track = -2; 321 fd->fdc = fdc; 322 fd->fdsu = fdsu; 323 printf(" [%d: fd%d: ", fdsu, fdu); |
310 | 324 |
311 switch (fdt & 0xf0) { | 325 switch (fdt) { |
312 case RTCFDT_12M: | 326 case RTCFDT_12M: |
313 printf("1.2MB 5.25in\n"); 314 fd_data[fdu].type = FD_1200; | 327 printf("1.2MB 5.25in]"); 328 fd->type = FD_1200; |
315 break; 316 case RTCFDT_144M: | 329 break; 330 case RTCFDT_144M: |
317 printf("1.44MB 3.5in\n"); 318 fd_data[fdu].type = FD_1440; | 331 printf("1.44MB 3.5in]"); 332 fd->type = FD_1440; |
319 break; 320 case RTCFDT_360K: | 333 break; 334 case RTCFDT_360K: |
321 printf("360KB 5.25in\n"); 322 fd_data[fdu].type = FD_360; | 335 printf("360KB 5.25in]"); 336 fd->type = FD_360; |
323 break; 324 case RTCFDT_720K: | 337 break; 338 case RTCFDT_720K: |
325 printf("720KB 3.5in\n"); 326 fd_data[fdu].type = FD_720; | 339 printf("720KB 3.5in]"); 340 fd->type = FD_720; |
327 break; 328 default: | 341 break; 342 default: |
329 printf("unknown\n"); 330 fd_data[fdu].type = NO_TYPE; | 343 printf("unknown]"); 344 fd->type = NO_TYPE; |
331 break; 332 } 333 | 345 break; 346 } 347 |
334 fdt <<= 4; | |
335 fd_turnoff((caddr_t)fdu, 0); 336 hdr = 1; 337 } | 348 fd_turnoff((caddr_t)fdu, 0); 349 hdr = 1; 350 } |
351 printf("\n"); |
|
338 339 /* Set transfer to 500kbps */ 340 outb(fdc->baseport+fdctl,0); /*XXX*/ 341 return 1; 342} 343 344int 345fdsize(dev) --- 14 unchanged lines hidden (view full) --- 360 fdu_t fdu; 361 fdc_p fdc; 362 fd_p fd; 363 364 fdu = FDUNIT(minor(bp->b_dev)); 365 fd = &fd_data[fdu]; 366 fdc = fd->fdc; 367 fdcu = fdc->fdcu; | 352 353 /* Set transfer to 500kbps */ 354 outb(fdc->baseport+fdctl,0); /*XXX*/ 355 return 1; 356} 357 358int 359fdsize(dev) --- 14 unchanged lines hidden (view full) --- 374 fdu_t fdu; 375 fdc_p fdc; 376 fd_p fd; 377 378 fdu = FDUNIT(minor(bp->b_dev)); 379 fd = &fd_data[fdu]; 380 fdc = fd->fdc; 381 fdcu = fdc->fdcu; |
368 /*type = FDTYPE(minor(bp->b_dev));*/ | |
369 | 382 |
370 if ((fdu >= NFD) || (bp->b_blkno < 0)) { | 383#if NFT > 0 384 /* check for controller already busy with tape */ 385 if (fdc->flags & FDC_TAPE_BUSY) { 386 bp->b_error = EBUSY; 387 bp->b_flags |= B_ERROR; 388 return; 389 } 390#endif 391 if ((fdu >= (NFD+NFT)) || (bp->b_blkno < 0)) { |
371 printf("fdstrat: fdu = %d, blkno = %d, bcount = %d\n", 372 fdu, bp->b_blkno, bp->b_bcount); 373 pg("fd:error in fdstrategy"); 374 bp->b_error = EINVAL; 375 bp->b_flags |= B_ERROR; 376 goto bad; 377 } 378 /* --- 163 unchanged lines hidden (view full) --- 542/****************************************************************************/ 543int 544Fdopen(dev, flags) 545 dev_t dev; 546 int flags; 547{ 548 fdu_t fdu = FDUNIT(minor(dev)); 549 int type = FDTYPE(minor(dev)); | 392 printf("fdstrat: fdu = %d, blkno = %d, bcount = %d\n", 393 fdu, bp->b_blkno, bp->b_bcount); 394 pg("fd:error in fdstrategy"); 395 bp->b_error = EINVAL; 396 bp->b_flags |= B_ERROR; 397 goto bad; 398 } 399 /* --- 163 unchanged lines hidden (view full) --- 563/****************************************************************************/ 564int 565Fdopen(dev, flags) 566 dev_t dev; 567 int flags; 568{ 569 fdu_t fdu = FDUNIT(minor(dev)); 570 int type = FDTYPE(minor(dev)); |
550 int s; | 571 fdc_p fdc; |
551 | 572 |
573#if NFT > 0 574 /* check for a tape open */ 575 if (type & F_TAPE_TYPE) 576 return(ftopen(dev, flags)); 577#endif |
|
552 /* check bounds */ | 578 /* check bounds */ |
553 if (fdu >= NFD || fd_data[fdu].fdc == NULL 554 || fd_data[fdu].type == NO_TYPE) return(ENXIO); 555 if (type > NUMDENS) return(ENXIO); | 579 if (fdu >= NFD) 580 return(ENXIO); 581 fdc = fd_data[fdu].fdc; 582 if ((fdc == NULL) || (fd_data[fdu].type == NO_TYPE)) 583 return(ENXIO); 584 if (type > NUMDENS) 585 return(ENXIO); |
556 if (type == 0) 557 type = fd_data[fdu].type; 558 else { | 586 if (type == 0) 587 type = fd_data[fdu].type; 588 else { |
559 type--; | |
560 if (type != fd_data[fdu].type) { 561 switch (fd_data[fdu].type) { 562 case FD_360: 563 return(ENXIO); 564 case FD_720: 565 if ( type != FD_820 566 && type != FD_800 567 ) --- 31 unchanged lines hidden (view full) --- 599 && type != FD_800 600 && type != FD_720 601 ) 602 return(ENXIO); 603 break; 604 } 605 } 606 } | 589 if (type != fd_data[fdu].type) { 590 switch (fd_data[fdu].type) { 591 case FD_360: 592 return(ENXIO); 593 case FD_720: 594 if ( type != FD_820 595 && type != FD_800 596 ) --- 31 unchanged lines hidden (view full) --- 628 && type != FD_800 629 && type != FD_720 630 ) 631 return(ENXIO); 632 break; 633 } 634 } 635 } |
607 fd_data[fdu].ft = fd_types + type; | 636 fd_data[fdu].ft = fd_types + type - 1; |
608 fd_data[fdu].flags |= FD_OPEN; 609 610 return 0; 611} 612 613int 614fdclose(dev, flags) 615 dev_t dev; 616 int flags; 617{ 618 fdu_t fdu = FDUNIT(minor(dev)); | 637 fd_data[fdu].flags |= FD_OPEN; 638 639 return 0; 640} 641 642int 643fdclose(dev, flags) 644 dev_t dev; 645 int flags; 646{ 647 fdu_t fdu = FDUNIT(minor(dev)); |
648 int type = FDTYPE(minor(dev)); 649 650#if NFT > 0 651 if (type & F_TAPE_TYPE) 652 return ftclose(0); 653#endif |
|
619 fd_data[fdu].flags &= ~FD_OPEN; 620 return(0); 621} 622 623 624/***************************************************************\ 625* fdstart * 626* We have just queued something.. if the controller is not busy * --- 80 unchanged lines hidden (view full) --- 707* fdintr * 708* keep calling the state machine until it returns a 0 * 709* ALWAYS called at SPLBIO * 710\***********************************************************************/ 711void 712fdintr(fdcu_t fdcu) 713{ 714 fdc_p fdc = fdc_data + fdcu; | 654 fd_data[fdu].flags &= ~FD_OPEN; 655 return(0); 656} 657 658 659/***************************************************************\ 660* fdstart * 661* We have just queued something.. if the controller is not busy * --- 80 unchanged lines hidden (view full) --- 742* fdintr * 743* keep calling the state machine until it returns a 0 * 744* ALWAYS called at SPLBIO * 745\***********************************************************************/ 746void 747fdintr(fdcu_t fdcu) 748{ 749 fdc_p fdc = fdc_data + fdcu; |
750#if NFT > 0 751 fdu_t fdu = fdc->fdu; 752 753 if (fdc->flags & FDC_TAPE_BUSY) 754 (ftintr(fdu)); 755 else 756#endif |
|
715 while(fdstate(fdcu, fdc)) 716 ; 717} 718 719/***********************************************************************\ 720* The controller state machine. * 721* if it returns a non zero value, it should be called again immediatly * 722\***********************************************************************/ --- 101 unchanged lines hidden (view full) --- 824 if(fd->track == -2) 825 { 826 int descyl = bp->b_cylin * fd->ft->steptrac; 827 out_fdc(fdcu,NE7CMD_SENSEI); 828 i = in_fdc(fdcu); 829 cyl = in_fdc(fdcu); 830 if (cyl != descyl) 831 { | 757 while(fdstate(fdcu, fdc)) 758 ; 759} 760 761/***********************************************************************\ 762* The controller state machine. * 763* if it returns a non zero value, it should be called again immediatly * 764\***********************************************************************/ --- 101 unchanged lines hidden (view full) --- 866 if(fd->track == -2) 867 { 868 int descyl = bp->b_cylin * fd->ft->steptrac; 869 out_fdc(fdcu,NE7CMD_SENSEI); 870 i = in_fdc(fdcu); 871 cyl = in_fdc(fdcu); 872 if (cyl != descyl) 873 { |
832 printf("fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n", fdu, 833 descyl, cyl, i, NE7_ST0BITS); | 874 printf("fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n", 875 fdu, descyl, cyl, i, NE7_ST0BITS); |
834 return(retrier(fdcu)); 835 } 836 } 837 838 fd->track = bp->b_cylin; 839 if(format) 840 fd->skip = (char *)&(finfo->fd_formb_cylno(0)) 841 - (char *)finfo; --- 283 unchanged lines hidden (view full) --- 1125 int flag; 1126 struct proc *p; 1127{ 1128 struct fd_type *fdt; 1129 struct disklabel *dl; 1130 char buffer[DEV_BSIZE]; 1131 int error; 1132 | 876 return(retrier(fdcu)); 877 } 878 } 879 880 fd->track = bp->b_cylin; 881 if(format) 882 fd->skip = (char *)&(finfo->fd_formb_cylno(0)) 883 - (char *)finfo; --- 283 unchanged lines hidden (view full) --- 1167 int flag; 1168 struct proc *p; 1169{ 1170 struct fd_type *fdt; 1171 struct disklabel *dl; 1172 char buffer[DEV_BSIZE]; 1173 int error; 1174 |
1175#if NFT > 0 1176 if (fd_data[FDUNIT(minor(dev))].fdc->flags & FDC_TAPE_BUSY) 1177 return ftioctl(dev, cmd, addr, flag, p); 1178#endif 1179 |
|
1133 error = 0; 1134 1135 switch (cmd) 1136 { 1137 case DIOCGDINFO: 1138 bzero(buffer, sizeof (buffer)); 1139 dl = (struct disklabel *)buffer; 1140 dl->d_secsize = FDBLK; --- 61 unchanged lines hidden --- | 1180 error = 0; 1181 1182 switch (cmd) 1183 { 1184 case DIOCGDINFO: 1185 bzero(buffer, sizeof (buffer)); 1186 dl = (struct disklabel *)buffer; 1187 dl->d_secsize = FDBLK; --- 61 unchanged lines hidden --- |