xref: /netbsd-src/external/bsd/pdisk/dist/DoSCSICommand.h (revision 48a628ae0434c4247b560ad8f2eb1dc06d0dd070)
1 /*
2  * DoScsiCommand.h -
3  *
4  * Modifed by Eryk Vershen
5  * from an original by Martin Minow
6  */
7 
8 /*
9  * Copyright 1993-1998 by Apple Computer, Inc.
10  *              All Rights Reserved
11  *
12  * Permission to use, copy, modify, and distribute this software and
13  * its documentation for any purpose and without fee is hereby granted,
14  * provided that the above copyright notice appears in all copies and
15  * that both the copyright notice and this permission notice appear in
16  * supporting documentation.
17  *
18  * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
19  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE.
21  *
22  * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
23  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
25  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
26  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27  */
28 
29 #ifndef __DoScsiCommand__
30 #define __DoScsiCommand__
31 
32 #include <SCSI.h>
33 #include "MacSCSICommand.h"
34 
35 
36 /*
37  * Defines
38  */
39 #ifndef EXTERN
40 #define EXTERN              extern
41 #endif
42 
43 #ifndef TRUE
44 #define TRUE                1
45 #define FALSE               0
46 #endif
47 
48 #ifndef NULL
49 #define NULL                0
50 #endif
51 
52 #define kOriginalSCSIBusAdaptor (0xFF)
53 
54 #define SameSCSIDevice(a, b) ((*((UInt32 *) &a)) == (*((UInt32 *) &b)))
55 
56 /*
57  * Cheap 'n dirty memory clear routine.
58  */
59 #define CLEAR(dst)          clear_memory((void *) &dst, sizeof dst)
60 
61 
62 /*
63  * Types
64  */
65 #if !defined(__NewTypesDefined__)
66 #define __NewTypesDefined__
67 typedef int8_t     SInt8;
68 typedef int16_t    SInt16;
69 typedef int32_t     SInt32;
70 typedef uint8_t   UInt8;
71 typedef uint16_t  UInt16;
72 typedef uint32_t   UInt32;
73 typedef uint32_t   ItemCount;
74 typedef uint32_t   ByteCount;
75 #endif
76 
77 
78 /*
79  * Global Constants
80  */
81 enum {
82     bit0 = (1 << 0),
83     bit1 = (1 << 1),
84     bit2 = (1 << 2),
85     bit3 = (1 << 3),
86     bit4 = (1 << 4),
87     bit5 = (1 << 5),
88     bit6 = (1 << 6),
89     bit7 = (1 << 7)
90 };
91 
92 
93 /*
94  * Global Variables
95  */
96 EXTERN int				gSCSIHiBusID;
97 EXTERN SCSIExecIOPB     *gSCSIExecIOPBPtr;
98 EXTERN UInt32           gSCSIExecIOPBPtrLen;
99 
100 
101 /*
102  * Forward declarations
103  */
104 void AllocatePB();
105 Boolean IsIllegalRequest(OSErr scsiStatus, const SCSI_Sense_Data *senseDataPtr);
106 Boolean IsNoMedia(OSErr scsiStatus, const SCSI_Sense_Data *senseDataPtr);
107 /*
108  * All SCSI Commands come here.
109  *  if scsiDevice.busID == kOriginalSCSIBusAdaptor, IM-IV SCSI will be called.
110  *  scsiFlags should be scsiDirectionNone, scsiDirectionIn, or scsiDirectionOut
111  *  actualTransferCount may be NULL if you don't care.
112  *  Both old and new SCSI return SCSI Manager 4.3 errors.
113  *
114  * DoSCSICommand throws really serious errors, but returns SCSI errors such
115  * as dataRunError and scsiDeviceNotThere.
116  */
117 OSErr DoSCSICommand(
118 	DeviceIdent             scsiDevice,
119 	ConstStr255Param        currentAction,
120 	const SCSI_CommandPtr   callerSCSICommand,
121 	Ptr                     dataBuffer,
122 	ByteCount               dataLength,
123 	UInt32                  scsiFlags,
124 	ByteCount               *actualTransferCount,
125 	SCSI_Sense_Data         *sensePtr,
126 	StringPtr               senseMessage
127 );
128 
129 
130 #endif /* __DoScsiCommand__ */
131