151974Smsmith/*-
251974Smsmith * Copyright (c) 1999 Michael Smith
351974Smsmith * All rights reserved.
451974Smsmith *
551974Smsmith * Redistribution and use in source and binary forms, with or without
651974Smsmith * modification, are permitted provided that the following conditions
751974Smsmith * are met:
851974Smsmith * 1. Redistributions of source code must retain the above copyright
951974Smsmith *    notice, this list of conditions and the following disclaimer.
1051974Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1151974Smsmith *    notice, this list of conditions and the following disclaimer in the
1251974Smsmith *    documentation and/or other materials provided with the distribution.
1351974Smsmith *
1451974Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1551974Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1651974Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1751974Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1851974Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1951974Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2051974Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2151974Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2251974Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2351974Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2451974Smsmith * SUCH DAMAGE.
2551974Smsmith *
26106225Semoore * Copyright (c) 2002 Eric Moore
27106225Semoore * Copyright (c) 2002 LSI Logic Corporation
28106225Semoore * All rights reserved.
29106225Semoore *
30106225Semoore * Redistribution and use in source and binary forms, with or without
31106225Semoore * modification, are permitted provided that the following conditions
32106225Semoore * are met:
33106225Semoore * 1. Redistributions of source code must retain the above copyright
34106225Semoore *    notice, this list of conditions and the following disclaimer.
35106225Semoore * 2. Redistributions in binary form must reproduce the above copyright
36106225Semoore *    notice, this list of conditions and the following disclaimer in the
37106225Semoore *    documentation and/or other materials provided with the distribution.
38105419Semoore * 3. The party using or redistributing the source code and binary forms
39106225Semoore *    agrees to the disclaimer below and the terms and conditions set forth
40105419Semoore *    herein.
41105419Semoore *
42106225Semoore * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
43106225Semoore * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44106225Semoore * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45106225Semoore * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
46106225Semoore * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47106225Semoore * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48106225Semoore * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49106225Semoore * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50106225Semoore * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51106225Semoore * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52106225Semoore * SUCH DAMAGE.
53105419Semoore *
54106225Semoore *
5551974Smsmith *	$FreeBSD$
5651974Smsmith */
5751974Smsmith
5852784Smsmith/*
5965245Smsmith * ioctl interface
6052784Smsmith */
6152784Smsmith
6265245Smsmith#include <sys/ioccom.h>
63133870Sambrisko#include <sys/param.h>
6465245Smsmith
6565245Smsmith/*
6665245Smsmith * Fetch the driver's interface version.
6765245Smsmith */
68153409Sscottl#define AMR_IO_VERSION_NUMBER	153
6965245Smsmith#define AMR_IO_VERSION	_IOR('A', 0x200, int)
7065245Smsmith
7165245Smsmith/*
7265245Smsmith * Pass a command from userspace through to the adapter.
7365245Smsmith *
7465245Smsmith * Note that in order to be code-compatible with the Linux
7565245Smsmith * interface where possible, the formatting of the au_cmd field is
7665245Smsmith * somewhat Interesting.
7765245Smsmith *
7865245Smsmith * For normal commands, the layout is (fields from struct amr_mailbox_ioctl):
7965245Smsmith *
8065245Smsmith * 0		mb_command
8165245Smsmith * 1		mb_channel
8265245Smsmith * 2		mb_param
8365245Smsmith * 3		mb_pad[0]
8465245Smsmith * 4		mb_drive
8565245Smsmith *
8665245Smsmith * For SCSI passthrough commands, the layout is:
8765245Smsmith *
8865245Smsmith * 0		AMR_CMD_PASS	(0x3)
8965245Smsmith * 1		reserved, 0
9065245Smsmith * 2		cdb length
9165245Smsmith * 3		cdb data
9265245Smsmith * 3+cdb_len	passthrough control byte (timeout, ars, islogical)
9365245Smsmith * 4+cdb_len	reserved, 0
9465245Smsmith * 5+cdb_len	channel
9565245Smsmith * 6+cdb_len	target
9665245Smsmith */
9765245Smsmith
9865245Smsmithstruct amr_user_ioctl {
9965245Smsmith    unsigned char	au_cmd[32];	/* command text from userspace */
10065245Smsmith    void		*au_buffer;	/* data buffer in userspace */
10165245Smsmith    unsigned long	au_length;	/* data buffer size (0 == no data) */
10265245Smsmith    int			au_direction;	/* data transfer direction */
10365245Smsmith#define AMR_IO_NODATA	0
10465245Smsmith#define AMR_IO_READ	1
10565245Smsmith#define AMR_IO_WRITE	2
10665245Smsmith    int			au_status;	/* command status returned by adapter */
10765245Smsmith};
10865245Smsmith
10965245Smsmith#define AMR_IO_COMMAND	_IOWR('A', 0x201, struct amr_user_ioctl)
11065245Smsmith
111133870Sambrisko#if defined(__amd64__) || defined(__ia64__)
112133870Sambrisko
113133870Sambriskostruct amr_user_ioctl32 {
114133870Sambrisko    unsigned char	au_cmd[32];	/* command text from userspace */
115133870Sambrisko    u_int32_t		au_buffer;	/* 32-bit pointer to uspace buf */
116133870Sambrisko    u_int32_t		au_length;	/* length of the uspace buffer */
117133870Sambrisko    int32_t		au_direction;	/* data transfer direction */
118133870Sambrisko    int32_t		au_status;	/* command status returned by adapter */
119133870Sambrisko};
120133870Sambrisko
121133870Sambrisko#	define AMR_IO_COMMAND32	_IOWR('A', 0x201, struct amr_user_ioctl32)
122133870Sambrisko#endif
123