diff options
-rw-r--r-- | sys/arch/amd64/amd64/conf.c | 12 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/dev_i386.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/pxeboot/devopen.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISKB | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISKC | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISK_CD | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/files.i386 | 3 | ||||
-rw-r--r-- | sys/arch/i386/i386/autoconf.c | 3 | ||||
-rw-r--r-- | sys/arch/i386/i386/conf.c | 11 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/dev_i386.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/pxeboot/devopen.c | 4 | ||||
-rw-r--r-- | sys/arch/zaurus/stand/zboot/devopen.c | 6 | ||||
-rw-r--r-- | sys/dev/isa/files.isa | 9 | ||||
-rw-r--r-- | sys/dev/isa/mcd.c | 1766 | ||||
-rw-r--r-- | sys/dev/isa/mcdreg.h | 247 |
17 files changed, 28 insertions, 2065 deletions
diff --git a/sys/arch/amd64/amd64/conf.c b/sys/arch/amd64/amd64/conf.c index f0bac927980..b4f78ff319c 100644 --- a/sys/arch/amd64/amd64/conf.c +++ b/sys/arch/amd64/amd64/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.33 2011/03/22 15:29:48 marco Exp $ */ +/* $OpenBSD: conf.c,v 1.34 2011/06/26 23:19:11 tedu Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -51,8 +51,6 @@ bdev_decl(fd); #include "st.h" #include "cd.h" #include "uk.h" -#include "mcd.h" -bdev_decl(mcd); #include "vnd.h" #include "ccd.h" #include "raid.h" @@ -67,7 +65,7 @@ struct bdevsw bdevsw[] = bdev_disk_init(NSD,sd), /* 4: SCSI disk */ bdev_tape_init(NST,st), /* 5: SCSI tape */ bdev_disk_init(NCD,cd), /* 6: SCSI CD-ROM */ - bdev_disk_init(NMCD,mcd), /* 7: Mitsumi CD-ROM */ + bdev_notdef(), /* 7 */ bdev_lkm_dummy(), /* 8 */ bdev_lkm_dummy(), /* 9 */ bdev_lkm_dummy(), /* 10 */ @@ -121,7 +119,6 @@ cdev_decl(wd); #include "com.h" cdev_decl(com); cdev_decl(fd); -cdev_decl(scd); #include "lpt.h" cdev_decl(lpt); #include "ch.h" @@ -142,7 +139,6 @@ cdev_decl(pms); #endif #include "cy.h" cdev_decl(cy); -cdev_decl(mcd); #include "tun.h" #include "audio.h" #include "video.h" @@ -238,7 +234,7 @@ struct cdevsw cdevsw[] = cdev_notdef(), /* 36: Logitech mouse */ cdev_notdef(), /* 37: Extended PS/2 mouse */ cdev_tty_init(NCY,cy), /* 38: Cyclom serial port */ - cdev_disk_init(NMCD,mcd), /* 39: Mitsumi CD-ROM */ + cdev_notdef(), /* 39: Mitsumi CD-ROM */ cdev_tun_init(NTUN,tun), /* 40: network tunnel */ cdev_disk_init(NVND,vnd), /* 41: vnode disk driver */ cdev_audio_init(NAUDIO,audio), /* 42: generic audio I/O */ @@ -390,7 +386,7 @@ int chrtoblktbl[] = { /* 36 */ NODEV, /* 37 */ NODEV, /* 38 */ NODEV, - /* 39 */ 7, /* mcd */ + /* 39 */ NODEV, /* 40 */ NODEV, /* 41 */ 14, /* vnd */ /* 42 */ NODEV, diff --git a/sys/arch/amd64/stand/libsa/dev_i386.c b/sys/arch/amd64/stand/libsa/dev_i386.c index 69487614d8c..b5c5f98a1de 100644 --- a/sys/arch/amd64/stand/libsa/dev_i386.c +++ b/sys/arch/amd64/stand/libsa/dev_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_i386.c,v 1.7 2011/06/26 21:37:52 tedu Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.8 2011/06/26 23:19:11 tedu Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -35,7 +35,7 @@ extern int debug; /* XXX use slot for 'rd' for 'hd' pseudo-device */ const char bdevs[][4] = { - "wd", "", "fd", "", "sd", "st", "cd", "mcd", + "wd", "", "fd", "", "sd", "st", "cd", "", "", "", "", "", "", "", "", "", "", "hd", "" }; const int nbdevs = nitems(bdevs); diff --git a/sys/arch/amd64/stand/pxeboot/devopen.c b/sys/arch/amd64/stand/pxeboot/devopen.c index 82036bb0910..e3d8cecf88e 100644 --- a/sys/arch/amd64/stand/pxeboot/devopen.c +++ b/sys/arch/amd64/stand/pxeboot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.8 2011/06/26 21:37:52 tedu Exp $ */ +/* $OpenBSD: devopen.c,v 1.9 2011/06/26 23:19:11 tedu Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -42,7 +42,7 @@ extern char *bootmac; /* Gets passed to kernel for network boot */ /* XXX use slot for 'rd' for 'hd' pseudo-device */ const char bdevs[][4] = { - "wd", "", "fd", "", "sd", "st", "cd", "mcd", + "wd", "", "fd", "", "sd", "st", "cd", "", "", "", "", "", "", "", "", "", "", "hd", "" }; const int nbdevs = nitems(bdevs); diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 3f5b6db6584..a258198f689 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.718 2011/06/20 06:07:26 dlg Exp $ +# $OpenBSD: GENERIC,v 1.719 2011/06/26 23:19:10 tedu Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -528,8 +528,6 @@ fdc0 at isa? port 0x3f0 irq 6 drq 2 # standard PC floppy controllers #fdc1 at isa? port 0x370 fd* at fdc? flags 0x00 -#mcd0 at isa? port 0x300 irq 10 # Mitsumi CD-ROM drives - # IDE controllers pciide* at pci? flags 0x0000 diff --git a/sys/arch/i386/conf/RAMDISK b/sys/arch/i386/conf/RAMDISK index b4603c5c3e9..7f66abe339d 100644 --- a/sys/arch/i386/conf/RAMDISK +++ b/sys/arch/i386/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.174 2011/06/06 06:15:02 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.175 2011/06/26 23:19:10 tedu Exp $ machine i386 # architecture, used by config; REQUIRED @@ -176,8 +176,6 @@ fdc0 at isa? port 0x3f0 irq 6 drq 2 # standard PC floppy controllers #fdc1 at isa? port 0x370 fd* at fdc? -#mcd0 at isa? port 0x300 irq 10 # Mitsumi CD-ROM drives - # IDE controllers pciide* at pci? flags 0x0000 diff --git a/sys/arch/i386/conf/RAMDISKB b/sys/arch/i386/conf/RAMDISKB index 97b164de6cd..623d23e1444 100644 --- a/sys/arch/i386/conf/RAMDISKB +++ b/sys/arch/i386/conf/RAMDISKB @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISKB,v 1.117 2011/01/07 19:33:08 deraadt Exp $ +# $OpenBSD: RAMDISKB,v 1.118 2011/06/26 23:19:10 tedu Exp $ machine i386 # architecture, used by config; REQUIRED @@ -194,8 +194,6 @@ fdc0 at isa? port 0x3f0 irq 6 drq 2 # standard PC floppy controllers #fdc1 at isa? port 0x370 fd* at fdc? -#mcd0 at isa? port 0x300 irq 10 # Mitsumi CD-ROM drives - # IDE controllers pciide* at pci? flags 0x0000 diff --git a/sys/arch/i386/conf/RAMDISKC b/sys/arch/i386/conf/RAMDISKC index 7fb060607f9..3bcda19b9cd 100644 --- a/sys/arch/i386/conf/RAMDISKC +++ b/sys/arch/i386/conf/RAMDISKC @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISKC,v 1.98 2011/05/24 20:27:11 matthew Exp $ +# $OpenBSD: RAMDISKC,v 1.99 2011/06/26 23:19:10 tedu Exp $ machine i386 # architecture, used by config; REQUIRED @@ -211,8 +211,6 @@ fdc0 at isa? port 0x3f0 irq 6 drq 2 # standard PC floppy controllers #fdc1 at isa? port 0x370 fd* at fdc? -#mcd0 at isa? port 0x300 irq 10 # Mitsumi CD-ROM drives - # IDE controllers pciide* at pci? flags 0x0000 diff --git a/sys/arch/i386/conf/RAMDISK_CD b/sys/arch/i386/conf/RAMDISK_CD index a0dc6d142f2..f3f8a9116de 100644 --- a/sys/arch/i386/conf/RAMDISK_CD +++ b/sys/arch/i386/conf/RAMDISK_CD @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK_CD,v 1.187 2011/05/24 20:27:11 matthew Exp $ +# $OpenBSD: RAMDISK_CD,v 1.188 2011/06/26 23:19:10 tedu Exp $ machine i386 # architecture, used by config; REQUIRED @@ -279,8 +279,6 @@ fdc0 at isa? port 0x3f0 irq 6 drq 2 # standard PC floppy controllers #fdc1 at isa? port 0x370 fd* at fdc? -#mcd0 at isa? port 0x300 irq 10 # Mitsumi CD-ROM drives - # IDE controllers pciide* at pci? flags 0x0000 diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index 6c655e0d050..d2d98845dce 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: files.i386,v 1.203 2011/05/23 09:54:20 claudio Exp $ +# $OpenBSD: files.i386,v 1.204 2011/06/26 23:19:10 tedu Exp $ # # new style config file for i386 architecture # @@ -181,7 +181,6 @@ file dev/pci/if_hme_pci.c hme_pci # ISA and mixed ISA+EISA or ISA+PCI or ISA+PCMCIA drivers # -major {mcd = 7} major {wd = 0} include "dev/isa/files.isa" diff --git a/sys/arch/i386/i386/autoconf.c b/sys/arch/i386/i386/autoconf.c index 00845856817..fa34ca1acd1 100644 --- a/sys/arch/i386/i386/autoconf.c +++ b/sys/arch/i386/i386/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.87 2011/04/25 21:00:08 mikeb Exp $ */ +/* $OpenBSD: autoconf.c,v 1.88 2011/06/26 23:19:11 tedu Exp $ */ /* $NetBSD: autoconf.c,v 1.20 1996/05/03 19:41:56 christos Exp $ */ /*- @@ -215,7 +215,6 @@ struct nam2blk nam2blk[] = { { "fd", 2 }, { "sd", 4 }, { "cd", 6 }, - { "mcd", 7 }, { "rd", 17 }, { "raid", 19 }, { "vnd", 14 }, diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c index 1e85bd7d269..59735e2e021 100644 --- a/sys/arch/i386/i386/conf.c +++ b/sys/arch/i386/i386/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.136 2011/01/14 19:04:08 jasper Exp $ */ +/* $OpenBSD: conf.c,v 1.137 2011/06/26 23:19:11 tedu Exp $ */ /* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */ /* @@ -52,8 +52,6 @@ bdev_decl(fd); #include "st.h" #include "cd.h" #include "uk.h" -#include "mcd.h" -bdev_decl(mcd); #include "vnd.h" #include "ccd.h" #include "raid.h" @@ -68,7 +66,7 @@ struct bdevsw bdevsw[] = bdev_disk_init(NSD,sd), /* 4: SCSI disk */ bdev_tape_init(NST,st), /* 5: SCSI tape */ bdev_disk_init(NCD,cd), /* 6: SCSI CD-ROM */ - bdev_disk_init(NMCD,mcd), /* 7: Mitsumi CD-ROM */ + bdev_notdef(), /* 7 */ bdev_lkm_dummy(), /* 8 */ bdev_lkm_dummy(), /* 9 */ bdev_lkm_dummy(), /* 10 */ @@ -142,7 +140,6 @@ cdev_decl(pms); #endif #include "cy.h" cdev_decl(cy); -cdev_decl(mcd); #include "tun.h" #include "audio.h" #include "video.h" @@ -241,7 +238,7 @@ struct cdevsw cdevsw[] = cdev_notdef(), /* 36: Logitech mouse */ cdev_notdef(), /* 37: Extended PS/2 mouse */ cdev_tty_init(NCY,cy), /* 38: Cyclom serial port */ - cdev_disk_init(NMCD,mcd), /* 39: Mitsumi CD-ROM */ + cdev_notdef(), /* 39: Mitsumi CD-ROM */ cdev_tun_init(NTUN,tun), /* 40: network tunnel */ cdev_disk_init(NVND,vnd), /* 41: vnode disk driver */ cdev_audio_init(NAUDIO,audio), /* 42: generic audio I/O */ @@ -392,7 +389,7 @@ int chrtoblktbl[] = { /* 36 */ NODEV, /* 37 */ NODEV, /* 38 */ NODEV, - /* 39 */ 7, /* mcd */ + /* 39 */ NODEV, /* 40 */ NODEV, /* 41 */ 14, /* vnd */ /* 42 */ NODEV, diff --git a/sys/arch/i386/stand/libsa/dev_i386.c b/sys/arch/i386/stand/libsa/dev_i386.c index a24621d3aae..5ff1e162a5b 100644 --- a/sys/arch/i386/stand/libsa/dev_i386.c +++ b/sys/arch/i386/stand/libsa/dev_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_i386.c,v 1.34 2011/06/26 21:37:52 tedu Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.35 2011/06/26 23:19:11 tedu Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -35,7 +35,7 @@ extern int debug; /* XXX use slot for 'rd' for 'hd' pseudo-device */ const char bdevs[][4] = { - "wd", "", "fd", "", "sd", "st", "cd", "mcd", + "wd", "", "fd", "", "sd", "st", "cd", "", "", "", "", "", "", "", "", "", "", "hd", "" }; const int nbdevs = nitems(bdevs); diff --git a/sys/arch/i386/stand/pxeboot/devopen.c b/sys/arch/i386/stand/pxeboot/devopen.c index 82036bb0910..e3d8cecf88e 100644 --- a/sys/arch/i386/stand/pxeboot/devopen.c +++ b/sys/arch/i386/stand/pxeboot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.8 2011/06/26 21:37:52 tedu Exp $ */ +/* $OpenBSD: devopen.c,v 1.9 2011/06/26 23:19:11 tedu Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -42,7 +42,7 @@ extern char *bootmac; /* Gets passed to kernel for network boot */ /* XXX use slot for 'rd' for 'hd' pseudo-device */ const char bdevs[][4] = { - "wd", "", "fd", "", "sd", "st", "cd", "mcd", + "wd", "", "fd", "", "sd", "st", "cd", "", "", "", "", "", "", "", "", "", "", "hd", "" }; const int nbdevs = nitems(bdevs); diff --git a/sys/arch/zaurus/stand/zboot/devopen.c b/sys/arch/zaurus/stand/zboot/devopen.c index 3ebdd33a456..442f30af831 100644 --- a/sys/arch/zaurus/stand/zboot/devopen.c +++ b/sys/arch/zaurus/stand/zboot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.9 2010/12/06 22:51:46 jasper Exp $ */ +/* $OpenBSD: devopen.c,v 1.10 2011/06/26 23:19:11 tedu Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -34,8 +34,8 @@ /* XXX use slot for 'rd' for 'hd' pseudo-device */ const char bdevs[][4] = { - "wd", "", "fd", "", "sd", "st", "cd", "mcd", - "", "", "", "", "", "", "", "scd", "", "hd", "" + "wd", "", "fd", "", "sd", "st", "cd", "", + "", "", "", "", "", "", "", "", "", "hd", "" }; const int nbdevs = nitems(bdevs); diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index 1777ffa8ebf..d408cde0408 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $OpenBSD: files.isa,v 1.108 2011/06/26 21:41:05 tedu Exp $ +# $OpenBSD: files.isa,v 1.109 2011/06/26 23:19:11 tedu Exp $ # $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $ # # Config file and device description for machine-independent ISA code. @@ -7,7 +7,7 @@ # ports should specify appropriate major numbers for the following # devices: -# mcd, wd +# wd device isa {[port = -1], [size = 0], [iomem = -1], [iosiz = 0], @@ -127,11 +127,6 @@ file dev/isa/opti.c opti # Other ISA disk controllers # -# Mitsumi CD-ROM controllers -device mcd: disk, opti -attach mcd at isa -file dev/isa/mcd.c mcd needs-flag - # ISA "wd" (ESDI/IDE/etc.) controllers, ATAPI bus attach wdc at isa with wdc_isa: isa_dma file dev/isa/wdc_isa.c wdc_isa diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c deleted file mode 100644 index da257b68cdc..00000000000 --- a/sys/dev/isa/mcd.c +++ /dev/null @@ -1,1766 +0,0 @@ -/* $OpenBSD: mcd.c,v 1.60 2011/06/20 08:47:59 matthew Exp $ */ -/* $NetBSD: mcd.c,v 1.60 1998/01/14 12:14:41 drochner Exp $ */ - -/* - * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. 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 product includes software developed by Charles M. Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * 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. - */ - -/*static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";*/ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/malloc.h> -#include <sys/buf.h> -#include <sys/stat.h> -#include <sys/uio.h> -#include <sys/ioctl.h> -#include <sys/dkio.h> -#include <sys/mtio.h> -#include <sys/cdio.h> -#include <sys/errno.h> -#include <sys/disklabel.h> -#include <sys/device.h> -#include <sys/disk.h> -#include <sys/timeout.h> - -#include <machine/cpu.h> -#include <machine/intr.h> -#include <machine/bus.h> - -#include <dev/isa/isavar.h> -#include <dev/isa/mcdreg.h> -#include <dev/isa/opti.h> - -#ifndef MCDDEBUG -#define MCD_TRACE(fmt,a,b,c,d) -#else -#define MCD_TRACE(fmt,a,b,c,d) {if (sc->debug) {printf("%s: st=%02x: ", sc->sc_dev.dv_xname, sc->status); printf(fmt,a,b,c,d);}} -#endif - -/* toc */ -#define MCD_MAXTOCS 104 /* from the Linux driver */ - -struct mcd_mbx { - int retry, count; - struct buf *bp; - daddr64_t blkno; - int nblk; - int sz; - u_long skip; - int state; -#define MCD_S_IDLE 0 -#define MCD_S_BEGIN 1 -#define MCD_S_WAITMODE 2 -#define MCD_S_WAITREAD 3 - int mode; -}; - -struct mcd_softc { - struct device sc_dev; - struct disk sc_dk; - void *sc_ih; - struct timeout sc_pi_tmo; - - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; - - int irq, drq; - - char *type; - int flags; -#define MCDF_LOADED 0x10 /* parameters loaded */ -#define MCDF_EJECTING 0x20 /* please eject at close */ - short status; - short audio_status; - int blksize; - u_long disksize; - struct mcd_volinfo volinfo; - union mcd_qchninfo toc[MCD_MAXTOCS]; - struct mcd_command lastpb; - struct mcd_mbx mbx; - int lastmode; -#define MCD_MD_UNKNOWN -1 - int lastupc; -#define MCD_UPC_UNKNOWN -1 - struct buf buf_queue; - u_char readcmd; - u_char debug; - u_char probe; -}; - -/* prototypes */ -/* XXX does not belong here */ -cdev_decl(mcd); -bdev_decl(mcd); - -u_int8_t const __bcd2bin[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0, 0, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, 0, 0, 0, 0, 0, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 0, 0, 0, 0, 0, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 0, 0, 0, 0, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, 0, 0, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, 0, 0, 0, 0, 0, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 -}; - -u_int8_t const __bin2bcd[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99 -}; -#define bcd2bin(b) (__bcd2bin[(b)&0xff]) -#define bin2bcd(b) (__bin2bcd[(b)&0xff]) - -static void hsg2msf(int, bcd_t *); -static daddr64_t msf2hsg(bcd_t *, int); - -int mcd_playtracks(struct mcd_softc *, struct ioc_play_track *); -int mcd_playmsf(struct mcd_softc *, struct ioc_play_msf *); -int mcd_playblocks(struct mcd_softc *, struct ioc_play_blocks *); -int mcd_stop(struct mcd_softc *); -int mcd_eject(struct mcd_softc *); -int mcd_read_subchannel(struct mcd_softc *, struct ioc_read_subchannel *); -int mcd_pause(struct mcd_softc *); -int mcd_resume(struct mcd_softc *); -int mcd_toc_header(struct mcd_softc *, struct ioc_toc_header *); -int mcd_toc_entries(struct mcd_softc *, struct ioc_read_toc_entry *); - -int mcd_getreply(struct mcd_softc *); -int mcd_getstat(struct mcd_softc *); -int mcd_getresult(struct mcd_softc *, struct mcd_result *); -void mcd_setflags(struct mcd_softc *); -int mcd_get(struct mcd_softc *, char *, int); -int mcd_send(struct mcd_softc *, struct mcd_mbox *, int); -int mcdintr(void *); -void mcd_soft_reset(struct mcd_softc *); -int mcd_hard_reset(struct mcd_softc *); -int mcd_setmode(struct mcd_softc *, int); -int mcd_setupc(struct mcd_softc *, int); -int mcd_read_toc(struct mcd_softc *); -int mcd_getqchan(struct mcd_softc *, union mcd_qchninfo *, int); -int mcd_setlock(struct mcd_softc *, int); - -int mcd_find(bus_space_tag_t, bus_space_handle_t, struct mcd_softc *); -int mcdprobe(struct device *, void *, void *); -void mcdattach(struct device *, struct device *, void *); - -struct cfattach mcd_ca = { - sizeof(struct mcd_softc), mcdprobe, mcdattach -}; - -struct cfdriver mcd_cd = { - NULL, "mcd", DV_DISK -}; - -int mcdgetdisklabel(dev_t, struct mcd_softc *, struct disklabel *, int); -int mcd_get_parms(struct mcd_softc *); -void mcdstrategy(struct buf *); -void mcdstart(struct mcd_softc *); -void mcd_pseudointr(void *); - -#define MCD_RETRIES 3 -#define MCD_RDRETRIES 3 - -/* several delays */ -#define RDELAY_WAITMODE 300 -#define RDELAY_WAITREAD 800 - -#define DELAY_GRANULARITY 25 /* 25us */ -#define DELAY_GETREPLY 100000 /* 100000 * 25us */ - -void -mcdattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct mcd_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - bus_space_tag_t iot = ia->ia_iot; - bus_space_handle_t ioh; - struct mcd_mbox mbx; - - /* Map i/o space */ - if (bus_space_map(iot, ia->ia_iobase, MCD_NPORT, 0, &ioh)) { - printf(": can't map i/o space\n"); - return; - } - - sc->sc_iot = iot; - sc->sc_ioh = ioh; - - sc->probe = 0; - sc->debug = 0; - - if (!mcd_find(iot, ioh, sc)) { - printf(": mcd_find failed\n"); - return; - } - - timeout_set(&sc->sc_pi_tmo, mcd_pseudointr, sc); - - /* - * Initialize and attach the disk structure. - */ - sc->sc_dk.dk_name = sc->sc_dev.dv_xname; - disk_attach(&sc->sc_dev, &sc->sc_dk); - - printf(": model %s\n", sc->type != 0 ? sc->type : "unknown"); - - (void) mcd_setlock(sc, MCD_LK_UNLOCK); - - mbx.cmd.opcode = MCD_CMDCONFIGDRIVE; - mbx.cmd.length = sizeof(mbx.cmd.data.config) - 1; - mbx.cmd.data.config.subcommand = MCD_CF_IRQENABLE; - mbx.cmd.data.config.data1 = 0x01; - mbx.res.length = 0; - (void) mcd_send(sc, &mbx, 0); - - mcd_soft_reset(sc); - - sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, - IPL_BIO, mcdintr, sc, sc->sc_dev.dv_xname); -} - -int -mcdopen(dev, flag, fmt, p) - dev_t dev; - int flag, fmt; - struct proc *p; -{ - int error; - int unit, part; - struct mcd_softc *sc; - - unit = DISKUNIT(dev); - if (unit >= mcd_cd.cd_ndevs) - return ENXIO; - sc = mcd_cd.cd_devs[unit]; - if (!sc) - return ENXIO; - - if ((error = disk_lock(&sc->sc_dk)) != 0) - return error; - - if (sc->sc_dk.dk_openmask != 0) { - /* - * If any partition is open, but the disk has been invalidated, - * disallow further opens. - */ - if ((sc->flags & MCDF_LOADED) == 0) { - error = EIO; - goto bad3; - } - } else { - /* - * Lock the drawer. This will also notice any pending disk - * change or door open indicator and clear the MCDF_LOADED bit - * if necessary. - */ - (void) mcd_setlock(sc, MCD_LK_LOCK); - - if ((sc->flags & MCDF_LOADED) == 0) { - /* Partially reset the state. */ - sc->lastmode = MCD_MD_UNKNOWN; - sc->lastupc = MCD_UPC_UNKNOWN; - - sc->flags |= MCDF_LOADED; - - /* Set the mode, causing the disk to spin up. */ - if ((error = mcd_setmode(sc, MCD_MD_COOKED)) != 0) - goto bad2; - - /* Load the physical device parameters. */ - if (mcd_get_parms(sc) != 0) { - error = ENXIO; - goto bad2; - } - - /* Read the table of contents. */ - if ((error = mcd_read_toc(sc)) != 0) - goto bad2; - - /* Fabricate a disk label. */ - mcdgetdisklabel(dev, sc, sc->sc_dk.dk_label, 0); - } - } - - MCD_TRACE("open: partition=%d disksize=%d blksize=%d\n", part, - sc->disksize, sc->blksize, 0); - - part = DISKPART(dev); - - /* Check that the partition exists. */ - if (part != RAW_PART && - (part >= sc->sc_dk.dk_label->d_npartitions || - sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) { - error = ENXIO; - goto bad; - } - - /* Insure only one open at a time. */ - switch (fmt) { - case S_IFCHR: - sc->sc_dk.dk_copenmask |= (1 << part); - break; - case S_IFBLK: - sc->sc_dk.dk_bopenmask |= (1 << part); - break; - } - sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; - - disk_unlock(&sc->sc_dk); - return 0; - -bad2: - sc->flags &= ~MCDF_LOADED; - -bad: - if (sc->sc_dk.dk_openmask == 0) { -#if 0 - (void) mcd_setmode(sc, MCD_MD_SLEEP); -#endif - (void) mcd_setlock(sc, MCD_LK_UNLOCK); - } - -bad3: - disk_unlock(&sc->sc_dk); - return error; -} - -int -mcdclose(dev, flag, fmt, p) - dev_t dev; - int flag, fmt; - struct proc *p; -{ - struct mcd_softc *sc = mcd_cd.cd_devs[DISKUNIT(dev)]; - int part = DISKPART(dev); - - MCD_TRACE("close: partition=%d\n", part, 0, 0, 0); - - disk_lock_nointr(&sc->sc_dk); - - switch (fmt) { - case S_IFCHR: - sc->sc_dk.dk_copenmask &= ~(1 << part); - break; - case S_IFBLK: - sc->sc_dk.dk_bopenmask &= ~(1 << part); - break; - } - sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; - - if (sc->sc_dk.dk_openmask == 0) { - /* XXXX Must wait for I/O to complete! */ - -#if 0 - (void) mcd_setmode(sc, MCD_MD_SLEEP); -#endif - (void) mcd_setlock(sc, MCD_LK_UNLOCK); - if (sc->flags & MCDF_EJECTING) { - mcd_eject(sc); - sc->flags &= ~MCDF_EJECTING; - } - } - disk_unlock(&sc->sc_dk); - return 0; -} - -void -mcdstrategy(bp) - struct buf *bp; -{ - struct mcd_softc *sc = mcd_cd.cd_devs[DISKUNIT(bp->b_dev)]; - int s; - - /* Test validity. */ - MCD_TRACE("strategy: buf=0x%lx blkno=%lld bcount=%ld\n", bp, - bp->b_blkno, bp->b_bcount, 0); - if (bp->b_blkno < 0 || - (bp->b_bcount % sc->blksize) != 0) { - printf("%s: strategy: blkno = %lld bcount = %ld\n", - sc->sc_dev.dv_xname, bp->b_blkno, bp->b_bcount); - bp->b_error = EINVAL; - goto bad; - } - - /* If device invalidated (e.g. media change, door open), error. */ - if ((sc->flags & MCDF_LOADED) == 0) { - MCD_TRACE("strategy: drive not valid\n", 0, 0, 0, 0); - bp->b_error = EIO; - goto bad; - } - - /* No data to read. */ - if (bp->b_bcount == 0) - goto done; - - /* - * Do bounds checking, adjust transfer. if error, process. - * If end of partition, just return. - */ - if (bounds_check_with_label(bp, sc->sc_dk.dk_label) <= 0) - goto done; - - /* Queue it. */ - s = splbio(); - disksort(&sc->buf_queue, bp); - splx(s); - if (!sc->buf_queue.b_active) - mcdstart(sc); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - bp->b_resid = bp->b_bcount; - s = splbio(); - biodone(bp); - splx(s); -} - -void -mcdstart(sc) - struct mcd_softc *sc; -{ - struct buf *bp, *dp = &sc->buf_queue; - int s; - -loop: - s = splbio(); - - bp = dp->b_actf; - if (bp == NULL) { - /* Nothing to do. */ - dp->b_active = 0; - splx(s); - return; - } - - /* Block found to process; dequeue. */ - MCD_TRACE("start: found block bp=0x%x\n", bp, 0, 0, 0); - dp->b_actf = bp->b_actf; - splx(s); - - /* Changed media? */ - if ((sc->flags & MCDF_LOADED) == 0) { - MCD_TRACE("start: drive not valid\n", 0, 0, 0, 0); - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - s = splbio(); - biodone(bp); - splx(s); - goto loop; - } - - dp->b_active = 1; - - /* Instrumentation. */ - s = splbio(); - disk_busy(&sc->sc_dk); - splx(s); - - sc->mbx.retry = MCD_RDRETRIES; - sc->mbx.bp = bp; - sc->mbx.blkno = bp->b_blkno / (sc->blksize / DEV_BSIZE); - if (DISKPART(bp->b_dev) != RAW_PART) { - struct partition *p; - p = &sc->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)]; - sc->mbx.blkno += DL_GETPOFFSET(p); - } - sc->mbx.nblk = bp->b_bcount / sc->blksize; - sc->mbx.sz = sc->blksize; - sc->mbx.skip = 0; - sc->mbx.state = MCD_S_BEGIN; - sc->mbx.mode = MCD_MD_COOKED; - - s = splbio(); - (void) mcdintr(sc); - splx(s); -} - -int -mcdread(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - - return (physio(mcdstrategy, dev, B_READ, minphys, uio)); -} - -int -mcdwrite(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - - return (physio(mcdstrategy, dev, B_WRITE, minphys, uio)); -} - -int -mcdioctl(dev, cmd, addr, flag, p) - dev_t dev; - u_long cmd; - caddr_t addr; - int flag; - struct proc *p; -{ - struct mcd_softc *sc = mcd_cd.cd_devs[DISKUNIT(dev)]; - struct disklabel *lp; - int error; - - MCD_TRACE("ioctl: cmd=0x%x\n", cmd, 0, 0, 0); - - if ((sc->flags & MCDF_LOADED) == 0) - return EIO; - - switch (cmd) { - case DIOCRLDINFO: - lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK); - mcdgetdisklabel(dev, sc, lp, 0); - bcopy(lp, sc->sc_dk.dk_label, sizeof(*lp)); - free(lp, M_TEMP); - return 0; - - case DIOCGDINFO: - case DIOCGPDINFO: - *(struct disklabel *)addr = *(sc->sc_dk.dk_label); - return 0; - - case DIOCGPART: - ((struct partinfo *)addr)->disklab = sc->sc_dk.dk_label; - ((struct partinfo *)addr)->part = - &sc->sc_dk.dk_label->d_partitions[DISKPART(dev)]; - return 0; - - case DIOCWDINFO: - case DIOCSDINFO: - if ((flag & FWRITE) == 0) - return EBADF; - - if ((error = disk_lock(&sc->sc_dk)) != 0) - return error; - - error = setdisklabel(sc->sc_dk.dk_label, - (struct disklabel *)addr, /*sc->sc_dk.dk_openmask : */0); - if (error == 0) { - } - - disk_unlock(&sc->sc_dk); - return error; - - case CDIOCPLAYTRACKS: - return mcd_playtracks(sc, (struct ioc_play_track *)addr); - case CDIOCPLAYMSF: - return mcd_playmsf(sc, (struct ioc_play_msf *)addr); - case CDIOCPLAYBLOCKS: - return mcd_playblocks(sc, (struct ioc_play_blocks *)addr); - case CDIOCREADSUBCHANNEL: - return mcd_read_subchannel(sc, (struct ioc_read_subchannel *)addr); - case CDIOREADTOCHEADER: - return mcd_toc_header(sc, (struct ioc_toc_header *)addr); - case CDIOREADTOCENTRYS: - return mcd_toc_entries(sc, (struct ioc_read_toc_entry *)addr); - case CDIOCSETPATCH: - case CDIOCGETVOL: - case CDIOCSETVOL: - case CDIOCSETMONO: - case CDIOCSETSTEREO: - case CDIOCSETMUTE: - case CDIOCSETLEFT: - case CDIOCSETRIGHT: - return EINVAL; - case CDIOCRESUME: - return mcd_resume(sc); - case CDIOCPAUSE: - return mcd_pause(sc); - case CDIOCSTART: - return EINVAL; - case CDIOCSTOP: - return mcd_stop(sc); - case MTIOCTOP: - if (((struct mtop *)addr)->mt_op != MTOFFL) - return EIO; - /* FALLTHROUGH */ - case CDIOCEJECT: /* FALLTHROUGH */ - case DIOCEJECT: - sc->flags |= MCDF_EJECTING; - return (0); - case CDIOCALLOW: - return mcd_setlock(sc, MCD_LK_UNLOCK); - case CDIOCPREVENT: - return mcd_setlock(sc, MCD_LK_LOCK); - case DIOCLOCK: - return mcd_setlock(sc, - (*(int *)addr) ? MCD_LK_LOCK : MCD_LK_UNLOCK); - case CDIOCSETDEBUG: - sc->debug = 1; - return 0; - case CDIOCCLRDEBUG: - sc->debug = 0; - return 0; - case CDIOCRESET: - return mcd_hard_reset(sc); - - default: - return ENOTTY; - } - -#ifdef DIAGNOSTIC - panic("mcdioctl: impossible"); -#endif -} - -int -mcdgetdisklabel(dev, sc, lp, spoofonly) - dev_t dev; - struct mcd_softc *sc; - struct disklabel *lp; - int spoofonly; -{ - bzero(lp, sizeof(struct disklabel)); - - lp->d_secsize = sc->blksize; - lp->d_ntracks = 1; - lp->d_nsectors = 100; - lp->d_ncylinders = (sc->disksize / 100) + 1; - lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; - if (lp->d_secpercyl == 0) { - lp->d_secpercyl = 100; - /* as long as it's not 0 - readdisklabel divides by it */ - } - - strncpy(lp->d_typename, "Mitsumi CD-ROM", sizeof lp->d_typename); - lp->d_type = DTYPE_SCSI; /* XXX */ - strncpy(lp->d_packname, "fictitious", sizeof lp->d_packname); - DL_SETDSIZE(lp, sc->disksize); - lp->d_version = 1; - - lp->d_magic = DISKMAGIC; - lp->d_magic2 = DISKMAGIC; - lp->d_checksum = dkcksum(lp); - - /* - * Call the generic disklabel extraction routine - */ - return (readdisklabel(DISKLABELDEV(dev), mcdstrategy, lp, spoofonly)); -} - -int -mcd_get_parms(sc) - struct mcd_softc *sc; -{ - struct mcd_mbox mbx; - daddr64_t size; - int error; - - /* Send volume info command. */ - mbx.cmd.opcode = MCD_CMDGETVOLINFO; - mbx.cmd.length = 0; - mbx.res.length = sizeof(mbx.res.data.volinfo); - if ((error = mcd_send(sc, &mbx, 1)) != 0) - return error; - - if (mbx.res.data.volinfo.trk_low == 0x00 && - mbx.res.data.volinfo.trk_high == 0x00) - return EINVAL; - - /* Volinfo is OK. */ - sc->volinfo = mbx.res.data.volinfo; - sc->blksize = MCD_BLKSIZE_COOKED; - size = msf2hsg(sc->volinfo.vol_msf, 0); - sc->disksize = size * (MCD_BLKSIZE_COOKED / DEV_BSIZE); - return 0; -} - -daddr64_t -mcdsize(dev) - dev_t dev; -{ - - /* CD-ROMs are read-only. */ - return -1; -} - -int -mcddump(dev, blkno, va, size) - dev_t dev; - daddr64_t blkno; - caddr_t va; - size_t size; -{ - - /* Not implemented. */ - return ENXIO; -} - -/* - * Find the board and fill in the softc. - */ -int -mcd_find(iot, ioh, sc) - bus_space_tag_t iot; - bus_space_handle_t ioh; - struct mcd_softc *sc; -{ - int i; - struct mcd_mbox mbx; - - sc->sc_iot = iot; - sc->sc_ioh = ioh; - - /* Send a reset. */ - bus_space_write_1(iot, ioh, MCD_RESET, 0); - delay(1000000); - /* Get any pending status and throw away. */ - for (i = 10; i; i--) - bus_space_read_1(iot, ioh, MCD_STATUS); - delay(1000); - - /* Send get status command. */ - mbx.cmd.opcode = MCD_CMDGETSTAT; - mbx.cmd.length = 0; - mbx.res.length = 0; - if (mcd_send(sc, &mbx, 0) != 0) - return 0; - - /* Get info about the drive. */ - mbx.cmd.opcode = MCD_CMDCONTINFO; - mbx.cmd.length = 0; - mbx.res.length = sizeof(mbx.res.data.continfo); - if (mcd_send(sc, &mbx, 0) != 0) - return 0; - - /* - * The following is code which is not guaranteed to work for all - * drives, because the meaning of the expected 'M' is not clear - * (M_itsumi is an obvious assumption, but I don't trust that). - * Also, the original hack had a bogus condition that always - * returned true. - * - * Note: Which models support interrupts? >=LU005S? - */ - sc->readcmd = MCD_CMDREADSINGLESPEED; - switch (mbx.res.data.continfo.code) { - case 'M': - if (mbx.res.data.continfo.version <= 2) - sc->type = "LU002S"; - else if (mbx.res.data.continfo.version <= 5) - sc->type = "LU005S"; - else - sc->type = "LU006S"; - break; - case 'F': - sc->type = "FX001"; - break; - case 'D': - sc->type = "FX001D"; - sc->readcmd = MCD_CMDREADDOUBLESPEED; - break; - default: -#ifdef MCDDEBUG - printf("%s: unrecognized drive version %c%02x; will try to use it anyway\n", - sc->sc_dev.dv_xname, - mbx.res.data.continfo.code, mbx.res.data.continfo.version); -#endif - sc->type = 0; - break; - } - - return 1; - -} - -int -mcdprobe(parent, match, aux) - struct device *parent; - void *match; - void *aux; -{ - struct isa_attach_args *ia = aux; - struct mcd_softc sc; - bus_space_tag_t iot = ia->ia_iot; - bus_space_handle_t ioh; - int rv; - - /* Disallow wildcarded i/o address. */ - if (ia->ia_iobase == -1 /*ISACF_PORT_DEFAULT*/) - return (0); - - /* Map i/o space */ - if (bus_space_map(iot, ia->ia_iobase, MCD_NPORT, 0, &ioh)) - return 0; - - if (!opti_cd_setup(OPTI_MITSUMI, ia->ia_iobase, ia->ia_irq, ia->ia_drq)) - /* printf("mcdprobe: could not setup OPTi chipset.\n") */; - - bzero(&sc, sizeof sc); - sc.debug = 0; - sc.probe = 1; - - rv = mcd_find(iot, ioh, &sc); - - bus_space_unmap(iot, ioh, MCD_NPORT); - - if (rv) { - ia->ia_iosize = MCD_NPORT; - ia->ia_msize = 0; - } - - return (rv); -} - -int -mcd_getreply(sc) - struct mcd_softc *sc; -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - int i; - - /* Wait until xfer port senses data ready. */ - for (i = DELAY_GETREPLY; i; i--) { - if ((bus_space_read_1(iot, ioh, MCD_XFER) & - MCD_XF_STATUSUNAVAIL) == 0) - break; - delay(DELAY_GRANULARITY); - } - if (!i) - return -1; - - /* Get the data. */ - return bus_space_read_1(iot, ioh, MCD_STATUS); -} - -int -mcd_getstat(sc) - struct mcd_softc *sc; -{ - struct mcd_mbox mbx; - - mbx.cmd.opcode = MCD_CMDGETSTAT; - mbx.cmd.length = 0; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 1); -} - -int -mcd_getresult(sc, res) - struct mcd_softc *sc; - struct mcd_result *res; -{ - int i, x; - - if (sc->debug) - printf("%s: mcd_getresult: %d", sc->sc_dev.dv_xname, - res->length); - - if ((x = mcd_getreply(sc)) < 0) { - if (sc->debug) - printf(" timeout\n"); - else if (sc->probe == 0) - printf("%s: timeout in getresult\n", sc->sc_dev.dv_xname); - return EIO; - } - if (sc->debug) - printf(" %02x", (u_int)x); - sc->status = x; - mcd_setflags(sc); - - if ((sc->status & MCD_ST_CMDCHECK) != 0) - return EINVAL; - - for (i = 0; i < res->length; i++) { - if ((x = mcd_getreply(sc)) < 0) { - if (sc->debug) - printf(" timeout\n"); - else - printf("%s: timeout in getresult\n", sc->sc_dev.dv_xname); - return EIO; - } - if (sc->debug) - printf(" %02x", (u_int)x); - res->data.raw.data[i] = x; - } - - if (sc->debug) - printf(" succeeded\n"); - -#ifdef MCDDEBUG - delay(10); - while ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, MCD_XFER) & - MCD_XF_STATUSUNAVAIL) == 0) { - x = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MCD_STATUS); - printf("%s: got extra byte %02x during getstatus\n", - sc->sc_dev.dv_xname, (u_int)x); - delay(10); - } -#endif - - return 0; -} - -void -mcd_setflags(sc) - struct mcd_softc *sc; -{ - - /* Check flags. */ - if ((sc->flags & MCDF_LOADED) != 0 && - (sc->status & (MCD_ST_DSKCHNG | MCD_ST_DSKIN | MCD_ST_DOOROPEN)) != - MCD_ST_DSKIN) { - if ((sc->status & MCD_ST_DOOROPEN) != 0) - printf("%s: door open\n", sc->sc_dev.dv_xname); - else if ((sc->status & MCD_ST_DSKIN) == 0) - printf("%s: no disk present\n", sc->sc_dev.dv_xname); - else if ((sc->status & MCD_ST_DSKCHNG) != 0) - printf("%s: media change\n", sc->sc_dev.dv_xname); - sc->flags &= ~MCDF_LOADED; - } - - if ((sc->status & MCD_ST_AUDIOBSY) != 0) - sc->audio_status = CD_AS_PLAY_IN_PROGRESS; - else if (sc->audio_status == CD_AS_PLAY_IN_PROGRESS || - sc->audio_status == CD_AS_AUDIO_INVALID) - sc->audio_status = CD_AS_PLAY_COMPLETED; -} - -int -mcd_send(sc, mbx, diskin) - struct mcd_softc *sc; - struct mcd_mbox *mbx; - int diskin; -{ - int retry, i, error; - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - - if (sc->debug) { - printf("%s: mcd_send: %d %02x", sc->sc_dev.dv_xname, - mbx->cmd.length, (u_int)mbx->cmd.opcode); - for (i = 0; i < mbx->cmd.length; i++) - printf(" %02x", (u_int)mbx->cmd.data.raw.data[i]); - printf("\n"); - } - - for (retry = MCD_RETRIES; retry; retry--) { - bus_space_write_1(iot, ioh, MCD_COMMAND, mbx->cmd.opcode); - for (i = 0; i < mbx->cmd.length; i++) - bus_space_write_1(iot, ioh, MCD_COMMAND, mbx->cmd.data.raw.data[i]); - if ((error = mcd_getresult(sc, &mbx->res)) == 0) - break; - if (error == EINVAL) - return error; - } - if (!retry) - return error; - if (diskin && (sc->flags & MCDF_LOADED) == 0) - return EIO; - - return 0; -} - -static void -hsg2msf(hsg, msf) - 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 daddr64_t -msf2hsg(msf, relative) - bcd_t *msf; - int relative; -{ - daddr64_t blkno; - - blkno = bcd2bin(M_msf(msf)) * 75 * 60 + - bcd2bin(S_msf(msf)) * 75 + - bcd2bin(F_msf(msf)); - if (!relative) - blkno -= 150; - return blkno; -} - -void -mcd_pseudointr(v) - void *v; -{ - struct mcd_softc *sc = v; - int s; - - s = splbio(); - (void) mcdintr(sc); - splx(s); -} - -/* - * State machine to process read requests. - * Initialize with MCD_S_BEGIN: calculate sizes, and set mode - * MCD_S_WAITMODE: waits for status reply from set mode, set read command - * MCD_S_WAITREAD: wait for read ready, read data. - */ -int -mcdintr(arg) - void *arg; -{ - struct mcd_softc *sc = arg; - struct mcd_mbx *mbx = &sc->mbx; - struct buf *bp = mbx->bp; - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - - int i; - u_char x; - bcd_t msf[3]; - - switch (mbx->state) { - case MCD_S_IDLE: - return 0; - - case MCD_S_BEGIN: - tryagain: - if (mbx->mode == sc->lastmode) - goto firstblock; - - sc->lastmode = MCD_MD_UNKNOWN; - bus_space_write_1(iot, ioh, MCD_COMMAND, MCD_CMDSETMODE); - bus_space_write_1(iot, ioh, MCD_COMMAND, mbx->mode); - - mbx->count = RDELAY_WAITMODE; - mbx->state = MCD_S_WAITMODE; - - case MCD_S_WAITMODE: - timeout_del(&sc->sc_pi_tmo); - for (i = 20; i; i--) { - x = bus_space_read_1(iot, ioh, MCD_XFER); - if ((x & MCD_XF_STATUSUNAVAIL) == 0) - break; - delay(50); - } - if (i == 0) - goto hold; - sc->status = bus_space_read_1(iot, ioh, MCD_STATUS); - mcd_setflags(sc); - if ((sc->flags & MCDF_LOADED) == 0) - goto changed; - MCD_TRACE("doread: got WAITMODE delay=%d\n", - RDELAY_WAITMODE - mbx->count, 0, 0, 0); - - sc->lastmode = mbx->mode; - - firstblock: - MCD_TRACE("doread: read blkno=%lld for bp=0x%x\n", mbx->blkno, - bp, 0, 0); - - /* Build parameter block. */ - hsg2msf(mbx->blkno, msf); - - /* Send the read command. */ - bus_space_write_1(iot, ioh, MCD_COMMAND, sc->readcmd); - bus_space_write_1(iot, ioh, MCD_COMMAND, msf[0]); - bus_space_write_1(iot, ioh, MCD_COMMAND, msf[1]); - bus_space_write_1(iot, ioh, MCD_COMMAND, msf[2]); - bus_space_write_1(iot, ioh, MCD_COMMAND, 0); - bus_space_write_1(iot, ioh, MCD_COMMAND, 0); - bus_space_write_1(iot, ioh, MCD_COMMAND, mbx->nblk); - - mbx->count = RDELAY_WAITREAD; - mbx->state = MCD_S_WAITREAD; - - case MCD_S_WAITREAD: - timeout_del(&sc->sc_pi_tmo); - nextblock: - loop: - for (i = 20; i; i--) { - x = bus_space_read_1(iot, ioh, MCD_XFER); - if ((x & MCD_XF_DATAUNAVAIL) == 0) - goto gotblock; - if ((x & MCD_XF_STATUSUNAVAIL) == 0) - break; - delay(50); - } - if (i == 0) - goto hold; - sc->status = bus_space_read_1(iot, ioh, MCD_STATUS); - mcd_setflags(sc); - if ((sc->flags & MCDF_LOADED) == 0) - goto changed; -#if 0 - printf("%s: got status byte %02x during read\n", - sc->sc_dev.dv_xname, (u_int)sc->status); -#endif - goto loop; - - gotblock: - MCD_TRACE("doread: got data delay=%d\n", - RDELAY_WAITREAD - mbx->count, 0, 0, 0); - - /* Data is ready. */ - bus_space_write_1(iot, ioh, MCD_CTL2, 0x04); /* XXX */ - bus_space_read_multi_1(iot, ioh, MCD_RDATA, - bp->b_data + mbx->skip, mbx->sz); - bus_space_write_1(iot, ioh, MCD_CTL2, 0x0c); /* XXX */ - mbx->blkno += 1; - mbx->skip += mbx->sz; - if (--mbx->nblk > 0) - goto nextblock; - - mbx->state = MCD_S_IDLE; - - /* Return buffer. */ - bp->b_resid = 0; - disk_unbusy(&sc->sc_dk, bp->b_bcount, (bp->b_flags & B_READ)); - biodone(bp); - - mcdstart(sc); - return 1; - - hold: - if (mbx->count-- < 0) { - printf("%s: timeout in state %d", - sc->sc_dev.dv_xname, mbx->state); - goto readerr; - } - -#if 0 - printf("%s: sleep in state %d\n", sc->sc_dev.dv_xname, - mbx->state); -#endif - timeout_add(&sc->sc_pi_tmo, hz / 100); - return -1; - } - -readerr: - if (mbx->retry-- > 0) { - printf("; retrying\n"); - goto tryagain; - } else - printf("; giving up\n"); - -changed: - /* Invalidate the buffer. */ - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount - mbx->skip; - disk_unbusy(&sc->sc_dk, (bp->b_bcount - bp->b_resid), - (bp->b_flags & B_READ)); - biodone(bp); - - mcdstart(sc); - return -1; - -#ifdef notyet - printf("%s: unit timeout; resetting\n", sc->sc_dev.dv_xname); - bus_space_write_1(iot, ioh, MCD_RESET, MCD_CMDRESET); - delay(300000); - (void) mcd_getstat(sc, 1); - (void) mcd_getstat(sc, 1); - /*sc->status &= ~MCD_ST_DSKCHNG; */ - sc->debug = 1; /* preventive set debug mode */ -#endif -} - -void -mcd_soft_reset(sc) - struct mcd_softc *sc; -{ - - sc->debug = 0; - sc->flags = 0; - sc->lastmode = MCD_MD_UNKNOWN; - sc->lastupc = MCD_UPC_UNKNOWN; - sc->audio_status = CD_AS_AUDIO_INVALID; - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MCD_CTL2, 0x0c); /* XXX */ -} - -int -mcd_hard_reset(sc) - struct mcd_softc *sc; -{ - struct mcd_mbox mbx; - - mcd_soft_reset(sc); - - mbx.cmd.opcode = MCD_CMDRESET; - mbx.cmd.length = 0; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 0); -} - -int -mcd_setmode(sc, mode) - struct mcd_softc *sc; - int mode; -{ - struct mcd_mbox mbx; - int error; - - if (sc->lastmode == mode) - return 0; - if (sc->debug) - printf("%s: setting mode to %d\n", sc->sc_dev.dv_xname, mode); - sc->lastmode = MCD_MD_UNKNOWN; - - mbx.cmd.opcode = MCD_CMDSETMODE; - mbx.cmd.length = sizeof(mbx.cmd.data.datamode); - mbx.cmd.data.datamode.mode = mode; - mbx.res.length = 0; - if ((error = mcd_send(sc, &mbx, 1)) != 0) - return error; - - sc->lastmode = mode; - return 0; -} - -int -mcd_setupc(sc, upc) - struct mcd_softc *sc; - int upc; -{ - struct mcd_mbox mbx; - int error; - - if (sc->lastupc == upc) - return 0; - if (sc->debug) - printf("%s: setting upc to %d\n", sc->sc_dev.dv_xname, upc); - sc->lastupc = MCD_UPC_UNKNOWN; - - mbx.cmd.opcode = MCD_CMDCONFIGDRIVE; - mbx.cmd.length = sizeof(mbx.cmd.data.config) - 1; - mbx.cmd.data.config.subcommand = MCD_CF_READUPC; - mbx.cmd.data.config.data1 = upc; - mbx.res.length = 0; - if ((error = mcd_send(sc, &mbx, 1)) != 0) - return error; - - sc->lastupc = upc; - return 0; -} - -int -mcd_toc_header(sc, th) - struct mcd_softc *sc; - struct ioc_toc_header *th; -{ - - if (sc->debug) - printf("%s: mcd_toc_header: reading toc header\n", - sc->sc_dev.dv_xname); - - th->len = msf2hsg(sc->volinfo.vol_msf, 0); - th->starting_track = bcd2bin(sc->volinfo.trk_low); - th->ending_track = bcd2bin(sc->volinfo.trk_high); - - return 0; -} - -int -mcd_read_toc(sc) - struct mcd_softc *sc; -{ - struct ioc_toc_header th; - union mcd_qchninfo q; - int error, trk, idx, retry; - - if ((error = mcd_toc_header(sc, &th)) != 0) - return error; - - if ((error = mcd_stop(sc)) != 0) - return error; - - if (sc->debug) - printf("%s: read_toc: reading qchannel info\n", - sc->sc_dev.dv_xname); - - for (trk = th.starting_track; trk <= th.ending_track; trk++) - sc->toc[trk].toc.idx_no = 0x00; - trk = th.ending_track - th.starting_track + 1; - for (retry = 300; retry && trk > 0; retry--) { - if (mcd_getqchan(sc, &q, CD_TRACK_INFO) != 0) - break; - if (q.toc.trk_no != 0x00 || q.toc.idx_no == 0x00) - continue; - idx = bcd2bin(q.toc.idx_no); - if (idx < MCD_MAXTOCS && - sc->toc[idx].toc.idx_no == 0x00) { - sc->toc[idx] = q; - trk--; - } - } - - /* Inform the drive that we're finished so it turns off the light. */ - if ((error = mcd_setmode(sc, MCD_MD_COOKED)) != 0) - return error; - - if (trk != 0) - return EINVAL; - - /* Add a fake last+1 for mcd_playtracks(). */ - idx = th.ending_track + 1; - sc->toc[idx].toc.control = sc->toc[idx-1].toc.control; - sc->toc[idx].toc.addr_type = sc->toc[idx-1].toc.addr_type; - sc->toc[idx].toc.trk_no = 0x00; - sc->toc[idx].toc.idx_no = 0xaa; - sc->toc[idx].toc.absolute_pos[0] = sc->volinfo.vol_msf[0]; - sc->toc[idx].toc.absolute_pos[1] = sc->volinfo.vol_msf[1]; - sc->toc[idx].toc.absolute_pos[2] = sc->volinfo.vol_msf[2]; - - return 0; -} - -int -mcd_toc_entries(sc, te) - struct mcd_softc *sc; - struct ioc_read_toc_entry *te; -{ - int len = te->data_len; - struct ret_toc { - struct ioc_toc_header header; - struct cd_toc_entry entries[MCD_MAXTOCS]; - } data; - u_char trk; - daddr64_t lba; - int error, n; - - if (len > sizeof(data.entries) || - len < sizeof(struct cd_toc_entry)) - return EINVAL; - if (te->address_format != CD_MSF_FORMAT && - te->address_format != CD_LBA_FORMAT) - return EINVAL; - - /* Copy the TOC header. */ - if ((error = mcd_toc_header(sc, &data.header)) != 0) - return error; - - /* Verify starting track. */ - trk = te->starting_track; - if (trk == 0x00) - trk = data.header.starting_track; - else if (trk == 0xaa) - trk = data.header.ending_track + 1; - else if (trk < data.header.starting_track || - trk > data.header.ending_track + 1) - return EINVAL; - - /* Copy the TOC data. */ - for (n = 0; trk <= data.header.ending_track + 1; trk++) { - if (sc->toc[trk].toc.idx_no == 0x00) - continue; - data.entries[n].control = sc->toc[trk].toc.control; - data.entries[n].addr_type = sc->toc[trk].toc.addr_type; - data.entries[n].track = bcd2bin(sc->toc[trk].toc.idx_no); - switch (te->address_format) { - case CD_MSF_FORMAT: - data.entries[n].addr.addr[0] = 0; - data.entries[n].addr.addr[1] = - bcd2bin(sc->toc[trk].toc.absolute_pos[0]); - data.entries[n].addr.addr[2] = - bcd2bin(sc->toc[trk].toc.absolute_pos[1]); - data.entries[n].addr.addr[3] = - bcd2bin(sc->toc[trk].toc.absolute_pos[2]); - break; - case CD_LBA_FORMAT: - lba = msf2hsg(sc->toc[trk].toc.absolute_pos, 0); - data.entries[n].addr.addr[0] = lba >> 24; - data.entries[n].addr.addr[1] = lba >> 16; - data.entries[n].addr.addr[2] = lba >> 8; - data.entries[n].addr.addr[3] = lba; - break; - } - n++; - } - - len = min(len, n * sizeof(struct cd_toc_entry)); - - /* Copy the data back. */ - return copyout(&data.entries[0], te->data, len); -} - -int -mcd_stop(sc) - struct mcd_softc *sc; -{ - struct mcd_mbox mbx; - int error; - - if (sc->debug) - printf("%s: mcd_stop: stopping play\n", sc->sc_dev.dv_xname); - - mbx.cmd.opcode = MCD_CMDSTOPAUDIO; - mbx.cmd.length = 0; - mbx.res.length = 0; - if ((error = mcd_send(sc, &mbx, 1)) != 0) - return error; - - sc->audio_status = CD_AS_PLAY_COMPLETED; - return 0; -} - -int -mcd_getqchan(sc, q, qchn) - struct mcd_softc *sc; - union mcd_qchninfo *q; - int qchn; -{ - struct mcd_mbox mbx; - int error; - - if (qchn == CD_TRACK_INFO) { - if ((error = mcd_setmode(sc, MCD_MD_TOC)) != 0) - return error; - } else { - if ((error = mcd_setmode(sc, MCD_MD_COOKED)) != 0) - return error; - } - if (qchn == CD_MEDIA_CATALOG) { - if ((error = mcd_setupc(sc, MCD_UPC_ENABLE)) != 0) - return error; - } else { - if ((error = mcd_setupc(sc, MCD_UPC_DISABLE)) != 0) - return error; - } - - mbx.cmd.opcode = MCD_CMDGETQCHN; - mbx.cmd.length = 0; - mbx.res.length = sizeof(mbx.res.data.qchninfo); - if ((error = mcd_send(sc, &mbx, 1)) != 0) - return error; - - *q = mbx.res.data.qchninfo; - return 0; -} - -int -mcd_read_subchannel(sc, ch) - struct mcd_softc *sc; - struct ioc_read_subchannel *ch; -{ - int len = ch->data_len; - union mcd_qchninfo q; - struct cd_sub_channel_info data; - daddr64_t lba; - int error; - - if (sc->debug) - printf("%s: subchan: af=%d df=%d\n", sc->sc_dev.dv_xname, - ch->address_format, ch->data_format); - - if (len > sizeof(data) || - len < sizeof(struct cd_sub_channel_header)) - return EINVAL; - if (ch->address_format != CD_MSF_FORMAT && - ch->address_format != CD_LBA_FORMAT) - return EINVAL; - if (ch->data_format != CD_CURRENT_POSITION && - ch->data_format != CD_MEDIA_CATALOG) - return EINVAL; - - if ((error = mcd_getqchan(sc, &q, ch->data_format)) != 0) - return error; - - data.header.audio_status = sc->audio_status; - data.what.media_catalog.data_format = ch->data_format; - - switch (ch->data_format) { - case CD_MEDIA_CATALOG: - data.what.media_catalog.mc_valid = 1; -#if 0 - data.what.media_catalog.mc_number = -#endif - break; - - case CD_CURRENT_POSITION: - data.what.position.track_number = bcd2bin(q.current.trk_no); - data.what.position.index_number = bcd2bin(q.current.idx_no); - switch (ch->address_format) { - case CD_MSF_FORMAT: - data.what.position.reladdr.addr[0] = 0; - data.what.position.reladdr.addr[1] = - bcd2bin(q.current.relative_pos[0]); - data.what.position.reladdr.addr[2] = - bcd2bin(q.current.relative_pos[1]); - data.what.position.reladdr.addr[3] = - bcd2bin(q.current.relative_pos[2]); - data.what.position.absaddr.addr[0] = 0; - data.what.position.absaddr.addr[1] = - bcd2bin(q.current.absolute_pos[0]); - data.what.position.absaddr.addr[2] = - bcd2bin(q.current.absolute_pos[1]); - data.what.position.absaddr.addr[3] = - bcd2bin(q.current.absolute_pos[2]); - break; - case CD_LBA_FORMAT: - lba = msf2hsg(q.current.relative_pos, 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 == 0x00) - lba = -lba; - data.what.position.reladdr.addr[0] = lba >> 24; - data.what.position.reladdr.addr[1] = lba >> 16; - data.what.position.reladdr.addr[2] = lba >> 8; - data.what.position.reladdr.addr[3] = lba; - lba = msf2hsg(q.current.absolute_pos, 0); - data.what.position.absaddr.addr[0] = lba >> 24; - data.what.position.absaddr.addr[1] = lba >> 16; - data.what.position.absaddr.addr[2] = lba >> 8; - data.what.position.absaddr.addr[3] = lba; - break; - } - break; - } - - return copyout(&data, ch->data, len); -} - -int -mcd_playtracks(sc, p) - struct mcd_softc *sc; - struct ioc_play_track *p; -{ - struct mcd_mbox mbx; - int a = p->start_track; - int z = p->end_track; - int error; - - if (sc->debug) - printf("%s: playtracks: from %d:%d to %d:%d\n", - sc->sc_dev.dv_xname, - a, p->start_index, z, p->end_index); - - if (a < bcd2bin(sc->volinfo.trk_low) || - a > bcd2bin(sc->volinfo.trk_high) || - a > z || - z < bcd2bin(sc->volinfo.trk_low) || - z > bcd2bin(sc->volinfo.trk_high)) - return EINVAL; - - if ((error = mcd_setmode(sc, MCD_MD_COOKED)) != 0) - return error; - - mbx.cmd.opcode = MCD_CMDREADSINGLESPEED; - mbx.cmd.length = sizeof(mbx.cmd.data.play); - mbx.cmd.data.play.start_msf[0] = sc->toc[a].toc.absolute_pos[0]; - mbx.cmd.data.play.start_msf[1] = sc->toc[a].toc.absolute_pos[1]; - mbx.cmd.data.play.start_msf[2] = sc->toc[a].toc.absolute_pos[2]; - mbx.cmd.data.play.end_msf[0] = sc->toc[z+1].toc.absolute_pos[0]; - mbx.cmd.data.play.end_msf[1] = sc->toc[z+1].toc.absolute_pos[1]; - mbx.cmd.data.play.end_msf[2] = sc->toc[z+1].toc.absolute_pos[2]; - sc->lastpb = mbx.cmd; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 1); -} - -int -mcd_playmsf(sc, p) - struct mcd_softc *sc; - struct ioc_play_msf *p; -{ - struct mcd_mbox mbx; - int error; - - if (sc->debug) - printf("%s: playmsf: from %d:%d.%d to %d:%d.%d\n", - sc->sc_dev.dv_xname, - 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)) - return EINVAL; - - if ((error = mcd_setmode(sc, MCD_MD_COOKED)) != 0) - return error; - - mbx.cmd.opcode = MCD_CMDREADSINGLESPEED; - mbx.cmd.length = sizeof(mbx.cmd.data.play); - mbx.cmd.data.play.start_msf[0] = bin2bcd(p->start_m); - mbx.cmd.data.play.start_msf[1] = bin2bcd(p->start_s); - mbx.cmd.data.play.start_msf[2] = bin2bcd(p->start_f); - mbx.cmd.data.play.end_msf[0] = bin2bcd(p->end_m); - mbx.cmd.data.play.end_msf[1] = bin2bcd(p->end_s); - mbx.cmd.data.play.end_msf[2] = bin2bcd(p->end_f); - sc->lastpb = mbx.cmd; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 1); -} - -int -mcd_playblocks(sc, p) - struct mcd_softc *sc; - struct ioc_play_blocks *p; -{ - struct mcd_mbox mbx; - int error; - - if (sc->debug) - printf("%s: playblocks: blkno %lld length %d\n", - sc->sc_dev.dv_xname, p->blk, p->len); - - if (p->blk > sc->disksize || p->len > sc->disksize || - (p->blk + p->len) > sc->disksize) - return 0; - - if ((error = mcd_setmode(sc, MCD_MD_COOKED)) != 0) - return error; - - mbx.cmd.opcode = MCD_CMDREADSINGLESPEED; - mbx.cmd.length = sizeof(mbx.cmd.data.play); - hsg2msf(p->blk, mbx.cmd.data.play.start_msf); - hsg2msf(p->blk + p->len, mbx.cmd.data.play.end_msf); - sc->lastpb = mbx.cmd; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 1); -} - -int -mcd_pause(sc) - struct mcd_softc *sc; -{ - union mcd_qchninfo q; - int error; - - /* Verify current status. */ - if (sc->audio_status != CD_AS_PLAY_IN_PROGRESS) { - printf("%s: pause: attempted when not playing\n", - sc->sc_dev.dv_xname); - return EINVAL; - } - - /* Get the current position. */ - if ((error = mcd_getqchan(sc, &q, CD_CURRENT_POSITION)) != 0) - return error; - - /* Copy it into lastpb. */ - sc->lastpb.data.seek.start_msf[0] = q.current.absolute_pos[0]; - sc->lastpb.data.seek.start_msf[1] = q.current.absolute_pos[1]; - sc->lastpb.data.seek.start_msf[2] = q.current.absolute_pos[2]; - - /* Stop playing. */ - if ((error = mcd_stop(sc)) != 0) - return error; - - /* Set the proper status and exit. */ - sc->audio_status = CD_AS_PLAY_PAUSED; - return 0; -} - -int -mcd_resume(sc) - struct mcd_softc *sc; -{ - struct mcd_mbox mbx; - int error; - - if (sc->audio_status != CD_AS_PLAY_PAUSED) - return EINVAL; - - if ((error = mcd_setmode(sc, MCD_MD_COOKED)) != 0) - return error; - - mbx.cmd = sc->lastpb; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 1); -} - -int -mcd_eject(sc) - struct mcd_softc *sc; -{ - struct mcd_mbox mbx; - - mbx.cmd.opcode = MCD_CMDEJECTDISK; - mbx.cmd.length = 0; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 0); -} - -int -mcd_setlock(sc, mode) - struct mcd_softc *sc; - int mode; -{ - struct mcd_mbox mbx; - - mbx.cmd.opcode = MCD_CMDSETLOCK; - mbx.cmd.length = sizeof(mbx.cmd.data.lockmode); - mbx.cmd.data.lockmode.mode = mode; - mbx.res.length = 0; - return mcd_send(sc, &mbx, 1); -} diff --git a/sys/dev/isa/mcdreg.h b/sys/dev/isa/mcdreg.h deleted file mode 100644 index 9a527d2b892..00000000000 --- a/sys/dev/isa/mcdreg.h +++ /dev/null @@ -1,247 +0,0 @@ -/* $OpenBSD: mcdreg.h,v 1.6 2003/11/16 20:30:06 avsm Exp $ */ -/* $NetBSD: mcdreg.h,v 1.8 1997/04/04 18:59:37 christos Exp $ */ - -/* - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * 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. - */ - -typedef unsigned char bcd_t; -#define M_msf(msf) msf[0] -#define S_msf(msf) msf[1] -#define F_msf(msf) msf[2] - -#define MCD_COMMAND 0 -#define MCD_STATUS 0 -#define MCD_RDATA 0 -#define MCD_RESET 1 -#define MCD_XFER 1 -#define MCD_CTL2 2 /* XXX Is this right? */ -#define MCD_CONFIG 3 -#define MCD_NPORT 4 - -#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 */ - -/* 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_READERR 0x04 -#define MCD_ST_AUDIOBSY 0x02 /* audio disk is playing */ -#define MCD_ST_CMDCHECK 0x01 /* command error */ - -/* Xfer bits */ -#define MCD_XF_STATUSUNAVAIL 0x04 -#define MCD_XF_DATAUNAVAIL 0x02 - -/* Modes */ -#define MCD_MD_TESTMODE 0x80 /* 0 = DATALENGTH is valid */ -#define MCD_MD_DATALENGTH 0x40 /* 1 = read ECC data also */ -#define MCD_MD_ECCMODE 0x20 /* 1 = disable secondary ECC */ -#define MCD_MD_SPINDOWN 0x08 /* 1 = spin down */ -#define MCD_MD_READTOC 0x04 /* 1 = read TOC on GETQCHN */ -#define MCD_MD_PLAYAUDIO 0x01 /* 1 = play audio through headphones */ - -#define MCD_MD_RAW (MCD_MD_PLAYAUDIO|MCD_MD_ECCMODE|MCD_MD_DATALENGTH) -#define MCD_MD_COOKED (MCD_MD_PLAYAUDIO) -#define MCD_MD_TOC (MCD_MD_PLAYAUDIO|MCD_MD_READTOC) -#define MCD_MD_SLEEP (MCD_MD_PLAYAUDIO|MCD_MD_SPINDOWN) - -#define MCD_BLKSIZE_RAW sizeof(struct mcd_rawsector) -#define MCD_BLKSIZE_COOKED 2048 - -/* Lock states */ -#define MCD_LK_UNLOCK 0x00 -#define MCD_LK_LOCK 0x01 -#define MCD_LK_TEST 0x02 - -/* Config commands */ -#define MCD_CF_IRQENABLE 0x10 -#define MCD_CF_DMATIMEOUT 0x08 -#define MCD_CF_READUPC 0x04 -#define MCD_CF_DMAENABLE 0x02 -#define MCD_CF_BLOCKSIZE 0x01 - -/* UPC subcommands */ -#define MCD_UPC_DISABLE 0x00 -#define MCD_UPC_ENABLE 0x01 - -/* commands known by the controller */ -#define MCD_CMDRESET 0x00 -#define MCD_CMDGETVOLINFO 0x10 /* gets mcd_volinfo */ -#define MCD_CMDGETDISKINFO 0x11 /* gets mcd_disk */ -#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_CMDSTOPAUDIO 0x70 -#define MCD_CMDSTOPAUDIOTIME 0x80 -#define MCD_CMDGETVOLUME 0x8E /* gets mcd_volume */ -#define MCD_CMDCONFIGDRIVE 0x90 -#define MCD_CMDSETDRIVEMODE 0xa0 /* set drive mode */ -#define MCD_CMDSETVOLUME 0xae /* sets mcd_volume */ -#define MCD_CMDREAD1 0xb0 /* read n sectors */ -#define MCD_CMDREADSINGLESPEED 0xc0 /* read (single speed) */ -#define MCD_CMDREADDOUBLESPEED 0xc1 /* read (double speed) */ -#define MCD_CMDGETDRIVEMODE 0xc2 /* get drive mode */ -#define MCD_CMDREAD3 0xc3 /* ? */ -#define MCD_CMDSETINTERLEAVE 0xc8 /* set interleave for read */ -#define MCD_CMDCONTINFO 0xdc /* get controller info */ -#define MCD_CMDSTOP 0xf0 /* stop everything */ -#define MCD_CMDEJECTDISK 0xf6 -#define MCD_CMDCLOSETRAY 0xf8 -#define MCD_CMDSETLOCK 0xfe /* needs byte */ - -union mcd_qchninfo { - struct { - u_char control:4; - u_char addr_type:4; - u_char trk_no; - u_char idx_no; - bcd_t track_size[3]; - u_char :8; - bcd_t absolute_pos[3]; - } toc; - struct { - u_char control:4; - u_char addr_type:4; - u_char trk_no; - u_char idx_no; - bcd_t relative_pos[3]; - u_char :8; - bcd_t absolute_pos[3]; - } current; - struct { - u_char control:4; - u_char addr_type:4; - u_char upccode[7]; - u_char junk[2]; - } upc; -} __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_result { - u_char length; - union { - struct { - u_char data[1]; - } raw; - struct { - u_char code; - u_char version; - } continfo; - union mcd_qchninfo qchninfo; - struct mcd_volinfo volinfo; - } data; -} __packed; - -struct mcd_command { - u_char opcode; - u_char length; - union { - struct { - u_char data[1]; - } raw; - struct { - bcd_t start_msf[3]; - bcd_t reserved[3]; - } seek; - struct { - bcd_t start_msf[3]; - bcd_t length[3]; - } read; - struct { - bcd_t start_msf[3]; - bcd_t end_msf[3]; - } play; - struct { - u_char mode; - } datamode; - struct { - u_char time; - } hold; - struct { - u_char mode; - } drivemode; - struct { - u_char mode; - } lockmode; - struct { - u_char subcommand; - u_char data1, data2; - } config; - } data; -} __packed; - -struct mcd_mbox { - struct mcd_command cmd; - struct mcd_result res; -} __packed; - -struct mcd_volume { - u_char v0l; - u_char v0rs; - u_char v0r; - u_char v0ls; -} __packed; - -struct mcd_rawsector { - u_char sync1[12]; - u_char header[4]; - u_char subheader1[4]; - u_char subheader2[4]; - u_char data[MCD_BLKSIZE_COOKED]; - u_char ecc_bits[280]; -} __packed; |