xref: /386bsd/usr/src/kernel/mcd/mcdreg.h (revision dc8b130e)
1 /*
2  * Copyright 1993 by Holger Veit (data part)
3  * Copyright 1993 by Brian Moore (audio part)
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This software was developed by Holger Veit and Brian Moore
17  *      for use with "386BSD" and similar operating systems.
18  *    "Similar operating systems" includes mainly non-profit oriented
19  *    systems for research and education, including but not restricted to
20  *    "NetBSD", "FreeBSD", "Mach" (by CMU).
21  * 4. Neither the name of the developer(s) nor the name "386BSD"
22  *    may be used to endorse or promote products derived from this
23  *    software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
26  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE DEVELOPER(S) BE
29  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
31  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37 
38  *	@(#) $RCSfile: mcdreg.h,v $	$Revision: 1.4 $ $Date: 95/01/08 16:51:37 $
39  *
40  * This file contains definitions for some cdrom control commands
41  * and status codes. This info was "inherited" from the DOS MTMCDE.SYS
42  * driver, and is thus not complete (and may even be wrong). Some day
43  * the manufacturer or anyone else might provide better documentation,
44  * so this file (and the driver) will then have a better quality.
45  */
46 #ifndef MCD_H
47 #define MCD_H
48 
49 #ifdef __GNUC__
50 #if __GNUC__ >= 2
51 #pragma pack(1)
52 #endif
53 #endif
54 
55 typedef unsigned char	bcd_t;
56 #define M_msf(msf) msf[0]
57 #define S_msf(msf) msf[1]
58 #define F_msf(msf) msf[2]
59 
60 /*
61  * Decoder Card ports and port bit definitions
62  */
63 #define	mcd_command	0
64 #define mcd_status	0
65 #define mcd_rdata	0
66 #define mcd_Data	0		/* Drive data port (R/W) */
67 
68 #define mcd_reset	1		/* Drive Reset signal (W) */
69 #define mcd_Status	1		/* Drive status signals (R) */
70 /*#define		MCD_CMDRESET	0x00*/
71 #define mcd_xfer	1
72 #define		MCD_ST_BUSY	0x04
73 #define		MCD_STEN	0x04	/* status enabled */
74 #define		MCD_DTEN	0x02	/* data enabled */
75 		/* XXX Bit 3,1 used, but for what? */
76 #define mcd_ctl2	2 /* XXX Is this right? */
77 #define mcd_hostcfg	2		/* Host Bus adapter configuration */
78 #define		MCD_16BUFEN	0x41	/* enable low and hi byte */
79 #define		MCD_16DIR	0x80	/* read PIO instead of DMA (override) */
80 #define		MCDH_DTS	0x08	/* read PIO instead of DMA (override) */
81 /*#define		MCD_???	0x04	/* ?? */
82 
83 #define mcd_config	3
84 #define		MCD_DECODER	0x80	/* OTI decoder instead of Sanyo */
85 #define		MCD_MASK_IRQ	0x70	/* bits 6-4 = INT number */
86 					/* 000 = *no interrupt* */
87 					/* 001 = int 2,9 */
88 					/* 010 = int 3 */
89 					/* 011 = int 5 */
90 					/* 100 = int 10 */
91 					/* 101 = int 11 */
92 #define 	MCD_PIO16	0x10	/* 16 vs 8 bit programmed I/O */
93 #define 	MCD_MASK_DMA	0x07	/* bits 2-0 = DMA channel */
94 					/* 000 = *no DMA*, PIO */
95 
96 /*
97  * CDROM drive commands, command options, and status bits
98  */
99 
100 /* commands known by the controller */
101 #define MCD_CMDGETVOLINFO	0x10	/* gets mcd_volinfo  GET TOC*/
102 #define MCD_CMDGETSESSION	0x11	/* get session info */
103 					/* 0=single / 1=multisession, */
104 					/* mm, hh, ff of last session */
105 
106 #define MCD_CMDGETQCHN	0x20	/* gets mcd_qchninfo */
107 #define MCD_CMDGETSTAT	0x40	/* gets a byte  of status */
108 #define		MCD_ST_DOOROPEN	0x80	/* drive door is open */
109 #define		MCD_ST_DSKIN	0x40	/* disk is inside drive */
110 #define		MCD_ST_DSKCHNG	0x20	/* disk has been changed */
111 #define		MCD_ST_DSKSPIN	0x10	/* disk is spinning */
112 #define		MCD_ST_AUDIOTRK	0x08	/* audio or data track */
113 #define		MCD_ST_READERR	0x04	/* read error */
114 #define		MCD_ST_AUDIOBSY	0x02	/* drive playing audio */
115 #define		MCD_ST_INVCMD	0x01	/* invalid command */
116 
117 #define	MCD_CMDSETMODE	0x50	/* set transmission mode, needs byte */
118 #define	 MCD_MD_RAW		 0x60
119 #define	 MCD_MD_UPC		 0x00
120 #define	 MCD_MD_COOKED		 0x01
121 #define	 MCD_MD_TOC		 0x05
122 
123 #define MCD_SOFTRESET		0x60
124 #define MCD_CMDSTOPAUDIO	0x70	/* actually pause HOLD */
125 #define MCD_CMDINACTIVE		0x80	/* inactivity timeout */
126 
127 #define MCD_CMDGETVOLUME	0x8E	/* gets mcd_volume */
128 
129 	/* XXX 0x90 used, 1,2,or 3 args */
130 #define	MCD_SETPARAMS	0x90	/* set drive parameters */
131 #define	 MCD_SP_DLEN	 0x01	 /* data length selection, takes two bytes */
132 				  /* MSB, then LSB */
133 #define	 MCD_SP_MODE	 0x02	 /* mode selection, takes a byte: */
134 #define	  MCDSP_DMA	  0x01	  /* DMA mode */
135 #define	  MCDSP_PIO	  0x00	  /* PIO mode */
136 #define	 MCD_SP_SYSMODE	 0x04	 /* system mode selection, takes a byte: */
137 #define	  MCDSP_UPC	  0x01	  /* enter UPC mode */
138 #define	  MCDSP_NORMAL	  0x00	  /* leave UPC mode, resume normal mode */
139 #define	 MCD_SP_TIMEO	 0x08	 /* timeout selection, takes a byte(2MS units) */
140 #define	 MCD_SP_INTR	 0x10	 /* interrupt selection, takes a byte: */
141 #define	  MCDSP_PRE	  0x05	  /* interrupt before xxx */
142 #define	  MCDSP_POST	  0x06	  /* interrupt after xxx */
143 #define	 MCD_SP_SRETRYS	 0x20	 /* seek retrys selection, takes a byte */
144 
145 	/* XXX 0xA0 used, 1 arg */
146 #define	MCD_SETDSKMODE	0xa0	/* set diskette mode, takes a byte */
147 				 /* MODE# (either 0x01 or 0x02 */
148 #define MCD_CMDGETUPC	0xA2	/* put upc into subchannel data */
149 
150 #define MCD_CMDSETVOLUME	0xAE	/* sets mcd_volume */
151 #define MCD_CMDREAD1	0xB0	/* read n sectors of audio subchannel */
152 #define MCD_CMDREAD2	0xC0	/* read from-to */
153 #define MCD_CMDREAD2D	0xC1	/* read from-to (double speed) */
154 	/* XXX 0xDC used, gets 2 bytes */
155 #define MCD_CMDGETVERS	0xDC	/* get drive model & firmware version */
156 #define	 MCD_VER_LU	 'M'	 /* LU model */
157 #define	 MCD_VER_FX	 'F'	 /* FX model */
158 #define	 MCD_VER_FXD	 'D'	 /* FXxxxD model */
159 #define MCD_CMDSTOP		0xF0	/* stop CD from spinning */
160 #define MCD_CMDEJECTDISK	0xF6
161 #define	MCD_CMDCLOSETRAY	0xF8
162 #define MCD_CMDLOCKDRV	0xFE	/* needs byte */
163 #define		MCD_LK_UNLOCK	0x00
164 #define		MCD_LK_LOCK	0x01
165 #define		MCD_LK_TEST	0x02
166 
167 struct mcd_volinfo {
168 	bcd_t	trk_low;
169 	bcd_t	trk_high;
170 	bcd_t	vol_msf[3];
171 	bcd_t	trk1_msf[3];
172 };
173 
174 struct mcd_qchninfo {
175 	u_char	ctrl_adr;
176 	u_char	trk_no;
177 	u_char	idx_no;
178 	bcd_t	trk_size_msf[3];
179 	u_char	:8;
180 	bcd_t	hd_pos_msf[3];
181 };
182 
183 struct mcd_volume {
184 	u_char	v0l;
185 	u_char	v0rs;
186 	u_char	v0r;
187 	u_char	v0ls;
188 };
189 
190 struct mcd_read1 {
191 	bcd_t	start_msf[3];
192 	u_char	nsec[3];
193 };
194 
195 struct mcd_read2 {
196 	bcd_t	start_msf[3];
197 	bcd_t	end_msf[3];
198 };
199 
200 
201 #endif /* MCD_H */
202