win-pvdrivers

diff xenvbd_common/common_miniport.h @ 1025:aa2e51f67f7c

Fix hibernate under Win8. Change debugprints.
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 19 15:14:53 2013 +1100 (2013-02-19)
parents 9c6af8d0bdb6
children 306c10cdcba1
line diff
     1.1 --- a/xenvbd_common/common_miniport.h	Tue Feb 19 15:13:22 2013 +1100
     1.2 +++ b/xenvbd_common/common_miniport.h	Tue Feb 19 15:14:53 2013 +1100
     1.3 @@ -40,10 +40,9 @@ ULONGLONG parse_numeric_string(PCHAR str
     1.4  
     1.5  /* called with StartIoLock held */
     1.6  static blkif_shadow_t *
     1.7 -get_shadow_from_freelist(PXENVBD_DEVICE_DATA xvdd)
     1.8 -{
     1.9 +get_shadow_from_freelist(PXENVBD_DEVICE_DATA xvdd) {
    1.10    if (xvdd->shadow_free == 0) {
    1.11 -    KdPrint((__DRIVER_NAME "     No more shadow entries\n"));
    1.12 +    FUNCTION_MSG("No more shadow entries\n");
    1.13      return NULL;
    1.14    }
    1.15    xvdd->shadow_free--;
    1.16 @@ -118,7 +117,7 @@ decode_cdb_sector(PSCSI_REQUEST_BLOCK sr
    1.17             | ((ULONGLONG)(UCHAR)srb->Cdb[4] << 40) | ((ULONGLONG)(UCHAR)srb->Cdb[5] << 32)
    1.18             | ((ULONGLONG)(UCHAR)srb->Cdb[6] << 24) | ((ULONGLONG)(UCHAR)srb->Cdb[7] << 16)
    1.19             | ((ULONGLONG)(UCHAR)srb->Cdb[8] << 8) | ((ULONGLONG)(UCHAR)srb->Cdb[9]);
    1.20 -    //KdPrint((__DRIVER_NAME "     sector_number = %d (high) %d (low)\n", (ULONG)(sector >> 32), (ULONG)sector));
    1.21 +    //FUNCTION_MSG("sector_number = %d (high) %d (low)\n", (ULONG)(sector >> 32), (ULONG)sector);
    1.22      break;
    1.23    default:
    1.24      sector = 0;
    1.25 @@ -182,8 +181,11 @@ XenVbd_HandleEvent(PXENVBD_DEVICE_DATA x
    1.26    blkif_shadow_t *shadow;
    1.27    srb_list_entry_t *srb_entry;
    1.28  
    1.29 -  //if (dump_mode)
    1.30 -  //FUNCTION_ENTER();
    1.31 +  if (xvdd->device_state != DEVICE_STATE_ACTIVE && xvdd->device_state != DEVICE_STATE_DISCONNECTING) {
    1.32 +    /* if we aren't active (eg just restored from hibernate) then we still want to process non-scsi srb's */
    1.33 +    XenVbd_ProcessSrbList(xvdd);
    1.34 +    return;
    1.35 +  }
    1.36  
    1.37    while (more_to_do) {
    1.38      rp = xvdd->ring.sring->rsp_prod;
    1.39 @@ -202,22 +204,22 @@ XenVbd_HandleEvent(PXENVBD_DEVICE_DATA x
    1.40          FUNCTION_MSG("discarding stale (non-dump-mode) shadow\n");
    1.41        } else {
    1.42          srb = shadow->srb;
    1.43 -        NT_ASSERT(srb);
    1.44 +        XN_ASSERT(srb);
    1.45          srb_entry = srb->SrbExtension;
    1.46 -        NT_ASSERT(srb_entry);
    1.47 +        XN_ASSERT(srb_entry);
    1.48          /* a few errors occur in dump mode because Xen refuses to allow us to map pages we are using for other stuff. Just ignore them */
    1.49          if (rep->status == BLKIF_RSP_OKAY || (dump_mode &&  dump_mode_errors++ < DUMP_MODE_ERROR_LIMIT)) {
    1.50            srb->SrbStatus = SRB_STATUS_SUCCESS;
    1.51          } else {
    1.52 -          KdPrint((__DRIVER_NAME "     Xen Operation returned error\n"));
    1.53 +          FUNCTION_MSG("Xen Operation returned error\n");
    1.54            if (decode_cdb_is_read(srb))
    1.55 -            KdPrint((__DRIVER_NAME "     Operation = Read\n"));
    1.56 +            FUNCTION_MSG("Operation = Read\n");
    1.57            else
    1.58 -            KdPrint((__DRIVER_NAME "     Operation = Write\n"));
    1.59 +            FUNCTION_MSG("Operation = Write\n");
    1.60            srb_entry->error = TRUE;
    1.61          }
    1.62          if (shadow->aligned_buffer_in_use) {
    1.63 -          NT_ASSERT(xvdd->aligned_buffer_in_use);
    1.64 +          XN_ASSERT(xvdd->aligned_buffer_in_use);
    1.65            xvdd->aligned_buffer_in_use = FALSE;
    1.66            if (srb->SrbStatus == SRB_STATUS_SUCCESS && decode_cdb_is_read(srb))
    1.67              memcpy((PUCHAR)shadow->system_address, xvdd->aligned_buffer, shadow->length);
    1.68 @@ -259,7 +261,7 @@ XenVbd_HandleEvent(PXENVBD_DEVICE_DATA x
    1.69      }
    1.70    }
    1.71  
    1.72 -  if (xvdd->device_state != DEVICE_STATE_ACTIVE && xvdd->device_state != DEVICE_STATE_INACTIVE && xvdd->shadow_free == SHADOW_ENTRIES) {
    1.73 +  if (xvdd->device_state == DEVICE_STATE_DISCONNECTING && xvdd->shadow_free == SHADOW_ENTRIES) {
    1.74      FUNCTION_MSG("ring now empty - completing disconnect\n");
    1.75      XenVbd_CompleteDisconnect(xvdd);
    1.76    }
    1.77 @@ -282,23 +284,25 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
    1.78    PVOID system_address;
    1.79  
    1.80    //if (dump_mode) FUNCTION_ENTER();
    1.81 -  //FUNCTION_MSG("Srb = %p\n", srb);
    1.82  
    1.83    //FUNCTION_MSG("aligned_buffer_in_use = %d\n", xvdd->aligned_buffer_in_use);
    1.84    //FUNCTION_MSG("shadow_free = %d\n", xvdd->shadow_free);
    1.85    
    1.86 -  NT_ASSERT(srb);
    1.87 +  XN_ASSERT(srb);
    1.88 +  
    1.89 +  if (xvdd->device_state != DEVICE_STATE_ACTIVE) {
    1.90 +    InsertHeadList(&xvdd->srb_list, (PLIST_ENTRY)srb->SrbExtension);
    1.91 +    return FALSE;
    1.92 +  }
    1.93  
    1.94    if (!dump_mode) {
    1.95      if (SxxxPortGetSystemAddress(xvdd, srb, &system_address) != STATUS_SUCCESS) {
    1.96        FUNCTION_MSG("Failed to map DataBuffer\n");
    1.97        InsertHeadList(&xvdd->srb_list, (PLIST_ENTRY)srb->SrbExtension);
    1.98 -      //if (dump_mode) FUNCTION_EXIT();
    1.99        return FALSE;
   1.100      }
   1.101      system_address = (PUCHAR)system_address + srb_entry->offset;
   1.102    } else {
   1.103 -    //FUNCTION_MSG("DataBuffer = %p\n", srb->DataBuffer);
   1.104      system_address = (PUCHAR)srb->DataBuffer + srb_entry->offset;
   1.105    }
   1.106    block_count = decode_cdb_length(srb);
   1.107 @@ -306,12 +310,12 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
   1.108    block_count *= xvdd->bytes_per_sector / 512;
   1.109    sector_number *= xvdd->bytes_per_sector / 512;
   1.110  
   1.111 -  NT_ASSERT(block_count * 512 == srb->DataTransferLength);
   1.112 +  XN_ASSERT(block_count * 512 == srb->DataTransferLength);
   1.113    
   1.114    sector_number += srb_entry->offset / 512;
   1.115    block_count -= srb_entry->offset / 512;
   1.116  
   1.117 -  NT_ASSERT(block_count > 0);
   1.118 +  XN_ASSERT(block_count > 0);
   1.119  
   1.120    /* look for pending writes that overlap this one */
   1.121    /* we get warnings from drbd if we don't */
   1.122 @@ -336,14 +340,13 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
   1.123        if (sector_number2 < sector_number && sector_number2 + block_count2 <= sector_number)
   1.124          continue;
   1.125  
   1.126 -      KdPrint((__DRIVER_NAME "     Concurrent outstanding write detected (%I64d, %d) (%I64d, %d)\n",
   1.127 -        sector_number, block_count, sector_number2, block_count2));
   1.128 +      FUNCTION_MSG("Concurrent outstanding write detected (%I64d, %d) (%I64d, %d)\n",
   1.129 +        sector_number, block_count, sector_number2, block_count2);
   1.130        break;
   1.131      }
   1.132      if (i != MAX_SHADOW_ENTRIES) {
   1.133        /* put the srb back at the start of the queue */
   1.134        InsertHeadList(&xvdd->srb_list, (PLIST_ENTRY)srb->SrbExtension);
   1.135 -      //if (dump_mode) FUNCTION_EXIT();
   1.136        return FALSE;
   1.137      }
   1.138    }
   1.139 @@ -355,8 +358,8 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
   1.140      //if (dump_mode) FUNCTION_EXIT();
   1.141      return FALSE;
   1.142    }
   1.143 -  NT_ASSERT(!shadow->aligned_buffer_in_use);
   1.144 -  NT_ASSERT(!shadow->srb);
   1.145 +  XN_ASSERT(!shadow->aligned_buffer_in_use);
   1.146 +  XN_ASSERT(!shadow->srb);
   1.147    shadow->req.sector_number = sector_number;
   1.148    shadow->req.handle = 0;
   1.149    shadow->req.operation = decode_cdb_is_read(srb)?BLKIF_OP_READ:BLKIF_OP_WRITE;
   1.150 @@ -380,7 +383,7 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
   1.151        shadow->aligned_buffer_in_use = FALSE;
   1.152      }
   1.153    } else {
   1.154 -    NT_ASSERT(!((ULONG_PTR)shadow->system_address & 511));
   1.155 +    XN_ASSERT(!((ULONG_PTR)shadow->system_address & 511));
   1.156      ptr = shadow->system_address;
   1.157      shadow->aligned_buffer_in_use = FALSE;
   1.158    }
   1.159 @@ -392,11 +395,10 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
   1.160      if (!dump_mode) {
   1.161        physical_address = MmGetPhysicalAddress(ptr);
   1.162      } else {
   1.163 -#if 0
   1.164 -      ULONG length;       
   1.165 -      physical_address = StorPortGetPhysicalAddress(xvdd, srb, ptr, &length);
   1.166 -#endif
   1.167 -      physical_address = MmGetPhysicalAddress(ptr);
   1.168 +      ULONG length;
   1.169 +      physical_address = SxxxPortGetPhysicalAddress(xvdd, srb, ptr, &length);
   1.170 +      //FUNCTION_MSG("physical_address = %08I64x\n", physical_address.QuadPart);
   1.171 +      
   1.172      }
   1.173      gref = XnGrantAccess(xvdd->handle,
   1.174             (ULONG)(physical_address.QuadPart >> PAGE_SHIFT), FALSE, INVALID_GRANT_REF, xvdd->grant_tag);
   1.175 @@ -413,15 +415,15 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
   1.176        /* put the srb back at the start of the queue */
   1.177        InsertHeadList(&xvdd->srb_list, (PLIST_ENTRY)srb_entry);
   1.178        put_shadow_on_freelist(xvdd, shadow);
   1.179 -      KdPrint((__DRIVER_NAME "     Out of gref's. Deferring\n"));
   1.180 +      FUNCTION_MSG("Out of gref's. Deferring\n");
   1.181        /* TODO: what if there are no requests currently in progress to kick the queue again?? timer? */
   1.182        return FALSE;
   1.183      }
   1.184      offset = physical_address.LowPart & (PAGE_SIZE - 1);
   1.185      length = min(PAGE_SIZE - offset, remaining);
   1.186 -    NT_ASSERT((offset & 511) == 0);
   1.187 -    NT_ASSERT((length & 511) == 0);
   1.188 -    NT_ASSERT(offset + length <= PAGE_SIZE);
   1.189 +    XN_ASSERT((offset & 511) == 0);
   1.190 +    XN_ASSERT((length & 511) == 0);
   1.191 +    XN_ASSERT(offset + length <= PAGE_SIZE);
   1.192      shadow->req.seg[shadow->req.nr_segments].gref = gref;
   1.193      shadow->req.seg[shadow->req.nr_segments].first_sect = (UCHAR)(offset / 512);
   1.194      shadow->req.seg[shadow->req.nr_segments].last_sect = (UCHAR)(((offset + length) / 512) - 1);
   1.195 @@ -462,8 +464,6 @@ XenVbd_FillModePage(PXENVBD_DEVICE_DATA 
   1.196    RtlZeroMemory(buffer, ARRAY_SIZE(buffer));
   1.197    offset = 0;
   1.198  
   1.199 -  //KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   1.200 -  
   1.201    switch (srb->Cdb[0]) {
   1.202    case SCSIOP_MODE_SENSE:
   1.203      cdb_llbaa = FALSE;
   1.204 @@ -474,7 +474,7 @@ XenVbd_FillModePage(PXENVBD_DEVICE_DATA 
   1.205      parameter_header->MediumType = 0;
   1.206      parameter_header->DeviceSpecificParameter = 0;
   1.207      if (xvdd->device_mode == XENVBD_DEVICEMODE_READ) {
   1.208 -      KdPrint((__DRIVER_NAME " Mode sense to a read only disk.\n"));
   1.209 +      FUNCTION_MSG(" Mode sense to a read only disk.\n");
   1.210        parameter_header->DeviceSpecificParameter |= MODE_DSP_WRITE_PROTECT; 
   1.211      }
   1.212      offset += sizeof(MODE_PARAMETER_HEADER);
   1.213 @@ -487,15 +487,14 @@ XenVbd_FillModePage(PXENVBD_DEVICE_DATA 
   1.214      parameter_header10 = (PMODE_PARAMETER_HEADER10)&buffer[offset];
   1.215      parameter_header10->MediumType = 0;
   1.216      parameter_header10->DeviceSpecificParameter = 0;
   1.217 -    if (xvdd->device_mode == XENVBD_DEVICEMODE_READ)
   1.218 -    {
   1.219 -      KdPrint((__DRIVER_NAME " Mode sense to a read only disk.\n"));
   1.220 +    if (xvdd->device_mode == XENVBD_DEVICEMODE_READ) {
   1.221 +      FUNCTION_MSG(" Mode sense to a read only disk.\n");
   1.222        parameter_header10->DeviceSpecificParameter |= MODE_DSP_WRITE_PROTECT; 
   1.223      }
   1.224      offset += sizeof(MODE_PARAMETER_HEADER10);
   1.225      break;
   1.226    default:
   1.227 -    KdPrint((__DRIVER_NAME "     SCSIOP_MODE_SENSE_WTF (%02x)\n", (ULONG)srb->Cdb[0]));
   1.228 +    FUNCTION_MSG("SCSIOP_MODE_SENSE_WTF (%02x)\n", (ULONG)srb->Cdb[0]);
   1.229      return FALSE;
   1.230    }  
   1.231    
   1.232 @@ -600,7 +599,6 @@ XenVbd_ResetBus(PXENVBD_DEVICE_DATA xvdd
   1.233    /* need to make sure that each SRB is only reset once */
   1.234    LIST_ENTRY srb_reset_list;
   1.235    PLIST_ENTRY list_entry;
   1.236 -  //STOR_LOCK_HANDLE lock_handle;
   1.237  
   1.238    UNREFERENCED_PARAMETER(PathId);
   1.239  
   1.240 @@ -676,18 +674,13 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.241    #endif
   1.242    PCDB cdb;
   1.243    ULONG data_transfer_length;
   1.244 -  UCHAR srb_status = SRB_STATUS_PENDING;
   1.245 +  UCHAR srb_status;
   1.246    ULONG notify = FALSE;
   1.247    PSCSI_REQUEST_BLOCK srb;
   1.248    srb_list_entry_t *srb_entry;
   1.249    PSRB_IO_CONTROL sic;
   1.250    ULONG prev_offset;
   1.251  
   1.252 -  if (xvdd->device_state != DEVICE_STATE_ACTIVE) {
   1.253 -    FUNCTION_MSG("Not yet active - state = %d\n", xvdd->device_state);
   1.254 -    return;
   1.255 -  }
   1.256 -
   1.257    while(!xvdd->aligned_buffer_in_use && xvdd->shadow_free && (srb_entry = (srb_list_entry_t *)RemoveHeadList(&xvdd->srb_list)) != (srb_list_entry_t *)&xvdd->srb_list) {
   1.258      srb = srb_entry->srb;
   1.259      prev_offset = srb_entry->offset;
   1.260 @@ -700,23 +693,28 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.261      }
   1.262  
   1.263      data_transfer_length = srb->DataTransferLength;
   1.264 +    srb_status = SRB_STATUS_PENDING;
   1.265      
   1.266      switch (srb->Function) {
   1.267      case SRB_FUNCTION_EXECUTE_SCSI:
   1.268 +      if (xvdd->device_state != DEVICE_STATE_ACTIVE) {
   1.269 +        FUNCTION_MSG("Not yet active - state = %d\n", xvdd->device_state);
   1.270 +        InsertHeadList(&xvdd->srb_list, (PLIST_ENTRY)srb->SrbExtension);
   1.271 +        break;
   1.272 +      }
   1.273        cdb = (PCDB)srb->Cdb;
   1.274 -
   1.275        switch(cdb->CDB6GENERIC.OperationCode) {
   1.276        case SCSIOP_TEST_UNIT_READY:
   1.277          if (dump_mode)
   1.278 -          KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   1.279 +          FUNCTION_MSG("Command = TEST_UNIT_READY\n");
   1.280          srb_status = SRB_STATUS_SUCCESS;
   1.281          srb->ScsiStatus = 0;
   1.282          break;
   1.283        case SCSIOP_INQUIRY:
   1.284 -        if (dump_mode)
   1.285 -          KdPrint((__DRIVER_NAME "     Command = INQUIRY\n"));
   1.286 -  //      KdPrint((__DRIVER_NAME "     (LUN = %d, EVPD = %d, Page Code = %02X)\n", srb->Cdb[1] >> 5, srb->Cdb[1] & 1, srb->Cdb[2]));
   1.287 -  //      KdPrint((__DRIVER_NAME "     (Length = %d)\n", srb->DataTransferLength));
   1.288 +//        if (dump_mode)
   1.289 +          FUNCTION_MSG("Command = INQUIRY\n");
   1.290 +  //      FUNCTION_MSG("(LUN = %d, EVPD = %d, Page Code = %02X)\n", srb->Cdb[1] >> 5, srb->Cdb[1] & 1, srb->Cdb[2]);
   1.291 +  //      FUNCTION_MSG("(Length = %d)\n", srb->DataTransferLength);
   1.292          
   1.293          data_buffer = srb->DataBuffer;
   1.294          RtlZeroMemory(data_buffer, srb->DataTransferLength);
   1.295 @@ -760,22 +758,31 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.296                data_buffer[0] = DIRECT_ACCESS_DEVICE;
   1.297                data_buffer[1] = VPD_SERIAL_NUMBER;
   1.298                data_buffer[2] = 0x00;
   1.299 -              data_buffer[3] = 8;
   1.300 -              memset(&data_buffer[4], ' ', 8);
   1.301 -              data_transfer_length = 12;
   1.302 +              data_buffer[3] = (UCHAR)strlen(xvdd->serial_number);
   1.303 +              if (data_transfer_length > 4) {
   1.304 +                memcpy(&data_buffer[4], xvdd->serial_number, min(data_transfer_length - 4, strlen(xvdd->serial_number)));
   1.305 +              }
   1.306 +              data_transfer_length = 4 + (UCHAR)strlen(xvdd->serial_number);
   1.307                break;
   1.308              case VPD_DEVICE_IDENTIFIERS: /* identification - we don't support any so just return zero */
   1.309                FUNCTION_MSG("VPD_DEVICE_IDENTIFIERS\n");
   1.310                data_buffer[0] = DIRECT_ACCESS_DEVICE;
   1.311                data_buffer[1] = VPD_DEVICE_IDENTIFIERS;
   1.312                data_buffer[2] = 0x00;
   1.313 -              //data_buffer[3] = 4 + (UCHAR)strlen(xvdd->vectors.path); /* length */
   1.314 -              data_buffer[4] = 2; /* ASCII */
   1.315 -              data_buffer[5] = 1; /* VendorId */
   1.316 -              data_buffer[6] = 0;
   1.317 -              //data_buffer[7] = (UCHAR)strlen(xvdd->vectors.path);
   1.318 -              //memcpy(&data_buffer[8], xvdd->vectors.path, strlen(xvdd->vectors.path));
   1.319 -              //data_transfer_length = (ULONG)(8 + strlen(xvdd->vectors.path));
   1.320 +              data_buffer[3] = 2 * (4 + (UCHAR)strlen(xvdd->serial_number));
   1.321 +              if (data_transfer_length >= 4 + 2 * (4 + (ULONG)strlen(xvdd->serial_number))) {
   1.322 +                data_buffer[4] = 2; /* ASCII */
   1.323 +                data_buffer[5] = 0; /* VendorId */
   1.324 +                data_buffer[6] = 0; /* reserved */
   1.325 +                data_buffer[7] = (UCHAR)strlen(xvdd->serial_number);
   1.326 +                memcpy(&data_buffer[8], xvdd->serial_number, (UCHAR)strlen(xvdd->serial_number));
   1.327 +                data_buffer[8 + (UCHAR)strlen(xvdd->serial_number) + 0] = 2; /* ASCII */
   1.328 +                data_buffer[8 + (UCHAR)strlen(xvdd->serial_number) + 1] = 1; /* T10 VendorId */
   1.329 +                data_buffer[8 + (UCHAR)strlen(xvdd->serial_number) + 2] = 0; /* Reserved */
   1.330 +                data_buffer[8 + (UCHAR)strlen(xvdd->serial_number) + 3] = (UCHAR)strlen(xvdd->serial_number);
   1.331 +                memcpy(&data_buffer[8 + (UCHAR)strlen(xvdd->serial_number) + 4], xvdd->serial_number, (UCHAR)strlen(xvdd->serial_number));
   1.332 +              }
   1.333 +              data_transfer_length = 4 + 2 * (4 + (ULONG)strlen(xvdd->serial_number));
   1.334                break;
   1.335              case VPD_BLOCK_LIMITS: /* to indicate support for UNMAP (TRIM/DISCARD) */
   1.336                FUNCTION_MSG("VPD_BLOCK_LIMITS\n");
   1.337 @@ -836,36 +843,33 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.338                data_transfer_length = 12;
   1.339                break;
   1.340              default:
   1.341 -              //KdPrint((__DRIVER_NAME "     Unknown Page %02x requested\n", srb->Cdb[2]));
   1.342 +              FUNCTION_MSG("Unknown Page %02x requested\n", srb->Cdb[2]);
   1.343                srb_status = SRB_STATUS_ERROR;
   1.344                break;
   1.345              }
   1.346            }
   1.347            break;
   1.348          default:
   1.349 -          //KdPrint((__DRIVER_NAME "     Unknown DeviceType %02x requested\n", xvdd->device_type));
   1.350 +          FUNCTION_MSG("Unknown DeviceType %02x requested\n", xvdd->device_type);
   1.351            srb_status = SRB_STATUS_ERROR;
   1.352            break;
   1.353          }
   1.354          break;
   1.355        case SCSIOP_READ_CAPACITY:
   1.356          //if (dump_mode)
   1.357 -        //  KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY\n"));
   1.358 -        //KdPrint((__DRIVER_NAME "       LUN = %d, RelAdr = %d\n", srb->Cdb[1] >> 4, srb->Cdb[1] & 1));
   1.359 -        //KdPrint((__DRIVER_NAME "       LBA = %02x%02x%02x%02x\n", srb->Cdb[2], srb->Cdb[3], srb->Cdb[4], srb->Cdb[5]));
   1.360 -        //KdPrint((__DRIVER_NAME "       PMI = %d\n", srb->Cdb[8] & 1));
   1.361 +          FUNCTION_MSG("Command = READ_CAPACITY\n");
   1.362 +        //FUNCTION_MSG("  LUN = %d, RelAdr = %d\n", srb->Cdb[1] >> 4, srb->Cdb[1] & 1);
   1.363 +        //FUNCTION_MSG("  LBA = %02x%02x%02x%02x\n", srb->Cdb[2], srb->Cdb[3], srb->Cdb[4], srb->Cdb[5]);
   1.364 +        //FUNCTION_MSG("  PMI = %d\n", srb->Cdb[8] & 1);
   1.365          //data_buffer = LongLongToPtr(ScsiPortGetPhysicalAddress(xvdd, srb, srb->DataBuffer, &data_buffer_length).QuadPart);
   1.366          data_buffer = srb->DataBuffer;
   1.367          RtlZeroMemory(data_buffer, srb->DataTransferLength);
   1.368 -        if ((xvdd->total_sectors - 1) >> 32)
   1.369 -        {
   1.370 +        if ((xvdd->total_sectors - 1) >> 32) {
   1.371            data_buffer[0] = 0xff;
   1.372            data_buffer[1] = 0xff;
   1.373            data_buffer[2] = 0xff;
   1.374            data_buffer[3] = 0xff;
   1.375 -        }
   1.376 -        else
   1.377 -        {
   1.378 +        } else {
   1.379            data_buffer[0] = (unsigned char)((xvdd->total_sectors - 1) >> 24) & 0xff;
   1.380            data_buffer[1] = (unsigned char)((xvdd->total_sectors - 1) >> 16) & 0xff;
   1.381            data_buffer[2] = (unsigned char)((xvdd->total_sectors - 1) >> 8) & 0xff;
   1.382 @@ -881,10 +885,10 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.383          break;
   1.384        case SCSIOP_READ_CAPACITY16:
   1.385          //if (dump_mode)
   1.386 -          KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY16\n"));
   1.387 -        //KdPrint((__DRIVER_NAME "       LUN = %d, RelAdr = %d\n", srb->Cdb[1] >> 4, srb->Cdb[1] & 1));
   1.388 -        //KdPrint((__DRIVER_NAME "       LBA = %02x%02x%02x%02x\n", srb->Cdb[2], srb->Cdb[3], srb->Cdb[4], srb->Cdb[5]));
   1.389 -        //KdPrint((__DRIVER_NAME "       PMI = %d\n", srb->Cdb[8] & 1));
   1.390 +          FUNCTION_MSG("Command = READ_CAPACITY16\n");
   1.391 +        //FUNCTION_MSG("  LUN = %d, RelAdr = %d\n", srb->Cdb[1] >> 4, srb->Cdb[1] & 1);
   1.392 +        //FUNCTION_MSG("  LBA = %02x%02x%02x%02x\n", srb->Cdb[2], srb->Cdb[3], srb->Cdb[4], srb->Cdb[5]);
   1.393 +        //FUNCTION_MSG("  PMI = %d\n", srb->Cdb[8] & 1);
   1.394          data_buffer = srb->DataBuffer;
   1.395          RtlZeroMemory(data_buffer, srb->DataTransferLength);
   1.396          data_buffer[0] = (unsigned char)((xvdd->total_sectors - 1) >> 56) & 0xff;
   1.397 @@ -915,7 +919,7 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.398            break;
   1.399          default:
   1.400            data_buffer[13] = 0; /* 512 byte hardware sectors */
   1.401 -          KdPrint((__DRIVER_NAME "     Unknown logical blocks per physical block %d (%d / %d)\n", xvdd->hw_bytes_per_sector / xvdd->bytes_per_sector, xvdd->hw_bytes_per_sector, xvdd->bytes_per_sector));
   1.402 +          FUNCTION_MSG("Unknown logical blocks per physical block %d (%d / %d)\n", xvdd->hw_bytes_per_sector / xvdd->bytes_per_sector, xvdd->hw_bytes_per_sector, xvdd->bytes_per_sector);
   1.403            break;
   1.404          }
   1.405          data_buffer[14] = 0xC0; //0;
   1.406 @@ -927,7 +931,7 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.407        case SCSIOP_MODE_SENSE:
   1.408        case SCSIOP_MODE_SENSE10:
   1.409          if (dump_mode)
   1.410 -          KdPrint((__DRIVER_NAME "     Command = MODE_SENSE (DBD = %d, PC = %d, Page Code = %02x)\n", srb->Cdb[1] & 0x08, srb->Cdb[2] & 0xC0, srb->Cdb[2] & 0x3F));
   1.411 +          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.412          data_transfer_length = XenVbd_FillModePage(xvdd, srb);
   1.413          srb_status = SRB_STATUS_SUCCESS;
   1.414          break;
   1.415 @@ -944,16 +948,18 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.416        case SCSIOP_WRITE_SAME16:
   1.417          /* not yet supported */
   1.418          FUNCTION_MSG("WRITE_SAME\n");
   1.419 -        break;
   1.420 +        srb_status = SRB_STATUS_ERROR;
   1.421 +       break;
   1.422        case SCSIOP_UNMAP:
   1.423          /* not yet supported */
   1.424          FUNCTION_MSG("UNMAP\n");
   1.425 +        srb_status = SRB_STATUS_ERROR;
   1.426          break;
   1.427        case SCSIOP_VERIFY:
   1.428        case SCSIOP_VERIFY16:
   1.429          // Should we do more here?
   1.430          if (dump_mode)
   1.431 -          KdPrint((__DRIVER_NAME "     Command = VERIFY\n"));
   1.432 +          FUNCTION_MSG("Command = VERIFY\n");
   1.433          srb_status = SRB_STATUS_SUCCESS;
   1.434          break;
   1.435        case SCSIOP_REPORT_LUNS:
   1.436 @@ -978,13 +984,13 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.437          break;
   1.438        case SCSIOP_REQUEST_SENSE:
   1.439          if (dump_mode)
   1.440 -          KdPrint((__DRIVER_NAME "     Command = REQUEST_SENSE\n"));
   1.441 +          FUNCTION_MSG("Command = REQUEST_SENSE\n");
   1.442          data_transfer_length = XenVbd_MakeSense(xvdd, srb, xvdd->last_sense_key, xvdd->last_additional_sense_code);
   1.443          srb_status = SRB_STATUS_SUCCESS;
   1.444          break;      
   1.445        case SCSIOP_READ_TOC:
   1.446 -        if (dump_mode)
   1.447 -          KdPrint((__DRIVER_NAME "     Command = READ_TOC\n"));
   1.448 +        //if (dump_mode)
   1.449 +          FUNCTION_MSG("Command = READ_TOC\n");
   1.450          data_buffer = srb->DataBuffer;
   1.451    /*
   1.452    #define READ_TOC_FORMAT_TOC         0x00
   1.453 @@ -993,15 +999,7 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.454    #define READ_TOC_FORMAT_PMA         0x03
   1.455    #define READ_TOC_FORMAT_ATIP        0x04
   1.456    */
   1.457 -  //      KdPrint((__DRIVER_NAME "     Msf = %d\n", cdb->READ_TOC.Msf));
   1.458 -  //      KdPrint((__DRIVER_NAME "     LogicalUnitNumber = %d\n", cdb->READ_TOC.LogicalUnitNumber));
   1.459 -  //      KdPrint((__DRIVER_NAME "     Format2 = %d\n", cdb->READ_TOC.Format2));
   1.460 -  //      KdPrint((__DRIVER_NAME "     StartingTrack = %d\n", cdb->READ_TOC.StartingTrack));
   1.461 -  //      KdPrint((__DRIVER_NAME "     AllocationLength = %d\n", (cdb->READ_TOC.AllocationLength[0] << 8) | cdb->READ_TOC.AllocationLength[1]));
   1.462 -  //      KdPrint((__DRIVER_NAME "     Control = %d\n", cdb->READ_TOC.Control));
   1.463 -  //      KdPrint((__DRIVER_NAME "     Format = %d\n", cdb->READ_TOC.Format));
   1.464 -        switch (cdb->READ_TOC.Format2)
   1.465 -        {
   1.466 +        switch (cdb->READ_TOC.Format2) {
   1.467          case READ_TOC_FORMAT_TOC:
   1.468            data_buffer[0] = 0; // length MSB
   1.469            data_buffer[1] = 10; // length LSB
   1.470 @@ -1030,25 +1028,29 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.471          }
   1.472          break;
   1.473        case SCSIOP_START_STOP_UNIT:
   1.474 -        KdPrint((__DRIVER_NAME "     Command = SCSIOP_START_STOP_UNIT\n"));
   1.475 +        FUNCTION_MSG("Command = SCSIOP_START_STOP_UNIT\n");
   1.476          srb_status = SRB_STATUS_SUCCESS;
   1.477          break;
   1.478        case SCSIOP_RESERVE_UNIT:
   1.479 -        KdPrint((__DRIVER_NAME "     Command = SCSIOP_RESERVE_UNIT\n"));
   1.480 +        FUNCTION_MSG("Command = SCSIOP_RESERVE_UNIT\n");
   1.481          srb_status = SRB_STATUS_SUCCESS;
   1.482          break;
   1.483        case SCSIOP_RELEASE_UNIT:
   1.484 -        KdPrint((__DRIVER_NAME "     Command = SCSIOP_RELEASE_UNIT\n"));
   1.485 +        FUNCTION_MSG("Command = SCSIOP_RELEASE_UNIT\n");
   1.486 +        srb_status = SRB_STATUS_SUCCESS;
   1.487 +        break;
   1.488 +      case SCSIOP_SYNCHRONIZE_CACHE:
   1.489 +        FUNCTION_MSG("Command = SCSIOP_SYNCHRONIZE_CACHE\n");
   1.490          srb_status = SRB_STATUS_SUCCESS;
   1.491          break;
   1.492        default:
   1.493 -        KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", srb->Cdb[0]));
   1.494 +        FUNCTION_MSG("Unhandled EXECUTE_SCSI Command = %02X\n", srb->Cdb[0]);
   1.495          xvdd->last_sense_key = SCSI_SENSE_ILLEGAL_REQUEST;
   1.496          srb_status = SRB_STATUS_ERROR;
   1.497          break;
   1.498        }
   1.499        if (srb_status == SRB_STATUS_ERROR) {
   1.500 -        KdPrint((__DRIVER_NAME "     EXECUTE_SCSI Command = %02X returned error %02x\n", srb->Cdb[0], xvdd->last_sense_key));
   1.501 +        FUNCTION_MSG("EXECUTE_SCSI Command = %02X returned error %02x\n", srb->Cdb[0], xvdd->last_sense_key);
   1.502          if (xvdd->last_sense_key == SCSI_SENSE_NO_SENSE) {
   1.503            xvdd->last_sense_key = SCSI_SENSE_ILLEGAL_REQUEST;
   1.504            xvdd->last_additional_sense_code = SCSI_ADSENSE_INVALID_CDB;
   1.505 @@ -1058,8 +1060,11 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.506          XenVbd_MakeAutoSense(xvdd, srb);
   1.507          SxxxPortNotification(RequestComplete, xvdd, srb);
   1.508        } else if (srb_status != SRB_STATUS_PENDING) {
   1.509 +        if (srb->ScsiStatus != 0) {
   1.510 +          FUNCTION_MSG("ScsiStatus = 0x%02x\n", srb->ScsiStatus);
   1.511 +        }
   1.512          if (data_transfer_length > srb->DataTransferLength)
   1.513 -          KdPrint((__DRIVER_NAME "     data_transfer_length too big - %d > %d\n", data_transfer_length, srb->DataTransferLength));
   1.514 +          FUNCTION_MSG("data_transfer_length too big - %d > %d\n", data_transfer_length, srb->DataTransferLength);
   1.515          
   1.516          if (srb_status == SRB_STATUS_SUCCESS && data_transfer_length < srb->DataTransferLength) {
   1.517            srb->SrbStatus = SRB_STATUS_DATA_OVERRUN;
   1.518 @@ -1073,97 +1078,104 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.519        }
   1.520        break;
   1.521      case SRB_FUNCTION_FLUSH:
   1.522 -      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH %p, xvdd->shadow_free = %d\n", srb, xvdd->shadow_free));
   1.523 +      FUNCTION_MSG("SRB_FUNCTION_FLUSH %p, xvdd->shadow_free = %d\n", srb, xvdd->shadow_free);
   1.524        srb->SrbStatus = SRB_STATUS_SUCCESS;
   1.525        SxxxPortNotification(RequestComplete, xvdd, srb);
   1.526        break;
   1.527      #ifdef _NTSTORPORT_      
   1.528      case SRB_FUNCTION_PNP:
   1.529 -      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_PNP\n"));
   1.530 +      FUNCTION_MSG("SRB_FUNCTION_PNP\n");
   1.531        sprb = (PSCSI_PNP_REQUEST_BLOCK)srb;
   1.532        switch (sprb->PnPAction)
   1.533        {
   1.534        case StorStartDevice:
   1.535 -        KdPrint((__DRIVER_NAME "      StorStartDevice\n"));
   1.536 +        FUNCTION_MSG(" StorStartDevice\n");
   1.537          break;
   1.538        case StorRemoveDevice:
   1.539 -        KdPrint((__DRIVER_NAME "      StorRemoveDevice\n"));
   1.540 +        FUNCTION_MSG(" StorRemoveDevice\n");
   1.541          break;
   1.542        case StorStopDevice:
   1.543 -        KdPrint((__DRIVER_NAME "      StorStopDevice\n"));
   1.544 +        FUNCTION_MSG(" StorStopDevice\n");
   1.545          break;
   1.546        case StorQueryCapabilities:
   1.547 -        KdPrint((__DRIVER_NAME "      StorQueryCapabilities\n"));
   1.548 +        FUNCTION_MSG(" StorQueryCapabilities\n");
   1.549          break;
   1.550        case StorFilterResourceRequirements:
   1.551 -        KdPrint((__DRIVER_NAME "      StorFilterResourceRequirements\n"));
   1.552 +        FUNCTION_MSG(" StorFilterResourceRequirements\n");
   1.553          break;
   1.554        default:
   1.555 -        KdPrint((__DRIVER_NAME "      Stor%d\n", sprb->PnPAction));
   1.556 +        FUNCTION_MSG(" Stor%d\n", sprb->PnPAction);
   1.557          break;
   1.558        }
   1.559 -      KdPrint((__DRIVER_NAME "      SrbPnPFlags = %08x\n", sprb->SrbPnPFlags));
   1.560 +      FUNCTION_MSG(" SrbPnPFlags = %08x\n", sprb->SrbPnPFlags);
   1.561        srb->SrbStatus = SRB_STATUS_SUCCESS;
   1.562        SxxxPortNotification(RequestComplete, xvdd, srb);
   1.563        break;
   1.564        
   1.565      case SRB_FUNCTION_POWER:
   1.566 -      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_POWER\n"));
   1.567 +      FUNCTION_MSG("SRB_FUNCTION_POWER\n");   
   1.568 +      FUNCTION_MSG("IRQL = %d\n", KeGetCurrentIrql());
   1.569        spwrb = (PSCSI_POWER_REQUEST_BLOCK)srb;
   1.570 -      switch (spwrb->PowerAction)
   1.571 -      {
   1.572 -      case StorPowerActionNone:
   1.573 -        KdPrint((__DRIVER_NAME "      StorPowerActionNone\n"));
   1.574 -        break;
   1.575 -      case StorPowerActionReserved:
   1.576 -        KdPrint((__DRIVER_NAME "      StorPowerActionReserved\n"));
   1.577 -        break;
   1.578 -      case StorPowerActionSleep:
   1.579 -        KdPrint((__DRIVER_NAME "      StorPowerActionSleep\n"));
   1.580 -        break;
   1.581 -      case StorPowerActionHibernate:
   1.582 -        KdPrint((__DRIVER_NAME "      StorPowerActionHibernate\n"));
   1.583 -        break;
   1.584 -      case StorPowerActionShutdown:
   1.585 -        KdPrint((__DRIVER_NAME "      StorPowerActionShutdown\n"));
   1.586 -        break;
   1.587 -      case StorPowerActionShutdownReset:
   1.588 -        KdPrint((__DRIVER_NAME "      StorPowerActionShutdownReset\n"));
   1.589 -        break;
   1.590 -      case StorPowerActionShutdownOff:
   1.591 -        KdPrint((__DRIVER_NAME "      StorPowerActionShutdownOff\n"));
   1.592 -        break;
   1.593 -      case StorPowerActionWarmEject:
   1.594 -        KdPrint((__DRIVER_NAME "      StorPowerActionWarmEject\n"));
   1.595 -        break;
   1.596 -      default:
   1.597 -        KdPrint((__DRIVER_NAME "      Stor%d\n", spwrb->PowerAction));
   1.598 -        break;
   1.599 +      if (spwrb->DevicePowerState == StorPowerDeviceD0) {
   1.600 +        FUNCTION_MSG("Entering D0\n");
   1.601 +      } else {
   1.602 +        FUNCTION_MSG("Entering D%d (%d)\n", spwrb->DevicePowerState - StorPowerDeviceD0, spwrb->DevicePowerState);
   1.603 +        switch (spwrb->PowerAction) {
   1.604 +        case StorPowerActionNone:
   1.605 +          FUNCTION_MSG(" StorPowerActionNone\n");
   1.606 +          break;
   1.607 +        case StorPowerActionReserved:
   1.608 +          FUNCTION_MSG(" StorPowerActionReserved\n");
   1.609 +          break;
   1.610 +        case StorPowerActionSleep:
   1.611 +          FUNCTION_MSG(" StorPowerActionSleep\n");
   1.612 +          break;
   1.613 +        case StorPowerActionHibernate:
   1.614 +          FUNCTION_MSG(" StorPowerActionHibernate\n");
   1.615 +          break;
   1.616 +        case StorPowerActionShutdown:
   1.617 +          FUNCTION_MSG(" StorPowerActionShutdown\n");
   1.618 +          break;
   1.619 +        case StorPowerActionShutdownReset:
   1.620 +          FUNCTION_MSG(" StorPowerActionShutdownReset\n");
   1.621 +          break;
   1.622 +        case StorPowerActionShutdownOff:
   1.623 +          FUNCTION_MSG(" StorPowerActionShutdownOff\n");
   1.624 +          break;
   1.625 +        case StorPowerActionWarmEject:
   1.626 +          FUNCTION_MSG(" StorPowerActionWarmEject\n");
   1.627 +          break;
   1.628 +        default:
   1.629 +          FUNCTION_MSG(" Stor%d\n", spwrb->PowerAction);
   1.630 +          break;
   1.631 +        }
   1.632        }
   1.633 +      xvdd->power_state = spwrb->DevicePowerState;
   1.634 +      xvdd->power_action = spwrb->PowerAction;
   1.635        srb->SrbStatus = SRB_STATUS_SUCCESS;
   1.636        SxxxPortNotification(RequestComplete, xvdd, srb);
   1.637        break;
   1.638      case SRB_FUNCTION_DUMP_POINTERS:
   1.639 -      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_DUMP_POINTERS\n"));
   1.640 -      KdPrint((__DRIVER_NAME "     DataTransferLength = %d\n", srb->DataTransferLength));
   1.641 +      FUNCTION_MSG("SRB_FUNCTION_DUMP_POINTERS\n");
   1.642 +      FUNCTION_MSG("DataTransferLength = %d\n", srb->DataTransferLength);
   1.643        dump_pointers = srb->DataBuffer;
   1.644 -      KdPrint((__DRIVER_NAME "      Version = %d\n", dump_pointers->Version));
   1.645 -      KdPrint((__DRIVER_NAME "      Size = %d\n", dump_pointers->Size));
   1.646 -      KdPrint((__DRIVER_NAME "      DriverName = %S\n", dump_pointers->DriverName));
   1.647 -      KdPrint((__DRIVER_NAME "      AdapterObject = %p\n", dump_pointers->AdapterObject));
   1.648 -      KdPrint((__DRIVER_NAME "      MappedRegisterBase = %d\n", dump_pointers->MappedRegisterBase));
   1.649 -      KdPrint((__DRIVER_NAME "      CommonBufferSize = %d\n", dump_pointers->CommonBufferSize));
   1.650 -      KdPrint((__DRIVER_NAME "      MiniportPrivateDumpData = %p\n", dump_pointers->MiniportPrivateDumpData));
   1.651 -      KdPrint((__DRIVER_NAME "      SystemIoBusNumber = %d\n", dump_pointers->SystemIoBusNumber));
   1.652 -      KdPrint((__DRIVER_NAME "      AdapterInterfaceType = %d\n", dump_pointers->AdapterInterfaceType));
   1.653 -      KdPrint((__DRIVER_NAME "      MaximumTransferLength = %d\n", dump_pointers->MaximumTransferLength));
   1.654 -      KdPrint((__DRIVER_NAME "      NumberOfPhysicalBreaks = %d\n", dump_pointers->NumberOfPhysicalBreaks));
   1.655 -      KdPrint((__DRIVER_NAME "      AlignmentMask = %d\n", dump_pointers->AlignmentMask));
   1.656 -      KdPrint((__DRIVER_NAME "      NumberOfAccessRanges = %d\n", dump_pointers->NumberOfAccessRanges));
   1.657 -      KdPrint((__DRIVER_NAME "      NumberOfBuses = %d\n", dump_pointers->NumberOfBuses));
   1.658 -      KdPrint((__DRIVER_NAME "      Master = %d\n", dump_pointers->Master));
   1.659 -      KdPrint((__DRIVER_NAME "      MapBuffers = %d\n", dump_pointers->MapBuffers));
   1.660 -      KdPrint((__DRIVER_NAME "      MaximumNumberOfTargets = %d\n", dump_pointers->MaximumNumberOfTargets));
   1.661 +      FUNCTION_MSG(" Version = %d\n", dump_pointers->Version);
   1.662 +      FUNCTION_MSG(" Size = %d\n", dump_pointers->Size);
   1.663 +      FUNCTION_MSG(" DriverName = %S\n", dump_pointers->DriverName);
   1.664 +      FUNCTION_MSG(" AdapterObject = %p\n", dump_pointers->AdapterObject);
   1.665 +      FUNCTION_MSG(" MappedRegisterBase = %d\n", dump_pointers->MappedRegisterBase);
   1.666 +      FUNCTION_MSG(" CommonBufferSize = %d\n", dump_pointers->CommonBufferSize);
   1.667 +      FUNCTION_MSG(" MiniportPrivateDumpData = %p\n", dump_pointers->MiniportPrivateDumpData);
   1.668 +      FUNCTION_MSG(" SystemIoBusNumber = %d\n", dump_pointers->SystemIoBusNumber);
   1.669 +      FUNCTION_MSG(" AdapterInterfaceType = %d\n", dump_pointers->AdapterInterfaceType);
   1.670 +      FUNCTION_MSG(" MaximumTransferLength = %d\n", dump_pointers->MaximumTransferLength);
   1.671 +      FUNCTION_MSG(" NumberOfPhysicalBreaks = %d\n", dump_pointers->NumberOfPhysicalBreaks);
   1.672 +      FUNCTION_MSG(" AlignmentMask = %d\n", dump_pointers->AlignmentMask);
   1.673 +      FUNCTION_MSG(" NumberOfAccessRanges = %d\n", dump_pointers->NumberOfAccessRanges);
   1.674 +      FUNCTION_MSG(" NumberOfBuses = %d\n", dump_pointers->NumberOfBuses);
   1.675 +      FUNCTION_MSG(" Master = %d\n", dump_pointers->Master);
   1.676 +      FUNCTION_MSG(" MapBuffers = %d\n", dump_pointers->MapBuffers);
   1.677 +      FUNCTION_MSG(" MaximumNumberOfTargets = %d\n", dump_pointers->MaximumNumberOfTargets);
   1.678  
   1.679        dump_pointers->Version = DUMP_MINIPORT_VERSION_1;
   1.680        dump_pointers->Size = sizeof(MINIPORT_DUMP_POINTERS);
   1.681 @@ -1172,40 +1184,39 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.682        dump_pointers->MappedRegisterBase = 0;
   1.683        dump_pointers->CommonBufferSize = 0;
   1.684        dump_pointers->MiniportPrivateDumpData = xvdd;
   1.685 -      dump_pointers->AdapterInterfaceType = Internal;
   1.686 -      dump_pointers->MaximumTransferLength = 4 * 1024 * 1024; //BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE;;
   1.687 -      dump_pointers->NumberOfPhysicalBreaks = dump_pointers->MaximumTransferLength >> PAGE_SHIFT; //BLKIF_MAX_SEGMENTS_PER_REQUEST - 1;
   1.688 +      dump_pointers->MaximumTransferLength = 4 * 1024 * 1024;
   1.689 +      dump_pointers->NumberOfPhysicalBreaks = dump_pointers->MaximumTransferLength >> PAGE_SHIFT;
   1.690        dump_pointers->AlignmentMask = 0;
   1.691 -      dump_pointers->NumberOfAccessRanges = 1;
   1.692 +      dump_pointers->NumberOfAccessRanges = 0;
   1.693        dump_pointers->NumberOfBuses = 1;
   1.694        dump_pointers->Master = TRUE;
   1.695        dump_pointers->MapBuffers = STOR_MAP_NON_READ_WRITE_BUFFERS;
   1.696        dump_pointers->MaximumNumberOfTargets = 2;
   1.697  
   1.698 -      KdPrint((__DRIVER_NAME "      Version = %d\n", dump_pointers->Version));
   1.699 -      KdPrint((__DRIVER_NAME "      Size = %d\n", dump_pointers->Size));
   1.700 -      //KdPrint((__DRIVER_NAME "      DriverName = %S\n", dump_pointers->DriverName));
   1.701 -      KdPrint((__DRIVER_NAME "      AdapterObject = %p\n", dump_pointers->AdapterObject));
   1.702 -      KdPrint((__DRIVER_NAME "      MappedRegisterBase = %d\n", dump_pointers->MappedRegisterBase));
   1.703 -      KdPrint((__DRIVER_NAME "      CommonBufferSize = %d\n", dump_pointers->CommonBufferSize));
   1.704 -      KdPrint((__DRIVER_NAME "      MiniportPrivateDumpData = %p\n", dump_pointers->MiniportPrivateDumpData));
   1.705 -      KdPrint((__DRIVER_NAME "      SystemIoBusNumber = %d\n", dump_pointers->SystemIoBusNumber));
   1.706 -      KdPrint((__DRIVER_NAME "      AdapterInterfaceType = %d\n", dump_pointers->AdapterInterfaceType));
   1.707 -      KdPrint((__DRIVER_NAME "      MaximumTransferLength = %d\n", dump_pointers->MaximumTransferLength));
   1.708 -      KdPrint((__DRIVER_NAME "      NumberOfPhysicalBreaks = %d\n", dump_pointers->NumberOfPhysicalBreaks));
   1.709 -      KdPrint((__DRIVER_NAME "      AlignmentMask = %d\n", dump_pointers->AlignmentMask));
   1.710 -      KdPrint((__DRIVER_NAME "      NumberOfAccessRanges = %d\n", dump_pointers->NumberOfAccessRanges));
   1.711 -      KdPrint((__DRIVER_NAME "      NumberOfBuses = %d\n", dump_pointers->NumberOfBuses));
   1.712 -      KdPrint((__DRIVER_NAME "      Master = %d\n", dump_pointers->Master));
   1.713 -      KdPrint((__DRIVER_NAME "      MapBuffers = %d\n", dump_pointers->MapBuffers));
   1.714 -      KdPrint((__DRIVER_NAME "      MaximumNumberOfTargets = %d\n", dump_pointers->MaximumNumberOfTargets));
   1.715 +      FUNCTION_MSG(" Version = %d\n", dump_pointers->Version);
   1.716 +      FUNCTION_MSG(" Size = %d\n", dump_pointers->Size);
   1.717 +      //FUNCTION_MSG(" DriverName = %S\n", dump_pointers->DriverName);
   1.718 +      FUNCTION_MSG(" AdapterObject = %p\n", dump_pointers->AdapterObject);
   1.719 +      FUNCTION_MSG(" MappedRegisterBase = %d\n", dump_pointers->MappedRegisterBase);
   1.720 +      FUNCTION_MSG(" CommonBufferSize = %d\n", dump_pointers->CommonBufferSize);
   1.721 +      FUNCTION_MSG(" MiniportPrivateDumpData = %p\n", dump_pointers->MiniportPrivateDumpData);
   1.722 +      FUNCTION_MSG(" SystemIoBusNumber = %d\n", dump_pointers->SystemIoBusNumber);
   1.723 +      FUNCTION_MSG(" AdapterInterfaceType = %d\n", dump_pointers->AdapterInterfaceType);
   1.724 +      FUNCTION_MSG(" MaximumTransferLength = %d\n", dump_pointers->MaximumTransferLength);
   1.725 +      FUNCTION_MSG(" NumberOfPhysicalBreaks = %d\n", dump_pointers->NumberOfPhysicalBreaks);
   1.726 +      FUNCTION_MSG(" AlignmentMask = %d\n", dump_pointers->AlignmentMask);
   1.727 +      FUNCTION_MSG(" NumberOfAccessRanges = %d\n", dump_pointers->NumberOfAccessRanges);
   1.728 +      FUNCTION_MSG(" NumberOfBuses = %d\n", dump_pointers->NumberOfBuses);
   1.729 +      FUNCTION_MSG(" Master = %d\n", dump_pointers->Master);
   1.730 +      FUNCTION_MSG(" MapBuffers = %d\n", dump_pointers->MapBuffers);
   1.731 +      FUNCTION_MSG(" MaximumNumberOfTargets = %d\n", dump_pointers->MaximumNumberOfTargets);
   1.732  
   1.733        srb->SrbStatus = SRB_STATUS_SUCCESS;
   1.734        SxxxPortNotification(RequestComplete, xvdd, srb);
   1.735        break;
   1.736      #endif
   1.737      case SRB_FUNCTION_SHUTDOWN:
   1.738 -      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_SHUTDOWN %p, xvdd->shadow_free = %d\n", srb, xvdd->shadow_free));
   1.739 +      FUNCTION_MSG("SRB_FUNCTION_SHUTDOWN %p, xvdd->shadow_free = %d\n", srb, xvdd->shadow_free);
   1.740        srb->SrbStatus = SRB_STATUS_SUCCESS;
   1.741        SxxxPortNotification(RequestComplete, xvdd, srb);
   1.742        break;
   1.743 @@ -1229,15 +1240,20 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
   1.744        srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   1.745        SxxxPortNotification(RequestComplete, xvdd, srb);
   1.746        break;
   1.747 +    case 0x27:
   1.748 +      FUNCTION_MSG("SRB_FUNCTION_FREE_DUMP_POINTERS\n");
   1.749 +      srb->SrbStatus = SRB_STATUS_SUCCESS;
   1.750 +      SxxxPortNotification(RequestComplete, xvdd, srb);
   1.751 +      break;
   1.752      default:
   1.753 -      KdPrint((__DRIVER_NAME "     Unhandled srb->Function = %08X\n", srb->Function));
   1.754 +      FUNCTION_MSG("Unhandled srb->Function = %08X\n", srb->Function);
   1.755        srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   1.756        SxxxPortNotification(RequestComplete, xvdd, srb);
   1.757        break;
   1.758      }
   1.759      if ((PLIST_ENTRY)srb_entry == xvdd->srb_list.Flink && srb_entry->offset == prev_offset) {
   1.760        FUNCTION_MSG("Same entry\n");
   1.761 -      /* same entry was put back onto the head of the list unchanged so we can't progress */
   1.762 +      /* same entry was put back onto the head of the list unchanged, so we can't progress */
   1.763        break;
   1.764      }
   1.765    }