summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/i386/isa/matcd/matcd.c38
-rw-r--r--sys/i386/isa/matcd/matcddrv.h198
-rw-r--r--sys/i386/isa/matcd/options.h60
3 files changed, 272 insertions, 24 deletions
diff --git a/sys/i386/isa/matcd/matcd.c b/sys/i386/isa/matcd/matcd.c
index e042f8f39d2b..ff24f71603dd 100644
--- a/sys/i386/isa/matcd/matcd.c
+++ b/sys/i386/isa/matcd/matcd.c
@@ -314,10 +314,19 @@ Edit number code marking begins here - earlier edits were during development.
I also fixed some duplicate location strings in the tsleep calls.
24-Sep-95 Frank Durda IV bsdmail@nemesis.lonestar.org
+<26> Moved a function declaration that generated two warnings with
+ the FULLCONFIG/FULLDRIVER conditionals disabled.
+ Updated the igot function so that it correctly reports limited
+ functions when a sub-set driver is compiled.
+ Eliminated FULLCONFIG conditional and now set controller counts
+ based on the NMATCD #define produced by the config process.
+ Also, disable the audio-related ioctls based on the BOOTMFS
+ conditional to help make the boot floppy kernel smaller.
+ 18-Oct-95 Frank Durda IV bsdmail@nemesis.lonestar.org
---------------------------------------------------------------------------*/
/*Match this format: Version_dc(d)__dd-mmm-yy */
-static char MATCDVERSION[]="Version 1(25) 18-Sep-95";
+static char MATCDVERSION[]="Version 1(26) 18-Oct-95";
/* The following strings may not be changed*/
static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank Durda IV";
@@ -328,6 +337,7 @@ static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank
Include declarations
---------------------------------------------------------------------------*/
+#include "matcd.h" /*<26>*/
#include <sys/param.h> /*<16>*/
#include <sys/systm.h> /*<16>*/
@@ -341,7 +351,7 @@ static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank
#include "i386/isa/matcd/options.h" /*Conditional compile options
and probe port hints*/
-#include "i386/isa/matcd/matcd.h" /*Drive-related defs & strings*/
+#include "i386/isa/matcd/matcddrv.h" /*Drive-related defs & strings*/
#include "i386/isa/matcd/creative.h" /*Host interface related defs*/
#ifdef FREE2
@@ -355,11 +365,6 @@ static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank
Defines and structures
---------------------------------------------------------------------------*/
-#ifdef FULLCONFIG
-#define NUMCTRLRS 4 /*With modern boards, four is max*/
-#else /*FULLCONFIG*/
-#define NUMCTRLRS 1 /*Produces a slightly smaller kernel*/
-#endif /*FULLCONFIG*/
#define DRIVESPERC 4 /*This is a constant*/
#define TOTALDRIVES NUMCTRLRS*DRIVESPERC /*Max possible drives*/
#if DIAGPORT > 0xff /*<10>*/
@@ -414,7 +419,6 @@ struct matcd_mbx {
};
static struct matcd_data { /*<18>*/
- short config;
short drivemode; /*Last state drive was set to*/
short flags;
short status; /*Last audio-related function*/
@@ -423,8 +427,8 @@ static struct matcd_data { /*<18>*/
short iobase; /*<20>*/
short iftype; /*<20>Host interface type*/
struct disklabel dlabel;
- int partflags[MAXPARTITIONS];
- int openflags;
+ unsigned int partflags[MAXPARTITIONS];
+ unsigned int openflags;
struct matcd_volinfo volinfo;
struct matcd_mbx mbx;
u_char patch[2]; /*<12>Last known audio routing*/
@@ -576,7 +580,6 @@ static int matcd_route(int ldrive, int cdrive, int controller,/*<12>*/
int command); /*<12>*/
static int matcd_pitch(int ldrive, int cdrive, int controller,/*<12>*/
struct ioc_pitch * speed); /*<12>*/
-static int matcd_igot(struct ioc_capability * sqp); /*<16>*/
#endif /*FULLDRIVER*/
static int matcd_toc_header(int ldrive, int cdrive, int controller,/*<13>*/
struct ioc_toc_header * toc); /*<13>*/
@@ -585,6 +588,7 @@ static int matcd_toc_entries(int ldrive, int cdrive, /*<13>*/
struct ioc_read_toc_entry *ioc_entry);/*<13>*/
static int matcd_read_subq(int ldrive, int cdrive, int controller,/*<14>*/
struct ioc_read_subchannel * sqp);/*<14>*/
+static int matcd_igot(struct ioc_capability * sqp); /*<26>*/
static int waitforit(int timelimit, int state, int port,
char * where); /*<14>*/
static int get_stat(int port, int ldrive); /*<14>*/
@@ -1238,8 +1242,8 @@ int matcd_probe(struct isa_device *dev)
int i,cdrive;
unsigned char y;
int port = dev->id_iobase; /*Take port hint from config file*/
- cdrive=nextcontroller; /*Controller defined by pass for now*/
+ cdrive=nextcontroller; /*Controller defined by pass for now*/
#if DIAGPORT == 0x302 /*<10>*/
DIAGOUT(0x300,0x00); /*<10>Init diag board in case some
other device probe scrambled it*/
@@ -1262,7 +1266,6 @@ int matcd_probe(struct isa_device *dev)
i=nextcontroller*DRIVESPERC; /*Precompute controller offset*/
for (y=0; y<DRIVESPERC; y++) {
matcd_data[i+y].flags=0;
- matcd_data[i+y].config=0;
}
#ifdef DEBUGPROBE
@@ -1411,7 +1414,7 @@ static inline void matcd_register(struct isa_device *id)
int matcd_attach(struct isa_device *dev)
{
int i;
- unsigned char z,cdrive;
+ unsigned int z,cdrive;
unsigned char cmd[MAXCMDSIZ];
unsigned char data[12];
struct matcd_data *cd;
@@ -1481,6 +1484,7 @@ int matcd_attach(struct isa_device *dev)
void zero_cmd(char * lcmd)
{
int i;
+
for (i=0; i<MAXCMDSIZ; lcmd[i++]=0);
return;
}
@@ -2255,6 +2259,7 @@ int chk_error(int errnum)
int get_stat(int port,int ldrive)
{
int status,busstat; /*<16>*/
+
status=inb(port+DATA); /*Read status byte, last step of cmd*/
busstat=inb(port+STATUS); /*<16>Get bus status - should be 0xff*/
while ((busstat & (DTEN|STEN)) != (DTEN|STEN)) { /*<19>*/
@@ -2706,6 +2711,7 @@ static int matcd_read_subq(int ldrive, int cdrive, int controller,
static int matcd_igot(struct ioc_capability * sqp)
{
+#ifdef FULLDRIVER
sqp->play_function=(CDDOPLAYTRK | /*Can play trks/indx*/
CDDOPLAYMSF | /*Can play msf to msf*/
CDDOPAUSE | /*Can pause playback*/
@@ -2720,6 +2726,10 @@ static int matcd_igot(struct ioc_capability * sqp)
CDSETRIGHT | /*Can select right-only*/
CDSETMUTE | /*Can mute audio*/
CDSETPATCH); /*Direct patch settings*/
+#else /*FULLDRIVER*/
+ sqp->play_function=0; /*No audio capability*/
+ sqp->routing_function=0; /*No audio capability*/
+#endif /*FULLDRIVER*/
sqp->special_function=(CDDOEJECT | /*Door can be opened*/
CDDOCLOSE | /*Door can be closed*/
diff --git a/sys/i386/isa/matcd/matcddrv.h b/sys/i386/isa/matcd/matcddrv.h
new file mode 100644
index 000000000000..8802149d0803
--- /dev/null
+++ b/sys/i386/isa/matcd/matcddrv.h
@@ -0,0 +1,198 @@
+/*matcd.h---------------------------------------------------------------------
+
+ Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
+ Authored by Frank Durda IV
+
+ Copyright 1994, 1995 Frank Durda IV. All rights reserved.
+ "FDIV" is a trademark of Frank Durda IV.
+
+
+ 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 positioned at the very beginning of this file without
+ modification, all copyright strings, all related programming
+ codes that display the copyright strings, this list of
+ conditions and the following disclaimer.
+ 2. Redistributions in binary form must contain all copyright strings
+ and related programming code that display the copyright strings.
+ 3. 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.
+ 4. All advertising materials mentioning features or use of this
+ software must display the following acknowledgement:
+ "The Matsushita/Panasonic CD-ROM driver was developed
+ by Frank Durda IV for use with "FreeBSD" and similar
+ operating systems."
+ "Similar operating systems" includes mainly non-profit oriented
+ systems for research and education, including but not restricted
+ to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the
+ acknowledgement (in electronic form or printed text) may not be
+ changed without permission from the author.
+ 5. Absolutely no warranty of function, fitness or purpose is made
+ by the author Frank Durda IV.
+ 6. Neither the name of the author nor the name "FreeBSD" may
+ be used to endorse or promote products derived from this software
+ without specific prior written permission.
+ (The author can be reached at bsdmail@nemesis.lonestar.org)
+ 7. The product containing this software must meet all of these
+ conditions even if it is unsupported, not a complete system
+ and/or does not contain compiled code.
+ 8. These conditions will be in force for the full life of the
+ copyright.
+ 9. If all the above conditions are met, modifications to other
+ parts of this file may be freely made, although any person
+ or persons making changes do not receive the right to add their
+ name or names to the copyright strings and notices in this
+ software. Persons making changes are encouraged to insert edit
+ history in matcd.c and to put your name and details of the
+ change there.
+ 10. You must have prior written permission from the author to
+ deviate from these terms.
+
+ Vendors who produce product(s) containing this code are encouraged
+ (but not required) to provide copies of the finished product(s) to
+ the author and to correspond with the author about development
+ activity relating to this code. Donations of development hardware
+ and/or software are also welcome. (This is one of the faster ways
+ to get a driver developed for a device.)
+
+ 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.
+
+
+-----No changes are allowed above this line------------------------------------
+
+See matcd.c for Edit History information.
+
+
+ Matsushita CR562/CR563 Commands
+ This is not a complete list - just the ones this version uses
+*/
+
+#define NOP 0x05 /*No action - just return status*/
+#define DOOROPEN 0x06 /*Open tray*/
+#define DOORCLOSE 0x07 /*Close tray*/
+#define ABORT 0x08 /*Abort command*/
+#define MODESELECT 0x09 /*Set drive parameters*/
+#define LOCK 0x0c /*Prevent/Allow medium removal*/
+#define PAUSE 0x0d /*Pause/Resume playback*/
+#define PLAYBLOCKS 0x0e /*Play audio - block to block*/
+#define PLAYTRKS 0x0f /*Play audio - tracks & index*/
+#define READ 0x10 /*Read data*/
+#define READERROR 0x82 /*Read Error*/
+#define READID 0x83 /*Read Drive Type & Firmware Info*/
+#define MODESENSE 0x84 /*<12>Report drive settings*/
+#define READSUBQ 0x87 /*<14>Read Q channel information*/
+#define READDINFO 0x8b /*<13>Read TOC tracks & drive size*/
+#define READTOC 0x8c /*<13>Read entry from TOC*/
+
+#define BLOCKPARAM 0x00 /*Used with MODESELECT command*/
+#define SPEEDPARM 0x03 /*<12>Adjust audio playback speed*/
+#define AUDIOPARM 0x05 /*<12>Set/read audio levels & routing*/
+#define RESUME 0x80 /*Used with PAUSE command*/
+
+#define MAXCMDSIZ 12 /*Max command size with NULL*/
+
+/* Possible data transfers for MODESELECT + BLOCKPARAM */
+
+#define MODE_DATA 0x00 /*2048, 2340*/
+#define MODE_DA 0x82 /*2352*/
+#define MODE_USER 0x01 /*2048, 2052, 2336, 2340, 2352*/
+#define MODE_UNKNOWN 0xff /*Uninitialized state*/
+
+/*<12>The following mode is not implemented in the driver at this time*/
+
+#define MODE_XA 0x81 /*2048, 2060, 2324, 2336, 2340, 2352*/
+
+#define DEFVOL 0xff /*<12>Default drive volume level, 100%
+ volume. Based on drive action.*/
+#define OUTLEFT 0x01 /*Output on Left*/
+#define OUTRIGHT 0x02 /*Output on Right*/
+
+/* Matsushita CR562/CR563 Status bits*/
+
+#define MATCD_ST_DOOROPEN 0x80 /*Door is open right now*/
+#define MATCD_ST_DSKIN 0x40 /*Disc in drive*/
+#define MATCD_ST_SPIN 0x20 /*Disc is spinning*/
+#define MATCD_ST_ERROR 0x10 /*Error on command*/
+#define MATCD_ST_AUDIOBSY 0x08 /*Drive is playing audio*/
+#define MATCD_ST_LOCK 0x04 /*<14>Drive is locked*/
+#define MATCD_ST_X2 0x02 /*<14>Media is at double-speed*/
+#define MATCD_ST_READY 0x01 /*<14>Drive is ready*/
+
+#define MATCDAUDIOBSY MATCD_ST_AUDIOBSY
+#define MATCDDSKCHNG MATCD_ST_DSKCHNG
+#define MATCDDSKIN MATCD_ST_DSKIN
+#define MATCDDOOROPEN MATCD_ST_DOOROPEN
+
+
+/* Error codes returned from READERROR command.*/
+
+#define NO_ERROR 0x00
+#define RECV_RETRY 0x01
+#define RECV_ECC 0x02
+#define NOT_READY 0x03
+#define TOC_ERROR 0x04
+#define UNRECV_ERROR 0x05
+#define SEEK_ERROR 0x06
+#define TRACK_ERROR 0x07
+#define RAM_ERROR 0x08
+#define DIAG_ERROR 0x09
+#define FOCUS_ERROR 0x0a
+#define CLV_ERROR 0x0b
+#define DATA_ERROR 0x0c
+#define ADDRESS_ERROR 0x0d
+#define CDB_ERROR 0x0e
+#define END_ADDRESS 0x0f
+#define MODE_ERROR 0x10
+#define MEDIA_CHANGED 0x11
+#define HARD_RESET 0x12
+#define ROM_ERROR 0x13
+#define CMD_ERROR 0x14
+#define DISC_OUT 0x15
+#define HARD_ERROR 0x16
+#define ILLEGAL_REQ 0x17
+
+
+/* Human-readable error messages - what a concept!*/
+
+static unsigned char * matcderrors[]={"No error", /* 00 */
+ "Soft read error after retry", /* 01 */
+ "Soft read error after error-correction", /* 02 */
+ "Not ready", /* 03 */
+ "Unable to read TOC", /* 04 */
+ "Hard read error of data track",/* 05 */
+ "Seek did not complete", /* 06 */
+ "Tracking servo failure", /* 07 */
+ "Drive RAM failure", /* 08 */
+ "Drive self-test failed", /* 09 */
+ "Focusing servo failure", /* 0a */
+ "Spindle servo failure", /* 0b */
+ "Data path failure", /* 0c */
+ "Illegal logical block address",/* 0d */
+ "Illegal field in CDB", /* 0e */
+ "End of user encountered on this track", /* 0f */
+ "Illegal data mode for this track", /* 10 */
+ "Media changed", /* 11 */
+ "Power-on or drive reset occurred", /* 12 */
+ "Drive ROM failure", /* 13 */
+ "Illegal drive command received from host",/* 14 */
+ "Disc removed during operation",/* 15 */
+ "Drive Hardware error", /* 16 */
+ "Illegal request from host"}; /* 17 */
+
+/*End of matcd.h*/
+
+
diff --git a/sys/i386/isa/matcd/options.h b/sys/i386/isa/matcd/options.h
index 63317035105b..f7ba057fc6d5 100644
--- a/sys/i386/isa/matcd/options.h
+++ b/sys/i386/isa/matcd/options.h
@@ -86,14 +86,21 @@
#define AUTOHUNT
-/* FULLCONFIG Allows up to four host interface boards for a
- total of 16 drives. If disabled, only a single
- host interface (of any type) is allowed. The
- additional driver size is insignificant.
- Leaving FULLCONFIG enabled is the recommended setting.
+/* NUMCTRLRS Configures support for between one and four
+ host interfaces, for up to 16 drives.
+ The number of entries in the kernel config
+ file is used by default, but this may be changed
+ to a specific value if desired.
+
+ Leaving NUMCTRLRS based on NMATCD is the
+ recommended setting.
*/
-#define FULLCONFIG
+#if NMATCD >= 4
+#define NUMCTRLRS 4 /*Limit driver to four host interfaces*/
+#else /*NMATCD*/
+#define NUMCTRLRS NMATCD
+#endif /*NMATCD*/
/* FULLDRIVER If not set, the audio, non-data functions and
@@ -103,7 +110,9 @@
Leaving FULLDRIVER enabled is the recommended setting.
*/
+#ifndef BOOTMFS
#define FULLDRIVER
+#endif /*BOOTMFS*/
/* RESETONBOOT causes the driver to reset the drive(s) to be
@@ -170,14 +179,45 @@
If you add entries to the table, add them immediately before
the -1 end-of-table marker. The values already present are
- the ones found on standard SoundBlaster 16 and standalone cards.
+ the ones used by Creative Labs boards and those of a few
+ other vendors.
+
+ Each additional entry increases the boot time by four seconds,
+ and can increase the chance of accessing some other device.
+ Therefore, the list should be kept to a minimum. Once the
+ devices have been correctly located, the kernel should be
+ configured so that it looks only at the correct location from
+ that point on.
+
+ Be sure to search devices located below 0x3ff BEFORE scanning
+ higher locations. Some boards don't decode all I/O address lines,
+ so 0x230 and 0x630 appear identical.
---------------------------------------------------------------------------*/
#ifdef AUTOHUNT
int port_hints[]={
- 0x230,0x240, /*Ports SB audio boards can use*/
- 0x250,0x260, /*Ports standalone CD/IF board can*/
- -1}; /*use. Table MUST end with -1*/
+ 0x230, /*SB Pro & SB16*/
+ 0x240, /*SB Pro & SB16*/
+ 0x250, /*Creative omniCD standalone boards*/
+ 0x260, /*Creative omniCD standalone boards*/
+ 0x340, /*Laser Mate*/
+ 0x360, /*Laser Mate*/
+ 0x630, /*IBM*/
+#if 0
+/* These locations are alternate settings for LaserMate and IBM
+ boards, but they usually conflict with network and SCSI cards.
+ I recommend against probing these randomly.
+*/
+ 0x310, /*Laser Mate*/
+ 0x320, /*Laser Mate*/
+ 0x330, /*Laser Mate*/
+ 0x350, /*Laser Mate*/
+ 0x370, /*Laser Mate*/
+ 0x650, /*IBM*/
+ 0x670, /*IBM*/
+ 0x690, /*IBM*/
+#endif /*0*/
+ -1}; /*use. Table MUST end with -1*/
#endif /*AUTOHUNT*/