Deleted Added
full compact
mcd.c (619) mcd.c (798)
1/*
2 * Copyright 1993 by Holger Veit (data part)
3 * Copyright 1993 by Brian Moore (audio part)
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
31 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
1/*
2 * Copyright 1993 by Holger Veit (data part)
3 * Copyright 1993 by Brian Moore (audio part)
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
31 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * $Id: mcd.c,v 1.1 1993/10/12 06:08:29 rgrimes Exp $
37 * $Id: mcd.c,v 1.2 1993/10/16 13:46:13 rgrimes Exp $
38 */
39static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
40
41#include "mcd.h"
42#if NMCD > 0
43#include "types.h"
44#include "param.h"
45#include "systm.h"

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

136#define MCD_S_BEGIN1 1
137#define MCD_S_WAITSTAT 2
138#define MCD_S_WAITMODE 3
139#define MCD_S_WAITREAD 4
140
141/* prototypes */
142int mcdopen(dev_t dev);
143int mcdclose(dev_t dev);
38 */
39static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
40
41#include "mcd.h"
42#if NMCD > 0
43#include "types.h"
44#include "param.h"
45#include "systm.h"

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

136#define MCD_S_BEGIN1 1
137#define MCD_S_WAITSTAT 2
138#define MCD_S_WAITMODE 3
139#define MCD_S_WAITREAD 4
140
141/* prototypes */
142int mcdopen(dev_t dev);
143int mcdclose(dev_t dev);
144int mcdstrategy(struct buf *bp);
144void mcdstrategy(struct buf *bp);
145int mcdioctl(dev_t dev, int cmd, caddr_t addr, int flags);
146int mcdsize(dev_t dev);
147static void mcd_done(struct mcd_mbx *mbx);
148static void mcd_start(int unit);
149static int mcd_getdisklabel(int unit);
150static void mcd_configure(struct mcd_data *cd);
151static int mcd_get(int unit, char *buf, int nmax);
152static void mcd_setflags(int unit,struct mcd_data *cd);

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

284 /* close channel */
285 cd->partflags[part] &= ~(MCDOPEN|MCDREADRAW);
286 cd->openflags &= ~(1<<part);
287 MCD_TRACE("close: partition=%d\n",part,0,0,0);
288
289 return 0;
290}
291
145int mcdioctl(dev_t dev, int cmd, caddr_t addr, int flags);
146int mcdsize(dev_t dev);
147static void mcd_done(struct mcd_mbx *mbx);
148static void mcd_start(int unit);
149static int mcd_getdisklabel(int unit);
150static void mcd_configure(struct mcd_data *cd);
151static int mcd_get(int unit, char *buf, int nmax);
152static void mcd_setflags(int unit,struct mcd_data *cd);

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

284 /* close channel */
285 cd->partflags[part] &= ~(MCDOPEN|MCDREADRAW);
286 cd->openflags &= ~(1<<part);
287 MCD_TRACE("close: partition=%d\n",part,0,0,0);
288
289 return 0;
290}
291
292int mcdstrategy(struct buf *bp)
292void
293mcdstrategy(struct buf *bp)
293{
294 struct mcd_data *cd;
295 struct buf *qp;
296 int s;
297
298 int unit = mcd_unit(bp->b_dev);
299
300 cd = mcd_data + unit;

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

782 if (cd->volinfo.trk_low != 0 || cd->volinfo.trk_high != 0) {
783 cd->flags |= MCDVOLINFO; /* volinfo is OK */
784 return 0;
785 }
786
787 return -1;
788}
789
294{
295 struct mcd_data *cd;
296 struct buf *qp;
297 int s;
298
299 int unit = mcd_unit(bp->b_dev);
300
301 cd = mcd_data + unit;

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

783 if (cd->volinfo.trk_low != 0 || cd->volinfo.trk_high != 0) {
784 cd->flags |= MCDVOLINFO; /* volinfo is OK */
785 return 0;
786 }
787
788 return -1;
789}
790
790int mcdintr(unit)
791void
792mcdintr(unit)
793 int unit;
791{
792 int port = mcd_data[unit].iobase;
793 u_int i;
794
795 MCD_TRACE("stray interrupt xfer=0x%x\n",inb(port+mcd_xfer),0,0,0);
796
797 /* just read out status and ignore the rest */
798 if ((inb(port+mcd_xfer)&0xFF) != 0xFF) {

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

825 switch (state) {
826 case MCD_S_BEGIN:
827 mbx = mbxsave = mbxin;
828
829 case MCD_S_BEGIN1:
830 /* get status */
831 outb(port+mcd_command, MCD_CMDGETSTAT);
832 mbx->count = RDELAY_WAITSTAT;
794{
795 int port = mcd_data[unit].iobase;
796 u_int i;
797
798 MCD_TRACE("stray interrupt xfer=0x%x\n",inb(port+mcd_xfer),0,0,0);
799
800 /* just read out status and ignore the rest */
801 if ((inb(port+mcd_xfer)&0xFF) != 0xFF) {

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

828 switch (state) {
829 case MCD_S_BEGIN:
830 mbx = mbxsave = mbxin;
831
832 case MCD_S_BEGIN1:
833 /* get status */
834 outb(port+mcd_command, MCD_CMDGETSTAT);
835 mbx->count = RDELAY_WAITSTAT;
833 timeout(mcd_doread,MCD_S_WAITSTAT,hz/100);
836 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
834 return;
835 case MCD_S_WAITSTAT:
836 untimeout(mcd_doread,MCD_S_WAITSTAT);
837 if (mbx->count-- >= 0) {
838 if (inb(port+mcd_xfer) & MCD_ST_BUSY) {
837 return;
838 case MCD_S_WAITSTAT:
839 untimeout(mcd_doread,MCD_S_WAITSTAT);
840 if (mbx->count-- >= 0) {
841 if (inb(port+mcd_xfer) & MCD_ST_BUSY) {
839 timeout(mcd_doread,MCD_S_WAITSTAT,hz/100);
842 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
840 return;
841 }
842 mcd_setflags(unit,cd);
843 MCD_TRACE("got WAITSTAT delay=%d\n",RDELAY_WAITSTAT-mbx->count,0,0,0);
844 /* reject, if audio active */
845 if (cd->status & MCDAUDIOBSY) {
846 printf("mcd%d: audio is active\n",unit);
847 goto readerr;

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

855 rm = MCD_MD_COOKED;
856 mbx->sz = cd->blksize;
857 }
858
859 mbx->count = RDELAY_WAITMODE;
860
861 mcd_put(port+mcd_command, MCD_CMDSETMODE);
862 mcd_put(port+mcd_command, rm);
843 return;
844 }
845 mcd_setflags(unit,cd);
846 MCD_TRACE("got WAITSTAT delay=%d\n",RDELAY_WAITSTAT-mbx->count,0,0,0);
847 /* reject, if audio active */
848 if (cd->status & MCDAUDIOBSY) {
849 printf("mcd%d: audio is active\n",unit);
850 goto readerr;

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

858 rm = MCD_MD_COOKED;
859 mbx->sz = cd->blksize;
860 }
861
862 mbx->count = RDELAY_WAITMODE;
863
864 mcd_put(port+mcd_command, MCD_CMDSETMODE);
865 mcd_put(port+mcd_command, rm);
863 timeout(mcd_doread,MCD_S_WAITMODE,hz/100);
866 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100); /* XXX */
864 return;
865 } else {
866#ifdef MCD_TO_WARNING_ON
867 printf("mcd%d: timeout getstatus\n",unit);
868#endif
869 goto readerr;
870 }
871
872 case MCD_S_WAITMODE:
873 untimeout(mcd_doread,MCD_S_WAITMODE);
874 if (mbx->count-- < 0) {
875#ifdef MCD_TO_WARNING_ON
876 printf("mcd%d: timeout set mode\n",unit);
877#endif
878 goto readerr;
879 }
880 if (inb(port+mcd_xfer) & MCD_ST_BUSY) {
867 return;
868 } else {
869#ifdef MCD_TO_WARNING_ON
870 printf("mcd%d: timeout getstatus\n",unit);
871#endif
872 goto readerr;
873 }
874
875 case MCD_S_WAITMODE:
876 untimeout(mcd_doread,MCD_S_WAITMODE);
877 if (mbx->count-- < 0) {
878#ifdef MCD_TO_WARNING_ON
879 printf("mcd%d: timeout set mode\n",unit);
880#endif
881 goto readerr;
882 }
883 if (inb(port+mcd_xfer) & MCD_ST_BUSY) {
881 timeout(mcd_doread,MCD_S_WAITMODE,hz/100);
884 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100);
882 return;
883 }
884 mcd_setflags(unit,cd);
885 MCD_TRACE("got WAITMODE delay=%d\n",RDELAY_WAITMODE-mbx->count,0,0,0);
886 /* for first block */
887 mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz;
888 mbx->skip = 0;
889

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

900 mcd_put(port+mcd_command,MCD_CMDREAD2);
901 mcd_put(port+mcd_command,rbuf.start_msf[0]);
902 mcd_put(port+mcd_command,rbuf.start_msf[1]);
903 mcd_put(port+mcd_command,rbuf.start_msf[2]);
904 mcd_put(port+mcd_command,0);
905 mcd_put(port+mcd_command,0);
906 mcd_put(port+mcd_command,1);
907 mbx->count = RDELAY_WAITREAD;
885 return;
886 }
887 mcd_setflags(unit,cd);
888 MCD_TRACE("got WAITMODE delay=%d\n",RDELAY_WAITMODE-mbx->count,0,0,0);
889 /* for first block */
890 mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz;
891 mbx->skip = 0;
892

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

903 mcd_put(port+mcd_command,MCD_CMDREAD2);
904 mcd_put(port+mcd_command,rbuf.start_msf[0]);
905 mcd_put(port+mcd_command,rbuf.start_msf[1]);
906 mcd_put(port+mcd_command,rbuf.start_msf[2]);
907 mcd_put(port+mcd_command,0);
908 mcd_put(port+mcd_command,0);
909 mcd_put(port+mcd_command,1);
910 mbx->count = RDELAY_WAITREAD;
908 timeout(mcd_doread,MCD_S_WAITREAD,hz/100);
911 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
909 return;
910 case MCD_S_WAITREAD:
911 untimeout(mcd_doread,MCD_S_WAITREAD);
912 if (mbx->count-- > 0) {
913 k = inb(port+mcd_xfer);
914 if ((k & 2)==0) {
915 MCD_TRACE("got data delay=%d\n",RDELAY_WAITREAD-mbx->count,0,0,0);
916 /* data is ready */

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

930 biodone(bp);
931
932 cd->flags &= ~MCDMBXBSY;
933 mcd_start(mbx->unit);
934 return;
935 }
936 if ((k & 4)==0)
937 mcd_getstat(unit,0);
912 return;
913 case MCD_S_WAITREAD:
914 untimeout(mcd_doread,MCD_S_WAITREAD);
915 if (mbx->count-- > 0) {
916 k = inb(port+mcd_xfer);
917 if ((k & 2)==0) {
918 MCD_TRACE("got data delay=%d\n",RDELAY_WAITREAD-mbx->count,0,0,0);
919 /* data is ready */

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

933 biodone(bp);
934
935 cd->flags &= ~MCDMBXBSY;
936 mcd_start(mbx->unit);
937 return;
938 }
939 if ((k & 4)==0)
940 mcd_getstat(unit,0);
938 timeout(mcd_doread,MCD_S_WAITREAD,hz/100);
941 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
939 return;
940 } else {
941#ifdef MCD_TO_WARNING_ON
942 printf("mcd%d: timeout read data\n",unit);
943#endif
944 goto readerr;
945 }
946 }

--- 314 unchanged lines hidden ---
942 return;
943 } else {
944#ifdef MCD_TO_WARNING_ON
945 printf("mcd%d: timeout read data\n",unit);
946#endif
947 goto readerr;
948 }
949 }

--- 314 unchanged lines hidden ---