xref: /titanic_50/usr/src/uts/common/sys/usb/clients/mass_storage/usb_bulkonly.h (revision d29f5a711240f866521445b1656d114da090335e)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_USB_BULKONLY_H
27 #define	_SYS_USB_BULKONLY_H
28 
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * usb_bulkonly.h: This header file provides the data structures
36  * and variable definitions for the mass storage bulk only protocol.
37  * (See Universal Serial Bus Mass Storage Class Bulk-Only Transport rev 1.0)
38  */
39 
40 /* Reset value to be passed */
41 #define	BULK_ONLY_RESET			0xFF
42 /* Bulk Class specific req  */
43 /* Bulk Class specific GET_Max_LUN bmRequest value */
44 #define	BULK_ONLY_GET_MAXLUN_BMREQ \
45 	(USB_DEV_REQ_DEV_TO_HOST | USB_DEV_REQ_TYPE_CLASS | \
46 		USB_DEV_REQ_RCPT_IF)
47 /* Bulk Class specific GET_Max_LUN bRequest value */
48 #define	BULK_ONLY_GET_MAXLUN_REQ	0xFE
49 
50 /*
51  * Command Block Wrapper:
52  *	The CBW is used to transfer commands to the device.
53  */
54 #define	CBW_SIGNATURE	0x43425355	/* "USBC" */
55 #define	CBW_DIR_IN	0x80		/* CBW from device to the host */
56 #define	CBW_DIR_OUT	0x00		/* CBW from host to the device */
57 #define	CBW_CDB_LEN	16		/* CDB Len to 10 byte cmds */
58 
59 #define	USB_BULK_CBWCMD_LEN	0x1F
60 
61 #define	CBW_MSB(x)	((x) & 0xFF)		/* Swap msb */
62 #define	CBW_MID1(x)	((x) >> 8 & 0xFF)
63 #define	CBW_MID2(x)	((x) >> 16 & 0xFF)
64 #define	CBW_LSB(x)	((x) >> 24 & 0xFF)
65 
66 /*
67  * Command Status Wrapper:
68  *	The device shall not execute any subsequent command until the
69  *	associated CSW from the previous command has been successfully
70  *	transported.
71  *
72  *	All CSW transfers shall be ordered withe LSB first.
73  */
74 typedef	struct usb_bulk_csw {
75 	uchar_t	csw_dCSWSignature0;	/* Signature */
76 	uchar_t	csw_dCSWSignature1;
77 	uchar_t	csw_dCSWSignature2;
78 	uchar_t	csw_dCSWSignature3;
79 	uchar_t	csw_dCSWTag3;		/* random tag */
80 	uchar_t	csw_dCSWTag2;
81 	uchar_t	csw_dCSWTag1;
82 	uchar_t	csw_dCSWTag0;
83 	uchar_t	csw_dCSWDataResidue0;	/* data not transferred */
84 	uchar_t	csw_dCSWDataResidue1;
85 	uchar_t	csw_dCSWDataResidue2;
86 	uchar_t	csw_dCSWDataResidue3;
87 	uchar_t	csw_bCSWStatus;		/* command status */
88 } usb_bulk_csw_t;
89 
90 #define	CSW_SIGNATURE	0x53425355	/* "SBSU" */
91 
92 #define	CSW_STATUS_GOOD		0x0	/* Good status */
93 #define	CSW_STATUS_FAILED	0x1	/* Command failed */
94 #define	CSW_STATUS_PHASE_ERROR	0x2	/* Phase error */
95 #define	CSW_LEN			0xD	/* CSW Command Len */
96 
97 /* Vendor specific command needed for specific Bulk Only devices */
98 #define	IOMEGA_CMD_CARTRIDGE_PROTECT	0x0C
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif	/* _SYS_USB_BULKONLY_H */
105