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 (*scsi_callback)(Scsi_Cmnd *);
11 #define SENSE_COMMAND_SIZE 6
12 #define HPUSBSCSI_SENSE_LENGTH 0x16
16 struct usb_device *dev; /* NULL indicates unplugged device */
20 int interrupt_interval;
23 struct Scsi_Host *host;
25 scsi_callback scallback;
29 wait_queue_head_t pending;
30 wait_queue_head_t deathrow;
33 struct urb *controlurb;
37 int current_data_pipe;
38 u8 sense_command[SENSE_COMMAND_SIZE];
42 #define SCSI_ERR_MASK ~0x3fu
44 static const unsigned char scsi_command_direction[256/8] = {
45 0x28, 0x81, 0x14, 0x14, 0x20, 0x01, 0x90, 0x77,
46 0x0C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
47 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
51 #define DIRECTION_IS_IN(x) ((scsi_command_direction[x>>3] >> (x & 7)) & 1)
53 static void simple_command_callback(struct urb *u, struct pt_regs *regs);
54 static void scatter_gather_callback(struct urb *u, struct pt_regs *regs);
55 static void simple_payload_callback (struct urb *u, struct pt_regs *regs);
56 static void request_sense_callback (struct urb *u, struct pt_regs *regs);
57 static void control_interrupt_callback (struct urb *u, struct pt_regs *regs);
58 static void simple_done (struct urb *u, struct pt_regs *regs);
59 static int hpusbscsi_scsi_queuecommand (Scsi_Cmnd *srb, scsi_callback callback);
60 static int hpusbscsi_scsi_host_reset (Scsi_Cmnd *srb);
61 static int hpusbscsi_scsi_abort (Scsi_Cmnd *srb);
62 static void issue_request_sense (struct hpusbscsi *hpusbscsi);
64 /* defines for internal driver state */
65 #define HP_STATE_FREE 0 /*ready for next request */
66 #define HP_STATE_BEGINNING 1 /*command being transferred */
67 #define HP_STATE_WORKING 2 /* data transfer stage */
68 #define HP_STATE_ERROR 3 /* error has been reported */
69 #define HP_STATE_WAIT 4 /* waiting for status transfer */
70 #define HP_STATE_PREMATURE 5 /* status prematurely reported */