win-pvdrivers

changeset 38:a5617e7e9f54

fixups from manual merge
author Andy Grover <andy.grover@oracle.com>
date Wed Dec 05 11:37:53 2007 -0800 (2007-12-05)
parents 3ac5c4431dbb
children 48261a2e2038
files xenpci/xenbus.c xenpci/xenpci.c xenpci/xenpci.h
line diff
     1.1 --- a/xenpci/xenbus.c	Wed Dec 05 11:14:28 2007 -0800
     1.2 +++ b/xenpci/xenbus.c	Wed Dec 05 11:37:53 2007 -0800
     1.3 @@ -300,7 +300,6 @@ XenBus_Init(WDFDEVICE Device)
     1.4  {
     1.5    PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
     1.6    NTSTATUS Status;
     1.7 -  OBJECT_ATTRIBUTES oa;
     1.8    int i;
     1.9      
    1.10    //KdPrint((__DRIVER_NAME " --> XenBus_Init\n"));
    1.11 @@ -309,11 +308,11 @@ XenBus_Init(WDFDEVICE Device)
    1.12    xpdd->xen_store_interface = EvtChn_GetXenStoreRingAddr(Device);
    1.13  
    1.14    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
    1.15 -    XenBus_WatchEntries[i].Active = 0;
    1.16 +    xpdd->XenBus_WatchEntries[i].Active = 0;
    1.17  
    1.18    KeInitializeEvent(&xpdd->XenBus_ReadThreadEvent, SynchronizationEvent, FALSE);
    1.19    KeInitializeEvent(&xpdd->XenBus_WatchThreadEvent, SynchronizationEvent, FALSE);
    1.20 -  XenBus_ShuttingDown = FALSE;
    1.21 +  xpdd->XenBus_ShuttingDown = FALSE;
    1.22  
    1.23    //InitializeObjectAttributes(&oa, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
    1.24    //Status = PsCreateSystemThread(&XenBus_ReadThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenBus_ReadThreadProc, NULL);
    1.25 @@ -331,9 +330,11 @@ XenBus_Init(WDFDEVICE Device)
    1.26  NTSTATUS
    1.27  XenBus_Start(WDFDEVICE Device)
    1.28  {
    1.29 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    1.30 +
    1.31    KdPrint((__DRIVER_NAME " --> XenBus_Start\n"));
    1.32  
    1.33 -  EvtChn_Bind(xen_store_evtchn, XenBus_Interrupt, NULL);
    1.34 +  EvtChn_Bind(Device, xpdd->xen_store_evtchn, XenBus_Interrupt, NULL);
    1.35  
    1.36    KdPrint((__DRIVER_NAME " <-- XenBus_Start\n"));
    1.37  
    1.38 @@ -350,8 +351,10 @@ XenBus_Stop(WDFDEVICE Device)
    1.39  
    1.40    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
    1.41    {
    1.42 -    if (XenBus_WatchEntries[i].Active)
    1.43 -      XenBus_RemWatch(XBT_NIL, XenBus_WatchEntries[i].Path, XenBus_WatchEntries[i].ServiceRoutine, XenBus_WatchEntries[i].ServiceContext);
    1.44 +    if (xpdd->XenBus_WatchEntries[i].Active)
    1.45 +      XenBus_RemWatch(Device, XBT_NIL, xpdd->XenBus_WatchEntries[i].Path,
    1.46 +        xpdd->XenBus_WatchEntries[i].ServiceRoutine,
    1.47 +        xpdd->XenBus_WatchEntries[i].ServiceContext);
    1.48    }
    1.49  
    1.50    EvtChn_Unbind(Device, xpdd->xen_store_evtchn);
    1.51 @@ -364,21 +367,22 @@ XenBus_Stop(WDFDEVICE Device)
    1.52  NTSTATUS
    1.53  XenBus_Close(WDFDEVICE Device)
    1.54  {
    1.55 -  PKWAIT_BLOCK WaitBlockArray[2];
    1.56 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    1.57 +  KWAIT_BLOCK WaitBlockArray[2];
    1.58    PVOID WaitArray[2];
    1.59  
    1.60 -  XenBus_ShuttingDown = TRUE;
    1.61 +  xpdd->XenBus_ShuttingDown = TRUE;
    1.62  
    1.63    KdPrint((__DRIVER_NAME "     Signalling Threads\n"));
    1.64 -  KeSetEvent(&XenBus_ReadThreadEvent, 1, FALSE);
    1.65 -  KeSetEvent(&XenBus_WatchThreadEvent, 1, FALSE);
    1.66 +  KeSetEvent(&xpdd->XenBus_ReadThreadEvent, 1, FALSE);
    1.67 +  KeSetEvent(&xpdd->XenBus_WatchThreadEvent, 1, FALSE);
    1.68    KdPrint((__DRIVER_NAME "     Waiting for threads to die\n"));
    1.69 -  ObReferenceObjectByHandle(XenBus_ReadThreadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, &WaitArray[0], NULL);
    1.70 -  ObReferenceObjectByHandle(XenBus_WatchThreadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, &WaitArray[1], NULL);
    1.71 +  ObReferenceObjectByHandle(xpdd->XenBus_ReadThreadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, &WaitArray[0], NULL);
    1.72 +  ObReferenceObjectByHandle(xpdd->XenBus_WatchThreadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, &WaitArray[1], NULL);
    1.73    KeWaitForMultipleObjects(2, WaitArray, WaitAll, Executive, KernelMode, FALSE, NULL, WaitBlockArray);
    1.74    KdPrint((__DRIVER_NAME "     Threads are dead\n"));
    1.75  
    1.76 -  XenBus_ShuttingDown = FALSE;
    1.77 +  xpdd->XenBus_ShuttingDown = FALSE;
    1.78  
    1.79    ObDereferenceObject(WaitArray[0]);
    1.80    ObDereferenceObject(WaitArray[1]);
    1.81 @@ -449,7 +453,7 @@ XenBus_ReadThreadProc(PVOID StartContext
    1.82    for(;;)
    1.83    {
    1.84      KeWaitForSingleObject(&xpdd->XenBus_ReadThreadEvent, Executive, KernelMode, FALSE, NULL);
    1.85 -    if (XenBus_ShuttingDown)
    1.86 +    if (xpdd->XenBus_ShuttingDown)
    1.87      {
    1.88        KdPrint((__DRIVER_NAME "     Shutdown detected in ReadThreadProc\n"));
    1.89        PsTerminateSystemThread(0);
    1.90 @@ -525,12 +529,12 @@ XenBus_WatchThreadProc(PVOID StartContex
    1.91    for(;;)
    1.92    {
    1.93      KeWaitForSingleObject(&xpdd->XenBus_WatchThreadEvent, Executive, KernelMode, FALSE, NULL);
    1.94 -    if (XenBus_ShuttingDown)
    1.95 +    if (xpdd->XenBus_ShuttingDown)
    1.96      {
    1.97        KdPrint((__DRIVER_NAME "     Shutdown detected in WatchThreadProc\n"));
    1.98        PsTerminateSystemThread(0);
    1.99      }
   1.100 -    while (xpdd->XenBus_WatchRingReadIndex != XenBus_WatchRingWriteIndex)
   1.101 +    while (xpdd->XenBus_WatchRingReadIndex != xpdd->XenBus_WatchRingWriteIndex)
   1.102      {
   1.103        xpdd->XenBus_WatchRingReadIndex = 
   1.104          (xpdd->XenBus_WatchRingReadIndex + 1) % WATCH_RING_SIZE;
     2.1 --- a/xenpci/xenpci.c	Wed Dec 05 11:14:28 2007 -0800
     2.2 +++ b/xenpci/xenpci.c	Wed Dec 05 11:37:53 2007 -0800
     2.3 @@ -579,7 +579,7 @@ XenPCI_D0Exit(WDFDEVICE Device, WDF_POWE
     2.4      break;
     2.5    }
     2.6  
     2.7 -  XenBus_Close();
     2.8 +  XenBus_Close(Device);
     2.9  
    2.10    KdPrint((__DRIVER_NAME " <-- DeviceD0Exit\n"));
    2.11  
     3.1 --- a/xenpci/xenpci.h	Wed Dec 05 11:14:28 2007 -0800
     3.2 +++ b/xenpci/xenpci.h	Wed Dec 05 11:37:53 2007 -0800
     3.3 @@ -102,6 +102,7 @@ typedef struct _XENBUS_WATCH_ENTRY {
     3.4  typedef struct {
     3.5  
     3.6    WDFDEVICE Device;
     3.7 +  BOOLEAN XenBus_ShuttingDown;
     3.8  
     3.9    WDFINTERRUPT XenInterrupt;
    3.10    ULONG irqNumber;