2 * Copyright 1997 Bruce Milner
3 * Copyright 1998 Andreas Mohr
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <sys/types.h>
28 #include "wine/windef16.h"
29 #include "wine/winbase16.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(aspi
);
39 typedef struct tagSRB16_HaInquiry
{
44 WORD SRB_55AASignature
;
45 WORD SRB_ExtBufferSize
;
48 BYTE HA_ManagerId
[16];
49 BYTE HA_Identifier
[16];
52 } SRB_HaInquiry16
, *PSRB_HaInquiry16
, *LPSRB_HaInquiry16
;
54 typedef struct tagSRB16_GDEVBlock
{
55 BYTE SRB_Cmd
; /* ASPI command code = SC_GET_DEV_TYPE */
56 BYTE SRB_Status
; /* ASPI command status byte */
57 BYTE SRB_HaId
; /* ASPI host adapter number */
58 BYTE SRB_Flags
; /* ASPI request flags */
59 DWORD SRB_Hdr_Rsvd
; /* Reserved, MUST = 0 */
60 BYTE SRB_Target
; /* Target's SCSI ID */
61 BYTE SRB_Lun
; /* Target's LUN number */
62 BYTE SRB_DeviceType
; /* Target's peripheral device type */
63 } SRB_GDEVBlock16
, *PSRB_GDEVBlock16
, *LPSRB_GDEVBlock16
;
65 typedef struct tagSRB16_ExecSCSICmd
{
66 BYTE SRB_Cmd
; /* ASPI command code (W) */
67 BYTE SRB_Status
; /* ASPI command status byte (R) */
68 BYTE SRB_HaId
; /* ASPI host adapter number (W) */
69 BYTE SRB_Flags
; /* ASPI request flags (W) */
70 DWORD SRB_Hdr_Rsvd
; /* Reserved, MUST = 0 (-) */
71 BYTE SRB_Target
; /* Target's SCSI ID (W) */
72 BYTE SRB_Lun
; /* Target's LUN number (W) */
73 DWORD SRB_BufLen
; /* Data Allocation LengthPG (W/R)*/
74 BYTE SRB_SenseLen
; /* Sense Allocation Length (W) */
75 SEGPTR SRB_BufPointer
; /* Data Buffer Pointer (W) */
76 DWORD SRB_Rsvd1
; /* Reserved, MUST = 0 (-/W)*/
77 BYTE SRB_CDBLen
; /* CDB Length = 6 (W) */
78 BYTE SRB_HaStat
; /* Host Adapter Status (R) */
79 BYTE SRB_TargStat
; /* Target Status (R) */
80 FARPROC16 SRB_PostProc
; /* Post routine (W) */
81 BYTE SRB_Rsvd2
[34]; /* Reserved, MUST = 0 */
82 BYTE CDBByte
[1]; /* SCSI CBD - variable length (W) */
83 /* variable example for 6 byte cbd
84 * BYTE CDBByte[6]; * SCSI CDB (W) *
85 * BYTE SenseArea6[SENSE_LEN]; * Request Sense buffer (R) *
87 } SRB_ExecSCSICmd16
, *PSRB_ExecSCSICmd16
, *LPSRB_ExecSCSICmd16
;
89 typedef struct tagSRB16_Abort
{
90 BYTE SRB_Cmd
; /* ASPI command code = SC_ABORT_SRB */
91 BYTE SRB_Status
; /* ASPI command status byte */
92 BYTE SRB_HaId
; /* ASPI host adapter number */
93 BYTE SRB_Flags
; /* ASPI request flags */
94 DWORD SRB_Hdr_Rsvd
; /* Reserved, MUST = 0 */
95 SEGPTR SRB_ToAbort
; /* Pointer to SRB to abort */
96 } SRB_Abort16
, *PSRB_Abort16
, *LPSRB_Abort16
;
98 typedef struct tagSRB16_BusDeviceReset
{
99 BYTE SRB_Cmd
; /* ASPI command code = SC_RESET_DEV */
100 BYTE SRB_Status
; /* ASPI command status byte */
101 BYTE SRB_HaId
; /* ASPI host adapter number */
102 BYTE SRB_Flags
; /* ASPI request flags */
103 DWORD SRB_Hdr_Rsvd
; /* Reserved, MUST = 0 */
104 BYTE SRB_Target
; /* Target's SCSI ID */
105 BYTE SRB_Lun
; /* Target's LUN number */
106 BYTE SRB_ResetRsvd1
[14]; /* Reserved, MUST = 0 */
107 BYTE SRB_HaStat
; /* Host Adapter Status */
108 BYTE SRB_TargStat
; /* Target Status */
109 FARPROC16 SRB_PostProc
; /* Post routine */
110 BYTE SRB_ResetRsvd2
[34]; /* Reserved, MUST = 0 */
111 } SRB_BusDeviceReset16
, *PSRB_BusDeviceReset16
, *LPSRB_BusDeviceReset16
;
113 typedef struct tagSRB16_Common
{
114 BYTE SRB_Cmd
; /* ASPI command code = SC_ABORT_SRB */
115 BYTE SRB_Status
; /* ASPI command status byte */
116 BYTE SRB_HaId
; /* ASPI host adapter number */
117 BYTE SRB_Flags
; /* ASPI request flags */
118 DWORD SRB_Hdr_Rsvd
; /* Reserved, MUST = 0 */
119 } SRB_Common16
, *PSRB_Common16
, *LPSRB_Common16
;
121 typedef union tagSRB16
{
123 SRB_HaInquiry16 inquiry
;
124 SRB_ExecSCSICmd16 cmd
;
126 SRB_BusDeviceReset16 reset
;
127 SRB_GDEVBlock16 devtype
;
132 static FARPROC16 ASPIChainFunc
= NULL
;
133 static FARPROC16 exec_postproc16
;
134 static SEGPTR exec_cmd16
;
136 static void SRB_PostProc( SRB_ExecSCSICmd
*cmd32
)
138 WOWCallback16( (DWORD
)exec_postproc16
, exec_cmd16
);
142 /***********************************************************************
143 * GetASPISupportInfo (WINASPI.1)
145 WORD WINAPI
GetASPISupportInfo16(void)
147 return GetASPI32SupportInfo();
151 /***********************************************************************
152 * SendASPICommand (WINASPI.2)
154 WORD WINAPI
SendASPICommand16(SEGPTR segptr_srb
)
157 LPSRB16 srb16
= MapSL( segptr_srb
);
162 /* This is not the post proc, it's the chain proc this time */
163 ret
= WOWCallback16((DWORD
)ASPIChainFunc
, segptr_srb
);
166 srb16
->inquiry
.SRB_Status
= SS_INVALID_SRB
;
171 switch (srb16
->common
.SRB_Cmd
)
174 srb32
.common
.SRB_Cmd
= SC_HA_INQUIRY
;
175 ret
= SendASPI32Command( &srb32
);
176 memcpy( &srb16
->inquiry
, &srb32
.inquiry
, sizeof(srb16
->inquiry
) );
179 case SC_GET_DEV_TYPE
:
180 FIXME("Not implemented SC_GET_DEV_TYPE\n");
183 case SC_EXEC_SCSI_CMD
:
184 srb32
.cmd
.SRB_Cmd
= srb16
->cmd
.SRB_Cmd
;
185 srb32
.cmd
.SRB_Status
= srb16
->cmd
.SRB_Status
;
186 srb32
.cmd
.SRB_HaId
= srb16
->cmd
.SRB_HaId
;
187 srb32
.cmd
.SRB_Flags
= srb16
->cmd
.SRB_Flags
;
188 srb32
.cmd
.SRB_Hdr_Rsvd
= srb16
->cmd
.SRB_Hdr_Rsvd
;
189 srb32
.cmd
.SRB_Target
= srb16
->cmd
.SRB_Target
;
190 srb32
.cmd
.SRB_Lun
= srb16
->cmd
.SRB_Lun
;
191 srb32
.cmd
.SRB_BufLen
= srb16
->cmd
.SRB_BufLen
;
192 srb32
.cmd
.SRB_BufPointer
= MapSL(srb16
->cmd
.SRB_BufPointer
);
193 srb32
.cmd
.SRB_SenseLen
= srb16
->cmd
.SRB_SenseLen
;
194 srb32
.cmd
.SRB_CDBLen
= srb16
->cmd
.SRB_CDBLen
;
195 srb32
.cmd
.SRB_HaStat
= srb16
->cmd
.SRB_HaStat
;
196 srb32
.cmd
.SRB_TargStat
= srb16
->cmd
.SRB_TargStat
;
197 memcpy( &srb32
.cmd
.CDBByte
, srb16
->cmd
.CDBByte
, srb32
.cmd
.SRB_CDBLen
);
198 srb32
.cmd
.SRB_PostProc
= SRB_PostProc
;
199 exec_postproc16
= srb16
->cmd
.SRB_PostProc
;
200 exec_cmd16
= segptr_srb
;
201 ret
= SendASPI32Command( &srb32
);
202 srb16
->cmd
.SRB_Status
= srb32
.cmd
.SRB_Status
;
203 srb16
->cmd
.SRB_BufLen
= srb32
.cmd
.SRB_BufLen
;
204 srb16
->cmd
.SRB_HaStat
= srb32
.cmd
.SRB_HaStat
;
205 srb16
->cmd
.SRB_TargStat
= srb32
.cmd
.SRB_TargStat
;
206 memcpy( srb16
->cmd
.CDBByte
+ srb16
->cmd
.SRB_CDBLen
, srb32
.cmd
.SenseArea
,
207 min( 16, srb32
.cmd
.SRB_SenseLen
) );
211 FIXME("Not implemented SC_RESET_DEV\n");
215 FIXME("Unknown command %d\n", srb16
->common
.SRB_Cmd
);
217 return SS_INVALID_SRB
;
221 /***********************************************************************
222 * InsertInASPIChain (WINASPI.3)
224 WORD WINAPI
InsertInASPIChain16(BOOL16 remove
, FARPROC16 pASPIChainFunc
)
226 if (remove
) /* Remove */
228 if (ASPIChainFunc
== pASPIChainFunc
)
230 ASPIChainFunc
= NULL
;
236 if (ASPIChainFunc
== NULL
)
238 ASPIChainFunc
= pASPIChainFunc
;
246 /***********************************************************************
247 * GetASPIDLLVersion (WINASPI.4)
249 DWORD WINAPI
GetASPIDLLVersion16(void)