win-pvdrivers

changeset 474:3d4ed6b566a0

Updates to support XenBus interaction again in drivers
author James Harper <james.harper@bendigoit.com.au>
date Tue Dec 02 20:59:22 2008 +1100 (2008-12-02)
parents 3c592df57caf
children 525a6f4ca9a1
files common/include/xen_public.h xenpci/xenpci.h xenpci/xenpci_pdo.c
line diff
     1.1 --- a/common/include/xen_public.h	Tue Dec 02 20:58:26 2008 +1100
     1.2 +++ b/common/include/xen_public.h	Tue Dec 02 20:59:22 2008 +1100
     1.3 @@ -101,6 +101,16 @@ typedef NTSTATUS
     1.4  typedef NTSTATUS
     1.5  (*PXEN_XENPCI_XEN_SHUTDOWN_DEVICE)(PVOID Context);
     1.6  
     1.7 +#ifndef XENPCI_POOL_TAG
     1.8 +#define XENPCI_POOL_TAG (ULONG) 'XenP'
     1.9 +#endif
    1.10 +
    1.11 +static __inline VOID
    1.12 +XenPci_FreeMem(PVOID Ptr)
    1.13 +{
    1.14 +  ExFreePoolWithTag(Ptr, XENPCI_POOL_TAG);
    1.15 +}
    1.16 +
    1.17  #define XEN_DATA_MAGIC 0x12345678
    1.18  
    1.19  typedef struct {
    1.20 @@ -124,6 +134,18 @@ typedef struct {
    1.21    PXEN_XENPCI_XEN_CONFIG_DEVICE XenPci_XenConfigDevice;
    1.22    PXEN_XENPCI_XEN_SHUTDOWN_DEVICE XenPci_XenShutdownDevice;
    1.23  
    1.24 +  CHAR path[128];
    1.25 +  CHAR backend_path[128];
    1.26 +
    1.27 +  PXEN_XENBUS_READ XenBus_Read;
    1.28 +  PXEN_XENBUS_WRITE XenBus_Write;
    1.29 +  PXEN_XENBUS_PRINTF XenBus_Printf;
    1.30 +  PXEN_XENBUS_STARTTRANSACTION XenBus_StartTransaction;
    1.31 +  PXEN_XENBUS_ENDTRANSACTION XenBus_EndTransaction;
    1.32 +  PXEN_XENBUS_LIST XenBus_List;
    1.33 +  PXEN_XENBUS_ADDWATCH XenBus_AddWatch;
    1.34 +  PXEN_XENBUS_REMWATCH XenBus_RemWatch;
    1.35 +
    1.36  } XENPCI_VECTORS, *PXENPCI_VECTORS;
    1.37  
    1.38  #define RESUME_STATE_RUNNING            0
     2.1 --- a/xenpci/xenpci.h	Tue Dec 02 20:58:26 2008 +1100
     2.2 +++ b/xenpci/xenpci.h	Tue Dec 02 20:59:22 2008 +1100
     2.3 @@ -272,9 +272,6 @@ typedef struct {
     2.4    PUCHAR assigned_resources_ptr;
     2.5    XENPCI_DEVICE_STATE device_state;
     2.6    BOOLEAN restart_on_resume;
     2.7 -  PXEN_COMM_IFACE comm_iface;
     2.8 -  KSPIN_LOCK comm_iface_spinlock;
     2.9 -  USHORT req_cons;
    2.10  } XENPCI_PDO_DEVICE_DATA, *PXENPCI_PDO_DEVICE_DATA;
    2.11  
    2.12  typedef struct
    2.13 @@ -346,11 +343,13 @@ sw_interrupt(UCHAR intno)
    2.14  
    2.15  #define XBT_NIL ((xenbus_transaction_t)0)
    2.16  
    2.17 +#if 0
    2.18  static __inline VOID
    2.19  XenPci_FreeMem(PVOID Ptr)
    2.20  {
    2.21    ExFreePoolWithTag(Ptr, XENPCI_POOL_TAG);
    2.22  }
    2.23 +#endif
    2.24  
    2.25  NTSTATUS
    2.26  hvm_get_stubs(PXENPCI_DEVICE_DATA xpdd);
     3.1 --- a/xenpci/xenpci_pdo.c	Tue Dec 02 20:58:26 2008 +1100
     3.2 +++ b/xenpci/xenpci_pdo.c	Tue Dec 02 20:59:22 2008 +1100
     3.3 @@ -396,6 +396,88 @@ XenPci_GntTbl_GetRef(PVOID Context)
     3.4    return GntTbl_GetRef(xpdd);
     3.5  }
     3.6  
     3.7 +PCHAR
     3.8 +XenPci_XenBus_Read(PVOID Context, xenbus_transaction_t xbt, const char *path, char **value)
     3.9 +{
    3.10 +  PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.11 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.12 +  return XenBus_Read(xpdd, xbt, path, value);
    3.13 +}
    3.14 +
    3.15 +PCHAR
    3.16 +XenPci_XenBus_Write(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *value)
    3.17 +{
    3.18 +  PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.19 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.20 +  return XenBus_Write(xpdd, xbt, path, value);
    3.21 +}
    3.22 +
    3.23 +PCHAR
    3.24 +XenPci_XenBus_Printf(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *fmt, ...)
    3.25 +{
    3.26 +  //PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.27 +  //PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.28 +  //return XenBus_Printf(xpdd, xbt, path, value);
    3.29 +  UNREFERENCED_PARAMETER(Context);
    3.30 +  UNREFERENCED_PARAMETER(xbt);
    3.31 +  UNREFERENCED_PARAMETER(path);
    3.32 +  UNREFERENCED_PARAMETER(fmt);
    3.33 +  return NULL;
    3.34 +}
    3.35 +
    3.36 +PCHAR
    3.37 +XenPci_XenBus_StartTransaction(PVOID Context, xenbus_transaction_t *xbt)
    3.38 +{
    3.39 +  PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.40 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.41 +  return XenBus_StartTransaction(xpdd, xbt);
    3.42 +}
    3.43 +
    3.44 +PCHAR
    3.45 +XenPci_XenBus_EndTransaction(PVOID Context, xenbus_transaction_t xbt, int abort, int *retry)
    3.46 +{
    3.47 +  PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.48 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.49 +  return XenBus_EndTransaction(xpdd, xbt, abort, retry);
    3.50 +}
    3.51 +
    3.52 +PCHAR
    3.53 +XenPci_XenBus_List(PVOID Context, xenbus_transaction_t xbt, const char *prefix, char ***contents)
    3.54 +{
    3.55 +  PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.56 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.57 +  return XenBus_List(xpdd, xbt, prefix, contents);
    3.58 +}
    3.59 +
    3.60 +PCHAR
    3.61 +XenPci_XenBus_AddWatch(PVOID Context, xenbus_transaction_t xbt, const char *path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext)
    3.62 +{
    3.63 +  PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.64 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.65 +  PCHAR retval;
    3.66 +  
    3.67 +  FUNCTION_ENTER();
    3.68 +  retval = XenBus_AddWatch(xpdd, xbt, path, ServiceRoutine, ServiceContext);
    3.69 +  if (retval == NULL)
    3.70 +  {
    3.71 +    KdPrint((__DRIVER_NAME "     XenPci_XenBus_AddWatch - %s = NULL\n", path));
    3.72 +  }
    3.73 +  else
    3.74 +  {
    3.75 +    KdPrint((__DRIVER_NAME "     XenPci_XenBus_AddWatch - %s = %s\n", path, retval));
    3.76 +  }
    3.77 +  FUNCTION_EXIT();
    3.78 +  return retval;
    3.79 +}
    3.80 +
    3.81 +PCHAR
    3.82 +XenPci_XenBus_RemWatch(PVOID Context, xenbus_transaction_t xbt, const char *path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext)
    3.83 +{
    3.84 +  PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    3.85 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    3.86 +  return XenBus_RemWatch(xpdd, xbt, path, ServiceRoutine, ServiceContext);
    3.87 +}
    3.88 +
    3.89  static NTSTATUS
    3.90  XenPci_XenShutdownDevice(PVOID Context)
    3.91  {
    3.92 @@ -502,6 +584,17 @@ XenPci_XenConfigDeviceSpecifyBuffers(PVO
    3.93    vectors.GntTbl_EndAccess = XenPci_GntTbl_EndAccess;
    3.94    vectors.XenPci_XenConfigDevice = XenPci_XenConfigDevice;
    3.95    vectors.XenPci_XenShutdownDevice = XenPci_XenShutdownDevice;
    3.96 +  strncpy(vectors.path, xppdd->path, 128);
    3.97 +  strncpy(vectors.backend_path, xppdd->backend_path, 128);
    3.98 +  vectors.XenBus_Read = XenPci_XenBus_Read;
    3.99 +  vectors.XenBus_Write = XenPci_XenBus_Write;
   3.100 +  vectors.XenBus_Printf = XenPci_XenBus_Printf;
   3.101 +  vectors.XenBus_StartTransaction = XenPci_XenBus_StartTransaction;
   3.102 +  vectors.XenBus_EndTransaction = XenPci_XenBus_EndTransaction;
   3.103 +  vectors.XenBus_List = XenPci_XenBus_List;
   3.104 +  vectors.XenBus_AddWatch = XenPci_XenBus_AddWatch;
   3.105 +  vectors.XenBus_RemWatch = XenPci_XenBus_RemWatch;
   3.106 + 
   3.107    ADD_XEN_INIT_RSP(&out_ptr, XEN_INIT_TYPE_VECTORS, NULL, &vectors);
   3.108    ADD_XEN_INIT_RSP(&out_ptr, XEN_INIT_TYPE_STATE_PTR, NULL, &xppdd->device_state);
   3.109