19428323dSchristos /* 29428323dSchristos * DoScsiCommand.h - 39428323dSchristos * 49428323dSchristos * Modifed by Eryk Vershen 59428323dSchristos * from an original by Martin Minow 69428323dSchristos */ 79428323dSchristos 89428323dSchristos /* 99428323dSchristos * Copyright 1993-1998 by Apple Computer, Inc. 109428323dSchristos * All Rights Reserved 119428323dSchristos * 129428323dSchristos * Permission to use, copy, modify, and distribute this software and 139428323dSchristos * its documentation for any purpose and without fee is hereby granted, 149428323dSchristos * provided that the above copyright notice appears in all copies and 159428323dSchristos * that both the copyright notice and this permission notice appear in 169428323dSchristos * supporting documentation. 179428323dSchristos * 189428323dSchristos * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 199428323dSchristos * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 209428323dSchristos * FOR A PARTICULAR PURPOSE. 219428323dSchristos * 229428323dSchristos * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 239428323dSchristos * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 249428323dSchristos * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 259428323dSchristos * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 269428323dSchristos * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 279428323dSchristos */ 289428323dSchristos 299428323dSchristos #ifndef __DoScsiCommand__ 309428323dSchristos #define __DoScsiCommand__ 319428323dSchristos 329428323dSchristos #include <SCSI.h> 339428323dSchristos #include "MacSCSICommand.h" 349428323dSchristos 359428323dSchristos 369428323dSchristos /* 379428323dSchristos * Defines 389428323dSchristos */ 399428323dSchristos #ifndef EXTERN 409428323dSchristos #define EXTERN extern 419428323dSchristos #endif 429428323dSchristos 439428323dSchristos #ifndef TRUE 449428323dSchristos #define TRUE 1 459428323dSchristos #define FALSE 0 469428323dSchristos #endif 479428323dSchristos 489428323dSchristos #ifndef NULL 499428323dSchristos #define NULL 0 509428323dSchristos #endif 519428323dSchristos 529428323dSchristos #define kOriginalSCSIBusAdaptor (0xFF) 539428323dSchristos 549428323dSchristos #define SameSCSIDevice(a, b) ((*((UInt32 *) &a)) == (*((UInt32 *) &b))) 559428323dSchristos 569428323dSchristos /* 579428323dSchristos * Cheap 'n dirty memory clear routine. 589428323dSchristos */ 599428323dSchristos #define CLEAR(dst) clear_memory((void *) &dst, sizeof dst) 609428323dSchristos 619428323dSchristos 629428323dSchristos /* 639428323dSchristos * Types 649428323dSchristos */ 659428323dSchristos #if !defined(__NewTypesDefined__) 669428323dSchristos #define __NewTypesDefined__ 67*48a628aeSchristos typedef int8_t SInt8; 68*48a628aeSchristos typedef int16_t SInt16; 69*48a628aeSchristos typedef int32_t SInt32; 70*48a628aeSchristos typedef uint8_t UInt8; 71*48a628aeSchristos typedef uint16_t UInt16; 72*48a628aeSchristos typedef uint32_t UInt32; 73*48a628aeSchristos typedef uint32_t ItemCount; 74*48a628aeSchristos typedef uint32_t ByteCount; 759428323dSchristos #endif 769428323dSchristos 779428323dSchristos 789428323dSchristos /* 799428323dSchristos * Global Constants 809428323dSchristos */ 819428323dSchristos enum { 829428323dSchristos bit0 = (1 << 0), 839428323dSchristos bit1 = (1 << 1), 849428323dSchristos bit2 = (1 << 2), 859428323dSchristos bit3 = (1 << 3), 869428323dSchristos bit4 = (1 << 4), 879428323dSchristos bit5 = (1 << 5), 889428323dSchristos bit6 = (1 << 6), 899428323dSchristos bit7 = (1 << 7) 909428323dSchristos }; 919428323dSchristos 929428323dSchristos 939428323dSchristos /* 949428323dSchristos * Global Variables 959428323dSchristos */ 969428323dSchristos EXTERN int gSCSIHiBusID; 979428323dSchristos EXTERN SCSIExecIOPB *gSCSIExecIOPBPtr; 989428323dSchristos EXTERN UInt32 gSCSIExecIOPBPtrLen; 999428323dSchristos 1009428323dSchristos 1019428323dSchristos /* 1029428323dSchristos * Forward declarations 1039428323dSchristos */ 1049428323dSchristos void AllocatePB(); 1059428323dSchristos Boolean IsIllegalRequest(OSErr scsiStatus, const SCSI_Sense_Data *senseDataPtr); 1069428323dSchristos Boolean IsNoMedia(OSErr scsiStatus, const SCSI_Sense_Data *senseDataPtr); 1079428323dSchristos /* 1089428323dSchristos * All SCSI Commands come here. 1099428323dSchristos * if scsiDevice.busID == kOriginalSCSIBusAdaptor, IM-IV SCSI will be called. 1109428323dSchristos * scsiFlags should be scsiDirectionNone, scsiDirectionIn, or scsiDirectionOut 1119428323dSchristos * actualTransferCount may be NULL if you don't care. 1129428323dSchristos * Both old and new SCSI return SCSI Manager 4.3 errors. 1139428323dSchristos * 1149428323dSchristos * DoSCSICommand throws really serious errors, but returns SCSI errors such 1159428323dSchristos * as dataRunError and scsiDeviceNotThere. 1169428323dSchristos */ 1179428323dSchristos OSErr DoSCSICommand( 1189428323dSchristos DeviceIdent scsiDevice, 1199428323dSchristos ConstStr255Param currentAction, 1209428323dSchristos const SCSI_CommandPtr callerSCSICommand, 1219428323dSchristos Ptr dataBuffer, 1229428323dSchristos ByteCount dataLength, 1239428323dSchristos UInt32 scsiFlags, 1249428323dSchristos ByteCount *actualTransferCount, 1259428323dSchristos SCSI_Sense_Data *sensePtr, 1269428323dSchristos StringPtr senseMessage 1279428323dSchristos ); 1289428323dSchristos 1299428323dSchristos 1309428323dSchristos #endif /* __DoScsiCommand__ */ 131