win-pvdrivers

diff xenpci/xenbus.c @ 279:685399b9adb0

Converted the suspend code to WDM. Still far from working properly but it's a starting point.
author James Harper <james.harper@bendigoit.com.au>
date Fri May 23 23:53:02 2008 +1000 (2008-05-23)
parents 909b775a891f
children 3c65d6c6453f
line diff
     1.1 --- a/xenpci/xenbus.c	Fri May 23 22:59:10 2008 +1000
     1.2 +++ b/xenpci/xenbus.c	Fri May 23 23:53:02 2008 +1000
     1.3 @@ -565,6 +565,44 @@ KdPrint((__DRIVER_NAME " --- for %s\n", 
     1.4    }
     1.5  }    
     1.6  
     1.7 +static char *
     1.8 +XenBus_SendAddWatch(
     1.9 +  PVOID Context,
    1.10 +  xenbus_transaction_t xbt,
    1.11 +  const char *Path,
    1.12 +  int slot)
    1.13 +{
    1.14 +  PXENPCI_DEVICE_DATA xpdd = Context;
    1.15 +  struct xsd_sockmsg *rep;
    1.16 +  char *msg;
    1.17 +  char Token[20];
    1.18 +  struct write_req req[2];
    1.19 +
    1.20 +  req[0].data = Path;
    1.21 +  req[0].len = (ULONG)strlen(Path) + 1;
    1.22 +
    1.23 +  RtlStringCbPrintfA(Token, ARRAY_SIZE(Token), "%d", slot);
    1.24 +  req[1].data = Token;
    1.25 +  req[1].len = (ULONG)strlen(Token) + 1;
    1.26 +
    1.27 +  rep = xenbus_msg_reply(xpdd, XS_WATCH, xbt, req, ARRAY_SIZE(req));
    1.28 +  msg = errmsg(rep);
    1.29 +
    1.30 +  ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
    1.31 +
    1.32 +  return msg;
    1.33 +}
    1.34 +
    1.35 +VOID
    1.36 +XenBus_Resume(PXENPCI_DEVICE_DATA xpdd)
    1.37 +{
    1.38 +  int i;
    1.39 +  
    1.40 +  for (i = 0; i < MAX_WATCH_ENTRIES; i++)
    1.41 +    if (xpdd->XenBus_WatchEntries[i].Active)
    1.42 +      XenBus_SendAddWatch(xpdd, XBT_NIL, xpdd->XenBus_WatchEntries[i].Path, i);
    1.43 +}
    1.44 +
    1.45  char *
    1.46  XenBus_AddWatch(
    1.47    PVOID Context,
    1.48 @@ -574,11 +612,8 @@ XenBus_AddWatch(
    1.49    PVOID ServiceContext)
    1.50  {
    1.51    PXENPCI_DEVICE_DATA xpdd = Context;
    1.52 -  struct xsd_sockmsg *rep;
    1.53    char *msg;
    1.54    int i;
    1.55 -  char Token[20];
    1.56 -  struct write_req req[2];
    1.57    PXENBUS_WATCH_ENTRY w_entry;
    1.58    KIRQL OldIrql;
    1.59  
    1.60 @@ -612,23 +647,14 @@ XenBus_AddWatch(
    1.61  
    1.62    KeReleaseSpinLock(&xpdd->WatchLock, OldIrql);
    1.63  
    1.64 -  req[0].data = Path;
    1.65 -  req[0].len = (ULONG)strlen(Path) + 1;
    1.66 +  msg = XenBus_SendAddWatch(xpdd, xbt, Path, i);
    1.67  
    1.68 -  RtlStringCbPrintfA(Token, ARRAY_SIZE(Token), "%d", i);
    1.69 -  req[1].data = Token;
    1.70 -  req[1].len = (ULONG)strlen(Token) + 1;
    1.71 -
    1.72 -  rep = xenbus_msg_reply(xpdd, XS_WATCH, xbt, req, ARRAY_SIZE(req));
    1.73 -
    1.74 -  msg = errmsg(rep);
    1.75    if (msg)
    1.76    {
    1.77      xpdd->XenBus_WatchEntries[i].Active = 0;
    1.78      KdPrint((__DRIVER_NAME " <-- XenBus_AddWatch (%s)\n", msg));
    1.79      return msg;
    1.80    }
    1.81 -  ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
    1.82  
    1.83    KdPrint((__DRIVER_NAME " <-- XenBus_AddWatch\n"));
    1.84