Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
SCSIFindDevices.h
/* |
File: SCSIFindDevices.h |
Contains: Include the O.S. files in a specific order to make sure that we have |
a definition for the _SCSIAtomic trap. |
Written by: |
Copyright: Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
Change History (most recent first): |
7/14/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
*/ |
#include <Traps.h> |
#ifndef _SCSIAtomic |
#define _SCSIAtomic 0xA089 |
#endif |
/* |
* This uses the new "common" SCSI.h which is not yet in the public |
* header folders. |
*/ |
#include "SCSI.h" |
/* |
* This is a parameter block for SCSIFindNextDevice that contains the data shared |
* with the calling program and the internal state that the function needs to |
* sequence between each device. If SCSIFindNextDevice succeeds, the device |
* inquiry data is stored in the record. |
*/ |
struct SCSIFindDevicesRec { |
/* Public variables */ |
DeviceIdent deviceID; /* <-> Bus/target/LUN */ |
short maxLUN; /* -> Maximum logical units */ |
Boolean isAsyncSCSIPresent; /* <- TRUE if SCSI Manager 4.3 */ |
long refNum; /* Reserved for the caller */ |
long actualInquirySize; /* <- data length in inquiry */ |
struct SCSI_Inquiry_Data { /* <- Inquiry returns this */ |
unsigned char devType; /* 0 Device type, */ |
unsigned char devTypeMod; /* 1 Device type modifier */ |
unsigned char version; /* 2 ISO/ECMA/ANSI version */ |
unsigned char format; /* 3 Response data format */ |
unsigned char length; /* 4 Additional Length */ |
unsigned char reserved5; /* 5 Reserved */ |
unsigned char reserved6; /* 6 Reserved */ |
unsigned char flags; /* 7 Capability flags */ |
unsigned char vendor[8]; /* 8-15 Vendor-specific */ |
unsigned char product[16]; /* 16-31 Product id */ |
unsigned char revision[4]; /* 32-35 Product revision */ |
unsigned char vendorSpecific[20]; /* 36-55 Vendor stuff */ |
unsigned char moreReserved[40]; /* 56-95 Reserved */ |
} inquiry; |
/* Private variables */ |
short state; /* Control overall operation */ |
unsigned short lastHostBus; /* Host bus iteration limit */ |
Boolean useAsynchSCSI; /* Is asynch ok on this bus? */ |
unsigned short initiatorID; /* Host processor bus ID */ |
unsigned short maxTargetID; /* Max target on this bus */ |
short maxBusLUN; /* Max LUN on this bus */ |
Boolean enableATN; /* Select with ATN on this bus? */ |
unsigned long execIOPBSize; /* SCSIAction pb size */ |
SCSIExecIOPB *scsiExecIOPB; /* Set on bus-by-bus basis */ |
}; |
typedef struct SCSIFindDevicesRec SCSIFindDevicesRec, *SCSIFindDevicesPtr; |
/* |
* Notes on the above: |
* Public variables: |
* deviceID This is the current SCSI device. If deviceID.bus == 0xFF |
* SCSIFindNextDevice will initialize itself. |
* maxLUN Set to zero to ignore logical units or seven to test |
* all targets for multiple logical units. Beware: some |
* devices fail miserably if a non-zero logical unit is |
* selected. |
* isAsyncSCSIPresent Set TRUE after the first call to SCSIFindNextDevice if |
* the asynchronous SCSI Manager (SCSI Manager 4.3) is |
* running. |
* actualInquirySize If the function succeeds, it returns the Device Inquiry |
* information in the inquiry field. actualInquirySize |
* is the length of the data that was returned. |
* inquiry This is the device information returned on success. |
* Private variables: |
* state This manages the overall code flow in the subroutine. |
* lastHostBus The highest host bus on this system (if asynch present) |
* useAsynchSCSI TRUE if the asynchronous SCSI Manager works on this bus |
* initiatorID The bus ID of the Macintosh. Normally 7 |
* maxTargetID The maximum target bus ID on this host bus. |
* enableATN Enable "select with attention" if set. This works around |
* a bug on un-patched Quadra 660-av and 840-av systems. |
* execIOPBSize The size of the SCSI parameter block. |
* scsiExecIOPB A pointer to the SCSI parameter block. |
*/ |
/* |
* SCSIFindNextDevice: |
* Scan the SCSI bus(es) for the next device. This will scan all buses, all |
* targets, and all logical units in order. To initialize, set deviceID.bus to |
* 0xFF and maxLUN to zero or seven as needed. |
* SCSIFindNextDevice allocates memory. |
* |
* Return: |
* noErr The deviceID field contains the next SCSI device and |
* the inquiry structure contains device-specific information. |
* eofErr The last device has been found. This is a normal status. |
* other errors Something horrible happened, such as a memory error. |
* (If your application calls SCSIFindNextDevice after any |
* error status, it will start from the beginning.) |
*/ |
OSErr SCSIFindNextDevice( |
SCSIFindDevicesPtr scsiFindDevicesPtr |
); |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14