1 /* $NetBSD: amrio.h,v 1.1 2006/07/23 12:01:26 bouyer Exp $ */
2 
3 /*-
4  * Copyright (c) 1999 Michael Smith
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * Copyright (c) 2002 Eric Moore
29  * Copyright (c) 2002 LSI Logic Corporation
30  * All rights reserved.
31  *
32  * Redistribution and use in source and binary forms, with or without
33  * modification, are permitted provided that the following conditions
34  * are met:
35  * 1. Redistributions of source code must retain the above copyright
36  *    notice, this list of conditions and the following disclaimer.
37  * 2. Redistributions in binary form must reproduce the above copyright
38  *    notice, this list of conditions and the following disclaimer in the
39  *    documentation and/or other materials provided with the distribution.
40  * 3. The party using or redistributing the source code and binary forms
41  *    agrees to the disclaimer below and the terms and conditions set forth
42  *    herein.
43  *
44  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
45  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
48  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54  * SUCH DAMAGE.
55  *
56  *
57  *	FreeBSD: src/sys/dev/amr/amrio.h,v 1.7 2005/12/14 03:26:49 scottl Exp
58  */
59 
60 /*
61  * ioctl interface
62  */
63 
64 #include <sys/ioccom.h>
65 #include <sys/param.h>
66 
67 /*
68  * Fetch the driver's interface version.
69  */
70 #define AMR_IO_VERSION_NUMBER	153
71 #define AMR_IO_VERSION	_IOR('A', 0x200, int)
72 
73 /*
74  * Pass a command from userspace through to the adapter.
75  *
76  * Note that in order to be code-compatible with the Linux
77  * interface where possible, the formatting of the au_cmd field is
78  * somewhat Interesting.
79  *
80  * For normal commands, the layout is (fields from struct amr_mailbox_ioctl):
81  *
82  * 0		mb_command
83  * 1		mb_channel
84  * 2		mb_param
85  * 3		mb_pad[0]
86  * 4		mb_drive
87  *
88  * For SCSI passthrough commands, the layout is:
89  *
90  * 0		AMR_CMD_PASS	(0x3)
91  * 1		reserved, 0
92  * 2		cdb length
93  * 3		cdb data
94  * 3+cdb_len	passthrough control byte (timeout, ars, islogical)
95  * 4+cdb_len	reserved, 0
96  * 5+cdb_len	channel
97  * 6+cdb_len	target
98  */
99 
100 struct amr_user_ioctl {
101     unsigned char	au_cmd[32];	/* command text from userspace */
102     void		*au_buffer;	/* data buffer in userspace */
103     unsigned long	au_length;	/* data buffer size (0 == no data) */
104     int			au_direction;	/* data transfer direction */
105 #define AMR_IO_NODATA	0
106 #define AMR_IO_READ	1
107 #define AMR_IO_WRITE	2
108     int			au_status;	/* command status returned by adapter */
109 };
110 
111 #define AMR_IO_COMMAND	_IOWR('A', 0x201, struct amr_user_ioctl)
112 
113 #if 0 /* defined(__amd64__) || defined(__ia64__) */
114 
115 struct amr_user_ioctl32 {
116     unsigned char	au_cmd[32];	/* command text from userspace */
117     u_int32_t		au_buffer;	/* 32-bit pointer to uspace buf */
118     u_int32_t		au_length;	/* length of the uspace buffer */
119     int32_t		au_direction;	/* data transfer direction */
120     int32_t		au_status;	/* command status returned by adapter */
121 };
122 
123 #	define AMR_IO_COMMAND32	_IOWR('A', 0x201, struct amr_user_ioctl32)
124 #endif
125