xref: /titanic_52/usr/src/uts/common/sys/dktp/dadkio.h (revision 56a424cca6b3f91f31bdab72a4626c48c779fe8b)
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_ICRC	22	/* Interface CRC error -- new driver	*/
128 				/* error code in ATA-4 and newer	*/
129 #define	DERR_RESV	23	/* Reserved				*/
130 
131 struct	dadkio_derr {
132 	int	d_action;
133 	int	d_severity;
134 };
135 
136 /*
137  *  dadkio_rwcmd cmd
138  */
139 
140 #define	DADKIO_RWCMD_READ		1	/* read command */
141 #define	DADKIO_RWCMD_WRITE		2	/* write command */
142 
143 /*
144  * dadkio_rwcmd flags
145  */
146 #define	DADKIO_FLAG_SILENT		0x01	/* driver should not */
147 						/* generate any warning */
148 						/* or error console msgs */
149 #define	DADKIO_FLAG_RESERVED		0x02	/* reserved/not used */
150 
151 
152 #define	DADKIO_ERROR_INFO_LEN	128
153 
154 /*
155  * dadkio_status status value.
156  */
157 struct dadkio_status {
158 	int		status;
159 	ulong_t		resid;
160 	int		failed_blk_is_valid;
161 	daddr_t		failed_blk;
162 	int		fru_code_is_valid;
163 	int		fru_code;
164 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
165 };
166 
167 #ifdef _SYSCALL32
168 struct dadkio_status32 {
169 	int		status;
170 	uint32_t	resid;
171 	int		failed_blk_is_valid;
172 	daddr32_t	failed_blk;
173 	int		fru_code_is_valid;
174 	int		fru_code;
175 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
176 };
177 #endif /* _SYSCALL32 */
178 
179 /*
180  * Used by read/write ioctl (DKIOCTL_RWCMD)
181  */
182 struct dadkio_rwcmd {
183 	int			cmd;
184 	int			flags;
185 	daddr_t			blkaddr;
186 	uint_t			buflen;
187 	caddr_t			bufaddr;
188 	struct dadkio_status	status;
189 };
190 
191 #ifdef _SYSCALL32
192 struct dadkio_rwcmd32 {
193 	int			cmd;
194 	int			flags;
195 	daddr32_t		blkaddr;
196 	uint_t			buflen;
197 	caddr32_t		bufaddr;
198 	struct dadkio_status32	status;
199 };
200 #endif /* _SYSCALL32 */
201 
202 /*
203  * dadkio_status status values
204  */
205 #define	DADKIO_STAT_NO_ERROR		0	/* cmd was successful */
206 #define	DADKIO_STAT_NOT_READY		1	/* device not ready */
207 #define	DADKIO_STAT_MEDIUM_ERROR	2	/* error on medium */
208 #define	DADKIO_STAT_HARDWARE_ERROR	3	/* other hardware error */
209 #define	DADKIO_STAT_ILLEGAL_REQUEST	4	/* illegal request */
210 #define	DADKIO_STAT_ILLEGAL_ADDRESS	5	/* illegal block address */
211 #define	DADKIO_STAT_WRITE_PROTECTED	6	/* device write-protected */
212 #define	DADKIO_STAT_TIMED_OUT		7	/* no response from device */
213 #define	DADKIO_STAT_PARITY		8	/* parity error in data */
214 #define	DADKIO_STAT_BUS_ERROR		9	/* error on bus */
215 #define	DADKIO_STAT_SOFT_ERROR		10	/* data recovered via ECC */
216 #define	DADKIO_STAT_NO_RESOURCES	11	/* no resources for cmd */
217 #define	DADKIO_STAT_NOT_FORMATTED	12	/* device is not formatted */
218 #define	DADKIO_STAT_RESERVED		13	/* device is reserved */
219 #define	DADKIO_STAT_NOT_SUPPORTED	14	/* feature not supported */
220 
221 
222 #ifdef	__cplusplus
223 }
224 #endif
225 
226 #endif	/* _SYS_DKTP_DADKIO_H */
227