fdc.c (2384b3a702ec96455bd31080c4aca588b2e470ec) fdc.c (ed2fa05ecec2e2d748d7e6d15e57ec55efaa96e9)
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.13 1993/12/16 04:28:42 ache Exp $
38 * $Id: fd.c,v 1.14 1993/12/16 19:47:42 ache Exp $
39 *
40 */
41
42#include "fd.h"
43#if NFD > 0
44
45#include "param.h"
46#include "dkbad.h"

--- 20 unchanged lines hidden (view full) ---

67#define b_cylin b_resid
68#define FDBLK 512
69
70struct fd_type {
71 int sectrac; /* sectors per track */
72 int secsize; /* size code for sectors */
73 int datalen; /* data len when secsize = 0 */
74 int gap; /* gap len between sectors */
39 *
40 */
41
42#include "fd.h"
43#if NFD > 0
44
45#include "param.h"
46#include "dkbad.h"

--- 20 unchanged lines hidden (view full) ---

67#define b_cylin b_resid
68#define FDBLK 512
69
70struct fd_type {
71 int sectrac; /* sectors per track */
72 int secsize; /* size code for sectors */
73 int datalen; /* data len when secsize = 0 */
74 int gap; /* gap len between sectors */
75 /* needed for format only */
75 int tracks; /* total num of tracks */
76 int size; /* size of disk in sectors */
77 int steptrac; /* steps per cylinder */
78 int trans; /* transfer speed code */
79 int heads; /* number of heads */
76 int tracks; /* total num of tracks */
77 int size; /* size of disk in sectors */
78 int steptrac; /* steps per cylinder */
79 int trans; /* transfer speed code */
80 int heads; /* number of heads */
81 int intleave; /* interleave factor */
82 /* needed for format only */
80};
81
83};
84
82#define NUMTYPES 9
85#define NUMTYPES 11
86#define NUMDENS (NUMTYPES - 3)
83
84/* This defines must match fd_types */
87
88/* This defines must match fd_types */
85#define FD_1440 0
86#define FD_1200 1
87#define FD_360in1200 2
88#define FD_360 3
89#define FD_720in1440 4
90#define FD_720in1200 FD_720in1440
91#define FD_1720in1440 5
92#define FD_800in1200 6
93#define FD_1440in1200 7
94#define FD_1460in1200 8
89#define FD_1720 0
90#define FD_1480 1
91#define FD_1440 2
92#define FD_1200 3
93#define FD_820 4
94#define FD_800 5
95#define FD_720 6
96#define FD_360 7
95
97
98#define FD_1480in1440 FD_1480
99#define FD_360inHD 8
100#define FD_1480in1200 9
101#define FD_1440in1200 10
102
96struct fd_type fd_types[NUMTYPES] =
97{
103struct fd_type fd_types[NUMTYPES] =
104{
98 { 18,2,0xFF,0x1B,80,2880,1,0,2 }, /* 1.44M in HD 3.5in drive */
99 { 15,2,0xFF,0x1B,80,2400,1,0,2 }, /* 1.2M in HD 5.25in drive */
100 { 9,2,0xFF,0x23,40,720,2,1,2 }, /* 360K in HD 5.25in drive */
101 { 9,2,0xFF,0x2A,40,720,1,1,2 }, /* 360K in DD 5.25in drive */
102 { 9,2,0xFF,0x20,80,1440,1,1,2 }, /* 720K in HD 3.5in drive */
103 { 21,2,0xFF,0x0C,82,3444,1,0,2 }, /* 1.72M in HD 3.5in drive */
104 { 10,2,0xFF,0x2E,80,1600,1,1,2 }, /* 800K in HD 5.25in drive */
105 { 18,2,0xFF,0x02,80,2880,1,0,2 }, /* 1.44M in HD 5.25in drive */
106 { 18,2,0xFF,0x02,82,2952,1,0,2 }, /* 1.46M in HD 5.25in drive */
105 { 21,2,0xFF,0x0C,82,3444,1,0,2,2 }, /* 1.72M in HD 3.5in drive */
106 { 18,2,0xFF,0x6C,82,2952,1,0,2,1 }, /* 1.48M in HD 3.5in drive */
107 { 18,2,0xFF,0x6C,80,2880,1,0,2,1 }, /* 1.44M in HD 3.5in drive */
108 { 15,2,0xFF,0x54,80,2400,1,0,2,1 }, /* 1.2M in HD drive */
109 { 10,2,0xFF,0x2E,82,1600,1,1,2,1 }, /* 820K in HD drive */
110 { 10,2,0xFF,0x2E,80,1600,1,1,2,1 }, /* 800K in HD drive */
111 { 9,2,0xFF,0x50,80,1440,1,1,2,1 }, /* 720K in HD drive */
112 { 9,2,0xFF,0x50,40,720,1,1,2,1 }, /* 360K in DD 5.25in drive */
113
114 { 9,2,0xFF,0x50,40,720,2,1,2,1 }, /* 360K in HD drive */
115 { 18,2,0xFF,0x02,82,2952,1,0,2,2 }, /* 1.48M in HD 5.25in drive */
116 { 18,2,0xFF,0x02,80,2880,1,0,2,2 }, /* 1.44M in HD 5.25in drive */
107};
108
109#define DRVS_PER_CTLR 2
110/***********************************************************************\
111* Per controller structure. *
112\***********************************************************************/
113struct fdc_data
114{

--- 191 unchanged lines hidden (view full) ---

306 printf("1.2MB 5.25in\n");
307 fd_data[fdu].type = FD_1200;
308 break;
309 case RTCFDT_144M:
310 printf("1.44MB 3.5in\n");
311 fd_data[fdu].type = FD_1440;
312 break;
313 case RTCFDT_360K:
117};
118
119#define DRVS_PER_CTLR 2
120/***********************************************************************\
121* Per controller structure. *
122\***********************************************************************/
123struct fdc_data
124{

--- 191 unchanged lines hidden (view full) ---

316 printf("1.2MB 5.25in\n");
317 fd_data[fdu].type = FD_1200;
318 break;
319 case RTCFDT_144M:
320 printf("1.44MB 3.5in\n");
321 fd_data[fdu].type = FD_1440;
322 break;
323 case RTCFDT_360K:
314 printf("360K 5.25in\n");
324 printf("360KB 5.25in\n");
315 fd_data[fdu].type = FD_360;
316 break;
325 fd_data[fdu].type = FD_360;
326 break;
327 case RTCFDT_720K:
328 printf("720KB 3.5in\n");
329 fd_data[fdu].type = FD_720;
330 break;
317 default:
318 printf("unknown\n");
319 fd_data[fdu].type = NO_TYPE;
320 break;
321 }
322
323 fdt <<= 4;
324 fd_turnoff((caddr_t)fdu, 0);

--- 210 unchanged lines hidden (view full) ---

535{
536 fdu_t fdu = FDUNIT(minor(dev));
537 int type = FDTYPE(minor(dev));
538 int s;
539
540 /* check bounds */
541 if (fdu >= NFD || fd_data[fdu].fdc == NULL
542 || fd_data[fdu].type == NO_TYPE) return(ENXIO);
331 default:
332 printf("unknown\n");
333 fd_data[fdu].type = NO_TYPE;
334 break;
335 }
336
337 fdt <<= 4;
338 fd_turnoff((caddr_t)fdu, 0);

--- 210 unchanged lines hidden (view full) ---

549{
550 fdu_t fdu = FDUNIT(minor(dev));
551 int type = FDTYPE(minor(dev));
552 int s;
553
554 /* check bounds */
555 if (fdu >= NFD || fd_data[fdu].fdc == NULL
556 || fd_data[fdu].type == NO_TYPE) return(ENXIO);
543 if (type > NUMTYPES) return(ENXIO);
557 if (type > NUMDENS) return(ENXIO);
544 if (type == 0)
545 type = fd_data[fdu].type;
546 else {
547 type--;
548 if (type != fd_data[fdu].type) {
549 switch (fd_data[fdu].type) {
550 case FD_360:
551 return(ENXIO);
558 if (type == 0)
559 type = fd_data[fdu].type;
560 else {
561 type--;
562 if (type != fd_data[fdu].type) {
563 switch (fd_data[fdu].type) {
564 case FD_360:
565 return(ENXIO);
566 case FD_720:
567 if (type == FD_360)
568 type = FD_360inHD;
569 else if (type != FD_800
570 && type != FD_820
571 )
572 return(ENXIO);
573 break;
552 case FD_1200:
574 case FD_1200:
553 if ( type != FD_720in1200
554 && type != FD_360in1200
555 && type != FD_800in1200
556 && type != FD_1440in1200
557 && type != FD_1460in1200
558 )
575 if (type == FD_360)
576 type = FD_360inHD;
577 else if (type == FD_1440)
578 type = FD_1440in1200;
579 else if (type == FD_1480)
580 type = FD_1480in1200;
581 else if (type != FD_720
582 && type != FD_800
583 && type != FD_820
584 )
559 return(ENXIO);
560 break;
561 case FD_1440:
585 return(ENXIO);
586 break;
587 case FD_1440:
562 if ( type != FD_1720in1440
563 && type != FD_720in1440
564 )
588 if (type == FD_360)
589 type = FD_360inHD;
590 else if (type == FD_1480)
591 type = FD_1480in1440;
592 else if (type != FD_720
593 && type != FD_800
594 && type != FD_820
595 && type != FD_1200
596 && type != FD_1720
597 )
565 return(ENXIO);
566 break;
567 }
568 }
569 }
570 fd_data[fdu].ft = fd_types + type;
571 fd_data[fdu].flags |= FD_OPEN;
572

--- 241 unchanged lines hidden (view full) ---

814 out_fdc(fdcu,NE7CMD_WRITE); /* WRITE */
815 }
816 out_fdc(fdcu,head << 2 | fdu); /* head & unit */
817 out_fdc(fdcu,fd->track); /* track */
818 out_fdc(fdcu,head);
819 out_fdc(fdcu,sec); /* sector XXX +1? */
820 out_fdc(fdcu,fd->ft->secsize); /* sector size */
821 out_fdc(fdcu,sectrac); /* sectors/track */
598 return(ENXIO);
599 break;
600 }
601 }
602 }
603 fd_data[fdu].ft = fd_types + type;
604 fd_data[fdu].flags |= FD_OPEN;
605

--- 241 unchanged lines hidden (view full) ---

847 out_fdc(fdcu,NE7CMD_WRITE); /* WRITE */
848 }
849 out_fdc(fdcu,head << 2 | fdu); /* head & unit */
850 out_fdc(fdcu,fd->track); /* track */
851 out_fdc(fdcu,head);
852 out_fdc(fdcu,sec); /* sector XXX +1? */
853 out_fdc(fdcu,fd->ft->secsize); /* sector size */
854 out_fdc(fdcu,sectrac); /* sectors/track */
822 out_fdc(fdcu,fd->ft->gap); /* gap size */
855#if 0
856 out_fdc(fdcu,fd->ft->gap); /* gap size */
857#endif
858 out_fdc(fdcu,2); /* always use gap 2 for read/write */
823 out_fdc(fdcu,fd->ft->datalen); /* data length */
824 fdc->state = IOCOMPLETE;
825 timeout(fd_timeout, (caddr_t)fdcu, 2 * hz);
826 return(0); /* will return later */
827 case IOCOMPLETE: /* IO DONE, post-analyze */
828 untimeout(fd_timeout,fdcu);
829 for(i=0;i<7;i++)
830 {

--- 231 unchanged lines hidden ---
859 out_fdc(fdcu,fd->ft->datalen); /* data length */
860 fdc->state = IOCOMPLETE;
861 timeout(fd_timeout, (caddr_t)fdcu, 2 * hz);
862 return(0); /* will return later */
863 case IOCOMPLETE: /* IO DONE, post-analyze */
864 untimeout(fd_timeout,fdcu);
865 for(i=0;i<7;i++)
866 {

--- 231 unchanged lines hidden ---