- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

csl_msc.h
Go to the documentation of this file.

    00001 /*  ============================================================================
    00002  *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2008
    00003  *
    00004  *   Use of this software is controlled by the terms and conditions found in the
    00005  *   license agreement under which this software has been supplied.
    00006  *  ============================================================================
    00007  */
    00008
    00016 /* ============================================================================
    00017  * Revision History
    00018  * ================
    00019  * 07-Oct-2008 Created
    00020  * 08-May-2009 Modified to fix the string desc ASCII to UNICODE conversion issue
    00021  * 28-May-2009 Modified as per the review comments
    00022  * 10-May-2010 Added fullspeed mode support
    00023  * ============================================================================
    00024  */
    00025
    00043 #ifndef _CSL_MSC_H_
    00044 #define _CSL_MSC_H_
    00045
    00046 #ifdef __cplusplus
    00047 extern "C" {
    00048 #endif
    00049
    00050 #include <cslr.h>
    00051 #include <csl_error.h>
    00052 #include <csl_types.h>
    00053 #include <cslr_usb.h>
    00054 #include <csl_usb.h>
    00055 #include <soc.h>
    00056 #include <csl_general.h>
    00057
    00058
    00077 /*****************************************************************************\
    00078           USB MSC global macro declarations                                   *
    00079 \*****************************************************************************/
    00086 #define CSL_MSC_CBW_0                                          (1)
    00087
    00088 #define CSL_MSC_CBW_1                                          (2)
    00089
    00090 #define CSL_MSC_CBW_2                                          (3)
    00091
    00092 #define CSL_MSC_CBW_3                                          (4)
    00093
    00094 #define CSL_MSC_CBW_4                                          (5)
    00095
    00096 #define CSL_MSC_CBW_5                                          (6)
    00097
    00098 #define CSL_MSC_CBW_6                                          (7)
    00099
    00100 #define CSL_MSC_CBW_7                                          (8)
    00101
    00102 #define CSL_MSC_CBW_8                                          (9)
    00103
    00104 #define CSL_MSC_CBW_9                                          (10)
    00105
    00106 #define CSL_MSC_CBW_10                                         (11)
    00107
    00108 #define CSL_MSC_CBW_11                                         (12)
    00109
    00110 #define CSL_MSC_CBW_12                                         (13)
    00111
    00112 #define CSL_MSC_CBW_13                                         (14)
    00113
    00114 #define CSL_MSC_CBW_14                                         (15)
    00115
    00116 #define CSL_MSC_CBW_15                                         (16)
    00117
    00120 #define CSL_MSC_CSW_2                                          (3)
    00121
    00122 #define CSL_MSC_CSW_3                                          (4)
    00123
    00124 #define CSL_MSC_CSW_4                                          (5)
    00125
    00126 #define CSL_MSC_CSW_5                                          (6)
    00127
    00128 #define CSL_MSC_CSW_6                                          (7)
    00129
    00131 #define CSL_MSC_CBW_SIGNATURE                                  (0x43425355)
    00132
    00133 #define CSL_MSC_CSW_SIGNATURE                                  (0x53425355)
    00134
    00135 #define CSL_MSC_CBW_DATADIR_IN                                 (0x80)
    00136
    00137 #define CSL_MSC_CBW_DATADIR_OUT                                (0x0)
    00138
    00139 #define CSL_MSC_CBW_DIRBIT_MASK                                (0x80)
    00140
    00143 #define CSL_MSC_MEDIA_PRESENT                                  (0x1)
    00144
    00145 #define CSL_MSC_MEDIA_LOCKED                                   (0x2)
    00146
    00147 #define CSL_MSC_MEDIA_WRITEPENDING                             (0x4)
    00148
    00149 #define CSL_MSC_MEDIA_BAD                                      (0x8)
    00150
    00151 #define CSL_MSC_MEDIA_WRITEENABLE                              (0x0001)
    00152
    00155 #define CSL_MSC_DEVICE_DESCRIPTOR_TYPE                         (0x01)
    00156
    00157 #define CSL_MSC_DEVICE_QUAL_DESCRIPTOR_TYPE                    (0x06)
    00158
    00159 #define CSL_MSC_CONFIGURATION_DESCRIPTOR_TYPE                  (0x02)
    00160
    00161 #define CSL_MSC_OTHERSPEED_CFG_DESCRIPTOR_TYPE                 (0x07)
    00162
    00163 #define CSL_MSC_STRING_DESCRIPTOR_TYPE                         (0x03)
    00164
    00165 #define CSL_MSC_INTERFACE_DESCRIPTOR_TYPE                      (0x04)
    00166
    00167 #define CSL_MSC_ENDPOINT_DESCRIPTOR_TYPE                       (0x05)
    00168
    00169 #define CSL_MSC_POWER_DESCRIPTOR_TYPE                          (0x06)
    00170
    00171 #define CSL_MSC_HID_DESCRIPTOR_TYPE                            (0x21)
    00172
    00175 #define CSL_MSC_FEATURE_ENDPOINT_STALL                         (0x0000)
    00176
    00177 #define CSL_MSC_FEATURE_REMOTE_WAKEUP                          (0x0001)
    00178
    00181 #define CSL_MSC_VERIFY_PASSED                                  (0x0)
    00182
    00183 #define CSL_MSC_VERIFY_FAILED                                  (0x1)
    00184
    00185 #define CSL_MSC_UNIT_REMOVEABLE                                (0x1)
    00186
    00187 #define CSL_MSC_CURRDEV_STAT                                   (0x01)
    00188
    00189 #define CSL_MSC_CURRINTRF_STAT                                 (0x00)
    00190
    00191 #define CSL_MSC_NO_ENDPTOBJECT                                 (5)
    00192
    00193 #define CSL_MSC_DEVDESC_LEN                                    (10)
    00194
    00195 #define CSL_MSC_CFGDESC_TOTAL_LEN                              (17)
    00196
    00197 #define CSL_MSC_DEVQUALDESC_LEN                                (6)
    00198
    00199 #define CSL_MSC_CONFDESC_LEN                                   (6)
    00200
    00201 #define CSL_MSC_MS_INTDESC_LEN                                 (6)
    00202
    00203 #define CSL_MSC_MS_BULKOUT_ENDPTDESC_LEN                       (5)
    00204
    00205 #define CSL_MSC_MS_BULKIN_ENDPTDESC_LEN                        (5)
    00206
    00207 #define CSL_MSC_STRDESC_LANGID_LEN                             (4)
    00208
    00209 #define CSL_MSC_SCSI_INQUIRY_LEN                               (50)
    00210
    00211 #define CSL_MSC_SENSEDATA_LEN                                  (15)
    00212
    00213 #define CSL_MSC_LUN_MAX                                        (4)
    00214
    00215 #define CSL_MSC_CBWSIZE                                        (17)
    00216
    00217 #define CSL_MSC_CSWSIZE                                        (8)
    00218
    00219 #define CSL_MSC_READCAP                                        (6)
    00220
    00221 #define CSL_MSC_CTRLBUFF_LEN                                   (5)
    00222
    00223 #define CSL_MSC_SCSI_INQUIRY_CONF_LEN                          (24)
    00224
    00225 #define CSL_MSC_DEVICE_CLASS_STORAGE                           (0x08)
    00226
    00227 #define CSL_MSC_SCSI_DATA_PROTECT                              (0x0007)
    00228
    00231 #define CSL_MSC_REQUEST_GET_STATUS                             (0x8000)
    00232
    00233 #define CSL_MSC_REQUEST_CLEAR_FEATURE                          (0x0001)
    00234
    00235 #define CSL_MSC_REQUEST_SET_FEATURE                            (0x0003)
    00236
    00237 #define CSL_MSC_REQUEST_SET_ADDRESS                            (0x0005)
    00238
    00239 #define CSL_MSC_REQUEST_GET_DESCRIPTOR                         (0x8006)
    00240
    00241 #define CSL_MSC_REQUEST_SET_DESCRIPTOR                         (0x0007)
    00242
    00243 #define CSL_MSC_REQUEST_GET_CONFIGURATION                      (0x8008)
    00244
    00245 #define CSL_MSC_REQUEST_SET_CONFIGURATION                      (0x0009)
    00246
    00247 #define CSL_MSC_REQUEST_GET_INTERFACE                          (0x800A)
    00248
    00249 #define CSL_MSC_REQUEST_SET_INTERFACE                          (0x000B)
    00250
    00251 #define CSL_MSC_REQUEST_SYNC_FRAME                             (0x800C)
    00252
    00253 #define CSL_MSC_REQUEST_BOT_MSC_RESET                          (0x20FF)
    00254
    00255 #define CSL_MSC_REQUEST_GET_MAX_LUN                            (0xA0FE)
    00256
    00257 #define CSL_MSC_REQUEST_TYPE_BASE                              (0x80)
    00258
    00259 #define CSL_MSC_REQUEST_TYPE_DEVICE_STATUS                     (0x0)
    00260
    00261 #define CSL_MSC_REQUEST_TYPE_INTERFACE_STATUS                  (0x1)
    00262
    00263 #define CSL_MSC_REQUEST_TYPE_EP_STATUS                         (0x2)
    00264
    00267 #define CSL_MSC_DEVICE_SUSPENDED                               (0x01)
    00268
    00269 #define CSL_MSC_DEVICE_NOT_SUSPENDED                           (0x0)
    00270
    00271 #define CSL_MSC_LUN_LOCKED                                     (0x01)
    00272
    00273 #define CSL_MSC_LUN_NOT_LOCKED                                 (0x0)
    00274
    00275 #define CSL_MSC_ACTIVITY_PRESENT                               (0x01)
    00276
    00277 #define CSL_MSC_ACTIVITY_NOT_PRESENT                           (0x0)
    00278
    00280 #define CSL_MSC_16BIT_MASK                                     (0xFFFF)
    00281
    00282 #define CSL_MSC_16BIT_SHIFT                                    (16)
    00283
    00285 #define CSL_MSC_24BIT_SHIFT                                    (24)
    00286
    00288 #define CSL_MSC_8BIT_MASK                                      (0xFF)
    00289
    00290 #define CSL_MSC_8BIT_HIGH_MASK                                 (0xFF00)
    00291
    00292 #define CSL_MSC_8BIT_SHIFT                                     (8)
    00293
    00294 #define CSL_MSC_UNICODE_SIZE                                   (66)
    00295
    00297 #define CSL_MSC_DEVICE_DESC_DEFLEN                             (18)
    00298
    00299 #define CSL_MSC_DEVICE_DESC0_DEFVAL                            (0x0000)
    00300
    00301 #define CSL_MSC_DEVICE_DESC2_DEFVAL                            (0x0200)
    00302
    00303 #define CSL_MSC_DEVICE_DESC3_DEFVAL                            (0x0000)
    00304
    00305 #define CSL_MSC_DEVICE_DESC4_DEFVAL                            (0x4000)
    00306
    00307 #define CSL_MSC_DEVICE_DESC5_DEFVAL                            (0x0451)
    00308
    00309 #define CSL_MSC_DEVICE_DESC6_DEFVAL                            (0x9010)
    00310
    00311 #define CSL_MSC_DEVICE_DESC7_DEFVAL                            (0x0001)
    00312
    00313 #define CSL_MSC_DEVICE_DESC8_DEFVAL                            (0x0201)
    00314
    00315 #define CSL_MSC_DEVICE_DESC9_DEFVAL                            (0x0103)
    00316
    00318 #define CSL_MSC_DEVICE_QUAL_DESC_DEFLEN                        (10)
    00319
    00320 #define CSL_MSC_DEVICE_QUAL_DESC0_DEFVAL                       (0x0000)
    00321
    00322 #define CSL_MSC_DEVICE_QUAL_DESC2_DEFVAL                       (0x0200)
    00323
    00324 #define CSL_MSC_DEVICE_QUAL_DESC3_DEFVAL                       (0x0000)
    00325
    00326 #define CSL_MSC_DEVICE_QUAL_DESC4_DEFVAL                       (0x4000)
    00327
    00328 #define CSL_MSC_DEVICE_QUAL_DESC5_DEFVAL                       (0x0001)
    00329
    00331 #define CSL_MSC_CONF_DESC_DEFLEN                               (9)
    00332
    00333 #define CSL_MSC_CONF_DESC0_DEFVAL                              (0x0000)
    00334
    00335 #define CSL_MSC_CONF_DESC2_DEFVAL                              (32)
    00336
    00337 #define CSL_MSC_CONF_DESC3_DEFVAL                              (0x0101)
    00338
    00339 #define CSL_MSC_CONF_DESC4_DEFVAL                              (0xC004)
    00340
    00341 #define CSL_MSC_CONF_DESC5_DEFVAL                              (50)
    00342
    00344 #define CSL_MSC_INTERFACE_DESC_DEFLEN                          (9)
    00345
    00346 #define CSL_MSC_INTERFACE_DESC0_DEFVAL                         (0x0000)
    00347
    00348 #define CSL_MSC_INTERFACE_DESC2_DEFVAL                         (0x0000)
    00349
    00350 #define CSL_MSC_INTERFACE_DESC3_DEFVAL  ((CSL_MSC_DEVICE_CLASS_STORAGE<<8) | 2)
    00351
    00352 #define CSL_MSC_INTERFACE_DESC4_DEFVAL                         (0x5006)
    00353
    00354 #define CSL_MSC_INTERFACE_DESC5_DEFVAL                         (0x05)
    00355
    00357 #define CSL_MSC_BULKOUTEP_DESC_DEFLEN                          (7)
    00358
    00359 #define CSL_MSC_BULKOUTEP_DESC0_DEFVAL                         (0x0000)
    00360
    00361 #define CSL_MSC_BULKOUTEP_DESC2_DEFVAL                         (0x0202)
    00362
    00363 #define CSL_MSC_BULKOUTEP_DESC3_DEFVAL                         (0x0040)
    00364
    00365 #define CSL_MSC_BULKOUTEP_DESC4_DEFVAL                         (0x00)
    00366
    00368 #define CSL_MSC_BULKINEP_DESC_DEFLEN                           (7)
    00369
    00370 #define CSL_MSC_BULKINEP_DESC0_DEFVAL                          (0x0000)
    00371
    00372 #define CSL_MSC_BULKINEP_DESC2_DEFVAL                          (0x0282)
    00373
    00374 #define CSL_MSC_BULKINEP_DESC3_DEFVAL                          (0x0040)
    00375
    00376 #define CSL_MSC_BULKINEP_DESC4_DEFVAL                          (0x00)
    00377
    00379 #define CSL_MSC_HS_CFG_DESC0_DEFVAL                            (0x0000)
    00380
    00381 #define CSL_MSC_HS_CFG_DESC2_DEFVAL                            (32)
    00382
    00383 #define CSL_MSC_HS_CFG_DESC3_DEFVAL                            (0x0101)
    00384
    00385 #define CSL_MSC_HS_CFG_DESC4_DEFVAL                            (0xC004)
    00386
    00387 #define CSL_MSC_HS_CFG_DESC5_DEFVAL                            (0x0932)
    00388
    00389 #define CSL_MSC_HS_CFG_DESC6_DEFVAL  (CSL_MSC_INTERFACE_DESCRIPTOR_TYPE)
    00390
    00391 #define CSL_MSC_HS_CFG_DESC7_DEFVAL                            (0x0200)
    00392
    00393 #define CSL_MSC_HS_CFG_DESC8_DEFVAL  (0x0600 | CSL_MSC_DEVICE_CLASS_STORAGE)
    00394
    00395 #define CSL_MSC_HS_CFG_DESC9_DEFVAL                            (0x0550)
    00396
    00397 #define CSL_MSC_HS_CFG_DESC10_DEFVAL ((CSL_MSC_ENDPOINT_DESCRIPTOR_TYPE<<8) | 7)
    00398
    00399 #define CSL_MSC_HS_CFG_DESC11_DEFVAL                           (0x0202)
    00400
    00401 #define CSL_MSC_HS_CFG_DESC12_DEFVAL                           (0x0200)
    00402
    00403 #define CSL_MSC_HS_CFG_DESC13_DEFVAL                           (0x0700)
    00404
    00405 #define CSL_MSC_HS_CFG_DESC14_DEFVAL (0x8100 | CSL_MSC_ENDPOINT_DESCRIPTOR_TYPE)
    00406
    00407 #define CSL_MSC_HS_CFG_DESC15_DEFVAL                           (0x0002)
    00408
    00409 #define CSL_MSC_HS_CFG_DESC16_DEFVAL                           (0x0002)
    00410
    00412 #define CSL_MSC_FS_CFG_DESC0_DEFVAL                    (0x0000)
    00413
    00414 #define CSL_MSC_FS_CFG_DESC2_DEFVAL                    (32)
    00415
    00416 #define CSL_MSC_FS_CFG_DESC3_DEFVAL                    (0x0101)
    00417
    00418 #define CSL_MSC_FS_CFG_DESC4_DEFVAL                    (0xC004)
    00419
    00420 #define CSL_MSC_FS_CFG_DESC5_DEFVAL                    (0x0932)
    00421
    00422 #define CSL_MSC_FS_CFG_DESC6_DEFVAL  (CSL_MSC_INTERFACE_DESCRIPTOR_TYPE)
    00423
    00424 #define CSL_MSC_FS_CFG_DESC7_DEFVAL                    (0x0200)
    00425
    00426 #define CSL_MSC_FS_CFG_DESC8_DEFVAL  (0x0600 | CSL_MSC_DEVICE_CLASS_STORAGE)
    00427
    00428 #define CSL_MSC_FS_CFG_DESC9_DEFVAL                    (0x0550)
    00429
    00430 #define CSL_MSC_FS_CFG_DESC10_DEFVAL ((CSL_MSC_ENDPOINT_DESCRIPTOR_TYPE<<8) | 7)
    00431
    00432 #define CSL_MSC_FS_CFG_DESC11_DEFVAL                   (0x0202)
    00433
    00434 #define CSL_MSC_FS_CFG_DESC12_DEFVAL                   (0x0040)
    00435
    00436 #define CSL_MSC_FS_CFG_DESC13_DEFVAL                   (0x0700)
    00437
    00438 #define CSL_MSC_FS_CFG_DESC14_DEFVAL (0x8100 | CSL_MSC_ENDPOINT_DESCRIPTOR_TYPE)
    00439
    00440 #define CSL_MSC_FS_CFG_DESC15_DEFVAL                   (0x4002)
    00441
    00442 #define CSL_MSC_FS_CFG_DESC16_DEFVAL                   (0x0000)
    00443
    00445 #define CSL_MSC_LANGID_DEFLEN                                  (4)
    00446
    00447 #define CSL_MSC_LANGID0_DEFVAL                                 (0x0000)
    00448
    00449 #define CSL_MSC_LANGID2_DEFVAL                                 (0x0409)
    00450
    00451 #define CSL_MSC_LANGID3_DEFVAL                                 (0x0000)
    00452
    00454 #define CSL_MSC_SENSE_DATA0_DEFVAL                             (26)
    00455
    00456 #define CSL_MSC_SENSE_DATA1_DEFVAL                             (0)
    00457
    00458 #define CSL_MSC_SENSE_DATA2_DEFVAL                             (0x0070)
    00459
    00460 #define CSL_MSC_SENSE_DATA3_DEFVAL                             (0x0000)
    00461
    00462 #define CSL_MSC_SENSE_DATA4_DEFVAL                             (0x0000)
    00463
    00464 #define CSL_MSC_SENSE_DATA5_DEFVAL                             ((11<<8) | 0)
    00465
    00467 #define CSL_MSC_MODESENSE_DATA0_DEFVAL                         (0x08)
    00468
    00469 #define CSL_MSC_MODESENSE_DATA1_DEFVAL                         (0x0)
    00470
    00471 #define CSL_MSC_MODESENSE_DATA2_DEFVAL                         (0x03)
    00472
    00473 #define CSL_MSC_MODESENSE_DATA3_DEFVAL                         (0x0)
    00474
    00475 #define CSL_MSC_MODESENSE_DATA4_DEFVAL                         (0x0)
    00476
    00477
    00479 #define CSL_MSC_READ_CAPACITY0_DEFVAL                          (8)
    00480
    00482 #define CSL_MSC_CSW0_DEFVAL                                    (0)
    00483
    00484 #define CSL_MSC_CSW1_DEFVAL                                    (0x5355)
    00485
    00486 #define CSL_MSC_CSW2_DEFVAL                                    (0x5342)
    00487
    00490 #define CSL_MSC_STORAGE_STATE_RESET                            (0)
    00491
    00492 #define CSL_MSC_STORAGE_STATE_WAIT_FOR_CBW                     (1)
    00493
    00494 #define CSL_MSC_STORAGE_STATE_SENDING_STALL                    (2)
    00495
    00496 #define CSL_MSC_STORAGE_STATE_SENDING_DATA                     (3)
    00497
    00498 #define CSL_MSC_STORAGE_STATE_SENDING_CSW                      (4)
    00499
    00500 #define CSL_MSC_STORAGE_STATE_READ                             (5)
    00501
    00502 #define CSL_MSC_STORAGE_STATE_WRITE                            (6)
    00503
    00504 #define CSL_MSC_STORAGE_STATE_SENDING_SHORT_PKT                (7)
    00505
    00507 #define CSL_MSC_STATE_RESET_DATA_SIZE                          (31)
    00508
    00509 #define CSL_MSC_CBW_DATA_SIZE                                  (31)
    00510
    00511 #define CSL_MSC_CSW_DATA_SIZE                                  (13)
    00512
    00515 #define CSL_MSC_SCSI_COMMAND_TEST_UNIT_READY                   (0x00)
    00516
    00517 #define CSL_MSC_SCSI_COMMAND_REQUEST_SENSE                     (0x03)
    00518
    00519 #define CSL_MSC_SCSI_COMMAND_FORMAT_UNIT                       (0x04)
    00520
    00521 #define CSL_MSC_SCSI_COMMAND_INQUIRY                           (0x12)
    00522
    00523 #define CSL_MSC_SCSI_COMMAND_MODE_SELECT_6                     (0x15)
    00524
    00525 #define CSL_MSC_SCSI_COMMAND_RESERVE_6                         (0x16)
    00526
    00527 #define CSL_MSC_SCSI_COMMAND_RELEASE_6                         (0x17)
    00528
    00529 #define CSL_MSC_SCSI_COMMAND_MODE_SENSE_6                      (0x1A)
    00530
    00531 #define CSL_MSC_SCSI_COMMAND_MODE_SENSE_10                     (0x5A)
    00532
    00533 #define CSL_MSC_SCSI_COMMAND_START_STOP_UNIT                   (0x1B)
    00534
    00535 #define CSL_MSC_SCSI_COMMAND_PREVENT_ALLOW_MEDIA_REMOVAL       (0x1E)
    00536
    00537 #define CSL_MSC_SCSI_COMMAND_READ_CAPACITY                     (0x25)
    00538
    00539 #define CSL_MSC_SCSI_COMMAND_READ_10                           (0x28)
    00540
    00541 #define CSL_MSC_SCSI_COMMAND_WRITE_10                          (0x2A)
    00542
    00543 #define CSL_MSC_SCSI_COMMAND_VERIFY_10                         (0x2F)
    00544
    00545 #define CSL_MSC_SCSI_COMMAND_SYNCHRONIZE_CACHE                 (0x35)
    00546
    00547 #define CSL_MSC_SCSI_COMMAND_WRITE_BUFFER                      (0x3B)
    00548
    00549 #define CSL_MSC_SCSI_COMMAND_PERSISTENT_RESERVE_IN             (0x5E)
    00550
    00551 #define CSL_MSC_SCSI_COMMAND_PERSISTENT_RESERVE_OUT            (0x5F)
    00552
    00555 #define CSL_MSC_SCSI_SENSEKEY_NO_SENSE                         (0x00)
    00556
    00557 #define CSL_MSC_SCSI_SENSEKEY_RECOVERED_ERROR                  (0x01)
    00558
    00559 #define CSL_MSC_SCSI_SENSEKEY_NOT_READY                        (0x02)
    00560
    00561 #define CSL_MSC_SCSI_SENSEKEY_MEDIA_ERROR                      (0x03)
    00562
    00563 #define CSL_MSC_SCSI_SENSEKEY_HARDWARE_ERROR                   (0x04)
    00564
    00565 #define CSL_MSC_SCSI_SENSEKEY_ILLEGAL_REQUEST                  (0x05)
    00566
    00567 #define CSL_MSC_SCSI_SENSEKEY_UNIT_ATTENTION                   (0x06)
    00568
    00569 #define CSL_MSC_SCSI_SENSEKEY_DATA_PROTECT                     (0x07)
    00570
    00571 #define CSL_MSC_SCSI_SENSEKEY_BLANK_CHECK                      (0x08)
    00572
    00573 #define CSL_MSC_SCSI_SENSEKEY_VENDOR_SPECIFIC                  (0x09)
    00574
    00575 #define CSL_MSC_SCSI_SENSEKEY_COPY_ABORTED                     (0x0A)
    00576
    00577 #define CSL_MSC_SCSI_SENSEKEY_ABORTED_COMMAND                  (0x0B)
    00578
    00579 #define CSL_MSC_SCSI_SENSEKEY_EQUAL                            (0x0C)
    00580
    00581 #define CSL_MSC_SCSI_SENSEKEY_VOLUME_OVERFLOW                  (0x0D)
    00582
    00583 #define CSL_MSC_SCSI_SENSEKEY_MISCOMPARE                       (0x0E)
    00584
    00585 #define CSL_MSC_SCSI_SENSEKEY_RESERVED                         (0x0F)
    00586
    00587 #define CSL_MSC_SCSI_ASC_MISCOMPARE_VERIFY                     (0x001D)
    00588
    00591 #define CSL_MSC_SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION       (0x0000)
    00592
    00593 #define CSL_MSC_SCSI_ASC_MEDIA_NOT_PRESENT                     (0x003A)
    00594
    00595 #define CSL_MSC_SCSI_ASC_INVALID_COMMAND_OPERATION_CODE        (0x0020)
    00596
    00597 #define CSL_MSC_SCSI_ASC_MEDIA_MAY_HAVE_CHANGED               (0x0028)
    00598
    00599 #define CSL_MSC_SCSI_ASC_MEDIA_MANUALINTERVENTION_REQUIRED    (0x0004)
    00600
    00601 #define CSL_MSC_SCSI_ASC_MEDIA_OUTOFRANGE                      (0x0021)
    00602
    00603 #define CSL_MSC_SCSI_ASC_WRITE_PROTECTED                       (0x0027)
    00604
    00605 #define CSL_MSC_SCSI_ASC_MEDIA_REMOVAL_PREVENTED               (0x0253)
    00606
    00609 #define CSL_MSC_CSW_STATUS_COMMAND_PASSED                      (0x00)
    00610
    00611 #define CSL_MSC_CSW_STATUS_COMMAND_FAILED                      (0x01)
    00612
    00613 #define CSL_MSC_CSW_STATUS_PHASE_ERROR                         (0x02)
    00614
    00616 #define CSL_MSC_RC_1                                           (2)
    00617
    00618 #define CSL_MSC_RC_2                                           (3)
    00619
    00620 #define CSL_MSC_RC_3                                           (4)
    00621
    00622 #define CSL_MSC_RC_4                                           (5)
    00623
    00625 #define CSL_MSC_SSD_2                                          (3)
    00626
    00627 #define CSL_MSC_SSD_7                                          (8)
    00628
    00630 #define CSL_SCSI_DATA0_DEFVAL                                  (96)
    00631
    00632 #define CSL_SCSI_DATA1_DEFVAL                                  (0x0)
    00633
    00634 #define CSL_SCSI_DATA2_DEFVAL                                  (0x8000)
    00635
    00636 #define CSL_SCSI_DATA3_DEFVAL                                  (0x0200)
    00637
    00638 #define CSL_SCSI_DATA4_DEFVAL                                  (92)
    00639
    00640 #define CSL_SCSI_DATA5_DEFVAL                                  (0x0000)
    00641
    00642 #define CSL_SCSI_DATA30_DEFVAL                                 (0x0000)
    00643
    00644 #define CSL_SCSI_DATA31_DEFVAL                                 (0x2002)
    00645
    00646 #define CSL_SCSI_DATA32_DEFVAL                                 (0x3802)
    00647
    00648 #define CSL_SCSI_DATA_NULL_VAL                                 (0x0000)
    00649
    00650 #define CSL_SCSI_DATA_SIZE1                                    (6)
    00651
    00652 #define CSL_SCSI_DATA_SIZE2                                    (30)
    00653
    00654 #define CSL_SCSI_DATA_SIZE3                                    (33)
    00655
    00656 #define CSL_SCSI_DATA_SIZE4                                    (50)
    00657
    00659 #define CSL_MSC_ERROR_BASE                             (CSL_EUSB_FIRST)
    00660
    00661 #define CSL_MSC_INVALID_REQUEST_HANDLER                (CSL_MSC_ERROR_BASE - 1)
    00662
    00663
    00665 #define CSL_MSC_REQUEST_ARGS     CSL_UsbDevNum         devNum,           \
    00666                                  CSL_UsbSetupStruct    *usbSetup,        \
    00667                                  pUsbEpHandle          hInEp,            \
    00668                                  pUsbEpHandle          hOutEp,           \
    00669                                  void                  *pMsc
    00670
    00675 /**************************************************************************\
    00676 * USB MSC global typedef declarations                                      *
    00677 \**************************************************************************/
    00678
    00685 typedef enum {
    00686     /* Don't call request again until new SETUP                              */
    00687     CSL_MSC_REQUEST_DONE = 0,
    00688     /* STALL the control endpoint                                            */
    00689     CSL_MSC_REQUEST_STALL,
    00690     /* Send a 0 length IN packet                                             */
    00691     CSL_MSC_REQUEST_SEND_ACK,
    00692     /* Prepare to receive 0 length OUT packet                                */
    00693     CSL_MSC_REQUEST_GET_ACK,
    00694     /* Notify handler when IN data has been transmitted                      */
    00695     CSL_MSC_REQUEST_DATA_IN,
    00696     /* Notify handler when OUT data has been received                        */
    00697     CSL_MSC_REQUEST_DATA_OUT
    00698 } CSL_MscRequestRet;
    00699
    00703 typedef enum {
    00705     CSL_MSC_MEDIACCESS_OVERFLOW,
    00707     CSL_MSC_MEDIACCESS_SUCCESS,
    00709     CSL_MSC_MEDIACCESS_NOTPRESENT,
    00711     CSL_MSC_MEDIACCESS_WRITEPROTECT,
    00713     CSL_MSC_MEDIACCESS_BADMEDIA
    00714 } CSL_MscMediaStatus;
    00715
    00719 typedef enum {
    00721     CSL_MSC_UNLOCK = 0,
    00723     CSL_MSC_LOCK
    00724 } CSL_MscMediaLockStatus;
    00725
    00730 /**************************************************************************\
    00731 * USB MSC global data structure declarations                               *
    00732 \**************************************************************************/
    00733
    00744 typedef struct CSL_MscRequestStruct {
    00746     WORD                 request;
    00748     CSL_MscRequestRet    (*fpRequestHandler)(CSL_MSC_REQUEST_ARGS);
    00749 } CSL_MscRequestStruct;
    00750
    00757 typedef struct CSL_MscInitStructApp {
    00759     void                    *pMscObj;
    00761     Uint16                  pId;
    00763     Uint16                  vId;
    00765     Uint16                  numLun;
    00767     char                    **strDescrApp;
    00770     Uint16                  *lbaBufferApp;
    00772     CSL_MscRequestStruct    *mscReqTableApp;
    00775     void                    (*bulkHandler)();
    00778     void                    (*ctrlHandler)();
    00780     CSL_MscMediaStatus      (*readMediaApp)(Uint16, Uint16*, Uint32, Uint16);
    00782     CSL_MscMediaStatus      (*writeMediaApp)(Uint16, Uint16*, Uint32, Uint16);
    00784     CSL_MscMediaStatus      (*mediaGetPresentStateApp)(Uint16);
    00786     CSL_MscMediaStatus      (*mediaInitApp)(Uint16);
    00788     CSL_MscMediaStatus      (*mediaEjectApp)(Uint16);
    00790     CSL_MscMediaStatus      (*mediaLockUnitApp)(Uint16,CSL_MscMediaLockStatus);
    00792     Uint32                  (*getMediaSizeApp)(Uint16);
    00793 } CSL_MscInitStructApp;
    00794
    00796 typedef CSL_MscInitStructApp  *pMscAppClassHandle;
    00797
    00804 typedef struct CSL_MscLunAttribApp {
    00806     Uint32    lbaSizeApp;
    00808     Uint32    mediaSizeApp;
    00810     Uint16    removeableApp;
    00812     Uint16    scsiInquiryConfData [CSL_MSC_SCSI_INQUIRY_CONF_LEN];
    00814     Uint16    mediaStateApp;
    00816     Uint16    readwriteApp;
    00817 } CSL_MscLunAttribApp;
    00818
    00820 typedef CSL_MscLunAttribApp   *pMscAppLunAttribHandle;
    00821
    00823 typedef  CSL_MscRequestRet (*fpMSC_REQ_HANDLER)(CSL_MSC_REQUEST_ARGS);
    00824
    00832 typedef struct CSL_MscLogicalUnit {
    00834     Uint16    scsiInquiryData[CSL_MSC_SCSI_INQUIRY_LEN];
    00837     Uint32    mediaSize;
    00839     Uint32    currLba;
    00841     Uint32    lbaSize;
    00843     Uint16    removeable;
    00845     Uint16    mediaState;
    00847     Uint16    readwrite;
    00849     Uint16    lbaCnt;
    00851     Uint16    verifyFlag;
    00852 } CSL_MscLogicalUnit;
    00853
    00859 typedef struct CSL_MscObject {
    00861     CSL_MscMediaStatus    (*readMedia)(Uint16 , Uint16* , Uint32, Uint16 );
    00863     CSL_MscMediaStatus    (*writeMedia)(Uint16 , Uint16* , Uint32, Uint16 );
    00865     CSL_MscMediaStatus    (*mediaGetPresentState)(Uint16 );
    00867     CSL_MscMediaStatus    (*mediaInit)(Uint16 );
    00869     CSL_MscMediaStatus    (*mediaEject)(Uint16 );
    00871     CSL_MscMediaStatus    (*mediaLockUnit)(Uint16,CSL_MscMediaLockStatus);
    00873     Uint32                (*getMediaSize)(Uint16 );
    00875     Uint16                *lbaBuffer;
    00877     Uint32                cbwDataTransferLength;
    00879     CSL_MscLogicalUnit    lun[CSL_MSC_LUN_MAX];
    00881     Uint16                senseData[CSL_MSC_SENSEDATA_LEN];
    00883     Uint16                activityPresentFlag;
    00885     Uint16                csw[CSL_MSC_CSWSIZE];
    00887     Uint16                readCapacity[CSL_MSC_READCAP];
    00889     Uint16                cbw[CSL_MSC_CBWSIZE];
    00891     CSL_UsbEpObj          bulkInEpObj;
    00893     CSL_UsbEpObj          bulkOutEpObj;
    00895     Uint16                noOfLun;
    00897     Uint16                storageState;
    00899     Uint16                modeSenseData[5];
    00901     Bool                  writeToMedia;
    00902 } CSL_MscObject;
    00903
    00909 typedef struct CSL_MscCtrlObject {
    00911     CSL_UsbEpObj             ctrlInEpObj;
    00913     CSL_UsbDevNum            devNum;
    00915     CSL_UsbEpObj             ctrlOutEpObj;
    00917     Uint16                   suspendFlag;
    00919     pUsbEpHandle             hEpObjArray[CSL_MSC_NO_ENDPTOBJECT];
    00921     CSL_UsbSetupStruct       usbSetup;
    00923     Uint16                   highSpeedCfgDescr[CSL_MSC_CFGDESC_TOTAL_LEN];
    00925     Uint16                   fullSpeedCfgDescr[CSL_MSC_CFGDESC_TOTAL_LEN];
    00927     Uint16                   deviceDescr[CSL_MSC_DEVDESC_LEN];
    00929     Uint16                   deviceQualDescr[CSL_MSC_DEVQUALDESC_LEN];
    00931     Uint16                   confDescr[CSL_MSC_CONFDESC_LEN];
    00933     Uint16                   massStorageIntDescr[CSL_MSC_MS_INTDESC_LEN];
    00935     Uint16 massStorageBulkOutEndptDescr[CSL_MSC_MS_BULKOUT_ENDPTDESC_LEN];
    00937     CSL_UsbDataStruct        massStorageInterfcLnk;
    00939     Uint16 massStorageBulkInEndptDescr[CSL_MSC_MS_BULKIN_ENDPTDESC_LEN];
    00941     CSL_UsbDataStruct        massStorageBulkOutEndptLnk;
    00943     Uint16                   stringDescrLangid[CSL_MSC_STRDESC_LANGID_LEN];
    00945     Uint16                   curConfigStat;
    00947     CSL_UsbDataStruct        massStorageBulkInEndptLnk;
    00949     Uint16                   ctrlBuffer[CSL_MSC_CTRLBUFF_LEN];
    00951     CSL_UsbDataStruct        configDescrLnk;
    00953     char                     **strDescr;
    00955     CSL_MscRequestStruct     *mscReqTable;
    00957     CSL_MscRequestRet        (*fpRequestHandler)(CSL_MSC_REQUEST_ARGS);
    00961     Bool                     usbSpeedCfg;
    00964     Uint16                   *pCfgDescr;
    00967     Uint16                   *pOtherSpeedCfgDescr;
    00968 } CSL_MscCtrlObject;
    00969
    00975 typedef struct CSL_MscClassStruct {
    00977     CSL_MscCtrlObject    ctrlHandle;
    00979     CSL_MscObject        mscHandle;
    00980 } CSL_MscClassStruct;
    00981
    00983 typedef CSL_MscClassStruct  *pMscClassHandle;
    00984
    00988 /**************************************************************************\
    00989 * USB MSC function declarations                                            *
    00990 \**************************************************************************/
    00991
    01041 CSL_Status MSC_Open(pMscAppClassHandle    pAppClassHandle);
    01042
    01089 CSL_Status MSC_OpenFullspeed(pMscAppClassHandle    pAppClassHandle);
    01090
    01139 static CSL_Status MSC_Setup(pMscAppClassHandle    pAppClassHandle,
    01140                             Bool                  usbSpeedCfg);
    01141
    01186 CSL_Status MSC_Close(pMscAppClassHandle    pAppClassHandle);
    01187
    01240 CSL_Status MSC_SetLunAttr(pMscAppClassHandle      pAppClassHandle,
    01241                           CSL_MscLunAttribApp     *lunHandle,
    01242                           Uint16                  lunNum);
    01243
    01291 CSL_Status MSC_Ctrl(void    *pMSC);
    01292
    01340 CSL_Status MSC_Bulk(void    *pMSC);
    01341
    01388 Uint16 MSC_GetLunLockedStatus(void      *pMSC,
    01389                               Uint16    lunNum);
    01390
    01436 Uint16 MSC_GetactivityFlagStatus(void    *pMSC);
    01437
    01483 Uint16 MSC_GetsuspendFlagStatus(void    *pMSC);
    01484
    01519 static CSL_Status MSC_initCtrlDesc(CSL_MscCtrlObject    *pCtrlHandle);
    01520
    01555 static CSL_Status MSC_initMscVal(CSL_MscObject    *pMscHandle);
    01556
    01605 CSL_Status MSC_HandleStateWaitForCBW(CSL_MscObject    *pMscHandle,
    01606                                      pUsbEpHandle     hUsbOutEp,
    01607                                      pUsbEpHandle     hUsbInEp);
    01608
    01661 CSL_Status MSC_ExecuteRead(CSL_MscObject    *pMscHandle,
    01662                            Uint16           lunNum,
    01663                            Uint16           first);
    01664
    01717 CSL_Status MSC_ExecuteWrite(CSL_MscObject    *pMscHandle,
    01718                             Uint16           lunNum,
    01719                             Uint16           first);
    01720
    01766 CSL_Status MSC_HandleTestUnitReady(CSL_MscObject    *pMscHandle,
    01767                                    pUsbEpHandle     hUsbInEp,
    01768                                    Uint16           logicalUnit);
    01769
    01815 CSL_Status MSC_HandlePreventAllowMediaRemoval(CSL_MscObject    *pMscHandle,
    01816                                               pUsbEpHandle     hUsbInEp,
    01817                                               Uint16           logicalUnit);
    01818
    01864 CSL_Status MSC_HandleReadCapacity(CSL_MscObject    *pMscHandle,
    01865                                   pUsbEpHandle     hUsbInEp,
    01866                                   Uint16           logicalUnit);
    01867
    01918 CSL_MscRequestRet MSC_reqGetDescriptor(CSL_UsbDevNum         devNum,
    01919                                        CSL_UsbSetupStruct    *usbSetup,
    01920                                        pUsbEpHandle          hInEp,
    01921                                        pUsbEpHandle          hOutEp,
    01922                                        void                  *pMsc);
    01923
    01979 CSL_MscRequestRet MSC_reqBotMscReset(CSL_UsbDevNum         devNum,
    01980                                      CSL_UsbSetupStruct    *usbSetup,
    01981                                      pUsbEpHandle          hInEp,
    01982                                      pUsbEpHandle          hOutEp,
    01983                                      void                  *pMsc);
    01984
    02033 CSL_Status MSC_sendCswWithPhaseError(CSL_MscObject    *pMscHandle,
    02034                                      pUsbEpHandle     hUsbInEp);
    02035
    02086 CSL_Status MSC_handleDataDirMisMatch(CSL_MscObject    *pMscHandle,
    02087                                       Uint16           dataDir);
    02093 #ifdef __cplusplus
    02094 }
    02095 #endif
    02096
    02097 #endif    //_CSL_MSC_H_
    02098