win-pvdrivers

changeset 470:bc403c97a002

Rolled back the whole comm_iface thing. It was a stupid idea.
author James Harper <james.harper@bendigoit.com.au>
date Thu Nov 27 21:15:09 2008 +1100 (2008-11-27)
parents fd203efae5ca
children babd1ef136ac
files common/include/xen_public.h xenpci/xenpci_pdo.c
line diff
     1.1 --- a/common/include/xen_public.h	Thu Nov 27 09:35:33 2008 +1100
     1.2 +++ b/common/include/xen_public.h	Thu Nov 27 21:15:09 2008 +1100
     1.3 @@ -103,147 +103,6 @@ typedef NTSTATUS
     1.4  
     1.5  #define XEN_DATA_MAGIC 0x12345678
     1.6  
     1.7 -#define COMM_IFACE_CMD_XENBUS_READ      0x01
     1.8 -#define COMM_IFACE_CMD_XENBUS_LIST      0x02
     1.9 -
    1.10 -#define COMM_IFACE_STATUS_SUCCESS	0x00
    1.11 -#define COMM_IFACE_STATUS_ERROR		0xFF
    1.12 -
    1.13 -#define COMM_IFACE_MAX_PACKET_SIZE	1024
    1.14 -
    1.15 -//#define __COMM_IFACE_RING_SIZE_BITS	9
    1.16 -//#define COMM_IFACE_RING_SIZE (1 << __COMM_IFACE_RING_SIZE_BITS)
    1.17 -
    1.18 -/*
    1.19 -This structure + fdo data must fit into one page
    1.20 -*/
    1.21 -typedef struct {
    1.22 -  ULONG magic;
    1.23 -  USHORT length;
    1.24 -  ULONG pdo_event_channel;
    1.25 -  ULONG fdo_event_channel;
    1.26 -  CHAR path[128];
    1.27 -  CHAR backend_path[128];
    1.28 -  USHORT req_prod;
    1.29 -  USHORT rsp_prod;
    1.30 -  USHORT packet_type;
    1.31 -  USHORT packet_status;
    1.32 -  union
    1.33 -  {
    1.34 -    struct {
    1.35 -      CHAR path[256];
    1.36 -    } read_req;
    1.37 -    struct {
    1.38 -      CHAR value[256];
    1.39 -    } read_rsp;
    1.40 -    struct {
    1.41 -      CHAR path[256];
    1.42 -    } list_req;
    1.43 -    struct {
    1.44 -      CHAR values[1024];
    1.45 -    } list_rsp;
    1.46 -  } packet;
    1.47 -#pragma warning(suppress : 4200)
    1.48 -  UCHAR fdo_data[0];
    1.49 -} XEN_COMM_IFACE, *PXEN_COMM_IFACE;
    1.50 -
    1.51 -typedef struct {
    1.52 -  USHORT length;
    1.53 -  UCHAR status;
    1.54 -  UCHAR type;
    1.55 -#pragma warning(suppress : 4200)
    1.56 -  UCHAR data[0];
    1.57 -} COMM_PACKET, *PCOMM_PACKET;
    1.58 -
    1.59 -#if 0
    1.60 -static VOID
    1.61 -XenPci_PutDataOnRing(PUCHAR start, ULONG prod, PUCHAR data, ULONG length)
    1.62 -{
    1.63 -  ULONG pos;
    1.64 -
    1.65 -  FUNCTION_ENTER();
    1.66 -  ASSERT(length <= COMM_IFACE_RING_SIZE);
    1.67 -  pos = prod & (COMM_IFACE_RING_SIZE - 1);
    1.68 -  KdPrint((__DRIVER_NAME "     pos = %d\n", pos));
    1.69 -  if (pos + length > COMM_IFACE_RING_SIZE)
    1.70 -  {
    1.71 -    memcpy(start + pos, data, COMM_IFACE_RING_SIZE - pos);
    1.72 -    memcpy(start, data, length + pos - COMM_IFACE_RING_SIZE);
    1.73 -  }
    1.74 -  else
    1.75 -  {
    1.76 -    KdPrint((__DRIVER_NAME "     memcpy(%p, %p, %d)\n", start + pos, data, length));
    1.77 -    memcpy(start + pos, data, length);
    1.78 -  }
    1.79 -  FUNCTION_EXIT();
    1.80 -}
    1.81 -
    1.82 -static VOID
    1.83 -XenPci_GetDataFromRing(PUCHAR start, ULONG cons, PUCHAR data, ULONG length)
    1.84 -{
    1.85 -  ULONG pos;
    1.86 -
    1.87 -  FUNCTION_ENTER();
    1.88 -
    1.89 -  ASSERT(length <= COMM_IFACE_RING_SIZE);
    1.90 -  pos = cons & (COMM_IFACE_RING_SIZE - 1);
    1.91 -  KdPrint((__DRIVER_NAME "     pos = %d\n", pos));
    1.92 -  if (pos + length > COMM_IFACE_RING_SIZE)
    1.93 -  {
    1.94 -    memcpy(data, start + pos, COMM_IFACE_RING_SIZE - pos);
    1.95 -    memcpy(data, start, length + pos - COMM_IFACE_RING_SIZE);
    1.96 -  }
    1.97 -  else
    1.98 -  {
    1.99 -    KdPrint((__DRIVER_NAME "     memcpy(%p, %p, %d)\n", data, start + pos, length));
   1.100 -    memcpy(data, start + pos, length);
   1.101 -  }
   1.102 -  FUNCTION_EXIT();
   1.103 -}
   1.104 -
   1.105 -static VOID
   1.106 -XenPci_PutReqOnCommRing(PXENPCI_COMM_IFACE comm_iface, PCOMM_PACKET packet)
   1.107 -{
   1.108 -  FUNCTION_ENTER();
   1.109 -  XenPci_PutDataOnRing(comm_iface->req_ring, comm_iface->req_prod, (PUCHAR)packet, packet->length);
   1.110 -  KeMemoryBarrier();
   1.111 -  comm_iface->req_prod += packet->length;
   1.112 -  FUNCTION_EXIT();
   1.113 -}
   1.114 -
   1.115 -static VOID
   1.116 -XenPci_GetReqFromCommRing(PXENPCI_COMM_IFACE comm_iface, PCOMM_PACKET packet)
   1.117 -{
   1.118 -  FUNCTION_ENTER();
   1.119 -  XenPci_GetDataFromRing(comm_iface->req_ring, comm_iface->req_cons, (PUCHAR)packet, FIELD_OFFSET(COMM_PACKET, data));
   1.120 -  XenPci_GetDataFromRing(comm_iface->req_ring, comm_iface->req_cons, (PUCHAR)packet, packet->length);
   1.121 -  KeMemoryBarrier();
   1.122 -  comm_iface->req_cons += packet->length;
   1.123 -  FUNCTION_EXIT();
   1.124 -}
   1.125 -
   1.126 -static VOID
   1.127 -XenPci_PutRspOnCommRing(PXENPCI_COMM_IFACE comm_iface, PCOMM_PACKET packet)
   1.128 -{
   1.129 -  FUNCTION_ENTER();
   1.130 -  XenPci_PutDataOnRing(comm_iface->rsp_ring, comm_iface->rsp_prod, (PUCHAR)packet, packet->length);
   1.131 -  KeMemoryBarrier();
   1.132 -  comm_iface->rsp_prod += packet->length;
   1.133 -  FUNCTION_EXIT();
   1.134 -}
   1.135 -
   1.136 -static VOID
   1.137 -XenPci_GetRspFromCommRing(PXENPCI_COMM_IFACE comm_iface, PCOMM_PACKET packet)
   1.138 -{
   1.139 -  FUNCTION_ENTER();
   1.140 -  XenPci_GetDataFromRing(comm_iface->rsp_ring, comm_iface->rsp_cons, (PUCHAR)packet, FIELD_OFFSET(COMM_PACKET, data));
   1.141 -  XenPci_GetDataFromRing(comm_iface->rsp_ring, comm_iface->rsp_cons, (PUCHAR)packet, packet->length);
   1.142 -  KeMemoryBarrier();
   1.143 -  comm_iface->rsp_cons += packet->length;
   1.144 -  FUNCTION_EXIT();
   1.145 -}
   1.146 -#endif
   1.147 -
   1.148  typedef struct {
   1.149    ULONG magic;
   1.150    USHORT length;
   1.151 @@ -292,7 +151,6 @@ typedef struct {
   1.152  //#define XEN_INIT_TYPE_COPY_PTR          9
   1.153  #define XEN_INIT_TYPE_RUN               10
   1.154  #define XEN_INIT_TYPE_STATE_PTR         11
   1.155 -#define XEN_INIT_TYPE_COMM_IFACE        12
   1.156  
   1.157  static __inline VOID
   1.158  __ADD_XEN_INIT_UCHAR(PUCHAR *ptr, UCHAR val)
   1.159 @@ -394,7 +252,6 @@ ADD_XEN_INIT_REQ(PUCHAR *ptr, UCHAR type
   1.160    case XEN_INIT_TYPE_VECTORS:
   1.161    case XEN_INIT_TYPE_RUN:
   1.162    case XEN_INIT_TYPE_STATE_PTR:
   1.163 -  case XEN_INIT_TYPE_COMM_IFACE:
   1.164      break;
   1.165    case XEN_INIT_TYPE_WRITE_STRING:
   1.166      __ADD_XEN_INIT_STRING(ptr, p1);
   1.167 @@ -429,7 +286,6 @@ GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1,
   1.168    case XEN_INIT_TYPE_VECTORS:
   1.169    case XEN_INIT_TYPE_RUN:
   1.170    case XEN_INIT_TYPE_STATE_PTR:
   1.171 -  case XEN_INIT_TYPE_COMM_IFACE:
   1.172      *p1 = NULL;
   1.173      *p2 = NULL;
   1.174      break;
   1.175 @@ -491,7 +347,6 @@ ADD_XEN_INIT_RSP(PUCHAR *ptr, UCHAR type
   1.176      *ptr += PtrToUlong(p1) * sizeof(grant_entry_t);
   1.177      break;
   1.178    case XEN_INIT_TYPE_STATE_PTR:
   1.179 -  case XEN_INIT_TYPE_COMM_IFACE:
   1.180      __ADD_XEN_INIT_PTR(ptr, p2);
   1.181      break;
   1.182  //  case XEN_INIT_TYPE_COPY_PTR:
   1.183 @@ -545,7 +400,6 @@ GET_XEN_INIT_RSP(PUCHAR *ptr, PVOID *p1,
   1.184      *ptr += PtrToUlong(*p1) * sizeof(grant_ref_t);
   1.185      break;
   1.186    case XEN_INIT_TYPE_STATE_PTR:
   1.187 -  case XEN_INIT_TYPE_COMM_IFACE:
   1.188      *p2 = __GET_XEN_INIT_PTR(ptr);
   1.189      break;
   1.190  //  case XEN_INIT_TYPE_COPY_PTR:
     2.1 --- a/xenpci/xenpci_pdo.c	Thu Nov 27 09:35:33 2008 +1100
     2.2 +++ b/xenpci/xenpci_pdo.c	Thu Nov 27 21:15:09 2008 +1100
     2.3 @@ -456,93 +456,6 @@ XenPci_XenShutdownDevice(PVOID Context)
     2.4    return STATUS_SUCCESS;
     2.5  }
     2.6  
     2.7 -static VOID
     2.8 -XenPci_Pdo_Comm_Iface_Worker(PDEVICE_OBJECT device_object, PVOID context)
     2.9 -{
    2.10 -  PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
    2.11 -  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    2.12 -  //char path[128];
    2.13 -  char *read_value;
    2.14 -  char **list_value;
    2.15 -  char *err;
    2.16 -  char *ptr;
    2.17 -  int i;
    2.18 -  
    2.19 -  UNREFERENCED_PARAMETER(context);
    2.20 -  
    2.21 -  FUNCTION_ENTER();
    2.22 -  
    2.23 -  switch(xppdd->comm_iface->packet_type)
    2.24 -  {
    2.25 -  case COMM_IFACE_CMD_XENBUS_READ:
    2.26 -    KdPrint((__DRIVER_NAME "     COMM_IFACE_CMD_XENBUS_READ\n"));
    2.27 -    err = XenBus_Read(xpdd, XBT_NIL, xppdd->comm_iface->packet.read_req.path, &read_value);
    2.28 -    if (err)
    2.29 -    {
    2.30 -        XenPci_FreeMem(err);
    2.31 -      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_ERROR;
    2.32 -    }
    2.33 -    else
    2.34 -    {
    2.35 -      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_SUCCESS;
    2.36 -      strcpy(xppdd->comm_iface->packet.read_rsp.value, read_value);
    2.37 -      XenPci_FreeMem(read_value);
    2.38 -    }
    2.39 -    break;
    2.40 -  case COMM_IFACE_CMD_XENBUS_LIST:
    2.41 -    KdPrint((__DRIVER_NAME "     COMM_IFACE_CMD_XENBUS_LIST\n"));
    2.42 -    err = XenBus_List(xpdd, XBT_NIL, xppdd->comm_iface->packet.read_req.path, &list_value);
    2.43 -    if (err)
    2.44 -    {
    2.45 -        XenPci_FreeMem(err);
    2.46 -      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_ERROR;
    2.47 -    }
    2.48 -    else
    2.49 -    {
    2.50 -      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_SUCCESS;
    2.51 -      for (ptr = xppdd->comm_iface->packet.list_rsp.values, i = 0; list_value[i]; i++)
    2.52 -      {
    2.53 -        strcpy(ptr, list_value[i]);
    2.54 -        ptr += strlen(list_value[i]) + 1;
    2.55 -        XenPci_FreeMem(list_value[i]);
    2.56 -      }
    2.57 -      strcpy(ptr, "");
    2.58 -      XenPci_FreeMem(list_value);
    2.59 -    }
    2.60 -    break;
    2.61 -  default:
    2.62 -    KdPrint((__DRIVER_NAME "     Unknown packet type = %d\n", xppdd->comm_iface->packet_type));
    2.63 -    break;
    2.64 -  }
    2.65 -  KeMemoryBarrier();
    2.66 -  xppdd->comm_iface->rsp_prod++;
    2.67 -  EvtChn_Notify(xpdd, xppdd->comm_iface->fdo_event_channel);
    2.68 -  FUNCTION_EXIT();
    2.69 -}
    2.70 -
    2.71 -static DDKAPI BOOLEAN
    2.72 -XenPci_Pdo_Dpc(PKINTERRUPT interrupt, PVOID context)
    2.73 -{
    2.74 -  PXENPCI_PDO_DEVICE_DATA xppdd = context;
    2.75 -  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    2.76 -  PIO_WORKITEM work_item;
    2.77 -  NTSTATUS status = STATUS_SUCCESS;
    2.78 -
    2.79 -  if (!xppdd->comm_iface)
    2.80 -    return FALSE;
    2.81 -  KeAcquireSpinLockAtDpcLevel(&xppdd->comm_iface_spinlock);
    2.82 -  if (xppdd->comm_iface->req_prod == xppdd->req_cons)
    2.83 -  {
    2.84 -    KeReleaseSpinLockFromDpcLevel(&xppdd->comm_iface_spinlock);
    2.85 -    return FALSE;
    2.86 -  }
    2.87 -  xppdd->req_cons = xppdd->comm_iface->req_prod;
    2.88 -  KeReleaseSpinLockFromDpcLevel(&xppdd->comm_iface_spinlock);
    2.89 -	work_item = IoAllocateWorkItem(xppdd->common.pdo);
    2.90 -	IoQueueWorkItem(work_item, XenPci_Pdo_Comm_Iface_Worker, DelayedWorkQueue, NULL);
    2.91 -  return TRUE;
    2.92 -}
    2.93 -
    2.94  static NTSTATUS
    2.95  XenPci_XenConfigDevice(PVOID context);
    2.96  
    2.97 @@ -726,19 +639,6 @@ XenPci_XenConfigDeviceSpecifyBuffers(PVO
    2.98          __ADD_XEN_INIT_ULONG(&xppdd->assigned_resources_ptr, gref);
    2.99        }
   2.100        break;
   2.101 -    case XEN_INIT_TYPE_COMM_IFACE:
   2.102 -      xppdd->comm_iface = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);
   2.103 -      xppdd->comm_iface->magic = XEN_DATA_MAGIC;
   2.104 -      xppdd->comm_iface->length = sizeof(XEN_COMM_IFACE);
   2.105 -      xppdd->comm_iface->pdo_event_channel = EvtChn_AllocIpi(xpdd, 0);
   2.106 -      EvtChn_BindDpc(xpdd, xppdd->comm_iface->pdo_event_channel, XenPci_Pdo_Dpc, xppdd);
   2.107 -      xppdd->comm_iface->fdo_event_channel = EvtChn_AllocIpi(xpdd, 0);
   2.108 -      EvtChn_BindIrq(xpdd, xppdd->comm_iface->fdo_event_channel, xppdd->irq_vector, path);
   2.109 -      strcpy(xppdd->comm_iface->path, xppdd->path);
   2.110 -      strcpy(xppdd->comm_iface->backend_path, xppdd->backend_path);
   2.111 -      xppdd->comm_iface->req_prod = 0;
   2.112 -      xppdd->comm_iface->rsp_prod = 0;
   2.113 -      ADD_XEN_INIT_RSP(&out_ptr, type, NULL, xppdd->comm_iface);
   2.114      }
   2.115    }
   2.116    ADD_XEN_INIT_RSP(&out_ptr, XEN_INIT_TYPE_END, NULL, NULL);