winaspi16.c 12.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Copyright 1997 Bruce Milner
 * Copyright 1998 Andreas Mohr
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

20
#include "config.h"
21
#include "wine/port.h"
22

Alexandre Julliard's avatar
Alexandre Julliard committed
23 24 25 26
#include <stdlib.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
27 28 29
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
30
#include <string.h>
31
#include <stdarg.h>
32
#include <stdio.h>
33

34
#include "windef.h"
35
#include "winbase.h"
36
#include "wine/windef16.h"
37
#include "winreg.h"
38
#include "wownt32.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
39
#include "aspi.h"
40
#include "winescsi.h"
41
#include "wine/winaspi.h"
42
#include "wine/debug.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
43

44
WINE_DEFAULT_DEBUG_CHANNEL(aspi);
45

Alexandre Julliard's avatar
Alexandre Julliard committed
46 47 48 49 50 51 52 53

/* FIXME!
 * 1) Residual byte length reporting not handled
 * 2) Make this code re-entrant for multithreading
 * 3) Only linux supported so far
 */

#ifdef linux
54

55 56 57
#define PTR_TO_LIN(ptr,mode) \
  ((mode) == ASPI_DOS ? ((void*)(((unsigned int)SELECTOROF(ptr) << 4) + OFFSETOF(ptr))) : MapSL(ptr))

Patrik Stridvall's avatar
Patrik Stridvall committed
58 59
static ASPI_DEVICE_INFO *ASPI_open_devices = NULL;

60 61 62
static FARPROC16 ASPIChainFunc = NULL;
static WORD HA_Count = 1; /* host adapter count; FIXME: detect it */

Alexandre Julliard's avatar
Alexandre Julliard committed
63 64 65
static int
ASPI_OpenDevice16(SRB_ExecSCSICmd16 *prb)
{
66
    HKEY hkey;
Alexandre Julliard's avatar
Alexandre Julliard committed
67
    int	fd;
68
    char	idstr[50];
Alexandre Julliard's avatar
Alexandre Julliard committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    char	device_str[50];
    ASPI_DEVICE_INFO *curr;

    /* search list of devices to see if we've opened it already.
     * There is not an explicit open/close in ASPI land, so hopefully
     * keeping a device open won't be a problem.
     */

    for (curr = ASPI_open_devices; curr; curr = curr->next) {
	if (curr->hostId == prb->SRB_HaId &&
	    curr->target == prb->SRB_Target &&
	    curr->lun == prb->SRB_Lun) {
	    return curr->fd;
	}
    }

    /* device wasn't cached, go ahead and open it */
86 87
    sprintf( idstr, "Software\\Wine\\Wine\\Config\\scsi c%1dt%1dd%1d",
             prb->SRB_HaId, prb->SRB_Target, prb->SRB_Lun);
Alexandre Julliard's avatar
Alexandre Julliard committed
88

89 90 91 92
    device_str[0] = 0;
    if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, idstr, 0, KEY_ALL_ACCESS, &hkey ))
    {
        DWORD type, count = sizeof(device_str);
93
        if (RegQueryValueExA( hkey, "Device", 0, &type, (LPBYTE)device_str, &count )) device_str[0] = 0;
94 95 96 97 98
        RegCloseKey( hkey );
    }

    if (!device_str[0])
    {
99
	TRACE("Trying to open unlisted scsi device %s\n", idstr);
Alexandre Julliard's avatar
Alexandre Julliard committed
100 101 102
	return -1;
    }

103
    TRACE("Opening device %s=%s\n", idstr, device_str);
Alexandre Julliard's avatar
Alexandre Julliard committed
104 105 106 107

    fd = open(device_str, O_RDWR);
    if (fd == -1) {
	int save_error = errno;
108
	ERR("Error opening device %s, error '%s'\n", device_str, strerror(save_error));
Alexandre Julliard's avatar
Alexandre Julliard committed
109 110 111 112
	return -1;
    }

    /* device is now open */
113
    curr = HeapAlloc( GetProcessHeap(), 0, sizeof(ASPI_DEVICE_INFO) );
Alexandre Julliard's avatar
Alexandre Julliard committed
114 115 116 117 118 119 120 121 122 123 124 125 126
    curr->fd = fd;
    curr->hostId = prb->SRB_HaId;
    curr->target = prb->SRB_Target;
    curr->lun = prb->SRB_Lun;

    /* insert new record at beginning of open device list */
    curr->next = ASPI_open_devices;
    ASPI_open_devices = curr;
    return fd;
}


static void
Alexandre Julliard's avatar
Alexandre Julliard committed
127
ASPI_DebugPrintCmd(SRB_ExecSCSICmd16 *prb, UINT16 mode)
Alexandre Julliard's avatar
Alexandre Julliard committed
128 129 130 131
{
  BYTE	cmd;
  int	i;
  BYTE *cdb;
132
  BYTE *lpBuf = PTR_TO_LIN( prb->SRB_BufPointer, mode );
Alexandre Julliard's avatar
Alexandre Julliard committed
133 134 135

  switch (prb->CDBByte[0]) {
  case CMD_INQUIRY:
136 137 138 139 140 141 142
    TRACE("{\n");
    TRACE("\tEVPD: %d\n", prb->CDBByte[1] & 1);
    TRACE("\tLUN: %d\n", (prb->CDBByte[1] & 0xc) >> 1);
    TRACE("\tPAGE CODE: %d\n", prb->CDBByte[2]);
    TRACE("\tALLOCATION LENGTH: %d\n", prb->CDBByte[4]);
    TRACE("\tCONTROL: %d\n", prb->CDBByte[5]);
    TRACE("}\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
143 144
    break;
  case CMD_SCAN_SCAN:
145
    TRACE("Transfer Length: %d\n", prb->CDBByte[4]);
Alexandre Julliard's avatar
Alexandre Julliard committed
146 147 148
    break;
  }

149 150
  TRACE("Host Adapter: %d\n", prb->SRB_HaId);
  TRACE("Flags: %d\n", prb->SRB_Flags);
Alexandre Julliard's avatar
Alexandre Julliard committed
151
  if (TARGET_TO_HOST(prb)) {
152
    TRACE("\tData transfer: Target to host. Length checked.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
153 154
  }
  else if (HOST_TO_TARGET(prb)) {
155
    TRACE("\tData transfer: Host to target. Length checked.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
156
  }
157
  else if (NO_DATA_TRANSFERRED(prb)) {
158
    TRACE("\tData transfer: none\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
159 160
  }
  else {
161
    WARN("\tTransfer by scsi cmd. Length not checked\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
162 163
  }

164 165 166 167 168 169 170 171 172 173 174
  TRACE("\tResidual byte length reporting %s\n", prb->SRB_Flags & 0x4 ? "enabled" : "disabled");
  TRACE("\tLinking %s\n", prb->SRB_Flags & 0x2 ? "enabled" : "disabled");
  TRACE("\tPosting %s\n", prb->SRB_Flags & 0x1 ? "enabled" : "disabled");
  TRACE("Target: %d\n", prb->SRB_Target);
  TRACE("Lun: %d\n", prb->SRB_Lun);
  TRACE("BufLen: %ld\n", prb->SRB_BufLen);
  TRACE("SenseLen: %d\n", prb->SRB_SenseLen);
  TRACE("BufPtr: %lx (%p)\n", prb->SRB_BufPointer, lpBuf);
  TRACE("LinkPointer %lx\n", prb->SRB_Rsvd1);
  TRACE("CDB Length: %d\n", prb->SRB_CDBLen);
  TRACE("POST Proc: %lx\n", (DWORD) prb->SRB_PostProc);
Alexandre Julliard's avatar
Alexandre Julliard committed
175 176
  cdb = &prb->CDBByte[0];
  cmd = prb->CDBByte[0];
177 178
  if (TRACE_ON(aspi))
  {
179
      TRACE("CDB buffer[");
180
      for (i = 0; i < prb->SRB_CDBLen; i++) {
181 182
          if (i != 0) TRACE(",");
          TRACE("%02x", *cdb++);
183
      }
184
      TRACE("]\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
185 186 187 188
  }
}

static void
Alexandre Julliard's avatar
Alexandre Julliard committed
189
ASPI_PrintSenseArea16(SRB_ExecSCSICmd16 *prb)
Alexandre Julliard's avatar
Alexandre Julliard committed
190 191 192 193
{
  int	i;
  BYTE *cdb;

194 195 196
  if (TRACE_ON(aspi))
  {
      cdb = &prb->CDBByte[0];
197
      TRACE("SenseArea[");
198
      for (i = 0; i < prb->SRB_SenseLen; i++) {
199 200
          if (i) TRACE(",");
          TRACE("%02x", *cdb++);
201
      }
202
      TRACE("]\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
203 204 205 206
  }
}

static void
Alexandre Julliard's avatar
Alexandre Julliard committed
207
ASPI_DebugPrintResult(SRB_ExecSCSICmd16 *prb, UINT16 mode)
Alexandre Julliard's avatar
Alexandre Julliard committed
208
{
209
  BYTE *lpBuf = PTR_TO_LIN( prb->SRB_BufPointer, mode );
Alexandre Julliard's avatar
Alexandre Julliard committed
210 211 212

  switch (prb->CDBByte[0]) {
  case CMD_INQUIRY:
213
    TRACE("Vendor: '%s'\n", lpBuf + INQUIRY_VENDOR);
Alexandre Julliard's avatar
Alexandre Julliard committed
214 215
    break;
  case CMD_TEST_UNIT_READY:
Alexandre Julliard's avatar
Alexandre Julliard committed
216
    ASPI_PrintSenseArea16(prb);
Alexandre Julliard's avatar
Alexandre Julliard committed
217 218 219 220 221
    break;
  }
}

static WORD
Alexandre Julliard's avatar
Alexandre Julliard committed
222
ASPI_ExecScsiCmd(DWORD ptrPRB, UINT16 mode)
Alexandre Julliard's avatar
Alexandre Julliard committed
223
{
224
  SRB_ExecSCSICmd16 *lpPRB = PTR_TO_LIN( ptrPRB, mode );
Alexandre Julliard's avatar
Alexandre Julliard committed
225 226
  struct sg_header *sg_hd, *sg_reply_hdr;
  int	status;
Alexandre Julliard's avatar
Alexandre Julliard committed
227
  BYTE *lpBuf = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
228 229 230 231
  int	in_len, out_len;
  int	error_code = 0;
  int	fd;

Alexandre Julliard's avatar
Alexandre Julliard committed
232
  ASPI_DebugPrintCmd(lpPRB, mode);
Alexandre Julliard's avatar
Alexandre Julliard committed
233

Alexandre Julliard's avatar
Alexandre Julliard committed
234
  fd = ASPI_OpenDevice16(lpPRB);
Alexandre Julliard's avatar
Alexandre Julliard committed
235
  if (fd == -1) {
236
      WARN("Failed: could not open device. Device permissions !?\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
237
      lpPRB->SRB_Status = SS_ERR;
Alexandre Julliard's avatar
Alexandre Julliard committed
238 239 240 241 242 243
      return SS_ERR;
  }

  sg_hd = NULL;
  sg_reply_hdr = NULL;

Alexandre Julliard's avatar
Alexandre Julliard committed
244
  lpPRB->SRB_Status = SS_PENDING;
245
  lpBuf = PTR_TO_LIN( lpPRB->SRB_BufPointer, mode );
Alexandre Julliard's avatar
Alexandre Julliard committed
246

Alexandre Julliard's avatar
Alexandre Julliard committed
247
  if (!lpPRB->SRB_CDBLen) {
248
      WARN("Failed: lpPRB->SRB_CDBLen = 0.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
249
      lpPRB->SRB_Status = SS_ERR;
Alexandre Julliard's avatar
Alexandre Julliard committed
250 251 252 253
      return SS_ERR;
  }

  /* build up sg_header + scsi cmd */
Alexandre Julliard's avatar
Alexandre Julliard committed
254
  if (HOST_TO_TARGET(lpPRB)) {
Alexandre Julliard's avatar
Alexandre Julliard committed
255
    /* send header, command, and then data */
Alexandre Julliard's avatar
Alexandre Julliard committed
256
    in_len = SCSI_OFF + lpPRB->SRB_CDBLen + lpPRB->SRB_BufLen;
Alexandre Julliard's avatar
Alexandre Julliard committed
257 258
    sg_hd = (struct sg_header *) malloc(in_len);
    memset(sg_hd, 0, SCSI_OFF);
Alexandre Julliard's avatar
Alexandre Julliard committed
259 260 261
    memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
    if (lpPRB->SRB_BufLen) {
      memcpy(((BYTE *) sg_hd) + SCSI_OFF + lpPRB->SRB_CDBLen, lpBuf, lpPRB->SRB_BufLen);
Alexandre Julliard's avatar
Alexandre Julliard committed
262 263 264 265
    }
  }
  else {
    /* send header and command - no data */
Alexandre Julliard's avatar
Alexandre Julliard committed
266
    in_len = SCSI_OFF + lpPRB->SRB_CDBLen;
Alexandre Julliard's avatar
Alexandre Julliard committed
267 268
    sg_hd = (struct sg_header *) malloc(in_len);
    memset(sg_hd, 0, SCSI_OFF);
Alexandre Julliard's avatar
Alexandre Julliard committed
269
    memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
Alexandre Julliard's avatar
Alexandre Julliard committed
270 271
  }

Alexandre Julliard's avatar
Alexandre Julliard committed
272 273
  if (TARGET_TO_HOST(lpPRB)) {
    out_len = SCSI_OFF + lpPRB->SRB_BufLen;
Alexandre Julliard's avatar
Alexandre Julliard committed
274 275 276 277 278 279 280 281 282 283 284 285 286
    sg_reply_hdr = (struct sg_header *) malloc(out_len);
    memset(sg_reply_hdr, 0, SCSI_OFF);
    sg_hd->reply_len = out_len;
  }
  else {
    out_len = SCSI_OFF;
    sg_reply_hdr = (struct sg_header *) malloc(out_len);
    memset(sg_reply_hdr, 0, SCSI_OFF);
    sg_hd->reply_len = out_len;
  }

  status = write(fd, sg_hd, in_len);
  if (status < 0 || status != in_len) {
287
      int save_error = errno;
Alexandre Julliard's avatar
Alexandre Julliard committed
288

289
    WARN("Not enough bytes written to scsi device bytes=%d .. %d\n", in_len, status);
Alexandre Julliard's avatar
Alexandre Julliard committed
290
    if (status < 0) {
291
		if (save_error == ENOMEM) {
292
	    MESSAGE("ASPI: Linux generic scsi driver\n  You probably need to re-compile your kernel with a larger SG_BIG_BUFF value (sg.h)\n  Suggest 130560\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
293
	}
294
		WARN("error:= '%s'\n", strerror(save_error));
Alexandre Julliard's avatar
Alexandre Julliard committed
295 296 297 298 299 300
    }
    goto error_exit;
  }

  status = read(fd, sg_reply_hdr, out_len);
  if (status < 0 || status != out_len) {
301
    WARN("not enough bytes read from scsi device%d\n", status);
Alexandre Julliard's avatar
Alexandre Julliard committed
302 303 304 305 306
    goto error_exit;
  }

  if (sg_reply_hdr->result != 0) {
    error_code = sg_reply_hdr->result;
307
    WARN("reply header error (%d)\n", sg_reply_hdr->result);
Alexandre Julliard's avatar
Alexandre Julliard committed
308 309 310
    goto error_exit;
  }

Alexandre Julliard's avatar
Alexandre Julliard committed
311 312
  if (TARGET_TO_HOST(lpPRB) && lpPRB->SRB_BufLen) {
    memcpy(lpBuf, sg_reply_hdr + 1, lpPRB->SRB_BufLen);
Alexandre Julliard's avatar
Alexandre Julliard committed
313 314 315
  }

  /* copy in sense buffer to amount that is available in client */
Alexandre Julliard's avatar
Alexandre Julliard committed
316 317 318
  if (lpPRB->SRB_SenseLen) {
    int sense_len = lpPRB->SRB_SenseLen;
    if (lpPRB->SRB_SenseLen > 16)
Alexandre Julliard's avatar
Alexandre Julliard committed
319
      sense_len = 16;
Alexandre Julliard's avatar
Alexandre Julliard committed
320
    memcpy(SENSE_BUFFER(lpPRB), &sg_reply_hdr->sense_buffer[0], sense_len);
Alexandre Julliard's avatar
Alexandre Julliard committed
321 322 323
  }


Alexandre Julliard's avatar
Alexandre Julliard committed
324 325 326 327 328
  lpPRB->SRB_Status = SS_COMP;
  lpPRB->SRB_HaStat = HASTAT_OK;
  lpPRB->SRB_TargStat = STATUS_GOOD;

  /* now do posting */
Alexandre Julliard's avatar
Alexandre Julliard committed
329

Alexandre Julliard's avatar
Alexandre Julliard committed
330
  if (ASPI_POSTING(lpPRB) && lpPRB->SRB_PostProc) {
331
    TRACE("Post Routine (%lx) called\n", (DWORD) lpPRB->SRB_PostProc);
Alexandre Julliard's avatar
Alexandre Julliard committed
332 333 334 335 336
    switch (mode)
    {
      case ASPI_DOS:
      {
	SEGPTR spPRB = MapLS(lpPRB);
Alexandre Julliard's avatar
Alexandre Julliard committed
337

338
        WOWCallback16((DWORD)lpPRB->SRB_PostProc, spPRB);
Alexandre Julliard's avatar
Alexandre Julliard committed
339 340 341 342
	UnMapLS(spPRB);
	break;
      }
      case ASPI_WIN16:
343
        WOWCallback16((DWORD)lpPRB->SRB_PostProc, ptrPRB);
Alexandre Julliard's avatar
Alexandre Julliard committed
344 345
	break;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
346 347 348 349
  }

  free(sg_reply_hdr);
  free(sg_hd);
Alexandre Julliard's avatar
Alexandre Julliard committed
350
  ASPI_DebugPrintResult(lpPRB, mode);
Alexandre Julliard's avatar
Alexandre Julliard committed
351
  return SS_COMP;
352

Alexandre Julliard's avatar
Alexandre Julliard committed
353 354
error_exit:
  if (error_code == EBUSY) {
Alexandre Julliard's avatar
Alexandre Julliard committed
355
      lpPRB->SRB_Status = SS_ASPI_IS_BUSY;
356
      TRACE("Device busy\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
357 358
  }
  else {
359
      WARN("Failed\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
360
      lpPRB->SRB_Status = SS_ERR;
Alexandre Julliard's avatar
Alexandre Julliard committed
361 362 363
  }

  /* I'm not sure exactly error codes work here
Alexandre Julliard's avatar
Alexandre Julliard committed
364
   * We probably should set lpPRB->SRB_TargStat, SRB_HaStat ?
Alexandre Julliard's avatar
Alexandre Julliard committed
365
   */
366
  WARN("error_exit\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
367 368
  free(sg_reply_hdr);
  free(sg_hd);
Alexandre Julliard's avatar
Alexandre Julliard committed
369
  return lpPRB->SRB_Status;
Alexandre Julliard's avatar
Alexandre Julliard committed
370 371 372
}
#endif

Alexandre Julliard's avatar
Alexandre Julliard committed
373

Alexandre Julliard's avatar
Alexandre Julliard committed
374
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
375
 *             GetASPISupportInfo   (WINASPI.1)
Alexandre Julliard's avatar
Alexandre Julliard committed
376 377
 */

378
WORD WINAPI GetASPISupportInfo16(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
379 380
{
#ifdef linux
381
    TRACE("GETASPISupportInfo16\n");
382 383
    /* high byte SS_COMP - low byte number of host adapters */
    return ((SS_COMP << 8) | HA_Count);
Alexandre Julliard's avatar
Alexandre Julliard committed
384
#else
385
    return ((SS_NO_ASPI << 8) | 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
386 387 388 389
#endif
}


Alexandre Julliard's avatar
Alexandre Julliard committed
390
DWORD ASPI_SendASPICommand(DWORD ptrSRB, UINT16 mode)
Alexandre Julliard's avatar
Alexandre Julliard committed
391 392
{
#ifdef linux
393
  LPSRB16 lpSRB = PTR_TO_LIN( ptrSRB, mode );
Mike McCormack's avatar
Mike McCormack committed
394 395
  static const char szId[] = "Wine ASPI16";
  static const char szWh[] = "Wine host";
Alexandre Julliard's avatar
Alexandre Julliard committed
396

397
  if (mode == ASPI_WIN16 && ASPIChainFunc)
Alexandre Julliard's avatar
Alexandre Julliard committed
398
  {
399 400 401 402 403 404 405
      /* This is not the post proc, it's the chain proc this time */
      DWORD ret = WOWCallback16((DWORD)ASPIChainFunc, ptrSRB);
      if (ret)
      {
          lpSRB->inquiry.SRB_Status = SS_INVALID_SRB;
          return ret;
      }
Alexandre Julliard's avatar
Alexandre Julliard committed
406
  }
Alexandre Julliard's avatar
Alexandre Julliard committed
407

Alexandre Julliard's avatar
Alexandre Julliard committed
408
  switch (lpSRB->common.SRB_Cmd) {
Alexandre Julliard's avatar
Alexandre Julliard committed
409
  case SC_HA_INQUIRY:
Alexandre Julliard's avatar
Alexandre Julliard committed
410 411
    lpSRB->inquiry.SRB_Status = SS_COMP;       /* completed successfully */
    if (lpSRB->inquiry.SRB_55AASignature == 0x55aa) {
412
	TRACE("Extended request detected (Adaptec's ASPIxDOS).\nWe don't support it at the moment.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
413 414
    }
    lpSRB->inquiry.SRB_ExtBufferSize = 0x2000; /* bogus value */
415
    lpSRB->inquiry.HA_Count = HA_Count;
Alexandre Julliard's avatar
Alexandre Julliard committed
416
    lpSRB->inquiry.HA_SCSI_ID = 7;             /* not always ID 7 */
Mike McCormack's avatar
Mike McCormack committed
417 418
    memcpy(lpSRB->inquiry.HA_ManagerId, szId, sizeof szId); /* max 15 chars */
    memcpy(lpSRB->inquiry.HA_Identifier, szWh, sizeof szWh); /* FIXME: return host
Alexandre Julliard's avatar
Alexandre Julliard committed
419 420 421
adapter name */
    memset(lpSRB->inquiry.HA_Unique, 0, 16); /* default HA_Unique content */
    lpSRB->inquiry.HA_Unique[6] = 0x02; /* Maximum Transfer Length (128K, Byte> 4-7) */
422
    FIXME("ASPI: Partially implemented SC_HA_INQUIRY for adapter %d.\n", lpSRB->inquiry.SRB_HaId);
Alexandre Julliard's avatar
Alexandre Julliard committed
423
    return SS_COMP;
Alexandre Julliard's avatar
Alexandre Julliard committed
424
  case SC_GET_DEV_TYPE:
425
    FIXME("Not implemented SC_GET_DEV_TYPE\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
426 427
    break;
  case SC_EXEC_SCSI_CMD:
Alexandre Julliard's avatar
Alexandre Julliard committed
428
    return ASPI_ExecScsiCmd((DWORD)ptrSRB, mode);
Alexandre Julliard's avatar
Alexandre Julliard committed
429
  case SC_RESET_DEV:
430
    FIXME("Not implemented SC_RESET_DEV\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
431 432
    break;
  default:
433
    FIXME("Unknown command %d\n", lpSRB->common.SRB_Cmd);
Alexandre Julliard's avatar
Alexandre Julliard committed
434 435
  }
#endif
436
  return SS_INVALID_SRB;
Alexandre Julliard's avatar
Alexandre Julliard committed
437
}
Alexandre Julliard's avatar
Alexandre Julliard committed
438

Alexandre Julliard's avatar
Alexandre Julliard committed
439

Alexandre Julliard's avatar
Alexandre Julliard committed
440
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
441
 *             SendASPICommand   (WINASPI.2)
Alexandre Julliard's avatar
Alexandre Julliard committed
442
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
443 444 445 446 447
WORD WINAPI SendASPICommand16(SEGPTR segptr_srb)
{
#ifdef linux
    return ASPI_SendASPICommand(segptr_srb, ASPI_WIN16);
#else
448
    return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
449 450
#endif
}
Alexandre Julliard's avatar
Alexandre Julliard committed
451

Alexandre Julliard's avatar
Alexandre Julliard committed
452

453
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
454
 *             InsertInASPIChain   (WINASPI.3)
455 456 457 458
 */
WORD WINAPI InsertInASPIChain16(BOOL16 remove, FARPROC16 pASPIChainFunc)
{
#ifdef linux
459
    if (remove) /* Remove */
460 461 462 463 464 465 466
    {
	if (ASPIChainFunc == pASPIChainFunc)
	{
	    ASPIChainFunc = NULL;
	    return SS_COMP;
	}
    }
467
    else /* Insert */
468 469 470 471 472 473 474 475 476 477 478 479
    {
	if (ASPIChainFunc == NULL)
	{
	    ASPIChainFunc = pASPIChainFunc;
	    return SS_COMP;
	}
    }
#endif
    return SS_ERR;
}


Alexandre Julliard's avatar
Alexandre Julliard committed
480
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
481
 *             GETASPIDLLVERSION   (WINASPI.4)
Alexandre Julliard's avatar
Alexandre Julliard committed
482 483
 */

484
DWORD WINAPI GetASPIDLLVersion16(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
485 486
{
#ifdef linux
487
	return 2;
Alexandre Julliard's avatar
Alexandre Julliard committed
488
#else
489
	return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
490 491
#endif
}