summaryrefslogtreecommitdiff
path: root/minix/drivers/usb/usb_storage/bulk.h
blob: 2e7dc1994e1d9607e543f5092efca4126d30c9a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * "Bulk only transfer" related externally visible info
 */

#ifndef _BULK_H_
#define _BULK_H_

/*---------------------------*
 *    declared types         *
 *---------------------------*/
#define BULK_PACKED __attribute__((__packed__))

#define CBW_SIGNATURE		(0x43425355)
#define CBW_FLAGS_OUT		(0x00)
#define CBW_FLAGS_IN		(0x80)
#define CBW_CB_LENGTH		(16)

/* Command Block Wrapper */
typedef struct BULK_PACKED mass_storage_cbw {
	uint32_t	dCBWSignature;
	uint32_t	dCBWTag;
	uint32_t	dCBWDataTransferLength;
	uint8_t		bCBWFlags;
	uint8_t		bCBWLUN;		/* 4 bits */
	uint8_t		bCDBLength;		/* 5 bits */
	uint8_t		CBWCB[CBW_CB_LENGTH];
}
mass_storage_cbw;

#define CSW_SIGNATURE		(0x53425355)
#define CSW_STATUS_GOOD		(0x0)
#define CSWS_TATUS_FAILED	(0x1)
#define CSW_STATUS_PHASE	(0x2)

/* Command Status Wrapper */
typedef struct BULK_PACKED mass_storage_csw {
	uint32_t	dCSWSignature;
	uint32_t	dCSWTag;
	uint32_t	dCSWDataResidue;
	uint8_t		bCSWStatus;
}
mass_storage_csw;

#undef BULK_PACKED

/*---------------------------*
 *    declared functions     *
 *---------------------------*/
void init_cbw(mass_storage_cbw *, unsigned int);
void init_csw(mass_storage_csw *);

#endif /* !_BULK_H_ */