diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-10-22 16:20:18 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-10-22 16:20:18 +0000 |
commit | 87bf23596937f76ca7910cfd01d84e7b7226ec62 (patch) | |
tree | ed7aa5d74929fef1ce1cdca15feeea71f0da5222 /nuttx/include/nuttx/usb_bulk.h | |
parent | 4261a7a4b966c391b88c4e9c6b9df4141ae93430 (diff) | |
download | nuttx-87bf23596937f76ca7910cfd01d84e7b7226ec62.tar.gz nuttx-87bf23596937f76ca7910cfd01d84e7b7226ec62.tar.bz2 nuttx-87bf23596937f76ca7910cfd01d84e7b7226ec62.zip |
Building environment for USB storage
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1061 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include/nuttx/usb_bulk.h')
-rw-r--r-- | nuttx/include/nuttx/usb_bulk.h | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/nuttx/include/nuttx/usb_bulk.h b/nuttx/include/nuttx/usb_bulk.h new file mode 100644 index 000000000..2bd99a4d3 --- /dev/null +++ b/nuttx/include/nuttx/usb_bulk.h @@ -0,0 +1,139 @@ +/************************************************************************************ + * include/nuttx/usb_bulk.h + * + * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * References: + * "Universal Serial Bus Mass Storage Class, Specification Overview," + * Revision 1.2, USB Implementer's Forum, June 23, 2003. + * + * "Universal Serial Bus Mass Storage Class, Bulk-Only Transport," + * Revision 1.0, USB Implementer's Forum, September 31, 1999. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +#ifndef __NUTTX_USB_BULK_H +#define __NUTTX_USB_BULK_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include <nuttx/config.h> +#include <sys/types.h> + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/* Mass storage requests */ + +#define USBSTRG_TYPE_SETUPIN (USB_DIR_IN|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE) +#define USBSTRG_TYPE_SETUPOUT (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE) + +#define USBSTRG_REQ_MSRESET (0xff) /* Reset mass storage device and interface */ +#define USBSTRG_REQ_GETMAXLUN (0xfe) /* Return number LUNs supported */ + +/* Mass storage subclass codes */ + +#define USBSTRG_SUBCLASS_RBC (0x01) /* Reduced block commands (e.g., flash devices) */ +#define SUBSTRG_SUBCLASS_SFF1 (0x02) /* SFF-8020i/MMC-2 (ATAPI) (e.g., C/DVD) */ +#define SUBSTRG_SUBCLASS_QIC (0x03) /* QIC-157 (e.g., tape device) */ +#define SUBSTRG_SUBCLASS_UFI (0x04) /* e.g. floppy device */ +#define SUBSTRG_SUBCLASS_SFF2 (0x05) /* SFF-8070i (e.g. floppy disk) */ +#define SUBSTRG_SUBCLASS_SCSI (0x06) /* SCSI transparent */ + +/* Mass storage transport protocols */ + +#define USBSTRG_PROTO_CBI0 (0x00) /* CBI transport with command completion interrupt */ +#define USBSTRG_PROTO_CBI1 (0x01) /* CBI transport without command completion interrupt */ +#define USBSTRG_PROTO_BULKONLY (0x50) /* Bulk only transport */ + +/* Common Block Wrapper (CBW) */ + +#define USBSTRG_CBW_SIZEOF (31) +#define USBSTRG_CBW_SIGNATURE (0x43425355) /* Little endian USBC */ +#define USBSTRG_CBWFLAG_IN (0x80) /* Bit 7=1: Direction = IN */ + +#define USBSTRG_MAXCDBLEN (16) /* Max length of SCSI Command Data Block */ + +/* Command Status Wrapper (CSW) */ + +#define USBSTRG_CSW_SIZEOF (13) +#define USBSTRG_CSW_SIGNATURE (0x53425355) /* Little endian 'USBS' */ +#define USBSTRG_CSWSTATUS_PASS (0) +#define USBSTRG_CSWSTATUS_FAIL (1) +#define USBSTRG_CSWSTATUS_PHASEERROR (2) + +/************************************************************************************ + * Public Types + ************************************************************************************/ + +/* Command Block Wrapper (CBW) */ + +struct usbstrg_cbw_s +{ + ubyte signature[4]; /* 'USBC' = 0x43425355 */ + ubyte tag[4]; /* Depends on command id */ + ubyte datlen[4]; /* Number of bytes that host expects to transfer */ + ubyte flags; /* Bit 7: Direction=IN (other obsolete or reserved) */ + ubyte lun; /* LUN (normally 0) */ + ubyte cdblen; /* len of cdb[] */ + ubyte cdb[USBSTRG_MAXCDBLEN]; /* Command Data Block */ +}; + +/* Command Status Wrapper (CSW) */ + +struct usbstrg_csw_s +{ + ubyte signature[4]; /* 'USBS' = 0x53425355 */ + ubyte tag[4]; /* Same tag as original command */ + ubyte residue[4]; /* Amount not transferred */ + ubyte status; /* Status of transfer */ +}; + +/************************************************************************************ + * Private Data + ************************************************************************************/ + +/************************************************************************************ + * Public Data + ************************************************************************************/ + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +#endif // __NUTTX_USB_BULK_H |