first adaption of 'usbport' by Benedikt Sauter
[ppcskel.git] / usb / drivers / class / storage.h
1 /*
2  * Copyright (c) 2007, Benedikt Sauter <sauter@ixbat.de>
3  * All rights reserved.
4  *
5  * Short descripton of file:
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without 
9  * modification, are permitted provided that the following conditions 
10  * are met:
11  *
12  *   * Redistributions of source code must retain the above copyright 
13  *     notice, this list of conditions and the following disclaimer.
14  *   * Redistributions in binary form must reproduce the above 
15  *     copyright notice, this list of conditions and the following 
16  *     disclaimer in the documentation and/or other materials provided 
17  *     with the distribution.
18  *   * Neither the name of the FH Augsburg nor the names of its 
19  *     contributors may be used to endorse or promote products derived 
20  *     from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef __STORAGE_H
36 #define __STORAGE_H
37 void usb_storage_probe();
38 void usb_storage_check();
39
40 /* CSW Status Definitions */
41 #define CSW_CMD_PASSED                  0x00
42 #define CSW_CMD_FAILED                  0x01
43 #define CSW_PHASE_ERROR                 0x02
44
45
46 /* SCSI Commands */
47 #define SCSI_TEST_UNIT_READY            0x00
48 #define SCSI_REQUEST_SENSE              0x03
49 #define SCSI_FORMAT_UNIT                0x04
50 #define SCSI_INQUIRY                    0x12
51 #define SCSI_MODE_SELECT6               0x15
52 #define SCSI_MODE_SENSE6                0x1A
53 #define SCSI_START_STOP_UNIT            0x1B
54 #define SCSI_MEDIA_REMOVAL              0x1E
55 #define SCSI_READ_FORMAT_CAPACITIES     0x23
56 #define SCSI_READ_CAPACITY              0x25
57 #define SCSI_READ10                     0x28
58 #define SCSI_WRITE10                    0x2A
59 #define SCSI_VERIFY10                   0x2F
60 #define SCSI_MODE_SELECT10              0x55
61 #define SCSI_MODE_SENSE10               0x5A
62
63
64 typedef struct usb_storage_cbw_t usb_storage_cbw;
65 struct usb_storage_cbw_t {
66   u32 dCBWSignature;
67   u32 dCBWTag;
68   u32 dCBWDataTransferLength;
69   u8  bCWDFlags;
70   u8  bCBWLun;
71   u8  bCBWCBLength;
72   u8  CBWCB[16];
73 };
74
75 typedef struct usb_storage_csw_t usb_storage_csw;
76 struct usb_storage_csw_t {
77   u32 dCSWSignature;
78   u32 dCSWTag;
79   u32 dCSWDataResidue;
80   u8  bCSWStatus;
81 };
82
83
84 void usb_storage_init();
85
86 u8 usb_storage_open(u8 device);
87
88 u8 usb_storage_read_capacity(u8 device);
89 u8 usb_storage_inquiry(u8 device);
90 u8 usb_storage_read_sector(u8 device, u32 sector, char * buf);
91 u8 usb_storage_write_sector(u8 device, u32 sector, char * buf);
92 #endif /* __STORAGE_H */
93