home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Headers / driverkit / scsiTypes.h < prev    next >
Text File  |  1995-11-09  |  6KB  |  206 lines

  1. /*      Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved. 
  2.  *
  3.  * scsiTypes.h - Exported API of SCSIController class.
  4.  *
  5.  * HISTORY
  6.  * 14-Jun-95    Doug Mitchell at NeXT
  7.  *    Added SCSI-3 support.
  8.  * 11-Feb-91    Doug Mitchell at NeXT
  9.  *      Created. 
  10.  */
  11.  
  12. #import <objc/objc.h>
  13. #import <driverkit/driverTypes.h>
  14. #import <kernserv/clock_timer.h>
  15. #import <bsd/dev/scsireg.h>
  16.  
  17. /*
  18.  * Buffers aligned to IO_SCSI_DMA_ALIGNMENT (both start and end addresses) are
  19.  * guaranteed to be legal.
  20.  */
  21. #define IO_SCSI_DMA_ALIGNMENT      64
  22.  
  23. /*
  24.  * Argument to executeRequest:buffer:client method.
  25.  */
  26. typedef struct {
  27.  
  28.         /*** inputs ***/
  29.         
  30.         unsigned char        target;         /* SCSI target ID */
  31.         unsigned char        lun;            /* logical unit */
  32.         cdb_t            cdb;            /* command descriptor block - 
  33.                                                  * one of four formats */
  34.         BOOL            read;         /* expected DMA direction 
  35.                          * (YES if read) */
  36.         int            maxTransfer;    /* maximum number of bytes to
  37.                                                  * transfer */
  38.         int            timeoutLength;  /* I/O timeout in seconds */
  39.         unsigned        disconnect:1;   /* OK to disconnect */
  40.     unsigned        cmdQueueDisable:1;
  41.                         /* disable command queueing */
  42.     unsigned        syncDisable:1;    /* disable synchronous transfer
  43.                          * negotiation */
  44.     unsigned        ignoreChkcond:1;/* to disable issuing of chk.
  45.                            cond. cmd  */
  46.                 
  47.         unsigned        pad:24;    
  48.     unsigned        cdbLength:4;    /* length of CDB in bytes
  49.                          * (optional) */
  50.            
  51.         /*** outputs ***/
  52.         
  53.         sc_status_t        driverStatus;   /* driver status */
  54.         unsigned char        scsiStatus;     /* SCSI status byte */
  55.         int            bytesTransferred; /* actual number of bytes 
  56.                                                  * transferred by DMA */
  57.     ns_time_t        totalTime;    /* total execution time */
  58.     ns_time_t        latentTime;    /* disconnect time */
  59.     esense_reply_t         senseData;    /* extended sense if
  60.                          * driverStatus = SR_IOST_CHKSV
  61.                          */
  62.  
  63. } IOSCSIRequest;
  64.  
  65. /*
  66.  * Argument to executeSCSI3Request:buffer:client method.
  67.  */
  68. typedef struct {
  69.  
  70.         /*** inputs ***/
  71.         
  72.         unsigned long long    target;         /* SCSI target ID */
  73.         unsigned long long    lun;            /* logical unit */
  74.         scsi3_cdb_t        cdb;            /* command descriptor block - 
  75.                                                  * one of five formats */
  76.         BOOL            read;         /* expected DMA direction 
  77.                          * (YES if read) */
  78.         int            maxTransfer;    /* maximum number of bytes to
  79.                                                  * transfer */
  80.         int            timeoutLength;  /* I/O timeout in seconds */
  81.         unsigned        disconnect:1;   /* OK to disconnect */
  82.     unsigned        cmdQueueDisable:1;
  83.                         /* disable command queueing */
  84.     unsigned        syncDisable:1;    /* disable synchronous transfer
  85.                          * negotiation */
  86.                 
  87.         unsigned        pad:25;
  88.     unsigned        cdbLength:4;    /* length of CDB in bytes
  89.                          * (optional) */
  90.            
  91.         /*** outputs ***/
  92.         
  93.         sc_status_t        driverStatus;   /* driver status */
  94.         unsigned char        scsiStatus;     /* SCSI status byte */
  95.         int            bytesTransferred; /* actual number of bytes 
  96.                                                  * transferred by DMA */
  97.     ns_time_t        totalTime;    /* total execution time */
  98.     ns_time_t        latentTime;    /* disconnect time */
  99.     esense_reply_t         senseData;    /* extended sense if
  100.                          * driverStatus = SR_IOST_CHKSV
  101.                          */
  102.     unsigned char        pad2[4];
  103.  
  104. } IOSCSI3Request;
  105.  
  106.  
  107. /*
  108.  * Exported protocol for SCSIController object.
  109.  */
  110. @protocol IOSCSIControllerExported
  111.  
  112. /*
  113.  * Attempt to reserve specified target and lun for calling device. Returns
  114.  * non-zero if device already reserved.
  115.  */
  116. - (int)reserveTarget         : (unsigned char)target
  117.                 lun : (unsigned char)lun
  118.                forOwner : owner;
  119.  
  120. - (void)releaseTarget         : (unsigned char)target
  121.                 lun : (unsigned char)lun
  122.                forOwner : owner;
  123.  
  124. /*
  125.  * SCSI-3 versions of same.
  126.  */
  127. - (int)reserveSCSI3Target    : (unsigned long long)target
  128.                 lun : (unsigned long long)lun
  129.                forOwner : owner;
  130.  
  131. - (void)releaseSCSI3Target    : (unsigned long long)target
  132.                 lun : (unsigned long long)lun
  133.                forOwner : owner;
  134.  
  135.  
  136. /*
  137.  * Returns the number of SCSI targets supported.
  138.  * FIXME - should this return an unsigned long long?
  139.  */
  140. - (int)numberOfTargets;
  141.  
  142. /*
  143.  * Standard I/O methods.
  144.  *
  145.  * executeRequest requires buffers aligned to IO_SCSI_DMA_ALIGNMENT.
  146.  */
  147. - (sc_status_t) executeRequest     : (IOSCSIRequest *)scsiReq
  148.              buffer : (void *)buffer     /* data destination */
  149.               client : (vm_task_t)client;
  150.     
  151. /*
  152.  * SCSI-3 version, allows 64-bit target/lun and 16-byte CDB.
  153.  */
  154. - (sc_status_t) executeSCSI3Request : (IOSCSI3Request *)scsiReq
  155.                  buffer : (void *)buffer     /* data destination */
  156.                   client : (vm_task_t)client;
  157.  
  158. - (sc_status_t) resetSCSIBus;            /* reset the bus */
  159.  
  160. /*
  161.  * Convert an sc_status_t to an IOReturn.
  162.  */
  163. - (IOReturn)returnFromScStatus    : (sc_status_t)sc_status;
  164.  
  165. /*
  166.  * Determine maximum DMA which can be peformed in a single call to 
  167.  * executeRequest:buffer:client:.
  168.  */
  169. - (unsigned)maxTransfer;
  170.  
  171. /*
  172.  * Return required DMA alignment for current architecture.
  173.  */
  174. - (void)getDMAAlignment        : (IODMAAlignment *)alignment;
  175.  
  176. /*
  177.  * Allocate some well-aligned memory.
  178.  * Usage:
  179.  * 
  180.  * void *freePtr;
  181.  * void *alignedPtr;
  182.  * unsigned freeCnt;
  183.  * 
  184.  * alignedPtr = [controllerId allocateBufferOfLength:someLength
  185.  *            actualStart:&freePtr
  186.  *            actualLength:&freeCnt];
  187.  * ...
  188.  * when done...
  189.  *
  190.  * IOFree(freePtr, freeCnt);
  191.  */
  192.  
  193. - (void *)allocateBufferOfLength: (unsigned)length
  194.     actualStart : (void **)actualStart
  195.     actualLength : (unsigned *)actualLength;
  196.  
  197. @end
  198.  
  199. /*
  200.  * Public IONamedValue arrays.
  201.  */
  202. extern IONamedValue IOScStatusStrings[];
  203. extern IONamedValue IOSCSISenseStrings[];
  204. extern IONamedValue IOSCSIOpcodeStrings[];
  205.  
  206.