Deleted Added
full compact
mcd.c (5178) mcd.c (5226)
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.33 1994/12/21 15:12:41 ache Exp $
43 * $Id: mcd.c,v 1.34 1994/12/21 15:17:59 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>

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

621
622/* Wait for non-busy - return 0 on timeout */
623static int
624twiddle_thumbs(int port, int unit, int count, char *whine)
625{
626 int i;
627
628 for (i = 0; i < count; i++) {
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>

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

621
622/* Wait for non-busy - return 0 on timeout */
623static int
624twiddle_thumbs(int port, int unit, int count, char *whine)
625{
626 int i;
627
628 for (i = 0; i < count; i++) {
629 if (!(inb(port+MCD_FLAGS) & MCD_ST_BUSY)) {
629 if (!(inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
630 return 1;
631 }
630 return 1;
631 }
632 }
633 printf("mcd%d: timeout %s\n", unit, whine);
634 return 0;
635}
636
637/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */
638
639int
640mcd_probe(struct isa_device *dev)

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

672 outb(port+MCD_DATA, MCD_CMDCONTINFO);
673 for (j = 0; j < 3; j++) {
674 if (!twiddle_thumbs(port, unit, 3000, "getting version info"))
675 return 0;
676 stbytes[j] = (inb(port+MCD_DATA) & 0xFF);
677 }
678 if (stbytes[1] == stbytes[2])
679 return 0;
632 printf("mcd%d: timeout %s\n", unit, whine);
633 return 0;
634}
635
636/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */
637
638int
639mcd_probe(struct isa_device *dev)

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

671 outb(port+MCD_DATA, MCD_CMDCONTINFO);
672 for (j = 0; j < 3; j++) {
673 if (!twiddle_thumbs(port, unit, 3000, "getting version info"))
674 return 0;
675 stbytes[j] = (inb(port+MCD_DATA) & 0xFF);
676 }
677 if (stbytes[1] == stbytes[2])
678 return 0;
680 printf("mcd%d: version information is %c %x\n", unit,
681 stbytes[1], stbytes[2]);
682 if (stbytes[2] >= 4) {
679 if (stbytes[2] >= 4 || stbytes[1] != 'M') {
683 outb(port+MCD_CTRL, M_PICKLE);
684 mcd_data[unit].flags |= MCDNEWMODEL;
680 outb(port+MCD_CTRL, M_PICKLE);
681 mcd_data[unit].flags |= MCDNEWMODEL;
685 printf("mcd%d: Adjusted for newer drive model\n", unit);
686 }
687 switch (stbytes[1]) {
688 case 'M':
689 if (mcd_data[unit].flags & MCDNEWMODEL) {
690 mcd_data[unit].type = MCD_TYPE_LU005S;
691 mcd_data[unit].name = "Mitsumi LU005S";
692 } else {
693 mcd_data[unit].type = MCD_TYPE_LU002S;

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

702 mcd_data[unit].type = MCD_TYPE_FX001D;
703 mcd_data[unit].name = "Mitsumi FX001D";
704 break;
705 default:
706 mcd_data[unit].type = MCD_TYPE_UNKNOWN;
707 mcd_data[unit].name = "Mitsumi ???";
708 break;
709 }
682 }
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;

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

698 mcd_data[unit].type = MCD_TYPE_FX001D;
699 mcd_data[unit].name = "Mitsumi FX001D";
700 break;
701 default:
702 mcd_data[unit].type = MCD_TYPE_UNKNOWN;
703 mcd_data[unit].name = "Mitsumi ???";
704 break;
705 }
710 printf("mcd%d: type %s\n", unit, mcd_data[unit].name);
706 printf("mcd%d: type %s, version info: %c %x\n", unit, mcd_data[unit].name,
707 stbytes[1], stbytes[2]);
708
711 return 4;
712}
713
714
715static int
716mcd_waitrdy(int port,int dly)
717{
718 int i;
719
709 return 4;
710}
711
712
713static int
714mcd_waitrdy(int port,int dly)
715{
716 int i;
717
720 /* wait until xfer port senses data ready */
718 /* wait until flag port senses status ready */
721 for (i=0; i<dly; i+=MIN_DELAY) {
719 for (i=0; i<dly; i+=MIN_DELAY) {
722 if ((inb(port+mcd_xfer) & MCD_ST_BUSY)==0)
720 if (!(inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
723 return 0;
724 DELAY(MIN_DELAY);
725 }
726 return -1;
727}
728
729static int
730mcd_getreply(int unit,int dly)

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

922 outb(com_port, MCD_CMDGETSTAT);
923 mbx->count = RDELAY_WAITSTAT;
924 timeout((timeout_func_t)mcd_doread,
925 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
926 return;
927 case MCD_S_WAITSTAT:
928 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT);
929 if (mbx->count-- >= 0) {
721 return 0;
722 DELAY(MIN_DELAY);
723 }
724 return -1;
725}
726
727static int
728mcd_getreply(int unit,int dly)

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

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) {
930 if (inb(port+mcd_xfer) & MCD_ST_BUSY) {
928 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
931 timeout((timeout_func_t)mcd_doread,
932 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
933 return;
934 }
935 cd->status = inb(port+mcd_status) & 0xFF;
936 if (mcd_setflags(unit,cd) < 0)
937 goto changed;
938 MCD_TRACE("got WAITSTAT delay=%d\n",

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

971 }
972
973 case MCD_S_WAITMODE:
974 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE);
975 if (mbx->count-- < 0) {
976 printf("mcd%d: timeout set mode\n",unit);
977 goto readerr;
978 }
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;
934 if (mcd_setflags(unit,cd) < 0)
935 goto changed;
936 MCD_TRACE("got WAITSTAT delay=%d\n",

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

969 }
970
971 case MCD_S_WAITMODE:
972 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE);
973 if (mbx->count-- < 0) {
974 printf("mcd%d: timeout set mode\n",unit);
975 goto readerr;
976 }
979 if (inb(port+mcd_xfer) & MCD_ST_BUSY) {
977 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
980 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100);
981 return;
982 }
983 cd->status = inb(port+mcd_status) & 0xFF;
984 if (mcd_setflags(unit,cd) < 0)
985 goto changed;
986 cd->curr_mode = mbx->mode;
987 MCD_TRACE("got WAITMODE delay=%d\n",

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

1009 mcd_put(com_port,rbuf.start_msf[2]);
1010 mcd_put(com_port,0);
1011 mcd_put(com_port,0);
1012 mcd_put(com_port,1);
1013 enable_intr();
1014
1015 /* Spin briefly (<= 2ms) to avoid missing next block */
1016 for (i = 0; i < 20; i++) {
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;
982 if (mcd_setflags(unit,cd) < 0)
983 goto changed;
984 cd->curr_mode = mbx->mode;
985 MCD_TRACE("got WAITMODE delay=%d\n",

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

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
1013 /* Spin briefly (<= 2ms) to avoid missing next block */
1014 for (i = 0; i < 20; i++) {
1017 k = inb(port+mcd_xfer);
1018 if (!(k & 2))
1015 k = inb(port+MCD_FLAGS);
1016 if (!(k & MFL_DATA_NOT_AVAIL))
1019 goto got_it;
1020 DELAY(100);
1021 }
1022
1023 mbx->count = RDELAY_WAITREAD;
1024 timeout((timeout_func_t)mcd_doread,
1025 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
1026 return;
1027 case MCD_S_WAITREAD:
1028 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITREAD);
1029 if (mbx->count-- > 0) {
1017 goto got_it;
1018 DELAY(100);
1019 }
1020
1021 mbx->count = RDELAY_WAITREAD;
1022 timeout((timeout_func_t)mcd_doread,
1023 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
1024 return;
1025 case MCD_S_WAITREAD:
1026 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITREAD);
1027 if (mbx->count-- > 0) {
1030 k = inb(port+mcd_xfer);
1031 if (!(k & 2)) { /* XXX */
1028 k = inb(port+MCD_FLAGS);
1029 if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */
1032 MCD_TRACE("got data delay=%d\n",
1033 RDELAY_WAITREAD-mbx->count,0,0,0);
1034 got_it:
1035 /* data is ready */
1036 addr = bp->b_un.b_addr + mbx->skip;
1037
1038 outb(port+mcd_ctl2,0x04); /* XXX */
1039 for (i=0; i<mbx->sz; i++)
1040 *addr++ = inb(data_port);
1041 outb(port+mcd_ctl2,0x0c); /* XXX */
1042
1030 MCD_TRACE("got data delay=%d\n",
1031 RDELAY_WAITREAD-mbx->count,0,0,0);
1032 got_it:
1033 /* data is ready */
1034 addr = bp->b_un.b_addr + mbx->skip;
1035
1036 outb(port+mcd_ctl2,0x04); /* XXX */
1037 for (i=0; i<mbx->sz; i++)
1038 *addr++ = inb(data_port);
1039 outb(port+mcd_ctl2,0x0c); /* XXX */
1040
1043 k = inb(port+mcd_xfer);
1041 k = inb(port+MCD_FLAGS);
1044 /* If we still have some junk, read it too */
1042 /* If we still have some junk, read it too */
1045 if (!(k & 2)) {
1043 if (!(k & MFL_DATA_NOT_AVAIL)) {
1046 outb(port+mcd_ctl2,0x04); /* XXX */
1047 (void)inb(data_port);
1048 (void)inb(data_port);
1049 outb(port+mcd_ctl2,0x0c); /* XXX */
1050 }
1051
1052 if (--mbx->nblk > 0) {
1053 mbx->skip += mbx->sz;
1054 goto nextblock;
1055 }
1056
1057 /* return buffer */
1058 bp->b_resid = 0;
1059 biodone(bp);
1060
1061 cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
1062 mcd_start(mbx->unit);
1063 return;
1064 }
1044 outb(port+mcd_ctl2,0x04); /* XXX */
1045 (void)inb(data_port);
1046 (void)inb(data_port);
1047 outb(port+mcd_ctl2,0x0c); /* XXX */
1048 }
1049
1050 if (--mbx->nblk > 0) {
1051 mbx->skip += mbx->sz;
1052 goto nextblock;
1053 }
1054
1055 /* return buffer */
1056 bp->b_resid = 0;
1057 biodone(bp);
1058
1059 cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
1060 mcd_start(mbx->unit);
1061 return;
1062 }
1065 if (!(k & MCD_ST_BUSY)) {
1063 if (!(k & MFL_STATUS_NOT_AVAIL)) {
1066 cd->status = inb(port+mcd_status) & 0xFF;
1067 if (mcd_setflags(unit,cd) < 0)
1068 goto changed;
1069 }
1070 timeout((timeout_func_t)mcd_doread,
1071 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
1072 return;
1073 } else {

--- 450 unchanged lines hidden ---
1064 cd->status = inb(port+mcd_status) & 0xFF;
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 {

--- 450 unchanged lines hidden ---