Replace DPRINTF with TRACE.
[wine] / dlls / winaspi / winaspi32.c
1 /*
2  * Copyright 1997 Bruce Milner
3  * Copyright 1998 Andreas Mohr
4  *
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.
9  *
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.
14  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include "config.h"
21
22 #include <assert.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <sys/types.h>
26 #include <errno.h>
27 #include <fcntl.h>
28 #include <memory.h>
29 #ifdef HAVE_UNISTD_H
30 # include <unistd.h>
31 #endif
32
33 #include "winbase.h"
34 #include "aspi.h"
35 #include "wnaspi32.h"
36 #include "winescsi.h"
37 #include "wine/debug.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(aspi);
40
41 /* FIXME!
42  * 1) Residual byte length reporting not handled
43  * 2) Make this code re-entrant for multithreading
44  *    -- Added CriticalSection to OpenDevices function
45  * 3) Only linux supported so far
46  * 4) Leaves sg devices open. This may or may not be okay.  A better solution
47  *    would be to close the file descriptors when the thread/process using
48  *    them no longer needs them.
49  */
50
51 #ifdef linux
52
53 static ASPI_DEVICE_INFO *ASPI_open_devices = NULL;
54 static CRITICAL_SECTION ASPI_CritSection = CRITICAL_SECTION_INIT("ASPI_CritSection");
55
56 #endif /* defined(linux) */
57
58
59 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
60 {
61 #ifdef linux
62         switch( fdwReason )
63         {
64         case DLL_PROCESS_ATTACH:
65             SCSI_Init();
66             break;
67         case DLL_PROCESS_DETACH:
68             DeleteCriticalSection( &ASPI_CritSection );
69             break;
70         case DLL_THREAD_ATTACH:
71         case DLL_THREAD_DETACH:
72                 break;
73         }
74 #endif /* defined(linux) */
75         return TRUE;
76 }
77
78
79 #ifdef linux
80
81 static int
82 ASPI_OpenDevice(SRB_ExecSCSICmd *prb)
83 {
84     int fd;
85     DWORD       hc;
86     ASPI_DEVICE_INFO *curr;
87
88     /* search list of devices to see if we've opened it already.
89      * There is not an explicit open/close in ASPI land, so hopefully
90      * keeping a device open won't be a problem.
91      */
92
93     EnterCriticalSection(&ASPI_CritSection);
94     for (curr = ASPI_open_devices; curr; curr = curr->next) {
95         if (curr->hostId == prb->SRB_HaId &&
96             curr->target == prb->SRB_Target &&
97             curr->lun == prb->SRB_Lun) {
98             LeaveCriticalSection(&ASPI_CritSection);
99             return curr->fd;
100         }
101     }
102     LeaveCriticalSection(&ASPI_CritSection);
103
104     if (prb->SRB_HaId > ASPI_GetNumControllers())
105         return -1;
106
107     hc = ASPI_GetHCforController( prb->SRB_HaId );
108     fd = SCSI_OpenDevice( HIWORD(hc), LOWORD(hc), prb->SRB_Target, prb->SRB_Lun);
109
110     if (fd == -1)
111         return -1;
112
113     /* device is now open */
114     /* FIXME: Let users specify SCSI timeout in registry */
115     SCSI_LinuxSetTimeout( fd, SCSI_DEFAULT_TIMEOUT );
116
117     curr = HeapAlloc( GetProcessHeap(), 0, sizeof(ASPI_DEVICE_INFO) );
118     curr->fd = fd;
119     curr->hostId = prb->SRB_HaId;
120     curr->target = prb->SRB_Target;
121     curr->lun = prb->SRB_Lun;
122
123     /* insert new record at beginning of open device list */
124     EnterCriticalSection(&ASPI_CritSection);
125     curr->next = ASPI_open_devices;
126     ASPI_open_devices = curr;
127     LeaveCriticalSection(&ASPI_CritSection);
128     return fd;
129 }
130
131
132 static void
133 ASPI_DebugPrintCmd(SRB_ExecSCSICmd *prb)
134 {
135   BYTE  cmd;
136   int   i;
137   BYTE *cdb;
138
139   switch (prb->CDBByte[0]) {
140   case CMD_INQUIRY:
141     TRACE("INQUIRY {\n");
142     TRACE("\tEVPD: %d\n", prb->CDBByte[1] & 1);
143     TRACE("\tLUN: %d\n", (prb->CDBByte[1] & 0xc) >> 1);
144     TRACE("\tPAGE CODE: %d\n", prb->CDBByte[2]);
145     TRACE("\tALLOCATION LENGTH: %d\n", prb->CDBByte[4]);
146     TRACE("\tCONTROL: %d\n", prb->CDBByte[5]);
147     TRACE("}\n");
148     break;
149   case CMD_SCAN_SCAN:
150     TRACE("Transfer Length: %d\n", prb->CDBByte[4]);
151     break;
152   }
153
154   TRACE("Host Adapter: %d\n", prb->SRB_HaId);
155   TRACE("Flags: %d\n", prb->SRB_Flags);
156   if (TARGET_TO_HOST(prb)) {
157     TRACE("\tData transfer: Target to host. Length checked.\n");
158   }
159   else if (HOST_TO_TARGET(prb)) {
160     TRACE("\tData transfer: Host to target. Length checked.\n");
161   }
162   else if (NO_DATA_TRANSFERED(prb)) {
163     TRACE("\tData transfer: none\n");
164   }
165   else {
166     WARN("\tTransfer by scsi cmd. Length not checked.\n");
167   }
168
169   TRACE("\tResidual byte length reporting %s\n", prb->SRB_Flags & 0x4 ? "enabled" : "disabled");
170   TRACE("\tLinking %s\n", prb->SRB_Flags & 0x2 ? "enabled" : "disabled");
171   TRACE("\tPosting %s\n", prb->SRB_Flags & 0x1 ? "enabled" : "disabled");
172   TRACE("Target: %d\n", prb->SRB_Target);
173   TRACE("Lun: %d\n", prb->SRB_Lun);
174   TRACE("BufLen: %ld\n", prb->SRB_BufLen);
175   TRACE("SenseLen: %d\n", prb->SRB_SenseLen);
176   TRACE("BufPtr: %p\n", prb->SRB_BufPointer);
177   TRACE("CDB Length: %d\n", prb->SRB_CDBLen);
178   TRACE("POST Proc: %lx\n", (DWORD) prb->SRB_PostProc);
179   cdb = &prb->CDBByte[0];
180   cmd = prb->CDBByte[0];
181   if (TRACE_ON(aspi)) {
182       TRACE("CDB buffer[");
183       for (i = 0; i < prb->SRB_CDBLen; i++) {
184           if (i != 0) TRACE(",");
185           TRACE("%02x", *cdb++);
186       }
187       TRACE("]\n");
188   }
189 }
190
191 static void
192 ASPI_PrintCDBArea(SRB_ExecSCSICmd *prb)
193 {
194     if (TRACE_ON(aspi))
195     {
196         int i;
197         TRACE("CDB[");
198         for (i = 0; i < prb->SRB_CDBLen; i++) {
199             if (i) TRACE(",");
200             TRACE("%02x", prb->CDBByte[i]);
201         }
202         TRACE("]\n");
203     }
204 }
205
206 static void
207 ASPI_PrintSenseArea(SRB_ExecSCSICmd *prb)
208 {
209   int   i;
210   BYTE  *rqbuf = prb->SenseArea;
211
212   if (TRACE_ON(aspi))
213   {
214       TRACE("Request Sense reports:\n");
215       if ((rqbuf[0]&0x7f)!=0x70) {
216               TRACE("\tInvalid sense header: 0x%02x instead of 0x70\n", rqbuf[0]&0x7f);
217               return;
218       }
219       TRACE("\tCurrent command read filemark: %s\n",(rqbuf[2]&0x80)?"yes":"no");
220       TRACE("\tEarly warning passed: %s\n",(rqbuf[2]&0x40)?"yes":"no");
221       TRACE("\tIncorrect blocklength: %s\n",(rqbuf[2]&0x20)?"yes":"no");
222       TRACE("\tSense Key: %d\n",rqbuf[2]&0xf);
223       if (rqbuf[0]&0x80)
224         TRACE("\tResidual Length: %d\n",rqbuf[3]*0x1000000+rqbuf[4]*0x10000+rqbuf[5]*0x100+rqbuf[6]);
225       TRACE("\tAdditional Sense Length: %d\n",rqbuf[7]);
226       TRACE("\tAdditional Sense Code: %d\n",rqbuf[12]);
227       TRACE("\tAdditional Sense Code Qualifier: %d\n",rqbuf[13]);
228       if (rqbuf[15]&0x80) {
229         TRACE("\tIllegal Param is in %s\n",(rqbuf[15]&0x40)?"the CDB":"the Data Out Phase");
230         if (rqbuf[15]&0x8) {
231           TRACE("Pointer at %d, bit %d\n",rqbuf[16]*256+rqbuf[17],rqbuf[15]&0x7);
232         }
233       }
234       TRACE("SenseArea[");
235       for (i = 0; i < prb->SRB_SenseLen; i++) {
236         if (i) TRACE(",");
237         TRACE("%02x", *rqbuf++);
238       }
239       TRACE("]\n");
240   }
241 }
242
243 static void
244 ASPI_DebugPrintResult(SRB_ExecSCSICmd *prb)
245 {
246
247   TRACE("SRB_Status: %x\n", prb->SRB_Status);
248   TRACE("SRB_HaStat: %x\n", prb->SRB_HaStat);
249   TRACE("SRB_TargStat: %x\n", prb->SRB_TargStat);
250   switch (prb->CDBByte[0]) {
251   case CMD_INQUIRY:
252     TRACE("Vendor: '%s'\n", prb->SRB_BufPointer + INQUIRY_VENDOR);
253     break;
254   case CMD_TEST_UNIT_READY:
255     ASPI_PrintSenseArea(prb);
256     break;
257   }
258 }
259
260 /* Posting must be done in such a way that as soon as the SRB_Status is set
261  * we don't touch the SRB anymore because it could possibly be freed
262  * if the app is doing ASPI polling
263  */
264 static DWORD
265 WNASPI32_DoPosting( SRB_ExecSCSICmd *lpPRB, DWORD status )
266 {
267         void (*SRB_PostProc)() = lpPRB->SRB_PostProc;
268         BYTE SRB_Flags = lpPRB->SRB_Flags;
269         if( status == SS_PENDING )
270         {
271                 WARN("Tried posting SS_PENDING\n");
272                 return SS_PENDING;
273         }
274         lpPRB->SRB_Status = status;
275         /* lpPRB is NOT safe, it could be freed in another thread */
276
277         if (SRB_PostProc)
278         {
279                 if (SRB_Flags & 0x1)
280                 {
281                         TRACE("Post Routine (%lx) called\n", (DWORD) SRB_PostProc);
282                         /* Even though lpPRB could have been freed by
283                          * the program.. that's unlikely if it planned
284                          * to use it in the PostProc
285                          */
286                         (*SRB_PostProc)(lpPRB);
287                 }
288                 else if (SRB_Flags & SRB_EVENT_NOTIFY) {
289                         TRACE("Setting event %p\n", (HANDLE)SRB_PostProc);
290                         SetEvent((HANDLE)SRB_PostProc);
291                 }
292         }
293         return SS_PENDING;
294 }
295
296 static WORD
297 ASPI_ExecScsiCmd(SRB_ExecSCSICmd *lpPRB)
298 {
299   struct sg_header *sg_hd, *sg_reply_hdr;
300   WORD ret;
301   DWORD status;
302   int   in_len, out_len;
303   int   error_code = 0;
304   int   fd;
305   DWORD SRB_Status;
306
307   /* FIXME: hackmode */
308 #define MAKE_TARGET_TO_HOST(lpPRB) \
309         if (!TARGET_TO_HOST(lpPRB)) { \
310             WARN("program was not sending target_to_host for cmd %x (flags=%x),correcting.\n",lpPRB->CDBByte[0],lpPRB->SRB_Flags); \
311             lpPRB->SRB_Flags |= 0x08; \
312         }
313 #define MAKE_HOST_TO_TARGET(lpPRB) \
314         if (!HOST_TO_TARGET(lpPRB)) { \
315             WARN("program was not sending host_to_target for cmd %x (flags=%x),correcting.\n",lpPRB->CDBByte[0],lpPRB->SRB_Flags); \
316             lpPRB->SRB_Flags |= 0x10; \
317         }
318   switch (lpPRB->CDBByte[0]) {
319   case 0x12: /* INQUIRY */
320   case 0x5a: /* MODE_SENSE_10 */
321   case 0xa4: /* REPORT_KEY (DVD) MMC-2 */
322   case 0xad: /* READ DVD STRUCTURE MMC-2 */
323         MAKE_TARGET_TO_HOST(lpPRB)
324         break;
325   case 0xa3: /* SEND KEY (DVD) MMC-2 */
326         MAKE_HOST_TO_TARGET(lpPRB)
327         break;
328   default:
329         if ((((lpPRB->SRB_Flags & 0x18) == 0x00) ||
330              ((lpPRB->SRB_Flags & 0x18) == 0x18)
331             ) && lpPRB->SRB_BufLen
332         ) {
333             FIXME("command 0x%02x, no data transfer specified, but buflen is %ld!!!\n",lpPRB->CDBByte[0],lpPRB->SRB_BufLen);
334         }
335         break;
336   }
337   ASPI_DebugPrintCmd(lpPRB);
338   if (lpPRB->SRB_HaId > ASPI_GetNumControllers()) {
339       ERR("Failed: Wanted hostadapter %d, but we have only %d.\n",
340           lpPRB->SRB_HaId,ASPI_GetNumControllers()
341       );
342       return WNASPI32_DoPosting( lpPRB, SS_INVALID_HA );
343   }
344   fd = ASPI_OpenDevice(lpPRB);
345   if (fd == -1) {
346       return WNASPI32_DoPosting( lpPRB, SS_NO_DEVICE );
347   }
348
349   sg_hd = NULL;
350   sg_reply_hdr = NULL;
351
352   lpPRB->SRB_Status = SS_PENDING;
353
354   if (!lpPRB->SRB_CDBLen) {
355       ERR("Failed: lpPRB->SRB_CDBLen = 0.\n");
356       return WNASPI32_DoPosting( lpPRB, SS_INVALID_SRB );
357   }
358
359   /* build up sg_header + scsi cmd */
360   if (HOST_TO_TARGET(lpPRB)) {
361     /* send header, command, and then data */
362     in_len = SCSI_OFF + lpPRB->SRB_CDBLen + lpPRB->SRB_BufLen;
363     sg_hd = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, in_len);
364     memset(sg_hd, 0, SCSI_OFF);
365     memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
366     if (lpPRB->SRB_BufLen) {
367       memcpy(((BYTE *) sg_hd) + SCSI_OFF + lpPRB->SRB_CDBLen, lpPRB->SRB_BufPointer, lpPRB->SRB_BufLen);
368     }
369   }
370   else {
371     /* send header and command - no data */
372     in_len = SCSI_OFF + lpPRB->SRB_CDBLen;
373     sg_hd = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, in_len);
374     memset(sg_hd, 0, SCSI_OFF);
375     memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
376   }
377
378   if (TARGET_TO_HOST(lpPRB)) {
379     out_len = SCSI_OFF + lpPRB->SRB_BufLen;
380     sg_reply_hdr = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, out_len);
381     memset(sg_reply_hdr, 0, SCSI_OFF);
382     sg_hd->reply_len = out_len;
383   }
384   else {
385     out_len = SCSI_OFF;
386     sg_reply_hdr = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, out_len);
387     memset(sg_reply_hdr, 0, SCSI_OFF);
388     sg_hd->reply_len = out_len;
389   }
390
391   SCSI_Fix_CMD_LEN(fd, lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
392
393   if(!SCSI_LinuxDeviceIo( fd,
394                           sg_hd, in_len,
395                           sg_reply_hdr, out_len,
396                           &status) )
397   {
398     goto error_exit;
399   }
400
401   if (sg_reply_hdr->result != 0) {
402     error_code = sg_reply_hdr->result;
403     WARN("reply header error (%d)\n", sg_reply_hdr->result);
404     goto error_exit;
405   }
406
407   if (TARGET_TO_HOST(lpPRB) && lpPRB->SRB_BufLen) {
408     memcpy(lpPRB->SRB_BufPointer, sg_reply_hdr + 1, lpPRB->SRB_BufLen);
409   }
410
411   /* copy in sense buffer to amount that is available in client */
412   if (lpPRB->SRB_SenseLen) {
413     int sense_len = lpPRB->SRB_SenseLen;
414     if (lpPRB->SRB_SenseLen > 16)
415       sense_len = 16;
416
417     /* CDB is fixed in WNASPI32 */
418     memcpy(lpPRB->SenseArea, &sg_reply_hdr->sense_buffer[0], sense_len);
419
420     ASPI_PrintCDBArea(lpPRB);
421     ASPI_PrintSenseArea(lpPRB);
422   }
423
424   SRB_Status = SS_COMP;
425   lpPRB->SRB_HaStat = HASTAT_OK;
426   lpPRB->SRB_TargStat = sg_reply_hdr->target_status << 1;
427
428   HeapFree(GetProcessHeap(), 0, sg_reply_hdr);
429   HeapFree(GetProcessHeap(), 0, sg_hd);
430
431   /* FIXME: Should this be != 0 maybe? */
432   if( lpPRB->SRB_TargStat == 2 ) {
433     SRB_Status = SS_ERR;
434     switch (lpPRB->CDBByte[0]) {
435     case 0xa4: /* REPORT_KEY (DVD) MMC-2 */
436     case 0xa3: /* SEND KEY (DVD) MMC-2 */
437           SRB_Status = SS_COMP;
438           lpPRB->SRB_TargStat = 0;
439           FIXME("Program wants to do DVD Region switching, but fails (non compliant DVD drive). Ignoring....\n");
440           break;
441     }
442   }
443
444   ASPI_DebugPrintResult(lpPRB);
445   /* now do posting */
446   ret = WNASPI32_DoPosting( lpPRB, SRB_Status );
447
448   switch (lpPRB->CDBByte[0]) {
449   case CMD_INQUIRY:
450       if (SRB_Status == SS_COMP)
451           return SS_COMP; /* some junk expects ss_comp here. */
452       /*FALLTHROUGH*/
453   default:
454       break;
455   }
456
457   /* In real WNASPI32 stuff really is always pending because ASPI does things
458      in the background, but we are not doing that (yet) */
459
460   return ret;
461
462 error_exit:
463   SRB_Status = SS_ERR;
464   if (error_code == EBUSY) {
465       WNASPI32_DoPosting( lpPRB, SS_ASPI_IS_BUSY );
466       TRACE("Device busy\n");
467   } else
468       FIXME("Failed\n");
469
470   /* I'm not sure exactly error codes work here
471    * We probably should set lpPRB->SRB_TargStat, SRB_HaStat ?
472    */
473   WARN("error_exit\n");
474   HeapFree(GetProcessHeap(), 0, sg_reply_hdr);
475   HeapFree(GetProcessHeap(), 0, sg_hd);
476   WNASPI32_DoPosting( lpPRB, SRB_Status );
477   return SS_PENDING;
478 }
479
480 #endif /* defined(linux) */
481
482
483 /*******************************************************************
484  *     GetASPI32SupportInfo             [WNASPI32.1]
485  *
486  * Checks if the ASPI subsystem is initialized correctly.
487  *
488  * RETURNS
489  *    HIWORD: 0.
490  *    HIBYTE of LOWORD: status (SS_COMP or SS_FAILED_INIT)
491  *    LOBYTE of LOWORD: # of host adapters.
492  */
493 DWORD __cdecl GetASPI32SupportInfo(void)
494 {
495     DWORD controllers = ASPI_GetNumControllers();
496
497     if (!controllers)
498         return SS_NO_ADAPTERS << 8;
499     return (SS_COMP << 8) | controllers ;
500 }
501
502 /***********************************************************************
503  *             SendASPI32Command (WNASPI32.2)
504  */
505 DWORD __cdecl SendASPI32Command(LPSRB lpSRB)
506 {
507 #ifdef linux
508   switch (lpSRB->common.SRB_Cmd) {
509   case SC_HA_INQUIRY:
510     lpSRB->inquiry.SRB_Status = SS_COMP;       /* completed successfully */
511     lpSRB->inquiry.HA_Count = ASPI_GetNumControllers();
512     lpSRB->inquiry.HA_SCSI_ID = 7;             /* not always ID 7 */
513     strcpy(lpSRB->inquiry.HA_ManagerId, "ASPI for WIN32"); /* max 15 chars, don't change */
514     strcpy(lpSRB->inquiry.HA_Identifier, "Wine host"); /* FIXME: return host adapter name */
515     memset(lpSRB->inquiry.HA_Unique, 0, 16); /* default HA_Unique content */
516     lpSRB->inquiry.HA_Unique[6] = 0x02; /* Maximum Transfer Length (128K, Byte> 4-7) */
517     lpSRB->inquiry.HA_Unique[3] = 0x08; /* Maximum number of SCSI targets */
518     FIXME("ASPI: Partially implemented SC_HA_INQUIRY for adapter %d.\n", lpSRB->inquiry.SRB_HaId);
519     return SS_COMP;
520
521   case SC_GET_DEV_TYPE: {
522     /* FIXME: We should return SS_NO_DEVICE if the device is not configured */
523     /* FIXME: We should return SS_INVALID_HA if HostAdapter!=0 */
524     SRB         tmpsrb;
525     char        inqbuf[200];
526     DWORD       ret;
527
528     memset(&tmpsrb,0,sizeof(tmpsrb));
529
530     /* Copy header */
531     memcpy(&tmpsrb.common,&(lpSRB->common),sizeof(tmpsrb.common));
532
533     tmpsrb.cmd.SRB_Flags        |= 8; /* target to host */
534     tmpsrb.cmd.SRB_Cmd          = SC_EXEC_SCSI_CMD;
535     tmpsrb.cmd.SRB_Target       = lpSRB->devtype.SRB_Target;
536     tmpsrb.cmd.SRB_Lun          = lpSRB->devtype.SRB_Lun;
537     tmpsrb.cmd.SRB_BufLen       = sizeof(inqbuf);
538     tmpsrb.cmd.SRB_BufPointer   = inqbuf;
539     tmpsrb.cmd.CDBByte[0]       = 0x12; /* INQUIRY  */
540                                   /* FIXME: handle lun */
541     tmpsrb.cmd.CDBByte[4]       = sizeof(inqbuf);
542     tmpsrb.cmd.SRB_CDBLen       = 6;
543
544     ret = ASPI_ExecScsiCmd(&tmpsrb.cmd);
545
546     lpSRB->devtype.SRB_Status   = tmpsrb.cmd.SRB_Status;
547     lpSRB->devtype.SRB_DeviceType = inqbuf[0]&0x1f;
548
549     TRACE("returning devicetype %d for target %d\n",inqbuf[0]&0x1f,tmpsrb.cmd.SRB_Target);
550     if (ret!=SS_PENDING) /* Any error is passed down directly */
551         return ret;
552     /* FIXME: knows that the command is finished already, pass final Status */
553     return tmpsrb.cmd.SRB_Status;
554   }
555   case SC_EXEC_SCSI_CMD:
556     return ASPI_ExecScsiCmd(&lpSRB->cmd);
557   case SC_ABORT_SRB:
558     FIXME("Not implemented SC_ABORT_SRB\n");
559     break;
560   case SC_RESET_DEV:
561     FIXME("Not implemented SC_RESET_DEV\n");
562     break;
563   case SC_GET_DISK_INFO:
564     /* here we have to find out the int13 / bios association.
565      * We just say we do not have any.
566      */
567     FIXME("SC_GET_DISK_INFO always return 'int13 unassociated disk'.\n");
568     lpSRB->diskinfo.SRB_DriveFlags = 0; /* disk is not int13 served */
569     return SS_COMP;
570   default:
571     FIXME("Unknown command %d\n", lpSRB->common.SRB_Cmd);
572   }
573   return SS_INVALID_SRB;
574 #else
575   return SS_INVALID_SRB;
576 #endif
577 }
578
579
580 /***********************************************************************
581  *             GetASPI32DLLVersion   (WNASPI32.4)
582  */
583 DWORD __cdecl GetASPI32DLLVersion(void)
584 {
585 #ifdef linux
586         TRACE("Returning version 1\n");
587         return (DWORD)1;
588 #else
589         FIXME("Please add SCSI support for your operating system, returning 0\n");
590         return (DWORD)0;
591 #endif
592 }
593
594 /***********************************************************************
595  *             GetASPI32Buffer   (WNASPI32.8)
596  * Supposed to return a DMA capable large SCSI buffer.
597  * Our implementation does not use those at all, all buffer stuff is
598  * done in the kernel SG device layer. So we just heapalloc the buffer.
599  */
600 BOOL __cdecl GetASPI32Buffer(PASPI32BUFF pab)
601 {
602     pab->AB_BufPointer = HeapAlloc(GetProcessHeap(),
603                 pab->AB_ZeroFill?HEAP_ZERO_MEMORY:0,
604                 pab->AB_BufLen
605     );
606     if (!pab->AB_BufPointer) return FALSE;
607     return TRUE;
608 }
609
610 /***********************************************************************
611  *             FreeASPI32Buffer   (WNASPI32.14)
612  */
613 BOOL __cdecl FreeASPI32Buffer(PASPI32BUFF pab)
614 {
615     HeapFree(GetProcessHeap(),0,pab->AB_BufPointer);
616     return TRUE;
617 }
618
619 /***********************************************************************
620  *             TranslateASPI32Address   (WNASPI32.7)
621  */
622 BOOL __cdecl TranslateASPI32Address(LPDWORD pdwPath, LPDWORD pdwDEVNODE)
623 {
624     FIXME("(%p, %p), stub !\n", pdwPath, pdwDEVNODE);
625     return TRUE;
626 }