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 */
7 /* A big thanks to Jose for untiring testing */
9 typedef void (*usb_urb_callback) (struct urb *);
10 typedef void (*scsi_callback)(Scsi_Cmnd *);
12 #define SENSE_COMMAND_SIZE 6
13 #define HPUSBSCSI_SENSE_LENGTH 0x16
18 struct usb_device *dev; /* NULL indicates unplugged device */
22 int interrupt_interval;
23 int need_short_workaround;
25 struct Scsi_Host *host;
26 Scsi_Host_Template ctempl;
28 scsi_callback scallback;
30 u8 sense_command[SENSE_COMMAND_SIZE];
33 struct semaphore lock;
34 wait_queue_head_t pending;
35 wait_queue_head_t deathrow;
38 struct urb controlurb;
42 int current_data_pipe;
47 #define SCSI_ERR_MASK ~0x3fu
49 static const unsigned char scsi_command_direction[256/8] = {
50 0x28, 0x81, 0x14, 0x14, 0x20, 0x01, 0x90, 0x77,
51 0x0C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
52 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
53 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
56 #define DIRECTION_IS_IN(x) ((scsi_command_direction[x>>3] >> (x & 7)) & 1)
58 static int hpusbscsi_scsi_detect (struct SHT * sht);
59 static void simple_command_callback(struct urb *u);
60 static void scatter_gather_callback(struct urb *u);
61 static void simple_payload_callback (struct urb *u);
62 static void control_interrupt_callback (struct urb *u);
63 static void request_sense_callback (struct urb *u);
64 static void simple_done (struct urb *u);
65 static int hpusbscsi_scsi_queuecommand (Scsi_Cmnd *srb, scsi_callback callback);
66 static int hpusbscsi_scsi_host_reset (Scsi_Cmnd *srb);
67 static int hpusbscsi_scsi_abort (Scsi_Cmnd *srb);
68 static void issue_request_sense (struct hpusbscsi *hpusbscsi);
70 static Scsi_Host_Template hpusbscsi_scsi_host_template = {
72 detect: hpusbscsi_scsi_detect,
73 // release: hpusbscsi_scsi_release,
74 queuecommand: hpusbscsi_scsi_queuecommand,
76 eh_abort_handler: hpusbscsi_scsi_abort,
77 eh_host_reset_handler: hpusbscsi_scsi_host_reset,
84 unchecked_isa_dma: FALSE,
86 use_new_eh_code: TRUE,
90 /* defines for internal driver state */
91 #define HP_STATE_FREE 0 /*ready for next request */
92 #define HP_STATE_BEGINNING 1 /*command being transfered */
93 #define HP_STATE_WORKING 2 /* data transfer stage */
94 #define HP_STATE_ERROR 3 /* error has been reported */
95 #define HP_STATE_WAIT 4 /* waiting for status transfer */
96 #define HP_STATE_PREMATURE 5 /* status prematurely reported */