win-pvdrivers

changeset 464:4f1c7b79948b

Updates to support a different configuration method for xenscsi
author James Harper <james.harper@bendigoit.com.au>
date Thu Nov 27 09:28:00 2008 +1100 (2008-11-27)
parents 7f9bedb7dcf9
children 82dbbaac8d17
files xenpci/evtchn.c xenpci/xenbus.c xenpci/xenpci.h xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/evtchn.c	Sun Nov 23 14:58:25 2008 +1100
     1.2 +++ b/xenpci/evtchn.c	Thu Nov 27 09:28:00 2008 +1100
     1.3 @@ -303,7 +303,7 @@ EvtChn_Notify(PVOID Context, evtchn_port
     1.4  }
     1.5  
     1.6  evtchn_port_t
     1.7 -EvtChn_BindIpi(PVOID context, ULONG vcpu)
     1.8 +EvtChn_AllocIpi(PVOID context, ULONG vcpu)
     1.9  {
    1.10    PXENPCI_DEVICE_DATA xpdd = context;
    1.11    evtchn_bind_ipi_t op;
    1.12 @@ -372,7 +372,7 @@ EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
    1.13    xpdd->interrupts_masked = FALSE;
    1.14    KeMemoryBarrier();
    1.15  
    1.16 -  xpdd->suspend_evtchn = EvtChn_BindIpi(xpdd, 0);
    1.17 +  xpdd->suspend_evtchn = EvtChn_AllocIpi(xpdd, 0);
    1.18    xpdd->ev_actions[xpdd->suspend_evtchn].type = EVT_ACTION_TYPE_SUSPEND;
    1.19    EvtChn_Unmask(xpdd, xpdd->suspend_evtchn);
    1.20    
     2.1 --- a/xenpci/xenbus.c	Sun Nov 23 14:58:25 2008 +1100
     2.2 +++ b/xenpci/xenbus.c	Thu Nov 27 09:28:00 2008 +1100
     2.3 @@ -34,7 +34,7 @@ XenBus_ReadThreadProc(PVOID StartContext
     2.4  static DDKAPI void
     2.5  XenBus_WatchThreadProc(PVOID StartContext);
     2.6  static DDKAPI BOOLEAN
     2.7 -XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext);
     2.8 +XenBus_Dpc(PKINTERRUPT Interrupt, PVOID ServiceContext);
     2.9  
    2.10  /* called with xenbus_mutex held */
    2.11  static int allocate_xenbus_id(PXENPCI_DEVICE_DATA xpdd)
    2.12 @@ -311,7 +311,7 @@ XenBus_Connect(PXENPCI_DEVICE_DATA xpdd)
    2.13    pa_xen_store_interface.QuadPart = (ULONGLONG)xen_store_mfn << PAGE_SHIFT;
    2.14    xpdd->xen_store_interface = MmMapIoSpace(pa_xen_store_interface, PAGE_SIZE, MmNonCached);
    2.15  
    2.16 -  EvtChn_BindDpc(xpdd, xpdd->xen_store_evtchn, XenBus_Interrupt, xpdd);
    2.17 +  EvtChn_BindDpc(xpdd, xpdd->xen_store_evtchn, XenBus_Dpc, xpdd);
    2.18  
    2.19    xpdd->XenBus_ShuttingDown = FALSE;
    2.20    KeMemoryBarrier();
    2.21 @@ -915,7 +915,7 @@ XenBus_EndTransaction(
    2.22  }
    2.23  
    2.24  static DDKAPI BOOLEAN
    2.25 -XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext)
    2.26 +XenBus_Dpc(PKINTERRUPT Interrupt, PVOID ServiceContext)
    2.27  {
    2.28    PXENPCI_DEVICE_DATA xpdd = ServiceContext;
    2.29  
     3.1 --- a/xenpci/xenpci.h	Sun Nov 23 14:58:25 2008 +1100
     3.2 +++ b/xenpci/xenpci.h	Thu Nov 27 09:28:00 2008 +1100
     3.3 @@ -272,6 +272,9 @@ typedef struct {
     3.4    PUCHAR assigned_resources_ptr;
     3.5    XENPCI_DEVICE_STATE device_state;
     3.6    BOOLEAN restart_on_resume;
     3.7 +  PXEN_COMM_IFACE comm_iface;
     3.8 +  KSPIN_LOCK comm_iface_spinlock;
     3.9 +  USHORT req_cons;
    3.10  } XENPCI_PDO_DEVICE_DATA, *PXENPCI_PDO_DEVICE_DATA;
    3.11  
    3.12  typedef struct
    3.13 @@ -450,7 +453,7 @@ EvtChn_BindDpc(PVOID Context, evtchn_por
    3.14  NTSTATUS
    3.15  EvtChn_BindIrq(PVOID Context, evtchn_port_t Port, ULONG vector, PCHAR description);
    3.16  evtchn_port_t
    3.17 -EvtChn_BindIpi(PVOID context, ULONG vcpu);
    3.18 +EvtChn_AllocIpi(PVOID context, ULONG vcpu);
    3.19  NTSTATUS
    3.20  EvtChn_Unbind(PVOID Context, evtchn_port_t Port);
    3.21  NTSTATUS
     4.1 --- a/xenpci/xenpci_pdo.c	Sun Nov 23 14:58:25 2008 +1100
     4.2 +++ b/xenpci/xenpci_pdo.c	Thu Nov 27 09:28:00 2008 +1100
     4.3 @@ -452,6 +452,93 @@ XenPci_XenShutdownDevice(PVOID Context)
     4.4    return STATUS_SUCCESS;
     4.5  }
     4.6  
     4.7 +static VOID
     4.8 +XenPci_Pdo_Comm_Iface_Worker(PDEVICE_OBJECT device_object, PVOID context)
     4.9 +{
    4.10 +  PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
    4.11 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    4.12 +  //char path[128];
    4.13 +  char *read_value;
    4.14 +  char **list_value;
    4.15 +  char *err;
    4.16 +  char *ptr;
    4.17 +  int i;
    4.18 +  
    4.19 +  UNREFERENCED_PARAMETER(context);
    4.20 +  
    4.21 +  FUNCTION_ENTER();
    4.22 +  
    4.23 +  switch(xppdd->comm_iface->packet_type)
    4.24 +  {
    4.25 +  case COMM_IFACE_CMD_XENBUS_READ:
    4.26 +    KdPrint((__DRIVER_NAME "     COMM_IFACE_CMD_XENBUS_READ\n"));
    4.27 +    err = XenBus_Read(xpdd, XBT_NIL, xppdd->comm_iface->packet.read_req.path, &read_value);
    4.28 +    if (err)
    4.29 +    {
    4.30 +        XenPci_FreeMem(err);
    4.31 +      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_ERROR;
    4.32 +    }
    4.33 +    else
    4.34 +    {
    4.35 +      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_SUCCESS;
    4.36 +      strcpy(xppdd->comm_iface->packet.read_rsp.value, read_value);
    4.37 +      XenPci_FreeMem(read_value);
    4.38 +    }
    4.39 +    break;
    4.40 +  case COMM_IFACE_CMD_XENBUS_LIST:
    4.41 +    KdPrint((__DRIVER_NAME "     COMM_IFACE_CMD_XENBUS_LIST\n"));
    4.42 +    err = XenBus_List(xpdd, XBT_NIL, xppdd->comm_iface->packet.read_req.path, &list_value);
    4.43 +    if (err)
    4.44 +    {
    4.45 +        XenPci_FreeMem(err);
    4.46 +      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_ERROR;
    4.47 +    }
    4.48 +    else
    4.49 +    {
    4.50 +      xppdd->comm_iface->packet_status = COMM_IFACE_STATUS_SUCCESS;
    4.51 +      for (ptr = xppdd->comm_iface->packet.list_rsp.values, i = 0; list_value[i]; i++)
    4.52 +      {
    4.53 +        strcpy(ptr, list_value[i]);
    4.54 +        ptr += strlen(list_value[i]) + 1;
    4.55 +        XenPci_FreeMem(list_value[i]);
    4.56 +      }
    4.57 +      strcpy(ptr, "");
    4.58 +      XenPci_FreeMem(list_value);
    4.59 +    }
    4.60 +    break;
    4.61 +  default:
    4.62 +    KdPrint((__DRIVER_NAME "     Unknown packet type = %d\n", xppdd->comm_iface->packet_type));
    4.63 +    break;
    4.64 +  }
    4.65 +  KeMemoryBarrier();
    4.66 +  xppdd->comm_iface->rsp_prod++;
    4.67 +  EvtChn_Notify(xpdd, xppdd->comm_iface->fdo_event_channel);
    4.68 +  FUNCTION_EXIT();
    4.69 +}
    4.70 +
    4.71 +static DDKAPI BOOLEAN
    4.72 +XenPci_Pdo_Dpc(PKINTERRUPT interrupt, PVOID context)
    4.73 +{
    4.74 +  PXENPCI_PDO_DEVICE_DATA xppdd = context;
    4.75 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    4.76 +  PIO_WORKITEM work_item;
    4.77 +  NTSTATUS status = STATUS_SUCCESS;
    4.78 +
    4.79 +  if (!xppdd->comm_iface)
    4.80 +    return FALSE;
    4.81 +  KeAcquireSpinLockAtDpcLevel(&xppdd->comm_iface_spinlock);
    4.82 +  if (xppdd->comm_iface->req_prod == xppdd->req_cons)
    4.83 +  {
    4.84 +    KeReleaseSpinLockFromDpcLevel(&xppdd->comm_iface_spinlock);
    4.85 +    return FALSE;
    4.86 +  }
    4.87 +  xppdd->req_cons = xppdd->comm_iface->req_prod;
    4.88 +  KeReleaseSpinLockFromDpcLevel(&xppdd->comm_iface_spinlock);
    4.89 +	work_item = IoAllocateWorkItem(xppdd->common.pdo);
    4.90 +	IoQueueWorkItem(work_item, XenPci_Pdo_Comm_Iface_Worker, DelayedWorkQueue, NULL);
    4.91 +  return TRUE;
    4.92 +}
    4.93 +
    4.94  static NTSTATUS
    4.95  XenPci_XenConfigDevice(PVOID context);
    4.96  
    4.97 @@ -635,6 +722,19 @@ XenPci_XenConfigDeviceSpecifyBuffers(PVO
    4.98          __ADD_XEN_INIT_ULONG(&xppdd->assigned_resources_ptr, gref);
    4.99        }
   4.100        break;
   4.101 +    case XEN_INIT_TYPE_COMM_IFACE:
   4.102 +      xppdd->comm_iface = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);
   4.103 +      xppdd->comm_iface->magic = XEN_DATA_MAGIC;
   4.104 +      xppdd->comm_iface->length = sizeof(XEN_COMM_IFACE);
   4.105 +      xppdd->comm_iface->pdo_event_channel = EvtChn_AllocIpi(xpdd, 0);
   4.106 +      EvtChn_BindDpc(xpdd, xppdd->comm_iface->pdo_event_channel, XenPci_Pdo_Dpc, xppdd);
   4.107 +      xppdd->comm_iface->fdo_event_channel = EvtChn_AllocIpi(xpdd, 0);
   4.108 +      EvtChn_BindIrq(xpdd, xppdd->comm_iface->fdo_event_channel, xppdd->irq_vector, path);
   4.109 +      strcpy(xppdd->comm_iface->path, xppdd->path);
   4.110 +      strcpy(xppdd->comm_iface->backend_path, xppdd->backend_path);
   4.111 +      xppdd->comm_iface->req_prod = 0;
   4.112 +      xppdd->comm_iface->rsp_prod = 0;
   4.113 +      ADD_XEN_INIT_RSP(&out_ptr, type, NULL, xppdd->comm_iface);
   4.114      }
   4.115    }
   4.116    ADD_XEN_INIT_RSP(&out_ptr, XEN_INIT_TYPE_END, NULL, NULL);
   4.117 @@ -734,7 +834,7 @@ XenPci_Pdo_Resume(PDEVICE_OBJECT device_
   4.118        // reset things - feed the 'requested resources' back in
   4.119        ADD_XEN_INIT_REQ(&xppdd->requested_resources_ptr, XEN_INIT_TYPE_END, NULL, NULL);
   4.120        src = xppdd->requested_resources_start;
   4.121 -      xppdd->requested_resources_ptr = xppdd->requested_resources_start = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);;
   4.122 +      xppdd->requested_resources_ptr = xppdd->requested_resources_start = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);
   4.123        xppdd->assigned_resources_ptr = xppdd->assigned_resources_start;
   4.124        
   4.125        dst = MmMapIoSpace(xppdd->config_page_phys, xppdd->config_page_length, MmNonCached);