OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [usb/] [msd/] [slave/] [current/] [include/] [usbs_msd_scsi.h] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_USBS_MSD_SCSI_H
2
#define CYGONCE_USBS_MSD_SCSI_H
3
//==========================================================================
4
//
5
//      include/usbs_msd_scsi.h
6
//
7
//      SCSI support for the USB slave-side MSD device
8
//
9
//==========================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2010 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later
18
// version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28
//
29
// As a special exception, if other files instantiate templates or use
30
// macros or inline functions from this file, or you compile this file
31
// and link it with other works to produce a work based on this file,
32
// this file does not by itself cause the resulting work to be covered by
33
// the GNU General Public License. However the source code for this file
34
// must still be made available in accordance with section (3) of the GNU
35
// General Public License v2.
36
//
37
// This exception does not invalidate any other reasons why a work based
38
// on this file might be covered by the GNU General Public License.
39
// -------------------------------------------
40
// ####ECOSGPLCOPYRIGHTEND####
41
//==========================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):    ccoutand
45
// Contributors:
46
// Date:         2010-06-02
47
// Purpose:
48
// Description:  USB slave-side MSD support
49
//
50
//
51
//####DESCRIPTIONEND####
52
//==========================================================================
53
 
54
#ifdef __cplusplus
55
extern "C" {
56
#endif
57
 
58
// The standard INQUIRY data shall contain at least 36 bytes
59
// This is the reduced structure for Mass Storage Devices
60
typedef struct
61
{
62
   cyg_uint8 peripheral;         // Device Type
63
   cyg_uint8 rmb;                // Removable Media Bit
64
   cyg_uint8 version;            // Version Field
65
   cyg_uint8 resp_data_format;   // Response Data Format
66
   cyg_uint8 additional_len;     // Additional Length
67
   cyg_uint8 sccstp;             // SCC Supported (include embedded storage array)
68
   cyg_uint8 bque;               // Basic Queuing
69
   cyg_uint8 cmdque;             // Command Queuing
70
   cyg_uint8 vendor_id[8];
71
   cyg_uint8 product_id[16];
72
   cyg_uint8 product_rev[4];
73
} msd_scsi_inq_resp;
74
 
75
#define USBS_SCSI_DIRECT_ACCESS_BLOCK_DEVICE 0x00
76
#define USBS_SCSI_REMOVABLE_DEVICE           0x80
77
 
78
// Fixed-format Sense Data ( defined as a 18 bytes array )
79
typedef struct
80
{
81
   cyg_uint8 byte[18];
82
} msd_scsi_req_sense_resp;
83
 
84
// Set Valid information field
85
#define USBS_MSD_SCSI_SET_SENSE_VALID( ptr_sense, _valid_ ) \
86
{ \
87
  if( _valid_ ) \
88
    ptr_sense[0] |= 0x80; \
89
  else \
90
    ptr_sense[0] &= ~0x80; \
91
};
92
 
93
// Set Response Code field
94
#define USBS_MSD_SCSI_SET_SENSE_RESP_CODE( ptr_sense, _code_ ) \
95
{ \
96
    cyg_uint8 byte = ptr_sense[0] & 0x80; \
97
    ptr_sense[0] = ((_code_ & 0x7F) | byte); \
98
};
99
 
100
// Set Sense Key field
101
#define USBS_MSD_SCSI_SET_SENSE_KEY( ptr_sense, _key_ ) \
102
{ \
103
    cyg_uint8 byte = ptr_sense[0] & 0xF0; \
104
    ptr_sense[0] = ((_key_ & 0x0F) | byte); \
105
};
106
 
107
// Set Additional Sense Length field
108
#define USBS_MSD_SCSI_SET_SENSE_ASL( ptr_sense, _asl_ ) \
109
{ \
110
    ptr_sense[7] = _asl_; \
111
};
112
 
113
// Set Additional Sense Code field
114
#define USBS_MSD_SCSI_SET_SENSE_ASC( ptr_sense, _asc_ ) \
115
{ \
116
    ptr_sense[12] = _asc_; \
117
};
118
 
119
// Set Additional Sense Code Qualifier field
120
#define USBS_MSD_SCSI_SET_SENSE_ASCQ( ptr_sense, _ascq_ ) \
121
{ \
122
    ptr_sense[13] = _ascq_; \
123
};
124
 
125
// Init Sense Data structure
126
#define USBS_MSD_SCSI_INIT_SENSE_DATA( _array_ ) \
127
{ \
128
   cyg_int32 i; \
129
   for(i = 0; i < sizeof(msd_scsi_req_sense_resp); i++) \
130
   _array_[i] = 0; \
131
   USBS_MSD_SCSI_SET_SENSE_VALID( _array_, 1); \
132
   USBS_MSD_SCSI_SET_SENSE_RESP_CODE( _array_, 0x70 ); \
133
   USBS_MSD_SCSI_SET_SENSE_ASC( _array_, 0x0a ); \
134
};
135
 
136
cyg_int32 usbs_msd_scsi_handle_cmd( usbs_msd * );
137
bool usbs_msd_scsi_init( void ** ctxt );
138
 
139
#ifdef __cplusplus
140
} // extern "C"
141
#endif
142
 
143
#endif // CYGONCE_USBS_MSD_SCSI_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.