storage.h

00001 /*
00002  * Copyright (c) 2007, Benedikt Sauter <sauter@ixbat.de>
00003  * All rights reserved.
00004  *
00005  * Short descripton of file:
00006  *
00007  *
00008  * Redistribution and use in source and binary forms, with or without 
00009  * modification, are permitted provided that the following conditions 
00010  * are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright 
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above 
00015  *     copyright notice, this list of conditions and the following 
00016  *     disclaimer in the documentation and/or other materials provided 
00017  *     with the distribution.
00018  *   * Neither the name of the FH Augsburg nor the names of its 
00019  *     contributors may be used to endorse or promote products derived 
00020  *     from this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00023  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00025  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
00026  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00035 #ifndef __STORAGE_H
00036 #define __STORAGE_H
00037 void usb_storage_probe();
00038 void usb_storage_check();
00039 
00040 /* CSW Status Definitions */
00041 #define CSW_CMD_PASSED                  0x00
00042 #define CSW_CMD_FAILED                  0x01
00043 #define CSW_PHASE_ERROR                 0x02
00044 
00045 
00046 /* SCSI Commands */
00047 #define SCSI_TEST_UNIT_READY            0x00
00048 #define SCSI_REQUEST_SENSE              0x03
00049 #define SCSI_FORMAT_UNIT                0x04
00050 #define SCSI_INQUIRY                    0x12
00051 #define SCSI_MODE_SELECT6               0x15
00052 #define SCSI_MODE_SENSE6                0x1A
00053 #define SCSI_START_STOP_UNIT            0x1B
00054 #define SCSI_MEDIA_REMOVAL              0x1E
00055 #define SCSI_READ_FORMAT_CAPACITIES     0x23
00056 #define SCSI_READ_CAPACITY              0x25
00057 #define SCSI_READ10                     0x28
00058 #define SCSI_WRITE10                    0x2A
00059 #define SCSI_VERIFY10                   0x2F
00060 #define SCSI_MODE_SELECT10              0x55
00061 #define SCSI_MODE_SENSE10               0x5A
00062 
00063 
00064 typedef struct usb_storage_cbw_t usb_storage_cbw;
00065 struct usb_storage_cbw_t {
00066         u32 dCBWSignature;
00067         u32 dCBWTag;
00068         u32 dCBWDataTransferLength;
00069         u8  bCWDFlags;
00070         u8  bCBWLun;
00071         u8  bCBWCBLength;
00072         u8  CBWCB[16];
00073 };
00074 
00075 typedef struct usb_storage_csw_t usb_storage_csw;
00076 struct usb_storage_csw_t {
00077         u32 dCSWSignature;
00078         u32 dCSWTag;
00079         u32 dCSWDataResidue;
00080         u8  bCSWStatus;
00081 };
00082 
00083 
00084 void usb_storage_init();
00085 
00086 u8 usb_storage_open(u8 device);
00087 
00088 u8 usb_storage_read_capacity(u8 device);
00089 u8 usb_storage_inquiry(u8 device);
00090 u8 usb_storage_read_sector(u8 device, u32 sector, char * buf);
00091 u8 usb_storage_write_sector(u8 device, u32 sector, char * buf);
00092 #endif /* __STORAGE_H */
00093 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated by  doxygen 1.6.3