win-pvdrivers

changeset 159:6d13e6b110b7

Updates to better enforce xenhide being loaded before enumerating devices on boot in xenvbd
author James Harper <james.harper@bendigoit.com.au>
date Fri Feb 01 00:22:46 2008 +1100 (2008-02-01)
parents b822b4f07ed7
children 71d971853d57
files common/include/xen_public.h xenenum/sources xenenum/xenenum.c xenhide/sources xenhide/xenhide.c xenhide/xenhide.h xennet/sources xenpci/sources xenpci/xenpci.c xenvbd/sources xenvbd/xenvbd.c
line diff
     1.1 --- a/common/include/xen_public.h	Sat Jan 26 22:18:40 2008 +1100
     1.2 +++ b/common/include/xen_public.h	Fri Feb 01 00:22:46 2008 +1100
     1.3 @@ -20,8 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  #if !defined(_XEN_PUBLIC_H_)
     1.5  #define _XEN_PUBLIC_H_
     1.6  
     1.7 -DEFINE_GUID( GUID_XEN_IFACE, 0x5C568AC5, 0x9DDF, 0x4FA5, 0xA9, 0x4A, 0x39, 0xD6, 0x70, 0x77, 0x81, 0x9C);
     1.8  //{5C568AC5-9DDF-4FA5-A94A-39D67077819C}
     1.9 +DEFINE_GUID(GUID_XEN_IFACE, 0x5C568AC5, 0x9DDF, 0x4FA5, 0xA9, 0x4A, 0x39, 0xD6, 0x70, 0x77, 0x81, 0x9C);
    1.10 +
    1.11 +//{CD433FE7-954F-4D51-BE29-D8A38DFA1108}
    1.12 +DEFINE_GUID(GUID_XENHIDE_IFACE, 0xCD433FE7, 0x954F, 0x4D51, 0xBE, 0x29, 0xD8, 0xA3, 0x8D, 0xFA, 0x11, 0x08);
    1.13  
    1.14  typedef PHYSICAL_ADDRESS
    1.15  (*PXEN_ALLOCMMIO)(PVOID Context, ULONG Length);
     2.1 --- a/xenenum/sources	Sat Jan 26 22:18:40 2008 +1100
     2.2 +++ b/xenenum/sources	Fri Feb 01 00:22:46 2008 +1100
     2.3 @@ -1,7 +1,7 @@
     2.4  TARGETNAME=xenenum
     2.5  TARGETTYPE=DRIVER
     2.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     2.7 -VERSION=0.6.0.1
     2.8 +VERSION=0.6.1.1
     2.9  KMDF_VERSION=1
    2.10  MSC_WARNING_LEVEL=/W4
    2.11  INF_NAME=xenenum
     3.1 --- a/xenenum/xenenum.c	Sat Jan 26 22:18:40 2008 +1100
     3.2 +++ b/xenenum/xenenum.c	Fri Feb 01 00:22:46 2008 +1100
     3.3 @@ -41,10 +41,7 @@ XenEnum_WatchHandler(char *Path, PVOID D
     3.4  #endif
     3.5  
     3.6  LIST_ENTRY DeviceListHead;
     3.7 -//XEN_IFACE_EVTCHN EvtChnInterface;
     3.8 -//XEN_IFACE_XENBUS XenBusInterface;
     3.9  XEN_IFACE XenInterface;
    3.10 -//XEN_IFACE_GNTTBL GntTblInterface;
    3.11  
    3.12  static BOOLEAN AutoEnumerate;
    3.13  
    3.14 @@ -80,84 +77,6 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    3.15      KdPrint((__DRIVER_NAME " WdfDriverCreate failed with status 0x%08x\n", status));
    3.16    }
    3.17  
    3.18 -  RtlInitUnicodeString(&RegKeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
    3.19 -  InitializeObjectAttributes(&RegObjectAttributes, &RegKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL);
    3.20 -  status = ZwOpenKey(&RegHandle, KEY_READ, &RegObjectAttributes);
    3.21 -  if(!NT_SUCCESS(status))
    3.22 -  {
    3.23 -    KdPrint((__DRIVER_NAME "     ZwOpenKey returned %08x\n", status));
    3.24 -  }
    3.25 -
    3.26 -  RtlInitUnicodeString(&RegValueName, L"SystemStartOptions");
    3.27 -  status = ZwQueryValueKey(RegHandle, &RegValueName, KeyValuePartialInformation,
    3.28 -    Buf, ARRAY_SIZE(Buf), &BufLen);
    3.29 -  if(!NT_SUCCESS(status))
    3.30 -  {
    3.31 -    KdPrint((__DRIVER_NAME "     ZwQueryKeyValue returned %08x\n", status));
    3.32 -  }
    3.33 -  //KdPrint((__DRIVER_NAME "     BufLen = %d\n", BufLen));
    3.34 -  KeyPartialValue = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
    3.35 -  KdPrint((__DRIVER_NAME "     Buf = %ws\n", KeyPartialValue->Data));
    3.36 -  SystemStartOptions = (WCHAR *)KeyPartialValue->Data;
    3.37 -
    3.38 -  AutoEnumerate = FALSE;
    3.39 -
    3.40 -  RtlStringCbLengthW(SystemStartOptions, KeyPartialValue->DataLength, &SystemStartOptionsLen);
    3.41 -
    3.42 -  for (i = 0; i <= SystemStartOptionsLen/2; i++)
    3.43 -  {
    3.44 -    //KdPrint((__DRIVER_NAME "     pos = %d, state = %d, char = '%wc' (%d)\n", i, State, SystemStartOptions[i], SystemStartOptions[i]));
    3.45 -    
    3.46 -    switch (State)
    3.47 -    {
    3.48 -    case 0:
    3.49 -      if (SystemStartOptions[i] == L'G')
    3.50 -      {
    3.51 -        StartPos = i;
    3.52 -        State = 2;
    3.53 -      } else if (SystemStartOptions[i] != L' ')
    3.54 -      {
    3.55 -        State = 1;
    3.56 -      }
    3.57 -      break;
    3.58 -    case 1:
    3.59 -      if (SystemStartOptions[i] == L' ')
    3.60 -        State = 0;
    3.61 -      break;
    3.62 -    case 2:
    3.63 -      if (SystemStartOptions[i] == L'P')
    3.64 -        State = 3;
    3.65 -      else
    3.66 -        State = 0;
    3.67 -      break;
    3.68 -    case 3:
    3.69 -      if (SystemStartOptions[i] == L'L')
    3.70 -        State = 4;
    3.71 -      else
    3.72 -        State = 0;
    3.73 -      break;
    3.74 -    case 4:
    3.75 -      if (SystemStartOptions[i] == L'P')
    3.76 -        State = 5;
    3.77 -      else
    3.78 -        State = 0;
    3.79 -      break;
    3.80 -    case 5:
    3.81 -      if (SystemStartOptions[i] == L'V')
    3.82 -        State = 6;
    3.83 -      else
    3.84 -        State = 0;
    3.85 -      break;
    3.86 -    case 6:
    3.87 -      if (SystemStartOptions[i] == L' ' || SystemStartOptions[i] == 0)
    3.88 -        AutoEnumerate = TRUE;
    3.89 -      State = 0;
    3.90 -      break;
    3.91 -    }
    3.92 -  }
    3.93 -
    3.94 -  KdPrint((__DRIVER_NAME "     AutoEnumerate = %d\n", AutoEnumerate));
    3.95 -
    3.96    KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
    3.97  
    3.98    return status;
    3.99 @@ -294,12 +213,12 @@ XenEnum_D0EntryPostInterruptsEnabled(WDF
   3.100    //KdPrint((__DRIVER_NAME "     Path = %s\n", PdoDeviceData->Path));
   3.101    PdoDeviceData->WatchHandler = XenEnum_WatchHandler;
   3.102    PdoDeviceData->WatchContext = Device;
   3.103 +  AutoEnumerate = PdoDeviceData->AutoEnumerate;
   3.104  
   3.105    EnumeratedDevices = 0;
   3.106    KeInitializeEvent(&WaitDevicesEvent, SynchronizationEvent, FALSE);  
   3.107  
   3.108    // TODO: Should probably do this in an EvtChildListScanForChildren
   3.109 -  // TODO: Get the correct path from parent here...
   3.110    msg = XenInterface.XenBus_List(XenInterface.InterfaceHeader.Context, XBT_NIL, PdoDeviceData->Path, &Devices);
   3.111    if (!msg)
   3.112    {
     4.1 --- a/xenhide/sources	Sat Jan 26 22:18:40 2008 +1100
     4.2 +++ b/xenhide/sources	Fri Feb 01 00:22:46 2008 +1100
     4.3 @@ -1,7 +1,7 @@
     4.4  TARGETNAME=XENHIDE
     4.5  TARGETTYPE=DRIVER
     4.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     4.7 -VERSION=0.6.0.0
     4.8 +VERSION=0.6.1.15
     4.9  KMDF_VERSION=1
    4.10  MSC_WARNING_LEVEL=/W4
    4.11  INF_NAME=xenhide
     5.1 --- a/xenhide/xenhide.c	Sat Jan 26 22:18:40 2008 +1100
     5.2 +++ b/xenhide/xenhide.c	Fri Feb 01 00:22:46 2008 +1100
     5.3 @@ -135,7 +135,6 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     5.4  
     5.5    KdPrint((__DRIVER_NAME "     AutoEnumerate = %d\n", AutoEnumerate));
     5.6  
     5.7 -
     5.8    WDF_DRIVER_CONFIG_INIT(&config, XenHide_AddDevice);
     5.9    status = WdfDriverCreate(
    5.10                        DriverObject,
    5.11 @@ -156,6 +155,43 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    5.12  static NTSTATUS
    5.13  XenHide_PreprocessWdmIrpPNP(WDFDEVICE Device, PIRP Irp);
    5.14  
    5.15 +static VOID 
    5.16 +XenPCI_IoDefault(
    5.17 +    IN WDFQUEUE  Queue,
    5.18 +    IN WDFREQUEST  Request
    5.19 +    )
    5.20 +{
    5.21 +  UNREFERENCED_PARAMETER(Queue);
    5.22 +
    5.23 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.24 +
    5.25 +  WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
    5.26 +
    5.27 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.28 +}
    5.29 +
    5.30 +static VOID 
    5.31 +XenPCI_IoRead(WDFQUEUE Queue, WDFREQUEST Request, size_t Length)
    5.32 +{
    5.33 +  PCHAR Buffer;
    5.34 +  size_t BufLen;
    5.35 +
    5.36 +  UNREFERENCED_PARAMETER(Queue);
    5.37 +  UNREFERENCED_PARAMETER(Length);
    5.38 +
    5.39 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.40 +
    5.41 +  WdfRequestRetrieveOutputBuffer(Request, 1, &Buffer, &BufLen);
    5.42 +
    5.43 +  ASSERT(BufLen > 0);
    5.44 +
    5.45 +  Buffer[0] = 1;
    5.46 +
    5.47 +  WdfRequestCompleteWithInformation(Request, STATUS_SUCCESS, 1);
    5.48 +
    5.49 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.50 +}
    5.51 +
    5.52  static NTSTATUS
    5.53  XenHide_AddDevice(
    5.54      IN WDFDRIVER Driver,
    5.55 @@ -164,7 +200,7 @@ XenHide_AddDevice(
    5.56  {
    5.57    NTSTATUS status;
    5.58    WDF_OBJECT_ATTRIBUTES attributes;
    5.59 -  UCHAR MinorFunctions[1] = { IRP_MN_QUERY_DEVICE_RELATIONS };
    5.60 +  UCHAR MinorFunctions[3] = { IRP_MN_QUERY_DEVICE_RELATIONS };
    5.61  
    5.62    UNREFERENCED_PARAMETER(Driver);
    5.63  
    5.64 @@ -173,15 +209,15 @@ XenHide_AddDevice(
    5.65  
    5.66    WdfFdoInitSetFilter(DeviceInit);
    5.67  
    5.68 -  WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
    5.69 -
    5.70 -  status = WdfDeviceInitAssignWdmIrpPreprocessCallback(DeviceInit, XenHide_PreprocessWdmIrpPNP, IRP_MJ_PNP, MinorFunctions, 1);
    5.71 +  status = WdfDeviceInitAssignWdmIrpPreprocessCallback(DeviceInit, XenHide_PreprocessWdmIrpPNP, IRP_MJ_PNP, MinorFunctions, 3);
    5.72    if(!NT_SUCCESS(status))
    5.73    {
    5.74      KdPrint((__DRIVER_NAME "     WdfDeviceInitAssignWdmIrpPreprocessCallback failed with status 0x%08x\n", status));
    5.75      return status;
    5.76    }
    5.77  
    5.78 +  WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
    5.79 +
    5.80    status = WdfDeviceCreate(&DeviceInit, &attributes, &Device);  
    5.81    if(!NT_SUCCESS(status))
    5.82    {
    5.83 @@ -189,6 +225,16 @@ XenHide_AddDevice(
    5.84      return status;
    5.85    }
    5.86  
    5.87 +  if (AutoEnumerate)
    5.88 +  {
    5.89 +    status = WdfDeviceCreateDeviceInterface(Device, (LPGUID)&GUID_XENHIDE_IFACE, NULL);
    5.90 +    if (!NT_SUCCESS(status))
    5.91 +    {
    5.92 +      KdPrint((__DRIVER_NAME "     WdfDeviceCreateDeviceInterface failed 0x%08x\n", status));
    5.93 +      return status;
    5.94 +    }
    5.95 +  }
    5.96 +
    5.97    KdPrint((__DRIVER_NAME " <-- DeviceAdd\n"));
    5.98  
    5.99    return status;
   5.100 @@ -272,7 +318,7 @@ XenHide_PreprocessWdmIrpPNP(WDFDEVICE De
   5.101    NTSTATUS Status = STATUS_SUCCESS;
   5.102    PIO_STACK_LOCATION Stack;
   5.103  
   5.104 -  KdPrint((__DRIVER_NAME " --> WdmIrpPreprocessPNP\n"));
   5.105 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   5.106    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   5.107  
   5.108    Stack = IoGetCurrentIrpStackLocation(Irp);
   5.109 @@ -318,6 +364,27 @@ XenHide_PreprocessWdmIrpPNP(WDFDEVICE De
   5.110        break;  
   5.111      }
   5.112      break;
   5.113 +  case IRP_MN_QUERY_INTERFACE:
   5.114 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_INTERFACE\n"));
   5.115 +    if (memcmp(Stack->Parameters.QueryInterface.InterfaceType, &GUID_XENHIDE_IFACE, sizeof(GUID)) == 0)
   5.116 +    {
   5.117 +      KdPrint((__DRIVER_NAME "     Interface == GUID_XENHIDE_IFACE\n"));
   5.118 +    }
   5.119 +    IoSkipCurrentIrpStackLocation(Irp);
   5.120 +    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   5.121 +    break;
   5.122 +  case IRP_MN_QUERY_BUS_INFORMATION:
   5.123 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_BUS_INFORMATION\n"));
   5.124 +    IoSkipCurrentIrpStackLocation(Irp);
   5.125 +    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   5.126 +    break;
   5.127 +/*
   5.128 +  case IRP_MN_START_DEVICE:
   5.129 +    KdPrint((__DRIVER_NAME "     IRP_MN_START_DEVICE\n"));
   5.130 +    IoSkipCurrentIrpStackLocation(Irp);
   5.131 +    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   5.132 +    break;
   5.133 +*/
   5.134    default:
   5.135      IoSkipCurrentIrpStackLocation(Irp);
   5.136      Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   5.137 @@ -325,7 +392,7 @@ XenHide_PreprocessWdmIrpPNP(WDFDEVICE De
   5.138      break;
   5.139    }
   5.140  
   5.141 -  KdPrint((__DRIVER_NAME " <-- WdmIrpPreprocessPNP (returning with status %08x\n", Status));
   5.142 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   5.143  
   5.144    return Status;
   5.145  }
     6.1 --- a/xenhide/xenhide.h	Sat Jan 26 22:18:40 2008 +1100
     6.2 +++ b/xenhide/xenhide.h	Fri Feb 01 00:22:46 2008 +1100
     6.3 @@ -43,6 +43,8 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  #include <hvm/params.h>
     6.5  #include <hvm/hvm_op.h>
     6.6  
     6.7 +#include <xen_public.h>
     6.8 +
     6.9  //{C828ABE9-14CA-4445-BAA6-82C2376C6518}
    6.10  //DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
    6.11  
     7.1 --- a/xennet/sources	Sat Jan 26 22:18:40 2008 +1100
     7.2 +++ b/xennet/sources	Fri Feb 01 00:22:46 2008 +1100
     7.3 @@ -1,7 +1,7 @@
     7.4  TARGETNAME=XENNET
     7.5  TARGETTYPE=DRIVER
     7.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     7.7 -VERSION=0.6.0.0
     7.8 +VERSION=0.6.1.1
     7.9  KMDF_VERSION=1
    7.10  MSC_WARNING_LEVEL=/W4
    7.11  INF_NAME=xennet
     8.1 --- a/xenpci/sources	Sat Jan 26 22:18:40 2008 +1100
     8.2 +++ b/xenpci/sources	Fri Feb 01 00:22:46 2008 +1100
     8.3 @@ -1,7 +1,7 @@
     8.4  TARGETNAME=XENPCI
     8.5  TARGETTYPE=DRIVER
     8.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     8.7 -VERSION=0.6.0.26
     8.8 +VERSION=0.6.1.18
     8.9  KMDF_VERSION=1
    8.10  MSC_WARNING_LEVEL=/W4
    8.11  INF_NAME=xenpci
     9.1 --- a/xenpci/xenpci.c	Sat Jan 26 22:18:40 2008 +1100
     9.2 +++ b/xenpci/xenpci.c	Fri Feb 01 00:22:46 2008 +1100
     9.3 @@ -113,83 +113,6 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     9.4    InitializeListHead(&ShutdownMsgList);
     9.5    KeInitializeSpinLock(&ShutdownMsgLock);
     9.6  
     9.7 -  RtlInitUnicodeString(&RegKeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
     9.8 -  InitializeObjectAttributes(&RegObjectAttributes, &RegKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL);
     9.9 -  status = ZwOpenKey(&RegHandle, KEY_READ, &RegObjectAttributes);
    9.10 -  if(!NT_SUCCESS(status))
    9.11 -  {
    9.12 -    KdPrint((__DRIVER_NAME "     ZwOpenKey returned %08x\n", status));
    9.13 -  }
    9.14 -
    9.15 -  RtlInitUnicodeString(&RegValueName, L"SystemStartOptions");
    9.16 -  status = ZwQueryValueKey(RegHandle, &RegValueName, KeyValuePartialInformation, Buf, BufLen, &BufLen);
    9.17 -  if(!NT_SUCCESS(status))
    9.18 -  {
    9.19 -    KdPrint((__DRIVER_NAME "     ZwQueryKeyValue returned %08x\n", status));
    9.20 -  }
    9.21 -  //KdPrint((__DRIVER_NAME "     BufLen = %d\n", BufLen));
    9.22 -  KeyPartialValue = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
    9.23 -  KdPrint((__DRIVER_NAME "     Buf = %ws\n", KeyPartialValue->Data));
    9.24 -  SystemStartOptions = (WCHAR *)KeyPartialValue->Data;
    9.25 -
    9.26 -  AutoEnumerate = FALSE;
    9.27 -
    9.28 -  RtlStringCbLengthW(SystemStartOptions, KeyPartialValue->DataLength, &SystemStartOptionsLen);
    9.29 -
    9.30 -  for (i = 0; i <= SystemStartOptionsLen/2; i++)
    9.31 -  {
    9.32 -    //KdPrint((__DRIVER_NAME "     pos = %d, state = %d, char = '%wc' (%d)\n", i, State, SystemStartOptions[i], SystemStartOptions[i]));
    9.33 -    
    9.34 -    switch (State)
    9.35 -    {
    9.36 -    case 0:
    9.37 -      if (SystemStartOptions[i] == L'G')
    9.38 -      {
    9.39 -        StartPos = (int)i;
    9.40 -        State = 2;
    9.41 -      } else if (SystemStartOptions[i] != L' ')
    9.42 -      {
    9.43 -        State = 1;
    9.44 -      }
    9.45 -      break;
    9.46 -    case 1:
    9.47 -      if (SystemStartOptions[i] == L' ')
    9.48 -        State = 0;
    9.49 -      break;
    9.50 -    case 2:
    9.51 -      if (SystemStartOptions[i] == L'P')
    9.52 -        State = 3;
    9.53 -      else
    9.54 -        State = 0;
    9.55 -      break;
    9.56 -    case 3:
    9.57 -      if (SystemStartOptions[i] == L'L')
    9.58 -        State = 4;
    9.59 -      else
    9.60 -        State = 0;
    9.61 -      break;
    9.62 -    case 4:
    9.63 -      if (SystemStartOptions[i] == L'P')
    9.64 -        State = 5;
    9.65 -      else
    9.66 -        State = 0;
    9.67 -      break;
    9.68 -    case 5:
    9.69 -      if (SystemStartOptions[i] == L'V')
    9.70 -        State = 6;
    9.71 -      else
    9.72 -        State = 0;
    9.73 -      break;
    9.74 -    case 6:
    9.75 -      if (SystemStartOptions[i] == L' ' || SystemStartOptions[i] == 0)
    9.76 -        AutoEnumerate = TRUE;
    9.77 -      State = 0;
    9.78 -      break;
    9.79 -    }
    9.80 -  }
    9.81 -
    9.82 -  KdPrint((__DRIVER_NAME "     AutoEnumerate = %d\n", AutoEnumerate));
    9.83 -
    9.84    WDF_DRIVER_CONFIG_INIT(&config, XenPCI_AddDevice);
    9.85    status = WdfDriverCreate(
    9.86                        DriverObject,
    9.87 @@ -342,6 +265,7 @@ XenPCI_AddDevice(
    9.88    DECLARE_CONST_UNICODE_STRING(SymbolicName, L"\\DosDevices\\XenShutdown");
    9.89    WDFDEVICE Device;
    9.90    PXENPCI_DEVICE_DATA xpdd;
    9.91 +  PWSTR InterfaceList;
    9.92  
    9.93    UNREFERENCED_PARAMETER(Driver);
    9.94  
    9.95 @@ -388,10 +312,16 @@ XenPCI_AddDevice(
    9.96    WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFileHibernation, TRUE);
    9.97    WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFileDump, TRUE);
    9.98  
    9.99 -  Status = WdfFdoQueryForInterface(Device, &GUID_BUS_INTERFACE_STANDARD, (PINTERFACE) &BusInterface, sizeof(BUS_INTERFACE_STANDARD), 1, NULL);
   9.100 -  if(!NT_SUCCESS(Status))
   9.101 +  Status = IoGetDeviceInterfaces(&GUID_XENHIDE_IFACE, NULL, 0, &InterfaceList);
   9.102 +  if (!NT_SUCCESS(Status) || InterfaceList == NULL || *InterfaceList == 0)
   9.103    {
   9.104 -    KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface (BusInterface) failed with Status 0x%08x\n", Status));
   9.105 +    AutoEnumerate = FALSE;
   9.106 +    KdPrint((__DRIVER_NAME "     XenHide not loaded or GPLPV not specified\n", Status));
   9.107 +  }
   9.108 +  else
   9.109 +  {
   9.110 +    AutoEnumerate = TRUE;
   9.111 +    KdPrint((__DRIVER_NAME "     XenHide loaded and GPLPV specified\n", Status));
   9.112    }
   9.113  
   9.114    busInfo.BusTypeGuid = GUID_XENPCI_DEVCLASS;
   9.115 @@ -400,7 +330,7 @@ XenPCI_AddDevice(
   9.116  
   9.117    WdfDeviceSetBusInformationForChildren(Device, &busInfo);
   9.118  
   9.119 -  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, NULL); //EvtChn_InterruptDpc);
   9.120 +  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, NULL);
   9.121    InterruptConfig.EvtInterruptEnable = XenPCI_InterruptEnable;
   9.122    InterruptConfig.EvtInterruptDisable = XenPCI_InterruptDisable;
   9.123    Status = WdfInterruptCreate(Device, &InterruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &xpdd->XenInterrupt);
    10.1 --- a/xenvbd/sources	Sat Jan 26 22:18:40 2008 +1100
    10.2 +++ b/xenvbd/sources	Fri Feb 01 00:22:46 2008 +1100
    10.3 @@ -1,7 +1,7 @@
    10.4  TARGETNAME=XENVBD
    10.5  TARGETTYPE=DRIVER
    10.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
    10.7 -VERSION=0.6.0.36
    10.8 +VERSION=0.6.1.2
    10.9  KMDF_VERSION=1
   10.10  MSC_WARNING_LEVEL=/W4
   10.11  INF_NAME=xenvbd
    11.1 --- a/xenvbd/xenvbd.c	Sat Jan 26 22:18:40 2008 +1100
    11.2 +++ b/xenvbd/xenvbd.c	Fri Feb 01 00:22:46 2008 +1100
    11.3 @@ -35,7 +35,7 @@ XenVbd_HwScsiAdapterControl(PVOID Device
    11.4  #pragma alloc_text (INIT, DriverEntry)
    11.5  #endif
    11.6  
    11.7 -static BOOLEAN AutoEnumerate;
    11.8 +//static BOOLEAN AutoEnumerate;
    11.9  
   11.10  NTSTATUS
   11.11  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   11.12 @@ -131,7 +131,7 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
   11.13    PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)TargetData->DeviceData;
   11.14    int more_to_do = TRUE;
   11.15  
   11.16 -  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
   11.17 +//  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
   11.18  
   11.19    while (more_to_do)
   11.20    {
   11.21 @@ -180,7 +180,7 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
   11.22      }
   11.23    }
   11.24  
   11.25 -  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
   11.26 +//  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
   11.27  }
   11.28  
   11.29  static BOOLEAN
   11.30 @@ -261,6 +261,7 @@ XenVbd_BackEndStateHandler(char *Path, P
   11.31      ref = DeviceData->XenDeviceData->XenInterface.GntTbl_GrantAccess(
   11.32        DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   11.33        0, PFN, FALSE);
   11.34 +    ASSERT((signed short)ref >= 0);
   11.35  
   11.36      TargetData->shadow = ExAllocatePoolWithTag(NonPagedPool, sizeof(blkif_shadow_t) * BLK_RING_SIZE, XENVBD_POOL_TAG);
   11.37  
   11.38 @@ -746,6 +747,7 @@ XenVbd_PutSrbOnRing(PXENVBD_TARGET_DATA 
   11.39      req->seg[i].gref = DeviceData->XenDeviceData->XenInterface.GntTbl_GrantAccess(
   11.40        DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   11.41        0, (ULONG)MmGetMdlPfnArray(TargetData->shadow[req->id].Mdl)[i], FALSE);
   11.42 +    ASSERT((signed short)req->seg[i].gref >= 0);
   11.43      req->seg[i].first_sect = 0;
   11.44      if (i == req->nr_segments - 1)
   11.45        req->seg[i].last_sect = (UINT8)((BlockCount - 1) % (PAGE_SIZE / TargetData->BytesPerSector));