3 * (c) 2004,2005 Laurent Vivier <Laurent@Vivier.EU>
7 #ifndef __MACOS_SCSI_H__
8 #define __MACOS_SCSI_H__
9 #include <macos/traps.h>
10 #include <macos/types.h>
13 op_inc = 1, /* transfer data, increment buffer pointer */
14 op_no_inc = 2, /* transfer data, don't increment pointer */
15 op_add = 3, /* add long to address */
16 op_mode = 4, /* move long to address */
17 op_loop = 5, /* decrement counter and loop if > 0 */
18 op_nop = 6, /* no operation */
19 op_stop = 7, /* stop TIB execution */
20 op_comp = 8, /* compare SCSI data with memory */
24 scCommErr = 2, /* Communications error, operation timeout */
25 scBadParmsErr = 4, /* Unrecognized TIB instruction */
26 scPhaseErr = 5, /* Phase error on the SCSI bus */
27 scCompareErr = 6, /* Comparison error from scComp instruction */
35 scsiBusy = scsiErrorBase + 49,
38 typedef struct TIB { /* Transfer Instruction Block */
39 short opcode; /* operation code */
40 int param1; /* 1st parameter */
41 int param2; /* 2nd parameter */
42 } __attribute__((packed)) TIB_t;
45 static inline OSErr SCSICmd(void* buffer, short count)
47 register OSErr ret asm("%%d0");
49 asm(" clr.w -(%%sp)\n"
50 " move.l %1, -(%%sp)\n"
51 " move.w %2, -(%%sp)\n"
52 SCSIDispatch(_SCSICmd)
53 : "=d" (ret) : "g" (buffer), "g" (count) : UNPRESERVED_REGS );
58 static inline OSErr SCSIComplete(short *stat, short *message, unsigned long wait)
60 register OSErr ret asm("%%d0");
63 " move.l %0, -(%%sp)\n"
64 " move.l %1, -(%%sp)\n"
65 " move.l %2, -(%%sp)\n"
66 SCSIDispatch(_SCSIComplete)
67 : "=d" (ret) : "g" (stat), "g" (message), "g" (wait) : UNPRESERVED_REGS );
72 static inline OSErr SCSIGet(void)
74 register OSErr ret asm("%%d0");
77 SCSIDispatch(_SCSIGet)
78 : "=d" (ret) :: UNPRESERVED_REGS );
83 static inline OSErr SCSIRead(void *tibPtr)
85 register OSErr ret asm("%%d0");
88 " move.l %1, -(%%sp)\n"
89 SCSIDispatch(_SCSIRead)
90 : "=d" (ret) : "g" (tibPtr) : UNPRESERVED_REGS );
95 static inline OSErr SCSIReset(void)
97 register OSErr ret asm("%%d0");
100 SCSIDispatch(_SCSIReset)
101 : "=d" (ret) :: UNPRESERVED_REGS );
106 static inline OSErr SCSISelect(short targetID)
108 register OSErr ret asm("%%d0");
110 asm("move.w %1, %%d0\n"
112 " move.w %%d0, -(%%sp)\n"
113 SCSIDispatch(_SCSISelect)
114 : "=d" (ret) : "g" (targetID) : UNPRESERVED_REGS );
119 static inline OSErr SCSIStat(void)
121 register OSErr ret asm("%%d0");
123 asm("clr.w -(%%sp)\n"
124 SCSIDispatch(_SCSIStat)
125 : "=d" (ret) :: UNPRESERVED_REGS );
129 #endif /* __mc68000__ */
130 #endif /* __MACOS_SCSI_H__ */