win-pvdrivers

changeset 5:2b0f6930eeeb

Trying to get Windows to allow a page file to exist on the PV disk
author James Harper <james.harper@bendigoit.com.au>
date Sun Nov 11 22:50:42 2007 +1100 (2007-11-11)
parents 3bf1f48005d8
children 8f643f8e229b
files xenvbd/target/xenvbd.inf xenvbd/xenvbd.c
line diff
     1.1 --- a/xenvbd/target/xenvbd.inf	Sun Nov 11 20:51:10 2007 +1100
     1.2 +++ b/xenvbd/target/xenvbd.inf	Sun Nov 11 22:50:42 2007 +1100
     1.3 @@ -3,7 +3,7 @@ Signature="$WINDOWS NT$"
     1.4  Class=SCSIAdapter
     1.5  ClassGuid={B968331F-9539-47d0-855E-66CB6AA613E2}
     1.6  Provider=%JAMESHARPER%
     1.7 -DriverVer=11/09/2007,1.0.1.286
     1.8 +DriverVer=11/11/2007,1.0.1.290
     1.9  
    1.10  [DestinationDirs]
    1.11  DefaultDestDir = 12
     2.1 --- a/xenvbd/xenvbd.c	Sun Nov 11 20:51:10 2007 +1100
     2.2 +++ b/xenvbd/xenvbd.c	Sun Nov 11 22:50:42 2007 +1100
     2.3 @@ -8,6 +8,7 @@
     2.4  #include <xen_public.h>
     2.5  #include <gnttbl_public.h>
     2.6  #include <io/xenbus.h>
     2.7 +#include <ntddft.h>
     2.8  
     2.9  #define wmb() KeMemoryBarrier()
    2.10  #define mb() KeMemoryBarrier()
    2.11 @@ -581,6 +582,7 @@ XenVbd_DpcThreadProc(WDFDPC Dpc)
    2.12    }
    2.13  
    2.14    KeReleaseSpinLock(&ChildDeviceData->Lock, KIrql);
    2.15 +
    2.16    //KdPrint((__DRIVER_NAME " <-- XenVbd_DpcThreadProc\n"));
    2.17    //KdPrint((__DRIVER_NAME " <-- XenVbd_DpcThreadProc (AddedToList = %d, RemovedFromList = %d, AddedToRing = %d, AddedToRingAtLastNotify = %d, AddedToRingAtLastInterrupt = %d, AddedToRingAtLastDpc = %d, RemovedFromRing = %d, IrpCompleted = %d)\n", ChildDeviceData->IrpAddedToList, ChildDeviceData->IrpRemovedFromList, ChildDeviceData->IrpAddedToRing, ChildDeviceData->IrpAddedToRingAtLastNotify, ChildDeviceData->IrpAddedToRingAtLastInterrupt, ChildDeviceData->IrpAddedToRingAtLastDpc, ChildDeviceData->IrpRemovedFromRing, ChildDeviceData->IrpCompleted));
    2.18  }
    2.19 @@ -838,20 +840,24 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    2.20  
    2.21    WdfDeviceInitSetDeviceType(ChildInit, FILE_DEVICE_MASS_STORAGE);
    2.22  
    2.23 +  // Capabilities = CM_DEVCAP_UNIQUEID
    2.24 +  // Devnode Flages = DN_NEED_RESTART??? DN_DISABLEABLE???
    2.25 +
    2.26    status = RtlUnicodeStringPrintf(&buffer, L"XEN\\Disk&Ven_James&Prod_James&Rev_1.00\0");
    2.27    status = WdfPdoInitAssignDeviceID(ChildInit, &buffer);
    2.28  
    2.29    status = RtlUnicodeStringPrintf(&buffer, L"%02d", ChildDeviceData->DeviceIndex);
    2.30    status = WdfPdoInitAssignInstanceID(ChildInit, &buffer);
    2.31  
    2.32 -  status = RtlUnicodeStringPrintf(&buffer, L"XEN\\Disk\0");
    2.33 -  status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
    2.34 -  status = RtlUnicodeStringPrintf(&buffer, L"XEN\\RAW\0");
    2.35 -  status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
    2.36 +  //status = RtlUnicodeStringPrintf(&buffer, L"XEN\\Disk\0");
    2.37 +  //status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
    2.38 +  //status = RtlUnicodeStringPrintf(&buffer, L"XEN\\RAW\0");
    2.39 +  //status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
    2.40    status = RtlUnicodeStringPrintf(&buffer, L"GenDisk\0");
    2.41    status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
    2.42 +  status = WdfPdoInitAddHardwareID(ChildInit, &buffer);
    2.43  
    2.44 -  status = RtlUnicodeStringPrintf(&buffer, L"vbd_%d", ChildDeviceData->DeviceIndex);
    2.45 +  status = RtlUnicodeStringPrintf(&buffer, L"Xen PV Disk (%d)", ChildDeviceData->DeviceIndex);
    2.46    status = WdfPdoInitAddDeviceText(ChildInit, &buffer, &DeviceLocation, 0x409);
    2.47  
    2.48    WdfPdoInitSetDefaultLocale(ChildInit, 0x409);
    2.49 @@ -868,6 +874,10 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    2.50      KdPrint((__DRIVER_NAME "     WdfDeviceCreate status = %08X\n", status));
    2.51    }
    2.52  
    2.53 +  WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFilePaging, TRUE);
    2.54 +  WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFileHibernation, TRUE);
    2.55 +  WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFileDump, TRUE);
    2.56 +
    2.57    WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&IoQueueConfig, WdfIoQueueDispatchSequential);
    2.58    IoQueueConfig.EvtIoDefault = XenVbd_Child_IoDefault;
    2.59    IoQueueConfig.EvtIoDeviceControl = XenVbd_Child_IoDeviceControl;
    2.60 @@ -978,8 +988,6 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    2.61      }
    2.62    }
    2.63  
    2.64 -//  if (MmGetMdlByteOffset(Irp->MdlAddress) != 0)
    2.65 -//    KdPrint((__DRIVER_NAME "     ByteOffset == %08x - we can't cope with this yet!\n", MmGetMdlByteOffset(Irp->MdlAddress)));
    2.66    sect_offset = MmGetMdlByteOffset(ChildDeviceData->shadow[req->id].Mdl) >> 9;
    2.67    for (i = 0, req->nr_segments = 0; i < BlockCount; req->nr_segments++)
    2.68    {
    2.69 @@ -995,7 +1003,6 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    2.70      if (DataBuffer == NULL)
    2.71        KdPrint((__DRIVER_NAME "     MmGetSystemAddressForMdlSafe failed in PutIrpOnRing\n"));
    2.72      memcpy(ChildDeviceData->shadow[req->id].Buf, DataBuffer, BlockCount * ChildDeviceData->BytesPerSector);
    2.73 -    //MmUnmapLockedPages(DataBuffer, Irp->MdlAddress);
    2.74    }
    2.75    ChildDeviceData->shadow[req->id].req = *req;
    2.76  
    2.77 @@ -1181,11 +1188,11 @@ XenVbd_Child_IoDefault(WDFQUEUE  Queue, 
    2.78  {
    2.79    UNREFERENCED_PARAMETER(Queue);
    2.80  
    2.81 -  //KdPrint((__DRIVER_NAME " --> EvtDeviceIoDefault\n"));
    2.82 +  KdPrint((__DRIVER_NAME " --> EvtDeviceIoDefault\n"));
    2.83  
    2.84    WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
    2.85  
    2.86 -  //KdPrint((__DRIVER_NAME " <-- EvtDeviceIoDefault\n"));
    2.87 +  KdPrint((__DRIVER_NAME " <-- EvtDeviceIoDefault\n"));
    2.88  }
    2.89  
    2.90  static VOID 
    2.91 @@ -1197,6 +1204,8 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
    2.92    PSTORAGE_PROPERTY_QUERY Spq;
    2.93    PSTORAGE_ADAPTER_DESCRIPTOR Sad;
    2.94    PSTORAGE_DEVICE_DESCRIPTOR Sdd;
    2.95 +  PSTORAGE_DEVICE_ID_DESCRIPTOR Sdid;
    2.96 +  PSTORAGE_IDENTIFIER Si;
    2.97    PSCSI_ADDRESS Sa;
    2.98  
    2.99    UNREFERENCED_PARAMETER(Queue);
   2.100 @@ -1271,54 +1280,78 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   2.101        }
   2.102        WdfRequestComplete(Request, STATUS_SUCCESS);
   2.103      }
   2.104 +    else if (Spq->PropertyId == StorageDeviceIdProperty && Spq->QueryType == PropertyStandardQuery)
   2.105 +    {
   2.106 +      if (OutputBufferLength >= 8)
   2.107 +      {
   2.108 +        Sdid = (PSTORAGE_DEVICE_ID_DESCRIPTOR)Irp->AssociatedIrp.SystemBuffer;
   2.109 +        Sdid->Version = 1;
   2.110 +        Sdid->Size = sizeof(STORAGE_DEVICE_ID_DESCRIPTOR) - 1 + sizeof(STORAGE_IDENTIFIER) - 1 + 5;
   2.111 +        if (OutputBufferLength >= Sdid->Size)
   2.112 +        {
   2.113 +          Sdid->NumberOfIdentifiers = 1;
   2.114 +          Si = (PSTORAGE_IDENTIFIER)Sdid->Identifiers;
   2.115 +          Si->CodeSet = 0;
   2.116 +          Si->Type = StorageIdTypeScsiNameString;
   2.117 +          Si->IdentifierSize = 5;
   2.118 +          Si->NextOffset = 0;
   2.119 +          Si->Association = StorageIdAssocDevice;
   2.120 +          Si->Identifier[0] = 'J';
   2.121 +          Si->Identifier[0] = 'a';
   2.122 +          Si->Identifier[0] = 'm';
   2.123 +          Si->Identifier[0] = 'e';
   2.124 +          Si->Identifier[0] = 's';
   2.125 +        }
   2.126 +      }
   2.127 +      WdfRequestComplete(Request, STATUS_SUCCESS);
   2.128 +    }
   2.129      else
   2.130      {
   2.131        switch (Spq->PropertyId)
   2.132        {
   2.133        case StorageDeviceProperty:
   2.134 -        //KdPrint((__DRIVER_NAME "     StorageDeviceProperty\n"));
   2.135 +        KdPrint((__DRIVER_NAME "     StorageDeviceProperty\n"));
   2.136          break;        
   2.137        case StorageAccessAlignmentProperty:
   2.138 -        //KdPrint((__DRIVER_NAME "     StorageAccessAlignmentProperty\n"));
   2.139 +        KdPrint((__DRIVER_NAME "     StorageAccessAlignmentProperty\n"));
   2.140          break;
   2.141        case StorageAdapterProperty:
   2.142 -        //KdPrint((__DRIVER_NAME "     StorageAdapterProperty\n"));
   2.143 -         break;
   2.144 +        KdPrint((__DRIVER_NAME "     StorageAdapterProperty\n"));
   2.145 +        break;
   2.146        case StorageDeviceIdProperty:
   2.147 -        //KdPrint((__DRIVER_NAME "     StorageDeviceIdProperty\n"));
   2.148 -         break;
   2.149 +        KdPrint((__DRIVER_NAME "     StorageDeviceIdProperty\n"));
   2.150 +        break;
   2.151        case StorageDeviceUniqueIdProperty:
   2.152 -        //KdPrint((__DRIVER_NAME "     StorageDeviceUniqueIdProperty\n"));
   2.153 +        KdPrint((__DRIVER_NAME "     StorageDeviceUniqueIdProperty\n"));
   2.154          break;
   2.155        case StorageDeviceWriteCacheProperty:
   2.156 -        //KdPrint((__DRIVER_NAME "     StorageDeviceWriteCacheProperty\n"));
   2.157 +        KdPrint((__DRIVER_NAME "     StorageDeviceWriteCacheProperty\n"));
   2.158          break;
   2.159        default:
   2.160 -        //KdPrint((__DRIVER_NAME "     Unknown Property %08x\n", Spq->PropertyId));
   2.161 -         break;
   2.162 +        KdPrint((__DRIVER_NAME "     Unknown Property %08x\n", Spq->PropertyId));
   2.163 +        break;
   2.164        }
   2.165        switch (Spq->QueryType)
   2.166        {
   2.167        case PropertyStandardQuery:
   2.168 -        //KdPrint((__DRIVER_NAME "     PropertyStandardQuery\n"));
   2.169 +        KdPrint((__DRIVER_NAME "     PropertyStandardQuery\n"));
   2.170          break;        
   2.171 -       //case PropertyIncludeSwIds:
   2.172 -      //  //KdPrint((__DRIVER_NAME "     PropertyIncludeSwIds\n"));
   2.173 -      //  break;        
   2.174 +      /*
   2.175 +      case PropertyIncludeSwIds:
   2.176 +        KdPrint((__DRIVER_NAME "     PropertyIncludeSwIds\n"));
   2.177 +        break;        
   2.178 +      */
   2.179        case PropertyExistsQuery:
   2.180 -        //KdPrint((__DRIVER_NAME "     PropertyExistsQuery\n"));
   2.181 +        KdPrint((__DRIVER_NAME "     PropertyExistsQuery\n"));
   2.182          break;        
   2.183        default:
   2.184 -        //KdPrint((__DRIVER_NAME "     Unknown Query %08x\n", Spq->QueryType));
   2.185 +        KdPrint((__DRIVER_NAME "     Unknown Query %08x\n", Spq->QueryType));
   2.186          break;
   2.187        }
   2.188        WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
   2.189      }
   2.190      break;
   2.191    // http://www.osronline.com/article.cfm?article=229
   2.192 -  // 0x00070000 device = 0x70, Function = 0x000 = IOCTL_DISK_GET_DRIVE_GEOMETRY
   2.193 -  // 0x00041018 device = 0x04, function = 0x406 = IOCTL_SCSI_GET_ADDRESS 
   2.194 -  // 0x00049400 device = 0x04, function = 0x500 = ???IOCTL_STORAGE_QUERY_PROPERTY
   2.195    // 0x00560030 device = 0x56, Function = 0x00c = 
   2.196    case IOCTL_DISK_GET_DRIVE_GEOMETRY:
   2.197      KdPrint((__DRIVER_NAME "     IOCTL_DISK_GET_DRIVE_GEOMETRY\n"));
   2.198 @@ -1335,8 +1368,11 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   2.199      Sa->Lun = 0;
   2.200      WdfRequestComplete(Request, STATUS_SUCCESS);
   2.201      break;
   2.202 +  case FT_BALANCED_READ_MODE: // just pretend we know what this is...
   2.203 +    WdfRequestComplete(Request, STATUS_SUCCESS);
   2.204 +    break;
   2.205    default:
   2.206 -    //KdPrint((__DRIVER_NAME "     Not Implemented IoControlCode=%08X\n", IoControlCode));
   2.207 +    KdPrint((__DRIVER_NAME "     Not Implemented IoControlCode=%08X\n", IoControlCode));
   2.208      WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
   2.209      break;
   2.210    }