home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / driverkit / scsiTypes.h < prev    next >
Text File  |  1993-06-30  |  3KB  |  128 lines

  1. /*      Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved. 
  2.  *
  3.  * scsiTypes.h - Exported API of SCSIController class.
  4.  *
  5.  * HISTORY
  6.  * 11-Feb-91    Doug Mitchell at NeXT
  7.  *      Created. 
  8.  */
  9.  
  10. #import <objc/objc.h>
  11. #import <driverkit/driverTypes.h>
  12. #import <kernserv/clock_timer.h>
  13. #import <bsd/dev/scsireg.h>
  14.  
  15. /*
  16.  * Buffers aligned to IO_SCSI_DMA_ALIGNMENT (both start and end addresses) are
  17.  * guaranteed to be legal.
  18.  */
  19. #define IO_SCSI_DMA_ALIGNMENT      64
  20.  
  21. /*
  22.  * Argument to executeRequest:buffer:client method.
  23.  */
  24. typedef struct {
  25.  
  26.         /*** inputs ***/
  27.         
  28.         unsigned char        target;         /* SCSI target ID */
  29.         unsigned char        lun;            /* logical unit */
  30.         cdb_t            cdb;            /* command descriptor block - 
  31.                                                  * one of three formats */
  32.         BOOL            read;         /* expected DMA direction 
  33.                          * (YES if read) */
  34.         int            maxTransfer;    /* maximum number of bytes to
  35.                                                  * transfer */
  36.         int            timeoutLength;  /* I/O timeout in seconds */
  37.         unsigned        disconnect:1;   /* OK to disconnect */
  38.         unsigned        pad:31;
  39.                                                  
  40.         /*** outputs ***/
  41.         
  42.         sc_status_t        driverStatus;   /* driver status */
  43.         unsigned char        scsiStatus;     /* SCSI status byte */
  44.         int            bytesTransferred; /* actual number of bytes 
  45.                                                  * transferred by DMA */
  46.     ns_time_t        totalTime;    /* total execution time */
  47.     ns_time_t        latentTime;    /* disconnect time */
  48.     esense_reply_t         senseData;    /* extended sense if
  49.                          * driverStatus = SR_IOST_CHKSV
  50.                          */
  51.  
  52. } IOSCSIRequest;
  53.  
  54. /*
  55.  * Exported protocol for SCSIController object.
  56.  */
  57. @protocol IOSCSIControllerExported
  58.  
  59. /*
  60.  * Attempt to reserve specified target and lun for calling device. Returns
  61.  * non-zero if device already reserved.
  62.  */
  63. - (int)reserveTarget         : (unsigned char)target
  64.                 lun : (unsigned char)lun
  65.                forOwner : owner;
  66.  
  67. - (void)releaseTarget         : (unsigned char)target
  68.                 lun : (unsigned char)lun
  69.                forOwner : owner;
  70.  
  71. /*
  72.  * Standard I/O methods.
  73.  *
  74.  * executeRequest requires buffers aligned to IO_SCSI_DMA_ALIGNMENT.
  75.  */
  76. - (sc_status_t) executeRequest     : (IOSCSIRequest *)scsiReq
  77.              buffer : (void *)buffer     /* data destination */
  78.               client : (vm_task_t)client;
  79.                    
  80. - (sc_status_t) resetSCSIBus;            /* reset the bus */
  81.  
  82. /*
  83.  * Convert an sc_status_t to an IOReturn.
  84.  */
  85. - (IOReturn)returnFromScStatus    : (sc_status_t)sc_status;
  86.  
  87. /*
  88.  * Determine maximum DMA which can be peformed in a single call to 
  89.  * executeRequest:buffer:client:.
  90.  */
  91. - (unsigned)maxTransfer;
  92.  
  93. /*
  94.  * Return required DMA alignment for current architecture.
  95.  */
  96. - (void)getDMAAlignment        : (IODMAAlignment *)alignment;
  97.  
  98. /*
  99.  * Allocate some well-aligned memory.
  100.  * Usage:
  101.  * 
  102.  * void *freePtr;
  103.  * void *alignedPtr;
  104.  * unsigned freeCnt;
  105.  * 
  106.  * alignedPtr = [controllerId allocateBufferOfLength:someLength
  107.  *            actualStart:&freePtr
  108.  *            actualLength:&freeCnt];
  109.  * ...
  110.  * when done...
  111.  *
  112.  * IOFree(freePtr, freeCnt);
  113.  */
  114.  
  115. - (void *)allocateBufferOfLength: (unsigned)length
  116.     actualStart : (void **)actualStart
  117.     actualLength : (unsigned *)actualLength;
  118.  
  119. @end
  120.  
  121. /*
  122.  * Public IONamedValue arrays.
  123.  */
  124. extern IONamedValue IOScStatusStrings[];
  125. extern IONamedValue IOSCSISenseStrings[];
  126. extern IONamedValue IOSCSIOpcodeStrings[];
  127.  
  128.