Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Devices /
Chapter 4 - SCSI Manager 4.3


Summary of SCSI Manager 4.3

C Summary

Constants

enum {
   scsiVERSION = 43
};
/* SCSI Manager function codes */
enum {
   SCSINop                 = 0x00,  /* no operation */
   SCSIExecIO              = 0x01,  /* execute a SCSI IO transaction */
   SCSIBusInquiry          = 0x03,  /* bus inquiry */
   SCSIReleaseQ            = 0x04,  /* release a frozen SIM queue */
   SCSIAbortCommand        = 0x10,  /* abort a SCSI command */
   SCSIResetBus            = 0x11,  /* reset the SCSI bus */
   SCSIResetDevice         = 0x12,  /* reset a SCSI device */
   SCSITerminateIO         = 0x13,  /* terminate I/O transaction */
   SCSIGetVirtualIDInfo    = 0x80,  /* return DeviceIdent of virtual ID */
   SCSILoadDriver          = 0x82,  /* load a driver from a SCSI device */
   SCSIOldCall             = 0x84,  /* begin old-API emulation */
   SCSICreateRefNumXref    = 0x85,  /* register a device driver */
   SCSILookupRefNumXref    = 0x86,  /* find a driver reference number */
   SCSIRemoveRefNumXref    = 0x87,  /* deregister a device driver */
   SCSIRegisterWithNewXPT  = 0x88,  /* XPT replaced; SIM must reregister */
   vendorUnique            = 0xC0   /* 0xC0 through 0xFF */
};
/* allocation lengths for parameter block fields */
enum {
   handshakeDataLength     = 8,     /* handshake data length */
   maxCDBLength            = 16,    /* space for the CDB bytes/pointer */
   vendorIDLength          = 16     /* ASCII string length for vendor ID  */
};
/* types for the scsiTransferType field */
enum {
   scsiTransferBlind    = 0,        /* DMA if available, otherwise blind */
   scsiTransferPolled               /* polled */
}; 
/* types for the scsiDataType field */
enum {
   scsiDataBuffer       = 0,        /* single contiguous buffer supplied */
   scsiDataTIB          = 1,        /* TIB supplied (ptr in scsiDataPtr) */
   scsiDataSG           = 2         /* scatter/gather list supplied */
}; 
/* flags for the scsiResultFlags field */
enum {
   scsiSIMQFrozen       = 0x0001,   /* the SIM queue is frozen */
   scsiAutosenseValid   = 0x0002,   /* autosense data valid for target */
   scsiBusNotFree       = 0x0004    /* SCSI bus is not free */
};
/* bit numbers of the scsiFlags field */
enum {
   kbSCSIDisableAutosense  = 29,    /* disable autosense feature */
   kbSCSIFlagReservedA     = 28,
   kbSCSIFlagReserved0     = 27,
   kbSCSICDBLinked         = 26,    /* the PB contains a linked CDB */
   kbSCSIQEnable           = 25,    /* target queue actions are enabled */
   kbSCSICDBIsPointer      = 24,    /* the CDB field contains a pointer */
   kbSCSIFlagReserved1     = 23,
   kbSCSIInitiateSyncData  = 22,    /* attempt sync data transfer and SDTR */
   kbSCSIDisableSyncData   = 21,    /* disable sync, go to async */
   kbSCSISIMQHead          = 20,    /* place PB at the head of SIM queue */
   kbSCSISIMQFreeze        = 19,    /* freeze the SIM queue */
   kbSCSISIMQNoFreeze      = 18,    /* disable SIM queue freezing */
   kbSCSIDoDisconnect      = 17,    /* definitely do disconnect */
   kbSCSIDontDisconnect    = 16,    /* definitely don't disconnect */
   kbSCSIDataReadyForDMA   = 15,    /* data buffer(s) are ready for DMA */
   kbSCSIFlagReserved3     = 14,
   kbSCSIDataPhysical      = 13,    /* S/G buffer data ptrs are physical */
   kbSCSISensePhysical     = 12,    /* autosense buffer ptr is physical */
   kbSCSIFlagReserved5     = 11,
   kbSCSIFlagReserved6     = 10,
   kbSCSIFlagReserved7     = 9,
   kbSCSIFlagReserved8     = 8,
   kbSCSIDataBufferValid   = 7,     /* data buffer valid */
   kbSCSIStatusBufferValid = 6,     /* status buffer valid */
   kbSCSIMessageBufferValid= 5,     /* message buffer valid */
   kbSCSIFlagReserved9     = 4
};
/* bit masks for the scsiFlags field */
enum {
   scsiDirectionMask       = 0xC0000000, /* data direction mask */
   scsiDirectionNone       = 0xC0000000, /* data direction (11: no data) */
   scsiDirectionReserved   = 0x00000000, /* data direction (00: reserved) */
   scsiDirectionOut        = 0x80000000, /* data direction (10: DATA OUT) */
   scsiDirectionIn         = 0x40000000, /* data direction (01: DATA IN) */
   scsiDisableAutosense    = 0x20000000, /* disable auto sense feature */
   scsiFlagReservedA       = 0x10000000,
   scsiFlagReserved0       = 0x08000000,
   scsiCDBLinked           = 0x04000000, /* the PB contains a linked CDB */
   scsiQEnable             = 0x02000000, /* target queue actions enabled */
   scsiCDBIsPointer        = 0x01000000, /* the CDB field is a pointer */
   scsiFlagReserved1       = 0x00800000,
   scsiInitiateSyncData    = 0x00400000, /* attempt sync data xfer & SDTR */
   scsiDisableSyncData     = 0x00200000, /* disable sync, go to async */
   scsiSIMQHead            = 0x00100000, /* place PB at the head of queue */
   scsiSIMQFreeze          = 0x00080000, /* freeze the SIM queue */
   scsiSIMQNoFreeze        = 0x00040000, /* disallow SIM Q freezing */
   scsiDoDisconnect        = 0x00020000, /* definitely do disconnect */
   scsiDontDisconnect      = 0x00010000, /* definitely don't disconnect */
   scsiDataReadyForDMA     = 0x00008000, /* buffer(s) are ready for DMA */
   scsiFlagReserved3       = 0x00004000,
   scsiDataPhysical        = 0x00002000, /* S/G buffer ptrs are physical */
   scsiSensePhysical       = 0x00001000, /* autosense ptr is physical */
   scsiFlagReserved5       = 0x00000800,
   scsiFlagReserved6       = 0x00000400,
   scsiFlagReserved7       = 0x00000200,
   scsiFlagReserved8       = 0x00000100
};
/* bit masks for the scsiIOFlags field */
enum {
   scsiNoParityCheck       = 0x0002,   /* disable parity checking */
   scsiDisableSelectWAtn   = 0x0004,   /* disable select w/Atn */
   scsiSavePtrOnDisconnect = 0x0008,   /* SaveDataPointer on disconnect */
   scsiNoBucketIn          = 0x0010,   /* don't bit-bucket on input */
   scsiNoBucketOut         = 0x0020,   /* don't bit-bucket on output */
   scsiDisableWide         = 0x0040,   /* disable wide negotiation */
   scsiInitiateWide        = 0x0080,   /* initiate wide negotiation */
   scsiRenegotiateSense    = 0x0100,   /* renegotiate sync/wide */
   scsiIOFlagReserved0080  = 0x0080,
   scsiIOFlagReserved8000  = 0x8000
};
/* SIM queue actions. */
enum {
   scsiSimpleQTag          = 0x20,     /* tag for a simple queue */
   scsiHeadQTag            = 0x21,     /* tag for head of queue  */
   scsiOrderedQTag         = 0x22      /* tag for ordered queue */
};
/* scsiHBAInquiry field bits */
enum {
   scsiBusMDP        = 0x80,     /* supports Modify Data Pointer message */
   scsiBusWide32     = 0x40,     /* supports 32-bit wide SCSI */
   scsiBusWide16     = 0x20,     /* supports 16-bit wide SCSI */
   scsiBusSDTR       = 0x10,     /* supports SDTR message */
   scsiBusLinkedCDB  = 0x08,     /* supports linked CDBs */
   scsiBusTagQ       = 0x02,     /* supports tag queue message */
   scsiBusSoftReset  = 0x01      /* supports soft reset */
};
/* scsiDataTypes field bits  */
/* bits 0-15 Apple-defined, 16-30 vendor unique, 31 = reserved */
enum {
   scsiBusDataBuffer       = (1<<scsiDataBuffer),  /* single buffer */
   scsiBusDataTIB          = (1<<scsiDataTIB), /* TIB (ptr in scsiDataPtr) */
   scsiBusDataSG           = (1<<scsiDataSG),      /* scatter/gather list */
   scsiBusDataReserved     = 0x80000000
};
/* scsiScanFlags field bits */
enum {
   scsiBusScansDevices     = 0x80, /* bus scans and maintains device list */
   scsiBusScansOnInit      = 0x40, /* bus scans at startup */
   scsiBusLoadsROMDrivers  = 0x20/* may load ROM drivers for targets */
};
/* scsiFeatureFlags field bits */
enum {
   scsiBusInternalExternalMask   = 0x000000C0, /* internal/external mask*/
   scsiBusInternalExternalUnknown = 0x00000000, /* unknown if in or out */
   scsiBusInternalExternal       = 0x000000C0, /* both inside and outside */
   scsiBusInternal               = 0x00000080, /* bus goes inside the box */
   scsiBusExternal               = 0x00000040, /* bus goes outside the box */
   scsiBusCacheCoherentDMA       = 0x00000020, /* DMA is cache coherent */
   scsiBusOldCallCapable         = 0x00000010, /* SIM supports old API */
   scsiBusDifferential           = 0x00000004, /* uses differential bus */
   scsiBusFastSCSI               = 0x00000002, /* HBA supports fast SCSI */
   scsiBusDMAavailable           = 0x00000001/* DMA is available */
};
/* scsiWeirdStuff field bits */
enum {
   /* disconnects on odd byte boundries are unsafe with DMA or blind reads */
   scsiOddDisconnectUnsafeRead1  = 0x0001,
   /* disconnects on odd byte boundries unsafe with DMA or blind writes */
   scsiOddDisconnectUnsafeWrite1 = 0x0002,
   /* non-handshaked delays or disconnects on blind transfer may hang */
   scsiBusErrorsUnsafe           = 0x0004,
   /* non-handshaked delays or disconnects on blind transfer may corrupt */
   scsiRequiresHandshake         = 0x0008,
   /* targets that initiate synchronous negotiations are supported */
   scsiTargetDrivenSDTRSafe      = 0x0010
};
/* scsiHBAslotType values */
enum {
   scsiMotherboardBus            = 0x01,  /* a built-in Apple bus */
   scsiNuBus                     = 0x02,  /* a SIM on a NuBus card */
   scsiPDSBus                    = 0x03   /* a SIM on a PDS card  */
};
/* flags for the scsiDriverFlags field */
enum {
   scsiDeviceSensitive = 0x0001, /* only driver should access this device */
   scsiDeviceNoOldCallAccess = 0x0002 /* device does not support old API */
};
/* SCSI Phases (used by SIMs that support the original SCSI Manager) */
enum {
   kDataOutPhase,       /* encoded MSG, C/D, I/O bits */
   kDataInPhase,
   kCommandPhase,
   kStatusPhase,
   kPhaseIllegal0,
   kPhaseIllegal1,
   kMessageOutPhase,
   kMessageInPhase,
   kBusFreePhase,       /* additional phases */
   kArbitratePhase,
   kSelectPhase
};

Data Types

/* SCSI callback function prototypes */  
typedef pascal void (*CallbackProc) (void * scsiPB);
typedef void   (*AENCallbackProc) (void);
typedef OSErr  (*SIMInitProc) (Ptr SIMinfoPtr);
typedef void   (*SIMActionProc) (void * scsiPB, Ptr SIMGlobals);
typedef void   (*SCSIProc) (void );
typedef void   (*MakeCallbackProc) (void * scsiPB);
typedef SInt32 (*InterruptPollProc) (Ptr SIMGlobals);
struct DeviceIdent 
{
   UInt8 diReserved;                /* reserved */
   UInt8 bus;                       /* SCSI - bus number */
   UInt8 targetID;                  /* SCSI - target SCSI ID */
   UInt8 LUN;                       /* SCSI - logical unit number */
};
typedef struct DeviceIdent DeviceIdent;
union CDB
{
   UInt8 *cdbPtr;                   /* pointer to the CDB, or */
   UInt8 cdbBytes[maxCDBLength];    /* the actual CDB to send */
};
typedef union CDB CDB, *CDBPtr;
struct SGRecord
{
   Ptr      SGAddr;              /* scatter/gather buffer address */
   UInt32   SGCount;             /* buffer size */
};
typedef struct SGRecord SGRecord;
#define SCSIPBHdr \
   struct SCSIHdr *qLink;        /*internal use, must be nil */      \
   SInt16   scsiReserved1;       /* -> reserved for input */             \
   UInt16   scsiPBLength;        /* -> length of the entire PB  */       \
   UInt8    scsiFunctionCode;    /* -> function selector */              \
   UInt8    scsiReserved2;       /* <- reserved for output*/             \
   OSErr    scsiResult;          /* <- returned result */                \
   DeviceIdentscsiDevice;     /* -> device ID (bus+target+LUN) */     \
   CallbackProcscsiCompletion; /* -> completion routine pointer */                    \
   UInt32   scsiFlags;           /* -> assorted flags */                 \
   UInt8    *scsiDriverStorage;  /* <> pointer for driver private use */ \
   Ptr      scsiXPTprivate;      /*private field for XPT */          \
   SInt32   scsiReserved3;       /*reserved */

struct SCSI_PB
{
   SCSIPBHdr
};
typedef struct SCSI_PB SCSI_PB;
#define SCSI_IO_Macro \
   SCSIPBHdr                     /*header information fields */     \
   UInt16   scsiResultFlags;     /* <- flags that modify scsiResult */  \
   UInt16   scsiReserved12;      /* -> reserved */                      \
   UInt8    *scsiDataPtr;        /* -> data pointer */                  \
   UInt32   scsiDataLength;      /* -> data transfer length */          \
   UInt8    *scsiSensePtr;       /* -> autosense data buffer pointer */ \
   UInt8    scsiSenseLength;     /* -> size of the autosense buffer */     \
   UInt8    scsiCDBLength;       /* -> number of bytes for the CDB */   \
   UInt16   scsiSGListCount;     /* -> number of S/G list entries */    \
   UInt32   scsiReserved4;       /* <- reserved for output */           \
   UInt8    scsiSCSIstatus;      /* <- returned SCSI device status */   \
   SInt8    scsiSenseResidual;   /* <- autosense residual length */     \
   UInt16   scsiReserved5;       /* <- reserved for output */           \
   SInt32   scsiDataResidual;    /* <- data residual length */          \
   CDB      scsiCDB;             /* -> actual CDB or pointer to CDB */  \
   SInt32   scsiTimeout;         /* -> timeout value */                 \
   UInt8    *scsiReserved13;     /* -> reserved */                      \
   UInt16   scsiReserved14;      /* -> reserved */                         \
   UInt16   scsiIOFlags;         /* -> additional I/O flags */          \
   UInt8    scsiTagAction;       /* -> what to do for tag queuing */    \
   UInt8    scsiReserved6;       /* -> reserved for input */            \
   UInt16   scsiReserved7;       /* -> reserved for input */            \
   UInt16   scsiSelectTimeout;   /* -> select timeout value */          \
   UInt8    scsiDataType;        /* -> data description type */         \
   UInt8    scsiTransferType;    /* -> transfer type (blind/polled) */  \
   UInt32   scsiReserved8;       /* -> reserved for input */            \
   UInt32   scsiReserved9;       /* -> reserved for input */            \
   UInt16   scsiHandshake[handshakeDataLength]; /* -> handshake info */ \
   UInt32   scsiReserved10;      /* -> reserved for input */            \
   UInt32   scsiReserved11;      /* -> reserved for input */            \
   struct   SCSI_IO *scsiCommandLink; /* -> linked command pointer */   \
   UInt8    scsiSIMpublics[8];   /* -> reserved for SIM input */        \
   UInt8    scsiAppleReserved6[8];/* -> reserved for input */       \
   /* XPT private fields for original SCSI Manager emulation */         \
   UInt16   scsiCurrentPhase;    /* <- bus phase after old call */         \
   SInt16   scsiSelector;        /* -> selector for old call */            \
   OSErr    scsiOldCallResult;   /* <- result of old call */            \
   UInt8    scsiSCSImessage;     /* <- SCSIComplete message byte */     \
   UInt8    XPTprivateFlags;     /* <> XPT private flags */             \
   UInt8    XPTextras[12];       /*reserved */

struct SCSI_IO
{
   SCSI_IO_Macro
};
typedef struct SCSI_IO SCSI_IO;
typedef SCSI_IO SCSIExecIOPB;
struct SCSIBusInquiryPB
{
   SCSIPBHdr                        /* header information fields */
   UInt16   scsiEngineCount;        /* <- number of engines on HBA */
   UInt16   scsiMaxTransferType;    /* <- number of xfer types supported */
   UInt32   scsiDataTypes;          /* <- data types supported by this SIM */
   UInt16   scsiIOpbSize;           /* <- size of SCSI_IO PB for this SIM */
   UInt16   scsiMaxIOpbSize;        /* <- largest SCSI_IO PB for all SIMs */
   UInt32   scsiFeatureFlags;       /* <- supported features flags field */
   UInt8    scsiVersionNumber;      /* <- version number for the SIM/HBA */
   UInt8    scsiHBAInquiry;         /* <- mimic of INQ byte 7 for the HBA */
   UInt8    scsiTargetModeFlags;    /* <- flags for target mode support */
   UInt8    scsiScanFlags;          /* <- scan related feature flags */
   UInt32   scsiSIMPrivatesPtr;     /* <- pointer to SIM private data */
   UInt32   scsiSIMPrivatesSize;    /* <- size of SIM private data */
   UInt32   scsiAsyncFlags;         /* <- reserved for input */
   UInt8    scsiHiBusID;            /* <- highest path ID in the subsystem */
   UInt8    scsiInitiatorID;        /* <- ID of the HBA on the SCSI bus */
   UInt16   scsiBIReserved0;        /* reserved */
   UInt32   scsiBIReserved1;        /* reserved */
   UInt32   scsiFlagsSupported;     /* <- which scsiFlags are supported */
   UInt16   scsiIOFlagsSupported;   /* <- which scsiIOFlags are supported */
   UInt16   scsiWeirdStuff;         /* <- flags for strange behavior */
   UInt16   scsiMaxTarget;          /* <- maximum target ID supported */
   UInt16   scsiMaxLUN;             /* <- maximum LUN supported */
   SInt8 scsiSIMVendor[vendorIDLength]; /* <- vendor ID of the SIM */
   SInt8 scsiHBAVendor[vendorIDLength]; /* <- vendor ID of the HBA */
   SInt8 scsiControllerFamily[vendorIDLength]; /* <- controller family */
   SInt8 scsiControllerType[vendorIDLength]; /* <- controller model */
   SInt8 scsiXPTversion[4];         /* <- version number of XPT */
   SInt8 scsiSIMversion[4];         /* <- version number of SIM */
   SInt8 scsiHBAversion[4];         /* <- version number of HBA */
   UInt8    scsiHBAslotType;        /* <- type of slot this HBA is in */
   UInt8    scsiHBAslotNumber;      /* <- slot number of this HBA */
   UInt16   scsiSIMsRsrcID;         /* <- sResource ID of this SIM */
   UInt16   scsiBIReserved3;        /* <- reserved for input */
   UInt16   scsiAdditionalLength;   /* <- additional length of PB */
};
typedef struct SCSIBusInquiryPB SCSIBusInquiryPB;
struct SCSIAbortCommandPB
{
   SCSIPBHdr               /* header information fields */
   SCSI_IO  *scsiIOptr;    /* -> pointer to the PB to abort */
};
typedef struct SCSIAbortCommandPB SCSIAbortCommandPB;
struct SCSITerminateIOPB
{
   SCSIPBHdr               /* header information fields */
   SCSI_IO  *scsiIOptr;    /* -> pointer to the PB to terminate */
};
typedef struct SCSITerminateIOPB SCSITerminateIOPB;
struct SCSIGetVirtualIDInfoPB
{
   SCSIPBHdr               /* header information fields */
   UInt16   scsiOldCallID; /* -> SCSI ID of device in question */
   Boolean  scsiExists;    /* <- true if device exists */
};
typedef struct SCSIGetVirtualIDInfoPB SCSIGetVirtualIDInfoPB;
struct SCSIDriverPB
{
   SCSIPBHdr                     /* header information fields */
   SInt16      scsiDriver;       /* -> driver refNum, for CreateRefNumXref */
                                 /* <- for LookupRefNumXref */
   UInt16      scsiDriverFlags;  /* <> details of driver/device */
   DeviceIdent scsiNextDevice;   /* <- DeviceIdent of the next driver */
};
typedef struct SCSIDriverPB SCSIDriverPB;
struct SCSILoadDriverPB
{
   SCSIPBHdr                     /* header information fields */
   SInt16   scsiLoadedRefNum;    /* <- SIM returns driver reference number */
   Boolean  scsiDiskLoadFailed;  /* -> if true, previous call failed */
};
typedef struct SCSILoadDriverPB SCSILoadDriverPB;
struct SIMInitInfo 
{
   UInt8          *SIMstaticPtr;  /* <- pointer to the SIM's static data */
   SInt32         staticSize;     /* -> size requested for SIM static data */
   SIMInitProc    SIMInit;        /* -> pointer to the SIMInit function */
   SIMActionProc  SIMAction;      /* -> pointer to the SIMAction function */
   SCSIProc       SIM_ISR;        /*  reserved */
   InterruptPollProc SIMInterruptPoll; /* -> pointer to SIMInterruptPoll */
   SIMActionProc  NewOldCall;     /* -> pointer to NewOldCall function */
   UInt16         ioPBSize;       /* -> size of SCSI_IO PB for this SIM */
   Boolean        oldCallCapable; /* -> true if SIM handles old-API calls */
   UInt8          simInfoUnused1; /*   reserved */
   SInt32         simInternalUse; /* not affected or viewed by XPT */
   SCSIProc       XPT_ISR;        /*    reserved */
   SCSIProc       EnteringSIM;    /* <- pointer to EnteringSIM function */
   SCSIProc       ExitingSIM;     /* <- pointer to ExitingSIM function */
   MakeCallbackProc MakeCallback; /* <- pointer to MakeCallback function */
   UInt16         busID;          /* <- bus number for the registered bus */
   UInt16         simInfoUnused3; /* <- reserved */
   SInt32         simInfoUnused4; /* <- reserved */
};
typedef struct SIMInitInfo SIMInitInfo; 

Functions

OSErr SCSIAction        (SCSI_PB *scsiPB);
OSErr SCSIRegisterBus   (SIMInitInfo *SIMinfoPtr);
OSErr SCSIDeregisterBus (SCSI_PB *scsiPB);
OSErr SCSIReregisterBus (SIMInitInfo *SIMinfoPtr);
OSErr SCSIKillXPT       (void *);

Pascal Summary

Constants

CONST
   scsiVERSION    = 43;
   {SCSI Manager function codes}
   SCSINop                    = $00;   {no operation}
   SCSIExecIO                 = $01;   {execute a SCSI IO transaction}
   SCSIBusInquiry             = $03;   {bus inquiry}
   SCSIReleaseQ               = $04;   {release a frozen SIM queue}
   SCSIAbortCommand           = $10;   {abort a SCSI command}
   SCSIResetBus               = $11;   {reset the SCSI bus}
   SCSIResetDevice            = $12;   {reset a SCSI device}
   SCSITerminateIO            = $13;   {terminate I/O transaction}
   SCSIGetVirtualIDInfo       = $80;   {return DeviceIdent of virtual ID}
   SCSILoadDriver             = $82;   {load a driver from a SCSI device}
   SCSIOldCall                = $84;   {begin old-API emulation}
   SCSICreateRefNumXref       = $85;   {register a device driver}
   SCSILookupRefNumXref       = $86;   {find a driver reference number}
   SCSIRemoveRefNumXref       = $87;   {deregister a device driver}
   SCSIRegisterWithNewXPT     = $88;   {XPT replaced; SIM must reregister}
   vendorUnique               = $C0;   {$C0 through $FF}
   {allocation lengths for parameter block fields}
   handshakeDataLength        = 8;     {handshake data length}
   maxCDBLength               = 16;    {space for the CDB bytes/pointer}
   vendorIDLength             = 16;    {ASCII string length for Vendor ID}
   {types for the scsiTransferType field}
   scsiTransferBlind          = 0;     {DMA if available, otherwise blind}
   scsiTransferPolled         = 1;     {polled}
   {types for the scsiDataType field}
   scsiDataBuffer             = 0;     {single contiguous buffer supplied}
   scsiDataTIB                = 1;     {TIB supplied (ptr in scsiDataPtr)}
   scsiDataSG                 = 2;     {scatter/gather list supplied}
   {flags for the scsiResultFlags field}
   scsiSIMQFrozen             = $0001; {the SIM queue is frozen}
   scsiAutosenseValid         = $0002; {autosense data valid for target}
   scsiBusNotFree             = $0004; {SCSI bus is not free}
   {bit numbers in the scsiFlags field}
   kbSCSIDisableAutosense     = 29;    {disable auto sense feature}
   kbSCSIFlagReservedA        = 28;
   kbSCSIFlagReserved0        = 27;
   kbSCSICDBLinked            = 26;    {the PB contains a linked CDB}
   kbSCSIQEnable              = 25;    {target queue actions are enabled}
   kbSCSICDBIsPointer         = 24;    {the CDB field contains a pointer}
   kbSCSIFlagReserved1        = 23;
   kbSCSIInitiateSyncData     = 22;    {attempt sync data transfer and SDTR}
   kbSCSIDisableSyncData      = 21;    {disable sync, go to async}
   kbSCSISIMQHead             = 20;    {place PB at the head of SIM queue}
   kbSCSISIMQFreeze           = 19;    {freeze the SIM queue}
   kbSCSISIMQNoFreeze         = 18;    {disable SIM queue freezing}
   kbSCSIDoDisconnect         = 17;    {definitely do disconnect}
   kbSCSIDontDisconnect       = 16;    {definitely don't disconnect}
   kbSCSIDataReadyForDMA      = 15;    {data buffer(s) are ready for DMA}
   kbSCSIFlagReserved3        = 14;
   kbSCSIDataPhysical         = 13;    {S/G buffer data ptrs are physical}
   kbSCSISensePhysical        = 12;    {autosense buffer ptr is physical}
   kbSCSIFlagReserved5        = 11;
   kbSCSIFlagReserved6        = 10;
   kbSCSIFlagReserved7        = 9;
   kbSCSIFlagReserved8        = 8;
   kbSCSIDataBufferValid      = 7;     {data buffer valid}
   kbSCSIStatusBufferValid    = 6;     {status buffer valid}
   kbSCSIMessageBufferValid   = 5;     {message buffer valid}
   kbSCSIFlagReserved9        = 4;
   {bit masks for the scsiFlags field}
   scsiDirectionMask          = $C0000000;   {data direction mask}
   scsiDirectionNone          = $C0000000;   {data direction (11: no data)}
   scsiDirectionReserved      = $00000000;   {data direction (00: reserved)}
   scsiDirectionOut           = $80000000;   {data direction (10: DATA OUT)}
   scsiDirectionIn            = $40000000;   {data direction (01: DATA IN)}
   scsiDisableAutosense       = $20000000;   {disable auto sense feature}
   scsiFlagReservedA          = $10000000;
   scsiFlagReserved0          = $08000000;
   scsiCDBLinked              = $04000000;   {the PB contains a linked CDB}
   scsiQEnable                = $02000000;   {target queue actions enabled}
   scsiCDBIsPointer           = $01000000;   {the CDB field is a pointer}
   scsiFlagReserved1          = $00800000;
   scsiInitiateSyncData       = $00400000;   {attempt sync data xfer & SDTR}
   scsiDisableSyncData        = $00200000;   {disable sync; go to async}
   scsiSIMQHead               = $00100000;   {place PB at the head of queue}
   scsiSIMQFreeze             = $00080000;   {freeze the SIM queue}
   scsiSIMQNoFreeze           = $00040000;   {disallow SIM Q freezing}
   scsiDoDisconnect           = $00020000;   {definitely do disconnect}
   scsiDontDisconnect         = $00010000;   {definitely don't disconnect}
   scsiDataReadyForDMA        = $00008000;   {buffer(s) are ready for DMA}
   scsiFlagReserved3          = $00004000;
   scsiDataPhysical           = $00002000;   {S/G buffer ptrs are physical}
   scsiSensePhysical          = $00001000;   {autosense ptr is physical}
   scsiFlagReserved5          = $00000800;
   scsiFlagReserved6          = $00000400;
   scsiFlagReserved7          = $00000200;
   scsiFlagReserved8          = $00000100;
   {bit masks for the scsiIOFlags field}
   scsiNoParityCheck          = $0002;       {disable parity checking}
   scsiDisableSelectWAtn      = $0004;       {disable select w/Atn}
   scsiSavePtrOnDisconnect    = $0008;       {SaveDataPointer on disconnect}
   scsiNoBucketIn             = $0010;       {don't bit-bucket on input}
   scsiNoBucketOut            = $0020;       {don't bit-bucket on output}
   scsiDisableWide            = $0040;       {disable wide negotiation}
   scsiInitiateWide           = $0080;       {initiate wide negotiation}
   scsiRenegotiateSense       = $0100;       {renegotiate sync/wide}
   scsiIOFlagReserved0080     = $0080;
   scsiIOFlagReserved8000     = $8000;
   {SIM queue actions}
   scsiSimpleQTag             = $20;   {tag for a simple queue}
   scsiHeadQTag               = $21;   {tag for head of queue}
   scsiOrderedQTag            = $22;   {tag for ordered queue}
   {scsiHBAInquiry field bits}
   scsiBusMDP                 = $80;   {supports Modify Data Pointer message}
   scsiBusWide32              = $40;   {supports 32-bit wide SCSI}
   scsiBusWide16              = $20;   {supports 16-bit wide SCSI}
   scsiBusSDTR                = $10;   {supports SDTR message}
   scsiBusLinkedCDB           = $08;   {supports linked CDBs}
   scsiBusTagQ                = $02;   {supports tag queue message}
   scsiBusSoftReset           = $01;   {supports soft reset}
   {scsiDataTypes field bits}
   {bits 0-15 Apple-defined, 16-30 vendor unique, 31 = reserved}
   scsiBusDataBuffer          = $00000001; {single buffer}
   scsiBusDataTIB             = $00000002; {TIB (pointer in scsiDataPtr)}
   scsiBusDataSG              = $00000004; {scatter/gather list}
   scsiBusDataReserved        = $80000000;
   {scsiScanFlags field bits}
   scsiBusScansDevices        = $80;   {bus scans and maintains device list}
   scsiBusScansOnInit         = $40;   {bus scans at startup}
   scsiBusLoadsROMDrivers     = $20;   {may load ROM drivers for targets}
   {scsiFeatureFlags field bits}
   scsiBusInternalExternalMask      = $000000C0; {internal/external mask}
   scsiBusInternalExternalUnknown   = $00000000; {unknown if in or out}
   scsiBusInternalExternal          = $000000C0; {both inside and outside}
   scsiBusInternal                  = $00000080; {bus goes inside the box}
   scsiBusExternal                  = $00000040; {bus goes outside the box}
   scsiBusCacheCoherentDMA          = $00000020; {DMA is cache coherent}
   scsiBusOldCallCapable            = $00000010; {SIM supports old-API}
   scsiBusDifferential              = $00000004; {uses differential bus}
   scsiBusFastSCSI                  = $00000002; {HBA supports fast SCSI}
   scsiBusDMAavailable              = $00000001; {DMA is available}
   {scsiWeirdStuff field bits}
   scsiOddDisconnectUnsafeRead1     = $0001; {odd byte disconnects unsafe}
   scsiOddDisconnectUnsafeWrite1    = $0002; {odd byte disconnects unsafe}
   scsiBusErrorsUnsafe              = $0004; {delays or disconnects may hang}
   scsiRequiresHandshake            = $0008; {delays/disconnects may corrupt}
   scsiTargetDrivenSDTRSafe         = $0010; {target-driven STDR supported}
   {scsiHBAslotType values}
   scsiMotherboardBus         = $01;   {a built-in Apple bus}
   scsiNuBus                  = $02;   {a SIM on a NuBus card}
   scsiPDSBus                 = $03;   {a SIM on a PDS card}
   {flags for the scsiDriverFlags field}
   scsiDeviceSensitive        = $0001; {only driver should access the device}
   scsiDeviceNoOldCallAccess  = $0002; {device does not support old API}
   {SCSI Phases (used by SIMs that support the original SCSI Manager)}
   kDataOutPhase              = $00;   {encoded MSG, C/D, I/O bits}
   kDataInPhase               = $01;
   kCommandPhase              = $02;
   kStatusPhase               = $03;
   kPhaseIllegal0             = $04;
   kPhaseIllegal1             = $05;
   kMessageOutPhase           = $06;
   kMessageInPhase            = $07;
   kBusFreePhase              = $08;   {additional phases}
   kArbitratePhase            = $09;
   kSelectPhase               = $0A;

Data Types

TYPE
   {SCSI callback function prototypes}
   CallbackProc               = ProcPtr;
   AENCallbackProc            = ProcPtr;
   SIMInitProc                = ProcPtr;
   SIMActionProc              = ProcPtr;
   SCSIProc                   = ProcPtr;
   MakeCallbackProc           = ProcPtr;
   InterruptPollProc          = ProcPtr;
TYPE
   DI =
   PACKED RECORD
      diReserved:             Byte;    {reserved}
      bus:                    Byte;    {SCSI - bus number}
      targetID:               Byte;    {SCSI - target SCSI ID}
      LUN:                    Byte;    {SCSI - logical unit number}
   END;
   DeviceIdent = DI;
   CDBRec = 
   PACKED RECORD
   CASE Integer OF
      0: cdbPtr:           ^Byte;               {pointer to the CDB, or}
      1: cdbBytes:         ARRAY [0..15] OF Byte; {the actual CDB to send}
   END;
   CDB = CDBRec;
   CDBPtr = ^CDBRec;
   SGR = 
   PACKED RECORD
      SGAddr:              Ptr;           {scatter/gather buffer address}
      SGCount:             LongInt;       {buffer size}
   END;
   SGRecord = SGR;
   SCSIHdr = 
   PACKED RECORD
      qLink:               ^SCSIHdr;      {internal use, must be NIL}
      scsiReserved1:       Integer;       {-> reserved for input}
      scsiPBLength:        Integer;       {-> length of the entire PB}
      scsiFunctionCode:    Byte;          {-> function selector}
      scsiReserved2:       Byte;          {<- reserved for output}
      scsiResult:          OSErr;         {<- returned result}
      scsiDevice:          DeviceIdent;   {-> device ID (bus+target+LUN)}
      scsiCompletion:      CallbackProc;  {-> completion routine pointer}
      scsiFlags:           LongInt;       {-> assorted flags}
      scsiDriverStorage:   ^Byte;         {<> pointer for driver private use}
      scsiXPTprivate:      Ptr;           {private field for XPT}
      scsiReserved3:       LongInt;       {reserved}
   END;
   SCSI_PB = SCSIHdr;
   SCSI_IO = 
   PACKED RECORD
      qLink:               ^SCSIHdr;      {internal use, must be NIL}
      scsiReserved1:       Integer;       {-> reserved for input}
      scsiPBLength:        Integer;       {-> length of the entire PB}
      scsiFunctionCode:    Byte;          {-> function selector}
      scsiReserved2:       Byte;          {<- reserved for output}
      scsiResult:          OSErr;         {<- returned result}
      scsiDevice:          DeviceIdent;   {-> device ID (bus+target+LUN)}
      scsiCompletion:      CallbackProc;  {-> completion routine pointer}
      scsiFlags:           LongInt;       {-> assorted flags}
      scsiDriverStorage:   ^Byte;         {<> pointer for driver private use}
      scsiXPTprivate:      Ptr;           {private field for XPT}
      scsiReserved3:       LongInt;       {reserved}
      scsiResultFlags:     Integer;       {<- flags that modify scsiResult}
      scsiReserved12:      Integer;       {-> reserved}
      scsiDataPtr:         ^Byte;         {-> data pointer}
      scsiDataLength:      LongInt;       {-> data transfer length}
      scsiSensePtr:        ^Byte;         {-> autosense data buffer pointer}
      scsiSenseLength:     Byte;          {-> size of the autosense buffer}
      scsiCDBLength:       Byte;          {-> number of bytes for the CDB}
      scsiSGListCount:     Integer;       {-> number of S/G list entries}
      scsiReserved4:       LongInt;       {<- reserved for output}
      scsiSCSIstatus:      Byte;          {<- returned SCSI device status}
      scsiSenseResidual:   Char;          {<- autosense residual length}
      scsiReserved5:       Integer;       {<- reserved for output}
      scsiDataResidual:    LongInt;       {<- data residual length}
      scsiCDB:             CDB;           {-> actual CDB or pointer to CDB}
      scsiTimeout:         LongInt;       {-> timeout value}
      scsiReserved13:      ^Byte;         {-> reserved}
      scsiReserved14:      Integer;       {-> reserved}
      scsiIOFlags:         Integer;       {-> additional I/O flags}
      scsiTagAction:       Byte;          {-> what to do for tag queuing}
      scsiReserved6:       Byte;          {-> reserved for input}
      scsiReserved7:       Integer;       {-> reserved for input}
      scsiSelectTimeout:   Integer;       {-> select timeout value}
      scsiDataType:        Byte;          {-> data description type}
      scsiTransferType:    Byte;          {-> transfer type (blind/polled)}
      scsiReserved8:       LongInt;       {-> reserved for input}
      scsiReserved9:       LongInt;       {-> reserved for input}
      scsiHandshake:       ARRAY [0..7] OF Integer; {-> handshake info}
      scsiReserved10:      LongInt;       {-> reserved for input}
      scsiReserved11:      LongInt;       {-> reserved for input}
      scsiCommandLink:     ^SCSI_IO;      {-> linked command pointer}
      scsiSIMpublics:      ARRAY [0..7] OF Byte; {-> reserved for SIM input}
      scsiAppleReserved6:  ARRAY [0..7] OF Byte; {-> reserved for input}
      scsiCurrentPhase:    Integer;       {<- bus phase after old call}
      scsiSelector:        Integer;       {-> selector for old call}
      scsiOldCallResult:   OSErr;         {<- result of old call}
      scsiSCSImessage:     Byte;          {<- SCSIComplete message byte}
      XPTprivateFlags:     Byte;          {<> XPT private flags}
      XPTextras:           ARRAY [0..11] OF Byte; {reserved}
   END;
   SCSIExecIOPB = SCSI_IO;
   SCSIBusInquiryPB = 
   PACKED RECORD
      qLink:                ^SCSIHdr;     {internal use, must be NIL}
      scsiReserved1:        Integer;      {-> reserved for input}
      scsiPBLength:         Integer;      {-> length of the entire PB}
      scsiFunctionCode:     Byte;         {-> function selector}
      scsiReserved2:        Byte;         {<- reserved for output}
      scsiResult:           OSErr;        {<- returned result}
      scsiDevice:           DeviceIdent;  {-> device ID (bus+target+LUN)}
      scsiCompletion:       CallbackProc; {-> completion routine pointer}
      scsiFlags:            LongInt;      {-> assorted flags}
      scsiDriverStorage:    ^Byte;        {<> pointer for driver private use}
      scsiXPTprivate:       Ptr;          {private field for XPT}
      scsiReserved3:        LongInt;      {reserved}
      scsiEngineCount:      Integer;      {<- number of engines on HBA}
      scsiMaxTransferType:  Integer;      {<- number of xfer types supported}
      scsiDataTypes:        LongInt;      {<- data types supported by SIM}
      scsiIOpbSize:         Integer;      {<- size of SCSI_IO PB for SIM}
      scsiMaxIOpbSize:      Integer;      {<- largest SCSI_IO PB registered}
      scsiFeatureFlags:     LongInt;      {<- supported features flags field}
      scsiVersionNumber:    Byte;         {<- version number for the SIM/HBA}
      scsiHBAInquiry:       Byte;         {<- mimic of INQ byte 7 for HBA}
      scsiTargetModeFlags:  Byte;         {<- flags for target mode support}
      scsiScanFlags:        Byte;         {<- scan related feature flags}
      scsiSIMPrivatesPtr:   LongInt;      {<- pointer to SIM private data}
      scsiSIMPrivatesSize:  LongInt;      {<- size of SIM private data}
      scsiAsyncFlags:       LongInt;      {<- reserved for input}
      scsiHiBusID:          Byte;         {<- highest bus ID registered}
      scsiInitiatorID:      Byte;         {<- ID of the HBA on the SCSI bus}
      scsiBIReserved0:      Integer;      {reserved}
      scsiBIReserved1:      LongInt;      {reserved}
      scsiFlagsSupported:   LongInt;      {<- which scsiFlags are supported}
      scsiIOFlagsSupported: Integer;      {<- which scsiIOFlags supported}
      scsiWeirdStuff:       Integer;      {<- flags for strange behavior}
      scsiMaxTarget:        Integer;      {<- maximum target ID supported}
      scsiMaxLUN:           Integer;      {<- maximum LUN supported}
      scsiSIMVendor:        ARRAY [0..15] OF Char; {<- vendor ID of the SIM}
      scsiHBAVendor:        ARRAY [0..15] OF Char; {<- vendor ID of the HBA}
      scsiControllerFamily: ARRAY [0..15] OF Char; {<- controller family}
      scsiControllerType:   ARRAY [0..15] OF Char; {<- controller model}
      scsiXPTversion:       ARRAY [0..3] OF Char; {<- version number of XPT}
      scsiSIMversion:       ARRAY [0..3] OF Char; {<- version number of SIM}
      scsiHBAversion:       ARRAY [0..3] OF Char; {<- version number of HBA}
      scsiHBAslotType:      Byte;         {<- type of slot this HBA is in}
      scsiHBAslotNumber:    Byte;         {<- slot number of this HBA}
      scsiSIMsRsrcID:       Integer;      {<- sResource ID of this SIM}
      scsiBIReserved3:      Integer;      {<- reserved for input}
      scsiAdditionalLength: Integer;      {<- additional length of PB}
   END;
   SCSIAbortCommandPB = 
   PACKED RECORD
      qLink:               ^SCSIHdr;      {internal use, must be NIL}
      scsiReserved1:       Integer;       {-> reserved for input}
      scsiPBLength:        Integer;       {-> length of the entire PB}
      scsiFunctionCode:    Byte;          {-> function selector}
      scsiReserved2:       Byte;          {<- reserved for output}
      scsiResult:          OSErr;         {<- returned result}
      scsiDevice:          DeviceIdent;   {-> device ID (bus+target+LUN)}
      scsiCompletion:      CallbackProc;  {-> completion routine pointer}
      scsiFlags:           LongInt;       {-> assorted flags}
      scsiDriverStorage:   ^Byte;         {<> pointer for driver private use}
      scsiXPTprivate:      Ptr;           {private field for XPT}
      scsiReserved3:       LongInt;       {reserved}
      scsiIOptr:           ^SCSI_IO;      {-> pointer to the PB to abort}
   END;
   SCSITerminateIOPB = 
   PACKED RECORD
      qLink:               ^SCSIHdr;      {internal use, must be NIL}
      scsiReserved1:       Integer;       {-> reserved for input}
      scsiPBLength:        Integer;       {-> length of the entire PB}
      scsiFunctionCode:    Byte;          {-> function selector}
      scsiReserved2:       Byte;          {<- reserved for output}
      scsiResult:          OSErr;         {<- returned result}
      scsiDevice:          DeviceIdent;   {-> device ID (bus+target+LUN)}
      scsiCompletion:      CallbackProc;  {-> completion routine pointer}
      scsiFlags:           LongInt;       {-> assorted flags}
      scsiDriverStorage:   ^Byte;         {<> pointer for driver private use}
      scsiXPTprivate:      Ptr;           {private field for XPT}
      scsiReserved3:       LongInt;       {reserved}
      scsiIOptr:           ^SCSI_IO;      {-> pointer to the PB to terminate}
   END;
   SCSIGetVirtualIDInfoPB = 
   PACKED RECORD
      qLink:               ^SCSIHdr;      {internal use, must be NIL}
      scsiReserved1:       Integer;       {-> reserved for input}
      scsiPBLength:        Integer;       {-> length of the entire PB}
      scsiFunctionCode:    Byte;          {-> function selector}
      scsiReserved2:       Byte;          {<- reserved for output}
      scsiResult:          OSErr;         {<- returned result}
      scsiDevice:          DeviceIdent;   {-> device ID (bus+target+LUN)}
      scsiCompletion:      CallbackProc;  {-> completion routine pointer}
      scsiFlags:           LongInt;       {-> assorted flags}
      scsiDriverStorage:   ^Byte;         {<> pointer for driver private use}
      scsiXPTprivate:      Ptr;           {private field for XPT}
      scsiReserved3:       LongInt;       {reserved}
      scsiOldCallID:       Integer;       {-> SCSI ID of device in question}
      scsiExists:          Boolean;       {<- true if device exists}
   END;
   SCSIDriverPB = 
   PACKED RECORD
      qLink:               ^SCSIHdr;      {internal use, must be NIL}
      scsiReserved1:       Integer;       {-> reserved for input}
      scsiPBLength:        Integer;       {-> length of the entire PB}
      scsiFunctionCode:    Byte;          {-> function selector}
      scsiReserved2:       Byte;          {<- reserved for output}
      scsiResult:          OSErr;         {<- returned result}
      scsiDevice:          DeviceIdent;   {-> device ID (bus+target+LUN)}
      scsiCompletion:      CallbackProc;  {-> completion routine pointer}
      scsiFlags:           LongInt;       {-> assorted flags}
      scsiDriverStorage:   ^Byte;         {<> pointer for driver private use}
      scsiXPTprivate:      Ptr;           {private field for XPT}
      scsiReserved3:       LongInt;       {reserved}
      scsiDriver:          Integer;       {<> driver reference number}
      scsiDriverFlags:     Integer;       {<> details of driver/device}
      scsiNextDevice:      DeviceIdent;   {<- DeviceIdent of the next driver}
   END;
   SCSILoadDriverPB = 
   PACKED RECORD
      qLink:               ^SCSIHdr;      {internal use, must be NIL}
      scsiReserved1:       Integer;       {-> reserved for input}
      scsiPBLength:        Integer;       {-> length of the entire PB}
      scsiFunctionCode:    Byte;          {-> function selector}
      scsiReserved2:       Byte;          {<- reserved for output}
      scsiResult:          OSErr;         {<- returned result}
      scsiDevice:          DeviceIdent;   {-> device ID (bus+target+LUN)}
      scsiCompletion:      CallbackProc;  {-> completion routine pointer}
      scsiFlags:           LongInt;       {-> assorted flags}
      scsiDriverStorage:   ^Byte;         {<> pointer for driver private use}
      scsiXPTprivate:      Ptr;           {private field for XPT}
      scsiReserved3:       LongInt;       {reserved}
      scsiLoadedRefNum:    Integer;       {<- SIM returns driver refNum}
      scsiDiskLoadFailed:  Boolean;       {-> if true, previous call failed}
   END;
   SIMInitInfo = 
   PACKED RECORD
      SIMstaticPtr:        ^Byte;         {<- pointer to SIM's static data}
      staticSize:          LongInt;       {-> requested SIM static data size}
      SIMInit:             SIMInitProc;   {-> SIMInit function pointer}
      SIMAction:           SIMActionProc; {-> SIMAction function pointer}
      SIM_ISR:             SCSIProc;      {reserved}
      SIMInterruptPoll:    InterruptPollProc;{-> SIMInterruptPoll function}
      NewOldCall:          SIMActionProc; {-> NewOldCall function pointer}
      ioPBSize:            Integer;       {-> size of SCSI_IO PB for SIM}
      oldCallCapable:      Boolean;       {-> true if SIM supports old-API}
      simInfoUnused1:      Byte;          {reserved}
      simInternalUse:      LongInt;       { not affected or viewed by XPT}
      XPT_ISR:             SCSIProc;      {reserved}
      EnteringSIM:         SCSIProc;      {<- EnteringSIM function pointer}
      ExitingSIM:          SCSIProc;      {<- ExitingSIM function pointer}
      MakeCallback:        MakeCallbackProc;{<- MakeCallback function ptr}
      busID:               Integer;       {<- bus number assigned by XPT}
      simInfoUnused3:      Integer;       {<- reserved}
      simInfoUnused4:      LongInt;       {<- reserved}
   END;

Routines

FUNCTION SCSIAction        (VAR ioPtr: SCSI_PB): OSErr;
FUNCTION SCSIRegisterBus   (VAR ioPtr: SIMInitInfo): OSErr;
FUNCTION SCSIDeregisterBus (VAR ioPtr: SIMInitInfo): OSErr;
FUNCTION SCSIReregisterBus (VAR ioPtr: SIMInitInfo): OSErr;
FUNCTION SCSIKillXPT       (VAR ioPtr: SIMInitInfo): OSErr;

Assembly-Language Summary

Data Structures

The Device Identification Record
0diReservedbytereserved
1busbytebus number
2targetIDbytetarget SCSI ID
3LUNbytelogical unit number

The Command Descriptor Block Record
0cdbPtrlongCDB buffer pointer
4cdbBytes16 bytesCDB buffer

The Scatter/Gather List Element
0SGAddrlongbuffer pointer
4SGCountlongbuffer size

The SCSI Manager Parameter Block Header
0qLinklongused internally by the SCSI Manager
4scsiReservedwordreserved
6scsiPBLengthwordparameter block size
8scsiFunctionCodebytefunction selector code
9scsiReserved2bytereserved
10scsiResultwordresult code
12scsiDevice4 bytesdevice ID (bus number, target ID, LUN)
16scsiCompletionlongcompletion routine
20scsiFlagslongflags
24scsiDriverStoragelongdriver private data
28scsiXPTprivatelongreserved
32scsiReserved3longreserved

The SCSI I/O Parameter Block
0SCSIPBHdr36 bytesparameter block header
36scsiResultFlagswordI/O result flags
38scsiReserved12wordreserved
40scsiDataPtrlongdata buffer pointer
44scsiDataLengthlongdata buffer size
48scsiSensePtrlongautosense buffer pointer
52scsiSenseLengthbyteautosense buffer size
53scsiCDBLengthbyteCDB size
54scsiSGListCountwordnumber of scatter/gather list entries
56scsiReserved4longreserved
60scsiSCSIstatusbyteSCSI device status
61scsiSenseResidualbyteautosense residual length
62scsiReserved5wordreserved
64scsiDataResiduallongdata transfer residual length
68scsiCDB16 bytescommand descriptor block record
84scsiTimeoutlongtimeout value, in Time Manager format
88scsiReserved13longreserved
92scsiReserved14longreserved
94scsiIOFlagswordI/O flags
96scsiTagActionbytereserved
97scsiReserved6bytereserved
98scsiReserved7wordreserved
100scsiSelectTimeoutwordselection timeout value, in milliseconds
102scsiDataTypebytedata type of scsiDataPtr
103scsiTransferTypebytetransfer mode (polled or blind)
104scsiReserved8longreserved
108scsiReserved9 longreserved
112scsiHandshake16 byteshandshaking instructions
128scsiReserved10longreserved
132scsiReserved1longreserved
136scsiCommandLinklonglinked parameter block pointer
140scsiSIMpublics8 bytesadditional input to SIM
148scsiAppleReserved68 bytesreserved
156scsiCurrentPhasewordbus phase after original SCSI Manager function
158scsiSelectorword_SCSIDispatch selector for original function
160scsiOldCallResultwordresult code of original function
162scsiSCSImessagebyteSCSIComplete message byte
163XPTprivateFlagsbytereserved
164XPTextras12 bytesreserved
    

The SCSI Bus Inquiry Parameter Block
0SCSIPBHdr36 bytesparameter block header
36scsiEngineCountwordnumber of engines on the HBA
38scsiMaxTransferTypewordnumber of data transfer types supported
40scsiDataTypeslongbit map of supported data types
44scsiIOpbSize wordSCSI I/O parameter block size for this SIM
46scsiMaxIOpbSize wordlargest parameter block for any registered SIM
48scsiFeatureFlags longbus feature flags
52scsiVersionNumberbyteSIM/HBA version number
53scsiHBAInquiry bytebus capability flags
54scsiTargetModeFlagsbytereserved
55scsiScanFlags bytescan feature flags
56scsiSIMPrivatesPtrlongSIM private data pointer
60scsiSIMPrivatesSizelongSIM private data size
64scsiAsyncFlags longreserved
68scsiHiBusID bytehighest registered bus number
69scsiInitiatorID byteSCSI ID of the HBA
70scsiBIReserved0 wordreserved
72scsiBIReserved1 longreserved
76scsiFlagsSupportedlongbit map of supported scsiFlags
80scsiIOFlagsSupportedwordbit map of supported scsiIOFlags
82scsiWeirdStuff wordmiscellaneous flags
84scsiMaxTarget wordhighest SCSI ID supported by the HBA
86scsiMaxLUN wordhighest LUN supported by the HBA
88scsiSIMVendor 16 bytesSIM vendor string
104scsiHBAVendor 16 bytesHBA vendor string
120scsiControllerFamily 16 bytesSCSI controller family string
136scsiControllerType16 bytesSCSI controller type string
152scsiXPTversion 4 bytesXPT version string
156scsiSIMversion 4 bytesSIM version string
160scsiHBAversion 4 bytesHBA version string
164scsiHBAslotType byteHBA slot type
165scsiHBAslotNumber byteHBA slot number
166scsiSIMsRsrcID wordSIM sResource ID
168scsiBIReserved3 wordreserved
170scsiAdditionalLengthwordadditional size of the parameter block

The SCSI Abort Command Parameter Block
0SCSIPBHdr36 bytesparameter block header
36scsiIOptrlongSCSI I/O parameter block pointer

The SCSI Terminate I/O Parameter Block
0SCSIPBHdr36 bytesparameter block header
36scsiIOptrlongSCSI I/O parameter block pointer

The SCSI Virtual ID Information Parameter Block
0SCSIPBHdr36 bytesparameter block header
36scsiOldCallIDwordvirtual SCSI ID of the device to search for
38scsiExistsbyteBoolean (true if the device was found)

The SCSI Load Driver Parameter Block
0SCSIPBHdr36 bytesparameter block header
36scsiLoadedRefNumworddriver reference number
38scsiDiskLoadFailedbyteBoolean (true if a driver could not be loaded)

The SCSI Driver Identification Parameter Block
0SCSIPBHdr36 bytesparameter block header
36scsiDriverworddriver reference number
38scsiDriverFlagsworddriver flags
40scsiNextDevice4 bytesdevice ID of the next device in the list

The SIM Initialization Record
0SIMstaticPtrlongSIM private data pointer
4staticSizelongSIM private data size
8SIMInitlongSIMInit function pointer
12SIMActionlongSIMAction function pointer
16SIM_ISRlongreserved
20SIMInterruptPolllongSIMInterruptPoll function pointer
24NewOldCalllongNewOldCall function pointer
28ioPBSizewordSCSI I/O parameter block size for this SIM
30oldCallCapablebyteBoolean (true if SIM accepts original functions)
31simInfoUnused1bytereserved
32simInternalUselongSIM private data
36XPT_ISRlongreserved
40EnteringSIMlongEnteringSIM function pointer
44ExitingSIMlongExitingSIM function pointer
48MakeCallbacklongMakeCallback function pointer
52busIDwordbus number
54simInfoUnused3wordreserved
56simInfoUnused4longreserved

Trap Macros

Trap Macros Requiring Routine Selectors

_SCSIAtomic
SelectorRoutine
$0001SCSIAction
$0002SCSIRegisterBus
$0003SCSIDeregisterBus
$0004SCSIReregisterBus
$0005SCSIKillXPT

Result Codes
noErr0No error
scsiRequestInProgress1Parameter block request is in progress
scsiCDBLengthInvalid-7863The CDB length supplied is not supported by this SIM; typically this means it was too big
scsiTransferTypeInvalid-7864The scsiTransferType is not supported by this SIM
scsiDataTypeInvalid-7865SIM does not support the requested scsiDataType
scsiIDInvalid-7866The initiator ID is invalid
scsiLUNInvalid-7867The logical unit number is invalid
scsiTIDInvalid-7868The target ID is invalid
scsiBusInvalid-7869The bus ID is invalid
scsiRequestInvalid-7870The parameter block request is invalid
scsiFunctionNotAvailable-7871The requested function is not supported by this SIM
scsiPBLengthError-7872The parameter block length is too small for this SIM
scsiQLinkInvalid-7881The qLink field was not 0
scsiNoSuchXref-7882No driver has been cross-referenced with this device
scsiDeviceConflict-7883Attempt to register more than one driver to a device
scsiNoHBA-7884No HBA detected
scsiDeviceNotThere-7885SCSI device not installed or available
scsiProvideFail-7886Unable to provide the requested service
scsiBusy-7887SCSI subsystem is busy
scsiTooManyBuses-7888SIM registration failed because the XPT registry is full
scsiCDBReceived-7910The SCSI CDB was received
scsiNoNexus-7911Nexus is not established
scsiTerminated-7912Parameter block request terminated by the host
scsiBDRsent-7913A SCSI bus device reset (BDR) message was sent to the target
scsiWrongDirection-7915Data phase was in an unexpected direction
scsiSequenceFail-7916Target bus phase sequence failure
scsiUnexpectedBusFree-7917Unexpected bus free phase
scsiDataRunError-7918Data overrun/underrun error
scsiAutosenseFailed-7920Automatic REQUEST SENSE command failed
scsiParityError-7921An uncorrectable parity error occurred
scsiSCSIBusReset-7922Execution of this parameter block was halted because of a SCSI bus reset
scsiMessageRejectReceived-7923REJECT message received
scsiIdentifyMessageRejected-7924The target issued a REJECT message in response to the IDENTIFY message; the LUN probably does not exist
scsiCommandTimeout-7925The timeout value for this parameter block was exceeded and the parameter block was aborted
scsiSelectTimeout-7926Target selection timeout
scsiUnableToTerminate-7927Unable to terminate I/O parameter block request
scsiNonZeroStatus-7932The target returned non-zero status upon completion of the request
scsiUnableToAbort-7933Unable to abort parameter block request
scsiRequestAborted-7934Parameter block request aborted by the host


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice