00001 /* ---------------------------------------------------------------------------- 00002 * SAM Software Package License 00003 * ---------------------------------------------------------------------------- 00004 * Copyright (c) 2014, Atmel Corporation 00005 * 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the disclaimer below. 00013 * 00014 * Atmel's name may not be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00020 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * ---------------------------------------------------------------------------- 00028 */ 00029 00030 /** \file 00031 * \section Purpose 00032 * 00033 * SCSI commands implementation. 00034 * 00035 * section Usage 00036 * 00037 * -# After a CBW is received from host, use SBC_GetCommandInformation to check 00038 * if the command is supported, and get the command length and type 00039 * information before processing it. 00040 * -# Then SBC_ProcessCommand can be used to handle a valid command, to 00041 * perform the command operations. 00042 * -# SBC_UpdateSenseData is used to update the sense data that will be sent 00043 * to host. 00044 */ 00045 00046 #ifndef SBCMETHODS_H 00047 #define SBCMETHODS_H 00048 00049 /** \addtogroup usbd_msd 00050 *@{ 00051 */ 00052 00053 /*------------------------------------------------------------------------------ 00054 * Headers 00055 *------------------------------------------------------------------------------*/ 00056 00057 #include "SBC.h" 00058 #include "MSDLun.h" 00059 #include "MSDDStateMachine.h" 00060 00061 /*------------------------------------------------------------------------------ 00062 * Definitions 00063 *------------------------------------------------------------------------------*/ 00064 00065 /** \addtogroup usbd_sbc_command_state SBC Command States 00066 * @{ 00067 * This page lists the possible states of a SBC command. 00068 * 00069 * \section States 00070 * - SBC_STATE_READ 00071 * - SBC_STATE_WAIT_READ 00072 * - SBC_STATE_WRITE 00073 * - SBC_STATE_WAIT_WRITE 00074 * - SBC_STATE_NEXT_BLOCK 00075 */ 00076 00077 /** Start of reading bulk data */ 00078 #define SBC_STATE_READ 0x01 00079 /** Waiting for the bulk data reading complete */ 00080 #define SBC_STATE_WAIT_READ 0x02 00081 /** Read error state */ 00082 #define SBC_STATE_READ_ERROR 0x03 00083 /** Start next read block */ 00084 #define SBC_STATE_NEXT_READ 0x04 00085 /** Start writing bulk data to host */ 00086 #define SBC_STATE_WRITE 0x05 00087 /** Waiting for the bulk data sending complete */ 00088 #define SBC_STATE_WAIT_WRITE 0x06 00089 /** Write error state */ 00090 #define SBC_STATE_WRITE_ERROR 0x07 00091 /** Start next write block */ 00092 #define SBC_STATE_NEXT_WRITE 0x08 00093 /** Start next command block */ 00094 #define SBC_STATE_NEXT_BLOCK 0x09 00095 /** @}*/ 00096 00097 /*------------------------------------------------------------------------------ 00098 * Exported functions 00099 *------------------------------------------------------------------------------*/ 00100 00101 void SBC_UpdateSenseData(SBCRequestSenseData *requestSenseData, 00102 unsigned char senseKey, 00103 unsigned char additionalSenseCode, 00104 unsigned char additionalSenseCodeQualifier); 00105 00106 unsigned char SBC_GetCommandInformation(void *command, 00107 unsigned int *length, 00108 unsigned char *type, 00109 MSDLun *lun); 00110 00111 unsigned char SBC_ProcessCommand(MSDLun *lun, 00112 MSDCommandState *commandState); 00113 00114 /**@}*/ 00115 00116 #endif /*#ifndef SBCMETHODS_H */ 00117 00118