windows.gaming.input: Fake empty IGamepadStatics::Gamepads vector.
[wine/zf.git] / dlls / winaspi.dll16 / winaspi.c
blob71a0dd250d31b7ae41672b0255b3c728c3969ba5
1 /*
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
20 #include <stdlib.h>
21 #include <sys/types.h>
22 #include <string.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/windef16.h"
29 #include "wine/winbase16.h"
30 #include "wnaspi32.h"
31 #include "winreg.h"
32 #include "wownt32.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(aspi);
37 #include <pshpack1.h>
39 typedef struct tagSRB16_HaInquiry {
40 BYTE SRB_Cmd;
41 BYTE SRB_Status;
42 BYTE SRB_HaId;
43 BYTE SRB_Flags;
44 WORD SRB_55AASignature;
45 WORD SRB_ExtBufferSize;
46 BYTE HA_Count;
47 BYTE HA_SCSI_ID;
48 BYTE HA_ManagerId[16];
49 BYTE HA_Identifier[16];
50 BYTE HA_Unique[16];
51 BYTE HA_ExtBuffer[4];
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 {
122 SRB_Common16 common;
123 SRB_HaInquiry16 inquiry;
124 SRB_ExecSCSICmd16 cmd;
125 SRB_Abort16 abort;
126 SRB_BusDeviceReset16 reset;
127 SRB_GDEVBlock16 devtype;
128 } SRB16, *LPSRB16;
130 #include <poppack.h>
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)
156 SRB srb32;
157 LPSRB16 srb16 = MapSL( segptr_srb );
158 DWORD ret;
160 if (ASPIChainFunc)
162 /* This is not the post proc, it's the chain proc this time */
163 ret = WOWCallback16((DWORD)ASPIChainFunc, segptr_srb);
164 if (ret)
166 srb16->inquiry.SRB_Status = SS_INVALID_SRB;
167 return ret;
171 switch (srb16->common.SRB_Cmd)
173 case SC_HA_INQUIRY:
174 srb32.common.SRB_Cmd = SC_HA_INQUIRY;
175 ret = SendASPI32Command( &srb32 );
176 memcpy( &srb16->inquiry, &srb32.inquiry, sizeof(srb16->inquiry) );
177 return ret;
179 case SC_GET_DEV_TYPE:
180 FIXME("Not implemented SC_GET_DEV_TYPE\n");
181 break;
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 ) );
208 return ret;
210 case SC_RESET_DEV:
211 FIXME("Not implemented SC_RESET_DEV\n");
212 break;
214 default:
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;
231 return SS_COMP;
234 else /* Insert */
236 if (ASPIChainFunc == NULL)
238 ASPIChainFunc = pASPIChainFunc;
239 return SS_COMP;
242 return SS_ERR;
246 /***********************************************************************
247 * GetASPIDLLVersion (WINASPI.4)
249 DWORD WINAPI GetASPIDLLVersion16(void)
251 return 2;