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