NUC472_NUC442_BSP V3.03.005
The Board Support Package for NUC472/NUC442
UmasTransport.h
Go to the documentation of this file.
1/* Driver for USB Mass Storage compliant devices
2 * Transport Functions Header File
3 *
4 * $Id: transport.h,v 1.13 2000/10/03 01:06:07 mdharm Exp $
5 *
6 * Current development and maintenance by:
7 * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
8 *
9 * This driver is based on the 'USB Mass Storage Class' document. This
10 * describes in detail the protocol used to communicate with such
11 * devices. Clearly, the designers had SCSI and ATAPI commands in
12 * mind when they created this document. The commands are all very
13 * similar to commands in the SCSI-II and ATAPI specifications.
14 *
15 * It is important to note that in a number of cases this class
16 * exhibits class-specific exemptions from the USB specification.
17 * Notably the usage of NAK, STALL and ACK differs from the norm, in
18 * that they are used to communicate wait, failed and OK on commands.
19 *
20 * Also, for certain devices, the interrupt endpoint is used to convey
21 * status of a command.
22 *
23 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
24 * information about this driver.
25 *
26 * This program is free software; you can redistribute it and/or modify it
27 * under the terms of the GNU General Public License as published by the
28 * Free Software Foundation; either version 2, or (at your option) any
29 * later version.
30 *
31 * This program is distributed in the hope that it will be useful, but
32 * WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 * General Public License for more details.
35 *
36 * You should have received a copy of the GNU General Public License along
37 * with this program; if not, write to the Free Software Foundation, Inc.,
38 * 675 Mass Ave, Cambridge, MA 02139, USA.
39 */
40
41#ifndef _UMAS_TRANSPORT_H_
42#define _UMAS_TRANSPORT_H_
43
45
46/* Protocols */
47#define UMAS_PR_CBI 0x00 /* Control/Bulk/Interrupt */
48#define UMAS_PR_CB 0x01 /* Control/Bulk w/o interrupt */
49#define UMAS_PR_BULK 0x50 /* bulk only */
50#define UMAS_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
51
52/*
53 * Bulk only data structures
54 */
55
56/* command block wrapper */
57struct bulk_cb_wrap
58{
59 uint32_t Signature; /* contains 'USBC' */
60 uint32_t Tag; /* unique per command id */
61 uint32_t DataTransferLength; /* size of data */
62 uint8_t Flags; /* direction in bit 0 */
63 uint8_t Lun; /* LUN normally 0 */
64 uint8_t Length; /* of of the CDB */
65 uint8_t CDB[16]; /* max command */
66};
67
68#define UMAS_BULK_CB_WRAP_LEN 31
69#define UMAS_BULK_CB_SIGN 0x43425355 /* spells out USBC */
70#define UMAS_BULK_FLAG_IN 1
71#define UMAS_BULK_FLAG_OUT 0
72
73/* command status wrapper */
74struct bulk_cs_wrap
75{
76 uint32_t Signature; /* should = 'USBS' */
77 uint32_t Tag; /* same as original command */
78 uint32_t Residue; /* amount not transferred */
79 uint8_t Status; /* see below */
80 uint8_t Filler[18];
81};
82
83#define UMAS_BULK_CS_WRAP_LEN 13
84#define UMAS_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */
85#define UMAS_BULK_STAT_OK 0 /* command passed */
86#define UMAS_BULK_STAT_FAIL 1 /* command failed */
87#define UMAS_BULK_STAT_PHASE 2 /* phase error */
88
89/* bulk-only class specific requests */
90#define UMAS_BULK_RESET_REQUEST 0xff
91#define UMAS_BULK_GET_MAX_LUN 0xfe
92
93/*
94 * us_bulk_transfer() return codes
95 */
96#define UMAS_BULK_TRANSFER_GOOD 0 /* good transfer */
97#define UMAS_BULK_TRANSFER_SHORT 1 /* transferred less than expected */
98#define UMAS_BULK_TRANSFER_FAILED 2 /* transfer died in the middle */
99#define UMAS_BULK_TRANSFER_ABORTED 3 /* transfer canceled */
100
101/*
102 * Transport return codes
103 */
104#define USB_STOR_TRANSPORT_GOOD 0 /* Transport good, command good */
105#define USB_STOR_TRANSPORT_FAILED 1 /* Transport good, command failed */
106#define USB_STOR_TRANSPORT_ERROR 2 /* Transport bad (i.e. device dead) */
107#define USB_STOR_TRANSPORT_ABORTED 3 /* Transport aborted */
108
109/*
110 * CBI accept device specific command
111 */
112#define US_CBI_ADSC 0
113
114void UMAS_CbiIrq(URB_T *urb);
115int UMAS_CbiTransport(SCSI_CMD_T *srb, UMAS_DATA_T *umas);
116
117int UMAS_CbTransport(SCSI_CMD_T *srb, UMAS_DATA_T *umas);
118int UMAS_CbReset(UMAS_DATA_T *umas);
119
120int UMAS_BulkTransport(SCSI_CMD_T *srb, UMAS_DATA_T *umas);
121int UMAS_BulkMaxLun(UMAS_DATA_T *umas);
122int UMAS_BulkReset(UMAS_DATA_T *umas);
123
124void UMAS_InvokeTransport(SCSI_CMD_T *srb, UMAS_DATA_T *us);
125
127
128#endif /* _UMAS_TRANSPORT_H_ */