win-pvdrivers

diff xenpci/xenbus.c @ 536:1d39de3ab8d6

mostly finished migration back to kmdf
author James Harper <james.harper@bendigoit.com.au>
date Sat Feb 14 13:35:48 2009 +1100 (2009-02-14)
parents 6a2d1517e10c
children e75bb8d68370
line diff
     1.1 --- a/xenpci/xenbus.c	Tue Jan 27 00:47:02 2009 +1100
     1.2 +++ b/xenpci/xenbus.c	Sat Feb 14 13:35:48 2009 +1100
     1.3 @@ -162,6 +162,8 @@ XenBus_Raw(
     1.4    struct xsd_sockmsg *msg)
     1.5  {
     1.6    struct xsd_sockmsg *reply;
     1.7 +  
     1.8 +  FUNCTION_ENTER();
     1.9  
    1.10    ExAcquireFastMutex(&xpdd->xb_request_mutex);
    1.11    xb_write(xpdd, msg, sizeof(struct xsd_sockmsg) + msg->len);
    1.12 @@ -170,6 +172,8 @@ XenBus_Raw(
    1.13    xpdd->xb_reply = NULL;
    1.14    ExReleaseFastMutex(&xpdd->xb_request_mutex);  
    1.15  
    1.16 +  FUNCTION_EXIT();
    1.17 +    
    1.18    return reply;
    1.19  }
    1.20  
    1.21 @@ -248,11 +252,11 @@ XenBus_Dpc(PVOID ServiceContext)
    1.22  {
    1.23    PXENPCI_DEVICE_DATA xpdd = ServiceContext;
    1.24  
    1.25 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    1.26 +  //KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    1.27  
    1.28    KeSetEvent(&xpdd->XenBus_ReadThreadEvent, IO_NO_INCREMENT, FALSE);
    1.29  
    1.30 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    1.31 +  //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    1.32  
    1.33    return;
    1.34  }
    1.35 @@ -268,9 +272,6 @@ XenBus_Connect(PXENPCI_DEVICE_DATA xpdd)
    1.36    pa_xen_store_interface.QuadPart = (ULONGLONG)xen_store_mfn << PAGE_SHIFT;
    1.37    xpdd->xen_store_interface = MmMapIoSpace(pa_xen_store_interface, PAGE_SIZE, MmNonCached);
    1.38  
    1.39 -  EvtChn_BindDpc(xpdd, xpdd->xen_store_evtchn, XenBus_Dpc, xpdd);
    1.40 -
    1.41 -  xpdd->XenBus_ShuttingDown = FALSE;
    1.42    KeMemoryBarrier();
    1.43    
    1.44    return STATUS_SUCCESS;
    1.45 @@ -299,13 +300,12 @@ XenBus_Init(PXENPCI_DEVICE_DATA xpdd)
    1.46    KeInitializeEvent(&xpdd->XenBus_WatchThreadEvent, SynchronizationEvent, FALSE);
    1.47    KeInitializeEvent(&xpdd->xb_request_complete_event, SynchronizationEvent, FALSE);
    1.48  
    1.49 -  xpdd->XenBus_ShuttingDown = FALSE;
    1.50 -
    1.51    status = XenBus_Connect(xpdd);
    1.52    if (!NT_SUCCESS(status))
    1.53    {
    1.54      return status;
    1.55    }
    1.56 +  EvtChn_BindDpc(xpdd, xpdd->xen_store_evtchn, XenBus_Dpc, xpdd);
    1.57  
    1.58    status = PsCreateSystemThread(&thread_handle, THREAD_ALL_ACCESS, NULL, NULL, NULL, XenBus_ReadThreadProc, xpdd);
    1.59    if (!NT_SUCCESS(status))
    1.60 @@ -313,7 +313,6 @@ XenBus_Init(PXENPCI_DEVICE_DATA xpdd)
    1.61      KdPrint((__DRIVER_NAME "     Could not start read thread\n"));
    1.62      return status;
    1.63    }
    1.64 -  KdPrint((__DRIVER_NAME "    Started ReadThread\n"));
    1.65    
    1.66    status = ObReferenceObjectByHandle(thread_handle, THREAD_ALL_ACCESS, NULL, KernelMode, &xpdd->XenBus_ReadThread, NULL);
    1.67    ZwClose(thread_handle);
    1.68 @@ -329,7 +328,6 @@ XenBus_Init(PXENPCI_DEVICE_DATA xpdd)
    1.69      KdPrint((__DRIVER_NAME " Could not start watch thread\n"));
    1.70      return status;
    1.71    }
    1.72 -  KdPrint((__DRIVER_NAME "    Started WatchThread\n"));
    1.73    status = ObReferenceObjectByHandle(thread_handle, THREAD_ALL_ACCESS, NULL, KernelMode, &xpdd->XenBus_WatchThread, NULL);
    1.74    ZwClose(thread_handle);
    1.75    if (!NT_SUCCESS(status))
    1.76 @@ -475,7 +473,7 @@ XenBus_ReadThreadProc(PVOID StartContext
    1.77    for(;;)
    1.78    {
    1.79      KeWaitForSingleObject(&xpdd->XenBus_ReadThreadEvent, Executive, KernelMode, FALSE, NULL);
    1.80 -    //Print((__DRIVER_NAME " +++ thread woken\n"));
    1.81 +    //KdPrint((__DRIVER_NAME " +++ thread woken\n"));
    1.82      if (xpdd->XenBus_ShuttingDown)
    1.83      {
    1.84        KdPrint((__DRIVER_NAME "     Shutdown detected in ReadThreadProc\n"));
    1.85 @@ -483,7 +481,7 @@ XenBus_ReadThreadProc(PVOID StartContext
    1.86      }
    1.87      while (xpdd->xen_store_interface->rsp_prod != xpdd->xen_store_interface->rsp_cons)
    1.88      {
    1.89 -      //KdPrint((__DRIVER_NAME "     a - Rsp_cons %d, rsp_prod %d.\n", xen_store_interface->rsp_cons, xen_store_interface->rsp_prod));
    1.90 +      //KdPrint((__DRIVER_NAME "     a - Rsp_cons %d, rsp_prod %d.\n", xpdd->xen_store_interface->rsp_cons, xpdd->xen_store_interface->rsp_prod));
    1.91        if (xpdd->xen_store_interface->rsp_prod - xpdd->xen_store_interface->rsp_cons < sizeof(msg))
    1.92        {
    1.93          //KdPrint((__DRIVER_NAME " +++ Message incomplete (not even a full header)\n"));
    1.94 @@ -527,7 +525,7 @@ XenBus_ReadThreadProc(PVOID StartContext
    1.95          }
    1.96          else
    1.97          {
    1.98 -          //KdPrint((__DRIVER_NAME " +++ Queue full Path = %s Token = %s\n", path, token));
    1.99 +          KdPrint((__DRIVER_NAME " +++ Queue full Path = %s Token = %s\n", path, token));
   1.100            // drop the message on the floor
   1.101            continue;
   1.102          }
   1.103 @@ -559,6 +557,7 @@ XenBus_WatchThreadProc(PVOID StartContex
   1.104      }
   1.105      while (xpdd->XenBus_WatchRingReadIndex != xpdd->XenBus_WatchRingWriteIndex)
   1.106      {
   1.107 +      //KdPrint((__DRIVER_NAME " +++ watch triggered\n"));
   1.108        xpdd->XenBus_WatchRingReadIndex = 
   1.109          (xpdd->XenBus_WatchRingReadIndex + 1) % WATCH_RING_SIZE;
   1.110        index = atoi(xpdd->XenBus_WatchRing[xpdd->XenBus_WatchRingReadIndex].Token);
   1.111 @@ -639,12 +638,13 @@ XenBus_Resume(PXENPCI_DEVICE_DATA xpdd)
   1.112    {
   1.113      return status;
   1.114    }
   1.115 +  EvtChn_BindDpc(xpdd, xpdd->xen_store_evtchn, XenBus_Dpc, xpdd);
   1.116    
   1.117    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
   1.118    {
   1.119      if (xpdd->XenBus_WatchEntries[i].Active)
   1.120      {
   1.121 -      KdPrint((__DRIVER_NAME "     Adding watch for path = %s\n", xpdd->XenBus_WatchEntries[i].Path));
   1.122 +      //KdPrint((__DRIVER_NAME "     Adding watch for path = %s\n", xpdd->XenBus_WatchEntries[i].Path));
   1.123        XenBus_SendAddWatch(xpdd, XBT_NIL, xpdd->XenBus_WatchEntries[i].Path, i);
   1.124      }
   1.125    }