win-pvdrivers

changeset 465:82dbbaac8d17

Config updates
author James Harper <james.harper@bendigoit.com.au>
date Thu Nov 27 09:28:57 2008 +1100 (2008-11-27)
parents 4f1c7b79948b
children 88cf95a1b34a
files common/include/xen_public.h
line diff
     1.1 --- a/common/include/xen_public.h	Thu Nov 27 09:28:00 2008 +1100
     1.2 +++ b/common/include/xen_public.h	Thu Nov 27 09:28:57 2008 +1100
     1.3 @@ -103,6 +103,147 @@ 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 @@ -120,8 +261,10 @@ typedef struct {
   1.152    PXEN_GNTTBL_PUTREF GntTbl_PutRef;
   1.153    PXEN_GNTTBL_GRANTACCESS GntTbl_GrantAccess;
   1.154    PXEN_GNTTBL_ENDACCESS GntTbl_EndAccess;
   1.155 +
   1.156    PXEN_XENPCI_XEN_CONFIG_DEVICE XenPci_XenConfigDevice;
   1.157    PXEN_XENPCI_XEN_SHUTDOWN_DEVICE XenPci_XenShutdownDevice;
   1.158 +
   1.159  } XENPCI_VECTORS, *PXENPCI_VECTORS;
   1.160  
   1.161  #define RESUME_STATE_RUNNING            0
   1.162 @@ -149,6 +292,7 @@ typedef struct {
   1.163  //#define XEN_INIT_TYPE_COPY_PTR          9
   1.164  #define XEN_INIT_TYPE_RUN               10
   1.165  #define XEN_INIT_TYPE_STATE_PTR         11
   1.166 +#define XEN_INIT_TYPE_COMM_IFACE        12
   1.167  
   1.168  static __inline VOID
   1.169  __ADD_XEN_INIT_UCHAR(PUCHAR *ptr, UCHAR val)
   1.170 @@ -250,6 +394,7 @@ ADD_XEN_INIT_REQ(PUCHAR *ptr, UCHAR type
   1.171    case XEN_INIT_TYPE_VECTORS:
   1.172    case XEN_INIT_TYPE_RUN:
   1.173    case XEN_INIT_TYPE_STATE_PTR:
   1.174 +  case XEN_INIT_TYPE_COMM_IFACE:
   1.175      break;
   1.176    case XEN_INIT_TYPE_WRITE_STRING:
   1.177      __ADD_XEN_INIT_STRING(ptr, p1);
   1.178 @@ -268,6 +413,7 @@ ADD_XEN_INIT_REQ(PUCHAR *ptr, UCHAR type
   1.179  //  case XEN_INIT_TYPE_COPY_PTR:
   1.180  //    __ADD_XEN_INIT_STRING(ptr, p1);
   1.181  //    __ADD_XEN_INIT_PTR(ptr, p2);
   1.182 +//    break;
   1.183    }
   1.184  }
   1.185  
   1.186 @@ -283,6 +429,7 @@ GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1,
   1.187    case XEN_INIT_TYPE_VECTORS:
   1.188    case XEN_INIT_TYPE_RUN:
   1.189    case XEN_INIT_TYPE_STATE_PTR:
   1.190 +  case XEN_INIT_TYPE_COMM_IFACE:
   1.191      *p1 = NULL;
   1.192      *p2 = NULL;
   1.193      break;
   1.194 @@ -304,6 +451,7 @@ GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1,
   1.195  //  case XEN_INIT_TYPE_COPY_PTR:
   1.196  //    *p1 = __GET_XEN_INIT_STRING(ptr);
   1.197  //    *p2 = __GET_XEN_INIT_PTR(ptr);
   1.198 +//    break;
   1.199    }
   1.200    return retval;
   1.201  }
   1.202 @@ -343,6 +491,7 @@ ADD_XEN_INIT_RSP(PUCHAR *ptr, UCHAR type
   1.203      *ptr += PtrToUlong(p1) * sizeof(grant_entry_t);
   1.204      break;
   1.205    case XEN_INIT_TYPE_STATE_PTR:
   1.206 +  case XEN_INIT_TYPE_COMM_IFACE:
   1.207      __ADD_XEN_INIT_PTR(ptr, p2);
   1.208      break;
   1.209  //  case XEN_INIT_TYPE_COPY_PTR:
   1.210 @@ -396,6 +545,7 @@ GET_XEN_INIT_RSP(PUCHAR *ptr, PVOID *p1,
   1.211      *ptr += PtrToUlong(*p1) * sizeof(grant_ref_t);
   1.212      break;
   1.213    case XEN_INIT_TYPE_STATE_PTR:
   1.214 +  case XEN_INIT_TYPE_COMM_IFACE:
   1.215      *p2 = __GET_XEN_INIT_PTR(ptr);
   1.216      break;
   1.217  //  case XEN_INIT_TYPE_COPY_PTR: