1 1.1 cgd /* 2 1.1 cgd * Written by Julian Elischer (julian (at) tfs.com) 3 1.1 cgd * for TRW Financial Systems for use under the MACH(2.5) operating system. 4 1.1 cgd * 5 1.1 cgd * TRW Financial Systems, in accordance with their agreement with Carnegie 6 1.1 cgd * Mellon University, makes this software available to CMU to distribute 7 1.1 cgd * or use in any manner that they see fit as long as this message is kept with 8 1.1 cgd * the software. For this reason TFS also grants any other persons or 9 1.1 cgd * organisations permission to use or modify this software. 10 1.1 cgd * 11 1.1 cgd * TFS supplies this software to be publicly redistributed 12 1.1 cgd * on the understanding that TFS is not responsible for the correct 13 1.1 cgd * functioning of this software in any circumstances. 14 1.1 cgd * 15 1.1 cgd * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE 16 1.1 cgd * -------------------- ----- ---------------------- 17 1.1 cgd * CURRENT PATCH LEVEL: 1 00098 18 1.1 cgd * -------------------- ----- ---------------------- 19 1.1 cgd * 20 1.1 cgd * 16 Feb 93 Julian Elischer ADDED for SCSI system 21 1.1 cgd * 22 1.1 cgd */ 23 1.1 cgd 24 1.1 cgd /* 25 1.1 cgd * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992 26 1.1 cgd */ 27 1.1 cgd 28 1.1 cgd /***********************************************\ 29 1.1 cgd * these calls are called by the high-end * 30 1.1 cgd * drivers to get services from whatever low-end * 31 1.1 cgd * drivers they are attached to * 32 1.1 cgd \***********************************************/ 33 1.1 cgd struct scsi_switch 34 1.1 cgd { 35 1.1 cgd int (*scsi_cmd)(); 36 1.1 cgd void (*scsi_minphys)(); 37 1.1 cgd int (*open_target_lu)(); 38 1.1 cgd int (*close_target_lu)(); 39 1.1 cgd long int (*adapter_info)(); /* see definitions below */ 40 1.1 cgd u_long spare[3]; 41 1.1 cgd }; 42 1.1 cgd #define AD_INF_MAX_CMDS 0x000000FF /* maximum number of entries 43 1.1 cgd queuable to a device by 44 1.1 cgd the adapter */ 45 1.1 cgd /* 24 bits of other adapter charcteristics go here */ 46 1.1 cgd 47 1.1 cgd /***********************************************\ 48 1.1 cgd * The scsi debug control bits * 49 1.1 cgd \***********************************************/ 50 1.1 cgd extern int scsi_debug; 51 1.1 cgd #define PRINTROUTINES 0x01 52 1.1 cgd #define TRACEOPENS 0x02 53 1.1 cgd #define TRACEINTERRUPTS 0x04 54 1.1 cgd #define SHOWREQUESTS 0x08 55 1.1 cgd #define SHOWSCATGATH 0x10 56 1.1 cgd #define SHOWINQUIRY 0x20 57 1.1 cgd #define SHOWCOMMANDS 0x40 58 1.1 cgd 59 1.1 cgd 60 1.1 cgd /********************************/ 61 1.1 cgd /* return values for scsi_cmd() */ 62 1.1 cgd /********************************/ 63 1.1 cgd #define SUCCESSFULLY_QUEUED 0 64 1.1 cgd #define TRY_AGAIN_LATER 1 65 1.1 cgd #define COMPLETE 2 66 1.1 cgd #define HAD_ERROR 3 67 1.1 cgd 68 1.1 cgd struct scsi_xfer 69 1.1 cgd { 70 1.1 cgd struct scsi_xfer *next; /* when free */ 71 1.1 cgd int flags; 72 1.1 cgd u_char adapter; 73 1.1 cgd u_char targ; 74 1.1 cgd u_char lu; 75 1.1 cgd u_char retries; /* the number of times to retry */ 76 1.1 cgd long int timeout; /* in miliseconds */ 77 1.1 cgd struct scsi_generic *cmd; 78 1.1 cgd int cmdlen; 79 1.1 cgd u_char *data; /* either the dma address OR a uio address */ 80 1.1 cgd int datalen; /* data len (blank if uio) */ 81 1.1 cgd int resid; 82 1.1 cgd int (*when_done)(); 83 1.1 cgd int done_arg; 84 1.1 cgd int done_arg2; 85 1.1 cgd int error; 86 1.1 cgd struct buf *bp; 87 1.1 cgd struct scsi_sense_data sense; 88 1.1 cgd }; 89 1.1 cgd /********************************/ 90 1.1 cgd /* Flag values */ 91 1.1 cgd /********************************/ 92 1.1 cgd #define SCSI_NOSLEEP 0x01 /* Not a user... don't sleep */ 93 1.1 cgd #define SCSI_NOMASK 0x02 /* dont allow interrupts.. booting */ 94 1.1 cgd #define SCSI_NOSTART 0x04 /* left over from ancient history */ 95 1.1 cgd #define ITSDONE 0x10 /* the transfer is as done as it gets */ 96 1.1 cgd #define INUSE 0x20 /* The scsi_xfer block is in use */ 97 1.1 cgd #define SCSI_SILENT 0x40 /* Don't report errors to console */ 98 1.1 cgd #define SCSI_ERR_OK 0x80 /* An error on this operation is OK. */ 99 1.1 cgd #define SCSI_RESET 0x100 /* Reset the device in question */ 100 1.1 cgd #define SCSI_DATA_UIO 0x200 /* The data address refers to a UIO */ 101 1.1 cgd #define SCSI_DATA_IN 0x400 /* expect data to come INTO memory */ 102 1.1 cgd #define SCSI_DATA_OUT 0x800 /* expect data to flow OUT of memory */ 103 1.1 cgd #define SCSI_TARGET 0x1000 /* This defines a TARGET mode op. */ 104 1.1 cgd /********************************/ 105 1.1 cgd /* Error values */ 106 1.1 cgd /********************************/ 107 1.1 cgd #define XS_NOERROR 0x0 /* there is no error, (sense is invalid) */ 108 1.1 cgd #define XS_SENSE 0x1 /* Check the returned sense for the error */ 109 1.1 cgd #define XS_DRIVER_STUFFUP 0x2 /* Driver failed to perform operation */ 110 1.1 cgd #define XS_TIMEOUT 0x03 /* The device timed out.. turned off? */ 111 1.1 cgd #define XS_SWTIMEOUT 0x04 /* The Timeout reported was caught by SW */ 112 1.1 cgd #define XS_BUSY 0x08 /* The device busy, try again later? */ 113 1.1 cgd 114