win-pvdrivers

changeset 275:0401d8062ede wdm

Update of xennet appears to be working now without a crash or reboot required.
author James Harper <james.harper@bendigoit.com.au>
date Fri May 23 22:54:13 2008 +1000 (2008-05-23)
parents 874c3640830e
children 2e2bcadfb181
files common.inc common/include/xen_public.h xenhide/xenhide.c xenhide/xenhide.h xennet/xennet.c xennet/xennet.h xenpci/xenpci_pdo.c xenscsi/makefile.inc xenscsi/xenscsi.h xenstub/xenstub.c xenstub/xenstub.inx
line diff
     1.1 --- a/common.inc	Thu May 22 13:46:15 2008 +1000
     1.2 +++ b/common.inc	Fri May 23 22:54:13 2008 +1000
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.9.0.12
     1.5 +VERSION=0.9.0.22
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  MSC_WARNING_LEVEL=/W4
     1.8  INCLUDES = ..\common\include;..\common\include\public
     2.1 --- a/common/include/xen_public.h	Thu May 22 13:46:15 2008 +1000
     2.2 +++ b/common/include/xen_public.h	Fri May 23 22:54:13 2008 +1000
     2.3 @@ -161,6 +161,7 @@ typedef struct {
     2.4  #define XEN_INIT_TYPE_READ_STRING_BACK  6
     2.5  #define XEN_INIT_TYPE_VECTORS           7
     2.6  #define XEN_INIT_TYPE_GRANT_ENTRIES     8
     2.7 +#define XEN_INIT_TYPE_COPY_PTR          9
     2.8  
     2.9  static __inline VOID
    2.10  __ADD_XEN_INIT_UCHAR(PUCHAR *ptr, UCHAR val)
    2.11 @@ -275,6 +276,9 @@ ADD_XEN_INIT_REQ(PUCHAR *ptr, UCHAR type
    2.12    case XEN_INIT_TYPE_GRANT_ENTRIES:
    2.13      __ADD_XEN_INIT_ULONG(ptr, PtrToUlong(p1));
    2.14      break;
    2.15 +  case XEN_INIT_TYPE_COPY_PTR:
    2.16 +    __ADD_XEN_INIT_STRING(ptr, p1);
    2.17 +    __ADD_XEN_INIT_PTR(ptr, p2);
    2.18    }
    2.19  }
    2.20  
    2.21 @@ -306,6 +310,9 @@ GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1,
    2.22    case XEN_INIT_TYPE_GRANT_ENTRIES:
    2.23      *p1 = UlongToPtr(__GET_XEN_INIT_ULONG(ptr));
    2.24      break;
    2.25 +  case XEN_INIT_TYPE_COPY_PTR:
    2.26 +    *p1 = __GET_XEN_INIT_STRING(ptr);
    2.27 +    *p2 = __GET_XEN_INIT_PTR(ptr);
    2.28    }
    2.29    return retval;
    2.30  }
    2.31 @@ -343,6 +350,9 @@ ADD_XEN_INIT_RSP(PUCHAR *ptr, UCHAR type
    2.32      memcpy(*ptr, p2, PtrToUlong(p1) * sizeof(grant_entry_t));
    2.33      *ptr += PtrToUlong(p1) * sizeof(grant_entry_t);
    2.34      break;
    2.35 +  case XEN_INIT_TYPE_COPY_PTR:
    2.36 +    __ADD_XEN_INIT_STRING(ptr, p1);
    2.37 +    __ADD_XEN_INIT_PTR(ptr, p2);
    2.38    }
    2.39  }
    2.40  
    2.41 @@ -388,6 +398,9 @@ GET_XEN_INIT_RSP(PUCHAR *ptr, PVOID *p1,
    2.42      *p2 = *ptr;
    2.43      *ptr += PtrToUlong(*p1) * sizeof(grant_entry_t);
    2.44      break;
    2.45 +  case XEN_INIT_TYPE_COPY_PTR:
    2.46 +    *p1 = __GET_XEN_INIT_STRING(ptr);
    2.47 +    *p2 = __GET_XEN_INIT_PTR(ptr);
    2.48    }
    2.49    return retval;
    2.50  }
     3.1 --- a/xenhide/xenhide.c	Thu May 22 13:46:15 2008 +1000
     3.2 +++ b/xenhide/xenhide.c	Fri May 23 22:54:13 2008 +1000
     3.3 @@ -156,7 +156,7 @@ XenHide_AddDevice(
     3.4  {
     3.5    NTSTATUS status;
     3.6    PDEVICE_OBJECT deviceObject = NULL;
     3.7 -  PXENHIDE_DEVICE_DATA DeviceExtension;
     3.8 +  PXENHIDE_DEVICE_DATA xhdd;
     3.9    ULONG length;
    3.10    WCHAR buffer[256];
    3.11  //  size_t StrLen;
    3.12 @@ -203,21 +203,18 @@ XenHide_AddDevice(
    3.13      FALSE,
    3.14      &deviceObject);
    3.15  
    3.16 -  DeviceExtension = (PXENHIDE_DEVICE_DATA)deviceObject->DeviceExtension;
    3.17 +  xhdd = (PXENHIDE_DEVICE_DATA)deviceObject->DeviceExtension;
    3.18  
    3.19 -  DeviceExtension->NextLowerDevice = IoAttachDeviceToDeviceStack(
    3.20 -    deviceObject,
    3.21 -    PhysicalDeviceObject);
    3.22 -  deviceObject->Flags |= DeviceExtension->NextLowerDevice->Flags;
    3.23 +  xhdd->lower_do = IoAttachDeviceToDeviceStack(
    3.24 +    deviceObject, PhysicalDeviceObject);
    3.25 +  deviceObject->Flags |= xhdd->lower_do->Flags;
    3.26  
    3.27 -  deviceObject->DeviceType = DeviceExtension->NextLowerDevice->DeviceType;
    3.28 +  deviceObject->DeviceType = xhdd->lower_do->DeviceType;
    3.29  
    3.30    deviceObject->Characteristics = 
    3.31 -    DeviceExtension->NextLowerDevice->Characteristics;
    3.32 +    xhdd->lower_do->Characteristics;
    3.33  
    3.34 -  DeviceExtension->Self = deviceObject;
    3.35 -
    3.36 -  //INITIALIZE_PNP_STATE(DeviceExtension);
    3.37 +  xhdd->filter_do = deviceObject;
    3.38  
    3.39    deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    3.40  
    3.41 @@ -229,11 +226,61 @@ XenHide_AddDevice(
    3.42  static NTSTATUS
    3.43  XenHide_Pass(PDEVICE_OBJECT DeviceObject, PIRP Irp)
    3.44  {
    3.45 -  PXENHIDE_DEVICE_DATA DeviceExtension = (PXENHIDE_DEVICE_DATA)DeviceObject->DeviceExtension;
    3.46 +  PXENHIDE_DEVICE_DATA xhdd = (PXENHIDE_DEVICE_DATA)DeviceObject->DeviceExtension;
    3.47    NTSTATUS status;
    3.48      
    3.49    IoSkipCurrentIrpStackLocation(Irp);
    3.50 -  status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
    3.51 +  status = IoCallDriver(xhdd->lower_do, Irp);
    3.52 +  return status;
    3.53 +}
    3.54 +
    3.55 +static NTSTATUS
    3.56 +XenHide_Pnp_IoCompletion(PDEVICE_OBJECT device_object, PIRP irp, PVOID context)
    3.57 +{
    3.58 +  PKEVENT event = (PKEVENT)context;
    3.59 +
    3.60 +  UNREFERENCED_PARAMETER(device_object);
    3.61 +
    3.62 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.63 +
    3.64 +  if (irp->PendingReturned)
    3.65 +  {
    3.66 +    KeSetEvent(event, IO_NO_INCREMENT, FALSE);
    3.67 +  }
    3.68 +
    3.69 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
    3.70 +
    3.71 +  return STATUS_MORE_PROCESSING_REQUIRED;
    3.72 +}
    3.73 +
    3.74 +static NTSTATUS
    3.75 +XenHide_SendAndWaitForIrp(PDEVICE_OBJECT device_object, PIRP irp)
    3.76 +{
    3.77 +  NTSTATUS status;
    3.78 +  PXENHIDE_DEVICE_DATA xhdd = (PXENHIDE_DEVICE_DATA)device_object->DeviceExtension;
    3.79 +  KEVENT event;
    3.80 +
    3.81 +  UNREFERENCED_PARAMETER(device_object);
    3.82 +
    3.83 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.84 +
    3.85 +  KeInitializeEvent(&event, NotificationEvent, FALSE);
    3.86 +
    3.87 +  IoCopyCurrentIrpStackLocationToNext(irp);
    3.88 +  IoSetCompletionRoutine(irp, XenHide_Pnp_IoCompletion, &event, TRUE, TRUE, TRUE);
    3.89 +
    3.90 +  status = IoCallDriver(xhdd->lower_do, irp);
    3.91 +
    3.92 +  if (status == STATUS_PENDING)
    3.93 +  {
    3.94 +    KdPrint((__DRIVER_NAME "     waiting ...\n"));
    3.95 +    KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
    3.96 +    KdPrint((__DRIVER_NAME "     ... done\n"));
    3.97 +    status = irp->IoStatus.Status;
    3.98 +  }
    3.99 +
   3.100 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   3.101 +
   3.102    return status;
   3.103  }
   3.104  
   3.105 @@ -254,9 +301,17 @@ XenHide_Pnp(PDEVICE_OBJECT device_object
   3.106      status = irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
   3.107      IoCompleteRequest(irp, IO_NO_INCREMENT);
   3.108      break;
   3.109 +  case IRP_MN_QUERY_CAPABILITIES:
   3.110 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_CAPABILITIES\n"));
   3.111 +    stack->Parameters.DeviceCapabilities.Capabilities->NoDisplayInUI = 1;
   3.112 +    status = XenHide_SendAndWaitForIrp(device_object, irp);
   3.113 +    status = irp->IoStatus.Status = STATUS_SUCCESS;
   3.114 +    IoCompleteRequest(irp, IO_NO_INCREMENT);
   3.115 +    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   3.116 +    return status;
   3.117    default:
   3.118      IoSkipCurrentIrpStackLocation(irp);
   3.119 -    status = IoCallDriver(xhdd->NextLowerDevice, irp);
   3.120 +    status = IoCallDriver(xhdd->lower_do, irp);
   3.121      break;
   3.122    }
   3.123  
     4.1 --- a/xenhide/xenhide.h	Thu May 22 13:46:15 2008 +1000
     4.2 +++ b/xenhide/xenhide.h	Fri May 23 22:54:13 2008 +1000
     4.3 @@ -41,13 +41,10 @@ Foundation, Inc., 51 Franklin Street, Fi
     4.4  #define XENHIDE_TYPE_HIDE 2
     4.5  
     4.6  struct {
     4.7 -  PDEVICE_OBJECT Self;
     4.8 -  PDEVICE_OBJECT PhysicalDeviceObject;
     4.9 -  PDRIVER_OBJECT DriverObject;
    4.10 -  PDEVICE_OBJECT NextLowerDevice;
    4.11 +  PDEVICE_OBJECT filter_do;
    4.12 +  PDEVICE_OBJECT pdo;
    4.13 +  PDEVICE_OBJECT lower_do;
    4.14    IO_REMOVE_LOCK RemoveLock;
    4.15 -  UNICODE_STRING InterfaceName;
    4.16 -  ULONG InternalState;
    4.17  } typedef XENHIDE_DEVICE_DATA, *PXENHIDE_DEVICE_DATA;
    4.18  
    4.19  #endif
     5.1 --- a/xennet/xennet.c	Thu May 22 13:46:15 2008 +1000
     5.2 +++ b/xennet/xennet.c	Fri May 23 22:54:13 2008 +1000
     5.3 @@ -126,7 +126,7 @@ XenNet_Init(
     5.4    UINT i, j;
     5.5    BOOLEAN medium_found = FALSE;
     5.6    struct xennet_info *xi = NULL;
     5.7 -  ULONG length;
     5.8 +  ULONG nrl_length;
     5.9    PNDIS_RESOURCE_LIST nrl;
    5.10    PCM_PARTIAL_RESOURCE_DESCRIPTOR prd;
    5.11    KIRQL irq_level = 0;
    5.12 @@ -134,6 +134,7 @@ XenNet_Init(
    5.13    UCHAR type;
    5.14    PUCHAR ptr;
    5.15    PCHAR setting, value;
    5.16 +  ULONG length;
    5.17    
    5.18    UNREFERENCED_PARAMETER(OpenErrorStatus);
    5.19  
    5.20 @@ -173,18 +174,18 @@ XenNet_Init(
    5.21      0, NDIS_ATTRIBUTE_DESERIALIZE, // | NDIS_ATTRIBUTE_BUS_MASTER),
    5.22      NdisInterfaceInternal);
    5.23  
    5.24 -  length = 0;
    5.25 +  nrl_length = 0;
    5.26    NdisMQueryAdapterResources(&status, WrapperConfigurationContext,
    5.27 -    NULL, (PUINT)&length);
    5.28 -  KdPrint((__DRIVER_NAME "     length = %d\n", length));
    5.29 -  status = NdisAllocateMemoryWithTag(&nrl, length, XENNET_POOL_TAG);
    5.30 +    NULL, (PUINT)&nrl_length);
    5.31 +  KdPrint((__DRIVER_NAME "     nrl_length = %d\n", nrl_length));
    5.32 +  status = NdisAllocateMemoryWithTag(&nrl, nrl_length, XENNET_POOL_TAG);
    5.33    if (status != NDIS_STATUS_SUCCESS)
    5.34    {
    5.35      KdPrint((__DRIVER_NAME "     Could not get allocate memory for Adapter Resources 0x%x\n", status));
    5.36      return NDIS_ERROR_CODE_ADAPTER_NOT_FOUND;
    5.37    }
    5.38    NdisMQueryAdapterResources(&status, WrapperConfigurationContext,
    5.39 -    nrl, (PUINT)&length);
    5.40 +    nrl, (PUINT)&nrl_length);
    5.41    if (status != NDIS_STATUS_SUCCESS)
    5.42    {
    5.43      KdPrint((__DRIVER_NAME "     Could not get Adapter Resources 0x%x\n", status));
    5.44 @@ -262,6 +263,19 @@ XenNet_Init(
    5.45            else
    5.46              memcpy(&xi->vectors, value, sizeof(XENPCI_VECTORS));
    5.47            break;
    5.48 +        case XEN_INIT_TYPE_COPY_PTR:
    5.49 +          if (strcmp(setting, "new_crl_translated") == 0)
    5.50 +          {
    5.51 +            xi->new_crl_translated = (PCM_RESOURCE_LIST)value;
    5.52 +          }
    5.53 +          else if (strcmp(setting, "new_crl_raw") == 0)
    5.54 +          {
    5.55 +            xi->new_crl_raw = (PCM_RESOURCE_LIST)value;
    5.56 +          }
    5.57 +          else if (strcmp(setting, "uncached_config_page") == 0)
    5.58 +          {
    5.59 +            xi->uncached_config_page = (PMDL)value;
    5.60 +          }
    5.61          default:
    5.62            KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_%d\n", type));
    5.63            break;
    5.64 @@ -269,7 +283,9 @@ XenNet_Init(
    5.65        }
    5.66        break;
    5.67      }
    5.68 -  } 
    5.69 +  }
    5.70 +
    5.71 +  NdisFreeMemory(nrl, nrl_length, 0);
    5.72  
    5.73    KeInitializeSpinLock(&xi->rx_lock);
    5.74  
    5.75 @@ -424,6 +440,10 @@ XenNet_Halt(
    5.76  
    5.77    xi->vectors.XenPci_ShutdownDevice(xi->vectors.context);
    5.78  
    5.79 +  ExFreePoolWithTag(xi->new_crl_raw, XENNET_POOL_TAG);
    5.80 +  ExFreePoolWithTag(xi->new_crl_translated, XENNET_POOL_TAG);
    5.81 +  FreeUncachedPage(xi->uncached_config_page);
    5.82 +
    5.83    xi->connected = FALSE;
    5.84    KeMemoryBarrier(); /* make sure everyone sees that we are now shut down */
    5.85  
    5.86 @@ -456,7 +476,9 @@ XenNet_Pnp(PDEVICE_OBJECT device_object,
    5.87  {
    5.88    PIO_STACK_LOCATION stack;
    5.89    NTSTATUS status;
    5.90 -  PCM_RESOURCE_LIST old_crl, new_crl;
    5.91 +  PCM_RESOURCE_LIST old_crl;
    5.92 +  PCM_RESOURCE_LIST new_crl_translated;
    5.93 +  PCM_RESOURCE_LIST new_crl_raw;
    5.94    PCM_PARTIAL_RESOURCE_LIST prl;
    5.95    PCM_PARTIAL_RESOURCE_DESCRIPTOR prd;
    5.96    ULONG old_length, new_length;
    5.97 @@ -555,9 +577,10 @@ XenNet_Pnp(PDEVICE_OBJECT device_object,
    5.98          FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
    5.99          sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * old_crl->List[0].PartialResourceList.Count;
   5.100        new_length = old_length + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * 1;
   5.101 -      new_crl = ExAllocatePoolWithTag(PagedPool, new_length, XENNET_POOL_TAG);
   5.102 -      memcpy(new_crl, old_crl, old_length);
   5.103 -      prl = &new_crl->List[0].PartialResourceList;
   5.104 +      new_crl_translated = ExAllocatePoolWithTag(PagedPool, new_length, XENNET_POOL_TAG);
   5.105 +      new_crl_raw = ExAllocatePoolWithTag(PagedPool, new_length, XENNET_POOL_TAG);
   5.106 +      memcpy(new_crl_translated, old_crl, old_length);
   5.107 +      prl = &new_crl_translated->List[0].PartialResourceList;
   5.108        prd = &prl->PartialDescriptors[prl->Count++];
   5.109        prd->Type = CmResourceTypeMemory;
   5.110        prd->ShareDisposition = CmResourceShareDeviceExclusive;
   5.111 @@ -576,21 +599,23 @@ XenNet_Pnp(PDEVICE_OBJECT device_object,
   5.112        ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_WRITE_STRING, "request-rx-copy", "1");
   5.113        ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_WRITE_STRING, "feature-rx-notify", "1");
   5.114        ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_VECTORS, NULL, NULL);
   5.115 +      ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_COPY_PTR, "new_crl_translated", new_crl_translated);
   5.116 +      ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_COPY_PTR, "new_crl_raw", new_crl_raw);
   5.117 +      ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_COPY_PTR, "uncached_config_page", mdl);
   5.118        ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_END, NULL, NULL);
   5.119        
   5.120 -      stack->Parameters.StartDevice.AllocatedResourcesTranslated = new_crl;
   5.121 +      stack->Parameters.StartDevice.AllocatedResourcesTranslated = new_crl_translated;
   5.122  
   5.123        old_crl = stack->Parameters.StartDevice.AllocatedResources;
   5.124 -      new_crl = ExAllocatePoolWithTag(PagedPool, new_length, XENNET_POOL_TAG);
   5.125 -      memcpy(new_crl, old_crl, old_length);
   5.126 -      prl = &new_crl->List[0].PartialResourceList;
   5.127 +      memcpy(new_crl_raw, old_crl, old_length);
   5.128 +      prl = &new_crl_raw->List[0].PartialResourceList;
   5.129        prd = &prl->PartialDescriptors[prl->Count++];
   5.130        prd->Type = CmResourceTypeMemory;
   5.131        prd->ShareDisposition = CmResourceShareDeviceExclusive;
   5.132        prd->Flags = CM_RESOURCE_MEMORY_READ_WRITE|CM_RESOURCE_MEMORY_PREFETCHABLE|CM_RESOURCE_MEMORY_CACHEABLE;
   5.133        prd->u.Memory.Start.QuadPart = MmGetMdlPfnArray(mdl)[0] << PAGE_SHIFT;
   5.134        prd->u.Memory.Length = PAGE_SIZE;
   5.135 -      stack->Parameters.StartDevice.AllocatedResources = new_crl;
   5.136 +      stack->Parameters.StartDevice.AllocatedResources = new_crl_raw;
   5.137        IoCopyCurrentIrpStackLocationToNext(irp);
   5.138      }
   5.139      else
     6.1 --- a/xennet/xennet.h	Thu May 22 13:46:15 2008 +1000
     6.2 +++ b/xennet/xennet.h	Fri May 23 22:54:13 2008 +1000
     6.3 @@ -156,6 +156,9 @@ struct xennet_info
     6.4    PDEVICE_OBJECT lower_do;
     6.5    //WDFDEVICE wdf_device;
     6.6    WCHAR dev_desc[NAME_SIZE];
     6.7 +  PMDL uncached_config_page;
     6.8 +  PCM_RESOURCE_LIST new_crl_raw;
     6.9 +  PCM_RESOURCE_LIST new_crl_translated;
    6.10  
    6.11    /* NDIS-related vars */
    6.12    NDIS_HANDLE adapter_handle;
     7.1 --- a/xenpci/xenpci_pdo.c	Thu May 22 13:46:15 2008 +1000
     7.2 +++ b/xenpci/xenpci_pdo.c	Fri May 23 22:54:13 2008 +1000
     7.3 @@ -392,13 +392,6 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
     7.4    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
     7.5    XenBus_AddWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
     7.6  
     7.7 -  if (XenPci_ChangeFrontendState(xppdd, XenbusStateInitialising, XenbusStateInitWait, 30000) != STATUS_SUCCESS)
     7.8 -  {
     7.9 -    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    7.10 -    XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    7.11 -    return STATUS_UNSUCCESSFUL;
    7.12 -  }
    7.13 -
    7.14    res_list = &stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList;
    7.15    for (i = 0; i < res_list->Count; i++)
    7.16    {
    7.17 @@ -427,6 +420,12 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    7.18      case CmResourceTypeMemory:
    7.19        KdPrint((__DRIVER_NAME "     CmResourceTypeMemory\n"));
    7.20        KdPrint((__DRIVER_NAME "     Start = %08x, Length = %d\n", res_descriptor->u.Memory.Start.LowPart, res_descriptor->u.Memory.Length));
    7.21 +      if (XenPci_ChangeFrontendState(xppdd, XenbusStateInitialising, XenbusStateInitWait, 30000) != STATUS_SUCCESS)
    7.22 +      {
    7.23 +        RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    7.24 +        XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    7.25 +        return STATUS_UNSUCCESSFUL;
    7.26 +      }
    7.27        out_ptr = out_start = MmMapIoSpace(res_descriptor->u.Memory.Start, res_descriptor->u.Memory.Length, MmNonCached);
    7.28        in_ptr = xppdd->xenbus_request = ExAllocatePoolWithTag(PagedPool, res_descriptor->u.Memory.Length, XENPCI_POOL_TAG);
    7.29        KdPrint((__DRIVER_NAME "     out_ptr = %p, in_ptr = %p\n", out_ptr, in_ptr));
    7.30 @@ -484,24 +483,26 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    7.31            }
    7.32            event_channels++;
    7.33            break;
    7.34 +        case XEN_INIT_TYPE_COPY_PTR:
    7.35 +          ADD_XEN_INIT_RSP(&out_ptr, type, setting, value);
    7.36 +          break;
    7.37          }
    7.38        }
    7.39 +      if (!NT_SUCCESS(status))
    7.40 +      {
    7.41 +        RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    7.42 +        XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    7.43 +        return status;
    7.44 +      }
    7.45 +      if (XenPci_ChangeFrontendState(xppdd, XenbusStateConnected, XenbusStateConnected, 30000) != STATUS_SUCCESS)
    7.46 +      {
    7.47 +        RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    7.48 +        XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    7.49 +        return STATUS_UNSUCCESSFUL;
    7.50 +      }
    7.51      }
    7.52    }
    7.53  
    7.54 -  if (!NT_SUCCESS(status))
    7.55 -  {
    7.56 -    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    7.57 -    XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    7.58 -    return status;
    7.59 -  }
    7.60 -  if (XenPci_ChangeFrontendState(xppdd, XenbusStateConnected, XenbusStateConnected, 30000) != STATUS_SUCCESS)
    7.61 -  {
    7.62 -    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    7.63 -    XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    7.64 -    return STATUS_UNSUCCESSFUL;
    7.65 -  }
    7.66 -
    7.67    res_list = &stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList;
    7.68    for (i = 0; i < res_list->Count; i++)
    7.69    {
    7.70 @@ -617,7 +618,7 @@ XenPci_Pnp_RemoveDevice(PDEVICE_OBJECT d
    7.71    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    7.72    XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    7.73    
    7.74 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    7.75 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (status = %08x)\n", status));
    7.76  
    7.77    return status;
    7.78  }
    7.79 @@ -962,13 +963,14 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
    7.80  NTSTATUS
    7.81  XenPci_Irp_Create_Pdo(PDEVICE_OBJECT device_object, PIRP irp)
    7.82  {
    7.83 -  PXENPCI_DEVICE_DATA xpdd;
    7.84    NTSTATUS status;
    7.85  
    7.86 +  UNREFERENCED_PARAMETER(device_object);
    7.87 +
    7.88    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    7.89  
    7.90 -  xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
    7.91 -  status = IoCallDriver(xpdd->common.lower_do, irp);
    7.92 +  status = irp->IoStatus.Status;
    7.93 +  IoCompleteRequest(irp, IO_NO_INCREMENT);
    7.94  
    7.95    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
    7.96  
    7.97 @@ -978,13 +980,14 @@ XenPci_Irp_Create_Pdo(PDEVICE_OBJECT dev
    7.98  NTSTATUS
    7.99  XenPci_Irp_Close_Pdo(PDEVICE_OBJECT device_object, PIRP irp)
   7.100  {
   7.101 -  PXENPCI_DEVICE_DATA xpdd;
   7.102    NTSTATUS status;
   7.103  
   7.104 +  UNREFERENCED_PARAMETER(device_object);
   7.105 +
   7.106    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   7.107  
   7.108 -  xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
   7.109 -  status = IoCallDriver(xpdd->common.lower_do, irp);
   7.110 +  status = irp->IoStatus.Status;
   7.111 +  IoCompleteRequest(irp, IO_NO_INCREMENT);
   7.112  
   7.113    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   7.114  
   7.115 @@ -994,13 +997,14 @@ XenPci_Irp_Close_Pdo(PDEVICE_OBJECT devi
   7.116  NTSTATUS
   7.117  XenPci_Irp_Read_Pdo(PDEVICE_OBJECT device_object, PIRP irp)
   7.118  {
   7.119 -  PXENPCI_DEVICE_DATA xpdd;
   7.120    NTSTATUS status;
   7.121  
   7.122 +  UNREFERENCED_PARAMETER(device_object);
   7.123 +
   7.124    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   7.125  
   7.126 -  xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
   7.127 -  status = IoCallDriver(xpdd->common.lower_do, irp);
   7.128 +  status = irp->IoStatus.Status;
   7.129 +  IoCompleteRequest(irp, IO_NO_INCREMENT);
   7.130  
   7.131    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   7.132  
   7.133 @@ -1016,8 +1020,7 @@ XenPci_Irp_Cleanup_Pdo(PDEVICE_OBJECT de
   7.134  
   7.135    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   7.136    
   7.137 -  status = STATUS_SUCCESS;
   7.138 -  irp->IoStatus.Status = status;
   7.139 +  status = irp->IoStatus.Status;
   7.140    IoCompleteRequest(irp, IO_NO_INCREMENT);
   7.141    
   7.142    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
     8.1 --- a/xenscsi/makefile.inc	Thu May 22 13:46:15 2008 +1000
     8.2 +++ b/xenscsi/makefile.inc	Fri May 23 22:54:13 2008 +1000
     8.3 @@ -1,5 +1,5 @@
     8.4  _LNG=$(LANGUAGE)
     8.5 -STAMP=stampinf -f $@ -a $(_BUILDARCH) -d * -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) -v $(VERSION)
     8.6 +STAMP=stampinf -f $@ -a $(_BUILDARCH) -d * -v $(VERSION)
     8.7  
     8.8  ..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf: $(INF_NAME).inx sources ..\common.inc
     8.9      copy $(@B).inx $@
     9.1 --- a/xenscsi/xenscsi.h	Thu May 22 13:46:15 2008 +1000
     9.2 +++ b/xenscsi/xenscsi.h	Fri May 23 22:54:13 2008 +1000
     9.3 @@ -4,7 +4,6 @@
     9.4  #include <ntifs.h>
     9.5  #include <ntddk.h>
     9.6  #include <wdm.h>
     9.7 -#include <wdf.h>
     9.8  #include <initguid.h>
     9.9  #include <ntdddisk.h>
    9.10  #include <srb.h>
    10.1 --- a/xenstub/xenstub.c	Thu May 22 13:46:15 2008 +1000
    10.2 +++ b/xenstub/xenstub.c	Fri May 23 22:54:13 2008 +1000
    10.3 @@ -22,6 +22,70 @@ Foundation, Inc., 51 Franklin Street, Fi
    10.4  
    10.5  DRIVER_INITIALIZE DriverEntry;
    10.6  
    10.7 +static NTSTATUS
    10.8 +XenStub_Pnp_IoCompletion(PDEVICE_OBJECT device_object, PIRP irp, PVOID context)
    10.9 +{
   10.10 +  PKEVENT event = (PKEVENT)context;
   10.11 +
   10.12 +  UNREFERENCED_PARAMETER(device_object);
   10.13 +
   10.14 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   10.15 +
   10.16 +  if (irp->PendingReturned)
   10.17 +  {
   10.18 +    KeSetEvent(event, IO_NO_INCREMENT, FALSE);
   10.19 +  }
   10.20 +
   10.21 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   10.22 +
   10.23 +  return STATUS_MORE_PROCESSING_REQUIRED;
   10.24 +}
   10.25 +
   10.26 +#if 0
   10.27 +static NTSTATUS
   10.28 +XenStub_QueueWorkItem(PDEVICE_OBJECT device_object, PIO_WORKITEM_ROUTINE routine, PVOID context)
   10.29 +{
   10.30 +  PIO_WORKITEM work_item;
   10.31 +  NTSTATUS status = STATUS_SUCCESS;
   10.32 +
   10.33 +  work_item = IoAllocateWorkItem(device_object);
   10.34 +  IoQueueWorkItem(work_item, routine, DelayedWorkQueue, context);
   10.35 +	
   10.36 +  return status;
   10.37 +}
   10.38 +#endif
   10.39 +
   10.40 +static NTSTATUS
   10.41 +XenStub_SendAndWaitForIrp(PDEVICE_OBJECT device_object, PIRP irp)
   10.42 +{
   10.43 +  NTSTATUS status;
   10.44 +  PXENSTUB_DEVICE_DATA xsdd = (PXENSTUB_DEVICE_DATA)device_object->DeviceExtension;
   10.45 +  KEVENT event;
   10.46 +
   10.47 +  UNREFERENCED_PARAMETER(device_object);
   10.48 +
   10.49 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   10.50 +
   10.51 +  KeInitializeEvent(&event, NotificationEvent, FALSE);
   10.52 +
   10.53 +  IoCopyCurrentIrpStackLocationToNext(irp);
   10.54 +  IoSetCompletionRoutine(irp, XenStub_Pnp_IoCompletion, &event, TRUE, TRUE, TRUE);
   10.55 +
   10.56 +  status = IoCallDriver(xsdd->lower_do, irp);
   10.57 +
   10.58 +  if (status == STATUS_PENDING)
   10.59 +  {
   10.60 +    KdPrint((__DRIVER_NAME "     waiting ...\n"));
   10.61 +    KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
   10.62 +    KdPrint((__DRIVER_NAME "     ... done\n"));
   10.63 +    status = irp->IoStatus.Status;
   10.64 +  }
   10.65 +
   10.66 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   10.67 +
   10.68 +  return status;
   10.69 +}
   10.70 +
   10.71  NTSTATUS
   10.72  XenStub_Irp_Pnp(PDEVICE_OBJECT device_object, PIRP irp)
   10.73  {
   10.74 @@ -39,38 +103,42 @@ XenStub_Irp_Pnp(PDEVICE_OBJECT device_ob
   10.75    {
   10.76    case IRP_MN_START_DEVICE:
   10.77      KdPrint((__DRIVER_NAME "     IRP_MN_START_DEVICE\n"));
   10.78 -    IoSkipCurrentIrpStackLocation(irp);
   10.79 -    //irp->IoStatus.Status = STATUS_SUCCESS;
   10.80 -    break;
   10.81 -    
   10.82 +    IoMarkIrpPending(irp);
   10.83 +    status = XenStub_SendAndWaitForIrp(device_object, irp);
   10.84 +    //XenStub_QueueWorkItem(device_object, XenStub_Pnp_StartDeviceCallback, irp);
   10.85 +    status = irp->IoStatus.Status = STATUS_SUCCESS;
   10.86 +    IoCompleteRequest(irp, IO_NO_INCREMENT);
   10.87 +    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   10.88 +    return status;
   10.89 +
   10.90    case IRP_MN_QUERY_STOP_DEVICE:
   10.91      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_STOP_DEVICE\n"));
   10.92      IoSkipCurrentIrpStackLocation(irp);
   10.93 -    //irp->IoStatus.Status = STATUS_SUCCESS;
   10.94 +    irp->IoStatus.Status = STATUS_SUCCESS;
   10.95      break;
   10.96  
   10.97    case IRP_MN_STOP_DEVICE:
   10.98      KdPrint((__DRIVER_NAME "     IRP_MN_STOP_DEVICE\n"));
   10.99      IoSkipCurrentIrpStackLocation(irp);
  10.100 -    //irp->IoStatus.Status = STATUS_SUCCESS;
  10.101 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.102      break;
  10.103  
  10.104    case IRP_MN_CANCEL_STOP_DEVICE:
  10.105      KdPrint((__DRIVER_NAME "     IRP_MN_CANCEL_STOP_DEVICE\n"));
  10.106      IoSkipCurrentIrpStackLocation(irp);
  10.107 -    //irp->IoStatus.Status = STATUS_SUCCESS;
  10.108 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.109      break;
  10.110  
  10.111    case IRP_MN_QUERY_REMOVE_DEVICE:
  10.112      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_REMOVE_DEVICE\n"));
  10.113      IoSkipCurrentIrpStackLocation(irp);
  10.114 -    //irp->IoStatus.Status = STATUS_SUCCESS;
  10.115 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.116      break;
  10.117      
  10.118    case IRP_MN_REMOVE_DEVICE:
  10.119      KdPrint((__DRIVER_NAME "     IRP_MN_REMOVE_DEVICE\n"));
  10.120      IoSkipCurrentIrpStackLocation(irp);
  10.121 -    //irp->IoStatus.Status = STATUS_SUCCESS;
  10.122 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.123      break;
  10.124  
  10.125    case IRP_MN_CANCEL_REMOVE_DEVICE:
  10.126 @@ -88,12 +156,13 @@ XenStub_Irp_Pnp(PDEVICE_OBJECT device_ob
  10.127    case IRP_MN_DEVICE_USAGE_NOTIFICATION:
  10.128      KdPrint((__DRIVER_NAME "     IRP_MN_DEVICE_USAGE_NOTIFICATION\n"));
  10.129      IoSkipCurrentIrpStackLocation(irp);
  10.130 -    //irp->IoStatus.Status = STATUS_SUCCESS;
  10.131 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.132      break;
  10.133  
  10.134    case IRP_MN_QUERY_DEVICE_RELATIONS:
  10.135      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
  10.136      IoSkipCurrentIrpStackLocation(irp);
  10.137 +    //irp->IoStatus.Information = 0;
  10.138      //irp->IoStatus.Status = STATUS_SUCCESS;
  10.139      break;
  10.140  
  10.141 @@ -102,9 +171,23 @@ XenStub_Irp_Pnp(PDEVICE_OBJECT device_ob
  10.142      IoSkipCurrentIrpStackLocation(irp);
  10.143      //irp->IoStatus.Status = STATUS_SUCCESS;
  10.144      break;
  10.145 +/*   
  10.146 +  case IRP_MN_QUERY_CAPABILITIES:
  10.147 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_CAPABILITIES\n"));
  10.148 +    stack->Parameters.DeviceCapabilities.Capabilities->NoDisplayInUI = 1;
  10.149 +    status = irp->IoStatus.Status = STATUS_SUCCESS;
  10.150 +*/  
  10.151 +  case IRP_MN_QUERY_PNP_DEVICE_STATE:
  10.152 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_PNP_DEVICE_STATE\n"));
  10.153 +    status = XenStub_SendAndWaitForIrp(device_object, irp);
  10.154 +    irp->IoStatus.Information |= PNP_DEVICE_DONT_DISPLAY_IN_UI;
  10.155 +    status = irp->IoStatus.Status = STATUS_SUCCESS;
  10.156 +    IoCompleteRequest(irp, IO_NO_INCREMENT);
  10.157 +    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.158 +    return status;
  10.159  
  10.160    default:
  10.161 -    //KdPrint((__DRIVER_NAME "     Unhandled Minor = %d\n", stack->MinorFunction));
  10.162 +    KdPrint((__DRIVER_NAME "     Unhandled Minor = %d\n", stack->MinorFunction));
  10.163      IoSkipCurrentIrpStackLocation(irp);
  10.164      break;
  10.165    }
    11.1 --- a/xenstub/xenstub.inx	Thu May 22 13:46:15 2008 +1000
    11.2 +++ b/xenstub/xenstub.inx	Fri May 23 22:54:13 2008 +1000
    11.3 @@ -3,11 +3,10 @@ Signature="$WINDOWS NT$"
    11.4  Class=System
    11.5  ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
    11.6  Provider=%XenGplPv%
    11.7 +CatalogFile="XenGPLPV.cat"
    11.8  
    11.9  [DestinationDirs]
   11.10  DefaultDestDir = 12
   11.11 -ClassInstall32_CopyFiles=11
   11.12 -CoInstaller_CopyFiles = 11
   11.13  
   11.14  [ControlFlags]
   11.15  ExcludeFromSelect=*
   11.16 @@ -34,13 +33,12 @@ XenStub.sys
   11.17  
   11.18  [SourceDisksFiles]
   11.19  XenStub.sys=1
   11.20 -WdfCoinstaller$KMDFCOINSTALLERVERSION$.dll=1,,
   11.21  
   11.22  [SourceDisksNames.x86]
   11.23 -1 = %DISK_NAME%,,,\i386
   11.24 +1 = %DISK_NAME%,,,.\i386
   11.25  
   11.26  [SourceDisksNames.amd64]
   11.27 -1 = %DISK_NAME%,,,\amd64
   11.28 +1 = %DISK_NAME%,,,.\amd64
   11.29  
   11.30  [XenStub_Inst.Services]
   11.31  AddService=XenStub,2,XenStub_Service 
   11.32 @@ -51,34 +49,17 @@ AddService=XenStub,2,XenStub_Service
   11.33  [XenStub_Service]
   11.34  DisplayName    = %XenStub.SVCDESC%                            
   11.35  ServiceType    = 1
   11.36 -StartType      = 0
   11.37 +StartType      = 3
   11.38  ErrorControl   = 1
   11.39 -LoadOrderGroup = WdfLoadGroup
   11.40 +LoadOrderGroup = System Bus Extender
   11.41  ServiceBinary  = %12%\xenstub.sys                            
   11.42  AddReg = XenStub_Service_AddReg
   11.43  
   11.44  [XenStub_Service_AddReg]
   11.45  HKR,"Parameters\PnpInterface", "0", 0x00010001, 0x00000001
   11.46  
   11.47 -[XenStub_Inst.NT.CoInstallers]
   11.48 -AddReg=CoInstaller_AddReg
   11.49 -CopyFiles=CoInstaller_CopyFiles
   11.50 -
   11.51 -[CoInstaller_CopyFiles]
   11.52 -WdfCoinstaller$KMDFCOINSTALLERVERSION$.dll,,,2
   11.53 -
   11.54 -[CoInstaller_AddReg]
   11.55 -HKR,,CoInstallers32,0x00010000, "WdfCoinstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"
   11.56 -
   11.57 -[XenStub_Inst.NT.Wdf]
   11.58 -KmdfService = XenStub, XenStub_wdfsect
   11.59 -
   11.60 -[XenStub_wdfsect]
   11.61 -KmdfLibraryVersion = $KMDFVERSION$
   11.62 -
   11.63  [Strings]
   11.64  XenGplPv = "Xen GPL PV Driver Developers"
   11.65 -ClassName = "Network Adapters"
   11.66  XenStub.SVCDESC = "Xen Stub Device Driver"
   11.67  XenStub.DRVDESC = "Xen Stub Device Driver"
   11.68 -DISK_NAME = "Xen Net Device Driver Install Disk"
   11.69 +DISK_NAME = "Xen Stub Device Driver Install Disk"