aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2016-08-15 20:38:02 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2016-08-15 20:38:02 +0000
commit061ae3c51943536f7349ed1d1c29fe107b0da0aa (patch)
tree86c65b30fdc25208105325e0e903e9b1b6828760
parent79ef07d4c022bfc80f274fd77127cd5b9e7dc32c (diff)
downloadsrc-061ae3c51943536f7349ed1d1c29fe107b0da0aa.tar.gz
src-061ae3c51943536f7349ed1d1c29fe107b0da0aa.zip
Remove the mcd(4) driver for Mitsumi CD-ROM players.
This is a driver for a pre-ATAPI ISA CD-ROM adapter. As noted in the manpage, this driver is only useful as a backend to cdcontrol to play audio CDs since it doesn't use DMA, so its data performance is "abysmal" (and that was true in the mid 90's).
Notes
Notes: svn path=/head/; revision=304187
-rw-r--r--ObsoleteFiles.inc2
-rw-r--r--share/man/man4/Makefile1
-rw-r--r--share/man/man4/mcd.4165
-rw-r--r--sys/conf/NOTES5
-rw-r--r--sys/conf/files2
-rw-r--r--sys/dev/mcd/mcd.c1652
-rw-r--r--sys/dev/mcd/mcd_isa.c202
-rw-r--r--sys/dev/mcd/mcdreg.h219
-rw-r--r--sys/dev/mcd/mcdvar.h71
-rw-r--r--sys/modules/Makefile1
-rw-r--r--sys/modules/mcd/Makefile9
11 files changed, 2 insertions, 2327 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index d5e71e9c6e6b..02a55b608cb1 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,8 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20160815: Remove mcd(4)
+OLD_FILES+=usr/share/man/man4/mcd.4.gz
# 20160703: POSIXify locales with variants
OLD_FILES+=usr/share/locale/zh_Hant_TW.UTF-8/LC_COLLATE
OLD_FILES+=usr/share/locale/zh_Hant_TW.UTF-8/LC_CTYPE
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 1cd099b0b5a4..e85e531aa802 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -269,7 +269,6 @@ MAN= aac.4 \
mac_stub.4 \
mac_test.4 \
malo.4 \
- mcd.4 \
md.4 \
mdio.4 \
me.4 \
diff --git a/share/man/man4/mcd.4 b/share/man/man4/mcd.4
deleted file mode 100644
index 3a79eee41799..000000000000
--- a/share/man/man4/mcd.4
+++ /dev/null
@@ -1,165 +0,0 @@
-.\"
-.\" Copyright (c) 1994 Keith E. Walker
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd December 8, 1994
-.Dt MCD 4
-.Os
-.Sh NAME
-.Nm mcd
-.Nd Mitsumi CD-ROM driver
-.Sh SYNOPSIS
-.Cd "device mcd"
-.Pp
-In
-.Pa /boot/device.hints :
-.Cd hint.mcd.0.at="isa"
-.Cd hint.mcd.0.port="0x300"
-.Cd hint.mcd.0.irq="10"
-.Sh DESCRIPTION
-The
-.Nm
-driver provides a data and audio interface to the Mitsumi-brand CD-ROM
-player.
-The CD-ROM player must be interfaced to the ISA bus through
-one of the Mitsumi proprietary controller boards.
-The controller
-boards supported are the LU002S, LU005S, the FX001 and the quite
-common FX001D.
-.Pp
-The
-.Nm
-driver responds to disk-specific
-.Fn ioctl
-commands, namely the
-.Dv DIOCGPART
-command.
-Other disk-specific
-.Fn ioctl
-commands will return an error.
-.Pp
-The
-.Nm
-driver also responds to special CD-ROM
-.Fn ioctl
-commands.
-These commands
-control the CD-ROM player's audio features.
-The commands are:
-.Pp
-.Bl -tag -width CDIOCREADSUBCHANNEL -compact -offset indent
-.It CDIOCREADSUBCHANNEL
-get sub-channel information on current status of disc playing
-.It CDIOCREADTOCHEADER
-get table of contents header
-.It CDIOCREADTOCENTRYS
-gets all of the table of contents
-.It CDIOCPLAYTRACKS
-begins audio playing at location specified
-.It CDIOCPLAYBLOCKS
-fails with error
-.Er EINVAL
-.It CDIOCPLAYMSF
-begins audio playing at location specified
-.It CDIOCRESUME
-resumes playing a previously paused disc
-.It CDIOCPAUSE
-pauses a playing disc
-.It CDIOCSTART
-begins playing a disc
-.It CDIOCSTOP
-stops a previously playing disc
-.It CDIOCEJECT
-opens the disc tray (there is no support for a corresponding un-eject
-command).
-.It CDIOCRESET
-stops any play and resets the Mitsumi controller board
-.It CDIOCSETDEBUG
-cause the kernel to print debug messages to the console about the
-.Nm
-driver
-.It CDIOCCLRDEBUG
-cause the kernel to quit printing debug messages about the
-.Nm
-driver
-.El
-.Pp
-The
-.Fn ioctl
-commands defined above are the only ones that the
-.Nm
-driver supports.
-There are other CD-ROM related
-.Fn ioctl
-commands (such as
-.Dv CDIOCSETVOL
-and
-.Dv CDIOCSETSTERIO )
-which are available
-and may be supported by future versions of the driver.
-.Sh FILES
-.Bl -tag -width /dev/(r)mcd0a -compact
-.It Pa /dev/(r)mcd0a
-accesses
-.Bx
-partition on the disc.
-Normally, there is only
-one file system on a CD-ROM disc.
-.It Pa /dev/(r)mcd0c
-accesses raw device.
-.El
-.Sh NOTES
-The character-mode devices for the
-.Nm
-driver should only be used for accessing the audio features of the
-CD-ROM player as the performance on data is abysmal.
-.Pp
-The current version of the driver uses neither the DMA or IRQ
-features of the interface board, although it has an interrupt handler
-for any IRQ requests that are generated.
-Until the DMA features are
-supported, the only interrupts that the board generates are those that
-are not supported by the driver anyway.
-.Sh SEE ALSO
-.In sys/cdio.h
-.Sh HISTORY
-An
-.Nm
-driver appeared in
-.Fx 1.0 .
-.Sh AUTHORS
-.An -nosplit
-The driver was written by
-.An Holger Veit
-(data part) and
-.An Brian Moore
-(audio part).
-Changes were provided by
-.An Gary Clark II ,
-.An Andrew A. Chernov ,
-and
-.An Jordan K. Hubbard .
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 9b7d8cd95482..dda8211d44a3 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -2412,15 +2412,10 @@ options SND_OLDSTEREO
# Miscellaneous hardware:
#
# scd: Sony CD-ROM using proprietary (non-ATAPI) interface
-# mcd: Mitsumi CD-ROM using proprietary (non-ATAPI) interface
# bktr: Brooktree bt848/848a/849a/878/879 video capture and TV Tuner board
# joy: joystick (including IO DATA PCJOY PC Card joystick)
# cmx: OmniKey CardMan 4040 pccard smartcard reader
-# Mitsumi CD-ROM
-device mcd
-hint.mcd.0.at="isa"
-hint.mcd.0.port="0x300"
# for the Sony CDU31/33A CDROM
device scd
hint.scd.0.at="isa"
diff --git a/sys/conf/files b/sys/conf/files
index 5da337273bcd..40c5281b3baf 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -2018,8 +2018,6 @@ dev/malo/if_malohal.c optional malo
dev/malo/if_malo_pci.c optional malo pci
dev/mc146818/mc146818.c optional mc146818
dev/mca/mca_bus.c optional mca
-dev/mcd/mcd.c optional mcd isa nowerror
-dev/mcd/mcd_isa.c optional mcd isa nowerror
dev/md/md.c optional md
dev/mdio/mdio_if.m optional miiproxy | mdio
dev/mdio/mdio.c optional miiproxy | mdio
diff --git a/sys/dev/mcd/mcd.c b/sys/dev/mcd/mcd.c
deleted file mode 100644
index dacbb3d3e2f0..000000000000
--- a/sys/dev/mcd/mcd.c
+++ /dev/null
@@ -1,1652 +0,0 @@
-/*-
- * Copyright 1993 by Holger Veit (data part)
- * Copyright 1993 by Brian Moore (audio part)
- * Changes Copyright 1993 by Gary Clark II
- * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia
- *
- * Rewrote probe routine to work on newer Mitsumi drives.
- * Additional changes (C) 1994 by Jordan K. Hubbard
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This software was developed by Holger Veit and Brian Moore
- * for use with "386BSD" and similar operating systems.
- * "Similar operating systems" includes mainly non-profit oriented
- * systems for research and education, including but not restricted to
- * "NetBSD", "FreeBSD", "Mach" (by CMU).
- * 4. Neither the name of the developer(s) nor the name "386BSD"
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-static const char __used COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#include <sys/bio.h>
-#include <sys/cdio.h>
-#include <sys/disk.h>
-#include <sys/bus.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <isa/isavar.h>
-
-#include <dev/mcd/mcdreg.h>
-#include <dev/mcd/mcdvar.h>
-
-#define MCD_TRACE(format, args...) \
-{ \
- if (sc->debug) { \
- device_printf(sc->dev, "status=0x%02x: ", \
- sc->data.status); \
- printf(format, ## args); \
- } \
-}
-
-#define RAW_PART 2
-
-/* flags */
-#define MCDVALID 0x0001 /* parameters loaded */
-#define MCDINIT 0x0002 /* device is init'd */
-#define MCDNEWMODEL 0x0004 /* device is new model */
-#define MCDLABEL 0x0008 /* label is read */
-#define MCDPROBING 0x0010 /* probing */
-#define MCDREADRAW 0x0020 /* read raw mode (2352 bytes) */
-#define MCDVOLINFO 0x0040 /* already read volinfo */
-#define MCDTOC 0x0080 /* already read toc */
-#define MCDMBXBSY 0x0100 /* local mbx is busy */
-
-/* status */
-#define MCDAUDIOBSY MCD_ST_AUDIOBSY /* playing audio */
-#define MCDDSKCHNG MCD_ST_DSKCHNG /* sensed change of disk */
-#define MCDDSKIN MCD_ST_DSKIN /* sensed disk in drive */
-#define MCDDOOROPEN MCD_ST_DOOROPEN /* sensed door open */
-
-/* These are apparently the different states a mitsumi can get up to */
-#define MCDCDABSENT 0x0030
-#define MCDCDPRESENT 0x0020
-#define MCDSCLOSED 0x0080
-#define MCDSOPEN 0x00a0
-
-#define MCD_MD_UNKNOWN (-1)
-
-#define MCD_TYPE_UNKNOWN 0
-#define MCD_TYPE_LU002S 1
-#define MCD_TYPE_LU005S 2
-#define MCD_TYPE_LU006S 3
-#define MCD_TYPE_FX001 4
-#define MCD_TYPE_FX001D 5
-
-/* reader state machine */
-#define MCD_S_BEGIN 0
-#define MCD_S_BEGIN1 1
-#define MCD_S_WAITSTAT 2
-#define MCD_S_WAITMODE 3
-#define MCD_S_WAITREAD 4
-
-/* prototypes */
-static void mcd_start(struct mcd_softc *);
-#ifdef NOTYET
-static void mcd_configure(struct mcd_softc *sc);
-#endif
-static int mcd_get(struct mcd_softc *, char *buf, int nmax);
-static int mcd_setflags(struct mcd_softc *);
-static int mcd_getstat(struct mcd_softc *,int sflg);
-static int mcd_send(struct mcd_softc *, int cmd,int nretrys);
-static void hsg2msf(int hsg, bcd_t *msf);
-static int msf2hsg(bcd_t *msf, int relative);
-static int mcd_volinfo(struct mcd_softc *);
-static int mcd_waitrdy(struct mcd_softc *,int dly);
-static void mcd_timeout(void *arg);
-static void mcd_doread(struct mcd_softc *, int state, struct mcd_mbx *mbxin);
-static void mcd_soft_reset(struct mcd_softc *);
-static int mcd_hard_reset(struct mcd_softc *);
-static int mcd_setmode(struct mcd_softc *, int mode);
-static int mcd_getqchan(struct mcd_softc *, struct mcd_qchninfo *q);
-static int mcd_subchan(struct mcd_softc *, struct ioc_read_subchannel *sc,
- int nocopyout);
-static int mcd_toc_header(struct mcd_softc *, struct ioc_toc_header *th);
-static int mcd_read_toc(struct mcd_softc *);
-static int mcd_toc_entrys(struct mcd_softc *, struct ioc_read_toc_entry *te);
-#if 0
-static int mcd_toc_entry(struct mcd_softc *, struct ioc_read_toc_single_entry *te);
-#endif
-static int mcd_stop(struct mcd_softc *);
-static int mcd_eject(struct mcd_softc *);
-static int mcd_inject(struct mcd_softc *);
-static int mcd_playtracks(struct mcd_softc *, struct ioc_play_track *pt);
-static int mcd_play(struct mcd_softc *, struct mcd_read2 *pb);
-static int mcd_playmsf(struct mcd_softc *, struct ioc_play_msf *pt);
-static int mcd_playblocks(struct mcd_softc *, struct ioc_play_blocks *);
-static int mcd_pause(struct mcd_softc *);
-static int mcd_resume(struct mcd_softc *);
-static int mcd_lock_door(struct mcd_softc *, int lock);
-static int mcd_close_tray(struct mcd_softc *);
-static int mcd_size(struct cdev *dev);
-
-static d_open_t mcdopen;
-static d_close_t mcdclose;
-static d_ioctl_t mcdioctl;
-static d_strategy_t mcdstrategy;
-
-static struct cdevsw mcd_cdevsw = {
- .d_version = D_VERSION,
- .d_open = mcdopen,
- .d_close = mcdclose,
- .d_read = physread,
- .d_ioctl = mcdioctl,
- .d_strategy = mcdstrategy,
- .d_name = "mcd",
- .d_flags = D_DISK,
-};
-
-#define MCD_RETRYS 5
-#define MCD_RDRETRYS 8
-
-#define CLOSE_TRAY_SECS 8
-#define DISK_SENSE_SECS 3
-#define WAIT_FRAC 4
-
-/* several delays */
-#define RDELAY_WAITSTAT 300
-#define RDELAY_WAITMODE 300
-#define RDELAY_WAITREAD 800
-
-#define MIN_DELAY 15
-#define DELAY_GETREPLY 5000000
-
-int
-mcd_attach(struct mcd_softc *sc)
-{
- int unit;
-
- unit = device_get_unit(sc->dev);
-
- MCD_LOCK(sc);
- sc->data.flags |= MCDINIT;
- mcd_soft_reset(sc);
- bioq_init(&sc->data.head);
-
-#ifdef NOTYET
- /* wire controller for interrupts and dma */
- mcd_configure(sc);
-#endif
- MCD_UNLOCK(sc);
- /* name filled in probe */
- sc->mcd_dev_t = make_dev(&mcd_cdevsw, 8 * unit,
- UID_ROOT, GID_OPERATOR, 0640, "mcd%d", unit);
-
- sc->mcd_dev_t->si_drv1 = (void *)sc;
- callout_init_mtx(&sc->timer, &sc->mtx, 0);
-
- return (0);
-}
-
-static int
-mcdopen(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
- struct mcd_softc *sc;
- int r,retry;
-
- sc = (struct mcd_softc *)dev->si_drv1;
-
- /* invalidated in the meantime? mark all open part's invalid */
- MCD_LOCK(sc);
- if (!(sc->data.flags & MCDVALID) && sc->data.openflags) {
- MCD_UNLOCK(sc);
- return (ENXIO);
- }
-
- if (mcd_getstat(sc, 1) == -1) {
- MCD_UNLOCK(sc);
- return (EIO);
- }
-
- if ( (sc->data.status & (MCDDSKCHNG|MCDDOOROPEN))
- || !(sc->data.status & MCDDSKIN))
- for (retry = 0; retry < DISK_SENSE_SECS * WAIT_FRAC; retry++) {
- (void) mtx_sleep(sc, &sc->mtx, PSOCK | PCATCH,
- "mcdsn1", hz/WAIT_FRAC);
- if ((r = mcd_getstat(sc, 1)) == -1) {
- MCD_UNLOCK(sc);
- return (EIO);
- }
- if (r != -2)
- break;
- }
-
- if (sc->data.status & MCDDOOROPEN) {
- MCD_UNLOCK(sc);
- device_printf(sc->dev, "door is open\n");
- return (ENXIO);
- }
- if (!(sc->data.status & MCDDSKIN)) {
- MCD_UNLOCK(sc);
- device_printf(sc->dev, "no CD inside\n");
- return (ENXIO);
- }
- if (sc->data.status & MCDDSKCHNG) {
- MCD_UNLOCK(sc);
- device_printf(sc->dev, "CD not sensed\n");
- return (ENXIO);
- }
-
- if (mcd_size(dev) < 0) {
- MCD_UNLOCK(sc);
- device_printf(sc->dev, "failed to get disk size\n");
- return (ENXIO);
- }
-
- sc->data.openflags = 1;
- sc->data.partflags |= MCDREADRAW;
- sc->data.flags |= MCDVALID;
-
- (void) mcd_lock_door(sc, MCD_LK_LOCK);
- if (!(sc->data.flags & MCDVALID)) {
- MCD_UNLOCK(sc);
- return (ENXIO);
- }
-
- r = mcd_read_toc(sc);
- MCD_UNLOCK(sc);
- return (r);
-}
-
-static int
-mcdclose(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
- struct mcd_softc *sc;
-
- sc = (struct mcd_softc *)dev->si_drv1;
-
- MCD_LOCK(sc);
- KASSERT(sc->data.openflags, ("device not open"));
-
- (void) mcd_lock_door(sc, MCD_LK_UNLOCK);
- sc->data.openflags = 0;
- sc->data.partflags &= ~MCDREADRAW;
- MCD_UNLOCK(sc);
-
- return (0);
-}
-
-static void
-mcdstrategy(struct bio *bp)
-{
- struct mcd_softc *sc;
-
- sc = (struct mcd_softc *)bp->bio_dev->si_drv1;
-
- /* if device invalidated (e.g. media change, door open), error */
- MCD_LOCK(sc);
- if (!(sc->data.flags & MCDVALID)) {
- device_printf(sc->dev, "media changed\n");
- bp->bio_error = EIO;
- goto bad;
- }
-
- /* read only */
- if (!(bp->bio_cmd == BIO_READ)) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
- /* no data to read */
- if (bp->bio_bcount == 0)
- goto done;
-
- if (!(sc->data.flags & MCDTOC)) {
- bp->bio_error = EIO;
- goto bad;
- }
-
- bp->bio_resid = 0;
-
- /* queue it */
- bioq_disksort(&sc->data.head, bp);
-
- /* now check whether we can perform processing */
- mcd_start(sc);
- MCD_UNLOCK(sc);
- return;
-
-bad:
- bp->bio_flags |= BIO_ERROR;
-done:
- MCD_UNLOCK(sc);
- bp->bio_resid = bp->bio_bcount;
- biodone(bp);
- return;
-}
-
-static void
-mcd_start(struct mcd_softc *sc)
-{
- struct bio *bp;
-
- MCD_ASSERT_LOCKED(sc);
- if (sc->data.flags & MCDMBXBSY) {
- return;
- }
-
- bp = bioq_takefirst(&sc->data.head);
- if (bp != 0) {
- /* block found to process, dequeue */
- /*MCD_TRACE("mcd_start: found block bp=0x%x\n",bp,0,0,0);*/
- sc->data.flags |= MCDMBXBSY;
- } else {
- /* nothing to do */
- return;
- }
-
- sc->data.mbx.retry = MCD_RETRYS;
- sc->data.mbx.bp = bp;
-
- mcd_doread(sc, MCD_S_BEGIN,&(sc->data.mbx));
- return;
-}
-
-static int
-mcdioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
-{
- struct mcd_softc *sc;
- int retry,r;
-
- sc = (struct mcd_softc *)dev->si_drv1;
-
- MCD_LOCK(sc);
- if (mcd_getstat(sc, 1) == -1) { /* detect disk change too */
- MCD_UNLOCK(sc);
- return (EIO);
- }
-MCD_TRACE("ioctl called 0x%lx\n", cmd);
-
- switch (cmd) {
- case CDIOCSETPATCH:
- case CDIOCGETVOL:
- case CDIOCSETVOL:
- case CDIOCSETMONO:
- case CDIOCSETSTERIO:
- case CDIOCSETMUTE:
- case CDIOCSETLEFT:
- case CDIOCSETRIGHT:
- MCD_UNLOCK(sc);
- return (EINVAL);
- case CDIOCEJECT:
- r = mcd_eject(sc);
- MCD_UNLOCK(sc);
- return (r);
- case CDIOCSETDEBUG:
- sc->data.debug = 1;
- MCD_UNLOCK(sc);
- return (0);
- case CDIOCCLRDEBUG:
- sc->data.debug = 0;
- MCD_UNLOCK(sc);
- return (0);
- case CDIOCRESET:
- r = mcd_hard_reset(sc);
- MCD_UNLOCK(sc);
- return (r);
- case CDIOCALLOW:
- r = mcd_lock_door(sc, MCD_LK_UNLOCK);
- MCD_UNLOCK(sc);
- return (r);
- case CDIOCPREVENT:
- r = mcd_lock_door(sc, MCD_LK_LOCK);
- MCD_UNLOCK(sc);
- return (r);
- case CDIOCCLOSE:
- r = mcd_inject(sc);
- MCD_UNLOCK(sc);
- return (r);
- }
-
- if (!(sc->data.flags & MCDVALID)) {
- if ( (sc->data.status & (MCDDSKCHNG|MCDDOOROPEN))
- || !(sc->data.status & MCDDSKIN))
- for (retry = 0; retry < DISK_SENSE_SECS * WAIT_FRAC; retry++) {
- (void) mtx_sleep(sc, &sc->mtx, PSOCK | PCATCH,
- "mcdsn2", hz/WAIT_FRAC);
- if ((r = mcd_getstat(sc, 1)) == -1) {
- MCD_UNLOCK(sc);
- return (EIO);
- }
- if (r != -2)
- break;
- }
- if ( (sc->data.status & (MCDDOOROPEN|MCDDSKCHNG))
- || !(sc->data.status & MCDDSKIN)
- || mcd_size(dev) < 0
- ) {
- MCD_UNLOCK(sc);
- return (ENXIO);
- }
- sc->data.flags |= MCDVALID;
- sc->data.partflags |= MCDREADRAW;
- (void) mcd_lock_door(sc, MCD_LK_LOCK);
- if (!(sc->data.flags & MCDVALID)) {
- MCD_UNLOCK(sc);
- return (ENXIO);
- }
- }
-
- switch (cmd) {
- case DIOCGMEDIASIZE:
- *(off_t *)addr = (off_t)sc->data.disksize * sc->data.blksize;
- r = 0;
- break;
- case DIOCGSECTORSIZE:
- *(u_int *)addr = sc->data.blksize;
- r = 0;
- break;
- case CDIOCPLAYTRACKS:
- r = mcd_playtracks(sc, (struct ioc_play_track *) addr);
- break;
- case CDIOCPLAYBLOCKS:
- r = mcd_playblocks(sc, (struct ioc_play_blocks *) addr);
- break;
- case CDIOCPLAYMSF:
- r = mcd_playmsf(sc, (struct ioc_play_msf *) addr);
- break;
- case CDIOCREADSUBCHANNEL_SYSSPACE:
- return mcd_subchan(sc, (struct ioc_read_subchannel *) addr, 1);
- case CDIOCREADSUBCHANNEL:
- return mcd_subchan(sc, (struct ioc_read_subchannel *) addr, 0);
- case CDIOREADTOCHEADER:
- r = mcd_toc_header(sc, (struct ioc_toc_header *) addr);
- break;
- case CDIOREADTOCENTRYS:
- return mcd_toc_entrys(sc, (struct ioc_read_toc_entry *) addr);
- case CDIOCRESUME:
- r = mcd_resume(sc);
- break;
- case CDIOCPAUSE:
- r = mcd_pause(sc);
- break;
- case CDIOCSTART:
- if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
- r = EIO;
- else
- r = 0;
- break;
- case CDIOCSTOP:
- r = mcd_stop(sc);
- break;
- default:
- r = ENOTTY;
- }
- MCD_UNLOCK(sc);
- return (r);
-}
-
-static int
-mcd_size(struct cdev *dev)
-{
- struct mcd_softc *sc;
- int size;
-
- sc = (struct mcd_softc *)dev->si_drv1;
-
- if (mcd_volinfo(sc) == 0) {
- sc->data.blksize = MCDBLK;
- size = msf2hsg(sc->data.volinfo.vol_msf, 0);
- sc->data.disksize = size * (MCDBLK/DEV_BSIZE);
- return (0);
- }
- return (-1);
-}
-
-/***************************************************************
- * lower level of driver starts here
- **************************************************************/
-
-#ifdef NOTDEF
-static char
-irqs[] = {
- 0x00,0x00,0x10,0x20,0x00,0x30,0x00,0x00,
- 0x00,0x10,0x40,0x50,0x00,0x00,0x00,0x00
-};
-
-static char
-drqs[] = {
- 0x00,0x01,0x00,0x03,0x00,0x05,0x06,0x07,
-};
-#endif
-
-#ifdef NOT_YET
-static void
-mcd_configure(struct mcd_softc *sc)
-{
- MCD_WRITE(sc, MCD_REG_CONFIG, sc->data.config);
-}
-#endif
-
-/* Wait for non-busy - return 0 on timeout */
-static int
-twiddle_thumbs(struct mcd_softc *sc, int count, char *whine)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- if (!(MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
- return (1);
- }
- if (bootverbose)
- device_printf(sc->dev, "timeout %s\n", whine);
- return (0);
-}
-
-/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */
-
-int
-mcd_probe(struct mcd_softc *sc)
-{
- int i, j;
- unsigned char stbytes[3];
-
- sc->data.flags = MCDPROBING;
-
-#ifdef NOTDEF
- /* get irq/drq configuration word */
- sc->data.config = irqs[dev->id_irq]; /* | drqs[dev->id_drq];*/
-#else
- sc->data.config = 0;
-#endif
-
- /* send a reset */
- MCD_WRITE(sc, MCD_FLAGS, M_RESET);
-
- /*
- * delay awhile by getting any pending garbage (old data) and
- * throwing it away.
- */
- for (i = 1000000; i != 0; i--)
- (void)MCD_READ(sc, MCD_FLAGS);
-
- /* Get status */
- MCD_WRITE(sc, MCD_DATA, MCD_CMDGETSTAT);
- if (!twiddle_thumbs(sc, 1000000, "getting status"))
- return (ENXIO); /* Timeout */
- /* Get version information */
- MCD_WRITE(sc, MCD_DATA, MCD_CMDCONTINFO);
- for (j = 0; j < 3; j++) {
- if (!twiddle_thumbs(sc, 3000, "getting version info"))
- return (ENXIO);
- stbytes[j] = (MCD_READ(sc, MCD_DATA) & 0xFF);
- }
- if (stbytes[1] == stbytes[2])
- return (ENXIO);
- if (stbytes[2] >= 4 || stbytes[1] != 'M') {
- MCD_WRITE(sc, MCD_CTRL, M_PICKLE);
- sc->data.flags |= MCDNEWMODEL;
- }
- sc->data.read_command = MCD_CMDSINGLESPEEDREAD;
- switch (stbytes[1]) {
- case 'M':
- if (stbytes[2] <= 2) {
- sc->data.type = MCD_TYPE_LU002S;
- sc->data.name = "Mitsumi LU002S";
- } else if (stbytes[2] <= 5) {
- sc->data.type = MCD_TYPE_LU005S;
- sc->data.name = "Mitsumi LU005S";
- } else {
- sc->data.type = MCD_TYPE_LU006S;
- sc->data.name = "Mitsumi LU006S";
- }
- break;
- case 'F':
- sc->data.type = MCD_TYPE_FX001;
- sc->data.name = "Mitsumi FX001";
- break;
- case 'D':
- sc->data.type = MCD_TYPE_FX001D;
- sc->data.name = "Mitsumi FX001D";
- sc->data.read_command = MCD_CMDDOUBLESPEEDREAD;
- break;
- default:
- sc->data.type = MCD_TYPE_UNKNOWN;
- sc->data.name = "Mitsumi ???";
- break;
- }
-
- if (bootverbose)
- device_printf(sc->dev, "type %s, version info: %c %x\n",
- sc->data.name, stbytes[1], stbytes[2]);
-
- return (0);
-}
-
-
-static int
-mcd_waitrdy(struct mcd_softc *sc, int dly)
-{
- int i;
-
- /* wait until flag port senses status ready */
- for (i=0; i<dly; i+=MIN_DELAY) {
- if (!(MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
- return (0);
- DELAY(MIN_DELAY);
- }
- return (-1);
-}
-
-static int
-mcd_getreply(struct mcd_softc *sc, int dly)
-{
-
- /* wait data to become ready */
- if (mcd_waitrdy(sc, dly)<0) {
- device_printf(sc->dev, "timeout getreply\n");
- return (-1);
- }
-
- /* get the data */
- return (MCD_READ(sc, MCD_REG_STATUS) & 0xFF);
-}
-
-static int
-mcd_getstat(struct mcd_softc *sc, int sflg)
-{
- int i;
-
- /* get the status */
- if (sflg)
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDGETSTAT);
- i = mcd_getreply(sc, DELAY_GETREPLY);
- if (i<0 || (i & MCD_ST_CMDCHECK)) {
- sc->data.curr_mode = MCD_MD_UNKNOWN;
- return (-1);
- }
-
- sc->data.status = i;
-
- if (mcd_setflags(sc) < 0)
- return (-2);
- return (sc->data.status);
-}
-
-static int
-mcd_setflags(struct mcd_softc *sc)
-{
-
- /* check flags */
- if ( (sc->data.status & (MCDDSKCHNG|MCDDOOROPEN))
- || !(sc->data.status & MCDDSKIN)) {
- MCD_TRACE("setflags: sensed DSKCHNG or DOOROPEN or !DSKIN\n");
- mcd_soft_reset(sc);
- return (-1);
- }
-
- if (sc->data.status & MCDAUDIOBSY)
- sc->data.audio_status = CD_AS_PLAY_IN_PROGRESS;
- else if (sc->data.audio_status == CD_AS_PLAY_IN_PROGRESS)
- sc->data.audio_status = CD_AS_PLAY_COMPLETED;
- return (0);
-}
-
-static int
-mcd_get(struct mcd_softc *sc, char *buf, int nmax)
-{
- int i,k;
-
- for (i=0; i<nmax; i++) {
- /* wait for data */
- if ((k = mcd_getreply(sc, DELAY_GETREPLY)) < 0) {
- device_printf(sc->dev, "timeout mcd_get\n");
- return (-1);
- }
- buf[i] = k;
- }
- return (i);
-}
-
-static int
-mcd_send(struct mcd_softc *sc, int cmd,int nretrys)
-{
- int i,k=0;
-
-/*MCD_TRACE("mcd_send: command = 0x%02x\n",cmd,0,0,0);*/
- for (i=0; i<nretrys; i++) {
- MCD_WRITE(sc, MCD_REG_COMMAND, cmd);
- if ((k=mcd_getstat(sc, 0)) != -1)
- break;
- }
- if (k == -2) {
- device_printf(sc->dev, "media changed\n");
- return (-1);
- }
- if (i == nretrys) {
- device_printf(sc->dev, "mcd_send retry cnt exceeded\n");
- return (-1);
- }
-/*MCD_TRACE("mcd_send: done\n",0,0,0,0);*/
- return (0);
-}
-
-static void
-hsg2msf(int hsg, bcd_t *msf)
-{
- hsg += 150;
- F_msf(msf) = bin2bcd(hsg % 75);
- hsg /= 75;
- S_msf(msf) = bin2bcd(hsg % 60);
- hsg /= 60;
- M_msf(msf) = bin2bcd(hsg);
-}
-
-static int
-msf2hsg(bcd_t *msf, int relative)
-{
- return (bcd2bin(M_msf(msf)) * 60 + bcd2bin(S_msf(msf))) * 75 +
- bcd2bin(F_msf(msf)) - (!relative) * 150;
-}
-
-static int
-mcd_volinfo(struct mcd_softc *sc)
-{
-
- /* Just return if we already have it */
- if (sc->data.flags & MCDVOLINFO) return (0);
-
-/*MCD_TRACE("mcd_volinfo: enter\n",0,0,0,0);*/
-
- /* send volume info command */
- if (mcd_send(sc, MCD_CMDGETVOLINFO,MCD_RETRYS) < 0)
- return (EIO);
-
- /* get data */
- if (mcd_get(sc, (char*) &sc->data.volinfo,sizeof(struct mcd_volinfo)) < 0) {
- device_printf(sc->dev, "mcd_volinfo: error read data\n");
- return (EIO);
- }
-
- if (sc->data.volinfo.trk_low > 0 &&
- sc->data.volinfo.trk_high >= sc->data.volinfo.trk_low
- ) {
- sc->data.flags |= MCDVOLINFO; /* volinfo is OK */
- return (0);
- }
-
- return (EINVAL);
-}
-
-/* state machine to process read requests
- * initialize with MCD_S_BEGIN: calculate sizes, and read status
- * MCD_S_WAITSTAT: wait for status reply, set mode
- * MCD_S_WAITMODE: waits for status reply from set mode, set read command
- * MCD_S_WAITREAD: wait for read ready, read data
- */
-static void
-mcd_timeout(void *arg)
-{
- struct mcd_softc *sc;
-
- sc = (struct mcd_softc *)arg;
-
- MCD_ASSERT_LOCKED(sc);
- mcd_doread(sc, sc->ch_state, sc->ch_mbxsave);
-}
-
-static void
-mcd_doread(struct mcd_softc *sc, int state, struct mcd_mbx *mbxin)
-{
- struct mcd_mbx *mbx;
- struct bio *bp;
- int rm, i, k;
- struct mcd_read2 rbuf;
- int blknum;
- caddr_t addr;
-
- MCD_ASSERT_LOCKED(sc);
- mbx = (state!=MCD_S_BEGIN) ? sc->ch_mbxsave : mbxin;
- bp = mbx->bp;
-
-loop:
- switch (state) {
- case MCD_S_BEGIN:
- mbx = sc->ch_mbxsave = mbxin;
-
- case MCD_S_BEGIN1:
-retry_status:
- /* get status */
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDGETSTAT);
- mbx->count = RDELAY_WAITSTAT;
- sc->ch_state = MCD_S_WAITSTAT;
- callout_reset(&sc->timer, hz/100, mcd_timeout, sc); /* XXX */
- return;
- case MCD_S_WAITSTAT:
- sc->ch_state = MCD_S_WAITSTAT;
- callout_stop(&sc->timer);
- if (mbx->count-- >= 0) {
- if (MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
- sc->ch_state = MCD_S_WAITSTAT;
- callout_reset(&sc->timer, hz/100,
- mcd_timeout, sc); /* XXX */
- return;
- }
- sc->data.status = MCD_READ(sc, MCD_REG_STATUS) & 0xFF;
- if (sc->data.status & MCD_ST_CMDCHECK)
- goto retry_status;
- if (mcd_setflags(sc) < 0)
- goto changed;
- MCD_TRACE("got WAITSTAT delay=%d\n",
- RDELAY_WAITSTAT-mbx->count);
- /* reject, if audio active */
- if (sc->data.status & MCDAUDIOBSY) {
- device_printf(sc->dev, "audio is active\n");
- goto readerr;
- }
-
-retry_mode:
- /* to check for raw/cooked mode */
- if (sc->data.flags & MCDREADRAW) {
- rm = MCD_MD_RAW;
- mbx->sz = MCDRBLK;
- } else {
- rm = MCD_MD_COOKED;
- mbx->sz = sc->data.blksize;
- }
-
- if (rm == sc->data.curr_mode)
- goto modedone;
-
- mbx->count = RDELAY_WAITMODE;
-
- sc->data.curr_mode = MCD_MD_UNKNOWN;
- mbx->mode = rm;
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDSETMODE);
- MCD_WRITE(sc, MCD_REG_COMMAND, rm);
-
- sc->ch_state = MCD_S_WAITMODE;
- callout_reset(&sc->timer, hz / 100, mcd_timeout, sc); /* XXX */
- return;
- } else {
- device_printf(sc->dev, "timeout getstatus\n");
- goto readerr;
- }
-
- case MCD_S_WAITMODE:
- sc->ch_state = MCD_S_WAITMODE;
- callout_stop(&sc->timer);
- if (mbx->count-- < 0) {
- device_printf(sc->dev, "timeout set mode\n");
- goto readerr;
- }
- if (MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
- sc->ch_state = MCD_S_WAITMODE;
- callout_reset(&sc->timer, hz / 100, mcd_timeout, sc);
- return;
- }
- sc->data.status = MCD_READ(sc, MCD_REG_STATUS) & 0xFF;
- if (sc->data.status & MCD_ST_CMDCHECK) {
- sc->data.curr_mode = MCD_MD_UNKNOWN;
- goto retry_mode;
- }
- if (mcd_setflags(sc) < 0)
- goto changed;
- sc->data.curr_mode = mbx->mode;
- MCD_TRACE("got WAITMODE delay=%d\n",
- RDELAY_WAITMODE-mbx->count);
-modedone:
- /* for first block */
- mbx->nblk = howmany(bp->bio_bcount, mbx->sz);
- mbx->skip = 0;
-
-nextblock:
- blknum = bp->bio_offset / mbx->sz + mbx->skip/mbx->sz;
-
- MCD_TRACE("mcd_doread: read blknum=%d for bp=%p\n",
- blknum, bp);
-
- /* build parameter block */
- hsg2msf(blknum,rbuf.start_msf);
-retry_read:
- /* send the read command */
- MCD_WRITE(sc, MCD_REG_COMMAND, sc->data.read_command);
- MCD_WRITE(sc, MCD_REG_COMMAND, rbuf.start_msf[0]);
- MCD_WRITE(sc, MCD_REG_COMMAND, rbuf.start_msf[1]);
- MCD_WRITE(sc, MCD_REG_COMMAND, rbuf.start_msf[2]);
- MCD_WRITE(sc, MCD_REG_COMMAND, 0);
- MCD_WRITE(sc, MCD_REG_COMMAND, 0);
- MCD_WRITE(sc, MCD_REG_COMMAND, 1);
-
- /* Spin briefly (<= 2ms) to avoid missing next block */
- for (i = 0; i < 20; i++) {
- k = MCD_READ(sc, MCD_FLAGS);
- if (!(k & MFL_DATA_NOT_AVAIL))
- goto got_it;
- DELAY(100);
- }
-
- mbx->count = RDELAY_WAITREAD;
- sc->ch_state = MCD_S_WAITREAD;
- callout_reset(&sc->timer, hz / 100, mcd_timeout, sc); /* XXX */
- return;
- case MCD_S_WAITREAD:
- sc->ch_state = MCD_S_WAITREAD;
- callout_stop(&sc->timer);
- if (mbx->count-- > 0) {
- k = MCD_READ(sc, MCD_FLAGS);
- if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */
- MCD_TRACE("got data delay=%d\n",
- RDELAY_WAITREAD-mbx->count);
- got_it:
- /* data is ready */
- addr = bp->bio_data + mbx->skip;
-
- MCD_WRITE(sc, MCD_REG_CTL2,0x04); /* XXX */
- for (i=0; i<mbx->sz; i++)
- *addr++ = MCD_READ(sc, MCD_REG_RDATA);
- MCD_WRITE(sc, MCD_REG_CTL2,0x0c); /* XXX */
-
- k = MCD_READ(sc, MCD_FLAGS);
- /* If we still have some junk, read it too */
- if (!(k & MFL_DATA_NOT_AVAIL)) {
- MCD_WRITE(sc, MCD_REG_CTL2, 0x04); /* XXX */
- (void)MCD_READ(sc, MCD_REG_RDATA);
- (void)MCD_READ(sc, MCD_REG_RDATA);
- MCD_WRITE(sc, MCD_REG_CTL2, 0x0c); /* XXX */
- }
-
- if (--mbx->nblk > 0) {
- mbx->skip += mbx->sz;
- goto nextblock;
- }
-
- /* return buffer */
- bp->bio_resid = 0;
- biodone(bp);
-
- sc->data.flags &= ~(MCDMBXBSY|MCDREADRAW);
- mcd_start(sc);
- return;
- }
- if (!(k & MFL_STATUS_NOT_AVAIL)) {
- sc->data.status = MCD_READ(sc, MCD_REG_STATUS) & 0xFF;
- if (sc->data.status & MCD_ST_CMDCHECK)
- goto retry_read;
- if (mcd_setflags(sc) < 0)
- goto changed;
- }
- sc->ch_state = MCD_S_WAITREAD;
- callout_reset(&sc->timer, hz / 100, mcd_timeout, sc); /* XXX */
- return;
- } else {
- device_printf(sc->dev, "timeout read data\n");
- goto readerr;
- }
- }
-
-readerr:
- if (mbx->retry-- > 0) {
- device_printf(sc->dev, "retrying\n");
- state = MCD_S_BEGIN1;
- goto loop;
- }
-harderr:
- /* invalidate the buffer */
- bp->bio_flags |= BIO_ERROR;
- bp->bio_resid = bp->bio_bcount;
- biodone(bp);
-
- sc->data.flags &= ~(MCDMBXBSY|MCDREADRAW);
- mcd_start(sc);
- return;
-
-changed:
- device_printf(sc->dev, "media changed\n");
- goto harderr;
-
-#ifdef NOTDEF
- device_printf(sc->dev, "unit timeout, resetting\n");
- MCD_WRITE(sc, MCD_REG_RESET, MCD_CMDRESET);
- DELAY(300000);
- (void)mcd_getstat(sc, 1);
- (void)mcd_getstat(sc, 1);
- /*sc->data.status &= ~MCDDSKCHNG; */
- sc->data.debug = 1; /* preventive set debug mode */
-
-#endif
-
-}
-
-static int
-mcd_lock_door(struct mcd_softc *sc, int lock)
-{
-
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDLOCKDRV);
- MCD_WRITE(sc, MCD_REG_COMMAND, lock);
- if (mcd_getstat(sc, 0) == -1)
- return (EIO);
- return (0);
-}
-
-static int
-mcd_close_tray(struct mcd_softc *sc)
-{
- int retry, r;
-
- if (mcd_getstat(sc, 1) == -1)
- return (EIO);
- if (sc->data.status & MCDDOOROPEN) {
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDCLOSETRAY);
- for (retry = 0; retry < CLOSE_TRAY_SECS * WAIT_FRAC; retry++) {
- if (MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL)
- (void) mtx_sleep(sc, &sc->mtx, PSOCK | PCATCH,
- "mcdcls", hz/WAIT_FRAC);
- else {
- if ((r = mcd_getstat(sc, 0)) == -1)
- return (EIO);
- return (0);
- }
- }
- return (ENXIO);
- }
- return (0);
-}
-
-static int
-mcd_eject(struct mcd_softc *sc)
-{
- int r;
-
- if (mcd_getstat(sc, 1) == -1) /* detect disk change too */
- return (EIO);
- if (sc->data.status & MCDDOOROPEN)
- return (0);
- if ((r = mcd_stop(sc)) == EIO)
- return (r);
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDEJECTDISK);
- if (mcd_getstat(sc, 0) == -1)
- return (EIO);
- return (0);
-}
-
-static int
-mcd_inject(struct mcd_softc *sc)
-{
-
- if (mcd_getstat(sc, 1) == -1) /* detect disk change too */
- return (EIO);
- if (sc->data.status & MCDDOOROPEN)
- return mcd_close_tray(sc);
- return (0);
-}
-
-static int
-mcd_hard_reset(struct mcd_softc *sc)
-{
-
- MCD_WRITE(sc, MCD_REG_RESET, MCD_CMDRESET);
- sc->data.curr_mode = MCD_MD_UNKNOWN;
- sc->data.audio_status = CD_AS_AUDIO_INVALID;
- return (0);
-}
-
-static void
-mcd_soft_reset(struct mcd_softc *sc)
-{
-
- sc->data.flags &= (MCDINIT|MCDPROBING|MCDNEWMODEL);
- sc->data.curr_mode = MCD_MD_UNKNOWN;
- sc->data.partflags = 0;
- sc->data.audio_status = CD_AS_AUDIO_INVALID;
-}
-
-static int
-mcd_setmode(struct mcd_softc *sc, int mode)
-{
- int retry, st;
-
- if (sc->data.curr_mode == mode)
- return (0);
- if (sc->data.debug)
- device_printf(sc->dev, "setting mode to %d\n", mode);
- for(retry=0; retry<MCD_RETRYS; retry++)
- {
- sc->data.curr_mode = MCD_MD_UNKNOWN;
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDSETMODE);
- MCD_WRITE(sc, MCD_REG_COMMAND, mode);
- if ((st = mcd_getstat(sc, 0)) >= 0) {
- sc->data.curr_mode = mode;
- return (0);
- }
- if (st == -2) {
- device_printf(sc->dev, "media changed\n");
- break;
- }
- }
-
- return (-1);
-}
-
-static int
-mcd_toc_header(struct mcd_softc *sc, struct ioc_toc_header *th)
-{
- int r;
-
- if ((r = mcd_volinfo(sc)) != 0)
- return (r);
-
- th->starting_track = bcd2bin(sc->data.volinfo.trk_low);
- th->ending_track = bcd2bin(sc->data.volinfo.trk_high);
- th->len = 2 * sizeof(u_char) /* start & end tracks */ +
- (th->ending_track + 1 - th->starting_track + 1) *
- sizeof(struct cd_toc_entry);
-
- return (0);
-}
-
-static int
-mcd_read_toc(struct mcd_softc *sc)
-{
- struct ioc_toc_header th;
- struct mcd_qchninfo q;
- int rc, trk, idx, retry;
-
- /* Only read TOC if needed */
- if (sc->data.flags & MCDTOC)
- return (0);
-
- if (sc->data.debug)
- device_printf(sc->dev, "reading toc header\n");
-
- if ((rc = mcd_toc_header(sc, &th)) != 0)
- return (rc);
-
- if (mcd_send(sc, MCD_CMDSTOPAUDIO, MCD_RETRYS) < 0)
- return (EIO);
-
- if (mcd_setmode(sc, MCD_MD_TOC) != 0)
- return (EIO);
-
- if (sc->data.debug)
- device_printf(sc->dev, "get_toc reading qchannel info\n");
-
- for(trk=th.starting_track; trk<=th.ending_track; trk++)
- sc->data.toc[trk].idx_no = 0;
- trk = th.ending_track - th.starting_track + 1;
- for(retry=0; retry<600 && trk>0; retry++)
- {
- if (mcd_getqchan(sc, &q) < 0) break;
- idx = bcd2bin(q.idx_no);
- if (idx>=th.starting_track && idx<=th.ending_track && q.trk_no==0) {
- if (sc->data.toc[idx].idx_no == 0) {
- sc->data.toc[idx] = q;
- trk--;
- }
- }
- }
-
- if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
- return (EIO);
-
- if (trk != 0)
- return (ENXIO);
-
- /* add a fake last+1 */
- idx = th.ending_track + 1;
- sc->data.toc[idx].control = sc->data.toc[idx-1].control;
- sc->data.toc[idx].addr_type = sc->data.toc[idx-1].addr_type;
- sc->data.toc[idx].trk_no = 0;
- sc->data.toc[idx].idx_no = MCD_LASTPLUS1;
- sc->data.toc[idx].hd_pos_msf[0] = sc->data.volinfo.vol_msf[0];
- sc->data.toc[idx].hd_pos_msf[1] = sc->data.volinfo.vol_msf[1];
- sc->data.toc[idx].hd_pos_msf[2] = sc->data.volinfo.vol_msf[2];
-
- if (sc->data.debug)
- { int i;
- for (i = th.starting_track; i <= idx; i++)
- device_printf(sc->dev, "trk %d idx %d pos %d %d %d\n",
- i,
- sc->data.toc[i].idx_no > 0x99 ? sc->data.toc[i].idx_no :
- bcd2bin(sc->data.toc[i].idx_no),
- bcd2bin(sc->data.toc[i].hd_pos_msf[0]),
- bcd2bin(sc->data.toc[i].hd_pos_msf[1]),
- bcd2bin(sc->data.toc[i].hd_pos_msf[2]));
- }
-
- sc->data.flags |= MCDTOC;
-
- return (0);
-}
-
-#if 0
-static int
-mcd_toc_entry(struct mcd_softc *sc, struct ioc_read_toc_single_entry *te)
-{
- struct ioc_toc_header th;
- int rc, trk;
-
- if (te->address_format != CD_MSF_FORMAT
- && te->address_format != CD_LBA_FORMAT)
- return (EINVAL);
-
- /* Copy the toc header */
- if ((rc = mcd_toc_header(sc, &th)) != 0)
- return (rc);
-
- /* verify starting track */
- trk = te->track;
- if (trk == 0)
- trk = th.starting_track;
- else if (trk == MCD_LASTPLUS1)
- trk = th.ending_track + 1;
- else if (trk < th.starting_track || trk > th.ending_track + 1)
- return (EINVAL);
-
- /* Make sure we have a valid toc */
- if ((rc=mcd_read_toc(sc)) != 0)
- return (rc);
-
- /* Copy the TOC data. */
- if (sc->data.toc[trk].idx_no == 0)
- return (EIO);
-
- te->entry.control = sc->data.toc[trk].control;
- te->entry.addr_type = sc->data.toc[trk].addr_type;
- te->entry.track =
- sc->data.toc[trk].idx_no > 0x99 ? sc->data.toc[trk].idx_no :
- bcd2bin(sc->data.toc[trk].idx_no);
- switch (te->address_format) {
- case CD_MSF_FORMAT:
- te->entry.addr.msf.unused = 0;
- te->entry.addr.msf.minute = bcd2bin(sc->data.toc[trk].hd_pos_msf[0]);
- te->entry.addr.msf.second = bcd2bin(sc->data.toc[trk].hd_pos_msf[1]);
- te->entry.addr.msf.frame = bcd2bin(sc->data.toc[trk].hd_pos_msf[2]);
- break;
- case CD_LBA_FORMAT:
- te->entry.addr.lba = htonl(msf2hsg(sc->data.toc[trk].hd_pos_msf, 0));
- break;
- }
- return (0);
-}
-#endif
-
-static int
-mcd_toc_entrys(struct mcd_softc *sc, struct ioc_read_toc_entry *te)
-{
- struct cd_toc_entry entries[MCD_MAXTOCS];
- struct ioc_toc_header th;
- int rc, n, trk, len;
-
- if ( te->data_len < sizeof(entries[0])
- || (te->data_len % sizeof(entries[0])) != 0
- || (te->address_format != CD_MSF_FORMAT
- && te->address_format != CD_LBA_FORMAT)
- )
- return (EINVAL);
-
- /* Copy the toc header */
- if ((rc = mcd_toc_header(sc, &th)) != 0)
- return (rc);
-
- /* verify starting track */
- trk = te->starting_track;
- if (trk == 0)
- trk = th.starting_track;
- else if (trk == MCD_LASTPLUS1)
- trk = th.ending_track + 1;
- else if (trk < th.starting_track || trk > th.ending_track + 1)
- return (EINVAL);
-
- len = ((th.ending_track + 1 - trk) + 1) *
- sizeof(entries[0]);
- if (te->data_len < len)
- len = te->data_len;
- if (len > sizeof(entries))
- return (EINVAL);
-
- /* Make sure we have a valid toc */
- if ((rc=mcd_read_toc(sc)) != 0)
- return (rc);
-
- /* Copy the TOC data. */
- for (n = 0; len > 0 && trk <= th.ending_track + 1; trk++) {
- if (sc->data.toc[trk].idx_no == 0)
- continue;
- entries[n].control = sc->data.toc[trk].control;
- entries[n].addr_type = sc->data.toc[trk].addr_type;
- entries[n].track =
- sc->data.toc[trk].idx_no > 0x99 ? sc->data.toc[trk].idx_no :
- bcd2bin(sc->data.toc[trk].idx_no);
- switch (te->address_format) {
- case CD_MSF_FORMAT:
- entries[n].addr.msf.unused = 0;
- entries[n].addr.msf.minute = bcd2bin(sc->data.toc[trk].hd_pos_msf[0]);
- entries[n].addr.msf.second = bcd2bin(sc->data.toc[trk].hd_pos_msf[1]);
- entries[n].addr.msf.frame = bcd2bin(sc->data.toc[trk].hd_pos_msf[2]);
- break;
- case CD_LBA_FORMAT:
- entries[n].addr.lba = htonl(msf2hsg(sc->data.toc[trk].hd_pos_msf, 0));
- break;
- }
- len -= sizeof(struct cd_toc_entry);
- n++;
- }
-
- /* copy the data back */
- MCD_UNLOCK(sc);
- return copyout(entries, te->data, n * sizeof(struct cd_toc_entry));
-}
-
-static int
-mcd_stop(struct mcd_softc *sc)
-{
-
- /* Verify current status */
- if (sc->data.audio_status != CD_AS_PLAY_IN_PROGRESS &&
- sc->data.audio_status != CD_AS_PLAY_PAUSED &&
- sc->data.audio_status != CD_AS_PLAY_COMPLETED) {
- if (sc->data.debug)
- device_printf(sc->dev,
- "stop attempted when not playing, audio status %d\n",
- sc->data.audio_status);
- return (EINVAL);
- }
- if (sc->data.audio_status == CD_AS_PLAY_IN_PROGRESS)
- if (mcd_send(sc, MCD_CMDSTOPAUDIO, MCD_RETRYS) < 0)
- return (EIO);
- sc->data.audio_status = CD_AS_PLAY_COMPLETED;
- return (0);
-}
-
-static int
-mcd_getqchan(struct mcd_softc *sc, struct mcd_qchninfo *q)
-{
-
- if (mcd_send(sc, MCD_CMDGETQCHN, MCD_RETRYS) < 0)
- return (-1);
- if (mcd_get(sc, (char *) q, sizeof(struct mcd_qchninfo)) < 0)
- return (-1);
- if (sc->data.debug) {
- device_printf(sc->dev,
- "getqchan control=0x%x addr_type=0x%x trk=%d ind=%d ttm=%d:%d.%d dtm=%d:%d.%d\n",
- q->control, q->addr_type,
- bcd2bin(q->trk_no),
- bcd2bin(q->idx_no),
- bcd2bin(q->trk_size_msf[0]),
- bcd2bin(q->trk_size_msf[1]),
- bcd2bin(q->trk_size_msf[2]),
- bcd2bin(q->hd_pos_msf[0]),
- bcd2bin(q->hd_pos_msf[1]),
- bcd2bin(q->hd_pos_msf[2]));
- }
- return (0);
-}
-
-static int
-mcd_subchan(struct mcd_softc *sc, struct ioc_read_subchannel *sch, int nocopyout)
-{
- struct mcd_qchninfo q;
- struct cd_sub_channel_info data;
- int lba;
-
- if (sc->data.debug)
- device_printf(sc->dev, "subchan af=%d, df=%d\n",
- sch->address_format,
- sch->data_format);
-
- if (sch->address_format != CD_MSF_FORMAT &&
- sch->address_format != CD_LBA_FORMAT)
- return (EINVAL);
-
- if (sch->data_format != CD_CURRENT_POSITION &&
- sch->data_format != CD_MEDIA_CATALOG)
- return (EINVAL);
-
- if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
- return (EIO);
-
- if (mcd_getqchan(sc, &q) < 0)
- return (EIO);
-
- data.header.audio_status = sc->data.audio_status;
- data.what.position.data_format = sch->data_format;
-
- switch (sch->data_format) {
- case CD_MEDIA_CATALOG:
- data.what.media_catalog.mc_valid = 1;
- data.what.media_catalog.mc_number[0] = '\0';
- break;
-
- case CD_CURRENT_POSITION:
- data.what.position.control = q.control;
- data.what.position.addr_type = q.addr_type;
- data.what.position.track_number = bcd2bin(q.trk_no);
- data.what.position.index_number = bcd2bin(q.idx_no);
- switch (sch->address_format) {
- case CD_MSF_FORMAT:
- data.what.position.reladdr.msf.unused = 0;
- data.what.position.reladdr.msf.minute = bcd2bin(q.trk_size_msf[0]);
- data.what.position.reladdr.msf.second = bcd2bin(q.trk_size_msf[1]);
- data.what.position.reladdr.msf.frame = bcd2bin(q.trk_size_msf[2]);
- data.what.position.absaddr.msf.unused = 0;
- data.what.position.absaddr.msf.minute = bcd2bin(q.hd_pos_msf[0]);
- data.what.position.absaddr.msf.second = bcd2bin(q.hd_pos_msf[1]);
- data.what.position.absaddr.msf.frame = bcd2bin(q.hd_pos_msf[2]);
- break;
- case CD_LBA_FORMAT:
- lba = msf2hsg(q.trk_size_msf, 1);
- /*
- * Pre-gap has index number of 0, and decreasing MSF
- * address. Must be converted to negative LBA, per
- * SCSI spec.
- */
- if (data.what.position.index_number == 0)
- lba = -lba;
- data.what.position.reladdr.lba = htonl(lba);
- data.what.position.absaddr.lba = htonl(msf2hsg(q.hd_pos_msf, 0));
- break;
- }
- break;
- }
-
- MCD_UNLOCK(sc);
- if (nocopyout == 0)
- return copyout(&data, sch->data, min(sizeof(struct cd_sub_channel_info), sch->data_len));
- bcopy(&data, sch->data, min(sizeof(struct cd_sub_channel_info), sch->data_len));
- return (0);
-}
-
-static int
-mcd_playmsf(struct mcd_softc *sc, struct ioc_play_msf *p)
-{
- struct mcd_read2 pb;
-
- if (sc->data.debug)
- device_printf(sc->dev, "playmsf: from %d:%d.%d to %d:%d.%d\n",
- p->start_m, p->start_s, p->start_f,
- p->end_m, p->end_s, p->end_f);
-
- if ((p->start_m * 60 * 75 + p->start_s * 75 + p->start_f) >=
- (p->end_m * 60 * 75 + p->end_s * 75 + p->end_f) ||
- (p->end_m * 60 * 75 + p->end_s * 75 + p->end_f) >
- M_msf(sc->data.volinfo.vol_msf) * 60 * 75 +
- S_msf(sc->data.volinfo.vol_msf) * 75 +
- F_msf(sc->data.volinfo.vol_msf))
- return (EINVAL);
-
- pb.start_msf[0] = bin2bcd(p->start_m);
- pb.start_msf[1] = bin2bcd(p->start_s);
- pb.start_msf[2] = bin2bcd(p->start_f);
- pb.end_msf[0] = bin2bcd(p->end_m);
- pb.end_msf[1] = bin2bcd(p->end_s);
- pb.end_msf[2] = bin2bcd(p->end_f);
-
- if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
- return (EIO);
-
- return mcd_play(sc, &pb);
-}
-
-static int
-mcd_playtracks(struct mcd_softc *sc, struct ioc_play_track *pt)
-{
- struct mcd_read2 pb;
- int a = pt->start_track;
- int z = pt->end_track;
- int rc, i;
-
- if ((rc = mcd_read_toc(sc)) != 0)
- return (rc);
-
- if (sc->data.debug)
- device_printf(sc->dev, "playtracks from %d:%d to %d:%d\n",
- a, pt->start_index, z, pt->end_index);
-
- if ( a < bcd2bin(sc->data.volinfo.trk_low)
- || a > bcd2bin(sc->data.volinfo.trk_high)
- || a > z
- || z < bcd2bin(sc->data.volinfo.trk_low)
- || z > bcd2bin(sc->data.volinfo.trk_high))
- return (EINVAL);
-
- for (i = 0; i < 3; i++) {
- pb.start_msf[i] = sc->data.toc[a].hd_pos_msf[i];
- pb.end_msf[i] = sc->data.toc[z+1].hd_pos_msf[i];
- }
-
- if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
- return (EIO);
-
- return mcd_play(sc, &pb);
-}
-
-static int
-mcd_playblocks(struct mcd_softc *sc, struct ioc_play_blocks *p)
-{
- struct mcd_read2 pb;
-
- if (sc->data.debug)
- device_printf(sc->dev, "playblocks: blkno %d length %d\n",
- p->blk, p->len);
-
- if (p->blk > sc->data.disksize || p->len > sc->data.disksize ||
- p->blk < 0 || p->len < 0 ||
- (p->blk + p->len) > sc->data.disksize)
- return (EINVAL);
-
- hsg2msf(p->blk, pb.start_msf);
- hsg2msf(p->blk + p->len, pb.end_msf);
-
- if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
- return (EIO);
-
- return mcd_play(sc, &pb);
-}
-
-static int
-mcd_play(struct mcd_softc *sc, struct mcd_read2 *pb)
-{
- int retry, st = -1, status;
-
- sc->data.lastpb = *pb;
- for(retry=0; retry<MCD_RETRYS; retry++) {
-
- critical_enter();
- MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDSINGLESPEEDREAD);
- MCD_WRITE(sc, MCD_REG_COMMAND, pb->start_msf[0]);
- MCD_WRITE(sc, MCD_REG_COMMAND, pb->start_msf[1]);
- MCD_WRITE(sc, MCD_REG_COMMAND, pb->start_msf[2]);
- MCD_WRITE(sc, MCD_REG_COMMAND, pb->end_msf[0]);
- MCD_WRITE(sc, MCD_REG_COMMAND, pb->end_msf[1]);
- MCD_WRITE(sc, MCD_REG_COMMAND, pb->end_msf[2]);
- critical_exit();
-
- status=mcd_getstat(sc, 0);
- if (status == -1)
- continue;
- else if (status != -2)
- st = 0;
- break;
- }
-
- if (status == -2) {
- device_printf(sc->dev, "media changed\n");
- return (ENXIO);
- }
- if (sc->data.debug)
- device_printf(sc->dev,
- "mcd_play retry=%d, status=0x%02x\n", retry, status);
- if (st < 0)
- return (ENXIO);
- sc->data.audio_status = CD_AS_PLAY_IN_PROGRESS;
- return (0);
-}
-
-static int
-mcd_pause(struct mcd_softc *sc)
-{
- struct mcd_qchninfo q;
- int rc;
-
- /* Verify current status */
- if (sc->data.audio_status != CD_AS_PLAY_IN_PROGRESS &&
- sc->data.audio_status != CD_AS_PLAY_PAUSED) {
- if (sc->data.debug)
- device_printf(sc->dev,
- "pause attempted when not playing, audio status %d\n",
- sc->data.audio_status);
- return (EINVAL);
- }
-
- /* Get the current position */
- if (mcd_getqchan(sc, &q) < 0)
- return (EIO);
-
- /* Copy it into lastpb */
- sc->data.lastpb.start_msf[0] = q.hd_pos_msf[0];
- sc->data.lastpb.start_msf[1] = q.hd_pos_msf[1];
- sc->data.lastpb.start_msf[2] = q.hd_pos_msf[2];
-
- /* Stop playing */
- if ((rc=mcd_stop(sc)) != 0)
- return (rc);
-
- /* Set the proper status and exit */
- sc->data.audio_status = CD_AS_PLAY_PAUSED;
- return (0);
-}
-
-static int
-mcd_resume(struct mcd_softc *sc)
-{
-
- if (sc->data.audio_status != CD_AS_PLAY_PAUSED)
- return (EINVAL);
- return mcd_play(sc, &sc->data.lastpb);
-}
diff --git a/sys/dev/mcd/mcd_isa.c b/sys/dev/mcd/mcd_isa.c
deleted file mode 100644
index 92e8adb57192..000000000000
--- a/sys/dev/mcd/mcd_isa.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#include <sys/bio.h>
-#include <sys/cdio.h>
-#include <sys/bus.h>
-
-#include <sys/lock.h>
-#include <sys/mutex.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <isa/isavar.h>
-
-#include <dev/mcd/mcdreg.h>
-#include <dev/mcd/mcdvar.h>
-
-static int mcd_isa_probe (device_t);
-static int mcd_isa_attach (device_t);
-static int mcd_isa_detach (device_t);
-
-static int mcd_alloc_resources (device_t);
-static void mcd_release_resources (device_t);
-
-static int
-mcd_isa_probe (device_t dev)
-{
- struct mcd_softc * sc;
- int error;
-
- /* No pnp support */
- if (isa_get_vendorid(dev))
- return (ENXIO);
-
- /* IO port must be configured. */
- if (bus_get_resource_start(dev, SYS_RES_IOPORT, 0) == 0)
- return (ENXIO);
-
- sc = device_get_softc(dev);
- sc->dev = dev;
- sc->port_rid = 0;
- sc->port_type = SYS_RES_IOPORT;
- error = mcd_alloc_resources(dev);
- if (error)
- goto fail;
-
- error = mcd_probe(sc);
- if (error) {
- device_printf(dev, "Probe failed.\n");
- goto fail;
- }
-
- device_set_desc(dev, sc->data.name);
-
-fail:
- mcd_release_resources(dev);
- return (error);
-}
-
-static int
-mcd_isa_attach (device_t dev)
-{
- struct mcd_softc * sc;
- int error;
-
- sc = device_get_softc(dev);
- error = 0;
-
- sc->dev = dev;
- sc->port_rid = 0;
- sc->port_type = SYS_RES_IOPORT;
- error = mcd_alloc_resources(dev);
- if (error)
- goto fail;
-
- error = mcd_probe(sc);
- if (error) {
- device_printf(dev, "Re-Probe failed.\n");
- goto fail;
- }
-
- error = mcd_attach(sc);
- if (error) {
- device_printf(dev, "Attach failed.\n");
- goto fail;
- }
-
- return (0);
-fail:
- mcd_release_resources(dev);
- return (error);
-}
-
-static int
-mcd_isa_detach (device_t dev)
-{
- struct mcd_softc * sc;
- int error;
-
- sc = device_get_softc(dev);
- error = 0;
-
- destroy_dev(sc->mcd_dev_t);
-
- mcd_release_resources(dev);
-
- return (error);
-}
-
-static int
-mcd_alloc_resources (device_t dev)
-{
- struct mcd_softc * sc;
- int error;
-
- sc = device_get_softc(dev);
- error = 0;
- mtx_init(&sc->mtx, "mcd", NULL, MTX_DEF);
-
- if (sc->port_type) {
- sc->port = bus_alloc_resource_any(dev, sc->port_type,
- &sc->port_rid, RF_ACTIVE);
- if (sc->port == NULL) {
- device_printf(dev, "Unable to allocate PORT resource.\n");
- error = ENOMEM;
- goto bad;
- }
- }
-
- if (sc->irq_type) {
- sc->irq = bus_alloc_resource_any(dev, sc->irq_type,
- &sc->irq_rid, RF_ACTIVE);
- if (sc->irq == NULL) {
- device_printf(dev, "Unable to allocate IRQ resource.\n");
- error = ENOMEM;
- goto bad;
- }
- }
-
- if (sc->drq_type) {
- sc->drq = bus_alloc_resource_any(dev, sc->drq_type,
- &sc->drq_rid, RF_ACTIVE);
- if (sc->drq == NULL) {
- device_printf(dev, "Unable to allocate DRQ resource.\n");
- error = ENOMEM;
- goto bad;
- }
- }
-
-bad:
- return (error);
-}
-
-static void
-mcd_release_resources (device_t dev)
-{
- struct mcd_softc * sc;
-
- sc = device_get_softc(dev);
-
- if (sc->irq_ih)
- bus_teardown_intr(dev, sc->irq, sc->irq_ih);
- if (sc->port)
- bus_release_resource(dev, sc->port_type, sc->port_rid, sc->port);
- if (sc->irq)
- bus_release_resource(dev, sc->irq_type, sc->irq_rid, sc->irq);
- if (sc->drq)
- bus_release_resource(dev, sc->drq_type, sc->drq_rid, sc->drq);
-
- mtx_destroy(&sc->mtx);
-
- return;
-}
-
-static device_method_t mcd_isa_methods[] = {
- DEVMETHOD(device_probe, mcd_isa_probe),
- DEVMETHOD(device_attach, mcd_isa_attach),
- DEVMETHOD(device_detach, mcd_isa_detach),
-
- { 0, 0 }
-};
-
-static driver_t mcd_isa_driver = {
- "mcd",
- mcd_isa_methods,
- sizeof(struct mcd_softc)
-};
-
-static devclass_t mcd_devclass;
-
-DRIVER_MODULE(mcd, isa, mcd_isa_driver, mcd_devclass, NULL, 0);
diff --git a/sys/dev/mcd/mcdreg.h b/sys/dev/mcd/mcdreg.h
deleted file mode 100644
index 451fc5de76c3..000000000000
--- a/sys/dev/mcd/mcdreg.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*-
- * Copyright 1993 by Holger Veit (data part)
- * Copyright 1993 by Brian Moore (audio part)
- * Changes Copyright 1993 by Gary Clark II
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This software was developed by Holger Veit and Brian Moore
- * for use with "386BSD" and similar operating systems.
- * "Similar operating systems" includes mainly non-profit oriented
- * systems for research and education, including but not restricted to
- * "NetBSD", "FreeBSD", "Mach" (by CMU).
- * 4. Neither the name of the developer(s) nor the name "386BSD"
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This file contains definitions for some cdrom control commands
- * and status codes. This info was "inherited" from the DOS MTMCDE.SYS
- * driver, and is thus not complete (and may even be wrong). Some day
- * the manufacturer or anyone else might provide better documentation,
- * so this file (and the driver) will then have a better quality.
- *
- * $FreeBSD$
- */
-
-#ifndef MCD_H
-#define MCD_H
-
-/* toc */
-#define MCD_MAXTOCS 104 /* from the Linux driver */
-#define MCD_LASTPLUS1 170 /* special toc entry */
-
-typedef unsigned char bcd_t;
-#define M_msf(msf) msf[0]
-#define S_msf(msf) msf[1]
-#define F_msf(msf) msf[2]
-
-/* io lines used */
-#define MCD_IO_BASE 0x300
-
-#define MCD_REG_COMMAND 0
-#define MCD_REG_STATUS 0
-#define MCD_REG_RDATA 0
-
-#define MCD_REG_RESET 1
-#define MCD_REG_CTL2 2 /* XXX Is this right? */
-#define MCD_REG_CONFIG 3
-
-#define MCD_MASK_DMA 0x07 /* bits 2-0 = DMA channel */
-#define MCD_MASK_IRQ 0x70 /* bits 6-4 = INT number */
- /* 001 = int 2,9 */
- /* 010 = int 3 */
- /* 011 = int 5 */
- /* 100 = int 10 */
- /* 101 = int 11 */
-/* flags */
-#define MFL_DATA_NOT_AVAIL 0x02
-#define MFL_STATUS_NOT_AVAIL 0x04
-
-/* New Commands */
-#define M_RESET 0x00
-#define M_PICKLE 0x04
-
-/* ports */
-#define MCD_DATA 0
-#define MCD_FLAGS 1
-#define MCD_CTRL 2
-#define CHANNEL 3 /* XXX ??? */
-
-/* Status bits */
-#define MCD_ST_DOOROPEN 0x80
-#define MCD_ST_DSKIN 0x40
-#define MCD_ST_DSKCHNG 0x20
-#define MCD_ST_SPINNING 0x10
-#define MCD_ST_AUDIODISK 0x08 /* Audio Disk is in */
-#define MCD_ST_BUSY 0x04
-#define MCD_ST_AUDIOBSY 0x02 /* Audio Disk is Playing */
-#define MCD_ST_CMDCHECK 0x01 /* Command error */
-
-/* commands known by the controller */
-#define MCD_CMDRESET 0x00
-#define MCD_CMDGETVOLINFO 0x10 /* gets mcd_volinfo */
-#define MCD_CMDGETDISKINFO 0x11 /* gets mcd_disk information */
-#define MCD_CMDGETQCHN 0x20 /* gets mcd_qchninfo */
-#define MCD_CMDGETSENSE 0x30 /* gets sense info */
-#define MCD_CMDGETSTAT 0x40 /* gets a byte of status */
-
-#define MCD_CMDSETMODE 0x50 /* set transmission mode, needs byte */
-
-#define MCD_MDBIT_TESTMODE 0x80 /* 0 = DATALENGTH setting is valid */
-#define MCD_MDBIT_DATALENGTH 0x40 /* 0 = Read User Data Only */
- /* 1 = Read Raw sectors (2352 bytes) */
-
-#define MCDBLK 2048 /* for cooked mode */
-#define MCDRBLK sizeof(struct mcd_rawsector) /* for raw mode */
-
-#define MCD_MDBIT_ECCMODE 0x20 /* 0 = Use secondary correction */
- /* 1 = Don't use secondary ECC */
-#define MCD_MDBIT_SPINDOWN 0x08 /* 0 = Spin Up, 1 = Spin Down */
-#define MCD_MDBIT_GET_TOC 0x04 /* 0 = Get UPC on next GETQCHAN */
- /* 1 = Get TOC on GETQCHAN */
-#define MCD_MDBIT_MUTEDATA 0x01 /* 1 = Don't play back Data as audio */
-
-#define MCD_MD_RAW (MCD_MDBIT_DATALENGTH|MCD_MDBIT_ECCMODE|MCD_MDBIT_MUTEDATA)
-#define MCD_MD_COOKED (MCD_MDBIT_MUTEDATA)
-#define MCD_MD_TOC (MCD_MDBIT_GET_TOC|MCD_MDBIT_MUTEDATA)
-
-#define MCD_CMDSTOPAUDIO 0x70
-#define MCD_CMDSTOPAUDIOTIME 0x80
-#define MCD_CMDGETVOLUME 0x8E /* gets mcd_volume */
-#define MCD_CMDSETDRIVEMODE 0xA0 /* Set drive mode */
-#define MCD_READUPC 0xA2 /* Get UPC info */
-#define MCD_CMDSETVOLUME 0xAE /* sets mcd_volume */
-#define MCD_CMDREAD1 0xB0 /* read n sectors */
-#define MCD_CMDSINGLESPEEDREAD 0xC0 /* read from-to */
-#define MCD_CMDSTARTAUDIOMSF 0xC1 /* read audio data */
-#define MCD_CMDDOUBLESPEEDREAD 0xC1 /* Read lots of data from the drive */
-#define MCD_CMDGETDRIVEMODE 0xC2 /* Get the drive mode */
-#define MCD_CMDREAD 0xC3 /* Read data from the drive */
-#define MCD_CMDSETINTERLEAVE 0xC8 /* Adjust the interleave */
-#define MCD_CMDCONTINFO 0xDC /* Get controller info */
-#define MCD_CMDSTOP 0xF0 /* Stop everything */
-#define MCD_CMDEJECTDISK 0xF6
-#define MCD_CMDCLOSETRAY 0xF8
-
-#define MCD_CMDLOCKDRV 0xFE /* needs byte */
-#define MCD_LK_UNLOCK 0x00
-#define MCD_LK_LOCK 0x01
-#define MCD_LK_TEST 0x02
-
-/* DMA Enable Stuff */
-#define MCD_DMA_IRQFLAGS 0x10 /* Set data0 for IRQ click */
-
-#define MCD_DMA_PREIRQ 0x01 /* All of these are for */
-#define MCD_DMA_POSTIRQ 0x02 /* MCD_DMA_IRQFLAG... */
-#define MCD_DMA_ERRIRQ 0x04 /* */
-
-#define MCD_DMA_TIMEOUT 0x08 /* Set data0 for DMA timeout */
-#define MCD_DMA_UPCFLAG 0x04 /* 1 = Next command will be READUPC */
-
-#define MCD_DMA_DMAMODE 0x02 /* 1 = Data uses DMA */
-#define MCD_DMA_TRANSFERLENGTH 0x01 /* data0 = MSB, data1 = LSB of block length */
-
-struct mcd_dma_mode {
- u_char dma_mode;
- u_char data0; /* If dma_mode & 0x10: Use IRQ settings */
- u_char data1; /* Used if dma_mode & 0x01 */
-} __packed;
-
-struct mcd_volinfo {
- bcd_t trk_low;
- bcd_t trk_high;
- bcd_t vol_msf[3];
- bcd_t trk1_msf[3];
-} __packed;
-
-struct mcd_qchninfo {
- u_char addr_type:4;
- u_char control:4;
- u_char trk_no;
- u_char idx_no;
- bcd_t trk_size_msf[3];
- u_char :8;
- bcd_t hd_pos_msf[3];
-} __packed;
-
-struct mcd_volume {
- u_char v0l;
- u_char v0rs;
- u_char v0r;
- u_char v0ls;
-} __packed;
-
-struct mcd_holdtime {
- u_char units_of_ten_seconds;
- /* If this is 0, the default (12) is used */
-} __packed;
-
-struct mcd_read1 {
- bcd_t start_msf[3];
- u_char nsec[3];
-} __packed;
-
-struct mcd_read2 {
- bcd_t start_msf[3];
- bcd_t end_msf[3];
-} __packed;
-
-struct mcd_rawsector {
- u_char sync1[12];
- u_char header[4];
- u_char subheader1[4];
- u_char subheader2[4];
- u_char data[MCDBLK];
- u_char ecc_bits[280];
-} __packed;
-
-#endif /* MCD_H */
diff --git a/sys/dev/mcd/mcdvar.h b/sys/dev/mcd/mcdvar.h
deleted file mode 100644
index 71e45d0b0bd2..000000000000
--- a/sys/dev/mcd/mcdvar.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * $FreeBSD$
- */
-
-struct mcd_mbx {
- short retry;
- short nblk;
- int sz;
- u_long skip;
- struct bio * bp;
- short count;
- short mode;
-};
-
-struct mcd_data {
- short type;
- char * name;
- short config;
- short flags;
- u_char read_command;
- short status;
- int blksize;
- u_long disksize;
- int partflags;
- int openflags;
- struct mcd_volinfo volinfo;
- struct mcd_qchninfo toc[MCD_MAXTOCS];
- short audio_status;
- short curr_mode;
- struct mcd_read2 lastpb;
- short debug;
- struct bio_queue_head head; /* head of bio queue */
- struct mcd_mbx mbx;
-};
-
-struct mcd_softc {
- device_t dev;
- struct cdev *mcd_dev_t;
- int debug;
-
- struct resource * port;
- int port_rid;
- int port_type;
-
- struct resource * irq;
- int irq_rid;
- int irq_type;
- void * irq_ih;
-
- struct resource * drq;
- int drq_rid;
- int drq_type;
-
- struct mtx mtx;
-
- struct callout timer;
- int ch_state;
- struct mcd_mbx * ch_mbxsave;
-
- struct mcd_data data;
-};
-
-#define MCD_LOCK(_sc) mtx_lock(&_sc->mtx)
-#define MCD_UNLOCK(_sc) mtx_unlock(&_sc->mtx)
-#define MCD_ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED)
-
-#define MCD_READ(_sc, _reg) bus_read_1(_sc->port, _reg)
-#define MCD_WRITE(_sc, _reg, _val) bus_write_1(_sc->port, _reg, _val)
-
-int mcd_probe (struct mcd_softc *);
-int mcd_attach (struct mcd_softc *);
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 93d33d948abf..c6c76f90d215 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -224,7 +224,6 @@ SUBDIR= \
mac_stub \
mac_test \
malo \
- mcd \
md \
mdio \
mem \
diff --git a/sys/modules/mcd/Makefile b/sys/modules/mcd/Makefile
deleted file mode 100644
index 1602c0304c7f..000000000000
--- a/sys/modules/mcd/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../dev/mcd
-
-KMOD= mcd
-SRCS= mcd.c mcd_isa.c \
- bus_if.h device_if.h isa_if.h
-
-.include <bsd.kmod.mk>