110791Sjoehw/*-
210791Sjoehw * Copyright (c) 1999 Michael Smith
310791Sjoehw * All rights reserved.
410791Sjoehw *
510791Sjoehw * Redistribution and use in source and binary forms, with or without
610791Sjoehw * modification, are permitted provided that the following conditions
710791Sjoehw * are met:
810791Sjoehw * 1. Redistributions of source code must retain the above copyright
910791Sjoehw *    notice, this list of conditions and the following disclaimer.
1010791Sjoehw * 2. Redistributions in binary form must reproduce the above copyright
1110791Sjoehw *    notice, this list of conditions and the following disclaimer in the
1210791Sjoehw *    documentation and/or other materials provided with the distribution.
1310791Sjoehw *
1410791Sjoehw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1510791Sjoehw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1610791Sjoehw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1710791Sjoehw * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1810791Sjoehw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1910791Sjoehw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2010791Sjoehw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2110791Sjoehw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2210791Sjoehw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2310791Sjoehw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2410791Sjoehw * SUCH DAMAGE.
2510791Sjoehw *
2610791Sjoehw * Copyright (c) 2002 Eric Moore
2710791Sjoehw * Copyright (c) 2002 LSI Logic Corporation
2810791Sjoehw * All rights reserved.
2910791Sjoehw *
3010791Sjoehw * Redistribution and use in source and binary forms, with or without
3110791Sjoehw * modification, are permitted provided that the following conditions
3210791Sjoehw * are met:
3310791Sjoehw * 1. Redistributions of source code must retain the above copyright
3410791Sjoehw *    notice, this list of conditions and the following disclaimer.
3510791Sjoehw * 2. Redistributions in binary form must reproduce the above copyright
3610791Sjoehw *    notice, this list of conditions and the following disclaimer in the
3710791Sjoehw *    documentation and/or other materials provided with the distribution.
3810791Sjoehw * 3. The party using or redistributing the source code and binary forms
3910791Sjoehw *    agrees to the disclaimer below and the terms and conditions set forth
4010791Sjoehw *    herein.
4110791Sjoehw *
4210791Sjoehw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
4310791Sjoehw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4410791Sjoehw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4510791Sjoehw * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4610791Sjoehw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4710791Sjoehw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4810791Sjoehw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4910791Sjoehw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5010791Sjoehw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5110791Sjoehw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5210791Sjoehw * SUCH DAMAGE.
5310791Sjoehw *
5410791Sjoehw *
5510791Sjoehw *	$FreeBSD$
5610791Sjoehw */
5710791Sjoehw
5810791Sjoehw/*
5910791Sjoehw * ioctl interface
6010791Sjoehw */
6110791Sjoehw
6210791Sjoehw#include <sys/ioccom.h>
6310791Sjoehw#include <sys/param.h>
6410791Sjoehw
6510791Sjoehw/*
6610791Sjoehw * Fetch the driver's interface version.
6710791Sjoehw */
6810791Sjoehw#define AMR_IO_VERSION_NUMBER	153
6910791Sjoehw#define AMR_IO_VERSION	_IOR('A', 0x200, int)
7010791Sjoehw
7110791Sjoehw/*
7210791Sjoehw * Pass a command from userspace through to the adapter.
7310791Sjoehw *
7410791Sjoehw * Note that in order to be code-compatible with the Linux
7510791Sjoehw * interface where possible, the formatting of the au_cmd field is
7610791Sjoehw * somewhat Interesting.
7710791Sjoehw *
7810791Sjoehw * For normal commands, the layout is (fields from struct amr_mailbox_ioctl):
7910791Sjoehw *
8010791Sjoehw * 0		mb_command
8110791Sjoehw * 1		mb_channel
8210791Sjoehw * 2		mb_param
8310791Sjoehw * 3		mb_pad[0]
8410791Sjoehw * 4		mb_drive
8510791Sjoehw *
8610791Sjoehw * For SCSI passthrough commands, the layout is:
8710791Sjoehw *
8810791Sjoehw * 0		AMR_CMD_PASS	(0x3)
8910791Sjoehw * 1		reserved, 0
9010791Sjoehw * 2		cdb length
9110791Sjoehw * 3		cdb data
9210791Sjoehw * 3+cdb_len	passthrough control byte (timeout, ars, islogical)
9310791Sjoehw * 4+cdb_len	reserved, 0
9410791Sjoehw * 5+cdb_len	channel
9510791Sjoehw * 6+cdb_len	target
9610791Sjoehw */
9710791Sjoehw
9810791Sjoehwstruct amr_user_ioctl {
9910791Sjoehw    unsigned char	au_cmd[32];	/* command text from userspace */
10010791Sjoehw    void		*au_buffer;	/* data buffer in userspace */
10110791Sjoehw    unsigned long	au_length;	/* data buffer size (0 == no data) */
10210791Sjoehw    int			au_direction;	/* data transfer direction */
10310791Sjoehw#define AMR_IO_NODATA	0
10410791Sjoehw#define AMR_IO_READ	1
10510791Sjoehw#define AMR_IO_WRITE	2
10610791Sjoehw    int			au_status;	/* command status returned by adapter */
10710791Sjoehw};
10810791Sjoehw
10910791Sjoehw#define AMR_IO_COMMAND	_IOWR('A', 0x201, struct amr_user_ioctl)
11010791Sjoehw
11110791Sjoehw#if defined(__amd64__) || defined(__ia64__)
11210791Sjoehw
11310791Sjoehwstruct amr_user_ioctl32 {
11410791Sjoehw    unsigned char	au_cmd[32];	/* command text from userspace */
11510791Sjoehw    u_int32_t		au_buffer;	/* 32-bit pointer to uspace buf */
11610791Sjoehw    u_int32_t		au_length;	/* length of the uspace buffer */
11710791Sjoehw    int32_t		au_direction;	/* data transfer direction */
11810791Sjoehw    int32_t		au_status;	/* command status returned by adapter */
11910791Sjoehw};
12010791Sjoehw
12110791Sjoehw#	define AMR_IO_COMMAND32	_IOWR('A', 0x201, struct amr_user_ioctl32)
12210791Sjoehw#endif
12310791Sjoehw