1 /*
2  *   libdi - scsipt SCSI Device Interface Library
3  *
4  *   Copyright (C) 1993-2004  Ti Kan
5  *   E-mail: xmcd@amb.org
6  *
7  *   This program is free software; you can redistribute it and/or modify
8  *   it under the terms of the GNU General Public License as published by
9  *   the Free Software Foundation; either version 2 of the License, or
10  *   (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with this program; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 #ifndef __CDSIM_H__
22 #define __CDSIM_H__
23 
24 #if (defined(DI_SCSIPT) || defined(CDDA_RD_SCSIPT)) && defined(DEMO_ONLY)
25 
26 #ifndef lint
27 static char *_cdsim_h_ident_ = "@(#)cdsim.h	6.19 03/12/12";
28 #endif
29 
30 
31 #define CDSIM_MAGIC		0x584d4344	/* Magic number */
32 #define CDSIM_MAX_DATALEN	8192		/* Max I/O data length */
33 
34 /* Return status codes */
35 #define CDSIM_COMPOK		0	/* Command completed OK */
36 #define CDSIM_COMPERR		1	/* Command completed with error */
37 #define CDSIM_NOTSUPP		2	/* Command not supported */
38 #define CDSIM_PARMERR		3	/* Command parameter error */
39 #define CDSIM_PKTERR		4	/* Command packet error */
40 
41 
42 /* CD simulator IPC packet structure (1024 bytes in size) */
43 typedef struct simpkt {
44 	word32_t	magic;		/* Magic number */
45 
46 	byte_t		pktid;		/* Packet id */
47 	byte_t		retcode;	/* Return code */
48 	byte_t		dir;		/* Data direction: OP_NODATA,
49 					 * OP_DATAIN or OP_DATAOUT
50 					 */
51 	byte_t		cdbsz;		/* CDB size */
52 
53 	word32_t	len;		/* Data length in bytes */
54 
55 	byte_t		cdb[12];	/* CDB data */
56 
57 	byte_t		data[CDSIM_MAX_DATALEN];
58 					/* I/O Data */
59 } simpkt_t;
60 
61 
62 #define CDSIM_NODISC	0x00		/* CD simulator no disc */
63 #define CDSIM_STOPPED	0x01		/* CD simulator stopped */
64 #define CDSIM_PAUSED	0x02		/* CD simulator paused */
65 #define CDSIM_PLAYING	0x03		/* CD simulator playing audio */
66 
67 #define CDSIM_NTRKS	10		/* Number of tracks on simulated CD */
68 #define CDSIM_NIDXS	4		/* Number of index/track on sim CD */
69 #define CDSIM_TRKLEN	4500		/* Length of each simulated track */
70 #define CDSIM_IDXLEN	1125		/* Length of each simulated track */
71 
72 /* CD simulator internal status structures */
73 
74 typedef struct trkstat {
75 	word32_t	addr;		/* Starting absolute addr of track */
76 	byte_t		nidxs;		/* Number of indices */
77 	byte_t		rsvd[3];	/* Reserved */
78 	word32_t	iaddr[CDSIM_NIDXS];
79 					/* Index absolute addresses */
80 } trkstat_t;
81 
82 typedef struct simstat {
83 	byte_t		status;		/* Current mode status flag */
84 	byte_t		ntrks;		/* Number of tracks */
85 	byte_t		trkno;		/* Current track */
86 	byte_t		idxno;		/* Current index */
87 
88 	word32_t	absaddr;	/* Current absolute address */
89 	word32_t	reladdr;	/* Current relative address */
90 	trkstat_t	trk[MAXTRACK];	/* Per-track information */
91 	sword32_t	startaddr;	/* Start play address */
92 	sword32_t	endaddr;	/* End play address */
93 
94 	bool_t		caddylock;	/* Caddy locked */
95 } simstat_t;
96 
97 
98 #define CDSIM_PKTSZ	sizeof(simpkt_t)
99 #define CDSIM_INQSZ	sizeof(inquiry_data_t)
100 
101 
102 /* Public function prototypes */
103 extern bool_t	cdsim_sendpkt(char *, int, simpkt_t *);
104 extern bool_t	cdsim_getpkt(char *, int, simpkt_t *);
105 extern void	cdsim_main(int, int);
106 
107 #endif	/* DI_SCSIPT CDDA_RD_SCSIPT DEMO_ONLY */
108 
109 #endif	/* __CDSIM_H__ */
110 
111