xref: /titanic_41/usr/src/uts/common/sys/dktp/dadkio.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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 2004 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 
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 
96 /*	driver error code						*/
97 #define	DERR_SUCCESS	0	/* success				*/
98 #define	DERR_AMNF	1	/* address mark not found		*/
99 #define	DERR_TKONF	2	/* track 0 not found			*/
100 #define	DERR_ABORT	3	/* aborted command			*/
101 #define	DERR_DWF	4	/* write fault				*/
102 #define	DERR_IDNF	5	/* ID not found				*/
103 #define	DERR_BUSY	6	/* drive busy				*/
104 #define	DERR_UNC	7	/* uncorrectable data error		*/
105 #define	DERR_BBK	8	/* bad block detected			*/
106 #define	DERR_INVCDB	9	/* invalid cdb				*/
107 #define	DERR_HARD	10	/* hard device error - no retry 	*/
108 /*
109  * atapi additional error codes
110  */
111 #define	DERR_ILI	11	/* Illegal length indication		*/
112 #define	DERR_EOM	12	/* End of media detected		*/
113 #define	DERR_MCR	13	/* Media change requested		*/
114 /*
115  * atapi (SCSI) sense key errors
116  */
117 #define	DERR_RECOVER	14	/* Recovered from error			*/
118 #define	DERR_NOTREADY	15	/* Device not ready			*/
119 #define	DERR_MEDIUM	16	/* Medium error				*/
120 #define	DERR_HW		17	/* Hardware error			*/
121 #define	DERR_ILL	18	/* Illegal request			*/
122 #define	DERR_UNIT_ATTN	19	/* Unit attention			*/
123 #define	DERR_DATA_PROT	20	/* Data protection			*/
124 #define	DERR_MISCOMP	21	/* Miscompare				*/
125 #define	DERR_RESV	22	/* Reserved				*/
126 struct	dadkio_derr {
127 	int	d_action;
128 	int	d_severity;
129 };
130 
131 /*
132  *  dadkio_rwcmd cmd
133  */
134 
135 #define	DADKIO_RWCMD_READ		1	/* read command */
136 #define	DADKIO_RWCMD_WRITE		2	/* write command */
137 
138 /*
139  * dadkio_rwcmd flags
140  */
141 #define	DADKIO_FLAG_SILENT		0x01	/* driver should not */
142 						/* generate any warning */
143 						/* or error console msgs */
144 #define	DADKIO_FLAG_RESERVED		0x02	/* reserved/not used */
145 
146 
147 #define	DADKIO_ERROR_INFO_LEN	128
148 
149 /*
150  * dadkio_status status value.
151  */
152 struct dadkio_status {
153 	int		status;
154 	ulong_t		resid;
155 	int		failed_blk_is_valid;
156 	daddr_t		failed_blk;
157 	int		fru_code_is_valid;
158 	int		fru_code;
159 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
160 };
161 
162 #ifdef _SYSCALL32
163 struct dadkio_status32 {
164 	int		status;
165 	uint32_t	resid;
166 	int		failed_blk_is_valid;
167 	daddr32_t	failed_blk;
168 	int		fru_code_is_valid;
169 	int		fru_code;
170 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
171 };
172 #endif /* _SYSCALL32 */
173 
174 /*
175  * Used by read/write ioctl (DKIOCTL_RWCMD)
176  */
177 struct dadkio_rwcmd {
178 	int			cmd;
179 	int			flags;
180 	daddr_t			blkaddr;
181 	uint_t			buflen;
182 	caddr_t			bufaddr;
183 	struct dadkio_status	status;
184 };
185 
186 #ifdef _SYSCALL32
187 struct dadkio_rwcmd32 {
188 	int			cmd;
189 	int			flags;
190 	daddr32_t		blkaddr;
191 	uint_t			buflen;
192 	caddr32_t		bufaddr;
193 	struct dadkio_status32	status;
194 };
195 #endif /* _SYSCALL32 */
196 
197 /*
198  * dadkio_status status values
199  */
200 #define	DADKIO_STAT_NO_ERROR		0	/* cmd was successful */
201 #define	DADKIO_STAT_NOT_READY		1	/* device not ready */
202 #define	DADKIO_STAT_MEDIUM_ERROR	2	/* error on medium */
203 #define	DADKIO_STAT_HARDWARE_ERROR	3	/* other hardware error */
204 #define	DADKIO_STAT_ILLEGAL_REQUEST	4	/* illegal request */
205 #define	DADKIO_STAT_ILLEGAL_ADDRESS	5	/* illegal block address */
206 #define	DADKIO_STAT_WRITE_PROTECTED	6	/* device write-protected */
207 #define	DADKIO_STAT_TIMED_OUT		7	/* no response from device */
208 #define	DADKIO_STAT_PARITY		8	/* parity error in data */
209 #define	DADKIO_STAT_BUS_ERROR		9	/* error on bus */
210 #define	DADKIO_STAT_SOFT_ERROR		10	/* data recovered via ECC */
211 #define	DADKIO_STAT_NO_RESOURCES	11	/* no resources for cmd */
212 #define	DADKIO_STAT_NOT_FORMATTED	12	/* device is not formatted */
213 #define	DADKIO_STAT_RESERVED		13	/* device is reserved */
214 #define	DADKIO_STAT_NOT_SUPPORTED	14	/* feature not supported */
215 
216 
217 #ifdef	__cplusplus
218 }
219 #endif
220 
221 #endif	/* _SYS_DKTP_DADKIO_H */
222