win-pvdrivers

changeset 1049:4de2eb034713 0.11.0.402

Fix xenvbd under xp
author James Harper <james.harper@bendigoit.com.au>
date Mon May 13 21:19:23 2013 +1000 (2013-05-13)
parents fba0ce4d9e54
children 6bc417576ada
files xenvbd_common/common_miniport.h xenvbd_scsiport/xenvbd.c
line diff
     1.1 --- a/xenvbd_common/common_miniport.h	Mon May 13 21:14:35 2013 +1000
     1.2 +++ b/xenvbd_common/common_miniport.h	Mon May 13 21:19:23 2013 +1000
     1.3 @@ -63,10 +63,8 @@ put_shadow_on_freelist(PXENVBD_DEVICE_DA
     1.4  }
     1.5  
     1.6  static __inline ULONG
     1.7 -decode_cdb_length(PSCSI_REQUEST_BLOCK srb)
     1.8 -{
     1.9 -  switch (srb->Cdb[0])
    1.10 -  {
    1.11 +decode_cdb_length(PSCSI_REQUEST_BLOCK srb) {
    1.12 +  switch (srb->Cdb[0]) {
    1.13    case SCSIOP_READ:
    1.14    case SCSIOP_WRITE:
    1.15      return ((ULONG)(UCHAR)srb->Cdb[7] << 8) | (ULONG)(UCHAR)srb->Cdb[8];
    1.16 @@ -74,6 +72,7 @@ decode_cdb_length(PSCSI_REQUEST_BLOCK sr
    1.17    case SCSIOP_WRITE16:
    1.18      return ((ULONG)(UCHAR)srb->Cdb[10] << 24) | ((ULONG)(UCHAR)srb->Cdb[11] << 16) | ((ULONG)(UCHAR)srb->Cdb[12] << 8) | (ULONG)(UCHAR)srb->Cdb[13];    
    1.19    default:
    1.20 +    FUNCTION_MSG("Unknown SCSIOP function %02x\n", srb->Cdb[0]);
    1.21      return 0;
    1.22    }
    1.23  }
    1.24 @@ -105,8 +104,7 @@ decode_cdb_sector(PSCSI_REQUEST_BLOCK sr
    1.25  {
    1.26    ULONGLONG sector;
    1.27    
    1.28 -  switch (srb->Cdb[0])
    1.29 -  {
    1.30 +  switch (srb->Cdb[0]) {
    1.31    case SCSIOP_READ:
    1.32    case SCSIOP_WRITE:
    1.33      sector = ((ULONG)(UCHAR)srb->Cdb[2] << 24) | ((ULONG)(UCHAR)srb->Cdb[3] << 16) | ((ULONG)(UCHAR)srb->Cdb[4] << 8) | (ULONG)(UCHAR)srb->Cdb[5];
    1.34 @@ -120,6 +118,7 @@ decode_cdb_sector(PSCSI_REQUEST_BLOCK sr
    1.35      //FUNCTION_MSG("sector_number = %d (high) %d (low)\n", (ULONG)(sector >> 32), (ULONG)sector);
    1.36      break;
    1.37    default:
    1.38 +    FUNCTION_MSG("Unknown SCSIOP function %02x\n", srb->Cdb[0]);
    1.39      sector = 0;
    1.40      break;
    1.41    }
    1.42 @@ -138,6 +137,7 @@ decode_cdb_is_read(PSCSI_REQUEST_BLOCK s
    1.43    case SCSIOP_WRITE16:
    1.44      return FALSE;
    1.45    default:
    1.46 +    FUNCTION_MSG("Unknown SCSIOP function %02x\n", srb->Cdb[0]);
    1.47      return FALSE;
    1.48    }
    1.49  }
    1.50 @@ -452,8 +452,8 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
    1.51    return TRUE;
    1.52  }
    1.53  
    1.54 -static ULONG
    1.55 -XenVbd_FillModePage(PXENVBD_DEVICE_DATA xvdd, PSCSI_REQUEST_BLOCK srb) {
    1.56 +static UCHAR
    1.57 +XenVbd_FillModePage(PXENVBD_DEVICE_DATA xvdd, PSCSI_REQUEST_BLOCK srb, PULONG data_transfer_length) {
    1.58    PMODE_PARAMETER_HEADER parameter_header = NULL;
    1.59    PMODE_PARAMETER_HEADER10 parameter_header10 = NULL;
    1.60    PMODE_PARAMETER_BLOCK param_block;
    1.61 @@ -585,19 +585,15 @@ XenVbd_FillModePage(PXENVBD_DEVICE_DATA 
    1.62    }
    1.63  
    1.64    if (!valid_page && cdb_page_code != MODE_SENSE_RETURN_ALL) {
    1.65 -    srb->SrbStatus = SRB_STATUS_ERROR;
    1.66 +    srb->ScsiStatus = 0; // TODO: make this something meaningful
    1.67 +    *data_transfer_length = 0;
    1.68 +    return SRB_STATUS_ERROR;
    1.69    }
    1.70 -  else if(offset < srb->DataTransferLength)
    1.71 -    srb->SrbStatus = SRB_STATUS_DATA_OVERRUN;
    1.72 -  else
    1.73 -    srb->SrbStatus = SRB_STATUS_SUCCESS;
    1.74 -  srb->DataTransferLength = min(srb->DataTransferLength, offset);
    1.75    srb->ScsiStatus = 0;
    1.76 -  memcpy(srb->DataBuffer, buffer, srb->DataTransferLength);
    1.77 -  
    1.78 -  //FUNCTION_EXIT();
    1.79 +  memcpy(srb->DataBuffer, buffer, min(srb->DataTransferLength, offset));
    1.80 +  *data_transfer_length = offset;
    1.81  
    1.82 -  return TRUE;
    1.83 +  return SRB_STATUS_SUCCESS;
    1.84  }
    1.85  
    1.86  static BOOLEAN
    1.87 @@ -742,8 +738,8 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
    1.88          data_buffer = srb->DataBuffer;
    1.89          RtlZeroMemory(data_buffer, srb->DataTransferLength);
    1.90          srb_status = SRB_STATUS_SUCCESS;
    1.91 -        switch (xvdd->device_type)
    1.92 -        {
    1.93 +        srb->ScsiStatus = 0;
    1.94 +        switch (xvdd->device_type) {
    1.95          case XENVBD_DEVICETYPE_DISK:
    1.96            if ((srb->Cdb[1] & 1) == 0) {
    1.97              if (srb->Cdb[2]) {
    1.98 @@ -765,7 +761,7 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
    1.99            } else {
   1.100              switch (srb->Cdb[2]) {
   1.101              case VPD_SUPPORTED_PAGES: /* list of pages we support */
   1.102 -              FUNCTION_MSG("VPD_SUPPORTED_PAGES\n");
   1.103 +              FUNCTION_MSG("VPD_SUPPORTED_PAGES - length = %d\n", srb->DataTransferLength);
   1.104                data_buffer[0] = DIRECT_ACCESS_DEVICE;
   1.105                data_buffer[1] = VPD_SUPPORTED_PAGES;
   1.106                data_buffer[2] = 0x00;
   1.107 @@ -884,7 +880,6 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.108          //FUNCTION_MSG("  LUN = %d, RelAdr = %d\n", srb->Cdb[1] >> 4, srb->Cdb[1] & 1);
   1.109          //FUNCTION_MSG("  LBA = %02x%02x%02x%02x\n", srb->Cdb[2], srb->Cdb[3], srb->Cdb[4], srb->Cdb[5]);
   1.110          //FUNCTION_MSG("  PMI = %d\n", srb->Cdb[8] & 1);
   1.111 -        //data_buffer = LongLongToPtr(ScsiPortGetPhysicalAddress(xvdd, srb, srb->DataBuffer, &data_buffer_length).QuadPart);
   1.112          data_buffer = srb->DataBuffer;
   1.113          RtlZeroMemory(data_buffer, srb->DataTransferLength);
   1.114          if ((xvdd->total_sectors - 1) >> 32) {
   1.115 @@ -955,14 +950,12 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.116        case SCSIOP_MODE_SENSE10:
   1.117          if (dump_mode)
   1.118            FUNCTION_MSG("Command = MODE_SENSE (DBD = %d, PC = %d, Page Code = %02x)\n", srb->Cdb[1] & 0x08, srb->Cdb[2] & 0xC0, srb->Cdb[2] & 0x3F);
   1.119 -        data_transfer_length = XenVbd_FillModePage(xvdd, srb);
   1.120 -        srb_status = SRB_STATUS_SUCCESS;
   1.121 +        srb_status = XenVbd_FillModePage(xvdd, srb, &data_transfer_length);
   1.122          break;
   1.123        case SCSIOP_READ:
   1.124        case SCSIOP_READ16:
   1.125        case SCSIOP_WRITE:
   1.126        case SCSIOP_WRITE16:
   1.127 -        //FUNCTION_MSG("srb = %p\n", srb);
   1.128          if (XenVbd_PutSrbOnRing(xvdd, srb)) {
   1.129            notify = TRUE;
   1.130          }
   1.131 @@ -1090,7 +1083,10 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.132          }
   1.133          if (data_transfer_length > srb->DataTransferLength)
   1.134            FUNCTION_MSG("data_transfer_length too big - %d > %d\n", data_transfer_length, srb->DataTransferLength);        
   1.135 +          srb->SrbStatus = SRB_STATUS_DATA_OVERRUN;
   1.136 +          srb->DataTransferLength = data_transfer_length;
   1.137          if (srb_status == SRB_STATUS_SUCCESS && data_transfer_length < srb->DataTransferLength) {
   1.138 +          FUNCTION_MSG("data_transfer_length too small - %d < %d\n", data_transfer_length, srb->DataTransferLength);        
   1.139            srb->SrbStatus = SRB_STATUS_DATA_OVERRUN;
   1.140            srb->DataTransferLength = data_transfer_length;
   1.141          } else {
     2.1 --- a/xenvbd_scsiport/xenvbd.c	Mon May 13 21:14:35 2013 +1000
     2.2 +++ b/xenvbd_scsiport/xenvbd.c	Mon May 13 21:19:23 2013 +1000
     2.3 @@ -73,7 +73,7 @@ XenVbd_NotificationNextLuRequest(PXENVBD
     2.4  
     2.5  VOID
     2.6  XenVbd_NotificationNextRequest(PXENVBD_DEVICE_DATA xvdd) {
     2.7 -  ScsiPortNotification(NextLuRequest, xvdd->xvsd);
     2.8 +  ScsiPortNotification(NextRequest, xvdd->xvsd);
     2.9  }
    2.10  
    2.11  
    2.12 @@ -153,9 +153,9 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    2.13  
    2.14    FUNCTION_MSG("MultipleRequestPerLu = %d\n", ConfigInfo->MultipleRequestPerLu);
    2.15    FUNCTION_MSG("TaggedQueuing = %d\n", ConfigInfo->TaggedQueuing);
    2.16 -  FUNCTION_MSG("AutoRequestSense  = %d\n", ConfigInfo->AutoRequestSense );
    2.17 -  ConfigInfo->ScatterGather = TRUE;
    2.18 -  ConfigInfo->Master = TRUE;
    2.19 +  FUNCTION_MSG("AutoRequestSense  = %d\n", ConfigInfo->AutoRequestSense);
    2.20 +  ConfigInfo->ScatterGather = FALSE; //TRUE;
    2.21 +  ConfigInfo->Master = FALSE; //TRUE;
    2.22    ConfigInfo->CachesData = FALSE;
    2.23    ConfigInfo->MapBuffers = TRUE;
    2.24    ConfigInfo->AlignmentMask = 0;
    2.25 @@ -163,12 +163,14 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    2.26    ConfigInfo->InitiatorBusId[0] = 1;
    2.27    ConfigInfo->MaximumNumberOfLogicalUnits = 1;
    2.28    ConfigInfo->MaximumNumberOfTargets = 2;
    2.29 +  #if 0
    2.30    if (ConfigInfo->Dma64BitAddresses == SCSI_DMA64_SYSTEM_SUPPORTED) {
    2.31      ConfigInfo->Dma64BitAddresses = SCSI_DMA64_MINIPORT_SUPPORTED;
    2.32      FUNCTION_MSG("Dma64BitAddresses supported\n");
    2.33    } else {
    2.34      FUNCTION_MSG("Dma64BitAddresses not supported\n");
    2.35    }
    2.36 +  #endif
    2.37    *Again = FALSE;
    2.38  
    2.39    FUNCTION_EXIT();