xref: /titanic_52/usr/src/uts/common/sys/dktp/dadkio.h (revision d58fda4376e4bf67072ce2e69f6f47036f9dbb68)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_DKTP_DADKIO_H
28 #define	_SYS_DKTP_DADKIO_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*	direct coupled disk driver ioctl command			*/
37 #define	DIOCTL_GETGEOM		1	/* get logical disk geometry	*/
38 #define	DIOCTL_GETPHYGEOM	2	/* get physical disk geometry	*/
39 #define	DIOCTL_GETMODEL		3	/* get model number		*/
40 #define	DIOCTL_GETSERIAL	4	/* get serial number		*/
41 #define	DIOCTL_RWCMD		5	/* read/write a disk		*/
42 #define	DIOCTL_GETWCE		6	/* get write cache enabled state */
43 /*
44  * arg structure for DIOCTL_GETMODEL and DIOCTL_GETSERIAL
45  * On input to the ioctl, is_size contains the size of the buffer
46  * pointed to by is_buf;
47  * On return, is_size contains the number of characters needed to
48  * represent the string.  This may be more than the input value, in
49  * which case the caller can choose to
50  *  1. Use the truncated string as is
51  *  2. Allocate a buffer of is_size+1 bytes to hold the string
52  */
53 #ifdef _SYSCALL32
54 typedef struct dadk_ioc_string32
55 {
56 	caddr32_t	is_buf;		/* pointer to character array */
57 	int		is_size;	/* string length */
58 } dadk_ioc_string32_t;
59 #endif /* _SYSCALL32 */
60 
61 typedef struct dadk_ioc_string
62 {
63 	caddr_t		is_buf;		/* pointer to character array */
64 	int 		is_size;	/* string length */
65 } dadk_ioc_string_t;
66 
67 /*	direct coupled disk driver command				*/
68 #define	DCMD_READ	1	/* Read Sectors/Blocks 			*/
69 #define	DCMD_WRITE	2	/* Write Sectors/Blocks 		*/
70 #define	DCMD_FMTTRK	3	/* Format Tracks 			*/
71 #define	DCMD_FMTDRV	4	/* Format entire drive 			*/
72 #define	DCMD_RECAL	5	/* Recalibrate 				*/
73 #define	DCMD_SEEK	6	/* Seek to Cylinder 			*/
74 #define	DCMD_RDVER	7	/* Read Verify sectors on disk 		*/
75 #define	DCMD_GETDEF	8	/* Read manufacturers defect list	*/
76 /* cd-rom commands */
77 #define	DCMD_LOCK	9	/* Lock door				*/
78 #define	DCMD_UNLOCK	10	/* Unlock door				*/
79 #define	DCMD_START_MOTOR 11	/* Start motor				*/
80 #define	DCMD_STOP_MOTOR 12	/* Stop motor				*/
81 #define	DCMD_EJECT	13	/* Eject medium				*/
82 #define	DCMD_UPDATE_GEOM 14	/* Update geometry			*/
83 #define	DCMD_GET_STATE	15	/* Get removable disk status		*/
84 #define	DCMD_PAUSE	16	/* cdrom pause				*/
85 #define	DCMD_RESUME	17	/* cdrom resume				*/
86 #define	DCMD_PLAYTRKIND	18	/* cdrom play by track and index	*/
87 #define	DCMD_PLAYMSF	19	/* cdrom play msf			*/
88 #define	DCMD_SUBCHNL	20	/* cdrom sub channel			*/
89 #define	DCMD_READMODE1	21	/* cdrom read mode 1			*/
90 #define	DCMD_READTOCHDR	22	/* cdrom read table of contents header	*/
91 #define	DCMD_READTOCENT	23	/* cdrom read table of contents entry	*/
92 #define	DCMD_READOFFSET	24	/* cdrom read offset			*/
93 #define	DCMD_READMODE2	25	/* cdrom mode 2				*/
94 #define	DCMD_VOLCTRL	26	/* cdrom volume control			*/
95 /* additional disk commands */
96 #define	DCMD_FLUSH_CACHE 27	/* flush write cache to physical medium	*/
97 
98 /*	driver error code						*/
99 #define	DERR_SUCCESS	0	/* success				*/
100 #define	DERR_AMNF	1	/* address mark not found		*/
101 #define	DERR_TKONF	2	/* track 0 not found			*/
102 #define	DERR_ABORT	3	/* aborted command			*/
103 #define	DERR_DWF	4	/* write fault				*/
104 #define	DERR_IDNF	5	/* ID not found				*/
105 #define	DERR_BUSY	6	/* drive busy				*/
106 #define	DERR_UNC	7	/* uncorrectable data error		*/
107 #define	DERR_BBK	8	/* bad block detected			*/
108 #define	DERR_INVCDB	9	/* invalid cdb				*/
109 #define	DERR_HARD	10	/* hard device error - no retry 	*/
110 /*
111  * atapi additional error codes
112  */
113 #define	DERR_ILI	11	/* Illegal length indication		*/
114 #define	DERR_EOM	12	/* End of media detected		*/
115 #define	DERR_MCR	13	/* Media change requested		*/
116 /*
117  * atapi (SCSI) sense key errors
118  */
119 #define	DERR_RECOVER	14	/* Recovered from error			*/
120 #define	DERR_NOTREADY	15	/* Device not ready			*/
121 #define	DERR_MEDIUM	16	/* Medium error				*/
122 #define	DERR_HW		17	/* Hardware error			*/
123 #define	DERR_ILL	18	/* Illegal request			*/
124 #define	DERR_UNIT_ATTN	19	/* Unit attention			*/
125 #define	DERR_DATA_PROT	20	/* Data protection			*/
126 #define	DERR_MISCOMP	21	/* Miscompare				*/
127 #define	DERR_RESV	22	/* Reserved				*/
128 struct	dadkio_derr {
129 	int	d_action;
130 	int	d_severity;
131 };
132 
133 /*
134  *  dadkio_rwcmd cmd
135  */
136 
137 #define	DADKIO_RWCMD_READ		1	/* read command */
138 #define	DADKIO_RWCMD_WRITE		2	/* write command */
139 
140 /*
141  * dadkio_rwcmd flags
142  */
143 #define	DADKIO_FLAG_SILENT		0x01	/* driver should not */
144 						/* generate any warning */
145 						/* or error console msgs */
146 #define	DADKIO_FLAG_RESERVED		0x02	/* reserved/not used */
147 
148 
149 #define	DADKIO_ERROR_INFO_LEN	128
150 
151 /*
152  * dadkio_status status value.
153  */
154 struct dadkio_status {
155 	int		status;
156 	ulong_t		resid;
157 	int		failed_blk_is_valid;
158 	daddr_t		failed_blk;
159 	int		fru_code_is_valid;
160 	int		fru_code;
161 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
162 };
163 
164 #ifdef _SYSCALL32
165 struct dadkio_status32 {
166 	int		status;
167 	uint32_t	resid;
168 	int		failed_blk_is_valid;
169 	daddr32_t	failed_blk;
170 	int		fru_code_is_valid;
171 	int		fru_code;
172 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
173 };
174 #endif /* _SYSCALL32 */
175 
176 /*
177  * Used by read/write ioctl (DKIOCTL_RWCMD)
178  */
179 struct dadkio_rwcmd {
180 	int			cmd;
181 	int			flags;
182 	daddr_t			blkaddr;
183 	uint_t			buflen;
184 	caddr_t			bufaddr;
185 	struct dadkio_status	status;
186 };
187 
188 #ifdef _SYSCALL32
189 struct dadkio_rwcmd32 {
190 	int			cmd;
191 	int			flags;
192 	daddr32_t		blkaddr;
193 	uint_t			buflen;
194 	caddr32_t		bufaddr;
195 	struct dadkio_status32	status;
196 };
197 #endif /* _SYSCALL32 */
198 
199 /*
200  * dadkio_status status values
201  */
202 #define	DADKIO_STAT_NO_ERROR		0	/* cmd was successful */
203 #define	DADKIO_STAT_NOT_READY		1	/* device not ready */
204 #define	DADKIO_STAT_MEDIUM_ERROR	2	/* error on medium */
205 #define	DADKIO_STAT_HARDWARE_ERROR	3	/* other hardware error */
206 #define	DADKIO_STAT_ILLEGAL_REQUEST	4	/* illegal request */
207 #define	DADKIO_STAT_ILLEGAL_ADDRESS	5	/* illegal block address */
208 #define	DADKIO_STAT_WRITE_PROTECTED	6	/* device write-protected */
209 #define	DADKIO_STAT_TIMED_OUT		7	/* no response from device */
210 #define	DADKIO_STAT_PARITY		8	/* parity error in data */
211 #define	DADKIO_STAT_BUS_ERROR		9	/* error on bus */
212 #define	DADKIO_STAT_SOFT_ERROR		10	/* data recovered via ECC */
213 #define	DADKIO_STAT_NO_RESOURCES	11	/* no resources for cmd */
214 #define	DADKIO_STAT_NOT_FORMATTED	12	/* device is not formatted */
215 #define	DADKIO_STAT_RESERVED		13	/* device is reserved */
216 #define	DADKIO_STAT_NOT_SUPPORTED	14	/* feature not supported */
217 
218 
219 #ifdef	__cplusplus
220 }
221 #endif
222 
223 #endif	/* _SYS_DKTP_DADKIO_H */
224