xref: /titanic_41/usr/src/uts/sun/sys/dada/impl/udcd.h (revision cde2885fdf538266ee2a3b08dee2d5075ce8fa2b)
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_DADA_IMPL_UDCD_H
28 #define	_SYS_DADA_IMPL_UDCD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * definition for user dcd command  structure
38  */
39 
40 struct udcd_cmd {
41 	uchar_t	udcd_error_reg;	/* The error register value */
42 	uchar_t	udcd_status_reg; /* The status register */
43 	ushort_t	udcd_status;	/* The resulting status */
44 	ushort_t	udcd_timeout;	/* Timeout value for completion */
45 	int	udcd_flags;	/* Flags for specifying  read,write etc. */
46 	uint_t	udcd_resid;	/* This is the resid */
47 	uint_t	udcd_buflen;	/* Size of the io request */
48 	caddr_t	udcd_bufaddr;	/* Place to take the data or put the data in */
49 	struct  dcd_cmd *udcd_cmd; /* Command to be sent out */
50 	caddr_t	udcd_reserved;	/* reserved for future use */
51 	uint_t	version_no;	/* Version number for this struct */
52 };
53 
54 #if defined(_SYSCALL32)
55 struct udcd_cmd32 {
56 	uchar_t   udcd_error_reg;	/* The error register value */
57 	uchar_t   udcd_status_reg; /* The status register */
58 	ushort_t  udcd_status;	/* The resulting status */
59 	ushort_t  udcd_timeout;	/* Timeout value for completion */
60 	int	  udcd_flags;	/* Flags for specifying  read,write etc. */
61 	uint_t    udcd_resid;	/* This is the resid */
62 	uint_t    udcd_buflen;	/* Size of the io request */
63 	caddr32_t udcd_bufaddr; /* Place to take the data or put the data in */
64 	caddr32_t udcd_cmd; /* Command to be sent out */
65 	caddr32_t udcd_reserved;	/* reserved for future use */
66 	uint_t    version_no;	/* Version number for this struct */
67 };
68 
69 #define	udcd_cmd32toudcd_cmd(u32, ucmd)					\
70 	ucmd->udcd_error_reg	= u32->udcd_error_reg;			\
71 	ucmd->udcd_status_reg	= u32->udcd_status_reg;			\
72 	ucmd->udcd_status	= u32->udcd_status;			\
73 	ucmd->udcd_timeout	= u32->udcd_timeout;			\
74 	ucmd->udcd_flags	= u32->udcd_flags;			\
75 	ucmd->udcd_resid	= u32->udcd_resid;			\
76 	ucmd->udcd_buflen	= u32->udcd_buflen;			\
77 	ucmd->udcd_bufaddr	= (caddr_t)(uintptr_t)u32->udcd_bufaddr; \
78 	ucmd->udcd_cmd		= (struct  dcd_cmd *)(uintptr_t)u32->udcd_cmd; \
79 	ucmd->udcd_reserved	= (caddr_t)(uintptr_t)u32->udcd_reserved; \
80 	ucmd->version_no	= u32->version_no;
81 
82 #define	udcd_cmdtoudcd_cmd32(ucmd, u32)					\
83 	u32->udcd_error_reg	= ucmd->udcd_error_reg;			\
84 	u32->udcd_status_reg	= ucmd->udcd_status_reg;		\
85 	u32->udcd_status	= ucmd->udcd_status;			\
86 	u32->udcd_timeout	= ucmd->udcd_timeout;			\
87 	u32->udcd_flags		= ucmd->udcd_flags;			\
88 	u32->udcd_resid		= ucmd->udcd_resid;			\
89 	u32->udcd_buflen	= ucmd->udcd_buflen;			\
90 	u32->udcd_bufaddr	= (caddr32_t)(uintptr_t)ucmd->udcd_bufaddr; \
91 	u32->udcd_cmd		= (caddr32_t)(uintptr_t)ucmd->udcd_cmd;	\
92 	u32->udcd_reserved	= (caddr32_t)(uintptr_t)ucmd->udcd_reserved; \
93 	u32->version_no		= ucmd->version_no;
94 
95 #endif /* _SYSCALL32 */
96 
97 
98 /*
99  * Flags for the Udcd_flags field
100  */
101 #define	UDCD_WRITE	0x00000 /* Send data to device */
102 #define	UDCD_SILENT	0x00001	/* no error messages */
103 #define	UDCD_DIAGNOSE	0x00002 /* Fail of any error occurs */
104 #define	UDCD_ISOLATE	0x00004	/* isolate from normal command */
105 #define	UDCD_READ	0x00008	/* Read data from device */
106 #define	UDCD_NOINTR	0x00040 /*  No interrupts */
107 #define	UDCD_RESET	0x04000 /* Reset the target */
108 
109 
110 /*
111  * User ATA io control command
112  */
113 #define	UDCDIOC	(0x05 << 8)
114 #define	UDCDCMD	(UDCDIOC|201) /* User dcd command */
115 
116 #ifdef	__cplusplus
117 }
118 #endif
119 
120 #endif /* _SYS_DADA_IMPL_UDCD_H */
121