win-pvdrivers

changeset 515:4e7d9cc9f816

Refreshed the EVT_ACTION_TYPE_NORMAL code path. Updated prototypes.
Fixed compiler warning under amd64
author James Harper <james.harper@bendigoit.com.au>
date Thu Dec 25 17:49:31 2008 +1100 (2008-12-25)
parents 8381de10df8d
children 6d581a6a432b
files xenpci/evtchn.c xenpci/xenbus.c xenpci/xenpci.h xenpci/xenpci_fdo.c xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/evtchn.c	Thu Dec 25 17:46:07 2008 +1100
     1.2 +++ b/xenpci/evtchn.c	Thu Dec 25 17:49:31 2008 +1100
     1.3 @@ -50,7 +50,7 @@ EvtChn_DpcBounce(PRKDPC Dpc, PVOID Conte
     1.4  
     1.5    if (action->type == EVT_ACTION_TYPE_DPC)
     1.6    {
     1.7 -    action->ServiceRoutine(NULL, action->ServiceContext);
     1.8 +    action->ServiceRoutine(action->ServiceContext);
     1.9    }
    1.10    //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    1.11  }
    1.12 @@ -68,6 +68,7 @@ EvtChn_AckEvent(PVOID context, evtchn_po
    1.13    evt_word = port >> BITS_PER_LONG_SHIFT;
    1.14  
    1.15    val = synch_clear_bit(evt_bit, (volatile xen_long_t *)&xpdd->evtchn_pending_pvt[evt_word]);
    1.16 +  //KdPrint((__DRIVER_NAME "     EvtChn_AckEvent work[0] = %08x, port %d = %d\n", xpdd->evtchn_pending_pvt[0], port, val));
    1.17    
    1.18    return (BOOLEAN)!!val;
    1.19  }
    1.20 @@ -135,7 +136,7 @@ to CPU != 0, but we should always use vc
    1.21        {
    1.22        case EVT_ACTION_TYPE_NORMAL:
    1.23          //KdPrint((__DRIVER_NAME "     EVT_ACTION_TYPE_NORMAL\n"));
    1.24 -        ev_action->ServiceRoutine(NULL, ev_action->ServiceContext);
    1.25 +        ev_action->ServiceRoutine(ev_action->ServiceContext);
    1.26          break;
    1.27        case EVT_ACTION_TYPE_IRQ:
    1.28          //KdPrint((__DRIVER_NAME "     EVT_ACTION_TYPE_IRQ\n"));
    1.29 @@ -156,6 +157,10 @@ to CPU != 0, but we should always use vc
    1.30              int suspend_word = i >> BITS_PER_LONG_SHIFT;
    1.31              synch_set_bit(suspend_bit, (volatile xen_long_t *)&xpdd->evtchn_pending_pvt[suspend_word]);
    1.32            }
    1.33 +          else if (xpdd->ev_actions[i].type == EVT_ACTION_TYPE_NORMAL && xpdd->ev_actions[i].ServiceRoutine)
    1.34 +          {
    1.35 +            xpdd->ev_actions[i].ServiceRoutine(xpdd->ev_actions[i].ServiceContext);
    1.36 +          }
    1.37          }
    1.38          deferred = TRUE;
    1.39          break;
    1.40 @@ -170,11 +175,12 @@ to CPU != 0, but we should always use vc
    1.41    {
    1.42      KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    1.43    }
    1.44 +
    1.45    return handled && !deferred;
    1.46  }
    1.47  
    1.48  NTSTATUS
    1.49 -EvtChn_Bind(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    1.50 +EvtChn_Bind(PVOID Context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    1.51  {
    1.52    PXENPCI_DEVICE_DATA xpdd = Context;
    1.53  
    1.54 @@ -201,7 +207,7 @@ EvtChn_Bind(PVOID Context, evtchn_port_t
    1.55  }
    1.56  
    1.57  NTSTATUS
    1.58 -EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    1.59 +EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    1.60  {
    1.61    PXENPCI_DEVICE_DATA xpdd = Context;
    1.62  
     2.1 --- a/xenpci/xenbus.c	Thu Dec 25 17:46:07 2008 +1100
     2.2 +++ b/xenpci/xenbus.c	Thu Dec 25 17:49:31 2008 +1100
     2.3 @@ -32,8 +32,6 @@ static DDKAPI void
     2.4  XenBus_ReadThreadProc(PVOID StartContext);
     2.5  static DDKAPI void
     2.6  XenBus_WatchThreadProc(PVOID StartContext);
     2.7 -static DDKAPI BOOLEAN
     2.8 -XenBus_Dpc(PKINTERRUPT Interrupt, PVOID ServiceContext);
     2.9  
    2.10  // This routine free's the rep structure if there was an error!!!
    2.11  static char *errmsg(struct xsd_sockmsg *rep)
    2.12 @@ -138,7 +136,7 @@ xenbus_format_msg_reply(
    2.13    msg.tx_id = trans_id;
    2.14    msg.len = 0;
    2.15    for (i = 0; i < nr_reqs; i++)
    2.16 -    msg.len = msg.len + (size_t)req[i].len;
    2.17 +    msg.len += req[i].len;
    2.18  
    2.19    ExAcquireFastMutex(&xpdd->xb_request_mutex);
    2.20    xb_write(xpdd, &msg, sizeof(msg));
    2.21 @@ -245,6 +243,20 @@ XenBus_Write(
    2.22    return NULL;
    2.23  }
    2.24  
    2.25 +static VOID
    2.26 +XenBus_Dpc(PVOID ServiceContext)
    2.27 +{
    2.28 +  PXENPCI_DEVICE_DATA xpdd = ServiceContext;
    2.29 +
    2.30 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.31 +
    2.32 +  KeSetEvent(&xpdd->XenBus_ReadThreadEvent, IO_NO_INCREMENT, FALSE);
    2.33 +
    2.34 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    2.35 +
    2.36 +  return;
    2.37 +}
    2.38 +
    2.39  NTSTATUS
    2.40  XenBus_Connect(PXENPCI_DEVICE_DATA xpdd)
    2.41  {
    2.42 @@ -823,22 +835,6 @@ XenBus_EndTransaction(
    2.43    return NULL;
    2.44  }
    2.45  
    2.46 -static DDKAPI BOOLEAN
    2.47 -XenBus_Dpc(PKINTERRUPT Interrupt, PVOID ServiceContext)
    2.48 -{
    2.49 -  PXENPCI_DEVICE_DATA xpdd = ServiceContext;
    2.50 -
    2.51 -  UNREFERENCED_PARAMETER(Interrupt);
    2.52 -
    2.53 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.54 -
    2.55 -  KeSetEvent(&xpdd->XenBus_ReadThreadEvent, IO_NO_INCREMENT, FALSE);
    2.56 -
    2.57 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    2.58 -
    2.59 -  return TRUE;
    2.60 -}
    2.61 -
    2.62  char *
    2.63  XenBus_Printf(
    2.64    PVOID Context,
     3.1 --- a/xenpci/xenpci.h	Thu Dec 25 17:46:07 2008 +1100
     3.2 +++ b/xenpci/xenpci.h	Thu Dec 25 17:49:31 2008 +1100
     3.3 @@ -77,7 +77,7 @@ extern ULONG qemu_filtered;
     3.4  extern ULONG qemu_protocol_version;
     3.5  
     3.6  typedef struct _ev_action_t {
     3.7 -  PKSERVICE_ROUTINE ServiceRoutine;
     3.8 +  PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine;
     3.9    PVOID ServiceContext;
    3.10    CHAR description[128];
    3.11    ULONG type; /* EVT_ACTION_TYPE_* */
    3.12 @@ -421,9 +421,9 @@ EvtChn_Mask(PVOID Context, evtchn_port_t
    3.13  NTSTATUS
    3.14  EvtChn_Unmask(PVOID Context, evtchn_port_t Port);
    3.15  NTSTATUS
    3.16 -EvtChn_Bind(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    3.17 +EvtChn_Bind(PVOID Context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    3.18  NTSTATUS
    3.19 -EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    3.20 +EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    3.21  NTSTATUS
    3.22  EvtChn_BindIrq(PVOID Context, evtchn_port_t Port, ULONG vector, PCHAR description);
    3.23  evtchn_port_t
     4.1 --- a/xenpci/xenpci_fdo.c	Thu Dec 25 17:46:07 2008 +1100
     4.2 +++ b/xenpci/xenpci_fdo.c	Thu Dec 25 17:49:31 2008 +1100
     4.3 @@ -759,6 +759,8 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
     4.4  	    xpdd->irq_affinity = res_descriptor->u.Interrupt.Affinity;
     4.5        
     4.6        xpdd->irq_mode = (res_descriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED)?Latched:LevelSensitive;
     4.7 +      KdPrint((__DRIVER_NAME "     irq_mode = %s\n", (xpdd->irq_mode == Latched)?"Latched":"LevelSensitive"));
     4.8 +      
     4.9        //memcpy(&InterruptTranslated, res_descriptor, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
    4.10        break;
    4.11      case CmResourceTypeDevicePrivate:
     5.1 --- a/xenpci/xenpci_pdo.c	Thu Dec 25 17:46:07 2008 +1100
     5.2 +++ b/xenpci/xenpci_pdo.c	Thu Dec 25 17:49:31 2008 +1100
     5.3 @@ -298,7 +298,7 @@ DUMP_CURRENT_PNP_STATE(PXENPCI_PDO_DEVIC
     5.4  }
     5.5  
     5.6  static NTSTATUS
     5.7 -XenPci_EvtChn_Bind(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
     5.8 +XenPci_EvtChn_Bind(PVOID Context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
     5.9  {
    5.10    PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    5.11    PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    5.12 @@ -307,7 +307,7 @@ XenPci_EvtChn_Bind(PVOID Context, evtchn
    5.13  }
    5.14  
    5.15  static NTSTATUS
    5.16 -XenPci_EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    5.17 +XenPci_EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    5.18  {
    5.19    PXENPCI_PDO_DEVICE_DATA xppdd = Context;
    5.20    PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    5.21 @@ -517,8 +517,6 @@ XenPci_XenShutdownDevice(PVOID Context)
    5.22          FreePages(value);
    5.23          break;
    5.24        case XEN_INIT_TYPE_EVENT_CHANNEL: /* frontend event channel */
    5.25 -        // don't know how to do this yet...
    5.26 -        break;
    5.27        case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ: /* frontend event channel bound to irq */
    5.28          EvtChn_Unbind(xpdd, PtrToUlong(value));
    5.29          EvtChn_Close(xpdd, PtrToUlong(value));