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 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_USB_BULKONLY_H 28 #define _SYS_USB_BULKONLY_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * usb_bulkonly.h: This header file provides the data structures 38 * and variable definitions for the mass storage bulk only protocol. 39 * (See Universal Serial Bus Mass Storage Class Bulk-Only Transport rev 1.0) 40 */ 41 42 /* Reset value to be passed */ 43 #define BULK_ONLY_RESET 0xFF 44 /* Bulk Class specific req */ 45 /* Bulk Class specific GET_Max_LUN bmRequest value */ 46 #define BULK_ONLY_GET_MAXLUN_BMREQ \ 47 (USB_DEV_REQ_DEV_TO_HOST | USB_DEV_REQ_TYPE_CLASS | \ 48 USB_DEV_REQ_RCPT_IF) 49 /* Bulk Class specific GET_Max_LUN bRequest value */ 50 #define BULK_ONLY_GET_MAXLUN_REQ 0xFE 51 52 /* 53 * Command Block Wrapper: 54 * The CBW is used to transfer commands to the device. 55 */ 56 #define CBW_SIGNATURE 0x43425355 /* "USBC" */ 57 #define CBW_DIR_IN 0x80 /* CBW from device to the host */ 58 #define CBW_DIR_OUT 0x00 /* CBW from host to the device */ 59 #define CBW_CDB_LEN 16 /* CDB Len to 10 byte cmds */ 60 61 #define USB_BULK_CBWCMD_LEN 0x1F 62 63 #define CBW_MSB(x) ((x) & 0xFF) /* Swap msb */ 64 #define CBW_MID1(x) ((x) >> 8 & 0xFF) 65 #define CBW_MID2(x) ((x) >> 16 & 0xFF) 66 #define CBW_LSB(x) ((x) >> 24 & 0xFF) 67 68 /* 69 * Command Status Wrapper: 70 * The device shall not execute any subsequent command until the 71 * associated CSW from the previous command has been successfully 72 * transported. 73 * 74 * All CSW transfers shall be ordered withe LSB first. 75 */ 76 typedef struct usb_bulk_csw { 77 uchar_t csw_dCSWSignature0; /* Signature */ 78 uchar_t csw_dCSWSignature1; 79 uchar_t csw_dCSWSignature2; 80 uchar_t csw_dCSWSignature3; 81 uchar_t csw_dCSWTag3; /* random tag */ 82 uchar_t csw_dCSWTag2; 83 uchar_t csw_dCSWTag1; 84 uchar_t csw_dCSWTag0; 85 uchar_t csw_dCSWDataResidue0; /* data not transferred */ 86 uchar_t csw_dCSWDataResidue1; 87 uchar_t csw_dCSWDataResidue2; 88 uchar_t csw_dCSWDataResidue3; 89 uchar_t csw_bCSWStatus; /* command status */ 90 } usb_bulk_csw_t; 91 92 #define CSW_SIGNATURE 0x53425355 /* "SBSU" */ 93 94 #define CSW_STATUS_GOOD 0x0 /* Good status */ 95 #define CSW_STATUS_FAILED 0x1 /* Command failed */ 96 #define CSW_STATUS_PHASE_ERROR 0x2 /* Phase error */ 97 #define CSW_LEN 0xD /* CSW Command Len */ 98 99 /* Vendor specific command needed for specific Bulk Only devices */ 100 #define IOMEGA_CMD_CARTRIDGE_PROTECT 0x0C 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* _SYS_USB_BULKONLY_H */ 107