Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1668 lines
79 KiB

  1. /*
  2. File: SCSI.h
  3. Contains: SCSI Family Interfaces.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1986-2001 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __SCSI__
  11. #define __SCSI__
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #ifndef __MIXEDMODE__
  16. #include <MixedMode.h>
  17. #endif
  18. #ifndef __APPLEDISKPARTITIONS__
  19. #include <AppleDiskPartitions.h>
  20. #endif
  21. #if PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #if PRAGMA_IMPORT
  28. #pragma import on
  29. #endif
  30. #if PRAGMA_STRUCT_ALIGN
  31. #pragma options align=mac68k
  32. #elif PRAGMA_STRUCT_PACKPUSH
  33. #pragma pack(push, 2)
  34. #elif PRAGMA_STRUCT_PACK
  35. #pragma pack(2)
  36. #endif
  37. /* SCSI Manager errors. These are generated by Inside Mac IV calls only. */
  38. enum {
  39. scCommErr = 2, /* communications error, operation timeout */
  40. scArbNBErr = 3, /* arbitration timeout waiting for not BSY */
  41. scBadParmsErr = 4, /* bad parameter or TIB opcode */
  42. scPhaseErr = 5, /* SCSI bus not in correct phase for attempted operation */
  43. scCompareErr = 6, /* data compare error */
  44. scMgrBusyErr = 7, /* SCSI Manager busy */
  45. scSequenceErr = 8, /* attempted operation is out of sequence */
  46. scBusTOErr = 9, /* CPU bus timeout */
  47. scComplPhaseErr = 10 /* SCSI bus wasn't in Status phase */
  48. };
  49. /* TIB opcodes */
  50. enum {
  51. scInc = 1,
  52. scNoInc = 2,
  53. scAdd = 3,
  54. scMove = 4,
  55. scLoop = 5,
  56. scNop = 6,
  57. scStop = 7,
  58. scComp = 8
  59. };
  60. /*
  61. * All disk partition structures and definitions are now in the
  62. * AppleDiskPartitions.h/p/a files.
  63. */
  64. /* TIB instruction */
  65. struct SCSIInstr {
  66. unsigned short scOpcode;
  67. long scParam1;
  68. long scParam2;
  69. };
  70. typedef struct SCSIInstr SCSIInstr;
  71. /* SCSI Phases (used by SIMs to support the Original SCSI Manager */
  72. enum {
  73. kDataOutPhase = 0, /* Encoded MSG, C/D, I/O bits */
  74. kDataInPhase = 1,
  75. kCommandPhase = 2,
  76. kStatusPhase = 3,
  77. kPhaseIllegal0 = 4,
  78. kPhaseIllegal1 = 5,
  79. kMessageOutPhase = 6,
  80. kMessageInPhase = 7,
  81. kBusFreePhase = 8, /* Additional Phases */
  82. kArbitratePhase = 9,
  83. kSelectPhase = 10,
  84. kMessageInPhaseNACK = 11 /* Message In Phase with ACK hanging on the bus */
  85. };
  86. #if CALL_NOT_IN_CARBON
  87. /*
  88. * SCSIReset()
  89. *
  90. * Availability:
  91. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  92. * CarbonLib: not available
  93. * Mac OS X: not available
  94. */
  95. EXTERN_API( OSErr )
  96. SCSIReset(void) TWOWORDINLINE(0x4267, 0xA815);
  97. /*
  98. * SCSIGet()
  99. *
  100. * Availability:
  101. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  102. * CarbonLib: not available
  103. * Mac OS X: not available
  104. */
  105. EXTERN_API( OSErr )
  106. SCSIGet(void) THREEWORDINLINE(0x3F3C, 0x0001, 0xA815);
  107. /*
  108. * SCSISelect()
  109. *
  110. * Availability:
  111. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  112. * CarbonLib: not available
  113. * Mac OS X: not available
  114. */
  115. EXTERN_API( OSErr )
  116. SCSISelect(short targetID) THREEWORDINLINE(0x3F3C, 0x0002, 0xA815);
  117. /*
  118. * SCSICmd()
  119. *
  120. * Availability:
  121. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  122. * CarbonLib: not available
  123. * Mac OS X: not available
  124. */
  125. EXTERN_API( OSErr )
  126. SCSICmd(
  127. Ptr buffer,
  128. short count) THREEWORDINLINE(0x3F3C, 0x0003, 0xA815);
  129. /*
  130. * SCSIRead()
  131. *
  132. * Availability:
  133. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  134. * CarbonLib: not available
  135. * Mac OS X: not available
  136. */
  137. EXTERN_API( OSErr )
  138. SCSIRead(Ptr tibPtr) THREEWORDINLINE(0x3F3C, 0x0005, 0xA815);
  139. /*
  140. * SCSIRBlind()
  141. *
  142. * Availability:
  143. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  144. * CarbonLib: not available
  145. * Mac OS X: not available
  146. */
  147. EXTERN_API( OSErr )
  148. SCSIRBlind(Ptr tibPtr) THREEWORDINLINE(0x3F3C, 0x0008, 0xA815);
  149. /*
  150. * SCSIWrite()
  151. *
  152. * Availability:
  153. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  154. * CarbonLib: not available
  155. * Mac OS X: not available
  156. */
  157. EXTERN_API( OSErr )
  158. SCSIWrite(Ptr tibPtr) THREEWORDINLINE(0x3F3C, 0x0006, 0xA815);
  159. /*
  160. * SCSIWBlind()
  161. *
  162. * Availability:
  163. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  164. * CarbonLib: not available
  165. * Mac OS X: not available
  166. */
  167. EXTERN_API( OSErr )
  168. SCSIWBlind(Ptr tibPtr) THREEWORDINLINE(0x3F3C, 0x0009, 0xA815);
  169. /*
  170. * SCSIComplete()
  171. *
  172. * Availability:
  173. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  174. * CarbonLib: not available
  175. * Mac OS X: not available
  176. */
  177. EXTERN_API( OSErr )
  178. SCSIComplete(
  179. short * stat,
  180. short * message,
  181. unsigned long wait) THREEWORDINLINE(0x3F3C, 0x0004, 0xA815);
  182. /*
  183. * SCSIStat()
  184. *
  185. * Availability:
  186. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  187. * CarbonLib: not available
  188. * Mac OS X: not available
  189. */
  190. EXTERN_API( short )
  191. SCSIStat(void) THREEWORDINLINE(0x3F3C, 0x000A, 0xA815);
  192. /*
  193. * SCSISelAtn()
  194. *
  195. * Availability:
  196. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  197. * CarbonLib: not available
  198. * Mac OS X: not available
  199. */
  200. EXTERN_API( OSErr )
  201. SCSISelAtn(short targetID) THREEWORDINLINE(0x3F3C, 0x000B, 0xA815);
  202. /*
  203. * SCSIMsgIn()
  204. *
  205. * Availability:
  206. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  207. * CarbonLib: not available
  208. * Mac OS X: not available
  209. */
  210. EXTERN_API( OSErr )
  211. SCSIMsgIn(short * message) THREEWORDINLINE(0x3F3C, 0x000C, 0xA815);
  212. /*
  213. * SCSIMsgOut()
  214. *
  215. * Availability:
  216. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  217. * CarbonLib: not available
  218. * Mac OS X: not available
  219. */
  220. EXTERN_API( OSErr )
  221. SCSIMsgOut(short message) THREEWORDINLINE(0x3F3C, 0x000D, 0xA815);
  222. #endif /* CALL_NOT_IN_CARBON */
  223. enum {
  224. scsiVERSION = 43
  225. };
  226. /*
  227. * SCSI Callback Procedure Prototypes. Several of these are only callable
  228. * from SCSI Manager 4.3 SIM and XPT contexts.
  229. */
  230. typedef CALLBACK_API_C( void , AENCallbackProcPtr )(void);
  231. typedef CALLBACK_API_C( OSErr , SIMInitProcPtr )(Ptr SIMinfoPtr);
  232. typedef CALLBACK_API_C( void , SIMActionProcPtr )(void *scsiPB, Ptr SIMGlobals);
  233. typedef CALLBACK_API_C( void , SCSIProcPtr )(void);
  234. typedef CALLBACK_API_C( void , SCSIMakeCallbackProcPtr )(void * scsiPB);
  235. /* SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility */
  236. typedef CALLBACK_API_C( long , SCSIInterruptPollProcPtr )(Ptr SIMGlobals);
  237. typedef CALLBACK_API_C( long , SCSIInterruptProcPtr )(Ptr SIMGlobals);
  238. typedef STACK_UPP_TYPE(AENCallbackProcPtr) AENCallbackUPP;
  239. typedef STACK_UPP_TYPE(SIMInitProcPtr) SIMInitUPP;
  240. typedef STACK_UPP_TYPE(SIMActionProcPtr) SIMActionUPP;
  241. typedef STACK_UPP_TYPE(SCSIProcPtr) SCSIUPP;
  242. typedef STACK_UPP_TYPE(SCSIMakeCallbackProcPtr) SCSIMakeCallbackUPP;
  243. typedef STACK_UPP_TYPE(SCSIInterruptPollProcPtr) SCSIInterruptPollUPP;
  244. typedef STACK_UPP_TYPE(SCSIInterruptProcPtr) SCSIInterruptUPP;
  245. #if CALL_NOT_IN_CARBON
  246. /*
  247. * NewAENCallbackUPP()
  248. *
  249. * Availability:
  250. * Non-Carbon CFM: available as macro/inline
  251. * CarbonLib: not available
  252. * Mac OS X: not available
  253. */
  254. EXTERN_API_C( AENCallbackUPP )
  255. NewAENCallbackUPP(AENCallbackProcPtr userRoutine);
  256. #if !OPAQUE_UPP_TYPES
  257. enum { uppAENCallbackProcInfo = 0x00000001 }; /* no_return_value Func() */
  258. #ifdef __cplusplus
  259. inline DEFINE_API_C(AENCallbackUPP) NewAENCallbackUPP(AENCallbackProcPtr userRoutine) { return (AENCallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAENCallbackProcInfo, GetCurrentArchitecture()); }
  260. #else
  261. #define NewAENCallbackUPP(userRoutine) (AENCallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAENCallbackProcInfo, GetCurrentArchitecture())
  262. #endif
  263. #endif
  264. /*
  265. * NewSIMInitUPP()
  266. *
  267. * Availability:
  268. * Non-Carbon CFM: available as macro/inline
  269. * CarbonLib: not available
  270. * Mac OS X: not available
  271. */
  272. EXTERN_API_C( SIMInitUPP )
  273. NewSIMInitUPP(SIMInitProcPtr userRoutine);
  274. #if !OPAQUE_UPP_TYPES
  275. enum { uppSIMInitProcInfo = 0x000000E1 }; /* 2_bytes Func(4_bytes) */
  276. #ifdef __cplusplus
  277. inline DEFINE_API_C(SIMInitUPP) NewSIMInitUPP(SIMInitProcPtr userRoutine) { return (SIMInitUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMInitProcInfo, GetCurrentArchitecture()); }
  278. #else
  279. #define NewSIMInitUPP(userRoutine) (SIMInitUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMInitProcInfo, GetCurrentArchitecture())
  280. #endif
  281. #endif
  282. /*
  283. * NewSIMActionUPP()
  284. *
  285. * Availability:
  286. * Non-Carbon CFM: available as macro/inline
  287. * CarbonLib: not available
  288. * Mac OS X: not available
  289. */
  290. EXTERN_API_C( SIMActionUPP )
  291. NewSIMActionUPP(SIMActionProcPtr userRoutine);
  292. #if !OPAQUE_UPP_TYPES
  293. enum { uppSIMActionProcInfo = 0x000003C1 }; /* no_return_value Func(4_bytes, 4_bytes) */
  294. #ifdef __cplusplus
  295. inline DEFINE_API_C(SIMActionUPP) NewSIMActionUPP(SIMActionProcPtr userRoutine) { return (SIMActionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMActionProcInfo, GetCurrentArchitecture()); }
  296. #else
  297. #define NewSIMActionUPP(userRoutine) (SIMActionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMActionProcInfo, GetCurrentArchitecture())
  298. #endif
  299. #endif
  300. /*
  301. * NewSCSIUPP()
  302. *
  303. * Availability:
  304. * Non-Carbon CFM: available as macro/inline
  305. * CarbonLib: not available
  306. * Mac OS X: not available
  307. */
  308. EXTERN_API_C( SCSIUPP )
  309. NewSCSIUPP(SCSIProcPtr userRoutine);
  310. #if !OPAQUE_UPP_TYPES
  311. enum { uppSCSIProcInfo = 0x00000001 }; /* no_return_value Func() */
  312. #ifdef __cplusplus
  313. inline DEFINE_API_C(SCSIUPP) NewSCSIUPP(SCSIProcPtr userRoutine) { return (SCSIUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIProcInfo, GetCurrentArchitecture()); }
  314. #else
  315. #define NewSCSIUPP(userRoutine) (SCSIUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIProcInfo, GetCurrentArchitecture())
  316. #endif
  317. #endif
  318. /*
  319. * NewSCSIMakeCallbackUPP()
  320. *
  321. * Availability:
  322. * Non-Carbon CFM: available as macro/inline
  323. * CarbonLib: not available
  324. * Mac OS X: not available
  325. */
  326. EXTERN_API_C( SCSIMakeCallbackUPP )
  327. NewSCSIMakeCallbackUPP(SCSIMakeCallbackProcPtr userRoutine);
  328. #if !OPAQUE_UPP_TYPES
  329. enum { uppSCSIMakeCallbackProcInfo = 0x000000C1 }; /* no_return_value Func(4_bytes) */
  330. #ifdef __cplusplus
  331. inline DEFINE_API_C(SCSIMakeCallbackUPP) NewSCSIMakeCallbackUPP(SCSIMakeCallbackProcPtr userRoutine) { return (SCSIMakeCallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIMakeCallbackProcInfo, GetCurrentArchitecture()); }
  332. #else
  333. #define NewSCSIMakeCallbackUPP(userRoutine) (SCSIMakeCallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIMakeCallbackProcInfo, GetCurrentArchitecture())
  334. #endif
  335. #endif
  336. /*
  337. * NewSCSIInterruptPollUPP()
  338. *
  339. * Availability:
  340. * Non-Carbon CFM: available as macro/inline
  341. * CarbonLib: not available
  342. * Mac OS X: not available
  343. */
  344. EXTERN_API_C( SCSIInterruptPollUPP )
  345. NewSCSIInterruptPollUPP(SCSIInterruptPollProcPtr userRoutine);
  346. #if !OPAQUE_UPP_TYPES
  347. enum { uppSCSIInterruptPollProcInfo = 0x000000F1 }; /* 4_bytes Func(4_bytes) */
  348. #ifdef __cplusplus
  349. inline DEFINE_API_C(SCSIInterruptPollUPP) NewSCSIInterruptPollUPP(SCSIInterruptPollProcPtr userRoutine) { return (SCSIInterruptPollUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptPollProcInfo, GetCurrentArchitecture()); }
  350. #else
  351. #define NewSCSIInterruptPollUPP(userRoutine) (SCSIInterruptPollUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptPollProcInfo, GetCurrentArchitecture())
  352. #endif
  353. #endif
  354. /*
  355. * NewSCSIInterruptUPP()
  356. *
  357. * Availability:
  358. * Non-Carbon CFM: available as macro/inline
  359. * CarbonLib: not available
  360. * Mac OS X: not available
  361. */
  362. EXTERN_API_C( SCSIInterruptUPP )
  363. NewSCSIInterruptUPP(SCSIInterruptProcPtr userRoutine);
  364. #if !OPAQUE_UPP_TYPES
  365. enum { uppSCSIInterruptProcInfo = 0x000000F1 }; /* 4_bytes Func(4_bytes) */
  366. #ifdef __cplusplus
  367. inline DEFINE_API_C(SCSIInterruptUPP) NewSCSIInterruptUPP(SCSIInterruptProcPtr userRoutine) { return (SCSIInterruptUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptProcInfo, GetCurrentArchitecture()); }
  368. #else
  369. #define NewSCSIInterruptUPP(userRoutine) (SCSIInterruptUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptProcInfo, GetCurrentArchitecture())
  370. #endif
  371. #endif
  372. /*
  373. * DisposeAENCallbackUPP()
  374. *
  375. * Availability:
  376. * Non-Carbon CFM: available as macro/inline
  377. * CarbonLib: not available
  378. * Mac OS X: not available
  379. */
  380. EXTERN_API_C( void )
  381. DisposeAENCallbackUPP(AENCallbackUPP userUPP);
  382. #if !OPAQUE_UPP_TYPES
  383. #ifdef __cplusplus
  384. inline DEFINE_API_C(void) DisposeAENCallbackUPP(AENCallbackUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  385. #else
  386. #define DisposeAENCallbackUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  387. #endif
  388. #endif
  389. /*
  390. * DisposeSIMInitUPP()
  391. *
  392. * Availability:
  393. * Non-Carbon CFM: available as macro/inline
  394. * CarbonLib: not available
  395. * Mac OS X: not available
  396. */
  397. EXTERN_API_C( void )
  398. DisposeSIMInitUPP(SIMInitUPP userUPP);
  399. #if !OPAQUE_UPP_TYPES
  400. #ifdef __cplusplus
  401. inline DEFINE_API_C(void) DisposeSIMInitUPP(SIMInitUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  402. #else
  403. #define DisposeSIMInitUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  404. #endif
  405. #endif
  406. /*
  407. * DisposeSIMActionUPP()
  408. *
  409. * Availability:
  410. * Non-Carbon CFM: available as macro/inline
  411. * CarbonLib: not available
  412. * Mac OS X: not available
  413. */
  414. EXTERN_API_C( void )
  415. DisposeSIMActionUPP(SIMActionUPP userUPP);
  416. #if !OPAQUE_UPP_TYPES
  417. #ifdef __cplusplus
  418. inline DEFINE_API_C(void) DisposeSIMActionUPP(SIMActionUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  419. #else
  420. #define DisposeSIMActionUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  421. #endif
  422. #endif
  423. /*
  424. * DisposeSCSIUPP()
  425. *
  426. * Availability:
  427. * Non-Carbon CFM: available as macro/inline
  428. * CarbonLib: not available
  429. * Mac OS X: not available
  430. */
  431. EXTERN_API_C( void )
  432. DisposeSCSIUPP(SCSIUPP userUPP);
  433. #if !OPAQUE_UPP_TYPES
  434. #ifdef __cplusplus
  435. inline DEFINE_API_C(void) DisposeSCSIUPP(SCSIUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  436. #else
  437. #define DisposeSCSIUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  438. #endif
  439. #endif
  440. /*
  441. * DisposeSCSIMakeCallbackUPP()
  442. *
  443. * Availability:
  444. * Non-Carbon CFM: available as macro/inline
  445. * CarbonLib: not available
  446. * Mac OS X: not available
  447. */
  448. EXTERN_API_C( void )
  449. DisposeSCSIMakeCallbackUPP(SCSIMakeCallbackUPP userUPP);
  450. #if !OPAQUE_UPP_TYPES
  451. #ifdef __cplusplus
  452. inline DEFINE_API_C(void) DisposeSCSIMakeCallbackUPP(SCSIMakeCallbackUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  453. #else
  454. #define DisposeSCSIMakeCallbackUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  455. #endif
  456. #endif
  457. /*
  458. * DisposeSCSIInterruptPollUPP()
  459. *
  460. * Availability:
  461. * Non-Carbon CFM: available as macro/inline
  462. * CarbonLib: not available
  463. * Mac OS X: not available
  464. */
  465. EXTERN_API_C( void )
  466. DisposeSCSIInterruptPollUPP(SCSIInterruptPollUPP userUPP);
  467. #if !OPAQUE_UPP_TYPES
  468. #ifdef __cplusplus
  469. inline DEFINE_API_C(void) DisposeSCSIInterruptPollUPP(SCSIInterruptPollUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  470. #else
  471. #define DisposeSCSIInterruptPollUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  472. #endif
  473. #endif
  474. /*
  475. * DisposeSCSIInterruptUPP()
  476. *
  477. * Availability:
  478. * Non-Carbon CFM: available as macro/inline
  479. * CarbonLib: not available
  480. * Mac OS X: not available
  481. */
  482. EXTERN_API_C( void )
  483. DisposeSCSIInterruptUPP(SCSIInterruptUPP userUPP);
  484. #if !OPAQUE_UPP_TYPES
  485. #ifdef __cplusplus
  486. inline DEFINE_API_C(void) DisposeSCSIInterruptUPP(SCSIInterruptUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  487. #else
  488. #define DisposeSCSIInterruptUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  489. #endif
  490. #endif
  491. /*
  492. * InvokeAENCallbackUPP()
  493. *
  494. * Availability:
  495. * Non-Carbon CFM: available as macro/inline
  496. * CarbonLib: not available
  497. * Mac OS X: not available
  498. */
  499. EXTERN_API_C( void )
  500. InvokeAENCallbackUPP(AENCallbackUPP userUPP);
  501. #if !OPAQUE_UPP_TYPES
  502. #ifdef __cplusplus
  503. inline DEFINE_API_C(void) InvokeAENCallbackUPP(AENCallbackUPP userUPP) { CALL_ZERO_PARAMETER_UPP(userUPP, uppAENCallbackProcInfo); }
  504. #else
  505. #define InvokeAENCallbackUPP(userUPP) CALL_ZERO_PARAMETER_UPP((userUPP), uppAENCallbackProcInfo)
  506. #endif
  507. #endif
  508. /*
  509. * InvokeSIMInitUPP()
  510. *
  511. * Availability:
  512. * Non-Carbon CFM: available as macro/inline
  513. * CarbonLib: not available
  514. * Mac OS X: not available
  515. */
  516. EXTERN_API_C( OSErr )
  517. InvokeSIMInitUPP(
  518. Ptr SIMinfoPtr,
  519. SIMInitUPP userUPP);
  520. #if !OPAQUE_UPP_TYPES
  521. #ifdef __cplusplus
  522. inline DEFINE_API_C(OSErr) InvokeSIMInitUPP(Ptr SIMinfoPtr, SIMInitUPP userUPP) { return (OSErr)CALL_ONE_PARAMETER_UPP(userUPP, uppSIMInitProcInfo, SIMinfoPtr); }
  523. #else
  524. #define InvokeSIMInitUPP(SIMinfoPtr, userUPP) (OSErr)CALL_ONE_PARAMETER_UPP((userUPP), uppSIMInitProcInfo, (SIMinfoPtr))
  525. #endif
  526. #endif
  527. /*
  528. * InvokeSIMActionUPP()
  529. *
  530. * Availability:
  531. * Non-Carbon CFM: available as macro/inline
  532. * CarbonLib: not available
  533. * Mac OS X: not available
  534. */
  535. EXTERN_API_C( void )
  536. InvokeSIMActionUPP(
  537. void * scsiPB,
  538. Ptr SIMGlobals,
  539. SIMActionUPP userUPP);
  540. #if !OPAQUE_UPP_TYPES
  541. #ifdef __cplusplus
  542. inline DEFINE_API_C(void) InvokeSIMActionUPP(void * scsiPB, Ptr SIMGlobals, SIMActionUPP userUPP) { CALL_TWO_PARAMETER_UPP(userUPP, uppSIMActionProcInfo, scsiPB, SIMGlobals); }
  543. #else
  544. #define InvokeSIMActionUPP(scsiPB, SIMGlobals, userUPP) CALL_TWO_PARAMETER_UPP((userUPP), uppSIMActionProcInfo, (scsiPB), (SIMGlobals))
  545. #endif
  546. #endif
  547. /*
  548. * InvokeSCSIUPP()
  549. *
  550. * Availability:
  551. * Non-Carbon CFM: available as macro/inline
  552. * CarbonLib: not available
  553. * Mac OS X: not available
  554. */
  555. EXTERN_API_C( void )
  556. InvokeSCSIUPP(SCSIUPP userUPP);
  557. #if !OPAQUE_UPP_TYPES
  558. #ifdef __cplusplus
  559. inline DEFINE_API_C(void) InvokeSCSIUPP(SCSIUPP userUPP) { CALL_ZERO_PARAMETER_UPP(userUPP, uppSCSIProcInfo); }
  560. #else
  561. #define InvokeSCSIUPP(userUPP) CALL_ZERO_PARAMETER_UPP((userUPP), uppSCSIProcInfo)
  562. #endif
  563. #endif
  564. /*
  565. * InvokeSCSIMakeCallbackUPP()
  566. *
  567. * Availability:
  568. * Non-Carbon CFM: available as macro/inline
  569. * CarbonLib: not available
  570. * Mac OS X: not available
  571. */
  572. EXTERN_API_C( void )
  573. InvokeSCSIMakeCallbackUPP(
  574. void * scsiPB,
  575. SCSIMakeCallbackUPP userUPP);
  576. #if !OPAQUE_UPP_TYPES
  577. #ifdef __cplusplus
  578. inline DEFINE_API_C(void) InvokeSCSIMakeCallbackUPP(void * scsiPB, SCSIMakeCallbackUPP userUPP) { CALL_ONE_PARAMETER_UPP(userUPP, uppSCSIMakeCallbackProcInfo, scsiPB); }
  579. #else
  580. #define InvokeSCSIMakeCallbackUPP(scsiPB, userUPP) CALL_ONE_PARAMETER_UPP((userUPP), uppSCSIMakeCallbackProcInfo, (scsiPB))
  581. #endif
  582. #endif
  583. /*
  584. * InvokeSCSIInterruptPollUPP()
  585. *
  586. * Availability:
  587. * Non-Carbon CFM: available as macro/inline
  588. * CarbonLib: not available
  589. * Mac OS X: not available
  590. */
  591. EXTERN_API_C( long )
  592. InvokeSCSIInterruptPollUPP(
  593. Ptr SIMGlobals,
  594. SCSIInterruptPollUPP userUPP);
  595. #if !OPAQUE_UPP_TYPES
  596. #ifdef __cplusplus
  597. inline DEFINE_API_C(long) InvokeSCSIInterruptPollUPP(Ptr SIMGlobals, SCSIInterruptPollUPP userUPP) { return (long)CALL_ONE_PARAMETER_UPP(userUPP, uppSCSIInterruptPollProcInfo, SIMGlobals); }
  598. #else
  599. #define InvokeSCSIInterruptPollUPP(SIMGlobals, userUPP) (long)CALL_ONE_PARAMETER_UPP((userUPP), uppSCSIInterruptPollProcInfo, (SIMGlobals))
  600. #endif
  601. #endif
  602. /*
  603. * InvokeSCSIInterruptUPP()
  604. *
  605. * Availability:
  606. * Non-Carbon CFM: available as macro/inline
  607. * CarbonLib: not available
  608. * Mac OS X: not available
  609. */
  610. EXTERN_API_C( long )
  611. InvokeSCSIInterruptUPP(
  612. Ptr SIMGlobals,
  613. SCSIInterruptUPP userUPP);
  614. #if !OPAQUE_UPP_TYPES
  615. #ifdef __cplusplus
  616. inline DEFINE_API_C(long) InvokeSCSIInterruptUPP(Ptr SIMGlobals, SCSIInterruptUPP userUPP) { return (long)CALL_ONE_PARAMETER_UPP(userUPP, uppSCSIInterruptProcInfo, SIMGlobals); }
  617. #else
  618. #define InvokeSCSIInterruptUPP(SIMGlobals, userUPP) (long)CALL_ONE_PARAMETER_UPP((userUPP), uppSCSIInterruptProcInfo, (SIMGlobals))
  619. #endif
  620. #endif
  621. #endif /* CALL_NOT_IN_CARBON */
  622. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  623. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  624. #define NewAENCallbackProc(userRoutine) NewAENCallbackUPP(userRoutine)
  625. #define NewSIMInitProc(userRoutine) NewSIMInitUPP(userRoutine)
  626. #define NewSIMActionProc(userRoutine) NewSIMActionUPP(userRoutine)
  627. #define NewSCSIProc(userRoutine) NewSCSIUPP(userRoutine)
  628. #define NewSCSIMakeCallbackProc(userRoutine) NewSCSIMakeCallbackUPP(userRoutine)
  629. #define NewSCSIInterruptPollProc(userRoutine) NewSCSIInterruptPollUPP(userRoutine)
  630. #define NewSCSIInterruptProc(userRoutine) NewSCSIInterruptUPP(userRoutine)
  631. #define CallAENCallbackProc(userRoutine) InvokeAENCallbackUPP(userRoutine)
  632. #define CallSIMInitProc(userRoutine, SIMinfoPtr) InvokeSIMInitUPP(SIMinfoPtr, userRoutine)
  633. #define CallSIMActionProc(userRoutine, scsiPB, SIMGlobals) InvokeSIMActionUPP(scsiPB, SIMGlobals, userRoutine)
  634. #define CallSCSIProc(userRoutine) InvokeSCSIUPP(userRoutine)
  635. #define CallSCSIMakeCallbackProc(userRoutine, scsiPB) InvokeSCSIMakeCallbackUPP(scsiPB, userRoutine)
  636. #define CallSCSIInterruptPollProc(userRoutine, SIMGlobals) InvokeSCSIInterruptPollUPP(SIMGlobals, userRoutine)
  637. #define CallSCSIInterruptProc(userRoutine, SIMGlobals) InvokeSCSIInterruptUPP(SIMGlobals, userRoutine)
  638. #endif /* CALL_NOT_IN_CARBON */
  639. /*
  640. * SCSI Completion routine callback for SCSIAction.
  641. */
  642. typedef CALLBACK_API( void , SCSICallbackProcPtr )(void * scsiPB);
  643. typedef STACK_UPP_TYPE(SCSICallbackProcPtr) SCSICallbackUPP;
  644. /*
  645. * NewSCSICallbackUPP()
  646. *
  647. * Availability:
  648. * Non-Carbon CFM: available as macro/inline
  649. * CarbonLib: in CarbonLib 1.3 and later
  650. * Mac OS X: in version 10.0 and later
  651. */
  652. EXTERN_API_C( SCSICallbackUPP )
  653. NewSCSICallbackUPP(SCSICallbackProcPtr userRoutine);
  654. #if !OPAQUE_UPP_TYPES
  655. enum { uppSCSICallbackProcInfo = 0x000000C0 }; /* pascal no_return_value Func(4_bytes) */
  656. #ifdef __cplusplus
  657. inline DEFINE_API_C(SCSICallbackUPP) NewSCSICallbackUPP(SCSICallbackProcPtr userRoutine) { return (SCSICallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSICallbackProcInfo, GetCurrentArchitecture()); }
  658. #else
  659. #define NewSCSICallbackUPP(userRoutine) (SCSICallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSICallbackProcInfo, GetCurrentArchitecture())
  660. #endif
  661. #endif
  662. /*
  663. * DisposeSCSICallbackUPP()
  664. *
  665. * Availability:
  666. * Non-Carbon CFM: available as macro/inline
  667. * CarbonLib: in CarbonLib 1.3 and later
  668. * Mac OS X: in version 10.0 and later
  669. */
  670. EXTERN_API_C( void )
  671. DisposeSCSICallbackUPP(SCSICallbackUPP userUPP);
  672. #if !OPAQUE_UPP_TYPES
  673. #ifdef __cplusplus
  674. inline DEFINE_API_C(void) DisposeSCSICallbackUPP(SCSICallbackUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  675. #else
  676. #define DisposeSCSICallbackUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  677. #endif
  678. #endif
  679. /*
  680. * InvokeSCSICallbackUPP()
  681. *
  682. * Availability:
  683. * Non-Carbon CFM: available as macro/inline
  684. * CarbonLib: in CarbonLib 1.3 and later
  685. * Mac OS X: in version 10.0 and later
  686. */
  687. EXTERN_API_C( void )
  688. InvokeSCSICallbackUPP(
  689. void * scsiPB,
  690. SCSICallbackUPP userUPP);
  691. #if !OPAQUE_UPP_TYPES
  692. #ifdef __cplusplus
  693. inline DEFINE_API_C(void) InvokeSCSICallbackUPP(void * scsiPB, SCSICallbackUPP userUPP) { CALL_ONE_PARAMETER_UPP(userUPP, uppSCSICallbackProcInfo, scsiPB); }
  694. #else
  695. #define InvokeSCSICallbackUPP(scsiPB, userUPP) CALL_ONE_PARAMETER_UPP((userUPP), uppSCSICallbackProcInfo, (scsiPB))
  696. #endif
  697. #endif
  698. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  699. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  700. #define NewSCSICallbackProc(userRoutine) NewSCSICallbackUPP(userRoutine)
  701. #define CallSCSICallbackProc(userRoutine, scsiPB) InvokeSCSICallbackUPP(scsiPB, userRoutine)
  702. #endif /* CALL_NOT_IN_CARBON */
  703. /*
  704. SCSI Manager 4.3 function codes
  705. */
  706. enum {
  707. SCSINop = 0x00, /* Execute nothing */
  708. SCSIExecIO = 0x01, /* Execute the specified IO */
  709. SCSIBusInquiry = 0x03, /* Get parameters for entire path of HBAs */
  710. SCSIReleaseQ = 0x04, /* Release the frozen SIM queue for particular LUN */
  711. SCSIAbortCommand = 0x10, /* Abort the selected Control Block */
  712. SCSIResetBus = 0x11, /* Reset the SCSI bus */
  713. SCSIResetDevice = 0x12, /* Reset the SCSI device */
  714. SCSITerminateIO = 0x13 /* Terminate any pending IO */
  715. };
  716. /* Not available in Carbon on X */
  717. enum {
  718. SCSIGetVirtualIDInfo = 0x80, /* Find out which bus old ID is on */
  719. SCSILoadDriver = 0x82, /* Load a driver for a device ident */
  720. SCSIOldCall = 0x84, /* XPT->SIM private call for old-API */
  721. SCSICreateRefNumXref = 0x85, /* Register a DeviceIdent to drvr RefNum xref */
  722. SCSILookupRefNumXref = 0x86, /* Get DeviceIdent to drvr RefNum xref */
  723. SCSIRemoveRefNumXref = 0x87, /* Remove a DeviceIdent to drvr RefNum xref */
  724. SCSIRegisterWithNewXPT = 0x88 /* XPT has changed - SIM needs to re-register itself */
  725. };
  726. enum {
  727. vendorUnique = 0xC0 /* 0xC0 thru 0xFF */
  728. };
  729. /* Allocation length defines for some of the fields */
  730. enum {
  731. handshakeDataLength = 8, /* Handshake data length */
  732. maxCDBLength = 16, /* Space for the CDB bytes/pointer */
  733. vendorIDLength = 16 /* ASCII string len for Vendor ID */
  734. };
  735. /* Define DeviceIdent structure */
  736. struct DeviceIdent {
  737. UInt8 diReserved; /* reserved */
  738. UInt8 bus; /* SCSI - Bus Number */
  739. UInt8 targetID; /* SCSI - Target SCSI ID */
  740. UInt8 LUN; /* SCSI - LUN */
  741. };
  742. typedef struct DeviceIdent DeviceIdent;
  743. /* Constants for the diReserved field of DeviceIdent */
  744. /* used to distinguish whether the DeviceIdent holds */
  745. /* information about a SCSI device (kBusTypeSCSI) */
  746. /* or an ATA device (kBusTypeATA). The other */
  747. /* constants are pretty much deprecated. Let me */
  748. /* know if you see any. */
  749. enum {
  750. kBusTypeSCSI = 0,
  751. kBusTypeATA = 1,
  752. kBusTypePCMCIA = 2,
  753. kBusTypeMediaBay = 3
  754. };
  755. /* If diReserved indicates that a DeviceIdent is */
  756. /* really for ATA, you can cast it to DeviceIdentATA */
  757. /* to get at the important fields. */
  758. struct DeviceIdentATA {
  759. UInt8 diReserved;
  760. UInt8 busNum;
  761. UInt8 devNum;
  762. UInt8 diReserved2;
  763. };
  764. typedef struct DeviceIdentATA DeviceIdentATA;
  765. /* for use with Apple Patch Driver used during booting*/
  766. struct PatchDescriptor {
  767. OSType patchSig; /* The patches signature */
  768. UInt16 majorVers; /* The major version number of the */
  769. /* patch */
  770. UInt16 minorVers; /* The minor version number of the */
  771. /* patch */
  772. UInt32 flags; /* Reqired/Optional, etc. */
  773. UInt32 patchOffset; /* Block offset to the beginning of */
  774. /* the patch */
  775. UInt32 patchSize; /* Actual size of the patch in bytes */
  776. UInt32 patchCRC; /* As calculated by the SCSI drivers */
  777. /* CRC code */
  778. UInt32 patchDescriptorLen; /* Total length of the descriptor */
  779. /* (must be >= 61 bytes) */
  780. Str32 patchName; /* Pascal string with a short */
  781. /* description of the patch */
  782. UInt8 patchVendor[1]; /* The first byte of a pascal string */
  783. /* for the patch Vendor. Any amount */
  784. /* of data may follow the string. */
  785. };
  786. typedef struct PatchDescriptor PatchDescriptor;
  787. /* Constants for the flags field of PatchDescriptor. */
  788. enum {
  789. kRequiredPatch = 0x00000001 /* Patch must succeed to continue booting. */
  790. };
  791. struct PatchList {
  792. UInt16 numPatchBlocks; /* The number of disk blocks */
  793. /* to hold patch descriptions */
  794. UInt16 numPatches; /* The number of patches */
  795. PatchDescriptor thePatch[1]; /* An array with one patch */
  796. /* per element */
  797. };
  798. typedef struct PatchList PatchList;
  799. /* signature of a Patch entry point*/
  800. typedef CALLBACK_API( OSErr , PatchEntryPoint )(PatchDescriptor *myPatch, DeviceIdent myDevID);
  801. /* Command Descriptor Block structure */
  802. union CDB {
  803. BytePtr cdbPtr; /* pointer to the CDB, or */
  804. UInt8 cdbBytes[16]; /* the actual CDB to send */
  805. };
  806. typedef union CDB CDB;
  807. typedef CDB * CDBPtr;
  808. /* Scatter/gather list element (Deprecated for MacOS8) */
  809. struct SGRecord {
  810. Ptr SGAddr;
  811. UInt32 SGCount;
  812. };
  813. typedef struct SGRecord SGRecord;
  814. #define SCSIPBHdr \
  815. struct SCSIHdr* qLink; \
  816. short scsiReserved1; \
  817. UInt16 scsiPBLength; \
  818. UInt8 scsiFunctionCode; \
  819. UInt8 scsiReserved2; \
  820. volatile OSErr scsiResult; \
  821. DeviceIdent scsiDevice; \
  822. SCSICallbackUPP scsiCompletion; \
  823. UInt32 scsiFlags; \
  824. UInt8 * scsiDriverStorage; \
  825. Ptr scsiXPTprivate; \
  826. long scsiReserved3;
  827. struct SCSIHdr {
  828. struct SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  829. short scsiReserved1; /* -> reserved for input */
  830. UInt16 scsiPBLength; /* -> Length of the entire PB */
  831. UInt8 scsiFunctionCode; /* -> function selector */
  832. UInt8 scsiReserved2; /* <- reserved for output */
  833. volatile OSErr scsiResult; /* <- Returned result */
  834. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  835. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  836. UInt32 scsiFlags; /* -> assorted flags */
  837. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  838. Ptr scsiXPTprivate; /* private field for use in XPT */
  839. long scsiReserved3; /* reserved */
  840. };
  841. typedef struct SCSIHdr SCSIHdr;
  842. struct SCSI_PB {
  843. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  844. short scsiReserved1; /* -> reserved for input */
  845. UInt16 scsiPBLength; /* -> Length of the entire PB */
  846. UInt8 scsiFunctionCode; /* -> function selector */
  847. UInt8 scsiReserved2; /* <- reserved for output */
  848. volatile OSErr scsiResult; /* <- Returned result */
  849. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  850. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  851. UInt32 scsiFlags; /* -> assorted flags */
  852. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  853. Ptr scsiXPTprivate; /* private field for use in XPT */
  854. long scsiReserved3; /* reserved */
  855. };
  856. typedef struct SCSI_PB SCSI_PB;
  857. struct SCSI_IO {
  858. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  859. short scsiReserved1; /* -> reserved for input */
  860. UInt16 scsiPBLength; /* -> Length of the entire PB */
  861. UInt8 scsiFunctionCode; /* -> function selector */
  862. UInt8 scsiReserved2; /* <- reserved for output */
  863. volatile OSErr scsiResult; /* <- Returned result */
  864. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  865. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  866. UInt32 scsiFlags; /* -> assorted flags */
  867. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  868. Ptr scsiXPTprivate; /* private field for use in XPT */
  869. long scsiReserved3; /* reserved */
  870. UInt16 scsiResultFlags; /* <- Flags which modify the scsiResult field */
  871. UInt16 scsiReserved3pt5; /* -> Reserved */
  872. BytePtr scsiDataPtr; /* -> Pointer to the data buffer or the S/G list */
  873. UInt32 scsiDataLength; /* -> Data transfer length */
  874. BytePtr scsiSensePtr; /* -> Ptr to autosense data buffer */
  875. UInt8 scsiSenseLength; /* -> size of the autosense buffer */
  876. UInt8 scsiCDBLength; /* -> Number of bytes for the CDB */
  877. UInt16 scsiSGListCount; /* -> num of scatter gather list entries */
  878. UInt32 scsiReserved4; /* <- reserved for output */
  879. UInt8 scsiSCSIstatus; /* <- Returned scsi device status */
  880. SInt8 scsiSenseResidual; /* <- Autosense residual length */
  881. UInt16 scsiReserved5; /* <- reserved for output */
  882. long scsiDataResidual; /* <- Returned Transfer residual length */
  883. CDB scsiCDB; /* -> Actual CDB or pointer to CDB */
  884. long scsiTimeout; /* -> Timeout value (Time Mgr format) (CAM timeout) */
  885. BytePtr scsiReserved5pt5; /* -> Reserved */
  886. UInt16 scsiReserved5pt6; /* -> Reserved */
  887. UInt16 scsiIOFlags; /* -> additional I/O flags */
  888. UInt8 scsiTagAction; /* -> What to do for tag queuing */
  889. UInt8 scsiReserved6; /* -> reserved for input */
  890. UInt16 scsiReserved7; /* -> reserved for input */
  891. UInt16 scsiSelectTimeout; /* -> Select timeout value */
  892. UInt8 scsiDataType; /* -> Data description type (i.e. buffer, TIB, S/G) */
  893. UInt8 scsiTransferType; /* -> Transfer type (i.e. Blind vs Polled) */
  894. UInt32 scsiReserved8; /* -> reserved for input */
  895. UInt32 scsiReserved9; /* -> reserved for input */
  896. UInt16 scsiHandshake[8]; /* -> handshaking points (null term'd) */
  897. UInt32 scsiReserved10; /* -> reserved for input */
  898. UInt32 scsiReserved11; /* -> reserved for input */
  899. struct SCSI_IO * scsiCommandLink; /* -> Ptr to the next PB in linked cmd chain */
  900. UInt8 scsiSIMpublics[8]; /* -> reserved for input to 3rd-party SIMs */
  901. UInt8 scsiAppleReserved6[8]; /* -> reserved for input */
  902. /* XPT layer privates (for old-API emulation) */
  903. UInt16 scsiCurrentPhase; /* <- phase upon completing old call */
  904. short scsiSelector; /* -> selector specified in old calls */
  905. OSErr scsiOldCallResult; /* <- result of old call */
  906. UInt8 scsiSCSImessage; /* <- Returned scsi device message (for SCSIComplete)*/
  907. UInt8 XPTprivateFlags; /* <> various flags */
  908. UInt8 XPTextras[12]; /* */
  909. };
  910. typedef struct SCSI_IO SCSI_IO;
  911. typedef SCSI_IO SCSIExecIOPB;
  912. /* Bus inquiry PB */
  913. struct SCSIBusInquiryPB {
  914. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  915. short scsiReserved1; /* -> reserved for input */
  916. UInt16 scsiPBLength; /* -> Length of the entire PB */
  917. UInt8 scsiFunctionCode; /* -> function selector */
  918. UInt8 scsiReserved2; /* <- reserved for output */
  919. volatile OSErr scsiResult; /* <- Returned result */
  920. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  921. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  922. UInt32 scsiFlags; /* -> assorted flags */
  923. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  924. Ptr scsiXPTprivate; /* private field for use in XPT */
  925. long scsiReserved3; /* reserved */
  926. UInt16 scsiEngineCount; /* <- Number of engines on HBA */
  927. UInt16 scsiMaxTransferType; /* <- Number of transfer types for this HBA */
  928. UInt32 scsiDataTypes; /* <- which data types are supported by this SIM */
  929. UInt16 scsiIOpbSize; /* <- Size of SCSI_IO PB for this SIM/HBA */
  930. UInt16 scsiMaxIOpbSize; /* <- Size of max SCSI_IO PB for all SIM/HBAs */
  931. UInt32 scsiFeatureFlags; /* <- Supported features flags field */
  932. UInt8 scsiVersionNumber; /* <- Version number for the SIM/HBA */
  933. UInt8 scsiHBAInquiry; /* <- Mimic of INQ byte 7 for the HBA */
  934. UInt8 scsiTargetModeFlags; /* <- Flags for target mode support */
  935. UInt8 scsiScanFlags; /* <- Scan related feature flags */
  936. UInt32 scsiSIMPrivatesPtr; /* <- Ptr to SIM private data area */
  937. UInt32 scsiSIMPrivatesSize; /* <- Size of SIM private data area */
  938. UInt32 scsiAsyncFlags; /* <- Event cap. for Async Callback */
  939. UInt8 scsiHiBusID; /* <- Highest path ID in the subsystem */
  940. UInt8 scsiInitiatorID; /* <- ID of the HBA on the SCSI bus */
  941. UInt16 scsiBIReserved0; /* */
  942. UInt32 scsiBIReserved1; /* <- */
  943. UInt32 scsiFlagsSupported; /* <- which scsiFlags are supported */
  944. UInt16 scsiIOFlagsSupported; /* <- which scsiIOFlags are supported */
  945. UInt16 scsiWeirdStuff; /* <- */
  946. UInt16 scsiMaxTarget; /* <- maximum Target number supported */
  947. UInt16 scsiMaxLUN; /* <- maximum Logical Unit number supported */
  948. char scsiSIMVendor[16]; /* <- Vendor ID of SIM (or XPT if bus<FF) */
  949. char scsiHBAVendor[16]; /* <- Vendor ID of the HBA */
  950. char scsiControllerFamily[16]; /* <- Family of SCSI Controller */
  951. char scsiControllerType[16]; /* <- Specific Model of SCSI Controller used */
  952. char scsiXPTversion[4]; /* <- version number of XPT */
  953. char scsiSIMversion[4]; /* <- version number of SIM */
  954. char scsiHBAversion[4]; /* <- version number of HBA */
  955. UInt8 scsiHBAslotType; /* <- type of "slot" that this HBA is in */
  956. UInt8 scsiHBAslotNumber; /* <- slot number of this HBA */
  957. UInt16 scsiSIMsRsrcID; /* <- resource ID of this SIM */
  958. UInt16 scsiBIReserved3; /* <- */
  959. UInt16 scsiAdditionalLength; /* <- additional BusInquiry PB len */
  960. };
  961. typedef struct SCSIBusInquiryPB SCSIBusInquiryPB;
  962. /* Abort SIM Request PB */
  963. struct SCSIAbortCommandPB {
  964. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  965. short scsiReserved1; /* -> reserved for input */
  966. UInt16 scsiPBLength; /* -> Length of the entire PB */
  967. UInt8 scsiFunctionCode; /* -> function selector */
  968. UInt8 scsiReserved2; /* <- reserved for output */
  969. volatile OSErr scsiResult; /* <- Returned result */
  970. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  971. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  972. UInt32 scsiFlags; /* -> assorted flags */
  973. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  974. Ptr scsiXPTprivate; /* private field for use in XPT */
  975. long scsiReserved3; /* reserved */
  976. SCSI_IO * scsiIOptr; /* Pointer to the PB to abort */
  977. };
  978. typedef struct SCSIAbortCommandPB SCSIAbortCommandPB;
  979. /* Terminate I/O Process Request PB */
  980. struct SCSITerminateIOPB {
  981. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  982. short scsiReserved1; /* -> reserved for input */
  983. UInt16 scsiPBLength; /* -> Length of the entire PB */
  984. UInt8 scsiFunctionCode; /* -> function selector */
  985. UInt8 scsiReserved2; /* <- reserved for output */
  986. volatile OSErr scsiResult; /* <- Returned result */
  987. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  988. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  989. UInt32 scsiFlags; /* -> assorted flags */
  990. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  991. Ptr scsiXPTprivate; /* private field for use in XPT */
  992. long scsiReserved3; /* reserved */
  993. SCSI_IO * scsiIOptr; /* Pointer to the PB to terminate */
  994. };
  995. typedef struct SCSITerminateIOPB SCSITerminateIOPB;
  996. /* Reset SCSI Bus PB */
  997. struct SCSIResetBusPB {
  998. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  999. short scsiReserved1; /* -> reserved for input */
  1000. UInt16 scsiPBLength; /* -> Length of the entire PB */
  1001. UInt8 scsiFunctionCode; /* -> function selector */
  1002. UInt8 scsiReserved2; /* <- reserved for output */
  1003. volatile OSErr scsiResult; /* <- Returned result */
  1004. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  1005. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  1006. UInt32 scsiFlags; /* -> assorted flags */
  1007. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  1008. Ptr scsiXPTprivate; /* private field for use in XPT */
  1009. long scsiReserved3; /* reserved */
  1010. };
  1011. typedef struct SCSIResetBusPB SCSIResetBusPB;
  1012. /* Reset SCSI Device PB */
  1013. struct SCSIResetDevicePB {
  1014. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  1015. short scsiReserved1; /* -> reserved for input */
  1016. UInt16 scsiPBLength; /* -> Length of the entire PB */
  1017. UInt8 scsiFunctionCode; /* -> function selector */
  1018. UInt8 scsiReserved2; /* <- reserved for output */
  1019. volatile OSErr scsiResult; /* <- Returned result */
  1020. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  1021. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  1022. UInt32 scsiFlags; /* -> assorted flags */
  1023. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  1024. Ptr scsiXPTprivate; /* private field for use in XPT */
  1025. long scsiReserved3; /* reserved */
  1026. };
  1027. typedef struct SCSIResetDevicePB SCSIResetDevicePB;
  1028. /* Release SIM Queue PB */
  1029. struct SCSIReleaseQPB {
  1030. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  1031. short scsiReserved1; /* -> reserved for input */
  1032. UInt16 scsiPBLength; /* -> Length of the entire PB */
  1033. UInt8 scsiFunctionCode; /* -> function selector */
  1034. UInt8 scsiReserved2; /* <- reserved for output */
  1035. volatile OSErr scsiResult; /* <- Returned result */
  1036. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  1037. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  1038. UInt32 scsiFlags; /* -> assorted flags */
  1039. BytePtr scsiDriverStorage; /* <> Ptr for driver private use */
  1040. Ptr scsiXPTprivate; /* private field for use in XPT */
  1041. long scsiReserved3; /* reserved */
  1042. };
  1043. typedef struct SCSIReleaseQPB SCSIReleaseQPB;
  1044. /* SCSI Get Virtual ID Info PB */
  1045. struct SCSIGetVirtualIDInfoPB {
  1046. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  1047. short scsiReserved1; /* -> reserved for input */
  1048. UInt16 scsiPBLength; /* -> Length of the entire PB */
  1049. UInt8 scsiFunctionCode; /* -> function selector */
  1050. UInt8 scsiReserved2; /* <- reserved for output */
  1051. volatile OSErr scsiResult; /* <- Returned result */
  1052. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  1053. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  1054. UInt32 scsiFlags; /* -> assorted flags */
  1055. Ptr scsiDriverStorage; /* <> Ptr for driver private use */
  1056. Ptr scsiXPTprivate; /* private field for use in XPT */
  1057. long scsiReserved3; /* reserved */
  1058. UInt16 scsiOldCallID; /* -> SCSI ID of device in question */
  1059. Boolean scsiExists; /* <- true if device exists */
  1060. SInt8 filler;
  1061. };
  1062. typedef struct SCSIGetVirtualIDInfoPB SCSIGetVirtualIDInfoPB;
  1063. /* Create/Lookup/Remove RefNum for Device PB */
  1064. struct SCSIDriverPB {
  1065. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  1066. short scsiReserved1; /* -> reserved for input */
  1067. UInt16 scsiPBLength; /* -> Length of the entire PB */
  1068. UInt8 scsiFunctionCode; /* -> function selector */
  1069. UInt8 scsiReserved2; /* <- reserved for output */
  1070. volatile OSErr scsiResult; /* <- Returned result */
  1071. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  1072. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  1073. UInt32 scsiFlags; /* -> assorted flags */
  1074. Ptr scsiDriverStorage; /* <> Ptr for driver private use */
  1075. Ptr scsiXPTprivate; /* private field for use in XPT */
  1076. long scsiReserved3; /* reserved */
  1077. short scsiDriver; /* -> DriverRefNum, For SetDriver, <- For GetNextDriver */
  1078. UInt16 scsiDriverFlags; /* <> Details of driver/device */
  1079. DeviceIdent scsiNextDevice; /* <- DeviceIdent of the NEXT Item in the list */
  1080. };
  1081. typedef struct SCSIDriverPB SCSIDriverPB;
  1082. /* Load Driver PB */
  1083. struct SCSILoadDriverPB {
  1084. SCSIHdr * qLink; /* (internal use, must be nil on entry) */
  1085. short scsiReserved1; /* -> reserved for input */
  1086. UInt16 scsiPBLength; /* -> Length of the entire PB */
  1087. UInt8 scsiFunctionCode; /* -> function selector */
  1088. UInt8 scsiReserved2; /* <- reserved for output */
  1089. volatile OSErr scsiResult; /* <- Returned result */
  1090. DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/
  1091. SCSICallbackUPP scsiCompletion; /* -> Callback on completion function */
  1092. UInt32 scsiFlags; /* -> assorted flags */
  1093. Ptr scsiDriverStorage; /* <> Ptr for driver private use */
  1094. Ptr scsiXPTprivate; /* private field for use in XPT */
  1095. long scsiReserved3; /* reserved */
  1096. short scsiLoadedRefNum; /* <- SIM returns refnum of driver */
  1097. Boolean scsiDiskLoadFailed; /* -> if true, indicates call after failure to load */
  1098. SInt8 filler;
  1099. };
  1100. typedef struct SCSILoadDriverPB SCSILoadDriverPB;
  1101. /* Defines for the scsiTransferType field */
  1102. enum {
  1103. scsiTransferBlind = 0,
  1104. scsiTransferPolled = 1
  1105. };
  1106. enum {
  1107. scsiErrorBase = -7936
  1108. };
  1109. enum {
  1110. scsiRequestInProgress = 1, /* 1 = PB request is in progress */
  1111. /* Execution failed 00-2F */
  1112. scsiRequestAborted = scsiErrorBase + 2, /* -7934 = PB request aborted by the host */
  1113. scsiUnableToAbort = scsiErrorBase + 3, /* -7933 = Unable to Abort PB request */
  1114. scsiNonZeroStatus = scsiErrorBase + 4, /* -7932 = PB request completed with an err */
  1115. scsiUnused05 = scsiErrorBase + 5, /* -7931 = */
  1116. scsiUnused06 = scsiErrorBase + 6, /* -7930 = */
  1117. scsiUnused07 = scsiErrorBase + 7, /* -7929 = */
  1118. scsiUnused08 = scsiErrorBase + 8, /* -7928 = */
  1119. scsiUnableToTerminate = scsiErrorBase + 9, /* -7927 = Unable to Terminate I/O PB req */
  1120. scsiSelectTimeout = scsiErrorBase + 10, /* -7926 = Target selection timeout */
  1121. scsiCommandTimeout = scsiErrorBase + 11, /* -7925 = Command timeout */
  1122. scsiIdentifyMessageRejected = scsiErrorBase + 12, /* -7924 = */
  1123. scsiMessageRejectReceived = scsiErrorBase + 13, /* -7923 = Message reject received */
  1124. scsiSCSIBusReset = scsiErrorBase + 14, /* -7922 = SCSI bus reset sent/received */
  1125. scsiParityError = scsiErrorBase + 15, /* -7921 = Uncorrectable parity error occured */
  1126. scsiAutosenseFailed = scsiErrorBase + 16, /* -7920 = Autosense: Request sense cmd fail */
  1127. scsiUnused11 = scsiErrorBase + 17, /* -7919 = */
  1128. scsiDataRunError = scsiErrorBase + 18, /* -7918 = Data overrun/underrun error */
  1129. scsiUnexpectedBusFree = scsiErrorBase + 19, /* -7917 = Unexpected BUS free */
  1130. scsiSequenceFailed = scsiErrorBase + 20, /* -7916 = Target bus phase sequence failure */
  1131. scsiWrongDirection = scsiErrorBase + 21, /* -7915 = Data phase was in wrong direction */
  1132. scsiUnused16 = scsiErrorBase + 22, /* -7914 = */
  1133. scsiBDRsent = scsiErrorBase + 23, /* -7913 = A SCSI BDR msg was sent to target */
  1134. scsiTerminated = scsiErrorBase + 24, /* -7912 = PB request terminated by the host */
  1135. scsiNoNexus = scsiErrorBase + 25, /* -7911 = Nexus is not established */
  1136. scsiCDBReceived = scsiErrorBase + 26, /* -7910 = The SCSI CDB has been received */
  1137. /* Couldn't begin execution 30-3F */
  1138. scsiTooManyBuses = scsiErrorBase + 48, /* -7888 = Register failed because we're full */
  1139. scsiBusy = scsiErrorBase + 49, /* -7887 = SCSI subsystem is busy */
  1140. scsiProvideFail = scsiErrorBase + 50, /* -7886 = Unable to provide requ. capability */
  1141. scsiDeviceNotThere = scsiErrorBase + 51, /* -7885 = SCSI device not installed/there */
  1142. scsiNoHBA = scsiErrorBase + 52, /* -7884 = No HBA detected Error */
  1143. scsiDeviceConflict = scsiErrorBase + 53, /* -7883 = sorry, max 1 refNum per DeviceIdent */
  1144. scsiNoSuchXref = scsiErrorBase + 54, /* -7882 = no such RefNum xref */
  1145. scsiQLinkInvalid = scsiErrorBase + 55, /* -7881 = pre-linked PBs not supported */
  1146. /* (The QLink field was nonzero) */
  1147. /* Parameter errors 40-7F */
  1148. scsiPBLengthError = scsiErrorBase + 64, /* -7872 = (scsiPBLength is insuf'ct/invalid */
  1149. scsiFunctionNotAvailable = scsiErrorBase + 65, /* -7871 = The requ. func is not available */
  1150. scsiRequestInvalid = scsiErrorBase + 66, /* -7870 = PB request is invalid */
  1151. scsiBusInvalid = scsiErrorBase + 67, /* -7869 = Bus ID supplied is invalid */
  1152. scsiTIDInvalid = scsiErrorBase + 68, /* -7868 = Target ID supplied is invalid */
  1153. scsiLUNInvalid = scsiErrorBase + 69, /* -7867 = LUN supplied is invalid */
  1154. scsiIDInvalid = scsiErrorBase + 70, /* -7866 = The initiator ID is invalid */
  1155. scsiDataTypeInvalid = scsiErrorBase + 71, /* -7865 = scsiDataType requested not supported */
  1156. scsiTransferTypeInvalid = scsiErrorBase + 72, /* -7864 = scsiTransferType field is too high */
  1157. scsiCDBLengthInvalid = scsiErrorBase + 73 /* -7863 = scsiCDBLength field is too big */
  1158. };
  1159. /* New errors for SCSI Family */
  1160. enum {
  1161. scsiUnused74 = scsiErrorBase + 74, /* -7862 = */
  1162. scsiUnused75 = scsiErrorBase + 75, /* -7861 = */
  1163. scsiBadDataLength = scsiErrorBase + 76, /* -7860 = a zero data length in PB */
  1164. scsiPartialPrepared = scsiErrorBase + 77, /* -7859 = could not do full prepare mem for I/O*/
  1165. scsiInvalidMsgType = scsiErrorBase + 78, /* -7858 = Invalid message type (internal) */
  1166. scsiUnused79 = scsiErrorBase + 79, /* -7857 = */
  1167. scsiBadConnID = scsiErrorBase + 80, /* -7856 = Bad Connection ID */
  1168. scsiUnused81 = scsiErrorBase + 81, /* -7855 = */
  1169. scsiIOInProgress = scsiErrorBase + 82, /* -7854 = Can't close conn, IO in prog */
  1170. scsiTargetReserved = scsiErrorBase + 83, /* -7853 = Target already reserved */
  1171. scsiUnused84 = scsiErrorBase + 84, /* -7852 = */
  1172. scsiUnused85 = scsiErrorBase + 85, /* -7851 = */
  1173. scsiBadConnType = scsiErrorBase + 86, /* -7850 = Bad connection type */
  1174. scsiCannotLoadPlugin = scsiErrorBase + 87 /* -7849 = No matching service category */
  1175. };
  1176. /* +++ */
  1177. /*
  1178. * scsiFamilyInternalError and scsiPluginInternalError are intended to handle consistency check failures.
  1179. * For example, if the family stores a record on a lookaside queue, but does not find that record
  1180. * it can use this error to report this failure. SCSI Manager 4.3 uses dsIOCoreErr in a few places,
  1181. * but this is probably not the best error. In general, internal errors should be reported as bugs.
  1182. *
  1183. * The following range of errors is provided for third-party (non-Apple) SCSI SIM and device driver vendors.
  1184. * In general, they would be used for error conditions that are not covered by the standardized errors.
  1185. * They should not normally be conveyed to normal applications, but might be used for communication between
  1186. * a plug-in and a vendor-provided device driver (for example, to manage RAID hot-swapping).
  1187. *
  1188. * Note: I don't know how many SCSI errors are reserved in the error code architecture. Don't assume that
  1189. * we'll actually get sixteen, but we should reserve at least one.
  1190. */
  1191. enum {
  1192. scsiFamilyInternalError = scsiErrorBase + 87, /* -7849 = Internal consistency check failed */
  1193. scsiPluginInternalError = scsiErrorBase + 88, /* -7848 = Internal consistency check failed */
  1194. scsiVendorSpecificErrorBase = scsiErrorBase + 128, /* ?? = Start of third-party error range */
  1195. scsiVendorSpecificErrorCount = 16 /* Number of third-party errors */
  1196. };
  1197. /* --- */
  1198. enum {
  1199. scsiExecutionErrors = scsiErrorBase,
  1200. scsiNotExecutedErrors = scsiTooManyBuses,
  1201. scsiParameterErrors = scsiPBLengthError
  1202. };
  1203. /* Defines for the scsiResultFlags field */
  1204. enum {
  1205. scsiSIMQFrozen = 0x0001, /* The SIM queue is frozen w/this err */
  1206. scsiAutosenseValid = 0x0002, /* Autosense data valid for target */
  1207. scsiBusNotFree = 0x0004 /* At time of callback, SCSI bus is not free */
  1208. };
  1209. /* Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function */
  1210. enum {
  1211. kbSCSIDisableAutosense = 29, /* Disable auto sense feature */
  1212. kbSCSIFlagReservedA = 28, /* */
  1213. kbSCSIFlagReserved0 = 27, /* */
  1214. kbSCSICDBLinked = 26, /* The PB contains a linked CDB */
  1215. kbSCSIQEnable = 25, /* Target queue actions are enabled */
  1216. kbSCSICDBIsPointer = 24, /* The CDB field contains a pointer */
  1217. kbSCSIFlagReserved1 = 23, /* */
  1218. kbSCSIInitiateSyncData = 22, /* Attempt Sync data xfer and SDTR */
  1219. kbSCSIDisableSyncData = 21, /* Disable sync, go to async */
  1220. kbSCSISIMQHead = 20, /* Place PB at the head of SIM Q */
  1221. kbSCSISIMQFreeze = 19, /* Return the SIM Q to frozen state */
  1222. kbSCSISIMQNoFreeze = 18, /* Disallow SIM Q freezing */
  1223. kbSCSIDoDisconnect = 17, /* Definitely do disconnect */
  1224. kbSCSIDontDisconnect = 16, /* Definitely don't disconnect */
  1225. kbSCSIDataReadyForDMA = 15, /* Data buffer(s) are ready for DMA */
  1226. kbSCSIFlagReserved3 = 14, /* */
  1227. kbSCSIDataPhysical = 13, /* SG/Buffer data ptrs are physical */
  1228. kbSCSISensePhysical = 12, /* Autosense buffer ptr is physical */
  1229. kbSCSIFlagReserved5 = 11, /* */
  1230. kbSCSIFlagReserved6 = 10, /* */
  1231. kbSCSIFlagReserved7 = 9, /* */
  1232. kbSCSIFlagReserved8 = 8, /* */
  1233. kbSCSIDataBufferValid = 7, /* Data buffer valid */
  1234. kbSCSIStatusBufferValid = 6, /* Status buffer valid */
  1235. kbSCSIMessageBufferValid = 5, /* Message buffer valid */
  1236. kbSCSIFlagReserved9 = 4 /* */
  1237. };
  1238. /* Defines for the bit masks of the scsiFlags field */
  1239. enum {
  1240. scsiDirectionMask = (long)0xC0000000, /* Data direction mask */
  1241. scsiDirectionNone = (long)0xC0000000, /* Data direction (11: no data) */
  1242. scsiDirectionReserved = 0x00000000, /* Data direction (00: reserved) */
  1243. scsiDirectionOut = (long)0x80000000, /* Data direction (10: DATA OUT) */
  1244. scsiDirectionIn = 0x40000000, /* Data direction (01: DATA IN) */
  1245. scsiDisableAutosense = 0x20000000, /* Disable auto sense feature */
  1246. scsiFlagReservedA = 0x10000000, /* */
  1247. scsiFlagReserved0 = 0x08000000, /* */
  1248. scsiCDBLinked = 0x04000000, /* The PB contains a linked CDB */
  1249. scsiQEnable = 0x02000000, /* Target queue actions are enabled */
  1250. scsiCDBIsPointer = 0x01000000, /* The CDB field contains a pointer */
  1251. scsiFlagReserved1 = 0x00800000, /* */
  1252. scsiInitiateSyncData = 0x00400000, /* Attempt Sync data xfer and SDTR */
  1253. scsiDisableSyncData = 0x00200000, /* Disable sync, go to async */
  1254. scsiSIMQHead = 0x00100000, /* Place PB at the head of SIM Q */
  1255. scsiSIMQFreeze = 0x00080000, /* Return the SIM Q to frozen state */
  1256. scsiSIMQNoFreeze = 0x00040000, /* Disallow SIM Q freezing */
  1257. scsiDoDisconnect = 0x00020000, /* Definitely do disconnect */
  1258. scsiDontDisconnect = 0x00010000, /* Definitely don't disconnect */
  1259. scsiDataReadyForDMA = 0x00008000, /* Data buffer(s) are ready for DMA */
  1260. scsiFlagReserved3 = 0x00004000, /* */
  1261. scsiDataPhysical = 0x00002000, /* SG/Buffer data ptrs are physical */
  1262. scsiSensePhysical = 0x00001000, /* Autosense buffer ptr is physical */
  1263. scsiFlagReserved5 = 0x00000800, /* */
  1264. scsiFlagReserved6 = 0x00000400, /* */
  1265. scsiFlagReserved7 = 0x00000200, /* */
  1266. scsiFlagReserved8 = 0x00000100 /* */
  1267. };
  1268. /* bit masks for the scsiIOFlags field in SCSIExecIOPB */
  1269. enum {
  1270. scsiNoParityCheck = 0x0002, /* disable parity checking */
  1271. scsiDisableSelectWAtn = 0x0004, /* disable select w/Atn */
  1272. scsiSavePtrOnDisconnect = 0x0008, /* do SaveDataPointer upon Disconnect msg */
  1273. scsiNoBucketIn = 0x0010, /* don't bit bucket in during this I/O */
  1274. scsiNoBucketOut = 0x0020, /* don't bit bucket out during this I/O */
  1275. scsiDisableWide = 0x0040, /* disable wide transfer negotiation */
  1276. scsiInitiateWide = 0x0080, /* initiate wide transfer negotiation */
  1277. scsiRenegotiateSense = 0x0100, /* renegotiate sync/wide before issuing autosense */
  1278. scsiDisableDiscipline = 0x0200, /* disable parameter checking on SCSIExecIO calls */
  1279. scsiIOFlagReserved0080 = 0x0080, /* */
  1280. scsiIOFlagReserved8000 = 0x8000 /* */
  1281. };
  1282. /* Defines for the Bus Inquiry PB fields. */
  1283. /* scsiHBAInquiry field bits */
  1284. enum {
  1285. scsiBusMDP = 0x80, /* Supports Modify Data Pointer message */
  1286. scsiBusWide32 = 0x40, /* Supports 32 bit wide SCSI */
  1287. scsiBusWide16 = 0x20, /* Supports 16 bit wide SCSI */
  1288. scsiBusSDTR = 0x10, /* Supports Sync Data Transfer Req message */
  1289. scsiBusLinkedCDB = 0x08, /* Supports linked CDBs */
  1290. scsiBusTagQ = 0x02, /* Supports tag queue message */
  1291. scsiBusSoftReset = 0x01 /* Supports soft reset */
  1292. };
  1293. /* Defines for the scsiDataType field */
  1294. enum {
  1295. scsiDataBuffer = 0, /* single contiguous buffer supplied */
  1296. scsiDataTIB = 1, /* TIB supplied (ptr in scsiDataPtr) */
  1297. scsiDataSG = 2, /* scatter/gather list supplied */
  1298. scsiDataIOTable = 3 /*#(7/11/95) Prepared by Block Storage */
  1299. };
  1300. /* scsiDataTypes field bits */
  1301. /* bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved */
  1302. enum {
  1303. scsiBusDataTIB = (1 << scsiDataTIB), /* TIB supplied (ptr in scsiDataPtr) */
  1304. scsiBusDataBuffer = (1 << scsiDataBuffer), /* single contiguous buffer supplied */
  1305. scsiBusDataSG = (1 << scsiDataSG), /* scatter/gather list supplied */
  1306. scsiBusDataIOTable = (1 << scsiDataIOTable), /* (2/6/95) Prepare Memory for IO*/
  1307. scsiBusDataReserved = (long)0x80000000 /* */
  1308. };
  1309. /* scsiScanFlags field bits */
  1310. enum {
  1311. scsiBusScansDevices = 0x80, /* Bus scans for and maintains device list */
  1312. scsiBusScansOnInit = 0x40, /* Bus scans performed at power-up/reboot */
  1313. scsiBusLoadsROMDrivers = 0x20 /* may load ROM drivers to support targets */
  1314. };
  1315. /* scsiFeatureFlags field bits */
  1316. enum {
  1317. scsiBusLVD = 0x00000400, /* HBA is Low Voltage Differential Bus */
  1318. scsiBusUltra3SCSI = 0x00000200, /* HBA supports Ultra3 SCSI */
  1319. scsiBusUltra2SCSI = 0x00000100, /* HBA supports Ultra2 SCSI */
  1320. scsiBusInternalExternalMask = 0x000000C0, /* bus internal/external mask */
  1321. scsiBusInternalExternalUnknown = 0x00000000, /* not known whether bus is inside or outside */
  1322. scsiBusInternalExternal = 0x000000C0, /* bus goes inside and outside the box */
  1323. scsiBusInternal = 0x00000080, /* bus goes inside the box */
  1324. scsiBusExternal = 0x00000040, /* bus goes outside the box */
  1325. scsiBusCacheCoherentDMA = 0x00000020, /* DMA is cache coherent */
  1326. scsiBusOldCallCapable = 0x00000010, /* SIM is old call capable */
  1327. scsiBusUltraSCSI = 0x00000008, /* HBA supports Ultra SCSI */
  1328. scsiBusDifferential = 0x00000004, /* Single Ended (0) or Differential (1) */
  1329. scsiBusFastSCSI = 0x00000002, /* HBA supports fast SCSI */
  1330. scsiBusDMAavailable = 0x00000001 /* DMA is available */
  1331. };
  1332. /* scsiWeirdStuff field bits */
  1333. enum {
  1334. scsiOddDisconnectUnsafeRead1 = 0x0001, /* Disconnects on odd byte boundries are unsafe with DMA and/or blind reads */
  1335. scsiOddDisconnectUnsafeWrite1 = 0x0002, /* Disconnects on odd byte boundries are unsafe with DMA and/or blind writes */
  1336. scsiBusErrorsUnsafe = 0x0004, /* Non-handshaked delays or disconnects during blind transfers may cause a crash */
  1337. scsiRequiresHandshake = 0x0008, /* Non-handshaked delays or disconnects during blind transfers may cause data corruption */
  1338. scsiTargetDrivenSDTRSafe = 0x0010, /* Targets which initiate synchronous negotiations are supported */
  1339. scsiOddCountForPhysicalUnsafe = 0x0020, /* If using physical addrs all counts must be even, and disconnects must be on even boundries */
  1340. scsiAbortCmdFixed = 0x0040, /* Set if abort command is fixed to properly make callbacks */
  1341. scsiMeshACKTimingFixed = 0x0080 /* Set if bug allowing Mesh to release ACK prematurely is fixed */
  1342. };
  1343. /* scsiHBAslotType values */
  1344. enum {
  1345. scsiMotherboardBus = 0x00, /* A built in Apple supplied bus */
  1346. scsiNuBus = 0x01, /* A SIM on a NuBus card */
  1347. scsiPDSBus = 0x03, /* " on a PDS card */
  1348. scsiPCIBus = 0x04, /* " on a PCI bus card */
  1349. scsiPCMCIABus = 0x05, /* " on a PCMCIA card */
  1350. scsiFireWireBridgeBus = 0x06, /* " connected through a FireWire bridge */
  1351. scsiUSBBus = 0x07 /* " connected on a USB bus */
  1352. };
  1353. /* Defines for the scsiDriverFlags field (in SCSIDriverPB) */
  1354. enum {
  1355. scsiDeviceSensitive = 0x0001, /* Only driver should access this device */
  1356. scsiDeviceNoOldCallAccess = 0x0002 /* no old call access to this device */
  1357. };
  1358. /* SIMInitInfo PB */
  1359. /* directions are for SCSIRegisterBus call ( -> parm, <- result) */
  1360. struct SIMInitInfo {
  1361. Ptr SIMstaticPtr; /* <- alloc. ptr to the SIM's static vars */
  1362. long staticSize; /* -> num bytes SIM needs for static vars */
  1363. SIMInitUPP SIMInit; /* -> pointer to the SIM init routine */
  1364. SIMActionUPP SIMAction; /* -> pointer to the SIM action routine */
  1365. SCSIInterruptUPP SIM_ISR; /* reserved */
  1366. SCSIInterruptUPP SIMInterruptPoll; /* -> pointer to the SIM interrupt poll routine */
  1367. SIMActionUPP NewOldCall; /* -> pointer to the SIM NewOldCall routine */
  1368. UInt16 ioPBSize; /* -> size of SCSI_IO_PBs required for this SIM */
  1369. Boolean oldCallCapable; /* -> true if this SIM can handle old-API calls */
  1370. UInt8 simInfoUnused1; /* reserved */
  1371. long simInternalUse; /* xx not affected or viewed by XPT */
  1372. SCSIUPP XPT_ISR; /* reserved */
  1373. SCSIUPP EnteringSIM; /* <- ptr to the EnteringSIM routine */
  1374. SCSIUPP ExitingSIM; /* <- ptr to the ExitingSIM routine */
  1375. SCSIMakeCallbackUPP MakeCallback; /* <- the XPT layer's SCSIMakeCallback routine */
  1376. UInt16 busID; /* <- bus number for the registered bus */
  1377. UInt8 simSlotNumber; /* <- Magic cookie to place in scsiHBASlotNumber (PCI) */
  1378. UInt8 simSRsrcID; /* <- Magic cookie to place in scsiSIMsRsrcID (PCI) */
  1379. Ptr simRegEntry; /* -> The SIM's RegEntryIDPtr (PCI) */
  1380. };
  1381. typedef struct SIMInitInfo SIMInitInfo;
  1382. /* Glue between SCSI calls and SCSITrap format */
  1383. enum {
  1384. xptSCSIAction = 0x0001,
  1385. xptSCSIRegisterBus = 0x0002,
  1386. xptSCSIDeregisterBus = 0x0003,
  1387. xptSCSIReregisterBus = 0x0004,
  1388. xptSCSIKillXPT = 0x0005, /* kills Mini-XPT after transition */
  1389. xptSCSIInitialize = 0x000A /* Initialize the SCSI manager */
  1390. };
  1391. /*
  1392. * SCSI bus status. These values are returned by the SCSI target in the status phase.
  1393. * They are not related to Macintosh status values (except that values other than
  1394. * scsiStatusGood will result in scsiResult set to scsiNonZeroStatus).
  1395. */
  1396. enum {
  1397. scsiStatGood = 0x00, /* Good Status*/
  1398. scsiStatCheckCondition = 0x02, /* Check Condition*/
  1399. scsiStatConditionMet = 0x04, /* Condition Met*/
  1400. scsiStatBusy = 0x08, /* Busy*/
  1401. scsiStatIntermediate = 0x10, /* Intermediate*/
  1402. scsiStatIntermedMet = 0x14, /* Intermediate - Condition Met*/
  1403. scsiStatResvConflict = 0x18, /* Reservation conflict*/
  1404. scsiStatTerminated = 0x22, /* Command terminated*/
  1405. scsiStatQFull = 0x28 /* Queue full*/
  1406. };
  1407. /* SCSI messages*/
  1408. enum {
  1409. kCmdCompleteMsg = 0,
  1410. kExtendedMsg = 1, /* 0x01*/
  1411. kSaveDataPointerMsg = 2, /* 0x02*/
  1412. kRestorePointersMsg = 3, /* 0x03*/
  1413. kDisconnectMsg = 4, /* 0x04*/
  1414. kInitiatorDetectedErrorMsg = 5, /* 0x05*/
  1415. kAbortMsg = 6, /* 0x06*/
  1416. kMsgRejectMsg = 7, /* 0x07*/
  1417. kNoOperationMsg = 8, /* 0x08*/
  1418. kMsgParityErrorMsg = 9, /* 0x09*/
  1419. kLinkedCmdCompleteMsg = 10, /* 0x0a*/
  1420. kLinkedCmdCompleteWithFlagMsg = 11, /* 0x0b*/
  1421. kBusDeviceResetMsg = 12, /* 0x0c*/
  1422. kAbortTagMsg = 13, /* 0x0d*/
  1423. kClearQueueMsg = 14, /* 0x0e*/
  1424. kInitiateRecoveryMsg = 15, /* 0x0f*/
  1425. kReleaseRecoveryMsg = 16, /* 0x10*/
  1426. kTerminateIOProcessMsg = 17, /* 0x11*/
  1427. kSimpleQueueTag = 0x20, /* 0x20*/
  1428. kHeadOfQueueTagMsg = 0x21, /* 0x21*/
  1429. kOrderedQueueTagMsg = 0x22, /* 0x22*/
  1430. kIgnoreWideResidueMsg = 0x23 /* 0x23*/
  1431. };
  1432. /*
  1433. * SCSIAction()
  1434. *
  1435. * Discussion:
  1436. * This routine is deprecated. It is exported and callable, but it
  1437. * is no longer being maintained. Please use SCSITaskUserClient
  1438. * instead.
  1439. *
  1440. * Availability:
  1441. * Non-Carbon CFM: in InterfaceLib 7.5 and later
  1442. * CarbonLib: in CarbonLib 1.0 and later
  1443. * Mac OS X: in version 10.0 and later
  1444. */
  1445. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1446. #pragma parameter __D0 SCSIAction(__A0)
  1447. #endif
  1448. EXTERN_API( OSErr )
  1449. SCSIAction(SCSI_PB * parameterBlock) TWOWORDINLINE(0x7001, 0xA089);
  1450. #if CALL_NOT_IN_CARBON
  1451. /*
  1452. * SCSIRegisterBus()
  1453. *
  1454. * Availability:
  1455. * Non-Carbon CFM: in InterfaceLib 7.5 and later
  1456. * CarbonLib: not available
  1457. * Mac OS X: not available
  1458. */
  1459. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1460. #pragma parameter __D0 SCSIRegisterBus(__A0)
  1461. #endif
  1462. EXTERN_API( OSErr )
  1463. SCSIRegisterBus(SIMInitInfo * parameterBlock) TWOWORDINLINE(0x7002, 0xA089);
  1464. /*
  1465. * SCSIDeregisterBus()
  1466. *
  1467. * Availability:
  1468. * Non-Carbon CFM: in InterfaceLib 7.5 and later
  1469. * CarbonLib: not available
  1470. * Mac OS X: not available
  1471. */
  1472. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1473. #pragma parameter __D0 SCSIDeregisterBus(__A0)
  1474. #endif
  1475. EXTERN_API( OSErr )
  1476. SCSIDeregisterBus(SCSI_PB * parameterBlock) TWOWORDINLINE(0x7003, 0xA089);
  1477. /*
  1478. * SCSIReregisterBus()
  1479. *
  1480. * Availability:
  1481. * Non-Carbon CFM: in InterfaceLib 7.5 and later
  1482. * CarbonLib: not available
  1483. * Mac OS X: not available
  1484. */
  1485. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1486. #pragma parameter __D0 SCSIReregisterBus(__A0)
  1487. #endif
  1488. EXTERN_API( OSErr )
  1489. SCSIReregisterBus(SIMInitInfo * parameterBlock) TWOWORDINLINE(0x7004, 0xA089);
  1490. /*
  1491. * SCSIKillXPT()
  1492. *
  1493. * Availability:
  1494. * Non-Carbon CFM: in InterfaceLib 7.5 and later
  1495. * CarbonLib: not available
  1496. * Mac OS X: not available
  1497. */
  1498. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1499. #pragma parameter __D0 SCSIKillXPT(__A0)
  1500. #endif
  1501. EXTERN_API( OSErr )
  1502. SCSIKillXPT(SIMInitInfo * parameterBlock) TWOWORDINLINE(0x7005, 0xA089);
  1503. #endif /* CALL_NOT_IN_CARBON */
  1504. #if PRAGMA_STRUCT_ALIGN
  1505. #pragma options align=reset
  1506. #elif PRAGMA_STRUCT_PACKPUSH
  1507. #pragma pack(pop)
  1508. #elif PRAGMA_STRUCT_PACK
  1509. #pragma pack()
  1510. #endif
  1511. #ifdef PRAGMA_IMPORT_OFF
  1512. #pragma import off
  1513. #elif PRAGMA_IMPORT
  1514. #pragma import reset
  1515. #endif
  1516. #ifdef __cplusplus
  1517. }
  1518. #endif
  1519. #endif /* __SCSI__ */