1/**************************************************************************** 2 * include/nuttx/usb/storage.h 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one or more 5 * contributor license agreements. See the NOTICE file distributed with 6 * this work for additional information regarding copyright ownership. The 7 * ASF licenses this file to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance with the 9 * License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16 * License for the specific language governing permissions and limitations 17 * under the License. 18 * 19 ****************************************************************************/ 20 21#ifndef __INCLUDE_NUTTX_USB_STORAGE_H 22#define __INCLUDE_NUTTX_USB_STORAGE_H 23 24/**************************************************************************** 25 * Included Files 26 ****************************************************************************/ 27 28/**************************************************************************** 29 * Pre-processor Definitions 30 ****************************************************************************/ 31 32/* Mass storage requests */ 33 34#define USBMSC_TYPE_SETUPIN (USB_DIR_IN|UT_CLASS|UT_INTERFACE) 35#define USBMSC_TYPE_SETUPOUT (USB_DIR_OUT|UT_CLASS|UT_INTERFACE) 36 37#define USBMSC_REQ_MSRESET (0xff) /* Reset mass storage device and interface */ 38#define USBMSC_REQ_GETMAXLUN (0xfe) /* Return number LUNs supported */ 39 40/* Mass storage subclass codes */ 41 42#define USBMSC_SUBCLASS_RBC (0x01) /* Reduced block commands (e.g., flash devices) */ 43#define USBMSC_SUBCLASS_SFF1 (0x02) /* SFF-8020i/MMC-2 (ATAPI) (e.g., C/DVD) */ 44#define USBMSC_SUBCLASS_QIC (0x03) /* QIC-157 (e.g., tape device) */ 45#define USBMSC_SUBCLASS_UFI (0x04) /* e.g. floppy device */ 46#define USBMSC_SUBCLASS_SFF2 (0x05) /* SFF-8070i (e.g. floppy disk) */ 47#define USBMSC_SUBCLASS_SCSI (0x06) /* SCSI transparent */ 48 49#define UMASS_ATTACH_PRENAME "/dev/sd" 50#define MASS_NAME 10 51#define MAX_DEVICE 5 52 53/* Mass storage transport protocols */ 54 55#define USBMSC_PROTO_CBI0 (0x00) /* CBI transport with command completion interrupt */ 56#define USBMSC_PROTO_CBI1 (0x01) /* CBI transport without command completion interrupt */ 57#define USBMSC_PROTO_BULKONLY (0x50) /* Bulk only transport */ 58 59/* Common Block Wrapper (CBW) */ 60 61#define USBMSC_CBW_SIZEOF (31) 62#define USBMSC_CBW_SIGNATURE (0x43425355) /* Little endian USBC */ 63#define USBMSC_CBWFLAG_IN (0x80) /* Bit 7=1: Direction = IN */ 64 65#define USBMSC_MAXCDBLEN (16) /* Max length of SCSI Command Data Block */ 66 67/* Command Status Wrapper (CSW) */ 68 69#define USBMSC_CSW_SIZEOF (13) 70#define USBMSC_CSW_SIGNATURE (0x53425355) /* Little endian 'USBS' */ 71#define USBMSC_CSWSTATUS_PASS (0) 72#define USBMSC_CSWSTATUS_FAIL (1) 73#define USBMSC_CSWSTATUS_PHASEERROR (2) 74 75/**************************************************************************** 76 * Public Types 77 ****************************************************************************/ 78 79/* Command Block Wrapper (CBW) */ 80 81struct usbmsc_cbw_s 82{ 83 uint8_t signature[4]; /* 'USBC' = 0x43425355 */ 84 uint8_t tag[4]; /* Depends on command id */ 85 uint8_t datlen[4]; /* Number of bytes that host expects to transfer */ 86 uint8_t flags; /* Bit 7: Direction=IN (other obsolete or reserved) */ 87 uint8_t lun; /* LUN (normally 0) */ 88 uint8_t cdblen; /* len of cdb[] */ 89 uint8_t cdb[USBMSC_MAXCDBLEN]; /* Command Data Block */ 90}; 91 92/* Command Status Wrapper (CSW) */ 93 94struct usbmsc_csw_s 95{ 96 uint8_t signature[4]; /* 'USBS' = 0x53425355 */ 97 uint8_t tag[4]; /* Same tag as original command */ 98 uint8_t residue[4]; /* Amount not transferred */ 99 uint8_t status; /* Status of transfer */ 100}; 101 102/**************************************************************************** 103 * Public Data 104 ****************************************************************************/ 105 106/**************************************************************************** 107 * Public Functions Definitions 108 ****************************************************************************/ 109 110#endif /* __INCLUDE_NUTTX_USB_STORAGE_H */