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 typedef void (*usb_urb_callback) (struct urb *);
8 typedef void (*scsi_callback)(Scsi_Cmnd *);
13 struct usb_device *dev; /* NULL indicates unplugged device */
17 int interrupt_interval;
19 struct Scsi_Host *host;
20 Scsi_Host_Template ctempl;
22 scsi_callback scallback;
26 wait_queue_head_t pending;
27 wait_queue_head_t deathrow;
30 struct urb controlurb;
34 int current_data_pipe;
39 #define SCSI_ERR_MASK ~0x3fu
41 static const unsigned char scsi_command_direction[256/8] = {
42 0x28, 0x81, 0x14, 0x14, 0x20, 0x01, 0x90, 0x77,
43 0x0C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
48 #define DIRECTION_IS_IN(x) ((scsi_command_direction[x>>3] >> (x & 7)) & 1)
50 static int hpusbscsi_scsi_detect (struct SHT * sht);
51 static void simple_command_callback(struct urb *u);
52 static void scatter_gather_callback(struct urb *u);
53 static void simple_payload_callback (struct urb *u);
54 static void control_interrupt_callback (struct urb *u);
55 static void simple_done (struct urb *u);
56 static int hpusbscsi_scsi_queuecommand (Scsi_Cmnd *srb, scsi_callback callback);
57 static int hpusbscsi_scsi_host_reset (Scsi_Cmnd *srb);
58 static int hpusbscsi_scsi_abort (Scsi_Cmnd *srb);
60 static Scsi_Host_Template hpusbscsi_scsi_host_template = {
62 detect: hpusbscsi_scsi_detect,
63 // release: hpusbscsi_scsi_release,
64 queuecommand: hpusbscsi_scsi_queuecommand,
66 eh_abort_handler: hpusbscsi_scsi_abort,
67 eh_host_reset_handler: hpusbscsi_scsi_host_reset,
74 unchecked_isa_dma: FALSE,
76 use_new_eh_code: TRUE,
80 /* defines for internal driver state */
81 #define HP_STATE_FREE 0 /*ready for next request */
82 #define HP_STATE_BEGINNING 1 /*command being transfered */
83 #define HP_STATE_WORKING 2 /* data transfer stage */
84 #define HP_STATE_ERROR 3 /* error has been reported */
85 #define HP_STATE_WAIT 4 /* waiting for status transfer */
86 #define HP_STATE_PREMATURE 5 /* status prematurely reported */