Deleted Added
full compact
mcd.c (5226) mcd.c (6028)
1/*
2 * Copyright 1993 by Holger Veit (data part)
3 * Copyright 1993 by Brian Moore (audio part)
4 * Changes Copyright 1993 by Gary Clark II
5 * Changes Copyright (C) 1994 by Andrew A. Chernov
6 *
7 * Rewrote probe routine to work on newer Mitsumi drives.
8 * Additional changes (C) 1994 by Jordan K. Hubbard

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

35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
1/*
2 * Copyright 1993 by Holger Veit (data part)
3 * Copyright 1993 by Brian Moore (audio part)
4 * Changes Copyright 1993 by Gary Clark II
5 * Changes Copyright (C) 1994 by Andrew A. Chernov
6 *
7 * Rewrote probe routine to work on newer Mitsumi drives.
8 * Additional changes (C) 1994 by Jordan K. Hubbard

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

35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
43 * $Id: mcd.c,v 1.34 1994/12/21 15:17:59 ache Exp $
43 * $Id: mcd.c,v 1.35 1994/12/24 13:24:00 ache Exp $
44 */
45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
46
47#include "mcd.h"
48#if NMCD > 0
49#include <sys/types.h>
50#include <sys/param.h>
51#include <sys/systm.h>

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

121 short mode;
122};
123
124struct mcd_data {
125 short type;
126 char *name;
127 short config;
128 short flags;
44 */
45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
46
47#include "mcd.h"
48#if NMCD > 0
49#include <sys/types.h>
50#include <sys/param.h>
51#include <sys/systm.h>

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

121 short mode;
122};
123
124struct mcd_data {
125 short type;
126 char *name;
127 short config;
128 short flags;
129 u_char read_command;
129 short status;
130 int blksize;
131 u_long disksize;
132 int iobase;
133 struct disklabel dlabel;
134 int partflags[MAXPARTITIONS];
135 int openflags;
136 struct mcd_volinfo volinfo;

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

675 stbytes[j] = (inb(port+MCD_DATA) & 0xFF);
676 }
677 if (stbytes[1] == stbytes[2])
678 return 0;
679 if (stbytes[2] >= 4 || stbytes[1] != 'M') {
680 outb(port+MCD_CTRL, M_PICKLE);
681 mcd_data[unit].flags |= MCDNEWMODEL;
682 }
130 short status;
131 int blksize;
132 u_long disksize;
133 int iobase;
134 struct disklabel dlabel;
135 int partflags[MAXPARTITIONS];
136 int openflags;
137 struct mcd_volinfo volinfo;

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

676 stbytes[j] = (inb(port+MCD_DATA) & 0xFF);
677 }
678 if (stbytes[1] == stbytes[2])
679 return 0;
680 if (stbytes[2] >= 4 || stbytes[1] != 'M') {
681 outb(port+MCD_CTRL, M_PICKLE);
682 mcd_data[unit].flags |= MCDNEWMODEL;
683 }
684 mcd_data[unit].read_command = MCD_CMDSINGLESPEEDREAD;
683 switch (stbytes[1]) {
684 case 'M':
685 if (mcd_data[unit].flags & MCDNEWMODEL) {
686 mcd_data[unit].type = MCD_TYPE_LU005S;
687 mcd_data[unit].name = "Mitsumi LU005S";
688 } else {
689 mcd_data[unit].type = MCD_TYPE_LU002S;
690 mcd_data[unit].name = "Mitsumi LU002S";
691 }
692 break;
693 case 'F':
694 mcd_data[unit].type = MCD_TYPE_FX001;
695 mcd_data[unit].name = "Mitsumi FX001";
696 break;
697 case 'D':
698 mcd_data[unit].type = MCD_TYPE_FX001D;
699 mcd_data[unit].name = "Mitsumi FX001D";
685 switch (stbytes[1]) {
686 case 'M':
687 if (mcd_data[unit].flags & MCDNEWMODEL) {
688 mcd_data[unit].type = MCD_TYPE_LU005S;
689 mcd_data[unit].name = "Mitsumi LU005S";
690 } else {
691 mcd_data[unit].type = MCD_TYPE_LU002S;
692 mcd_data[unit].name = "Mitsumi LU002S";
693 }
694 break;
695 case 'F':
696 mcd_data[unit].type = MCD_TYPE_FX001;
697 mcd_data[unit].name = "Mitsumi FX001";
698 break;
699 case 'D':
700 mcd_data[unit].type = MCD_TYPE_FX001D;
701 mcd_data[unit].name = "Mitsumi FX001D";
702 mcd_data[unit].read_command = MCD_CMDDOUBLESPEEDREAD;
700 break;
701 default:
702 mcd_data[unit].type = MCD_TYPE_UNKNOWN;
703 mcd_data[unit].name = "Mitsumi ???";
704 break;
705 }
706 printf("mcd%d: type %s, version info: %c %x\n", unit, mcd_data[unit].name,
707 stbytes[1], stbytes[2]);

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

747 int i;
748 struct mcd_data *cd = mcd_data + unit;
749 int port = cd->iobase;
750
751 /* get the status */
752 if (sflg)
753 outb(port+mcd_command, MCD_CMDGETSTAT);
754 i = mcd_getreply(unit,DELAY_GETREPLY);
703 break;
704 default:
705 mcd_data[unit].type = MCD_TYPE_UNKNOWN;
706 mcd_data[unit].name = "Mitsumi ???";
707 break;
708 }
709 printf("mcd%d: type %s, version info: %c %x\n", unit, mcd_data[unit].name,
710 stbytes[1], stbytes[2]);

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

750 int i;
751 struct mcd_data *cd = mcd_data + unit;
752 int port = cd->iobase;
753
754 /* get the status */
755 if (sflg)
756 outb(port+mcd_command, MCD_CMDGETSTAT);
757 i = mcd_getreply(unit,DELAY_GETREPLY);
755 if (i<0) return -1;
758 if (i<0 || (i & MCD_ST_CMDCHECK)) return -1;
756
757 cd->status = i;
758
759 if (mcd_setflags(unit,cd) < 0)
760 return -2;
761 return cd->status;
762}
763

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

912
913loop:
914 switch (state) {
915 case MCD_S_BEGIN:
916 mbx = mbxsave = mbxin;
917
918 case MCD_S_BEGIN1:
919 /* get status */
759
760 cd->status = i;
761
762 if (mcd_setflags(unit,cd) < 0)
763 return -2;
764 return cd->status;
765}
766

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

915
916loop:
917 switch (state) {
918 case MCD_S_BEGIN:
919 mbx = mbxsave = mbxin;
920
921 case MCD_S_BEGIN1:
922 /* get status */
923retry_status:
920 outb(com_port, MCD_CMDGETSTAT);
921 mbx->count = RDELAY_WAITSTAT;
922 timeout((timeout_func_t)mcd_doread,
923 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
924 return;
925 case MCD_S_WAITSTAT:
926 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT);
927 if (mbx->count-- >= 0) {
928 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
929 timeout((timeout_func_t)mcd_doread,
930 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
931 return;
932 }
933 cd->status = inb(port+mcd_status) & 0xFF;
924 outb(com_port, MCD_CMDGETSTAT);
925 mbx->count = RDELAY_WAITSTAT;
926 timeout((timeout_func_t)mcd_doread,
927 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
928 return;
929 case MCD_S_WAITSTAT:
930 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT);
931 if (mbx->count-- >= 0) {
932 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
933 timeout((timeout_func_t)mcd_doread,
934 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
935 return;
936 }
937 cd->status = inb(port+mcd_status) & 0xFF;
938 if (cd->status & MCD_ST_CMDCHECK)
939 goto retry_status;
934 if (mcd_setflags(unit,cd) < 0)
935 goto changed;
936 MCD_TRACE("got WAITSTAT delay=%d\n",
937 RDELAY_WAITSTAT-mbx->count,0,0,0);
938 /* reject, if audio active */
939 if (cd->status & MCDAUDIOBSY) {
940 printf("mcd%d: audio is active\n",unit);
941 goto readerr;
942 }
940 if (mcd_setflags(unit,cd) < 0)
941 goto changed;
942 MCD_TRACE("got WAITSTAT delay=%d\n",
943 RDELAY_WAITSTAT-mbx->count,0,0,0);
944 /* reject, if audio active */
945 if (cd->status & MCDAUDIOBSY) {
946 printf("mcd%d: audio is active\n",unit);
947 goto readerr;
948 }
943
949retry_mode:
944 /* to check for raw/cooked mode */
945 if (cd->flags & MCDREADRAW) {
946 rm = MCD_MD_RAW;
947 mbx->sz = MCDRBLK;
948 } else {
949 rm = MCD_MD_COOKED;
950 mbx->sz = cd->blksize;
951 }

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

974 printf("mcd%d: timeout set mode\n",unit);
975 goto readerr;
976 }
977 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
978 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100);
979 return;
980 }
981 cd->status = inb(port+mcd_status) & 0xFF;
950 /* to check for raw/cooked mode */
951 if (cd->flags & MCDREADRAW) {
952 rm = MCD_MD_RAW;
953 mbx->sz = MCDRBLK;
954 } else {
955 rm = MCD_MD_COOKED;
956 mbx->sz = cd->blksize;
957 }

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

980 printf("mcd%d: timeout set mode\n",unit);
981 goto readerr;
982 }
983 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
984 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100);
985 return;
986 }
987 cd->status = inb(port+mcd_status) & 0xFF;
988 if (cd->status & MCD_ST_CMDCHECK) {
989 cd->curr_mode = MCD_MD_UNKNOWN;
990 goto retry_mode;
991 }
982 if (mcd_setflags(unit,cd) < 0)
983 goto changed;
984 cd->curr_mode = mbx->mode;
985 MCD_TRACE("got WAITMODE delay=%d\n",
986 RDELAY_WAITMODE-mbx->count,0,0,0);
987modedone:
988 /* for first block */
989 mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz;
990 mbx->skip = 0;
991
992nextblock:
993 blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE))
994 + mbx->p_offset + mbx->skip/mbx->sz;
995
996 MCD_TRACE("mcd_doread: read blknum=%d for bp=0x%x\n",
997 blknum,bp,0,0);
998
999 /* build parameter block */
1000 hsg2msf(blknum,rbuf.start_msf);
992 if (mcd_setflags(unit,cd) < 0)
993 goto changed;
994 cd->curr_mode = mbx->mode;
995 MCD_TRACE("got WAITMODE delay=%d\n",
996 RDELAY_WAITMODE-mbx->count,0,0,0);
997modedone:
998 /* for first block */
999 mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz;
1000 mbx->skip = 0;
1001
1002nextblock:
1003 blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE))
1004 + mbx->p_offset + mbx->skip/mbx->sz;
1005
1006 MCD_TRACE("mcd_doread: read blknum=%d for bp=0x%x\n",
1007 blknum,bp,0,0);
1008
1009 /* build parameter block */
1010 hsg2msf(blknum,rbuf.start_msf);
1001
1011retry_read:
1002 /* send the read command */
1003 disable_intr();
1012 /* send the read command */
1013 disable_intr();
1004 mcd_put(com_port,MCD_CMDREAD2);
1014 mcd_put(com_port,cd->read_command);
1005 mcd_put(com_port,rbuf.start_msf[0]);
1006 mcd_put(com_port,rbuf.start_msf[1]);
1007 mcd_put(com_port,rbuf.start_msf[2]);
1008 mcd_put(com_port,0);
1009 mcd_put(com_port,0);
1010 mcd_put(com_port,1);
1011 enable_intr();
1012

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

1057 biodone(bp);
1058
1059 cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
1060 mcd_start(mbx->unit);
1061 return;
1062 }
1063 if (!(k & MFL_STATUS_NOT_AVAIL)) {
1064 cd->status = inb(port+mcd_status) & 0xFF;
1015 mcd_put(com_port,rbuf.start_msf[0]);
1016 mcd_put(com_port,rbuf.start_msf[1]);
1017 mcd_put(com_port,rbuf.start_msf[2]);
1018 mcd_put(com_port,0);
1019 mcd_put(com_port,0);
1020 mcd_put(com_port,1);
1021 enable_intr();
1022

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

1067 biodone(bp);
1068
1069 cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
1070 mcd_start(mbx->unit);
1071 return;
1072 }
1073 if (!(k & MFL_STATUS_NOT_AVAIL)) {
1074 cd->status = inb(port+mcd_status) & 0xFF;
1075 if (cd->status & MCD_ST_CMDCHECK)
1076 goto retry_read;
1065 if (mcd_setflags(unit,cd) < 0)
1066 goto changed;
1067 }
1068 timeout((timeout_func_t)mcd_doread,
1069 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
1070 return;
1071 } else {
1072 printf("mcd%d: timeout read data\n",unit);

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

1443 struct mcd_data *cd = mcd_data + unit;
1444 int com_port = cd->iobase + mcd_command;
1445 int retry, st = -1, status;
1446
1447 cd->lastpb = *pb;
1448 for(retry=0; retry<MCD_RETRYS; retry++) {
1449
1450 disable_intr();
1077 if (mcd_setflags(unit,cd) < 0)
1078 goto changed;
1079 }
1080 timeout((timeout_func_t)mcd_doread,
1081 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
1082 return;
1083 } else {
1084 printf("mcd%d: timeout read data\n",unit);

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

1455 struct mcd_data *cd = mcd_data + unit;
1456 int com_port = cd->iobase + mcd_command;
1457 int retry, st = -1, status;
1458
1459 cd->lastpb = *pb;
1460 for(retry=0; retry<MCD_RETRYS; retry++) {
1461
1462 disable_intr();
1451 outb(com_port, MCD_CMDREAD2);
1463 outb(com_port, MCD_CMDSINGLESPEEDREAD);
1452 outb(com_port, pb->start_msf[0]);
1453 outb(com_port, pb->start_msf[1]);
1454 outb(com_port, pb->start_msf[2]);
1455 outb(com_port, pb->end_msf[0]);
1456 outb(com_port, pb->end_msf[1]);
1457 outb(com_port, pb->end_msf[2]);
1458 enable_intr();
1459

--- 62 unchanged lines hidden ---
1464 outb(com_port, pb->start_msf[0]);
1465 outb(com_port, pb->start_msf[1]);
1466 outb(com_port, pb->start_msf[2]);
1467 outb(com_port, pb->end_msf[0]);
1468 outb(com_port, pb->end_msf[1]);
1469 outb(com_port, pb->end_msf[2]);
1470 enable_intr();
1471

--- 62 unchanged lines hidden ---