hpusbscsi.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* Header file for the hpusbscsi driver */
  2. /* (C) Copyright 2001 Oliver Neukum */
  3. /* sponsored by the Linux Usb Project */
  4. /* large parts based on or taken from code by John Fremlin and Matt Dharm */
  5. /* this file is licensed under the GPL */
  6. /* A big thanks to Jose for untiring testing */
  7. typedef void (*usb_urb_callback) (struct urb *);
  8. typedef void (*scsi_callback)(Scsi_Cmnd *);
  9. #define SENSE_COMMAND_SIZE 6
  10. #define HPUSBSCSI_SENSE_LENGTH 0x16
  11. struct hpusbscsi
  12. {
  13.         struct list_head lh;
  14.         struct usb_device *dev; /* NULL indicates unplugged device */
  15.         int ep_out;
  16.         int ep_in;
  17.         int ep_int;
  18.         int interrupt_interval;
  19.         struct Scsi_Host *host;
  20.         Scsi_Host_Template ctempl;
  21.         int number;
  22.        scsi_callback scallback;
  23.        Scsi_Cmnd *srb;
  24. u8 sense_command[SENSE_COMMAND_SIZE];
  25.         int use_count;
  26.         wait_queue_head_t pending;
  27.         wait_queue_head_t deathrow;
  28.         struct urb dataurb;
  29.         struct urb controlurb;
  30.         int fragment;
  31.         int state;
  32.         int current_data_pipe;
  33.         u8 scsi_state_byte;
  34. };
  35. #define SCSI_ERR_MASK ~0x3fu
  36. static const unsigned char scsi_command_direction[256/8] = {
  37. 0x28, 0x81, 0x14, 0x14, 0x20, 0x01, 0x90, 0x77,
  38. 0x0C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
  39. 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
  40. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  41. };
  42. #define DIRECTION_IS_IN(x) ((scsi_command_direction[x>>3] >> (x & 7)) & 1)
  43. static int hpusbscsi_scsi_detect (struct SHT * sht);
  44. static void simple_command_callback(struct urb *u);
  45. static void scatter_gather_callback(struct urb *u);
  46. static void simple_payload_callback (struct urb *u);
  47. static void control_interrupt_callback (struct urb *u);
  48. static void request_sense_callback (struct urb *u);
  49. static void simple_done (struct urb *u);
  50. static int hpusbscsi_scsi_queuecommand (Scsi_Cmnd *srb, scsi_callback callback);
  51. static int hpusbscsi_scsi_host_reset (Scsi_Cmnd *srb);
  52. static int hpusbscsi_scsi_abort (Scsi_Cmnd *srb);
  53. static void issue_request_sense (struct hpusbscsi *hpusbscsi);
  54. static Scsi_Host_Template hpusbscsi_scsi_host_template = {
  55. name:           "hpusbscsi",
  56. detect: hpusbscsi_scsi_detect,
  57. // release: hpusbscsi_scsi_release,
  58. queuecommand: hpusbscsi_scsi_queuecommand,
  59. eh_abort_handler: hpusbscsi_scsi_abort,
  60. eh_host_reset_handler: hpusbscsi_scsi_host_reset,
  61. sg_tablesize: SG_ALL,
  62. can_queue: 1,
  63. this_id: -1,
  64. cmd_per_lun: 1,
  65. present: 0,
  66. unchecked_isa_dma: FALSE,
  67. use_clustering: TRUE,
  68. use_new_eh_code: TRUE,
  69. emulated: TRUE
  70. };
  71. /* defines for internal driver state */
  72. #define HP_STATE_FREE                 0  /*ready for next request */
  73. #define HP_STATE_BEGINNING      1  /*command being transfered */
  74. #define HP_STATE_WORKING         2  /* data transfer stage */
  75. #define HP_STATE_ERROR             3  /* error has been reported */
  76. #define HP_STATE_WAIT                 4  /* waiting for status transfer */
  77. #define HP_STATE_PREMATURE              5 /* status prematurely reported */