blob: 3e78b4e3bdf06f91e8cd5d92f0b664b60dcdbae5 [file] [log] [blame]
Christina Quastb123d742014-12-23 13:03:36 +01001/* ----------------------------------------------------------------------------
2 * ATMEL Microcontroller Software Support
3 * ----------------------------------------------------------------------------
4 * Copyright (c) 2008, Atmel Corporation
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * - Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the disclaimer below.
13 *
14 * Atmel's name may not be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * ----------------------------------------------------------------------------
28 */
29
30/** \file
31 * \section Purpose
32 *
33 * SCSI commands implementation.
34 *
35 * section Usage
36 *
37 * -# After a CBW is received from host, use SBC_GetCommandInformation to check
38 * if the command is supported, and get the command length and type
39 * information before processing it.
40 * -# Then SBC_ProcessCommand can be used to handle a valid command, to
41 * perform the command operations.
42 * -# SBC_UpdateSenseData is used to update the sense data that will be sent
43 * to host.
44 */
45
46#ifndef SBCMETHODS_H
47#define SBCMETHODS_H
48
49/** \addtogroup usbd_msd
50 *@{
51 */
52
53/*------------------------------------------------------------------------------
54 * Headers
55 *------------------------------------------------------------------------------*/
56
57#include "SBC.h"
58#include "MSDLun.h"
59#include "MSDDStateMachine.h"
60
61/*------------------------------------------------------------------------------
62 * Definitions
63 *------------------------------------------------------------------------------*/
64
65/** \addtogroup usbd_sbc_command_state SBC Command States
66 * @{
67 * This page lists the possible states of a SBC command.
68 *
69 * \section States
70 * - SBC_STATE_READ
71 * - SBC_STATE_WAIT_READ
72 * - SBC_STATE_WRITE
73 * - SBC_STATE_WAIT_WRITE
74 * - SBC_STATE_NEXT_BLOCK
75 */
76
77/** Start of reading bulk data */
78#define SBC_STATE_READ 0x01
79/** Waiting for the bulk data reading complete */
80#define SBC_STATE_WAIT_READ 0x02
81/** Read error state */
82#define SBC_STATE_READ_ERROR 0x03
83/** Start next read block */
84#define SBC_STATE_NEXT_READ 0x04
85/** Start writing bulk data to host */
86#define SBC_STATE_WRITE 0x05
87/** Waiting for the bulk data sending complete */
88#define SBC_STATE_WAIT_WRITE 0x06
89/** Write error state */
90#define SBC_STATE_WRITE_ERROR 0x07
91/** Start next write block */
92#define SBC_STATE_NEXT_WRITE 0x08
93/** Start next command block */
94#define SBC_STATE_NEXT_BLOCK 0x09
95/** @}*/
96
97/*------------------------------------------------------------------------------
98 * Exported functions
99 *------------------------------------------------------------------------------*/
100
101void SBC_UpdateSenseData(SBCRequestSenseData *requestSenseData,
102 unsigned char senseKey,
103 unsigned char additionalSenseCode,
104 unsigned char additionalSenseCodeQualifier);
105
106unsigned char SBC_GetCommandInformation(void *command,
107 unsigned int *length,
108 unsigned char *type,
109 MSDLun *lun);
110
111unsigned char SBC_ProcessCommand(MSDLun *lun,
112 MSDCommandState *commandState);
113
114/**@}*/
115
116#endif /*#ifndef SBCMETHODS_H */
117
118