win-pvdrivers

changeset 15:7f0f866dced6

wean xenbus.c off of global variables

rename some variables from deviceData to xpdd for brevity
some whitespace fixes
author Andy Grover <andy@groveronline.com>
date Wed Nov 28 16:49:26 2007 -0800 (2007-11-28)
parents bde45c4eca0c
children 53fdfc9f5d56
files xenpci/xenbus.c xenpci/xenpci.h
line diff
     1.1 --- a/xenpci/xenbus.c	Wed Nov 28 14:51:20 2007 -0800
     1.2 +++ b/xenpci/xenbus.c	Wed Nov 28 16:49:26 2007 -0800
     1.3 @@ -24,66 +24,22 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  #pragma warning( disable : 4204 ) 
     1.5  #pragma warning( disable : 4221 ) 
     1.6  
     1.7 -struct xenbus_req_info
     1.8 -{
     1.9 -  int In_Use:1;
    1.10 -  KEVENT WaitEvent;
    1.11 -  void *Reply;
    1.12 +struct write_req {
    1.13 +    const void *data;
    1.14 +    unsigned len;
    1.15  };
    1.16  
    1.17 -typedef struct _XENBUS_WATCH_ENTRY {
    1.18 -  char Path[128];
    1.19 -  PXENBUS_WATCH_CALLBACK ServiceRoutine;
    1.20 -  PVOID ServiceContext;
    1.21 -  int Count;
    1.22 -  int Active;
    1.23 -} XENBUS_WATCH_ENTRY, *PXENBUS_WATCH_ENTRY;
    1.24 -
    1.25 -typedef struct _XENBUS_WATCH_RING
    1.26 -{
    1.27 -  char Path[128];
    1.28 -  char Token[10];
    1.29 -} XENBUS_WATCH_RING;
    1.30 -
    1.31 -#define WATCH_RING_SIZE 128
    1.32 -
    1.33 -static XENBUS_WATCH_RING XenBus_WatchRing[WATCH_RING_SIZE];
    1.34 -static int XenBus_WatchRingReadIndex;
    1.35 -static int XenBus_WatchRingWriteIndex;
    1.36 -
    1.37 -#define MAX_WATCH_ENTRIES 128
    1.38 -
    1.39 -static XENBUS_WATCH_ENTRY XenBus_WatchEntries[MAX_WATCH_ENTRIES];
    1.40 -
    1.41 -#define NR_REQS 32
    1.42 -//#define XENSTORE_RING_SIZE 1024
    1.43 -
    1.44 -//#define XENSTORE_RING_SIZE 1024
    1.45 -//typedef uint32_t XENSTORE_RING_IDX;
    1.46 -//#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
    1.47 -
    1.48 -static struct xenstore_domain_interface *xen_store_interface;
    1.49 -
    1.50 -static struct xenbus_req_info req_info[NR_REQS];
    1.51 -static int nr_live_reqs;
    1.52 -//static spinlock_t req_lock = SPIN_LOCK_UNLOCKED;
    1.53 -
    1.54 -static HANDLE XenBus_ReadThreadHandle;
    1.55 -static KEVENT XenBus_ReadThreadEvent;
    1.56 -
    1.57 -static HANDLE XenBus_WatchThreadHandle;
    1.58 -static KEVENT XenBus_WatchThreadEvent;
    1.59 -
    1.60  static void
    1.61  XenBus_ReadThreadProc(PVOID StartContext);
    1.62  static void
    1.63  XenBus_WatchThreadProc(PVOID StartContext);
    1.64 -
    1.65  static BOOLEAN
    1.66  XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext);
    1.67  
    1.68 -static int allocate_xenbus_id(void)
    1.69 +static int allocate_xenbus_id(WDFDEVICE Device)
    1.70  {
    1.71 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);  
    1.72 +
    1.73    static int probe;
    1.74    int o_probe;
    1.75  
    1.76 @@ -92,7 +48,7 @@ static int allocate_xenbus_id(void)
    1.77    for (;;)
    1.78    {
    1.79  //    spin_lock(&req_lock);
    1.80 -    if (nr_live_reqs < NR_REQS)
    1.81 +    if (xpdd->nr_live_reqs < NR_XB_REQS)
    1.82        break;
    1.83  //    spin_unlock(&req_lock);
    1.84  //    wait_event(req_wq, (nr_live_reqs < NR_REQS));
    1.85 @@ -102,30 +58,32 @@ static int allocate_xenbus_id(void)
    1.86  
    1.87    for (;;)
    1.88    {
    1.89 -    if (!req_info[o_probe].In_Use)
    1.90 +    if (!xpdd->req_info[o_probe].In_Use)
    1.91        break;
    1.92 -    o_probe = (o_probe + 1) % NR_REQS;
    1.93 +    o_probe = (o_probe + 1) % NR_XB_REQS;
    1.94  //    BUG_ON(o_probe == probe);
    1.95    }
    1.96 -  nr_live_reqs++;
    1.97 -  req_info[o_probe].In_Use = 1;
    1.98 -  probe = (o_probe + 1) % NR_REQS;
    1.99 +  xpdd->nr_live_reqs++;
   1.100 +  xpdd->req_info[o_probe].In_Use = 1;
   1.101 +  probe = (o_probe + 1) % NR_XB_REQS;
   1.102    //spin_unlock(&req_lock);
   1.103    //init_waitqueue_head(&req_info[o_probe].waitq);
   1.104 -  KeInitializeEvent(&req_info[o_probe].WaitEvent, SynchronizationEvent, FALSE);
   1.105 +  KeInitializeEvent(&xpdd->req_info[o_probe].WaitEvent, SynchronizationEvent, FALSE);
   1.106  
   1.107    //KdPrint((__DRIVER_NAME " <-- allocate_xenbus_id\n"));
   1.108  
   1.109    return o_probe;
   1.110  }
   1.111  
   1.112 -static void release_xenbus_id(int id)
   1.113 +static void release_xenbus_id(WDFDEVICE Device, int id)
   1.114  {
   1.115 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);  
   1.116 +
   1.117  //    BUG_ON(!req_info[id].in_use);
   1.118  //    spin_lock(&req_lock);
   1.119 -    req_info[id].In_Use = 0;
   1.120 -    nr_live_reqs--;
   1.121 -    req_info[id].In_Use = 0;
   1.122 +    xpdd->req_info[id].In_Use = 0;
   1.123 +    xpdd->nr_live_reqs--;
   1.124 +    xpdd->req_info[id].In_Use = 0;
   1.125  //    if (nr_live_reqs == NR_REQS - 1)
   1.126  //        wake_up(&req_wq);
   1.127  //    spin_unlock(&req_lock);
   1.128 @@ -134,6 +92,7 @@ static void release_xenbus_id(int id)
   1.129  static char *errmsg(struct xsd_sockmsg *rep)
   1.130  {
   1.131    char *res;
   1.132 +
   1.133    if (!rep) {
   1.134      char msg[] = "No reply";
   1.135      size_t len = strlen(msg) + 1;
   1.136 @@ -162,21 +121,7 @@ static void memcpy_from_ring(const void 
   1.137    memcpy(dest + c1, ring, c2);
   1.138  }
   1.139  
   1.140 -void wait_for_watch(void)
   1.141 -{
   1.142 -//    DEFINE_WAIT(w);
   1.143 -//    add_waiter(w,watch_queue);
   1.144 -//    schedule();
   1.145 -//    remove_waiter(w);
   1.146 -//    wake(current);
   1.147 -}
   1.148 -
   1.149 -struct write_req {
   1.150 -    const void *data;
   1.151 -    unsigned len;
   1.152 -};
   1.153 -
   1.154 -static void xb_write (
   1.155 +static void xb_write(
   1.156    WDFDEVICE Device,
   1.157    int type,
   1.158    int req_id,
   1.159 @@ -184,7 +129,7 @@ static void xb_write (
   1.160    const struct write_req *req,
   1.161    int nr_reqs)
   1.162  {
   1.163 -  PXENPCI_DEVICE_DATA deviceData = GetDeviceData(Device);
   1.164 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.165    XENSTORE_RING_IDX prod;
   1.166    int r;
   1.167    size_t len = 0;
   1.168 @@ -207,17 +152,17 @@ static void xb_write (
   1.169  //  BUG_ON(len > XENSTORE_RING_SIZE);
   1.170    /* Wait for the ring to drain to the point where we can send the
   1.171       message. */
   1.172 -  prod = xen_store_interface->req_prod;
   1.173 +  prod = xpdd->xen_store_interface->req_prod;
   1.174  
   1.175    //KdPrint((__DRIVER_NAME " prod = %08x\n", prod));
   1.176  
   1.177 -  if (prod + len - xen_store_interface->req_cons > XENSTORE_RING_SIZE)
   1.178 +  if (prod + len - xpdd->xen_store_interface->req_cons > XENSTORE_RING_SIZE)
   1.179    {
   1.180      /* Wait for there to be space on the ring */
   1.181      //KdPrint((__DRIVER_NAME " prod %d, len %d, cons %d, size %d; waiting.\n", prod, len, xen_store_interface->req_cons, XENSTORE_RING_SIZE));
   1.182  //    wait_event(xb_waitq, xen_store_interface->req_prod + len - xen_store_interface->req_cons <= XENSTORE_RING_SIZE);
   1.183      //KdPrint((__DRIVER_NAME " Back from wait.\n"));
   1.184 -    prod = xen_store_interface->req_prod;
   1.185 +    prod = xpdd->xen_store_interface->req_prod;
   1.186    }
   1.187  
   1.188    /* We're now guaranteed to be able to send the message without
   1.189 @@ -229,7 +174,7 @@ static void xb_write (
   1.190    while (total_off < len)
   1.191    {
   1.192      this_chunk = min(cur_req->len - req_off,XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(prod));
   1.193 -    memcpy((char *)xen_store_interface->req + MASK_XENSTORE_IDX(prod), (char *)cur_req->data + req_off, this_chunk);
   1.194 +    memcpy((char *)xpdd->xen_store_interface->req + MASK_XENSTORE_IDX(prod), (char *)cur_req->data + req_off, this_chunk);
   1.195      prod += this_chunk;
   1.196      req_off += this_chunk;
   1.197      total_off += this_chunk;
   1.198 @@ -253,12 +198,12 @@ static void xb_write (
   1.199    //_WriteBarrier();
   1.200    KeMemoryBarrier();
   1.201  
   1.202 -  xen_store_interface->req_prod += len;
   1.203 +  xpdd->xen_store_interface->req_prod += len;
   1.204  
   1.205    //KdPrint((__DRIVER_NAME " prod = %08x\n", xen_store_interface->req_prod));
   1.206  
   1.207    /* Send evtchn to notify remote */
   1.208 -  EvtChn_Notify(Device, deviceData->xen_store_evtchn);
   1.209 +  EvtChn_Notify(Device, xpdd->xen_store_evtchn);
   1.210  
   1.211    //KdPrint((__DRIVER_NAME " <-- xb_write\n"));
   1.212  }
   1.213 @@ -271,13 +216,14 @@ xenbus_msg_reply(
   1.214    struct write_req *io,
   1.215    int nr_reqs)
   1.216  {
   1.217 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.218    int id;
   1.219  //  DEFINE_WAIT(w);
   1.220    struct xsd_sockmsg *rep;
   1.221  
   1.222    KdPrint((__DRIVER_NAME " --> xenbus_msg_reply\n"));
   1.223  
   1.224 -  id = allocate_xenbus_id();
   1.225 +  id = allocate_xenbus_id(Device);
   1.226  //  add_waiter(w, req_info[id].waitq);
   1.227  
   1.228    xb_write(Device, type, id, trans, io, nr_reqs);
   1.229 @@ -288,19 +234,19 @@ xenbus_msg_reply(
   1.230  //
   1.231    KdPrint((__DRIVER_NAME "     starting wait\n"));
   1.232  
   1.233 -  KeWaitForSingleObject(&req_info[id].WaitEvent, Executive, KernelMode, FALSE, NULL);
   1.234 +  KeWaitForSingleObject(&xpdd->req_info[id].WaitEvent, Executive, KernelMode, FALSE, NULL);
   1.235  
   1.236    //KdPrint((__DRIVER_NAME "     wait complete\n"));
   1.237  
   1.238 -  rep = req_info[id].Reply;
   1.239 +  rep = xpdd->req_info[id].Reply;
   1.240  //  BUG_ON(rep->req_id != id);
   1.241 -  release_xenbus_id(id);
   1.242 +  release_xenbus_id(Device, id);
   1.243    KdPrint((__DRIVER_NAME " <-- xenbus_msg_reply\n"));
   1.244    return rep;
   1.245  }
   1.246  
   1.247  char *
   1.248 -XenBus_Read (
   1.249 +XenBus_Read(
   1.250    PVOID Context,
   1.251    xenbus_transaction_t xbt,
   1.252    const char *path,
   1.253 @@ -349,43 +295,20 @@ XenBus_Write(
   1.254    return NULL;
   1.255  }
   1.256  
   1.257 -char* xenbus_wait_for_value(const char* path,const char* value)
   1.258 -{
   1.259 -  UNREFERENCED_PARAMETER(path);
   1.260 -  UNREFERENCED_PARAMETER(value);
   1.261 -//  for(;;)
   1.262 -//  {
   1.263 -//    char *res, *msg;
   1.264 -//    int r;
   1.265 -//
   1.266 -//    msg = xenbus_read(XBT_NIL, path, &res);
   1.267 -//    if(msg) return msg;
   1.268 -//
   1.269 -//    r = strcmp(value,res);
   1.270 -//    ExFreePoolWithTag(res, XENPCI_POOL_TAG);
   1.271 -//
   1.272 -//    if(r==0)
   1.273 -//      break;
   1.274 -//    else
   1.275 -//      wait_for_watch();
   1.276 -//    }
   1.277 -    return NULL;
   1.278 -}
   1.279 -
   1.280  NTSTATUS
   1.281  XenBus_Init(WDFDEVICE Device)
   1.282  {
   1.283 -  PXENPCI_DEVICE_DATA deviceData = GetDeviceData(Device);  
   1.284 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);  
   1.285    //KdPrint((__DRIVER_NAME " --> XenBus_Init\n"));
   1.286  
   1.287 -  deviceData->xen_store_evtchn = EvtChn_GetXenStorePort(Device);
   1.288 -  xen_store_interface = EvtChn_GetXenStoreRingAddr(Device);
   1.289 +  xpdd->xen_store_evtchn = EvtChn_GetXenStorePort(Device);
   1.290 +  xpdd->xen_store_interface = EvtChn_GetXenStoreRingAddr(Device);
   1.291  
   1.292    //KdPrint((__DRIVER_NAME "     xen_store_evtchn = %08x\n", xen_store_evtchn));
   1.293    //KdPrint((__DRIVER_NAME "     xen_store_interface = %08x\n", xen_store_interface));
   1.294  
   1.295 -  KeInitializeEvent(&XenBus_ReadThreadEvent, SynchronizationEvent, FALSE);
   1.296 -  KeInitializeEvent(&XenBus_WatchThreadEvent, SynchronizationEvent, FALSE);
   1.297 +  KeInitializeEvent(&xpdd->XenBus_ReadThreadEvent, SynchronizationEvent, FALSE);
   1.298 +  KeInitializeEvent(&xpdd->XenBus_WatchThreadEvent, SynchronizationEvent, FALSE);
   1.299  
   1.300    //KdPrint((__DRIVER_NAME " <-- XenBus_Init\n"));
   1.301  
   1.302 @@ -395,7 +318,7 @@ XenBus_Init(WDFDEVICE Device)
   1.303  NTSTATUS
   1.304  XenBus_Start(WDFDEVICE Device)
   1.305  {
   1.306 -  PXENPCI_DEVICE_DATA deviceData = GetDeviceData(Device);
   1.307 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.308    OBJECT_ATTRIBUTES oa;
   1.309    NTSTATUS status;
   1.310    int i;
   1.311 @@ -403,17 +326,19 @@ XenBus_Start(WDFDEVICE Device)
   1.312    KdPrint((__DRIVER_NAME " --> XenBus_Start\n"));
   1.313  
   1.314    InitializeObjectAttributes(&oa, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
   1.315 -  status = PsCreateSystemThread(&XenBus_ReadThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenBus_ReadThreadProc, NULL);
   1.316 +  status = PsCreateSystemThread(&xpdd->XenBus_ReadThreadHandle, THREAD_ALL_ACCESS,
   1.317 +    &oa, NULL, NULL, XenBus_ReadThreadProc, Device);
   1.318  
   1.319    // remove all existing watches already in Xen too...
   1.320  
   1.321    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
   1.322 -    XenBus_WatchEntries[i].Active = 0;
   1.323 +    xpdd->XenBus_WatchEntries[i].Active = 0;
   1.324  
   1.325    InitializeObjectAttributes(&oa, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
   1.326 -  status = PsCreateSystemThread(&XenBus_WatchThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenBus_WatchThreadProc, NULL);
   1.327 +  status = PsCreateSystemThread(&xpdd->XenBus_WatchThreadHandle, THREAD_ALL_ACCESS,
   1.328 +    &oa, NULL, NULL, XenBus_WatchThreadProc, Device);
   1.329  
   1.330 -  EvtChn_Bind(Device, deviceData->xen_store_evtchn, XenBus_Interrupt, NULL);
   1.331 +  EvtChn_Bind(Device, xpdd->xen_store_evtchn, XenBus_Interrupt, Device);
   1.332  
   1.333    KdPrint((__DRIVER_NAME " <-- XenBus_Start\n"));
   1.334  
   1.335 @@ -423,21 +348,24 @@ XenBus_Start(WDFDEVICE Device)
   1.336  NTSTATUS
   1.337  XenBus_Stop(WDFDEVICE Device)
   1.338  {
   1.339 -  PXENPCI_DEVICE_DATA deviceData = GetDeviceData(Device);
   1.340 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.341    int i;
   1.342  
   1.343    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
   1.344    {
   1.345 -    if (!XenBus_WatchEntries[i].Active)
   1.346 +    if (!xpdd->XenBus_WatchEntries[i].Active)
   1.347        continue;
   1.348 -    XenBus_RemWatch(Device, XBT_NIL, XenBus_WatchEntries[i].Path, XenBus_WatchEntries[i].ServiceRoutine, XenBus_WatchEntries[i].ServiceContext);
   1.349 +    XenBus_RemWatch(Device, XBT_NIL,
   1.350 +      xpdd->XenBus_WatchEntries[i].Path,
   1.351 +      xpdd->XenBus_WatchEntries[i].ServiceRoutine,
   1.352 +      xpdd->XenBus_WatchEntries[i].ServiceContext);
   1.353    }
   1.354  
   1.355 -  EvtChn_Unbind(Device, deviceData->xen_store_evtchn);
   1.356 +  EvtChn_Unbind(Device, xpdd->xen_store_evtchn);
   1.357  
   1.358    // Does this actually stop the threads???
   1.359 -  ZwClose(XenBus_WatchThreadHandle);
   1.360 -  ZwClose(XenBus_ReadThreadHandle);
   1.361 +  ZwClose(xpdd->XenBus_WatchThreadHandle);
   1.362 +  ZwClose(xpdd->XenBus_ReadThreadHandle);
   1.363  
   1.364    return STATUS_SUCCESS;
   1.365  }
   1.366 @@ -460,16 +388,21 @@ XenBus_List(
   1.367  
   1.368    repmsg = xenbus_msg_reply(Device, XS_DIRECTORY, xbt, req, ARRAY_SIZE(req));
   1.369    msg = errmsg(repmsg);
   1.370 -  if (msg) {
   1.371 +  if (msg)
   1.372 +  {
   1.373      *contents = NULL;
   1.374      //KdPrint((__DRIVER_NAME " <-- xenbus_ls (error)\n"));
   1.375      return msg;
   1.376    }
   1.377    reply = repmsg + 1;
   1.378    for (x = nr_elems = 0; x < repmsg->len; x++)
   1.379 +  {
   1.380      nr_elems += (((char *)reply)[x] == 0);
   1.381 -  res = ExAllocatePoolWithTag(NonPagedPool, sizeof(res[0]) * (nr_elems + 1), XENPCI_POOL_TAG);
   1.382 -  for (x = i = 0; i < nr_elems; i++) {
   1.383 +  }
   1.384 +  res = ExAllocatePoolWithTag(NonPagedPool, sizeof(res[0]) * (nr_elems + 1),
   1.385 +    XENPCI_POOL_TAG);
   1.386 +  for (x = i = 0; i < nr_elems; i++)
   1.387 +  {
   1.388      int l = strlen((char *)reply + x);
   1.389      res[i] = ExAllocatePoolWithTag(NonPagedPool, l + 1, XENPCI_POOL_TAG);
   1.390      memcpy(res[i], (char *)reply + x, l + 1);
   1.391 @@ -482,61 +415,33 @@ XenBus_List(
   1.392    return NULL;
   1.393  }
   1.394  
   1.395 -#if 0 // test code
   1.396 -void
   1.397 -do_ls_test(const char *pre)
   1.398 +static void
   1.399 +XenBus_ReadThreadProc(PVOID StartContext)
   1.400  {
   1.401 -  char **dirs;
   1.402 -  int x;
   1.403 -  char *msg;
   1.404 -
   1.405 -  //KdPrint((__DRIVER_NAME " <-- do_ls_test(\"%s\")\n", pre));
   1.406 -
   1.407 -  msg = XenBus_List(XBT_NIL, pre, &dirs);
   1.408 -  if (msg)
   1.409 -  {
   1.410 -    //KdPrint((__DRIVER_NAME "     Error in xenbus ls: %s\n", msg));
   1.411 -    ExFreePoolWithTag(msg, XENPCI_POOL_TAG);
   1.412 -    return;
   1.413 -  }
   1.414 -  for (x = 0; dirs[x]; x++)
   1.415 -  {
   1.416 -    //KdPrint((__DRIVER_NAME "     ls %s[%d] -> %s\n", pre, x, dirs[x]));
   1.417 -    ExFreePoolWithTag(dirs[x], XENPCI_POOL_TAG);
   1.418 -  }
   1.419 -  ExFreePoolWithTag(dirs, XENPCI_POOL_TAG);
   1.420 -  //KdPrint((__DRIVER_NAME " --> do_ls_test\n"));
   1.421 -}
   1.422 -#endif
   1.423 -
   1.424 -int ReadThreadSetCount;
   1.425 -int ReadThreadWaitCount;
   1.426 -
   1.427 -static void
   1.428 -XenBus_ReadThreadProc(PVOID StartContext) {
   1.429    int NewWriteIndex;
   1.430    struct xsd_sockmsg msg;
   1.431    char *payload;
   1.432    char *path, *token;
   1.433 -
   1.434 -  UNREFERENCED_PARAMETER(StartContext);
   1.435 +  WDFDEVICE Device = StartContext;
   1.436 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.437  
   1.438    for(;;)
   1.439    {
   1.440 -    KeWaitForSingleObject(&XenBus_ReadThreadEvent, Executive, KernelMode, FALSE, NULL);
   1.441 +    KeWaitForSingleObject(&xpdd->XenBus_ReadThreadEvent, Executive, KernelMode, FALSE, NULL);
   1.442      //KdPrint((__DRIVER_NAME "     ReadThread Woken (Count = %d)\n", ReadThreadWaitCount++));
   1.443 -    while (xen_store_interface->rsp_prod != xen_store_interface->rsp_cons)
   1.444 +    while (xpdd->xen_store_interface->rsp_prod != xpdd->xen_store_interface->rsp_cons)
   1.445      {
   1.446        //KdPrint((__DRIVER_NAME "     a - Rsp_cons %d, rsp_prod %d.\n", xen_store_interface->rsp_cons, xen_store_interface->rsp_prod));
   1.447 -      if (xen_store_interface->rsp_prod - xen_store_interface->rsp_cons < sizeof(msg))
   1.448 +      if (xpdd->xen_store_interface->rsp_prod - xpdd->xen_store_interface->rsp_cons < sizeof(msg))
   1.449        {
   1.450          //KdPrint((__DRIVER_NAME " +++ Message incomplete (not even a full header)\n"));
   1.451          break;
   1.452        }
   1.453        //_ReadBarrier();
   1.454        KeMemoryBarrier();
   1.455 -      memcpy_from_ring(xen_store_interface->rsp, &msg, MASK_XENSTORE_IDX(xen_store_interface->rsp_cons), sizeof(msg));
   1.456 -      if (xen_store_interface->rsp_prod - xen_store_interface->rsp_cons < sizeof(msg) + msg.len)
   1.457 +      memcpy_from_ring(xpdd->xen_store_interface->rsp, &msg,
   1.458 +        MASK_XENSTORE_IDX(xpdd->xen_store_interface->rsp_cons), sizeof(msg));
   1.459 +      if (xpdd->xen_store_interface->rsp_prod - xpdd->xen_store_interface->rsp_cons < sizeof(msg) + msg.len)
   1.460        {
   1.461          //KdPrint((__DRIVER_NAME " +++ Message incomplete (header but not full body)\n"));
   1.462          break;
   1.463 @@ -546,20 +451,21 @@ XenBus_ReadThreadProc(PVOID StartContext
   1.464        {
   1.465          payload = ExAllocatePoolWithTag(NonPagedPool, sizeof(msg) + msg.len, XENPCI_POOL_TAG);
   1.466    
   1.467 -        memcpy_from_ring(xen_store_interface->rsp, payload, MASK_XENSTORE_IDX(xen_store_interface->rsp_cons), msg.len + sizeof(msg));
   1.468 +        memcpy_from_ring(xpdd->xen_store_interface->rsp, payload,
   1.469 +          MASK_XENSTORE_IDX(xpdd->xen_store_interface->rsp_cons), msg.len + sizeof(msg));
   1.470    
   1.471 -        xen_store_interface->rsp_cons += msg.len + sizeof(msg);
   1.472 +        xpdd->xen_store_interface->rsp_cons += msg.len + sizeof(msg);
   1.473          //KdPrint((__DRIVER_NAME "     b - Rsp_cons %d, rsp_prod %d.\n", xen_store_interface->rsp_cons, xen_store_interface->rsp_prod));
   1.474    
   1.475          path = payload + sizeof(msg);
   1.476          token = path + strlen(path) + 1;
   1.477  
   1.478 -        NewWriteIndex = (XenBus_WatchRingWriteIndex + 1) & 127;
   1.479 -        if (NewWriteIndex != XenBus_WatchRingReadIndex)
   1.480 +        NewWriteIndex = (xpdd->XenBus_WatchRingWriteIndex + 1) & 127;
   1.481 +        if (NewWriteIndex != xpdd->XenBus_WatchRingReadIndex)
   1.482          {
   1.483 -          strncpy(XenBus_WatchRing[NewWriteIndex].Path, path, 128);
   1.484 -          strncpy(XenBus_WatchRing[NewWriteIndex].Token, token, 10);
   1.485 -          XenBus_WatchRingWriteIndex = NewWriteIndex;
   1.486 +          strncpy(xpdd->XenBus_WatchRing[NewWriteIndex].Path, path, 128);
   1.487 +          strncpy(xpdd->XenBus_WatchRing[NewWriteIndex].Token, token, 10);
   1.488 +          xpdd->XenBus_WatchRingWriteIndex = NewWriteIndex;
   1.489          }
   1.490          else
   1.491          {
   1.492 @@ -570,16 +476,19 @@ XenBus_ReadThreadProc(PVOID StartContext
   1.493  
   1.494          ExFreePoolWithTag(payload, XENPCI_POOL_TAG);
   1.495          //KdPrint((__DRIVER_NAME " +++ Watch Path = %s Token = %s\n", path, token));
   1.496 -        KeSetEvent(&XenBus_WatchThreadEvent, 1, FALSE);
   1.497 +        KeSetEvent(&xpdd->XenBus_WatchThreadEvent, 1, FALSE);
   1.498        }
   1.499        else
   1.500        {  
   1.501 -        req_info[msg.req_id].Reply = ExAllocatePoolWithTag(NonPagedPool, sizeof(msg) + msg.len, XENPCI_POOL_TAG);
   1.502 -        memcpy_from_ring(xen_store_interface->rsp, req_info[msg.req_id].Reply, MASK_XENSTORE_IDX(xen_store_interface->rsp_cons), msg.len + sizeof(msg));
   1.503 -        xen_store_interface->rsp_cons += msg.len + sizeof(msg);
   1.504 +        xpdd->req_info[msg.req_id].Reply = ExAllocatePoolWithTag(NonPagedPool, sizeof(msg) + msg.len, XENPCI_POOL_TAG);
   1.505 +        memcpy_from_ring(xpdd->xen_store_interface->rsp,
   1.506 +          xpdd->req_info[msg.req_id].Reply,
   1.507 +          MASK_XENSTORE_IDX(xpdd->xen_store_interface->rsp_cons),
   1.508 +          msg.len + sizeof(msg));
   1.509 +        xpdd->xen_store_interface->rsp_cons += msg.len + sizeof(msg);
   1.510          //KdPrint((__DRIVER_NAME "     c - Rsp_cons %d, rsp_prod %d.\n", xen_store_interface->rsp_cons, xen_store_interface->rsp_prod));
   1.511          //KdPrint((__DRIVER_NAME " +++ Message = %s\n", ((char *)req_info[msg.req_id].Reply) + sizeof(msg)));
   1.512 -        KeSetEvent(&req_info[msg.req_id].WaitEvent, 1, FALSE);
   1.513 +        KeSetEvent(&xpdd->req_info[msg.req_id].WaitEvent, 1, FALSE);
   1.514        }
   1.515      }
   1.516    }
   1.517 @@ -590,39 +499,45 @@ XenBus_WatchThreadProc(PVOID StartContex
   1.518  {
   1.519    int index;
   1.520    PXENBUS_WATCH_ENTRY entry;
   1.521 -
   1.522 -  UNREFERENCED_PARAMETER(StartContext);
   1.523 +  WDFDEVICE Device = StartContext;
   1.524 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.525  
   1.526    for(;;)
   1.527    {
   1.528 -    KeWaitForSingleObject(&XenBus_WatchThreadEvent, Executive, KernelMode, FALSE, NULL);
   1.529 -    while (XenBus_WatchRingReadIndex != XenBus_WatchRingWriteIndex)
   1.530 +    KeWaitForSingleObject(&xpdd->XenBus_WatchThreadEvent, Executive,
   1.531 +      KernelMode, FALSE, NULL);
   1.532 +    while (xpdd->XenBus_WatchRingReadIndex != xpdd->XenBus_WatchRingWriteIndex)
   1.533      {
   1.534 -      XenBus_WatchRingReadIndex = (XenBus_WatchRingReadIndex + 1) & 127;
   1.535 -      index = atoi(XenBus_WatchRing[XenBus_WatchRingReadIndex].Token);
   1.536 +      xpdd->XenBus_WatchRingReadIndex = 
   1.537 +        (xpdd->XenBus_WatchRingReadIndex + 1) % WATCH_RING_SIZE;
   1.538 +      index = atoi(xpdd->XenBus_WatchRing[xpdd->XenBus_WatchRingReadIndex].Token);
   1.539        //XenBus_WatchRing[XenBus_WatchRingReadIndex].Path
   1.540        //XenBus_WatchRing[XenBus_WatchRingReadIndex].Token
   1.541  
   1.542 -      entry = &XenBus_WatchEntries[index];
   1.543 +      entry = &xpdd->XenBus_WatchEntries[index];
   1.544        if (!entry->Active)
   1.545        {
   1.546 -        KdPrint((__DRIVER_NAME " +++ Watch not active! = %s Token = %s\n", XenBus_WatchRing[XenBus_WatchRingReadIndex].Path, XenBus_WatchRing[XenBus_WatchRingReadIndex].Token));
   1.547 +        KdPrint((__DRIVER_NAME " +++ Watch not active! = %s Token = %s\n",
   1.548 +        xpdd->XenBus_WatchRing[xpdd->XenBus_WatchRingReadIndex].Path,
   1.549 +        xpdd->XenBus_WatchRing[xpdd->XenBus_WatchRingReadIndex].Token));
   1.550          continue;
   1.551        }
   1.552        entry->Count++;
   1.553        if (!entry->ServiceRoutine)
   1.554        {
   1.555 -        KdPrint((__DRIVER_NAME " +++ no handler for watch! = %s Token = %s\n", XenBus_WatchRing[XenBus_WatchRingReadIndex].Path, XenBus_WatchRing[XenBus_WatchRingReadIndex].Token));
   1.556 +        KdPrint((__DRIVER_NAME " +++ no handler for watch! = %s Token = %s\n",
   1.557 +          xpdd->XenBus_WatchRing[xpdd->XenBus_WatchRingReadIndex].Path,
   1.558 +          xpdd->XenBus_WatchRing[xpdd->XenBus_WatchRingReadIndex].Token));
   1.559          continue;
   1.560        }
   1.561        //KdPrint((__DRIVER_NAME " +++ Watch Triggered Path = %s Token = %d (%s)\n", XenBus_WatchRing[XenBus_WatchRingReadIndex].Path, index, XenBus_WatchRing[XenBus_WatchRingReadIndex].Token));
   1.562 -      entry->ServiceRoutine(XenBus_WatchRing[XenBus_WatchRingReadIndex].Path, entry->ServiceContext);
   1.563 +      entry->ServiceRoutine(xpdd->XenBus_WatchRing[xpdd->XenBus_WatchRingReadIndex].Path, entry->ServiceContext);
   1.564      }
   1.565    }
   1.566  }    
   1.567  
   1.568  char *
   1.569 -XenBus_AddWatch (
   1.570 +XenBus_AddWatch(
   1.571    PVOID Context,
   1.572    xenbus_transaction_t xbt,
   1.573    const char *Path,
   1.574 @@ -630,6 +545,7 @@ XenBus_AddWatch (
   1.575    PVOID ServiceContext)
   1.576  {
   1.577    WDFDEVICE Device = Context;
   1.578 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.579    struct xsd_sockmsg *rep;
   1.580    char *msg;
   1.581    int i;
   1.582 @@ -641,7 +557,7 @@ XenBus_AddWatch (
   1.583    // check that Path < 128 chars
   1.584  
   1.585    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
   1.586 -    if (XenBus_WatchEntries[i].Active == 0)
   1.587 +    if (xpdd->XenBus_WatchEntries[i].Active == 0)
   1.588        break;
   1.589    
   1.590    if (i == MAX_WATCH_ENTRIES)
   1.591 @@ -665,11 +581,11 @@ XenBus_AddWatch (
   1.592  
   1.593    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
   1.594  
   1.595 -  strncpy(XenBus_WatchEntries[i].Path, Path, 128);
   1.596 -  XenBus_WatchEntries[i].ServiceRoutine = ServiceRoutine;
   1.597 -  XenBus_WatchEntries[i].ServiceContext = ServiceContext;
   1.598 -  XenBus_WatchEntries[i].Count = 0;
   1.599 -  XenBus_WatchEntries[i].Active = 1;
   1.600 +  strncpy(xpdd->XenBus_WatchEntries[i].Path, Path, 128);
   1.601 +  xpdd->XenBus_WatchEntries[i].ServiceRoutine = ServiceRoutine;
   1.602 +  xpdd->XenBus_WatchEntries[i].ServiceContext = ServiceContext;
   1.603 +  xpdd->XenBus_WatchEntries[i].Count = 0;
   1.604 +  xpdd->XenBus_WatchEntries[i].Active = 1;
   1.605  
   1.606    KdPrint((__DRIVER_NAME " <-- XenBus_AddWatch\n"));
   1.607  
   1.608 @@ -685,6 +601,7 @@ XenBus_RemWatch(
   1.609    PVOID ServiceContext)
   1.610  {
   1.611    WDFDEVICE Device = Context;
   1.612 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.613    struct xsd_sockmsg *rep;
   1.614    char *msg;
   1.615    int i;
   1.616 @@ -696,7 +613,10 @@ XenBus_RemWatch(
   1.617    // check that Path < 128 chars
   1.618  
   1.619    for (i = 0; i < MAX_WATCH_ENTRIES; i++) {
   1.620 -    if (XenBus_WatchEntries[i].Active == 1 && strcmp(XenBus_WatchEntries[i].Path, Path) == 0 && XenBus_WatchEntries[i].ServiceRoutine == ServiceRoutine && XenBus_WatchEntries[i].ServiceContext == ServiceContext)
   1.621 +    if (xpdd->XenBus_WatchEntries[i].Active == 1
   1.622 +      && strcmp(xpdd->XenBus_WatchEntries[i].Path, Path) == 0
   1.623 +      && xpdd->XenBus_WatchEntries[i].ServiceRoutine == ServiceRoutine
   1.624 +      && xpdd->XenBus_WatchEntries[i].ServiceContext == ServiceContext)
   1.625        break;
   1.626    }
   1.627  
   1.628 @@ -721,7 +641,7 @@ XenBus_RemWatch(
   1.629  
   1.630    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
   1.631  
   1.632 -  XenBus_WatchEntries[i].Active = 0;
   1.633 +  xpdd->XenBus_WatchEntries[i].Active = 0;
   1.634  
   1.635    //KdPrint((__DRIVER_NAME " <-- XenBus_RemWatch\n"));
   1.636  
   1.637 @@ -750,7 +670,11 @@ XenBus_StartTransaction(PVOID Context, x
   1.638  }
   1.639  
   1.640  char *
   1.641 -XenBus_EndTransaction(PVOID Context, xenbus_transaction_t t, int abort, int *retry)
   1.642 +XenBus_EndTransaction(
   1.643 +  PVOID Context,
   1.644 +  xenbus_transaction_t t,
   1.645 +  int abort,
   1.646 +  int *retry)
   1.647  {
   1.648    WDFDEVICE Device = Context;
   1.649    struct xsd_sockmsg *rep;
   1.650 @@ -775,39 +699,18 @@ XenBus_EndTransaction(PVOID Context, xen
   1.651    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
   1.652    return NULL;
   1.653  }
   1.654 -/*
   1.655 -void
   1.656 -XenBus_ThreadProc(PVOID StartContext)
   1.657 -{
   1.658 -  char *response;
   1.659 -
   1.660 -  //KdPrint((__DRIVER_NAME " --> XenBus_ThreadProc\n"));
   1.661 -
   1.662 -  //do_ls_test("device");
   1.663 -
   1.664 -//  do_ls_test("local");
   1.665 -
   1.666 -//  do_ls_test("control");
   1.667 -
   1.668 -//  do_ls_test(".");
   1.669 -
   1.670 -  response = XenBus_AddWatch(XBT_NIL, SHUTDOWN_PATH, XenBus_ShutdownHandler, NULL);
   1.671 -
   1.672 -  //KdPrint((__DRIVER_NAME " <-- watch response = '%s'\n", response)); 
   1.673 -
   1.674 -  //KdPrint((__DRIVER_NAME " <-- XenBus_ThreadProc\n"));
   1.675 -}
   1.676 -*/
   1.677  
   1.678  static BOOLEAN
   1.679  XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext)
   1.680  {
   1.681 +  WDFDEVICE Device = ServiceContext;
   1.682 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   1.683 +
   1.684    UNREFERENCED_PARAMETER(Interrupt);
   1.685 -  UNREFERENCED_PARAMETER(ServiceContext);
   1.686  
   1.687    //KdPrint((__DRIVER_NAME " --> XenBus_Interrupt (Count = %d)\n", ReadThreadSetCount++));
   1.688  
   1.689 -  KeSetEvent(&XenBus_ReadThreadEvent, 1, FALSE);
   1.690 +  KeSetEvent(&xpdd->XenBus_ReadThreadEvent, 1, FALSE);
   1.691  
   1.692    //KdPrint((__DRIVER_NAME " <-- XenBus_Interrupt\n"));
   1.693  
   1.694 @@ -815,7 +718,12 @@ XenBus_Interrupt(PKINTERRUPT Interrupt, 
   1.695  }
   1.696  
   1.697  char *
   1.698 -XenBus_Printf(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *fmt, ...)
   1.699 +XenBus_Printf(
   1.700 +  PVOID Context,
   1.701 +  xenbus_transaction_t xbt,
   1.702 +  const char *path,
   1.703 +  const char *fmt,
   1.704 +  ...)
   1.705  {
   1.706    WDFDEVICE Device = Context;
   1.707    va_list ap;
     2.1 --- a/xenpci/xenpci.h	Wed Nov 28 14:51:20 2007 -0800
     2.2 +++ b/xenpci/xenpci.h	Wed Nov 28 16:49:26 2007 -0800
     2.3 @@ -34,38 +34,17 @@ Foundation, Inc., 51 Franklin Street, Fi
     2.4  #include <ntstrsafe.h>
     2.5  
     2.6  #include <xen_windows.h>
     2.7 -/*
     2.8 -#define __XEN_INTERFACE_VERSION__ 0x00030205
     2.9 -#define __i386__
    2.10 -typedef signed char int8_t;
    2.11 -typedef unsigned char uint8_t;
    2.12 -typedef SHORT int16_t;
    2.13 -typedef USHORT uint16_t;
    2.14 -typedef LONG int32_t;
    2.15 -typedef ULONG uint32_t;
    2.16 -typedef ULONGLONG uint64_t;
    2.17 -typedef unsigned long pgentry_t;
    2.18 -
    2.19 -#define _PAGE_PRESENT  0x001UL
    2.20 -#define _PAGE_RW       0x002UL
    2.21 -#define _PAGE_USER     0x004UL
    2.22 -#define _PAGE_PWT      0x008UL
    2.23 -#define _PAGE_PCD      0x010UL
    2.24 -#define _PAGE_ACCESSED 0x020UL
    2.25 -#define _PAGE_DIRTY    0x040UL
    2.26 -#define _PAGE_PAT      0x080UL
    2.27 -#define _PAGE_PSE      0x080UL
    2.28 -#define _PAGE_GLOBAL   0x100UL
    2.29 -
    2.30 -#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
    2.31 -*/
    2.32 -
    2.33  #include <memory.h>
    2.34  #include <grant_table.h>
    2.35  #include <event_channel.h>
    2.36  #include <hvm/params.h>
    2.37  #include <hvm/hvm_op.h>
    2.38  
    2.39 +#include <evtchn_public.h>
    2.40 +#include <xenbus_public.h>
    2.41 +#include <xen_public.h>
    2.42 +#include <gnttbl_public.h>
    2.43 +
    2.44  //{C828ABE9-14CA-4445-BAA6-82C2376C6518}
    2.45  DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
    2.46  
    2.47 @@ -93,8 +72,33 @@ typedef struct _ev_action_t {
    2.48    ULONG Count;
    2.49  } ev_action_t;
    2.50  
    2.51 +typedef struct _XENBUS_WATCH_RING
    2.52 +{
    2.53 +  char Path[128];
    2.54 +  char Token[10];
    2.55 +} XENBUS_WATCH_RING;
    2.56 +
    2.57 +typedef struct _XENBUS_REQ_INFO
    2.58 +{
    2.59 +  int In_Use:1;
    2.60 +  KEVENT WaitEvent;
    2.61 +  void *Reply;
    2.62 +} XENBUS_REQ_INFO;
    2.63 +
    2.64 +typedef struct _XENBUS_WATCH_ENTRY {
    2.65 +  char Path[128];
    2.66 +  PXENBUS_WATCH_CALLBACK ServiceRoutine;
    2.67 +  PVOID ServiceContext;
    2.68 +  int Count;
    2.69 +  int Active;
    2.70 +} XENBUS_WATCH_ENTRY, *PXENBUS_WATCH_ENTRY;
    2.71 +
    2.72  #define NR_EVENTS 1024
    2.73 +#define WATCH_RING_SIZE 128
    2.74 +#define NR_XB_REQS 32
    2.75 +#define MAX_WATCH_ENTRIES 128
    2.76  
    2.77 +// TODO: tidy up & organize this struct
    2.78  typedef struct {
    2.79  
    2.80    WDFDEVICE Device;
    2.81 @@ -120,35 +124,30 @@ typedef struct {
    2.82    ev_action_t ev_actions[NR_EVENTS];
    2.83    unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
    2.84  
    2.85 +  HANDLE XenBus_ReadThreadHandle;
    2.86 +  KEVENT XenBus_ReadThreadEvent;
    2.87 +  HANDLE XenBus_WatchThreadHandle;
    2.88 +  KEVENT XenBus_WatchThreadEvent;
    2.89 +
    2.90 +  XENBUS_WATCH_RING XenBus_WatchRing[WATCH_RING_SIZE];
    2.91 +  int XenBus_WatchRingReadIndex;
    2.92 +  int XenBus_WatchRingWriteIndex;
    2.93 +
    2.94 +  struct xenstore_domain_interface *xen_store_interface;
    2.95 +
    2.96 +  XENBUS_REQ_INFO req_info[NR_XB_REQS];
    2.97 +  int nr_live_reqs;
    2.98 +  XENBUS_WATCH_ENTRY XenBus_WatchEntries[MAX_WATCH_ENTRIES];
    2.99 +
   2.100  } XENPCI_DEVICE_DATA, *PXENPCI_DEVICE_DATA;
   2.101  
   2.102  WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetDeviceData);
   2.103  
   2.104 -VOID
   2.105 -GntTbl_Init();
   2.106 -
   2.107 -
   2.108 -
   2.109  typedef unsigned long xenbus_transaction_t;
   2.110  typedef uint32_t XENSTORE_RING_IDX;
   2.111  
   2.112 -//struct __xsd_sockmsg
   2.113 -//{
   2.114 -//    uint32_t type;  /* XS_??? */
   2.115 -//    uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
   2.116 -//    uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
   2.117 -//    uint32_t len;   /* Length of data following this. */
   2.118 -//
   2.119 -//    /* Generally followed by nul-terminated string(s). */
   2.120 -//};
   2.121 -
   2.122  #define XBT_NIL ((xenbus_transaction_t)0)
   2.123  
   2.124 -#include <evtchn_public.h>
   2.125 -#include <xenbus_public.h>
   2.126 -#include <xen_public.h>
   2.127 -#include <gnttbl_public.h>
   2.128 -
   2.129  char *
   2.130  XenBus_Read(PVOID Context, xenbus_transaction_t xbt, const char *path, char **value);
   2.131  char *
   2.132 @@ -162,33 +161,23 @@ XenBus_EndTransaction(PVOID Context, xen
   2.133  char *
   2.134  XenBus_List(PVOID Context, xenbus_transaction_t xbt, const char *prefix, char ***contents);
   2.135  NTSTATUS
   2.136 -XenBus_Init();
   2.137 -NTSTATUS
   2.138 -XenBus_Start();
   2.139 +XenBus_Init(WDFDEVICE Device);
   2.140  NTSTATUS
   2.141 -XenBus_Stop();
   2.142 -
   2.143 -//typedef VOID
   2.144 -//(*PXENBUS_WATCH_CALLBACK)(char *Path, PVOID ServiceContext);
   2.145 -
   2.146 +XenBus_Start(WDFDEVICE Device);
   2.147 +NTSTATUS
   2.148 +XenBus_Stop(WDFDEVICE Device);
   2.149  char *
   2.150  XenBus_AddWatch(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   2.151  char *
   2.152  XenBus_RemWatch(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
   2.153 -
   2.154 -
   2.155  VOID
   2.156  XenBus_ThreadProc(PVOID StartContext);
   2.157  
   2.158  PHYSICAL_ADDRESS
   2.159  XenPCI_AllocMMIO(WDFDEVICE Device, ULONG len);
   2.160  
   2.161 -//PVOID
   2.162 -//map_frames(PULONG f, ULONG n);
   2.163 -
   2.164 -
   2.165 -extern shared_info_t *shared_info_area;
   2.166 -
   2.167 +NTSTATUS
   2.168 +EvtChn_Init(WDFDEVICE Device);
   2.169  BOOLEAN
   2.170  EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID);
   2.171  BOOLEAN
   2.172 @@ -205,17 +194,16 @@ NTSTATUS
   2.173  EvtChn_Notify(PVOID Context, evtchn_port_t Port);
   2.174  evtchn_port_t
   2.175  EvtChn_AllocUnbound(PVOID Context, domid_t Domain);
   2.176 -NTSTATUS
   2.177 -EvtChn_Init(WDFDEVICE Device);
   2.178 +evtchn_port_t
   2.179 +EvtChn_GetXenStorePort(WDFDEVICE Device);
   2.180 +PVOID
   2.181 +EvtChn_GetXenStoreRingAddr(WDFDEVICE Device);
   2.182  
   2.183 +VOID
   2.184 +GntTbl_Init(WDFDEVICE Device);
   2.185  grant_ref_t
   2.186  GntTbl_GrantAccess(WDFDEVICE Device, domid_t domid, unsigned long frame, int readonly);
   2.187  BOOLEAN
   2.188  GntTbl_EndAccess(WDFDEVICE Device, grant_ref_t ref);
   2.189  
   2.190 -evtchn_port_t
   2.191 -EvtChn_GetXenStorePort(WDFDEVICE Device);
   2.192 -PVOID
   2.193 -EvtChn_GetXenStoreRingAddr(WDFDEVICE Device);
   2.194 -
   2.195  #endif