xref: /onnv-gate/usr/src/uts/common/sys/dktp/dadkio.h (revision 7563:84ec90ffc3f7)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7563SPrasad.Singamsetty@Sun.COM  * Common Development and Distribution License (the "License").
6*7563SPrasad.Singamsetty@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*7563SPrasad.Singamsetty@Sun.COM 
220Sstevel@tonic-gate /*
23*7563SPrasad.Singamsetty@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _SYS_DKTP_DADKIO_H
280Sstevel@tonic-gate #define	_SYS_DKTP_DADKIO_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef	__cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*	direct coupled disk driver ioctl command			*/
350Sstevel@tonic-gate #define	DIOCTL_GETGEOM		1	/* get logical disk geometry	*/
360Sstevel@tonic-gate #define	DIOCTL_GETPHYGEOM	2	/* get physical disk geometry	*/
370Sstevel@tonic-gate #define	DIOCTL_GETMODEL		3	/* get model number		*/
380Sstevel@tonic-gate #define	DIOCTL_GETSERIAL	4	/* get serial number		*/
390Sstevel@tonic-gate #define	DIOCTL_RWCMD		5	/* read/write a disk		*/
40789Sahrens #define	DIOCTL_GETWCE		6	/* get write cache enabled state */
41*7563SPrasad.Singamsetty@Sun.COM 
42*7563SPrasad.Singamsetty@Sun.COM #if !defined(BLKADDR_TYPE)
43*7563SPrasad.Singamsetty@Sun.COM #define	BLKADDR_TYPE
44*7563SPrasad.Singamsetty@Sun.COM #if defined(_EXTVTOC)
45*7563SPrasad.Singamsetty@Sun.COM typedef	unsigned long	blkaddr_t;
46*7563SPrasad.Singamsetty@Sun.COM typedef	unsigned int	blkaddr32_t;
47*7563SPrasad.Singamsetty@Sun.COM #else
48*7563SPrasad.Singamsetty@Sun.COM typedef	daddr_t		blkaddr_t;
49*7563SPrasad.Singamsetty@Sun.COM typedef	daddr32_t	blkaddr32_t;
50*7563SPrasad.Singamsetty@Sun.COM #endif
51*7563SPrasad.Singamsetty@Sun.COM #endif
52*7563SPrasad.Singamsetty@Sun.COM 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * arg structure for DIOCTL_GETMODEL and DIOCTL_GETSERIAL
550Sstevel@tonic-gate  * On input to the ioctl, is_size contains the size of the buffer
560Sstevel@tonic-gate  * pointed to by is_buf;
570Sstevel@tonic-gate  * On return, is_size contains the number of characters needed to
580Sstevel@tonic-gate  * represent the string.  This may be more than the input value, in
590Sstevel@tonic-gate  * which case the caller can choose to
600Sstevel@tonic-gate  *  1. Use the truncated string as is
610Sstevel@tonic-gate  *  2. Allocate a buffer of is_size+1 bytes to hold the string
620Sstevel@tonic-gate  */
630Sstevel@tonic-gate #ifdef _SYSCALL32
640Sstevel@tonic-gate typedef struct dadk_ioc_string32
650Sstevel@tonic-gate {
660Sstevel@tonic-gate 	caddr32_t	is_buf;		/* pointer to character array */
670Sstevel@tonic-gate 	int		is_size;	/* string length */
680Sstevel@tonic-gate } dadk_ioc_string32_t;
690Sstevel@tonic-gate #endif /* _SYSCALL32 */
700Sstevel@tonic-gate 
710Sstevel@tonic-gate typedef struct dadk_ioc_string
720Sstevel@tonic-gate {
730Sstevel@tonic-gate 	caddr_t		is_buf;		/* pointer to character array */
740Sstevel@tonic-gate 	int 		is_size;	/* string length */
750Sstevel@tonic-gate } dadk_ioc_string_t;
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*	direct coupled disk driver command				*/
780Sstevel@tonic-gate #define	DCMD_READ	1	/* Read Sectors/Blocks 			*/
790Sstevel@tonic-gate #define	DCMD_WRITE	2	/* Write Sectors/Blocks 		*/
800Sstevel@tonic-gate #define	DCMD_FMTTRK	3	/* Format Tracks 			*/
810Sstevel@tonic-gate #define	DCMD_FMTDRV	4	/* Format entire drive 			*/
820Sstevel@tonic-gate #define	DCMD_RECAL	5	/* Recalibrate 				*/
830Sstevel@tonic-gate #define	DCMD_SEEK	6	/* Seek to Cylinder 			*/
840Sstevel@tonic-gate #define	DCMD_RDVER	7	/* Read Verify sectors on disk 		*/
850Sstevel@tonic-gate #define	DCMD_GETDEF	8	/* Read manufacturers defect list	*/
860Sstevel@tonic-gate /* cd-rom commands */
870Sstevel@tonic-gate #define	DCMD_LOCK	9	/* Lock door				*/
880Sstevel@tonic-gate #define	DCMD_UNLOCK	10	/* Unlock door				*/
890Sstevel@tonic-gate #define	DCMD_START_MOTOR 11	/* Start motor				*/
900Sstevel@tonic-gate #define	DCMD_STOP_MOTOR 12	/* Stop motor				*/
910Sstevel@tonic-gate #define	DCMD_EJECT	13	/* Eject medium				*/
920Sstevel@tonic-gate #define	DCMD_UPDATE_GEOM 14	/* Update geometry			*/
930Sstevel@tonic-gate #define	DCMD_GET_STATE	15	/* Get removable disk status		*/
940Sstevel@tonic-gate #define	DCMD_PAUSE	16	/* cdrom pause				*/
950Sstevel@tonic-gate #define	DCMD_RESUME	17	/* cdrom resume				*/
960Sstevel@tonic-gate #define	DCMD_PLAYTRKIND	18	/* cdrom play by track and index	*/
970Sstevel@tonic-gate #define	DCMD_PLAYMSF	19	/* cdrom play msf			*/
980Sstevel@tonic-gate #define	DCMD_SUBCHNL	20	/* cdrom sub channel			*/
990Sstevel@tonic-gate #define	DCMD_READMODE1	21	/* cdrom read mode 1			*/
1000Sstevel@tonic-gate #define	DCMD_READTOCHDR	22	/* cdrom read table of contents header	*/
1010Sstevel@tonic-gate #define	DCMD_READTOCENT	23	/* cdrom read table of contents entry	*/
1020Sstevel@tonic-gate #define	DCMD_READOFFSET	24	/* cdrom read offset			*/
1030Sstevel@tonic-gate #define	DCMD_READMODE2	25	/* cdrom mode 2				*/
1040Sstevel@tonic-gate #define	DCMD_VOLCTRL	26	/* cdrom volume control			*/
105789Sahrens /* additional disk commands */
106789Sahrens #define	DCMD_FLUSH_CACHE 27	/* flush write cache to physical medium	*/
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*	driver error code						*/
1090Sstevel@tonic-gate #define	DERR_SUCCESS	0	/* success				*/
1100Sstevel@tonic-gate #define	DERR_AMNF	1	/* address mark not found		*/
1110Sstevel@tonic-gate #define	DERR_TKONF	2	/* track 0 not found			*/
1120Sstevel@tonic-gate #define	DERR_ABORT	3	/* aborted command			*/
1130Sstevel@tonic-gate #define	DERR_DWF	4	/* write fault				*/
1140Sstevel@tonic-gate #define	DERR_IDNF	5	/* ID not found				*/
1150Sstevel@tonic-gate #define	DERR_BUSY	6	/* drive busy				*/
1160Sstevel@tonic-gate #define	DERR_UNC	7	/* uncorrectable data error		*/
1170Sstevel@tonic-gate #define	DERR_BBK	8	/* bad block detected			*/
1180Sstevel@tonic-gate #define	DERR_INVCDB	9	/* invalid cdb				*/
1190Sstevel@tonic-gate #define	DERR_HARD	10	/* hard device error - no retry 	*/
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate  * atapi additional error codes
1220Sstevel@tonic-gate  */
1230Sstevel@tonic-gate #define	DERR_ILI	11	/* Illegal length indication		*/
1240Sstevel@tonic-gate #define	DERR_EOM	12	/* End of media detected		*/
1250Sstevel@tonic-gate #define	DERR_MCR	13	/* Media change requested		*/
1260Sstevel@tonic-gate /*
1270Sstevel@tonic-gate  * atapi (SCSI) sense key errors
1280Sstevel@tonic-gate  */
1290Sstevel@tonic-gate #define	DERR_RECOVER	14	/* Recovered from error			*/
1300Sstevel@tonic-gate #define	DERR_NOTREADY	15	/* Device not ready			*/
1310Sstevel@tonic-gate #define	DERR_MEDIUM	16	/* Medium error				*/
1320Sstevel@tonic-gate #define	DERR_HW		17	/* Hardware error			*/
1330Sstevel@tonic-gate #define	DERR_ILL	18	/* Illegal request			*/
1340Sstevel@tonic-gate #define	DERR_UNIT_ATTN	19	/* Unit attention			*/
1350Sstevel@tonic-gate #define	DERR_DATA_PROT	20	/* Data protection			*/
1360Sstevel@tonic-gate #define	DERR_MISCOMP	21	/* Miscompare				*/
137977Sdq159996 #define	DERR_ICRC	22	/* Interface CRC error -- new driver	*/
138977Sdq159996 				/* error code in ATA-4 and newer	*/
139977Sdq159996 #define	DERR_RESV	23	/* Reserved				*/
140977Sdq159996 
1410Sstevel@tonic-gate struct	dadkio_derr {
1420Sstevel@tonic-gate 	int	d_action;
1430Sstevel@tonic-gate 	int	d_severity;
1440Sstevel@tonic-gate };
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /*
1470Sstevel@tonic-gate  *  dadkio_rwcmd cmd
1480Sstevel@tonic-gate  */
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate #define	DADKIO_RWCMD_READ		1	/* read command */
1510Sstevel@tonic-gate #define	DADKIO_RWCMD_WRITE		2	/* write command */
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate /*
1540Sstevel@tonic-gate  * dadkio_rwcmd flags
1550Sstevel@tonic-gate  */
1560Sstevel@tonic-gate #define	DADKIO_FLAG_SILENT		0x01	/* driver should not */
1570Sstevel@tonic-gate 						/* generate any warning */
1580Sstevel@tonic-gate 						/* or error console msgs */
1590Sstevel@tonic-gate #define	DADKIO_FLAG_RESERVED		0x02	/* reserved/not used */
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #define	DADKIO_ERROR_INFO_LEN	128
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate /*
1650Sstevel@tonic-gate  * dadkio_status status value.
1660Sstevel@tonic-gate  */
1670Sstevel@tonic-gate struct dadkio_status {
1680Sstevel@tonic-gate 	int		status;
1690Sstevel@tonic-gate 	ulong_t		resid;
1700Sstevel@tonic-gate 	int		failed_blk_is_valid;
171*7563SPrasad.Singamsetty@Sun.COM 	blkaddr_t	failed_blk;
1720Sstevel@tonic-gate 	int		fru_code_is_valid;
1730Sstevel@tonic-gate 	int		fru_code;
1740Sstevel@tonic-gate 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
1750Sstevel@tonic-gate };
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate #ifdef _SYSCALL32
1780Sstevel@tonic-gate struct dadkio_status32 {
1790Sstevel@tonic-gate 	int		status;
1800Sstevel@tonic-gate 	uint32_t	resid;
1810Sstevel@tonic-gate 	int		failed_blk_is_valid;
182*7563SPrasad.Singamsetty@Sun.COM 	blkaddr32_t	failed_blk;
1830Sstevel@tonic-gate 	int		fru_code_is_valid;
1840Sstevel@tonic-gate 	int		fru_code;
1850Sstevel@tonic-gate 	char		add_error_info[DADKIO_ERROR_INFO_LEN];
1860Sstevel@tonic-gate };
1870Sstevel@tonic-gate #endif /* _SYSCALL32 */
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /*
1900Sstevel@tonic-gate  * Used by read/write ioctl (DKIOCTL_RWCMD)
1910Sstevel@tonic-gate  */
1920Sstevel@tonic-gate struct dadkio_rwcmd {
1930Sstevel@tonic-gate 	int			cmd;
1940Sstevel@tonic-gate 	int			flags;
195*7563SPrasad.Singamsetty@Sun.COM 	blkaddr_t		blkaddr;
1960Sstevel@tonic-gate 	uint_t			buflen;
1970Sstevel@tonic-gate 	caddr_t			bufaddr;
1980Sstevel@tonic-gate 	struct dadkio_status	status;
1990Sstevel@tonic-gate };
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate #ifdef _SYSCALL32
2020Sstevel@tonic-gate struct dadkio_rwcmd32 {
2030Sstevel@tonic-gate 	int			cmd;
2040Sstevel@tonic-gate 	int			flags;
205*7563SPrasad.Singamsetty@Sun.COM 	blkaddr32_t		blkaddr;
2060Sstevel@tonic-gate 	uint_t			buflen;
2070Sstevel@tonic-gate 	caddr32_t		bufaddr;
2080Sstevel@tonic-gate 	struct dadkio_status32	status;
2090Sstevel@tonic-gate };
2100Sstevel@tonic-gate #endif /* _SYSCALL32 */
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate /*
2130Sstevel@tonic-gate  * dadkio_status status values
2140Sstevel@tonic-gate  */
2150Sstevel@tonic-gate #define	DADKIO_STAT_NO_ERROR		0	/* cmd was successful */
2160Sstevel@tonic-gate #define	DADKIO_STAT_NOT_READY		1	/* device not ready */
2170Sstevel@tonic-gate #define	DADKIO_STAT_MEDIUM_ERROR	2	/* error on medium */
2180Sstevel@tonic-gate #define	DADKIO_STAT_HARDWARE_ERROR	3	/* other hardware error */
2190Sstevel@tonic-gate #define	DADKIO_STAT_ILLEGAL_REQUEST	4	/* illegal request */
2200Sstevel@tonic-gate #define	DADKIO_STAT_ILLEGAL_ADDRESS	5	/* illegal block address */
2210Sstevel@tonic-gate #define	DADKIO_STAT_WRITE_PROTECTED	6	/* device write-protected */
2220Sstevel@tonic-gate #define	DADKIO_STAT_TIMED_OUT		7	/* no response from device */
2230Sstevel@tonic-gate #define	DADKIO_STAT_PARITY		8	/* parity error in data */
2240Sstevel@tonic-gate #define	DADKIO_STAT_BUS_ERROR		9	/* error on bus */
2250Sstevel@tonic-gate #define	DADKIO_STAT_SOFT_ERROR		10	/* data recovered via ECC */
2260Sstevel@tonic-gate #define	DADKIO_STAT_NO_RESOURCES	11	/* no resources for cmd */
2270Sstevel@tonic-gate #define	DADKIO_STAT_NOT_FORMATTED	12	/* device is not formatted */
2280Sstevel@tonic-gate #define	DADKIO_STAT_RESERVED		13	/* device is reserved */
2290Sstevel@tonic-gate #define	DADKIO_STAT_NOT_SUPPORTED	14	/* feature not supported */
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate #ifdef	__cplusplus
2330Sstevel@tonic-gate }
2340Sstevel@tonic-gate #endif
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate #endif	/* _SYS_DKTP_DADKIO_H */
237