win-pvdrivers

changeset 73:f74723639713

Corrected merge of dpc patches.
Releasing 0.5.0.0
author James Harper <james.harper@bendigoit.com.au>
date Thu Dec 20 13:07:44 2007 +1100 (2007-12-20)
parents 74afe8d3db57
children 06b4321b7068
files BUILDING.txt INSTALLING.txt common/include/evtchn_public.h xenhide/sources xenpci/evtchn.c xenpci/sources xenpci/xenpci.c xenpci/xenpci.h xenvbd/sources xenvbd/xenvbd.c
line diff
     1.1 --- a/BUILDING.txt	Thu Dec 20 13:07:13 2007 +1100
     1.2 +++ b/BUILDING.txt	Thu Dec 20 13:07:44 2007 +1100
     1.3 @@ -6,9 +6,10 @@ 3. Use Mercurial (get it from http://www
     1.4  
     1.5  4. Go into each of xenpci, xenvbd, xennet, and xenhide and do a 'BLD'.
     1.6  
     1.7 -5. Assuming all went well, your drivers should be in toplevel target/i386
     1.8 -directory.
     1.9 +5. Assuming all went well, your drivers should be in target/<sys>/i386 directory. (<sys> is winnet or winxp)
    1.10  
    1.11  I've probably omitted some vitally important step from the above, so please let me know if you need any assistance compiling.
    1.12  
    1.13  See the INSTALLING.txt file for information on how to install.
    1.14 +
    1.15 +There is also a simple C# app which will enable 'graceful' shutdown (eg 'xm shutdown' and 'xm reboot' will do the right thing). Open Xen.sln in Visual Studio to build it.
    1.16 \ No newline at end of file
     2.1 --- a/INSTALLING.txt	Thu Dec 20 13:07:13 2007 +1100
     2.2 +++ b/INSTALLING.txt	Thu Dec 20 13:07:44 2007 +1100
     2.3 @@ -1,15 +1,17 @@
     2.4  Please follow the steps here exactly. If you don't, you may be left with an unbootable machine (although 'Last known good configuration' should make it bootable again).
     2.5  
     2.6 -1. Copy the driver files that you built by following the BUILDING.txt steps, so that on your testing machine the tree looks like this:
     2.7 +1. Copy the driver files that you built by following the BUILDING.txt steps (or that you got from a binary dist), so that on your testing machine the tree looks like this:
     2.8  
     2.9 -Xen\xenhide.inf
    2.10 -Xen\xenpci.inf
    2.11 -Xen\xenvbd.inf
    2.12 -Xen\i386\xenhide.sys
    2.13 -Xen\i386\xenpci.sys
    2.14 -Xen\i386\xenvbd.sys
    2.15 -Xen\i386\WdfCoInstaller01005.dll
    2.16 +Xen\<arch>\xenhide.inf
    2.17 +Xen\<arch>\xenpci.inf
    2.18 +Xen\<arch>\xenvbd.inf
    2.19 +Xen\<arch>\i386\xenaddresource.sys
    2.20 +Xen\<arch>\i386\xenhide.sys
    2.21 +Xen\<arch>\i386\xenpci.sys
    2.22 +Xen\<arch>\i386\xenvbd.sys
    2.23 +Xen\<arch>\i386\WdfCoInstaller01005.dll
    2.24  (you'll need to copy WdfCoInstaller01005.dll from the redist folder in the DDK)
    2.25 +(<arch> is winxp for XP, or winnet for 2K3)
    2.26  
    2.27  2. Go to the device manager (Right click on My Computer, then select the Hardware tab, then click Device Manager)
    2.28  
    2.29 @@ -47,7 +49,7 @@ timeout=30
    2.30  default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
    2.31  [operating systems]
    2.32  multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /noexecute=optout /fastdetect
    2.33 -multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise, PV" /noexecute=optout /fastdetect /gplpv
    2.34 +multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise, GPLPV" /noexecute=optout /fastdetect /gplpv
    2.35  "
    2.36  
    2.37  17. The main thing in the above step is that you have a line with /gplpv on the end. This tells the PV drivers to activate, otherwise they will pretty much sit silent.
    2.38 @@ -63,3 +65,5 @@ xm block-attach mywindowsdomain phy:/dev
    2.39  I'm pretty sure that you need to specify the 'phy:' otherwise the backend doesn't seem to publish the block and sector sizes correctly.
    2.40  
    2.41  If you do the block-attach, then your block device should show up under windows, and you can partition it etc.
    2.42 +
    2.43 +19. If you have built ShutdownMon, run "ShutdownMon -i" which will install it as a service. You will need to change the service to 'Automatic' and start it (or reboot). 'xm shutdown' and 'xm reboot' should then do the right thing.
    2.44 \ No newline at end of file
     3.1 --- a/common/include/evtchn_public.h	Thu Dec 20 13:07:13 2007 +1100
     3.2 +++ b/common/include/evtchn_public.h	Thu Dec 20 13:07:44 2007 +1100
     3.3 @@ -50,6 +50,7 @@ typedef struct _XENBUS_IFACE_EVTCHN {
     3.4    PXEN_EVTCHN_UNMASK Unmask;
     3.5    PXEN_EVTCHN_NOTIFY Notify;
     3.6    PXEN_EVTCHN_ALLOCUNBOUND AllocUnbound;
     3.7 +  PXEN_EVTCHN_BIND BindDpc;
     3.8  
     3.9  } XEN_IFACE_EVTCHN, *PXEN_IFACE_EVTCHN;
    3.10  
     4.1 --- a/xenhide/sources	Thu Dec 20 13:07:13 2007 +1100
     4.2 +++ b/xenhide/sources	Thu Dec 20 13:07:44 2007 +1100
     4.3 @@ -1,7 +1,7 @@
     4.4  TARGETNAME=XENHIDE
     4.5  TARGETTYPE=DRIVER
     4.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     4.7 -VERSION=0.4.0.0
     4.8 +VERSION=0.5.0.0
     4.9  KMDF_VERSION=1
    4.10  MSC_WARNING_LEVEL=/W4
    4.11  INF_NAME=xenhide
     5.1 --- a/xenpci/evtchn.c	Thu Dec 20 13:07:13 2007 +1100
     5.2 +++ b/xenpci/evtchn.c	Thu Dec 20 13:07:44 2007 +1100
     5.3 @@ -20,6 +20,15 @@ Foundation, Inc., 51 Franklin Street, Fi
     5.4  #include "xenpci.h"
     5.5  #include "hypercall.h"
     5.6  
     5.7 +static VOID
     5.8 +EvtChn_DpcBounce(WDFDPC Dpc)
     5.9 +{
    5.10 +  ev_action_t *Action;
    5.11 +
    5.12 +  Action = GetEvtChnDeviceData(Dpc)->Action;
    5.13 +  Action->ServiceRoutine(NULL, Action->ServiceContext);
    5.14 +}
    5.15 +
    5.16  BOOLEAN
    5.17  EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID)
    5.18  {
    5.19 @@ -27,6 +36,10 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    5.20    vcpu_info_t *vcpu_info;
    5.21    PXENPCI_DEVICE_DATA xpdd = GetDeviceData(WdfInterruptGetDevice(Interrupt));
    5.22    shared_info_t *shared_info_area = xpdd->shared_info_area;
    5.23 +  unsigned long evt_words, evt_word;
    5.24 +  unsigned long evt_bit;
    5.25 +  unsigned long port;
    5.26 +  ev_action_t *ev_action;
    5.27  
    5.28    UNREFERENCED_PARAMETER(MessageID);
    5.29  
    5.30 @@ -34,28 +47,6 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    5.31  
    5.32    vcpu_info->evtchn_upcall_pending = 0;
    5.33  
    5.34 -  WdfInterruptQueueDpcForIsr(Interrupt);
    5.35 -
    5.36 -  return TRUE;
    5.37 -}
    5.38 -
    5.39 -VOID
    5.40 -EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject)
    5.41 -{
    5.42 -  int cpu = 0;
    5.43 -  vcpu_info_t *vcpu_info;
    5.44 -  unsigned long evt_words, evt_word;
    5.45 -  unsigned long evt_bit;
    5.46 -  unsigned long port;
    5.47 -  ev_action_t *ev_action;
    5.48 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(WdfInterruptGetDevice(Interrupt));
    5.49 -  shared_info_t *shared_info_area = xpdd->shared_info_area;
    5.50 -
    5.51 -  UNREFERENCED_PARAMETER(Interrupt);
    5.52 -  UNREFERENCED_PARAMETER(AssociatedObject);
    5.53 -
    5.54 -  vcpu_info = &shared_info_area->vcpu_info[cpu];
    5.55 -
    5.56    evt_words = _InterlockedExchange((volatile LONG *)&vcpu_info->evtchn_pending_sel, 0);
    5.57    
    5.58    while (_BitScanForward(&evt_word, evt_words))
    5.59 @@ -71,12 +62,20 @@ EvtChn_InterruptDpc(WDFINTERRUPT Interru
    5.60        }
    5.61        else
    5.62        {
    5.63 -        //KdPrint((__DRIVER_NAME "     Calling Handler for port %d\n", port));
    5.64 -        ev_action->ServiceRoutine(NULL, ev_action->ServiceContext);
    5.65 +        if (ev_action->DpcFlag)
    5.66 +        {
    5.67 +          WdfDpcEnqueue(ev_action->Dpc);
    5.68 +        }
    5.69 +        else
    5.70 +        {
    5.71 +          ev_action->ServiceRoutine(NULL, ev_action->ServiceContext);
    5.72 +        }
    5.73        }
    5.74        _interlockedbittestandreset((volatile LONG *)&shared_info_area->evtchn_pending[0], port);
    5.75      }
    5.76    }
    5.77 +
    5.78 +  return FALSE; // This needs to be FALSE so it can fall through to the scsiport ISR.
    5.79  }
    5.80  
    5.81  NTSTATUS
    5.82 @@ -89,9 +88,12 @@ EvtChn_Bind(PVOID Context, evtchn_port_t
    5.83  
    5.84    if(xpdd->ev_actions[Port].ServiceRoutine != NULL)
    5.85    {
    5.86 +    xpdd->ev_actions[Port].ServiceRoutine = NULL;
    5.87 +    KeMemoryBarrier(); // make sure we don't call the old Service Routine with the new data...
    5.88      KdPrint((__DRIVER_NAME " Handler for port %d already registered, replacing\n", Port));
    5.89    }
    5.90  
    5.91 +  xpdd->ev_actions[Port].DpcFlag = FALSE;
    5.92    xpdd->ev_actions[Port].ServiceContext = ServiceContext;
    5.93    KeMemoryBarrier();
    5.94    xpdd->ev_actions[Port].ServiceRoutine = ServiceRoutine;
    5.95 @@ -103,6 +105,41 @@ EvtChn_Bind(PVOID Context, evtchn_port_t
    5.96    return STATUS_SUCCESS;
    5.97  }
    5.98  
    5.99 +EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
   5.100 +{
   5.101 +  WDFDEVICE Device = Context;
   5.102 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   5.103 +  WDF_DPC_CONFIG DpcConfig;
   5.104 +  WDF_OBJECT_ATTRIBUTES DpcObjectAttributes;
   5.105 +
   5.106 +  KdPrint((__DRIVER_NAME " --> EvtChn_BindDpc\n"));
   5.107 +
   5.108 +  if(xpdd->ev_actions[Port].ServiceRoutine != NULL)
   5.109 +  {
   5.110 +    KdPrint((__DRIVER_NAME " Handler for port %d already registered, replacing\n", Port));
   5.111 +    xpdd->ev_actions[Port].ServiceRoutine = NULL;
   5.112 +    KeMemoryBarrier(); // make sure we don't call the old Service Routine with the new data...
   5.113 +  }
   5.114 +
   5.115 +  xpdd->ev_actions[Port].ServiceContext = ServiceContext;
   5.116 +  xpdd->ev_actions[Port].DpcFlag = TRUE;
   5.117 +
   5.118 +  WDF_DPC_CONFIG_INIT(&DpcConfig, EvtChn_DpcBounce);
   5.119 +  WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&DpcObjectAttributes, EVTCHN_DEVICE_DATA);
   5.120 +  DpcObjectAttributes.ParentObject = Device;
   5.121 +  WdfDpcCreate(&DpcConfig, &DpcObjectAttributes, &xpdd->ev_actions[Port].Dpc);
   5.122 +  GetEvtChnDeviceData(xpdd->ev_actions[Port].Dpc)->Action = &xpdd->ev_actions[Port];
   5.123 +
   5.124 +  KeMemoryBarrier(); // make sure that the new service routine is only called once the context is set up
   5.125 +  xpdd->ev_actions[Port].ServiceRoutine = ServiceRoutine;
   5.126 +
   5.127 +  EvtChn_Unmask(Device, Port);
   5.128 +
   5.129 +  KdPrint((__DRIVER_NAME " <-- EvtChn_BindDpc\n"));
   5.130 +
   5.131 +  return STATUS_SUCCESS;
   5.132 +}
   5.133 +
   5.134  NTSTATUS
   5.135  EvtChn_Unbind(PVOID Context, evtchn_port_t Port)
   5.136  {
     6.1 --- a/xenpci/sources	Thu Dec 20 13:07:13 2007 +1100
     6.2 +++ b/xenpci/sources	Thu Dec 20 13:07:44 2007 +1100
     6.3 @@ -1,7 +1,7 @@
     6.4  TARGETNAME=XENPCI
     6.5  TARGETTYPE=DRIVER
     6.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     6.7 -VERSION=0.4.0.28
     6.8 +VERSION=0.5.0.0
     6.9  KMDF_VERSION=1
    6.10  MSC_WARNING_LEVEL=/W4
    6.11  INF_NAME=xenpci
     7.1 --- a/xenpci/xenpci.c	Thu Dec 20 13:07:13 2007 +1100
     7.2 +++ b/xenpci/xenpci.c	Thu Dec 20 13:07:44 2007 +1100
     7.3 @@ -373,7 +373,7 @@ XenPCI_AddDevice(
     7.4  
     7.5    WdfDeviceSetBusInformationForChildren(Device, &busInfo);
     7.6  
     7.7 -  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, EvtChn_InterruptDpc);
     7.8 +  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, NULL); //EvtChn_InterruptDpc);
     7.9    InterruptConfig.EvtInterruptEnable = XenPCI_InterruptEnable;
    7.10    InterruptConfig.EvtInterruptDisable = XenPCI_InterruptDisable;
    7.11    Status = WdfInterruptCreate(Device, &InterruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &xpdd->XenInterrupt);
    7.12 @@ -806,6 +806,7 @@ XenPCI_ChildListCreateDevice(
    7.13    ChildDeviceData->EvtChnInterface.Unmask = EvtChn_Unmask;
    7.14    ChildDeviceData->EvtChnInterface.Notify = EvtChn_Notify;
    7.15    ChildDeviceData->EvtChnInterface.AllocUnbound = EvtChn_AllocUnbound;
    7.16 +  ChildDeviceData->EvtChnInterface.BindDpc = EvtChn_BindDpc;
    7.17    WDF_QUERY_INTERFACE_CONFIG_INIT(&qiConfig, (PINTERFACE)&ChildDeviceData->EvtChnInterface, &GUID_XEN_IFACE_EVTCHN, NULL);
    7.18    status = WdfDeviceAddQueryInterface(ChildDevice, &qiConfig);
    7.19    if (!NT_SUCCESS(status))
     8.1 --- a/xenpci/xenpci.h	Thu Dec 20 13:07:13 2007 +1100
     8.2 +++ b/xenpci/xenpci.h	Thu Dec 20 13:07:44 2007 +1100
     8.3 @@ -62,16 +62,22 @@ typedef struct _XENPCI_IDENTIFICATION_DE
     8.4  {
     8.5    WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
     8.6    UNICODE_STRING DeviceType;
     8.7 -//  ULONG DeviceIndex;
     8.8    char Path[128];
     8.9  } XENPCI_IDENTIFICATION_DESCRIPTION, *PXENPCI_IDENTIFICATION_DESCRIPTION;
    8.10  
    8.11  typedef struct _ev_action_t {
    8.12    PKSERVICE_ROUTINE ServiceRoutine;
    8.13    PVOID ServiceContext;
    8.14 +  BOOLEAN DpcFlag;
    8.15 +  WDFDPC Dpc;
    8.16    ULONG Count;
    8.17  } ev_action_t;
    8.18  
    8.19 +typedef struct {
    8.20 +  ev_action_t *Action;
    8.21 +} EVTCHN_DEVICE_DATA, *PEVTCHN_DEVICE_DATA;
    8.22 +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(EVTCHN_DEVICE_DATA, GetEvtChnDeviceData);
    8.23 +
    8.24  typedef struct _XENBUS_WATCH_RING
    8.25  {
    8.26    char Path[128];
    8.27 @@ -192,6 +198,8 @@ EvtChn_Unmask(PVOID Context, evtchn_port
    8.28  NTSTATUS
    8.29  EvtChn_Bind(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    8.30  NTSTATUS
    8.31 +EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    8.32 +NTSTATUS
    8.33  EvtChn_Unbind(PVOID Context, evtchn_port_t Port);
    8.34  NTSTATUS
    8.35  EvtChn_Notify(PVOID Context, evtchn_port_t Port);
     9.1 --- a/xenvbd/sources	Thu Dec 20 13:07:13 2007 +1100
     9.2 +++ b/xenvbd/sources	Thu Dec 20 13:07:44 2007 +1100
     9.3 @@ -1,7 +1,7 @@
     9.4  TARGETNAME=XENVBD
     9.5  TARGETTYPE=DRIVER
     9.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     9.7 -VERSION=0.4.0.126
     9.8 +VERSION=0.5.0.0
     9.9  KMDF_VERSION=1
    9.10  MSC_WARNING_LEVEL=/W4
    9.11  INF_NAME=xenvbd
    10.1 --- a/xenvbd/xenvbd.c	Thu Dec 20 13:07:13 2007 +1100
    10.2 +++ b/xenvbd/xenvbd.c	Thu Dec 20 13:07:44 2007 +1100
    10.3 @@ -205,7 +205,11 @@ XenVbd_Interrupt(PKINTERRUPT Interrupt, 
    10.4  {
    10.5    PXENVBD_TARGET_DATA TargetData = (PXENVBD_TARGET_DATA)DeviceExtension;
    10.6  
    10.7 +//  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
    10.8 +
    10.9    TargetData->PendingInterrupt = TRUE;
   10.10 +
   10.11 +//  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
   10.12    return;
   10.13  }
   10.14