⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocol.h

📁 <B>SMSC USB2.0 Flash硬盘驱动源码</B>
💻 H
📖 第 1 页 / 共 3 页
字号:
/*============================================================================
  ____________________________________________________________________________
                                ______________________________________________
   SSSS  M   M          CCCC          Standard Microsystems Corporation
  S      MM MM   SSSS  C                    Austin Design Center
   SSS   M M M  S      C                 11000 N. Mopac Expressway
      S  M   M   SSS   C                Stonelake Bldg. 6, Suite 500
  SSSS   M   M      S   CCCC                Austin, Texas 78759
                SSSS            ______________________________________________
  ____________________________________________________________________________
  Copyright(C) 1999, Standard Microsystems Corporation
  All Rights Reserved.
  This program code listing is proprietary to SMSC and may not be copied,
  distributed, or used without a license to do so.  Such license may have
  Limited or Restricted Rights. Please refer to the license for further
  clarification.
  ____________________________________________________________________________
  Notice: The program contained in this listing is a proprietary trade
  secret of SMSC, Hauppauge, New York, and is copyrighted
  under the United States Copyright Act of 1976 as an unpublished work,
  pursuant to Section 104 and Section 408 of Title XVII of the United
  States code. Unauthorized copying, adaption, distribution, use, or
  display is prohibited by this law.
  ____________________________________________________________________________
  Use, duplication, or disclosure by the Government is subject to
  restrictions as set forth in subparagraph(c)(1)(ii) of the Rights
  in Technical Data and Computer Software clause at DFARS 52.227-7013.
  Contractor/Manufacturer is Standard Microsystems Corporation,
  80 Arkay Drive, Hauppauge, New York, 1178-8847.
  ____________________________________________________________________________
  ____________________________________________________________________________
  <module name> - <module description>
  ____________________________________________________________________________
  comments tbd
  ____________________________________________________________________________
  Revision History
  Date      Who  Comment
  ________  ___  _____________________________________________________________
  12/06/01  tbh  initial version
  01/15/02  cds  added s_scsi_cb structure, added read_format_capacity and
                 start_stop_unit command parameter structures to the scsi cb
                 union.  Hopefully these unions will grow where they are used
                 (see lun.c for code examples utilizing structure)
  04/17/02  tbh  added k_protocol_mode_sense_6
  07/23/02  baw  added password protocol constants
  07/25/02  baw  Added three more password commands, they are
                 - Password Supported
                 - Is Locked
                 - Is Password Validated
                 These commands will give the application access to more information
                 so it doesn't have to make assuptions based on media present.
  09/25/02  cds  added new vendor specific command:  erase_media and report_media_geometry 
  10/01/02  ds   Added two new command definitions to support the vendor specific commands
                 secure_memory_write and secure_memory_read on a nvstore. Per a customer's requirement                
============================================================================*/

//------------------------------------------------------------------------------
#define k_protocol_format_unit                 0x04
#define k_protocol_inquiry                     0x12
#define k_protocol_mode_select_10              0x55
#define k_protocol_mode_sense_10               0x5A
#define k_protocol_mode_sense_6                0x1A
#define k_protocol_prevent_allow_medium_remval 0x1E
#define k_protocol_read_10                     0x28
#define k_protocol_read_12                     0xA8
#define k_protocol_read_capacity               0x25
#define k_protocol_read_format_capacities      0x23
#define k_protocol_request_sense               0x03
#define k_protocol_start_stop_unit             0x1B
#define k_protocol_synchronize_cache           0x35
#define k_protocol_test_unit_ready             0x00
#define k_protocol_verify_10                   0x2F
#define k_protocol_write_10                    0x2A
#define k_protocol_write_12                    0xAA
#define k_protocol_write_verify                0x2E

//Vendor specific opcode for secure-memory in nvstore
#define k_protocol_vendor_secure_memory_read   0xFA
#define k_protocol_vendor_secure_memory_write  0xFB

// The following vendor command has been made up,
//  it is not a standard SCSI command.
// I don't believe the code conflicts with anything presently.
// hopefully as the standard evolves it will continue not to conflict
#define k_protocol_vendor                      0xCF //not a standard SCSI command

//------------------------------------------------------------------------------
// vendor commands, cdb[1]
#define k_vendor_erase_media                   0x10
#define k_vendor_report_media_geometry         0x11



//------------------------------------------------------------------------------
// verify
#define kbm_verify_opt_dpo    0x10
#define kbm_verify_opt_bytchk 0x02
#define kbm_verify_opt_reladr 0x01

typedef struct s_param_verify10
{
  uint8    opts;
  t_udw32  lba;
  uint8    reserved1;
  t_uw16   len;
  uint8    control;
} t_param_verify10;

typedef struct s_param_verify12
{
  uint8 opts;
  t_udw32 lba;
  t_udw32 len;
  uint8 control;
} t_param_verify12;

typedef union u_param_verify
{
  t_param_verify10 verify10;
  t_param_verify12 verify12;
} t_param_verify;


//------------------------------------------------------------------------------
// Read10 / Read12
#define kbm_rwopts_dpo  0x10    // cache control bit
#define kbm_rwopts_fua  0x08    // force unit access
#define kbm_rwopts_reladr 0x01  // relative addressing

typedef struct s_param_rw10
{
  uint8    opts;
  t_udw32  lba;
  uint8    rsvd1;
  t_uw16   len;
  uint8    control;
} t_param_rw10;

typedef struct s_param_rw12
{
  uint8    opts;
  t_udw32  lba;
  t_udw32  len;
  uint8 control;
} t_param_rw12;

typedef union u_param_read
{
  t_param_rw10 rw10;
  t_param_rw12 rw12;
} t_param_rw;


//------------------------------------------------------------------------------
// read format capacity

typedef struct s_capacity
{
  t_udw32 lba_max;               // max lba that can be accessed.
  t_udw32 lba_sz;                // size of a single logical block, in bytes
} t_capacity;

typedef struct s_param_read_format_capacity
{
  uint8   reserved[6] ;
  uint16  allocation_len ;
  uint8   control ;
} t_param_read_format_capacity ;

typedef struct s_capacity_list_hdr
{
  uint8 reserved[3];
  uint8 capacity_list_length;
} t_capacity_list_hdr ;

typedef struct s_format_capacity_dscr
{
  t_udw32 num_blocks ;
  uint8   descr_or_format_type ;
  uint8   max_block_sz_hi;
  t_uw16  max_block_sz_lo;
} t_format_capacity_dscr ;


#if 0
#define k_max_fmt_cap_entry 4
typedef struct s_fmt_cap_dscr
{
  t_fmt_cap_hdr   fmt_cap_hdr;
  t_fmt_cap_entry fmt_cap_entry[k_max_fmt_cap_entry];
} t_fmt_cap_dscr;

#endif

//------------------------------------------------------------------------------
// mode sense, mode select
#define kbm_mode_sense_dbd                      0x80
#define kbm_mode_sense_pc                       0xc0
#define k_mode_sense_pc_current                 0x00
#define k_mode_sense_pc_changable               0x40
#define k_mode_sense_pc_default                 0x80
#define k_mode_sense_pc_saved                   0xc0
#define kbm_mode_sense_page                     0x3f
#define k_mode_page_rw_err_recovery             0x01
#define k_mode_page_dct_rct                     0x02
#define k_mode_page_format_device               0x03
#define k_mode_page_rigid_disk                  0x04
#define k_mode_page_flexible_disk               0x05
#define k_mode_page_verify_error_recovery       0x07
#define k_mode_page_caching                     0x08
#define k_mode_page_control                     0x0a
#define k_mode_page_medium_types                0x0b
#define k_mode_page_notch                       0x0c
#define k_mode_page_power_condition             0x0d
#define k_mode_page_xor_control                 0x10
#define k_mode_page_info_excpt_ctl              0x1c
#define k_mode_page_all                         0x3f


// Mode Page List Header
typedef struct s_mode_page_header
{
  uint16  data_length;
  uint8   medium_type;
  uint8   device_specific;
  uint8   reserved_1;
  uint8   reserved_2;
  uint16  block_descriptor_length;
} t_str_mode_page_header;

#define k_sz_mode_page_header        0x08
typedef uint8 t_buf_mode_page_header[k_sz_mode_page_header];

//------------------------------------------------------------------------------
// read write error recovery
#define k_mode_page_rw_err_recovery_page_length  0x0a
#define kbm_mode_page_rw_err_opt2_awre           0x80
#define kbm_mode_page_rw_err_opt2_arre           0x40
#define kbm_mode_page_rw_err_opt2_tb             0x20
#define kbm_mode_page_rw_err_opt2_rc             0x10
#define kbm_mode_page_rw_err_opt2_eer            0x08
#define kbm_mode_page_rw_err_opt2_per            0x04
#define kbm_mode_page_rw_err_opt2_dte            0x02
#define kbm_mode_page_rw_err_opt2_dcr            0x01

typedef struct s_mode_page_rw_err
{
  uint8     page_code;
  uint8     page_length;
  uint8     opt2;
  uint8     read_retry_count;
  uint8     correction_span;
  uint8     head_offset_count;
  uint8     data_strobe_offset_count;
  uint8     reserved_1;
  uint8     write_retry_count;
  uint8     reserved_2;
  uint16     recovery_time_limit;
} t_str_mode_page_rw_err;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -