win-pvdrivers

changeset 290:a5d5a0376f96 wdm

Stopped xenbus from appending nulls to values. Fixed physical cdrom support (or anything else with bytes/sector != 512).
author James Harper <james.harper@bendigoit.com.au>
date Wed Jun 04 14:21:09 2008 +1000 (2008-06-04)
parents 691c6ebe92cf
children 873944504204
files xenpci/xenbus.c xenvbd/scsiport.c
line diff
     1.1 --- a/xenpci/xenbus.c	Tue Jun 03 22:39:32 2008 +1000
     1.2 +++ b/xenpci/xenbus.c	Wed Jun 04 14:21:09 2008 +1000
     1.3 @@ -273,7 +273,7 @@ XenBus_Write(
     1.4    PXENPCI_DEVICE_DATA xpdd = Context;
     1.5    struct write_req req[] = {
     1.6      {path, (ULONG)strlen(path) + 1},
     1.7 -    {value, (ULONG)strlen(value) + 1},
     1.8 +    {value, (ULONG)strlen(value)},
     1.9  //    {path, (ULONG)strlen(path)},
    1.10  //    {value, (ULONG)strlen(value)},
    1.11    };
     2.1 --- a/xenvbd/scsiport.c	Tue Jun 03 22:39:32 2008 +1000
     2.2 +++ b/xenvbd/scsiport.c	Wed Jun 04 14:21:09 2008 +1000
     2.3 @@ -368,15 +368,16 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
     2.4    ASSERT(!xvdd->pending_srb);
     2.5    
     2.6    block_count = (srb->Cdb[7] << 8) | srb->Cdb[8];
     2.7 +  block_count *= xvdd->bytes_per_sector / 512;
     2.8    if (PtrToUlong(srb->DataBuffer) & 511) /* use SrbExtension intead of DataBuffer if DataBuffer is not aligned to sector size */
     2.9    {
    2.10      ptr = GET_PAGE_ALIGNED(srb->SrbExtension);
    2.11 -    transfer_length = min(block_count * xvdd->bytes_per_sector - srb_offset, UNALIGNED_DOUBLE_BUFFER_SIZE);
    2.12 +    transfer_length = min(block_count * 512 - srb_offset, UNALIGNED_DOUBLE_BUFFER_SIZE);
    2.13    }
    2.14    else
    2.15    {
    2.16      ptr = srb->DataBuffer;
    2.17 -    transfer_length = block_count * xvdd->bytes_per_sector;
    2.18 +    transfer_length = block_count * 512;
    2.19    }
    2.20    if (xvdd->grant_free <= ADDRESS_AND_SIZE_TO_SPAN_PAGES(ptr, transfer_length))
    2.21    {
    2.22 @@ -387,6 +388,7 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
    2.23    shadow = get_shadow_from_freelist(xvdd);
    2.24    ASSERT(shadow);
    2.25    shadow->req.sector_number = (srb->Cdb[2] << 24) | (srb->Cdb[3] << 16) | (srb->Cdb[4] << 8) | srb->Cdb[5];
    2.26 +  shadow->req.sector_number *= xvdd->bytes_per_sector / 512;
    2.27    shadow->req.handle = 0;
    2.28    shadow->req.operation = (srb->Cdb[0] == SCSIOP_READ)?BLKIF_OP_READ:BLKIF_OP_WRITE;
    2.29    shadow->req.nr_segments = 0;
    2.30 @@ -400,8 +402,8 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
    2.31  
    2.32    if (PtrToUlong(srb->DataBuffer) & 511) /* use SrbExtension intead of DataBuffer if DataBuffer is not aligned to sector size */
    2.33    {
    2.34 -    shadow->req.sector_number += srb_offset / xvdd->bytes_per_sector;
    2.35 -    KdPrint((__DRIVER_NAME "     Using unaligned buffer - DataBuffer = %p, SrbExtension = %p, total length = %d, offset = %d, length = %d, sector = %d\n", srb->DataBuffer, srb->SrbExtension, block_count * xvdd->bytes_per_sector, shadow->offset, shadow->length, shadow->req.sector_number));
    2.36 +    shadow->req.sector_number += srb_offset / 512; //xvdd->bytes_per_sector;
    2.37 +    KdPrint((__DRIVER_NAME "     Using unaligned buffer - DataBuffer = %p, SrbExtension = %p, total length = %d, offset = %d, length = %d, sector = %d\n", srb->DataBuffer, srb->SrbExtension, block_count * 512, shadow->offset, shadow->length, shadow->req.sector_number));
    2.38      if (srb->Cdb[0] == SCSIOP_WRITE)
    2.39        memcpy(ptr, ((PUCHAR)srb->DataBuffer) + srb_offset, shadow->length);
    2.40    }
    2.41 @@ -435,7 +437,7 @@ XenVbd_PutSrbOnRing(PXENVBD_DEVICE_DATA 
    2.42      xvdd->vectors.EvtChn_Notify(xvdd->vectors.context, xvdd->event_channel);
    2.43  
    2.44    /* we don't want another srb if we had to double buffer this one, it will put things out of order */
    2.45 -  if (xvdd->shadow_free && srb_offset + shadow->length == block_count * xvdd->bytes_per_sector )
    2.46 +  if (xvdd->shadow_free && srb_offset + shadow->length == block_count * 512); // * xvdd->bytes_per_sector )
    2.47    {
    2.48      ScsiPortNotification(NextLuRequest, xvdd, 0, 0, 0);
    2.49    }
    2.50 @@ -565,7 +567,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    2.51          srb = shadow->srb;
    2.52          ASSERT(srb != NULL);
    2.53          block_count = (srb->Cdb[7] << 8) | srb->Cdb[8];
    2.54 -
    2.55 +        block_count *= xvdd->bytes_per_sector / 512;
    2.56          if (rep->status == BLKIF_RSP_OKAY)
    2.57            srb->SrbStatus = SRB_STATUS_SUCCESS;
    2.58          else