win-pvdrivers

changeset 258:9b16ad37af17 wdm

Created wdm branch for the migration from wdf to wdm. the basics of xenpci are working, but the bus enumeration isn't yet.
author James Harper <james.harper@bendigoit.com.au>
date Fri May 02 20:54:46 2008 +1000 (2008-05-02)
parents 253ec5052cb4
children 161a8a26f3db
files common.inc common/include/xen_public.h xenhide/xenhide.c xenpci/evtchn.c xenpci/gnttbl.c xenpci/hypercall_x86.h xenpci/makefile.inc xenpci/sources xenpci/xenbus.c xenpci/xenpci.c xenpci/xenpci.h xenpci/xenpci.inx
line diff
     1.1 --- a/common.inc	Mon Apr 28 23:07:28 2008 +1000
     1.2 +++ b/common.inc	Fri May 02 20:54:46 2008 +1000
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.8.9.8
     1.5 +VERSION=0.8.9.35
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- a/common/include/xen_public.h	Mon Apr 28 23:07:28 2008 +1000
     2.2 +++ b/common/include/xen_public.h	Fri May 02 20:54:46 2008 +1000
     2.3 @@ -51,16 +51,16 @@ typedef evtchn_port_t
     2.4  (*PXEN_EVTCHN_ALLOCUNBOUND)(PVOID Context, domid_t Domain);
     2.5  
     2.6  typedef grant_ref_t
     2.7 -(*PXEN_GNTTBL_GRANTACCESS)(WDFDEVICE Device, domid_t domid, uint32_t frame, int readonly, grant_ref_t ref);
     2.8 +(*PXEN_GNTTBL_GRANTACCESS)(PVOID Context, domid_t domid, uint32_t frame, int readonly, grant_ref_t ref);
     2.9  
    2.10  typedef BOOLEAN
    2.11 -(*PXEN_GNTTBL_ENDACCESS)(WDFDEVICE Device, grant_ref_t ref, BOOLEAN keepref);
    2.12 +(*PXEN_GNTTBL_ENDACCESS)(PVOID Context, grant_ref_t ref, BOOLEAN keepref);
    2.13  
    2.14  typedef VOID
    2.15 -(*PXEN_GNTTBL_PUTREF)(WDFDEVICE Device, grant_ref_t ref);
    2.16 +(*PXEN_GNTTBL_PUTREF)(PVOID Context, grant_ref_t ref);
    2.17  
    2.18  typedef grant_ref_t
    2.19 -(*PXEN_GNTTBL_GETREF)(WDFDEVICE Device);
    2.20 +(*PXEN_GNTTBL_GETREF)(PVOID Context);
    2.21  
    2.22  
    2.23  typedef VOID
    2.24 @@ -121,6 +121,7 @@ typedef struct _XEN_IFACE {
    2.25  
    2.26  #define XEN_DATA_MAGIC 0x12345678
    2.27  
    2.28 +#if 0
    2.29  typedef struct _XENPCI_IDENTIFICATION_DESCRIPTION
    2.30  {
    2.31    WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
    2.32 @@ -142,5 +143,6 @@ typedef struct {
    2.33  } XENPCI_XEN_DEVICE_DATA, *PXENPCI_XEN_DEVICE_DATA;
    2.34  
    2.35  WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_XEN_DEVICE_DATA, GetXenDeviceData);
    2.36 +#endif
    2.37  
    2.38  #endif
     3.1 --- a/xenhide/xenhide.c	Mon Apr 28 23:07:28 2008 +1000
     3.2 +++ b/xenhide/xenhide.c	Fri May 02 20:54:46 2008 +1000
     3.3 @@ -163,27 +163,18 @@ XenHide_AddDevice(
     3.4    size_t StrLen;
     3.5    int Match;
     3.6    PWCHAR Ptr;
     3.7 +  INTERFACE_TYPE it;
     3.8  
     3.9  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.10  
    3.11 -  Length = sizeof(Buffer);
    3.12 -  status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyHardwareID, Length, Buffer, &Length);
    3.13 -//  KdPrint((__DRIVER_NAME " status = %08x, DevicePropertyHardwareID, = %ws\n", status, Buffer));
    3.14 +// get DevicePropertyLegacyBusType. If it's not PCI then return
    3.15 +
    3.16 +  Length = sizeof(it);
    3.17 +  status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyLegacyBusType, Length, &it, &Length);
    3.18    if (!NT_SUCCESS(status))
    3.19      return STATUS_SUCCESS;
    3.20  
    3.21 -  /* does end of HwID match PNP0A03? */
    3.22 -  Match = 0;
    3.23 -  RtlStringCchLengthW(Buffer, Length/2, &StrLen); // get strlen in wchars
    3.24 -  if (StrLen >= 7)
    3.25 -  {
    3.26 -    Ptr = Buffer + (StrLen - 7);
    3.27 -    if (wcscmp(Ptr, L"PNP0A03") == 0)
    3.28 -    {
    3.29 -      Match = 1;
    3.30 -    }
    3.31 -  }
    3.32 -  if (!Match)
    3.33 +  if (it != PCIBus)
    3.34      return STATUS_SUCCESS;
    3.35  
    3.36    KdPrint((__DRIVER_NAME " Found\n")); 
    3.37 @@ -240,13 +231,6 @@ XenHide_AddDevice(
    3.38    return STATUS_SUCCESS;
    3.39  }
    3.40  
    3.41 -static int
    3.42 -XenHide_StringMatches(PWCHAR String1, PWCHAR String2)
    3.43 -{
    3.44 -  for(;*String1 != 0 && *String2 != 0 && *String1 == *String2; String1++, String2++);
    3.45 -  return ((*String1 == 0 && *String2 == 0) || (*String1 == 0 && *String2 == L'\n') || (*String1 == L'\n' && *String2 == 0));
    3.46 -}
    3.47 -
    3.48  static NTSTATUS
    3.49  XenHide_IoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
    3.50  {
    3.51 @@ -278,7 +262,8 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    3.52      }
    3.53      break;
    3.54    case 1:
    3.55 -    DeviceExtension->InternalState = 2; 
    3.56 +    DeviceExtension->InternalState = 2;
    3.57 +#if 0
    3.58      if (Relations != NULL)
    3.59      {
    3.60        for (i = 0; i < Relations->Count; i++)
    3.61 @@ -328,6 +313,7 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    3.62        }
    3.63        Relations->Count -= Offset;
    3.64      }
    3.65 +#endif
    3.66      break;
    3.67    default:
    3.68      break;
    3.69 @@ -355,8 +341,8 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
    3.70    PIO_STACK_LOCATION Stack;
    3.71    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    3.72  
    3.73 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.74 -//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    3.75 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.76 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    3.77  
    3.78    Stack = IoGetCurrentIrpStackLocation(Irp);
    3.79  
    3.80 @@ -369,7 +355,7 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
    3.81  //      KdPrint((__DRIVER_NAME "       BusRelations\n"));
    3.82        IoCopyCurrentIrpStackLocationToNext(Irp);
    3.83        IoSetCompletionRoutine(Irp, XenHide_IoCompletion, DeviceExtension, TRUE, TRUE, TRUE);
    3.84 -      break;  
    3.85 +      break;
    3.86      default:
    3.87        IoSkipCurrentIrpStackLocation(Irp);
    3.88        break;  
    3.89 @@ -382,7 +368,7 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
    3.90  
    3.91    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
    3.92  
    3.93 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
    3.94 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
    3.95  
    3.96    return Status;
    3.97  }
     4.1 --- a/xenpci/evtchn.c	Mon Apr 28 23:07:28 2008 +1000
     4.2 +++ b/xenpci/evtchn.c	Fri May 02 20:54:46 2008 +1000
     4.3 @@ -32,20 +32,23 @@ Foundation, Inc., 51 Franklin Street, Fi
     4.4  #endif
     4.5  
     4.6  static VOID
     4.7 -EvtChn_DpcBounce(WDFDPC Dpc)
     4.8 +EvtChn_DpcBounce(PRKDPC Dpc, PVOID Context, PVOID SystemArgument1, PVOID SystemArgument2)
     4.9  {
    4.10 -  ev_action_t *Action;
    4.11 +  ev_action_t *action = Context;
    4.12  
    4.13 -  Action = GetEvtChnDeviceData(Dpc)->Action;
    4.14 -  Action->ServiceRoutine(NULL, Action->ServiceContext);
    4.15 +  UNREFERENCED_PARAMETER(Dpc);
    4.16 +  UNREFERENCED_PARAMETER(SystemArgument1);
    4.17 +  UNREFERENCED_PARAMETER(SystemArgument2);
    4.18 +
    4.19 +  action->ServiceRoutine(NULL, action->ServiceContext);
    4.20  }
    4.21  
    4.22 -BOOLEAN
    4.23 -EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID)
    4.24 +static BOOLEAN
    4.25 +EvtChn_Interrupt(PKINTERRUPT Interrupt, PVOID Context)
    4.26  {
    4.27    int cpu = KeGetCurrentProcessorNumber() & (MAX_VIRT_CPUS - 1);
    4.28    vcpu_info_t *vcpu_info;
    4.29 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(WdfInterruptGetDevice(Interrupt));
    4.30 +  PXENPCI_DEVICE_DATA xpdd = (PXENPCI_DEVICE_DATA)Context;
    4.31    shared_info_t *shared_info_area = xpdd->shared_info_area;
    4.32    xen_ulong_t evt_words;
    4.33    unsigned long evt_word;
    4.34 @@ -53,9 +56,9 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    4.35    unsigned int port;
    4.36    ev_action_t *ev_action;
    4.37  
    4.38 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (cpu = %d)\n", cpu));
    4.39 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (cpu = %d)\n", cpu));
    4.40  
    4.41 -  UNREFERENCED_PARAMETER(MessageID);
    4.42 +  UNREFERENCED_PARAMETER(Interrupt);
    4.43  
    4.44    vcpu_info = &shared_info_area->vcpu_info[cpu];
    4.45  
    4.46 @@ -78,8 +81,8 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    4.47        {
    4.48          if (ev_action->DpcFlag)
    4.49          {
    4.50 -//          KdPrint((__DRIVER_NAME " --- Scheduling Dpc\n"));
    4.51 -          WdfDpcEnqueue(ev_action->Dpc);
    4.52 +          KdPrint((__DRIVER_NAME "     Scheduling Dpc\n"));
    4.53 +          KeInsertQueueDpc(&ev_action->Dpc, NULL, NULL);
    4.54          }
    4.55          else
    4.56          {
    4.57 @@ -90,7 +93,7 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    4.58      }
    4.59    }
    4.60  
    4.61 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    4.62 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    4.63  
    4.64    /* Need to return FALSE so we can fall through to the scsiport ISR. */
    4.65    return FALSE;
    4.66 @@ -99,10 +102,8 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    4.67  NTSTATUS
    4.68  EvtChn_Bind(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    4.69  {
    4.70 -  WDFDEVICE Device = Context;
    4.71 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    4.72 -
    4.73 -  KdPrint((__DRIVER_NAME " --> EvtChn_Bind (ServiceRoutine = %08X, ServiceContext = %08x)\n", ServiceRoutine, ServiceContext));
    4.74 +  PXENPCI_DEVICE_DATA xpdd = Context;
    4.75 +  //KdPrint((__DRIVER_NAME " --> EvtChn_Bind (ServiceRoutine = %08X, ServiceContext = %08x)\n", ServiceRoutine, ServiceContext));
    4.76  
    4.77    if(xpdd->ev_actions[Port].ServiceRoutine != NULL)
    4.78    {
    4.79 @@ -116,7 +117,7 @@ EvtChn_Bind(PVOID Context, evtchn_port_t
    4.80    KeMemoryBarrier();
    4.81    xpdd->ev_actions[Port].ServiceRoutine = ServiceRoutine;
    4.82  
    4.83 -  EvtChn_Unmask(Device, Port);
    4.84 +  EvtChn_Unmask(Context, Port);
    4.85  
    4.86    KdPrint((__DRIVER_NAME " <-- EvtChn_Bind\n"));
    4.87  
    4.88 @@ -126,10 +127,7 @@ EvtChn_Bind(PVOID Context, evtchn_port_t
    4.89  NTSTATUS
    4.90  EvtChn_BindDpc(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    4.91  {
    4.92 -  WDFDEVICE Device = Context;
    4.93 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    4.94 -  WDF_DPC_CONFIG DpcConfig;
    4.95 -  WDF_OBJECT_ATTRIBUTES DpcObjectAttributes;
    4.96 +  PXENPCI_DEVICE_DATA xpdd = Context;
    4.97  
    4.98    KdPrint((__DRIVER_NAME " --> EvtChn_BindDpc\n"));
    4.99  
   4.100 @@ -143,16 +141,12 @@ EvtChn_BindDpc(PVOID Context, evtchn_por
   4.101    xpdd->ev_actions[Port].ServiceContext = ServiceContext;
   4.102    xpdd->ev_actions[Port].DpcFlag = TRUE;
   4.103  
   4.104 -  WDF_DPC_CONFIG_INIT(&DpcConfig, EvtChn_DpcBounce);
   4.105 -  WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&DpcObjectAttributes, EVTCHN_DEVICE_DATA);
   4.106 -  DpcObjectAttributes.ParentObject = Device;
   4.107 -  WdfDpcCreate(&DpcConfig, &DpcObjectAttributes, &xpdd->ev_actions[Port].Dpc);
   4.108 -  GetEvtChnDeviceData(xpdd->ev_actions[Port].Dpc)->Action = &xpdd->ev_actions[Port];
   4.109 +  KeInitializeDpc(&xpdd->ev_actions[Port].Dpc, EvtChn_DpcBounce, &xpdd->ev_actions[Port]);
   4.110  
   4.111    KeMemoryBarrier(); // make sure that the new service routine is only called once the context is set up
   4.112    xpdd->ev_actions[Port].ServiceRoutine = ServiceRoutine;
   4.113  
   4.114 -  EvtChn_Unmask(Device, Port);
   4.115 +  EvtChn_Unmask(Context, Port);
   4.116  
   4.117    KdPrint((__DRIVER_NAME " <-- EvtChn_BindDpc\n"));
   4.118  
   4.119 @@ -162,16 +156,15 @@ EvtChn_BindDpc(PVOID Context, evtchn_por
   4.120  NTSTATUS
   4.121  EvtChn_Unbind(PVOID Context, evtchn_port_t Port)
   4.122  {
   4.123 -  WDFDEVICE Device = Context;
   4.124 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   4.125 -
   4.126 +  PXENPCI_DEVICE_DATA xpdd = Context;
   4.127 +  
   4.128    EvtChn_Mask(Context, Port);
   4.129    xpdd->ev_actions[Port].ServiceRoutine = NULL;
   4.130    KeMemoryBarrier();
   4.131    xpdd->ev_actions[Port].ServiceContext = NULL;
   4.132  
   4.133    if (xpdd->ev_actions[Port].DpcFlag)
   4.134 -    WdfDpcCancel(xpdd->ev_actions[Port].Dpc, TRUE);
   4.135 +    KeRemoveQueueDpc(&xpdd->ev_actions[Port].Dpc);
   4.136    
   4.137    //KdPrint((__DRIVER_NAME " <-- EvtChn_UnBind\n"));
   4.138  
   4.139 @@ -179,115 +172,53 @@ EvtChn_Unbind(PVOID Context, evtchn_port
   4.140  }
   4.141  
   4.142  NTSTATUS
   4.143 -EvtChn_Mask(PVOID Context, evtchn_port_t Port)
   4.144 +EvtChn_Mask(PXENPCI_DEVICE_DATA xpdd, evtchn_port_t Port)
   4.145  {
   4.146 -  WDFDEVICE Device = Context;
   4.147 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   4.148 -  //KdPrint((__DRIVER_NAME " --> EvtChn_Mask\n"));
   4.149 -
   4.150    synch_set_bit(Port,
   4.151      (volatile xen_long_t *)&xpdd->shared_info_area->evtchn_mask[0]);
   4.152 -
   4.153 -  //KdPrint((__DRIVER_NAME " <-- EvtChn_Mask\n"));
   4.154 -
   4.155    return STATUS_SUCCESS;
   4.156  }
   4.157  
   4.158  NTSTATUS
   4.159 -EvtChn_Unmask(PVOID Context, evtchn_port_t Port)
   4.160 +EvtChn_Unmask(PXENPCI_DEVICE_DATA xpdd , evtchn_port_t Port)
   4.161  {
   4.162 -  WDFDEVICE Device = Context;
   4.163 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   4.164 -  //KdPrint((__DRIVER_NAME " --> EvtChn_Unmask\n"));
   4.165 -
   4.166    synch_clear_bit(Port,
   4.167      (volatile xen_long_t *)&xpdd->shared_info_area->evtchn_mask[0]);
   4.168 -  // should we kick off pending interrupts here too???
   4.169 -
   4.170 -  //KdPrint((__DRIVER_NAME " <-- EvtChn_Unmask\n"));
   4.171 -
   4.172    return STATUS_SUCCESS;
   4.173  }
   4.174  
   4.175  NTSTATUS
   4.176 -EvtChn_Notify(PVOID Context, evtchn_port_t Port)
   4.177 +EvtChn_Notify(PXENPCI_DEVICE_DATA xpdd, evtchn_port_t Port)
   4.178  {
   4.179    struct evtchn_send send;
   4.180  
   4.181 -  //KdPrint((__DRIVER_NAME " --> EvtChn_Notify\n"));
   4.182 -
   4.183    send.port = Port;
   4.184 -
   4.185 -  (void)HYPERVISOR_event_channel_op(Context, EVTCHNOP_send, &send);
   4.186 -
   4.187 -  //KdPrint((__DRIVER_NAME " <-- EvtChn_Notify\n"));
   4.188 -
   4.189 +  (void)HYPERVISOR_event_channel_op(xpdd, EVTCHNOP_send, &send);
   4.190    return STATUS_SUCCESS;
   4.191  }
   4.192  
   4.193  evtchn_port_t
   4.194  EvtChn_AllocUnbound(PVOID Context, domid_t Domain)
   4.195  {
   4.196 +  PXENPCI_DEVICE_DATA xpdd = Context;
   4.197    evtchn_alloc_unbound_t op;
   4.198 -
   4.199 -  //KdPrint((__DRIVER_NAME " --> AllocUnbound\n"));
   4.200 -
   4.201    op.dom = DOMID_SELF;
   4.202    op.remote_dom = Domain;
   4.203 -  HYPERVISOR_event_channel_op(Context, EVTCHNOP_alloc_unbound, &op);
   4.204 -
   4.205 -  //KdPrint((__DRIVER_NAME " <-- AllocUnbound\n"));
   4.206 -
   4.207 +  HYPERVISOR_event_channel_op(xpdd, EVTCHNOP_alloc_unbound, &op);
   4.208    return op.port;
   4.209  }
   4.210  
   4.211 -evtchn_port_t
   4.212 -EvtChn_GetXenStorePort(WDFDEVICE Device)
   4.213 +NTSTATUS
   4.214 +EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
   4.215  {
   4.216 -  evtchn_port_t Port;  
   4.217 -
   4.218 -  KdPrint((__DRIVER_NAME " --> EvtChn_GetStorePort\n"));
   4.219 -
   4.220 -  Port = (evtchn_port_t)hvm_get_parameter(Device, HVM_PARAM_STORE_EVTCHN);
   4.221 -
   4.222 -  KdPrint((__DRIVER_NAME " <-- EvtChn_GetStorePort\n"));
   4.223 -
   4.224 -  return Port;
   4.225 -}
   4.226 -
   4.227 -PVOID
   4.228 -EvtChn_GetXenStoreRingAddr(WDFDEVICE Device)
   4.229 -{
   4.230 -  PHYSICAL_ADDRESS pa_xen_store_interface;
   4.231 -  PVOID xen_store_interface;
   4.232 +  NTSTATUS status;
   4.233 +  int i;
   4.234  
   4.235 -  xen_ulong_t xen_store_mfn;
   4.236 -
   4.237 -  KdPrint((__DRIVER_NAME " --> EvtChn_GetRingAddr\n"));
   4.238 -
   4.239 -  xen_store_mfn = (xen_ulong_t)hvm_get_parameter(Device, HVM_PARAM_STORE_PFN);
   4.240 -
   4.241 -  pa_xen_store_interface.QuadPart = xen_store_mfn << PAGE_SHIFT;
   4.242 -  xen_store_interface = MmMapIoSpace(pa_xen_store_interface, PAGE_SIZE, MmCached);
   4.243 -
   4.244 -  KdPrint((__DRIVER_NAME " xen_store_mfn = %08x\n", xen_store_mfn));
   4.245 -  //KdPrint((__DRIVER_NAME " xen_store_evtchn = %08x\n", xen_store_evtchn));
   4.246 -  KdPrint((__DRIVER_NAME " xen_store_interface = %08x\n", xen_store_interface));
   4.247 -
   4.248 -  KdPrint((__DRIVER_NAME " <-- EvtChn_GetRingAddr\n"));
   4.249 -
   4.250 -  return xen_store_interface;
   4.251 -}
   4.252 -
   4.253 -NTSTATUS
   4.254 -EvtChn_Init(WDFDEVICE Device)
   4.255 -{
   4.256 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   4.257 -  int i;
   4.258 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   4.259  
   4.260    for (i = 0; i < NR_EVENTS; i++)
   4.261    {
   4.262 -    EvtChn_Mask(Device, i);
   4.263 +    EvtChn_Mask(xpdd, i);
   4.264      xpdd->ev_actions[i].ServiceRoutine = NULL;
   4.265      xpdd->ev_actions[i].ServiceContext = NULL;
   4.266      xpdd->ev_actions[i].Count = 0;
   4.267 @@ -302,7 +233,44 @@ EvtChn_Init(WDFDEVICE Device)
   4.268    {
   4.269      xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_pending = 0;
   4.270      xpdd->shared_info_area->vcpu_info[i].evtchn_pending_sel = 0;
   4.271 +    xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_mask = 1;
   4.272    }
   4.273  
   4.274 +  status = IoConnectInterrupt(
   4.275 +    &xpdd->interrupt,
   4.276 +	EvtChn_Interrupt,
   4.277 +	xpdd,
   4.278 +	NULL,
   4.279 +	xpdd->irq_vector,
   4.280 +	xpdd->irq_level,
   4.281 +	xpdd->irq_level,
   4.282 +	LevelSensitive,
   4.283 +	TRUE, /* this is a bit of a hack to make xenvbd work */
   4.284 +	xpdd->irq_affinity,
   4.285 +	FALSE);
   4.286 +  
   4.287 +  if (!NT_SUCCESS(status))
   4.288 +  {
   4.289 +    KdPrint((__DRIVER_NAME "     IoConnectInterrupt failed 0x%08x\n", status));
   4.290 +    return status;
   4.291 +  }
   4.292 +
   4.293 +  hvm_set_parameter(xpdd, HVM_PARAM_CALLBACK_IRQ, xpdd->irq_number);
   4.294 +
   4.295 +  for (i = 0; i < MAX_VIRT_CPUS; i++)
   4.296 +  {
   4.297 +    xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_mask = 0;
   4.298 +  }
   4.299 +  
   4.300 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   4.301 +
   4.302 +  return status;
   4.303 +}
   4.304 +
   4.305 +NTSTATUS
   4.306 +EvtChn_Shutdown(PXENPCI_DEVICE_DATA xpdd)
   4.307 +{
   4.308 +  UNREFERENCED_PARAMETER(xpdd);
   4.309 +
   4.310    return STATUS_SUCCESS;
   4.311  }
     5.1 --- a/xenpci/gnttbl.c	Mon Apr 28 23:07:28 2008 +1000
     5.2 +++ b/xenpci/gnttbl.c	Fri May 02 20:54:46 2008 +1000
     5.3 @@ -20,9 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fi
     5.4  #include "xenpci.h"
     5.5  
     5.6  VOID
     5.7 -GntTbl_PutRef(WDFDEVICE Device, grant_ref_t ref)
     5.8 +GntTbl_PutRef(PVOID Context, grant_ref_t ref)
     5.9  {
    5.10 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    5.11 +  PXENPCI_DEVICE_DATA xpdd = Context;
    5.12    KIRQL OldIrql;
    5.13  
    5.14    KeAcquireSpinLock(&xpdd->grant_lock, &OldIrql);
    5.15 @@ -32,9 +32,9 @@ GntTbl_PutRef(WDFDEVICE Device, grant_re
    5.16  }
    5.17  
    5.18  grant_ref_t
    5.19 -GntTbl_GetRef(WDFDEVICE Device)
    5.20 +GntTbl_GetRef(PVOID Context)
    5.21  {
    5.22 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    5.23 +  PXENPCI_DEVICE_DATA xpdd = Context;
    5.24    unsigned int ref;
    5.25    KIRQL OldIrql;
    5.26  
    5.27 @@ -47,22 +47,19 @@ GntTbl_GetRef(WDFDEVICE Device)
    5.28  }
    5.29  
    5.30  static int 
    5.31 -GntTbl_Map(WDFDEVICE Device, unsigned int start_idx, unsigned int end_idx)
    5.32 +GntTbl_Map(PVOID Context, unsigned int start_idx, unsigned int end_idx)
    5.33  {
    5.34 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    5.35 +  PXENPCI_DEVICE_DATA xpdd = Context;
    5.36    struct xen_add_to_physmap xatp;
    5.37    unsigned int i = end_idx;
    5.38  
    5.39 -  //KdPrint((__DRIVER_NAME " --> GntTbl_Init\n"));
    5.40 -  /* Loop backwards, so that the first hypercall has the largest index,
    5.41 -   * ensuring that the table will grow only once.
    5.42 -   */
    5.43 +  /* Loop backwards, so that the first hypercall has the largest index,  ensuring that the table will grow only once.  */
    5.44    do {
    5.45      xatp.domid = DOMID_SELF;
    5.46      xatp.idx = i;
    5.47      xatp.space = XENMAPSPACE_grant_table;
    5.48      xatp.gpfn = (xen_pfn_t)(xpdd->gnttab_table_physical.QuadPart >> PAGE_SHIFT) + i;
    5.49 -    if (HYPERVISOR_memory_op(Device, XENMEM_add_to_physmap, &xatp))
    5.50 +    if (HYPERVISOR_memory_op(xpdd, XENMEM_add_to_physmap, &xatp))
    5.51      {
    5.52        KdPrint((__DRIVER_NAME "     ***ERROR MAPPING FRAME***\n"));
    5.53      }
    5.54 @@ -71,50 +68,22 @@ GntTbl_Map(WDFDEVICE Device, unsigned in
    5.55    return 0;
    5.56  }
    5.57  
    5.58 -VOID
    5.59 -GntTbl_Init(WDFDEVICE Device)
    5.60 -{
    5.61 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    5.62 -  int i;
    5.63 -
    5.64 -  //KdPrint((__DRIVER_NAME " --> GntTbl_Init\n"));
    5.65 -
    5.66 -  
    5.67 -  KeInitializeSpinLock(&xpdd->grant_lock);
    5.68 -
    5.69 -  for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
    5.70 -    GntTbl_PutRef(Device, i);
    5.71 -
    5.72 -  xpdd->gnttab_table_physical = XenPCI_AllocMMIO(Device,
    5.73 -    PAGE_SIZE * NR_GRANT_FRAMES);
    5.74 -  xpdd->gnttab_table = MmMapIoSpace(xpdd->gnttab_table_physical,
    5.75 -    PAGE_SIZE * NR_GRANT_FRAMES, MmCached);
    5.76 -  if (!xpdd->gnttab_table)
    5.77 -  {
    5.78 -    KdPrint((__DRIVER_NAME "     Error Mapping Grant Table Shared Memory\n"));
    5.79 -    return;
    5.80 -  }
    5.81 -  GntTbl_Map(Device, 0, NR_GRANT_FRAMES - 1);
    5.82 -
    5.83 -  //KdPrint((__DRIVER_NAME " <-- GntTbl_Init table mapped at %p\n", gnttab_table));
    5.84 -}
    5.85 -
    5.86  grant_ref_t
    5.87  GntTbl_GrantAccess(
    5.88 -  WDFDEVICE Device,
    5.89 +  PVOID Context,
    5.90    domid_t domid,
    5.91    uint32_t frame,
    5.92    int readonly,
    5.93    grant_ref_t ref)
    5.94  {
    5.95 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    5.96 +  PXENPCI_DEVICE_DATA xpdd = Context;
    5.97  
    5.98    //KdPrint((__DRIVER_NAME " --> GntTbl_GrantAccess\n"));
    5.99  
   5.100    //KdPrint((__DRIVER_NAME "     Granting access to frame %08x\n", frame));
   5.101  
   5.102    if (ref == 0)
   5.103 -    ref = GntTbl_GetRef(Device);
   5.104 +    ref = GntTbl_GetRef(Context);
   5.105    xpdd->gnttab_table[ref].frame = frame;
   5.106    xpdd->gnttab_table[ref].domid = domid;
   5.107  
   5.108 @@ -132,11 +101,11 @@ GntTbl_GrantAccess(
   5.109  
   5.110  BOOLEAN
   5.111  GntTbl_EndAccess(
   5.112 -  WDFDEVICE Device,
   5.113 +  PVOID Context,
   5.114    grant_ref_t ref,
   5.115    BOOLEAN keepref)
   5.116  {
   5.117 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   5.118 +  PXENPCI_DEVICE_DATA xpdd = Context;
   5.119    unsigned short flags, nflags;
   5.120  
   5.121    //KdPrint((__DRIVER_NAME " --> GntTbl_EndAccess\n"));
   5.122 @@ -152,7 +121,33 @@ GntTbl_EndAccess(
   5.123      (volatile SHORT *)&xpdd->gnttab_table[ref].flags, 0, flags)) != flags);
   5.124  
   5.125    if (!keepref)
   5.126 -    GntTbl_PutRef(Device, ref);
   5.127 +    GntTbl_PutRef(Context, ref);
   5.128    //KdPrint((__DRIVER_NAME " <-- GntTbl_EndAccess\n"));
   5.129    return TRUE;
   5.130  }
   5.131 +
   5.132 +VOID
   5.133 +GntTbl_Init(PXENPCI_DEVICE_DATA xpdd)
   5.134 +{
   5.135 +  int i;
   5.136 +
   5.137 +  //KdPrint((__DRIVER_NAME " --> GntTbl_Init\n"));
   5.138 +  
   5.139 +  KeInitializeSpinLock(&xpdd->grant_lock);
   5.140 +
   5.141 +  for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
   5.142 +    GntTbl_PutRef(xpdd, i);
   5.143 +
   5.144 +  xpdd->gnttab_table_physical = XenPci_AllocMMIO(xpdd,
   5.145 +    PAGE_SIZE * NR_GRANT_FRAMES);
   5.146 +  xpdd->gnttab_table = MmMapIoSpace(xpdd->gnttab_table_physical,
   5.147 +    PAGE_SIZE * NR_GRANT_FRAMES, MmCached);
   5.148 +  if (!xpdd->gnttab_table)
   5.149 +  {
   5.150 +    KdPrint((__DRIVER_NAME "     Error Mapping Grant Table Shared Memory\n"));
   5.151 +    return;
   5.152 +  }
   5.153 +  GntTbl_Map(xpdd, 0, NR_GRANT_FRAMES - 1);
   5.154 +
   5.155 +  //KdPrint((__DRIVER_NAME " <-- GntTbl_Init table mapped at %p\n", gnttab_table));
   5.156 +}
     6.1 --- a/xenpci/hypercall_x86.h	Mon Apr 28 23:07:28 2008 +1000
     6.2 +++ b/xenpci/hypercall_x86.h	Fri May 02 20:54:46 2008 +1000
     6.3 @@ -18,9 +18,9 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  */
     6.5  
     6.6  static __inline int
     6.7 -HYPERVISOR_memory_op(WDFDEVICE Device, int cmd, void *arg)
     6.8 +HYPERVISOR_memory_op(PXENPCI_DEVICE_DATA xpdd, int cmd, void *arg)
     6.9  {
    6.10 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.11 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.12    long __res;
    6.13    __asm {
    6.14      mov ebx, cmd
    6.15 @@ -34,9 +34,9 @@ HYPERVISOR_memory_op(WDFDEVICE Device, i
    6.16  }
    6.17  
    6.18  static __inline int
    6.19 -HYPERVISOR_sched_op(WDFDEVICE Device, int cmd, void *arg)
    6.20 +HYPERVISOR_sched_op(PXENPCI_DEVICE_DATA xpdd, int cmd, void *arg)
    6.21  {
    6.22 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.23 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.24    long __res;
    6.25    __asm {
    6.26      mov ebx, cmd
    6.27 @@ -50,9 +50,9 @@ HYPERVISOR_sched_op(WDFDEVICE Device, in
    6.28  }
    6.29  
    6.30  static __inline int
    6.31 -HYPERVISOR_xen_version(WDFDEVICE Device, int cmd, void *arg)
    6.32 +HYPERVISOR_xen_version(PXENPCI_DEVICE_DATA xpdd, int cmd, void *arg)
    6.33  {
    6.34 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.35 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.36    long __res;
    6.37    __asm {
    6.38      mov ebx, cmd
    6.39 @@ -66,9 +66,9 @@ HYPERVISOR_xen_version(WDFDEVICE Device,
    6.40  }
    6.41  
    6.42  static __inline int
    6.43 -HYPERVISOR_grant_table_op(WDFDEVICE Device, int cmd, void *uop, unsigned int count)
    6.44 +HYPERVISOR_grant_table_op(PXENPCI_DEVICE_DATA xpdd, int cmd, void *uop, unsigned int count)
    6.45  {
    6.46 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.47 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.48    long __res;
    6.49    __asm {
    6.50      mov ebx, cmd
    6.51 @@ -83,9 +83,9 @@ HYPERVISOR_grant_table_op(WDFDEVICE Devi
    6.52  }
    6.53  
    6.54  static __inline int
    6.55 -HYPERVISOR_mmu_update(WDFDEVICE Device, mmu_update_t *req, int count, int *success_count, domid_t domid)
    6.56 +HYPERVISOR_mmu_update(PXENPCI_DEVICE_DATA xpdd, mmu_update_t *req, int count, int *success_count, domid_t domid)
    6.57  {
    6.58 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.59 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.60    long __res;
    6.61    long _domid = (long)domid;
    6.62    __asm {
    6.63 @@ -102,9 +102,9 @@ HYPERVISOR_mmu_update(WDFDEVICE Device, 
    6.64  }
    6.65  
    6.66  static __inline int
    6.67 -HYPERVISOR_console_io(WDFDEVICE Device, int cmd, int count, char *string)
    6.68 +HYPERVISOR_console_io(PXENPCI_DEVICE_DATA xpdd, int cmd, int count, char *string)
    6.69  {
    6.70 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.71 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.72    long __res;
    6.73    __asm {
    6.74      mov ebx, cmd
    6.75 @@ -119,9 +119,9 @@ HYPERVISOR_console_io(WDFDEVICE Device, 
    6.76  }
    6.77  
    6.78  static __inline int
    6.79 -HYPERVISOR_hvm_op(WDFDEVICE Device, int op, struct xen_hvm_param *arg)
    6.80 +HYPERVISOR_hvm_op(PXENPCI_DEVICE_DATA xpdd, int op, struct xen_hvm_param *arg)
    6.81  {
    6.82 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.83 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.84    long __res;
    6.85    __asm {
    6.86      mov ebx, op
    6.87 @@ -135,9 +135,9 @@ HYPERVISOR_hvm_op(WDFDEVICE Device, int 
    6.88  }
    6.89  
    6.90  static __inline int
    6.91 -HYPERVISOR_event_channel_op(WDFDEVICE Device, int cmd, void *op)
    6.92 +HYPERVISOR_event_channel_op(PXENPCI_DEVICE_DATA xpdd, int cmd, void *op)
    6.93  {
    6.94 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    6.95 +  char *hypercall_stubs = xpdd->hypercall_stubs;
    6.96    long __res;
    6.97    __asm {
    6.98      mov ebx, cmd
    6.99 @@ -150,38 +150,3 @@ HYPERVISOR_event_channel_op(WDFDEVICE De
   6.100    return __res;
   6.101  }
   6.102  
   6.103 -static __inline ULONGLONG
   6.104 -hvm_get_parameter(WDFDEVICE Device, int hvm_param)
   6.105 -{
   6.106 -  struct xen_hvm_param a;
   6.107 -  int retval;
   6.108 -
   6.109 -  KdPrint((__DRIVER_NAME " --> hvm_get_parameter\n"));
   6.110 -  a.domid = DOMID_SELF;
   6.111 -  a.index = hvm_param;
   6.112 -  //a.value = via;
   6.113 -  retval = HYPERVISOR_hvm_op(Device, HVMOP_get_param, &a);
   6.114 -  KdPrint((__DRIVER_NAME " hvm_get_parameter retval = %d\n", retval));
   6.115 -  KdPrint((__DRIVER_NAME " <-- hvm_get_parameter\n"));
   6.116 -  return a.value;
   6.117 -}
   6.118 -
   6.119 -static __inline int
   6.120 -HYPERVISOR_shutdown(WDFDEVICE Device, unsigned int reason)
   6.121 -{
   6.122 -  struct sched_shutdown ss;
   6.123 -  int retval;
   6.124 -
   6.125 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.126 -
   6.127 -  ss.reason = reason;
   6.128 -
   6.129 -  KdPrint((__DRIVER_NAME "     A\n"));
   6.130 -
   6.131 -  retval = HYPERVISOR_sched_op(Device, SCHEDOP_shutdown, &ss);
   6.132 -
   6.133 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.134 -
   6.135 -  return retval;
   6.136 -}
   6.137 -
     7.1 --- a/xenpci/makefile.inc	Mon Apr 28 23:07:28 2008 +1000
     7.2 +++ b/xenpci/makefile.inc	Fri May 02 20:54:46 2008 +1000
     7.3 @@ -1,5 +1,5 @@
     7.4  _LNG=$(LANGUAGE)
     7.5 -STAMP=stampinf -f $@ -a $(_BUILDARCH) -d * -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) -v $(VERSION)
     7.6 +STAMP=stampinf -f $@ -a $(_BUILDARCH) -d * -v $(VERSION)
     7.7  
     7.8  ..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf: $(INF_NAME).inx sources ..\common.inc
     7.9      copy $(@B).inx $@
     8.1 --- a/xenpci/sources	Mon Apr 28 23:07:28 2008 +1000
     8.2 +++ b/xenpci/sources	Fri May 02 20:54:46 2008 +1000
     8.3 @@ -1,7 +1,9 @@
     8.4  !INCLUDE ..\common.inc
     8.5 +!UNDEF KMDF_VERSION
     8.6 +!UNDEF KMDF_VERSION_MAJOR
     8.7  TARGETNAME=xenpci
     8.8  TARGETTYPE=DRIVER
     8.9  INF_NAME=$(TARGETNAME)
    8.10  MISCFILES=..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf
    8.11  AMD64_SOURCES=hypercall.asm
    8.12 -SOURCES=xenpci.c xenbus.c gnttbl.c evtchn.c
    8.13 +SOURCES=xenpci.c evtchn.c gnttbl.c xenbus.c
    8.14 \ No newline at end of file
     9.1 --- a/xenpci/xenbus.c	Mon Apr 28 23:07:28 2008 +1000
     9.2 +++ b/xenpci/xenbus.c	Fri May 02 20:54:46 2008 +1000
     9.3 @@ -36,10 +36,8 @@ XenBus_WatchThreadProc(PVOID StartContex
     9.4  static BOOLEAN
     9.5  XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext);
     9.6  
     9.7 -static int allocate_xenbus_id(WDFDEVICE Device)
     9.8 +static int allocate_xenbus_id(PXENPCI_DEVICE_DATA xpdd)
     9.9  {
    9.10 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);  
    9.11 -
    9.12    static int probe;
    9.13    int o_probe;
    9.14  
    9.15 @@ -75,10 +73,8 @@ static int allocate_xenbus_id(WDFDEVICE 
    9.16    return o_probe;
    9.17  }
    9.18  
    9.19 -static void release_xenbus_id(WDFDEVICE Device, int id)
    9.20 +static void release_xenbus_id(PXENPCI_DEVICE_DATA xpdd, int id)
    9.21  {
    9.22 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);  
    9.23 -
    9.24  //    BUG_ON(!req_info[id].in_use);
    9.25  //    spin_lock(&req_lock);
    9.26      xpdd->req_info[id].In_Use = 0;
    9.27 @@ -123,14 +119,13 @@ static void memcpy_from_ring(const void 
    9.28  }
    9.29  
    9.30  static void xb_write(
    9.31 -  WDFDEVICE Device,
    9.32 +  PXENPCI_DEVICE_DATA xpdd,
    9.33    int type,
    9.34    int req_id,
    9.35    xenbus_transaction_t trans_id,
    9.36    const struct write_req *req,
    9.37    int nr_reqs)
    9.38  {
    9.39 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    9.40    XENSTORE_RING_IDX prod;
    9.41    int r;
    9.42    size_t len = 0;
    9.43 @@ -204,31 +199,30 @@ static void xb_write(
    9.44    //KdPrint((__DRIVER_NAME " prod = %08x\n", xen_store_interface->req_prod));
    9.45  
    9.46    /* Send evtchn to notify remote */
    9.47 -  EvtChn_Notify(Device, xpdd->xen_store_evtchn);
    9.48 +  EvtChn_Notify(xpdd, xpdd->xen_store_evtchn);
    9.49  
    9.50  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    9.51  }
    9.52  
    9.53  static struct xsd_sockmsg *
    9.54  xenbus_msg_reply(
    9.55 -  WDFDEVICE Device,
    9.56 +  PXENPCI_DEVICE_DATA xpdd,
    9.57    int type,
    9.58    xenbus_transaction_t trans,
    9.59    struct write_req *io,
    9.60    int nr_reqs)
    9.61  {
    9.62 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    9.63    int id;
    9.64  
    9.65  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    9.66  
    9.67 -  id = allocate_xenbus_id(Device);
    9.68 +  id = allocate_xenbus_id(xpdd);
    9.69  
    9.70 -  xb_write(Device, type, id, trans, io, nr_reqs);
    9.71 +  xb_write(xpdd, type, id, trans, io, nr_reqs);
    9.72  
    9.73    KeWaitForSingleObject(&xpdd->req_info[id].WaitEvent, Executive, KernelMode, FALSE, NULL);
    9.74  
    9.75 -  release_xenbus_id(Device, id);
    9.76 +  release_xenbus_id(xpdd, id);
    9.77  
    9.78  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    9.79  
    9.80 @@ -242,7 +236,7 @@ XenBus_Read(
    9.81    const char *path,
    9.82    char **value)
    9.83  {
    9.84 -  WDFDEVICE Device = Context;
    9.85 +  PXENPCI_DEVICE_DATA xpdd = Context;
    9.86    struct write_req req[] = { {path, (ULONG)strlen(path) + 1} };
    9.87    struct xsd_sockmsg *rep;
    9.88    char *res;
    9.89 @@ -250,7 +244,7 @@ XenBus_Read(
    9.90  
    9.91  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    9.92  
    9.93 -  rep = xenbus_msg_reply(Device, XS_READ, xbt, req, ARRAY_SIZE(req));
    9.94 +  rep = xenbus_msg_reply(xpdd, XS_READ, xbt, req, ARRAY_SIZE(req));
    9.95    msg = errmsg(rep);
    9.96    if (msg) {
    9.97      *value = NULL;
    9.98 @@ -274,7 +268,7 @@ XenBus_Write(
    9.99    const char *path,
   9.100    const char *value)
   9.101  {
   9.102 -  WDFDEVICE Device = Context;
   9.103 +  PXENPCI_DEVICE_DATA xpdd = Context;
   9.104    struct write_req req[] = {
   9.105      {path, (ULONG)strlen(path) + 1},
   9.106      {value, (ULONG)strlen(value) + 1},
   9.107 @@ -284,7 +278,7 @@ XenBus_Write(
   9.108  
   9.109  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   9.110  
   9.111 -  rep = xenbus_msg_reply(Device, XS_WRITE, xbt, req, ARRAY_SIZE(req));
   9.112 +  rep = xenbus_msg_reply(xpdd, XS_WRITE, xbt, req, ARRAY_SIZE(req));
   9.113    msg = errmsg(rep);
   9.114    if (msg)
   9.115      return msg;
   9.116 @@ -296,9 +290,10 @@ XenBus_Write(
   9.117  }
   9.118  
   9.119  NTSTATUS
   9.120 -XenBus_Init(WDFDEVICE Device)
   9.121 +XenBus_Init(PXENPCI_DEVICE_DATA xpdd)
   9.122  {
   9.123 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.124 +  PHYSICAL_ADDRESS pa_xen_store_interface;
   9.125 +  xen_ulong_t xen_store_mfn;
   9.126    NTSTATUS Status;
   9.127    int i;
   9.128      
   9.129 @@ -306,8 +301,11 @@ XenBus_Init(WDFDEVICE Device)
   9.130  
   9.131    KeInitializeSpinLock(&xpdd->WatchLock);
   9.132  
   9.133 -  xpdd->xen_store_evtchn = EvtChn_GetXenStorePort(Device);
   9.134 -  xpdd->xen_store_interface = EvtChn_GetXenStoreRingAddr(Device);
   9.135 +  xpdd->xen_store_evtchn = (evtchn_port_t)hvm_get_parameter(xpdd, HVM_PARAM_STORE_EVTCHN);
   9.136 +
   9.137 +  xen_store_mfn = (xen_ulong_t)hvm_get_parameter(xpdd, HVM_PARAM_STORE_PFN);
   9.138 +  pa_xen_store_interface.QuadPart = xen_store_mfn << PAGE_SHIFT;
   9.139 +  xpdd->xen_store_interface = MmMapIoSpace(pa_xen_store_interface, PAGE_SIZE, MmCached);
   9.140  
   9.141    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
   9.142    {
   9.143 @@ -320,33 +318,43 @@ XenBus_Init(WDFDEVICE Device)
   9.144    KeInitializeEvent(&xpdd->XenBus_WatchThreadEvent, SynchronizationEvent, FALSE);
   9.145    xpdd->XenBus_ShuttingDown = FALSE;
   9.146  
   9.147 -  Status = PsCreateSystemThread(&xpdd->XenBus_ReadThreadHandle, THREAD_ALL_ACCESS, NULL, NULL, NULL, XenBus_ReadThreadProc, Device);
   9.148 +  Status = PsCreateSystemThread(&xpdd->XenBus_ReadThreadHandle, THREAD_ALL_ACCESS, NULL, NULL, NULL, XenBus_ReadThreadProc, xpdd);
   9.149    if (!NT_SUCCESS(Status))
   9.150    {
   9.151      KdPrint((__DRIVER_NAME " Could not start read thread\n"));
   9.152      return STATUS_UNSUCCESSFUL;
   9.153    }
   9.154  
   9.155 -  Status = PsCreateSystemThread(&xpdd->XenBus_WatchThreadHandle, THREAD_ALL_ACCESS, NULL, NULL, NULL, XenBus_WatchThreadProc, Device);
   9.156 +  Status = PsCreateSystemThread(&xpdd->XenBus_WatchThreadHandle, THREAD_ALL_ACCESS, NULL, NULL, NULL, XenBus_WatchThreadProc, xpdd);
   9.157    if (!NT_SUCCESS(Status))
   9.158    {
   9.159      KdPrint((__DRIVER_NAME " Could not start watch thread\n"));
   9.160      return STATUS_UNSUCCESSFUL;
   9.161    }
   9.162  
   9.163 +  EvtChn_BindDpc(xpdd, xpdd->xen_store_evtchn, XenBus_Interrupt, xpdd);
   9.164 +
   9.165    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.166  
   9.167    return STATUS_SUCCESS;
   9.168  }
   9.169  
   9.170  NTSTATUS
   9.171 -XenBus_Start(WDFDEVICE Device)
   9.172 +XenBus_Stop(PXENPCI_DEVICE_DATA xpdd)
   9.173  {
   9.174 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.175 +  int i;
   9.176  
   9.177    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   9.178  
   9.179 -  EvtChn_BindDpc(Device, xpdd->xen_store_evtchn, XenBus_Interrupt, Device);
   9.180 +  for (i = 0; i < MAX_WATCH_ENTRIES; i++)
   9.181 +  {
   9.182 +    if (xpdd->XenBus_WatchEntries[i].Active)
   9.183 +      XenBus_RemWatch(xpdd, XBT_NIL, xpdd->XenBus_WatchEntries[i].Path,
   9.184 +        xpdd->XenBus_WatchEntries[i].ServiceRoutine,
   9.185 +        xpdd->XenBus_WatchEntries[i].ServiceContext);
   9.186 +  }
   9.187 +
   9.188 +  EvtChn_Unbind(xpdd, xpdd->xen_store_evtchn);
   9.189  
   9.190    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.191  
   9.192 @@ -354,32 +362,8 @@ XenBus_Start(WDFDEVICE Device)
   9.193  }
   9.194  
   9.195  NTSTATUS
   9.196 -XenBus_Stop(WDFDEVICE Device)
   9.197 +XenBus_Close(PXENPCI_DEVICE_DATA xpdd)
   9.198  {
   9.199 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.200 -  int i;
   9.201 -
   9.202 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   9.203 -
   9.204 -  for (i = 0; i < MAX_WATCH_ENTRIES; i++)
   9.205 -  {
   9.206 -    if (xpdd->XenBus_WatchEntries[i].Active)
   9.207 -      XenBus_RemWatch(Device, XBT_NIL, xpdd->XenBus_WatchEntries[i].Path,
   9.208 -        xpdd->XenBus_WatchEntries[i].ServiceRoutine,
   9.209 -        xpdd->XenBus_WatchEntries[i].ServiceContext);
   9.210 -  }
   9.211 -
   9.212 -  EvtChn_Unbind(Device, xpdd->xen_store_evtchn);
   9.213 -
   9.214 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.215 -
   9.216 -  return STATUS_SUCCESS;
   9.217 -}
   9.218 -
   9.219 -NTSTATUS
   9.220 -XenBus_Close(WDFDEVICE Device)
   9.221 -{
   9.222 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.223    //KWAIT_BLOCK WaitBlockArray[2];
   9.224    PVOID WaitArray[2];
   9.225  
   9.226 @@ -408,7 +392,7 @@ XenBus_List(
   9.227    const char *pre,
   9.228    char ***contents)
   9.229  {
   9.230 -  WDFDEVICE Device = Context;
   9.231 +  PXENPCI_DEVICE_DATA xpdd = Context;
   9.232    struct xsd_sockmsg *reply, *repmsg;
   9.233    struct write_req req[] = { { pre, (ULONG)strlen(pre)+1 } };
   9.234    ULONG nr_elems, x, i;
   9.235 @@ -417,7 +401,7 @@ XenBus_List(
   9.236  
   9.237  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   9.238  
   9.239 -  repmsg = xenbus_msg_reply(Device, XS_DIRECTORY, xbt, req, ARRAY_SIZE(req));
   9.240 +  repmsg = xenbus_msg_reply(xpdd, XS_DIRECTORY, xbt, req, ARRAY_SIZE(req));
   9.241    msg = errmsg(repmsg);
   9.242    if (msg)
   9.243    {
   9.244 @@ -453,8 +437,7 @@ XenBus_ReadThreadProc(PVOID StartContext
   9.245    struct xsd_sockmsg msg;
   9.246    char *payload;
   9.247    char *path, *token;
   9.248 -  WDFDEVICE Device = StartContext;
   9.249 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.250 +  PXENPCI_DEVICE_DATA xpdd = StartContext;
   9.251  
   9.252    for(;;)
   9.253    {
   9.254 @@ -464,7 +447,7 @@ XenBus_ReadThreadProc(PVOID StartContext
   9.255        KdPrint((__DRIVER_NAME "     Shutdown detected in ReadThreadProc\n"));
   9.256        PsTerminateSystemThread(0);
   9.257      }
   9.258 -    //KdPrint((__DRIVER_NAME "     ReadThread Woken (Count = %d)\n", ReadThreadWaitCount++));
   9.259 +    KdPrint((__DRIVER_NAME "     ReadThread Woken\n"));
   9.260      while (xpdd->xen_store_interface->rsp_prod != xpdd->xen_store_interface->rsp_cons)
   9.261      {
   9.262        //KdPrint((__DRIVER_NAME "     a - Rsp_cons %d, rsp_prod %d.\n", xen_store_interface->rsp_cons, xen_store_interface->rsp_prod));
   9.263 @@ -529,8 +512,7 @@ XenBus_WatchThreadProc(PVOID StartContex
   9.264  {
   9.265    int index;
   9.266    PXENBUS_WATCH_ENTRY entry;
   9.267 -  WDFDEVICE Device = StartContext;
   9.268 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.269 +  PXENPCI_DEVICE_DATA xpdd = StartContext;
   9.270    KIRQL OldIrql;
   9.271  
   9.272    for(;;)
   9.273 @@ -581,8 +563,7 @@ XenBus_AddWatch(
   9.274    PXENBUS_WATCH_CALLBACK ServiceRoutine,
   9.275    PVOID ServiceContext)
   9.276  {
   9.277 -  WDFDEVICE Device = Context;
   9.278 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.279 +  PXENPCI_DEVICE_DATA xpdd = Context;
   9.280    struct xsd_sockmsg *rep;
   9.281    char *msg;
   9.282    int i;
   9.283 @@ -626,7 +607,7 @@ XenBus_AddWatch(
   9.284    req[1].data = Token;
   9.285    req[1].len = (ULONG)strlen(Token) + 1;
   9.286  
   9.287 -  rep = xenbus_msg_reply(Device, XS_WATCH, xbt, req, ARRAY_SIZE(req));
   9.288 +  rep = xenbus_msg_reply(xpdd, XS_WATCH, xbt, req, ARRAY_SIZE(req));
   9.289  
   9.290    msg = errmsg(rep);
   9.291    if (msg)
   9.292 @@ -650,8 +631,7 @@ XenBus_RemWatch(
   9.293    PXENBUS_WATCH_CALLBACK ServiceRoutine,
   9.294    PVOID ServiceContext)
   9.295  {
   9.296 -  WDFDEVICE Device = Context;
   9.297 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.298 +  PXENPCI_DEVICE_DATA xpdd = Context;
   9.299    struct xsd_sockmsg *rep;
   9.300    char *msg;
   9.301    int i;
   9.302 @@ -706,7 +686,7 @@ XenBus_RemWatch(
   9.303    req[1].data = Token;
   9.304    req[1].len = (ULONG)strlen(Token) + 1;
   9.305  
   9.306 -  rep = xenbus_msg_reply(Device, XS_UNWATCH, xbt, req, ARRAY_SIZE(req));
   9.307 +  rep = xenbus_msg_reply(xpdd, XS_UNWATCH, xbt, req, ARRAY_SIZE(req));
   9.308  
   9.309    msg = errmsg(rep);
   9.310    if (msg)
   9.311 @@ -725,7 +705,7 @@ XenBus_RemWatch(
   9.312  char *
   9.313  XenBus_StartTransaction(PVOID Context, xenbus_transaction_t *xbt)
   9.314  {
   9.315 -  WDFDEVICE Device = Context;
   9.316 +  PXENPCI_DEVICE_DATA xpdd = Context;
   9.317    /* xenstored becomes angry if you send a length 0 message, so just
   9.318       shove a nul terminator on the end */
   9.319    struct write_req req = { "", 1};
   9.320 @@ -734,7 +714,7 @@ XenBus_StartTransaction(PVOID Context, x
   9.321  
   9.322  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   9.323  
   9.324 -  rep = xenbus_msg_reply(Device, XS_TRANSACTION_START, 0, &req, 1);
   9.325 +  rep = xenbus_msg_reply(xpdd, XS_TRANSACTION_START, 0, &req, 1);
   9.326    err = errmsg(rep);
   9.327    if (err)
   9.328      return err;
   9.329 @@ -754,7 +734,7 @@ XenBus_EndTransaction(
   9.330    int abort,
   9.331    int *retry)
   9.332  {
   9.333 -  WDFDEVICE Device = Context;
   9.334 +  PXENPCI_DEVICE_DATA xpdd = Context;
   9.335    struct xsd_sockmsg *rep;
   9.336    struct write_req req;
   9.337    char *err;
   9.338 @@ -765,7 +745,7 @@ XenBus_EndTransaction(
   9.339  
   9.340    req.data = abort ? "F" : "T";
   9.341    req.len = 2;
   9.342 -  rep = xenbus_msg_reply(Device, XS_TRANSACTION_END, t, &req, 1);
   9.343 +  rep = xenbus_msg_reply(xpdd, XS_TRANSACTION_END, t, &req, 1);
   9.344    err = errmsg(rep);
   9.345    if (err) {
   9.346      if (!strcmp(err, "EAGAIN")) {
   9.347 @@ -786,8 +766,7 @@ XenBus_EndTransaction(
   9.348  static BOOLEAN
   9.349  XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext)
   9.350  {
   9.351 -  WDFDEVICE Device = ServiceContext;
   9.352 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
   9.353 +  PXENPCI_DEVICE_DATA xpdd = ServiceContext;
   9.354  
   9.355    UNREFERENCED_PARAMETER(Interrupt);
   9.356  
   9.357 @@ -808,7 +787,7 @@ XenBus_Printf(
   9.358    const char *fmt,
   9.359    ...)
   9.360  {
   9.361 -  WDFDEVICE Device = Context;
   9.362 +  PXENPCI_DEVICE_DATA xpdd = Context;
   9.363    va_list ap;
   9.364    char buf[512];
   9.365    char *retval;
   9.366 @@ -818,7 +797,7 @@ XenBus_Printf(
   9.367    va_start(ap, fmt);
   9.368    RtlStringCbVPrintfA(buf, ARRAY_SIZE(buf), fmt, ap);
   9.369    va_end(ap);
   9.370 -  retval = XenBus_Write(Device, xbt, path, buf);
   9.371 +  retval = XenBus_Write(xpdd, xbt, path, buf);
   9.372  
   9.373  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.374  
    10.1 --- a/xenpci/xenpci.c	Mon Apr 28 23:07:28 2008 +1000
    10.2 +++ b/xenpci/xenpci.c	Fri May 02 20:54:46 2008 +1000
    10.3 @@ -26,7 +26,11 @@ Foundation, Inc., 51 Franklin Street, Fi
    10.4  
    10.5  DRIVER_INITIALIZE DriverEntry;
    10.6  static NTSTATUS
    10.7 -XenPCI_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit);
    10.8 +XenPci_AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject);
    10.9 +static NTSTATUS
   10.10 +XenPci_Pnp(PDEVICE_OBJECT device_object, PIRP irp);
   10.11 +
   10.12 +#if 0
   10.13  static NTSTATUS
   10.14  XenPCI_PrepareHardware(WDFDEVICE hDevice, WDFCMRESLIST Resources, WDFCMRESLIST ResourcesTranslated);
   10.15  static NTSTATUS
   10.16 @@ -57,6 +61,7 @@ static NTSTATUS
   10.17  XenPCI_FilterAddResourceRequirements(WDFDEVICE Device, WDFIORESREQLIST RequirementsList);
   10.18  static NTSTATUS
   10.19  XenPCI_RemoveAddedResources(WDFDEVICE Device, WDFCMRESLIST ResourcesRaw, WDFCMRESLIST ResourcesTranslated);
   10.20 +#endif
   10.21  
   10.22  static VOID
   10.23  XenBus_SysrqHandler(char *Path, PVOID Data);
   10.24 @@ -69,7 +74,7 @@ XenPCI_XenBusWatchHandler(char *Path, PV
   10.25  
   10.26  #ifdef ALLOC_PRAGMA
   10.27  #pragma alloc_text (INIT, DriverEntry)
   10.28 -#pragma alloc_text (PAGE, XenPCI_AddDevice)
   10.29 +#pragma alloc_text (PAGE, XenPci_AddDevice)
   10.30  #endif
   10.31  
   10.32  /* Global (driver-wide) variables */
   10.33 @@ -90,30 +95,68 @@ static KSPIN_LOCK ShutdownMsgLock;
   10.34  CM_PARTIAL_RESOURCE_DESCRIPTOR InterruptRaw;
   10.35  CM_PARTIAL_RESOURCE_DESCRIPTOR InterruptTranslated;
   10.36  
   10.37 +static NTSTATUS
   10.38 +XenPci_Power(PDEVICE_OBJECT device_object, PIRP irp)
   10.39 +{
   10.40 +  NTSTATUS status;
   10.41 +  PIO_STACK_LOCATION stack;
   10.42 +  PXENPCI_DEVICE_DATA xpdd;
   10.43 +
   10.44 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   10.45 +
   10.46 +  xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
   10.47 +  stack = IoGetCurrentIrpStackLocation(irp);
   10.48 +  IoSkipCurrentIrpStackLocation(irp);
   10.49 +  status = PoCallDriver(xpdd->lower_do, irp);
   10.50 +
   10.51 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   10.52 +
   10.53 +  return status;
   10.54 +}
   10.55 +
   10.56 +static NTSTATUS
   10.57 +XenPci_Dummy(PDEVICE_OBJECT device_object, PIRP irp)
   10.58 +{
   10.59 +  NTSTATUS status;
   10.60 +  PIO_STACK_LOCATION stack;
   10.61 +  PXENPCI_DEVICE_DATA xpdd;
   10.62 +
   10.63 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   10.64 +
   10.65 +  xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
   10.66 +  stack = IoGetCurrentIrpStackLocation(irp);
   10.67 +  IoSkipCurrentIrpStackLocation(irp);
   10.68 +  status = IoCallDriver(xpdd->lower_do, irp);
   10.69 +
   10.70 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   10.71 +
   10.72 +  return status;
   10.73 +}
   10.74 +
   10.75  NTSTATUS
   10.76  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   10.77  {
   10.78 -  WDF_DRIVER_CONFIG config;
   10.79 -  NTSTATUS status;
   10.80 +  NTSTATUS status = STATUS_SUCCESS;
   10.81  
   10.82 -  KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
   10.83 +  UNREFERENCED_PARAMETER(RegistryPath);
   10.84 +
   10.85 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   10.86  
   10.87    InitializeListHead(&ShutdownMsgList);
   10.88    KeInitializeSpinLock(&ShutdownMsgLock);
   10.89  
   10.90 -  WDF_DRIVER_CONFIG_INIT(&config, XenPCI_AddDevice);
   10.91 -  status = WdfDriverCreate(
   10.92 -                      DriverObject,
   10.93 -                      RegistryPath,
   10.94 -                      WDF_NO_OBJECT_ATTRIBUTES,
   10.95 -                      &config,
   10.96 -                      WDF_NO_HANDLE);
   10.97 -  if(!NT_SUCCESS(status))
   10.98 -  {
   10.99 -    KdPrint((__DRIVER_NAME " WdfDriverCreate failed with status 0x%08x\n", status));
  10.100 -  }
  10.101 +  DriverObject->DriverExtension->AddDevice = XenPci_AddDevice;
  10.102 +  DriverObject->MajorFunction[IRP_MJ_PNP] = XenPci_Pnp;
  10.103 +  DriverObject->MajorFunction[IRP_MJ_POWER] = XenPci_Power;
  10.104 +  DriverObject->MajorFunction[IRP_MJ_CREATE] = XenPci_Dummy;
  10.105 +  DriverObject->MajorFunction[IRP_MJ_CLOSE] = XenPci_Dummy;
  10.106 +  DriverObject->MajorFunction[IRP_MJ_CLEANUP] = XenPci_Dummy;
  10.107 +  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = XenPci_Dummy;
  10.108 +  DriverObject->MajorFunction[IRP_MJ_READ] = XenPci_Dummy;
  10.109 +  DriverObject->MajorFunction[IRP_MJ_WRITE] = XenPci_Dummy;
  10.110 +  DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = XenPci_Dummy;
  10.111  
  10.112 -  KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
  10.113 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  10.114  
  10.115    return status;
  10.116  }
  10.117 @@ -128,60 +171,12 @@ XenPCI_FreeMem(PVOID Ptr)
  10.118    ExFreePoolWithTag(Ptr, XENPCI_POOL_TAG);
  10.119  }
  10.120  
  10.121 -static NTSTATUS
  10.122 -get_hypercall_stubs(WDFDEVICE Device)
  10.123 -{
  10.124 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
  10.125 -  DWORD32 cpuid_output[4];
  10.126 -  char xensig[13];
  10.127 -  ULONG i;
  10.128 -  ULONG pages;
  10.129 -  ULONG msr;  
  10.130 -
  10.131 -  __cpuid(cpuid_output, 0x40000000);
  10.132 -  *(ULONG*)(xensig + 0) = cpuid_output[1];
  10.133 -  *(ULONG*)(xensig + 4) = cpuid_output[2];
  10.134 -  *(ULONG*)(xensig + 8) = cpuid_output[3];
  10.135 -  xensig[12] = '\0';
  10.136 -  KdPrint((__DRIVER_NAME " Xen Signature = %s, EAX = 0x%08x\n", xensig, cpuid_output[0]));
  10.137 -
  10.138 -  __cpuid(cpuid_output, 0x40000002);
  10.139 -  pages = cpuid_output[0];
  10.140 -  msr = cpuid_output[1];
  10.141 -  //KdPrint((__DRIVER_NAME " Hypercall area is %u pages.\n", pages));
  10.142 -
  10.143 -  xpdd->hypercall_stubs = ExAllocatePoolWithTag(NonPagedPool, pages * PAGE_SIZE, XENPCI_POOL_TAG);
  10.144 -  KdPrint((__DRIVER_NAME " Hypercall area at %p\n", xpdd->hypercall_stubs));
  10.145 -
  10.146 -  if (!xpdd->hypercall_stubs)
  10.147 -    return 1;
  10.148 -  for (i = 0; i < pages; i++) {
  10.149 -    ULONGLONG pfn;
  10.150 -    pfn = (MmGetPhysicalAddress(xpdd->hypercall_stubs + i * PAGE_SIZE).QuadPart >> PAGE_SHIFT);
  10.151 -    KdPrint((__DRIVER_NAME " pfn = %16lX\n", pfn));
  10.152 -    __writemsr(msr, (pfn << PAGE_SHIFT) + i);
  10.153 -  }
  10.154 -  return STATUS_SUCCESS;
  10.155 -}
  10.156 -
  10.157 -static NTSTATUS
  10.158 -free_hypercall_stubs(WDFDEVICE Device)
  10.159 -{
  10.160 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
  10.161 -
  10.162 -  ExFreePoolWithTag(xpdd->hypercall_stubs, XENPCI_POOL_TAG);
  10.163 -
  10.164 -  return STATUS_SUCCESS;
  10.165 -}
  10.166 -
  10.167  /*
  10.168   * Alloc MMIO from the device's MMIO region. There is no corresponding free() fn
  10.169   */
  10.170  PHYSICAL_ADDRESS
  10.171 -XenPCI_AllocMMIO(WDFDEVICE Device, ULONG len)
  10.172 +XenPci_AllocMMIO(PXENPCI_DEVICE_DATA xpdd, ULONG len)
  10.173  {
  10.174 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
  10.175 -
  10.176    PHYSICAL_ADDRESS addr;
  10.177  
  10.178    len = (len + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
  10.179 @@ -195,69 +190,88 @@ XenPCI_AllocMMIO(WDFDEVICE Device, ULONG
  10.180    return addr;
  10.181  }
  10.182  
  10.183 -static int
  10.184 -init_xen_info(WDFDEVICE Device)
  10.185 +static NTSTATUS
  10.186 +XenPci_Init(PXENPCI_DEVICE_DATA xpdd)
  10.187  {
  10.188 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
  10.189    struct xen_add_to_physmap xatp;
  10.190    int ret;
  10.191    PHYSICAL_ADDRESS shared_info_area_unmapped;
  10.192  
  10.193 -  shared_info_area_unmapped = XenPCI_AllocMMIO(Device, PAGE_SIZE);
  10.194 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.195 +
  10.196 +  hvm_get_stubs(xpdd);
  10.197 +
  10.198 +  shared_info_area_unmapped = XenPci_AllocMMIO(xpdd, PAGE_SIZE);
  10.199    KdPrint((__DRIVER_NAME " shared_info_area_unmapped.QuadPart = %lx\n", shared_info_area_unmapped.QuadPart));
  10.200    xatp.domid = DOMID_SELF;
  10.201    xatp.idx = 0;
  10.202    xatp.space = XENMAPSPACE_shared_info;
  10.203    xatp.gpfn = (xen_pfn_t)(shared_info_area_unmapped.QuadPart >> PAGE_SHIFT);
  10.204    KdPrint((__DRIVER_NAME " gpfn = %d\n", xatp.gpfn));
  10.205 -  ret = HYPERVISOR_memory_op(Device, XENMEM_add_to_physmap, &xatp);
  10.206 +  ret = HYPERVISOR_memory_op(xpdd, XENMEM_add_to_physmap, &xatp);
  10.207    KdPrint((__DRIVER_NAME " hypervisor memory op ret = %d\n", ret));
  10.208    xpdd->shared_info_area = MmMapIoSpace(shared_info_area_unmapped,
  10.209      PAGE_SIZE, MmCached);
  10.210 -  return 0;
  10.211 -} 
  10.212 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  10.213  
  10.214 -static int
  10.215 -set_callback_irq(WDFDEVICE Device, ULONGLONG irq)
  10.216 -{
  10.217 -  struct xen_hvm_param a;
  10.218 -  int retval;
  10.219 -
  10.220 -  KdPrint((__DRIVER_NAME " --> set_callback_irq\n"));
  10.221 -  a.domid = DOMID_SELF;
  10.222 -  a.index = HVM_PARAM_CALLBACK_IRQ;
  10.223 -  a.value = irq;
  10.224 -  retval = HYPERVISOR_hvm_op(Device, HVMOP_set_param, &a);
  10.225 -  KdPrint((__DRIVER_NAME " HYPERVISOR_hvm_op retval = %d\n", retval));
  10.226 -  KdPrint((__DRIVER_NAME " <-- set_callback_irq\n"));
  10.227 -  return retval;
  10.228 +  return STATUS_SUCCESS;
  10.229  }
  10.230  
  10.231 +#if 0
  10.232  WDFQUEUE ReadQueue;
  10.233 +#endif
  10.234  
  10.235  static NTSTATUS
  10.236 -XenPCI_AddDevice(
  10.237 -    IN WDFDRIVER Driver,
  10.238 -    IN PWDFDEVICE_INIT DeviceInit
  10.239 -    )
  10.240 +XenPci_AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject)
  10.241  {
  10.242 -  NTSTATUS Status;
  10.243 +  NTSTATUS status;
  10.244 +  PDEVICE_OBJECT fdo = NULL;
  10.245 +/*
  10.246    WDF_CHILD_LIST_CONFIG config;
  10.247    WDF_OBJECT_ATTRIBUTES attributes;
  10.248    WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
  10.249    WDF_IO_QUEUE_CONFIG IoQConfig;
  10.250    WDF_INTERRUPT_CONFIG InterruptConfig;
  10.251 -  PNP_BUS_INFORMATION busInfo;
  10.252 -  DECLARE_CONST_UNICODE_STRING(DeviceName, L"\\Device\\XenShutdown");
  10.253 -  DECLARE_CONST_UNICODE_STRING(SymbolicName, L"\\DosDevices\\XenShutdown");
  10.254 -  WDFDEVICE Device;
  10.255 +*/
  10.256 +//  PNP_BUS_INFORMATION busInfo;
  10.257 +//  DECLARE_CONST_UNICODE_STRING(DeviceName, L"\\Device\\XenShutdown");
  10.258 +//  DECLARE_CONST_UNICODE_STRING(SymbolicName, L"\\DosDevices\\XenShutdown");
  10.259 +//  WDFDEVICE Device;
  10.260    PXENPCI_DEVICE_DATA xpdd;
  10.261 -  PWSTR InterfaceList;
  10.262 +  //PWSTR InterfaceList;
  10.263  
  10.264 -  UNREFERENCED_PARAMETER(Driver);
  10.265 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.266  
  10.267 -  KdPrint((__DRIVER_NAME " --> DeviceAdd\n"));
  10.268 +  status = IoCreateDevice(DriverObject,
  10.269 +    sizeof(XENPCI_DEVICE_DATA),
  10.270 +    NULL,
  10.271 +    FILE_DEVICE_BUS_EXTENDER,
  10.272 +    FILE_DEVICE_SECURE_OPEN,
  10.273 +    FALSE,
  10.274 +    &fdo);
  10.275  
  10.276 +  if (!NT_SUCCESS(status))
  10.277 +  {
  10.278 +    KdPrint((__DRIVER_NAME "     IoCreateDevice failed 0x%08x\n", status));
  10.279 +    return status;
  10.280 +  }
  10.281 +
  10.282 +  xpdd = (PXENPCI_DEVICE_DATA)fdo->DeviceExtension;
  10.283 +
  10.284 +  // zero out xpdd
  10.285 +
  10.286 +  xpdd->fdo = fdo;
  10.287 +  xpdd->pdo = PhysicalDeviceObject;
  10.288 +
  10.289 +  xpdd->lower_do = IoAttachDeviceToDeviceStack(fdo, PhysicalDeviceObject);
  10.290 +  if(xpdd->lower_do == NULL) {
  10.291 +    IoDeleteDevice(fdo);
  10.292 +    return STATUS_NO_SUCH_DEVICE;
  10.293 +  }
  10.294 +
  10.295 +  fdo->Flags &= ~DO_DEVICE_INITIALIZING;
  10.296 +
  10.297 +#if 0
  10.298    WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_BUS_EXTENDER);
  10.299    WDF_CHILD_LIST_CONFIG_INIT(&config, sizeof(XENPCI_IDENTIFICATION_DESCRIPTION), XenPCI_ChildListCreateDevice);
  10.300    WdfFdoInitSetDefaultChildListConfig(DeviceInit, &config, WDF_NO_OBJECT_ATTRIBUTES);
  10.301 @@ -365,107 +379,408 @@ XenPCI_AddDevice(
  10.302      KdPrint((__DRIVER_NAME "     WdfDeviceCreateSymbolicLink failed 0x%08x\n", Status));
  10.303      return Status;
  10.304    }
  10.305 +#endif
  10.306  
  10.307 -  KdPrint((__DRIVER_NAME " <-- DeviceAdd\n"));
  10.308 -  return Status;
  10.309 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.310 +  return status;
  10.311  }
  10.312  
  10.313  static NTSTATUS
  10.314 -XenPCI_PrepareHardware(
  10.315 -  IN WDFDEVICE    Device,
  10.316 -  IN WDFCMRESLIST ResourceList,
  10.317 -  IN WDFCMRESLIST ResourceListTranslated)
  10.318 +XenPci_Pnp_IoCompletion(PDEVICE_OBJECT device_object, PIRP irp, PVOID context)
  10.319 +{
  10.320 +  PKEVENT event = (PKEVENT)context;
  10.321 +
  10.322 +  UNREFERENCED_PARAMETER(device_object);
  10.323 +
  10.324 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.325 +
  10.326 +  if (irp->PendingReturned)
  10.327 +  {
  10.328 +    KeSetEvent(event, IO_NO_INCREMENT, FALSE);
  10.329 +  }
  10.330 +
  10.331 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.332 +
  10.333 +  return STATUS_MORE_PROCESSING_REQUIRED;
  10.334 +}
  10.335 +
  10.336 +static NTSTATUS
  10.337 +XenPci_QueueWorkItem(PDEVICE_OBJECT device_object, PIO_WORKITEM_ROUTINE routine, PVOID context)
  10.338 +{
  10.339 +    PIO_WORKITEM work_item;
  10.340 +    NTSTATUS status = STATUS_SUCCESS;
  10.341 +
  10.342 +	work_item = IoAllocateWorkItem(device_object);
  10.343 +	IoQueueWorkItem(work_item, routine, DelayedWorkQueue, context);
  10.344 +	
  10.345 +    return status;
  10.346 +}
  10.347 +
  10.348 +static NTSTATUS
  10.349 +XenPci_SendAndWaitForIrp(PDEVICE_OBJECT device_object, PIRP irp)
  10.350 +{
  10.351 +  NTSTATUS status;
  10.352 +  PXENPCI_DEVICE_DATA xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  10.353 +  KEVENT event;
  10.354 +
  10.355 +  UNREFERENCED_PARAMETER(device_object);
  10.356 +
  10.357 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.358 +
  10.359 +  KeInitializeEvent(&event, NotificationEvent, FALSE);
  10.360 +
  10.361 +  IoCopyCurrentIrpStackLocationToNext(irp);
  10.362 +  IoSetCompletionRoutine(irp, XenPci_Pnp_IoCompletion, &event, TRUE, TRUE, TRUE);
  10.363 +
  10.364 +  status = IoCallDriver(xpdd->lower_do, irp);
  10.365 +
  10.366 +  if (status == STATUS_PENDING)
  10.367 +  {
  10.368 +    KdPrint((__DRIVER_NAME "     waiting ...\n"));
  10.369 +    KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
  10.370 +    KdPrint((__DRIVER_NAME "     ... done\n"));
  10.371 +    status = irp->IoStatus.Status;
  10.372 +  }
  10.373 +
  10.374 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.375 +
  10.376 +  return status;
  10.377 +}
  10.378 +
  10.379 +static VOID
  10.380 +XenPci_Pnp_StartDeviceCallback(PDEVICE_OBJECT device_object, PVOID context)
  10.381  {
  10.382    NTSTATUS status = STATUS_SUCCESS;
  10.383 -  PCM_PARTIAL_RESOURCE_DESCRIPTOR descriptor;
  10.384 -  ULONG i;
  10.385 -  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
  10.386 -
  10.387 -  KdPrint((__DRIVER_NAME " --> EvtDevicePrepareHardware\n"));
  10.388 +  PXENPCI_DEVICE_DATA xpdd = device_object->DeviceExtension;
  10.389 +  PIRP irp = context;
  10.390  
  10.391 -  for (i = 0; i < WdfCmResourceListGetCount(ResourceList); i++)
  10.392 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.393 +  
  10.394 +  XenPci_Init(xpdd);
  10.395 +
  10.396 +  GntTbl_Init(xpdd);
  10.397 +
  10.398 +  EvtChn_Init(xpdd);
  10.399 +
  10.400 +  XenBus_Init(xpdd);
  10.401 +
  10.402 +  irp->IoStatus.Status = status;
  10.403 +  
  10.404 +  IoCompleteRequest(irp, IO_NO_INCREMENT);
  10.405 +
  10.406 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.407 +}
  10.408 +
  10.409 +static NTSTATUS
  10.410 +XenPci_Pnp_StartDevice(PDEVICE_OBJECT device_object, PIRP irp)
  10.411 +{
  10.412 +  NTSTATUS status;
  10.413 +  PXENPCI_DEVICE_DATA xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  10.414 +  PIO_STACK_LOCATION stack;
  10.415 +  PCM_PARTIAL_RESOURCE_LIST res_list;
  10.416 +  PCM_PARTIAL_RESOURCE_DESCRIPTOR res_descriptor;
  10.417 +  ULONG i;
  10.418 +
  10.419 +  UNREFERENCED_PARAMETER(device_object);
  10.420 +
  10.421 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.422 +
  10.423 +  stack = IoGetCurrentIrpStackLocation(irp);
  10.424 +
  10.425 +  IoMarkIrpPending(irp);
  10.426 +
  10.427 +  status = XenPci_SendAndWaitForIrp(device_object, irp);
  10.428 +
  10.429 +  /* I think we want to start a work item here to do this... */
  10.430 +
  10.431 +  res_list = &stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList;
  10.432 +  
  10.433 +  for (i = 0; i < res_list->Count; i++)
  10.434    {
  10.435 -    descriptor = WdfCmResourceListGetDescriptor(ResourceList, i);
  10.436 -    if(!descriptor)
  10.437 -      continue;
  10.438 -    switch (descriptor->Type)
  10.439 +    res_descriptor = &res_list->PartialDescriptors[i];
  10.440 +    switch (res_descriptor->Type)
  10.441      {
  10.442      case CmResourceTypeInterrupt:
  10.443 -      xpdd->irqNumber = descriptor->u.Interrupt.Vector;
  10.444 +      xpdd->irq_number = res_descriptor->u.Interrupt.Vector;
  10.445 +      memcpy(&InterruptRaw, res_descriptor, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
  10.446        break;
  10.447      }
  10.448    }
  10.449  
  10.450 -  //KdPrint((__DRIVER_NAME " GSI = %d\n", irqNumber));
  10.451 -
  10.452 -  //KdPrint((__DRIVER_NAME " ResourceListTranslated\n"));
  10.453 -  for (i = 0; i < WdfCmResourceListGetCount(ResourceListTranslated); i++)
  10.454 +  res_list = &stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList;
  10.455 +  
  10.456 +  for (i = 0; i < res_list->Count; i++)
  10.457    {
  10.458 -    descriptor = WdfCmResourceListGetDescriptor(ResourceListTranslated, i);
  10.459 -    if(!descriptor)
  10.460 -    {
  10.461 -      KdPrint((__DRIVER_NAME " --> EvtDevicePrepareHardware (No descriptor)\n"));
  10.462 -      return STATUS_DEVICE_CONFIGURATION_ERROR;
  10.463 -    }
  10.464 -    switch (descriptor->Type) {
  10.465 +    res_descriptor = &res_list->PartialDescriptors[i];
  10.466 +    switch (res_descriptor->Type) {
  10.467      case CmResourceTypePort:
  10.468 -      //KdPrint((__DRIVER_NAME "     I/O mapped CSR: (%x) Length: (%d)\n", descriptor->u.Port.Start.LowPart, descriptor->u.Port.Length));
  10.469        break;
  10.470      case CmResourceTypeMemory:
  10.471 -      KdPrint((__DRIVER_NAME "     Memory mapped CSR:(%x:%x) Length:(%d)\n", descriptor->u.Memory.Start.LowPart, descriptor->u.Memory.Start.HighPart, descriptor->u.Memory.Length));
  10.472 -      xpdd->platform_mmio_addr = descriptor->u.Memory.Start;
  10.473 -      xpdd->platform_mmio_len = descriptor->u.Memory.Length;
  10.474 +      KdPrint((__DRIVER_NAME "     Memory mapped CSR:(%x:%x) Length:(%d)\n", res_descriptor->u.Memory.Start.LowPart, res_descriptor->u.Memory.Start.HighPart, res_descriptor->u.Memory.Length));
  10.475 +      xpdd->platform_mmio_addr = res_descriptor->u.Memory.Start;
  10.476 +      xpdd->platform_mmio_len = res_descriptor->u.Memory.Length;
  10.477        xpdd->platform_mmio_alloc = 0;
  10.478        break;
  10.479      case CmResourceTypeInterrupt:
  10.480 -      //KdPrint((__DRIVER_NAME "     Interrupt level: 0x%0x, Vector: 0x%0x\n", descriptor->u.Interrupt.Level, descriptor->u.Interrupt.Vector));
  10.481 -      memcpy(&InterruptRaw, WdfCmResourceListGetDescriptor(ResourceList, i), sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
  10.482 -      memcpy(&InterruptTranslated, WdfCmResourceListGetDescriptor(ResourceListTranslated, i), sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
  10.483 +	  xpdd->irq_level = (KIRQL)res_descriptor->u.Interrupt.Level;
  10.484 +	  xpdd->irq_vector = res_descriptor->u.Interrupt.Vector;
  10.485 +	  xpdd->irq_affinity = res_descriptor->u.Interrupt.Affinity;
  10.486 +      memcpy(&InterruptTranslated, res_descriptor, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
  10.487        break;
  10.488      case CmResourceTypeDevicePrivate:
  10.489 -      //KdPrint((__DRIVER_NAME "     Private Data: 0x%02x 0x%02x 0x%02x\n", descriptor->u.DevicePrivate.Data[0], descriptor->u.DevicePrivate.Data[1], descriptor->u.DevicePrivate.Data[2] ));
  10.490 +      KdPrint((__DRIVER_NAME "     Private Data: 0x%02x 0x%02x 0x%02x\n", res_descriptor->u.DevicePrivate.Data[0], res_descriptor->u.DevicePrivate.Data[1], res_descriptor->u.DevicePrivate.Data[2] ));
  10.491        break;
  10.492      default:
  10.493 -      //KdPrint((__DRIVER_NAME "     Unhandled resource type (0x%x)\n", descriptor->Type));
  10.494 +      KdPrint((__DRIVER_NAME "     Unhandled resource type (0x%x)\n", res_descriptor->Type));
  10.495        break;
  10.496      }
  10.497    }
  10.498  
  10.499 -  get_hypercall_stubs(Device);
  10.500 -
  10.501 -  if (init_xen_info(Device))
  10.502 -    return STATUS_ACCESS_DENIED;
  10.503 -
  10.504 -  GntTbl_Init(Device);
  10.505 -
  10.506 -  EvtChn_Init(Device);
  10.507 +  XenPci_QueueWorkItem(device_object, XenPci_Pnp_StartDeviceCallback, irp);
  10.508  
  10.509 -  set_callback_irq(Device, xpdd->irqNumber);
  10.510 -
  10.511 -  XenBus_Init(Device);
  10.512 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.513 +  
  10.514 +  return STATUS_PENDING;
  10.515 +}
  10.516  
  10.517 -  //KdPrint((__DRIVER_NAME " upcall_pending = %d\n", shared_info_area->vcpu_info[0].evtchn_upcall_pending));
  10.518 +static NTSTATUS
  10.519 +XenPci_Pnp_StopDevice(PDEVICE_OBJECT device_object, PIRP irp, PVOID context)
  10.520 +{
  10.521 +  NTSTATUS status = STATUS_SUCCESS;
  10.522  
  10.523 -  xpdd->shared_info_area->vcpu_info[0].evtchn_upcall_mask = 0;
  10.524 +  UNREFERENCED_PARAMETER(device_object);
  10.525 +  UNREFERENCED_PARAMETER(context);
  10.526  
  10.527 -  //xen_reboot_init();
  10.528 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.529  
  10.530 -  KdPrint((__DRIVER_NAME " <-- EvtDevicePrepareHardware\n"));
  10.531 +  irp->IoStatus.Status = status;
  10.532 +  IoCompleteRequest(irp, IO_NO_INCREMENT);
  10.533 +
  10.534 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.535 +
  10.536 +  return irp->IoStatus.Status;
  10.537 +}
  10.538 +
  10.539 +static NTSTATUS
  10.540 +XenPci_Pnp_QueryRemoveDevice(PDEVICE_OBJECT device_object, PIRP irp)
  10.541 +{
  10.542 +  NTSTATUS status;
  10.543 +  PXENPCI_DEVICE_DATA xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  10.544 +  int devices = 0;
  10.545 +  PDEVICE_RELATIONS dev_relations;
  10.546 +
  10.547 +  UNREFERENCED_PARAMETER(device_object);
  10.548 +
  10.549 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.550 +
  10.551 +  if (FALSE)
  10.552 +  {
  10.553 +    /* We are in the paging or hibernation path - can't remove */
  10.554 +    status = irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
  10.555 +    IoCompleteRequest(irp, IO_NO_INCREMENT);
  10.556 +  }
  10.557 +  else
  10.558 +  {
  10.559 +    IoSkipCurrentIrpStackLocation(irp);
  10.560 +    status = IoCallDriver(xpdd->lower_do, irp);
  10.561 +  }
  10.562 +
  10.563 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.564  
  10.565    return status;
  10.566  }
  10.567  
  10.568  static NTSTATUS
  10.569 -XenPCI_ReleaseHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesTranslated)
  10.570 +XenPci_Pnp_RemoveDevice(PDEVICE_OBJECT device_object, PIRP irp)
  10.571  {
  10.572 -  UNREFERENCED_PARAMETER(ResourcesTranslated);
  10.573 +  NTSTATUS status;
  10.574 +  PXENPCI_DEVICE_DATA xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  10.575 +  int devices = 0;
  10.576 +  PDEVICE_RELATIONS dev_relations;
  10.577  
  10.578 -  free_hypercall_stubs(Device);
  10.579 +  UNREFERENCED_PARAMETER(device_object);
  10.580  
  10.581 -  return STATUS_SUCCESS;
  10.582 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.583 +
  10.584 +  irp->IoStatus.Status = STATUS_SUCCESS;
  10.585 +  IoSkipCurrentIrpStackLocation(irp);
  10.586 +  status = IoCallDriver(xpdd->lower_do, irp);
  10.587 +  IoDetachDevice(xpdd->lower_do);
  10.588 +
  10.589 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.590 +
  10.591 +  return status;
  10.592  }
  10.593  
  10.594  static NTSTATUS
  10.595 +XenPci_Pnp_QueryBusRelationsCallback(PDEVICE_OBJECT device_object, PVOID context)
  10.596 +{
  10.597 +  NTSTATUS status = STATUS_SUCCESS;
  10.598 +  PXENPCI_DEVICE_DATA xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  10.599 +  PIRP irp = context;
  10.600 +  int devices = 0;
  10.601 +  PDEVICE_RELATIONS dev_relations;
  10.602 +  //char *response;
  10.603 +  char *msgTypes;
  10.604 +  char **Types;
  10.605 +  int i;
  10.606 +
  10.607 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.608 +
  10.609 +  msgTypes = XenBus_List(xpdd, XBT_NIL, "device", &Types);
  10.610 +  if (!msgTypes)
  10.611 +  {
  10.612 +    // set all children to CHILD_STATE_DELETED
  10.613 +    for (i = 0; Types[i]; i++)
  10.614 +    {
  10.615 +	  // read device name
  10.616 +	  // check if already exists or not
  10.617 +	  // create pdo if it doesn't
  10.618 +	  // set it as ADDED
  10.619 +      //RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "device/%s", Types[i]);
  10.620 +      //XenPCI_XenBusWatchHandler(buffer, Device);
  10.621 +      KdPrint((__DRIVER_NAME "     %s\n", Types[i]));
  10.622 +      ExFreePoolWithTag(Types[i], XENPCI_POOL_TAG);
  10.623 +    }
  10.624 +    devices = 0;
  10.625 +    dev_relations = ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVICE_RELATIONS) + sizeof(PDEVICE_OBJECT) * (devices - 1), XENPCI_POOL_TAG);
  10.626 +    dev_relations->Count = devices;
  10.627 +	status = STATUS_SUCCESS;
  10.628 +  }
  10.629 +  else
  10.630 +  {
  10.631 +    devices = 0;
  10.632 +    dev_relations = ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVICE_RELATIONS) + sizeof(PDEVICE_OBJECT) * (devices - 1), XENPCI_POOL_TAG);
  10.633 +    dev_relations->Count = devices;
  10.634 +  }
  10.635 +
  10.636 +  XenPCI_FreeMem(Types);
  10.637 +
  10.638 +  irp->IoStatus.Status = status;
  10.639 +  irp->IoStatus.Information = (ULONG_PTR)dev_relations;
  10.640 +
  10.641 +  IoCompleteRequest (irp, IO_NO_INCREMENT);
  10.642 +
  10.643 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.644 +}
  10.645 +
  10.646 +static NTSTATUS
  10.647 +XenPci_Pnp_QueryBusRelations(PDEVICE_OBJECT device_object, PIRP irp)
  10.648 +{
  10.649 +  NTSTATUS status;
  10.650 +  PXENPCI_DEVICE_DATA xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  10.651 +  int devices = 0;
  10.652 +  PDEVICE_RELATIONS dev_relations;
  10.653 +
  10.654 +  UNREFERENCED_PARAMETER(device_object);
  10.655 +
  10.656 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.657 +
  10.658 +  IoMarkIrpPending(irp);
  10.659 +
  10.660 +  status = XenPci_SendAndWaitForIrp(device_object, irp);
  10.661 +
  10.662 +  XenPci_QueueWorkItem(device_object, XenPci_Pnp_QueryBusRelationsCallback, irp);
  10.663 +
  10.664 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.665 +
  10.666 +  return STATUS_PENDING;
  10.667 +}
  10.668 +
  10.669 +static NTSTATUS
  10.670 +XenPci_Pnp(PDEVICE_OBJECT device_object, PIRP irp)
  10.671 +{
  10.672 +  PIO_STACK_LOCATION stack;
  10.673 +  NTSTATUS status;
  10.674 +  PXENPCI_DEVICE_DATA xpdd;
  10.675 +
  10.676 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  10.677 +
  10.678 +  xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  10.679 +
  10.680 +  stack = IoGetCurrentIrpStackLocation(irp);
  10.681 +
  10.682 +  switch (stack->MinorFunction)
  10.683 +  {
  10.684 +  case IRP_MN_START_DEVICE:
  10.685 +    KdPrint((__DRIVER_NAME "     IRP_MN_START_DEVICE\n"));
  10.686 +    return XenPci_Pnp_StartDevice(device_object, irp);
  10.687 +
  10.688 +  case IRP_MN_QUERY_STOP_DEVICE:
  10.689 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_STOP_DEVICE\n"));
  10.690 +    IoSkipCurrentIrpStackLocation(irp);
  10.691 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.692 +    break;
  10.693 +
  10.694 +  case IRP_MN_STOP_DEVICE:
  10.695 +    KdPrint((__DRIVER_NAME "     IRP_MN_STOP_DEVICE\n"));
  10.696 +    IoCopyCurrentIrpStackLocationToNext(irp);
  10.697 +    IoSetCompletionRoutine(irp, XenPci_Pnp_StopDevice, NULL, TRUE, TRUE, TRUE);
  10.698 +    break;
  10.699 +
  10.700 +  case IRP_MN_CANCEL_STOP_DEVICE:
  10.701 +    KdPrint((__DRIVER_NAME "     IRP_MN_CANCEL_STOP_DEVICE\n"));
  10.702 +    IoSkipCurrentIrpStackLocation(irp);
  10.703 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.704 +    break;
  10.705 +
  10.706 +  case IRP_MN_QUERY_REMOVE_DEVICE:
  10.707 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_REMOVE_DEVICE\n"));
  10.708 +    return XenPci_Pnp_QueryRemoveDevice(device_object, irp);
  10.709 +
  10.710 +  case IRP_MN_REMOVE_DEVICE:
  10.711 +    KdPrint((__DRIVER_NAME "     IRP_MN_REMOVE_DEVICE\n"));
  10.712 +    return XenPci_Pnp_QueryRemoveDevice(device_object, irp);
  10.713 +    break;
  10.714 +
  10.715 +  case IRP_MN_CANCEL_REMOVE_DEVICE:
  10.716 +    KdPrint((__DRIVER_NAME "     IRP_MN_CANCEL_REMOVE_DEVICE\n"));
  10.717 +    IoSkipCurrentIrpStackLocation(irp);
  10.718 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.719 +    break;
  10.720 +
  10.721 +  case IRP_MN_SURPRISE_REMOVAL:
  10.722 +    KdPrint((__DRIVER_NAME "     IRP_MN_SURPRISE_REMOVAL\n"));
  10.723 +    IoSkipCurrentIrpStackLocation(irp);
  10.724 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.725 +    break;
  10.726 +
  10.727 +  case IRP_MN_DEVICE_USAGE_NOTIFICATION:
  10.728 +    KdPrint((__DRIVER_NAME "     IRP_MN_DEVICE_USAGE_NOTIFICATION\n"));
  10.729 +    IoSkipCurrentIrpStackLocation(irp);
  10.730 +    irp->IoStatus.Status = STATUS_SUCCESS;
  10.731 +    break;
  10.732 +
  10.733 +  case IRP_MN_QUERY_DEVICE_RELATIONS:
  10.734 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
  10.735 +    switch (stack->Parameters.QueryDeviceRelations.Type)
  10.736 +    {
  10.737 +    case BusRelations:
  10.738 +      KdPrint((__DRIVER_NAME "     BusRelations\n"));
  10.739 +      return XenPci_Pnp_QueryBusRelations(device_object, irp);
  10.740 +      break;  
  10.741 +    default:
  10.742 +      IoSkipCurrentIrpStackLocation(irp);
  10.743 +      break;  
  10.744 +    }
  10.745 +    break;
  10.746 +
  10.747 +  default:
  10.748 +    KdPrint((__DRIVER_NAME "     Unhandled Minor = %d\n", stack->MinorFunction));
  10.749 +    IoSkipCurrentIrpStackLocation(irp);
  10.750 +    break;
  10.751 +  }
  10.752 +
  10.753 +  status = IoCallDriver(xpdd->lower_do, irp);
  10.754 +
  10.755 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  10.756 +
  10.757 +  return status;
  10.758 +}
  10.759 +
  10.760 +#if 0
  10.761 +
  10.762 +static NTSTATUS
  10.763  XenPCI_D0Entry(
  10.764      IN WDFDEVICE  Device,
  10.765      IN WDF_POWER_DEVICE_STATE PreviousState
  10.766 @@ -582,7 +897,6 @@ XenPCI_IoDefault(
  10.767    KdPrint((__DRIVER_NAME " <-- EvtDeviceIoDefault\n"));
  10.768  }
  10.769  
  10.770 -
  10.771  static VOID 
  10.772  XenPCI_IoRead(WDFQUEUE Queue, WDFREQUEST Request, size_t Length)
  10.773  {
  10.774 @@ -744,7 +1058,7 @@ XenPCI_ChildListCreateDevice(
  10.775    ChildDeviceData->XenInterface.InterfaceHeader.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
  10.776    ChildDeviceData->XenInterface.InterfaceHeader.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
  10.777  
  10.778 -  ChildDeviceData->XenInterface.AllocMMIO = XenPCI_AllocMMIO;
  10.779 +  ChildDeviceData->XenInterface.AllocMMIO = XenPci_AllocMMIO;
  10.780    ChildDeviceData->XenInterface.FreeMem = XenPCI_FreeMem;
  10.781  
  10.782    ChildDeviceData->XenInterface.EvtChn_Bind = EvtChn_Bind;
  10.783 @@ -1164,4 +1478,4 @@ XenPCI_DeviceResourceRequirementsQuery(W
  10.784  
  10.785    return status;
  10.786  }
  10.787 -
  10.788 +#endif
  10.789 \ No newline at end of file
    11.1 --- a/xenpci/xenpci.h	Mon Apr 28 23:07:28 2008 +1000
    11.2 +++ b/xenpci/xenpci.h	Fri May 02 20:54:46 2008 +1000
    11.3 @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fi
    11.4  
    11.5  #include <ntddk.h>
    11.6  #include <wdm.h>
    11.7 -#include <wdf.h>
    11.8 +//#include <wdf.h>
    11.9  #include <initguid.h>
   11.10  #include <wdmguid.h>
   11.11  #include <errno.h>
   11.12 @@ -49,7 +49,6 @@ Foundation, Inc., 51 Franklin Street, Fi
   11.13  DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
   11.14  
   11.15  #define XENPCI_POOL_TAG (ULONG) 'XenP'
   11.16 -//#define XENPCI_FDO_INSTANCE_SIGNATURE (ULONG) 'XENP'
   11.17  
   11.18  #define NR_RESERVED_ENTRIES 8
   11.19  #define NR_GRANT_FRAMES 4
   11.20 @@ -61,15 +60,10 @@ typedef struct _ev_action_t {
   11.21    PKSERVICE_ROUTINE ServiceRoutine;
   11.22    PVOID ServiceContext;
   11.23    BOOLEAN DpcFlag;
   11.24 -  WDFDPC Dpc;
   11.25 +  KDPC Dpc;
   11.26    ULONG Count;
   11.27  } ev_action_t;
   11.28  
   11.29 -typedef struct {
   11.30 -  ev_action_t *Action;
   11.31 -} EVTCHN_DEVICE_DATA, *PEVTCHN_DEVICE_DATA;
   11.32 -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(EVTCHN_DEVICE_DATA, GetEvtChnDeviceData);
   11.33 -
   11.34  typedef struct _XENBUS_WATCH_RING
   11.35  {
   11.36    char Path[128];
   11.37 @@ -99,14 +93,28 @@ typedef struct _XENBUS_WATCH_ENTRY {
   11.38  #define NR_XB_REQS 32
   11.39  #define MAX_WATCH_ENTRIES 128
   11.40  
   11.41 +#define CHILD_STATE_DELETED 0
   11.42 +#define CHILD_STATE_ADDED 1
   11.43 +
   11.44 +typedef struct
   11.45 +{
   11.46 +  DEVICE_OBJECT pdo;
   11.47 +  int state;
   11.48 +  PCHAR path;
   11.49 +} XEN_CHILD, *PXEN_CHILD;
   11.50 +
   11.51  // TODO: tidy up & organize this struct
   11.52  typedef struct {
   11.53 -
   11.54 -  WDFDEVICE Device;
   11.55 +  PDEVICE_OBJECT fdo;
   11.56 +  PDEVICE_OBJECT pdo;
   11.57 +  PDEVICE_OBJECT lower_do;
   11.58    BOOLEAN XenBus_ShuttingDown;
   11.59  
   11.60 -  WDFINTERRUPT XenInterrupt;
   11.61 -  ULONG irqNumber;
   11.62 +  PKINTERRUPT interrupt;
   11.63 +  ULONG irq_number;
   11.64 +  ULONG irq_vector;
   11.65 +  KIRQL irq_level;
   11.66 +  KAFFINITY irq_affinity;
   11.67  
   11.68    shared_info_t *shared_info_area;
   11.69  
   11.70 @@ -124,7 +132,7 @@ typedef struct {
   11.71    grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
   11.72  
   11.73    ev_action_t ev_actions[NR_EVENTS];
   11.74 -  unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
   11.75 +//  unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
   11.76  
   11.77    HANDLE XenBus_ReadThreadHandle;
   11.78    KEVENT XenBus_ReadThreadEvent;
   11.79 @@ -146,18 +154,15 @@ typedef struct {
   11.80  
   11.81    KGUARDED_MUTEX WatchHandlerMutex;
   11.82  
   11.83 +  int child_count;
   11.84 +  XEN_CHILD child_devices[16];
   11.85 +  
   11.86    int suspending;
   11.87  } XENPCI_DEVICE_DATA, *PXENPCI_DEVICE_DATA;
   11.88  
   11.89 -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetDeviceData);
   11.90 +//WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetDeviceData);
   11.91  
   11.92 -#if defined(_X86_)
   11.93 -  #include "hypercall_x86.h"
   11.94 -#else
   11.95 -  #if defined(_AMD64_)
   11.96 -    #include "hypercall_amd64.h"
   11.97 -  #endif
   11.98 -#endif
   11.99 +#include "hypercall.h"
  11.100  
  11.101  typedef unsigned long xenbus_transaction_t;
  11.102  typedef uint32_t XENSTORE_RING_IDX;
  11.103 @@ -176,30 +181,29 @@ char *
  11.104  XenBus_EndTransaction(PVOID Context, xenbus_transaction_t t, int abort, int *retry);
  11.105  char *
  11.106  XenBus_List(PVOID Context, xenbus_transaction_t xbt, const char *prefix, char ***contents);
  11.107 -NTSTATUS
  11.108 -XenBus_Init(WDFDEVICE Device);
  11.109 -NTSTATUS
  11.110 -XenBus_Close(WDFDEVICE Device);
  11.111 -NTSTATUS
  11.112 -XenBus_Start(WDFDEVICE Device);
  11.113 -NTSTATUS
  11.114 -XenBus_Stop(WDFDEVICE Device);
  11.115  char *
  11.116  XenBus_AddWatch(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
  11.117  char *
  11.118  XenBus_RemWatch(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
  11.119  VOID
  11.120  XenBus_ThreadProc(PVOID StartContext);
  11.121 +NTSTATUS
  11.122 +XenBus_Init(PXENPCI_DEVICE_DATA xpdd);
  11.123 +NTSTATUS
  11.124 +XenBus_Close(PXENPCI_DEVICE_DATA xpdd);
  11.125 +NTSTATUS
  11.126 +XenBus_Start(PXENPCI_DEVICE_DATA xpdd);
  11.127 +NTSTATUS
  11.128 +XenBus_Stop(PXENPCI_DEVICE_DATA xpdd);
  11.129  
  11.130  PHYSICAL_ADDRESS
  11.131 -XenPCI_AllocMMIO(WDFDEVICE Device, ULONG len);
  11.132 +XenPci_AllocMMIO(PXENPCI_DEVICE_DATA xpdd, ULONG len);
  11.133  
  11.134  NTSTATUS
  11.135 -EvtChn_Init(WDFDEVICE Device);
  11.136 -BOOLEAN
  11.137 -EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID);
  11.138 -VOID
  11.139 -EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject);
  11.140 +EvtChn_Init(PXENPCI_DEVICE_DATA xpdd);
  11.141 +NTSTATUS
  11.142 +EvtChn_Shutdown(PXENPCI_DEVICE_DATA xpdd);
  11.143 +
  11.144  NTSTATUS
  11.145  EvtChn_Mask(PVOID Context, evtchn_port_t Port);
  11.146  NTSTATUS
  11.147 @@ -214,20 +218,17 @@ NTSTATUS
  11.148  EvtChn_Notify(PVOID Context, evtchn_port_t Port);
  11.149  evtchn_port_t
  11.150  EvtChn_AllocUnbound(PVOID Context, domid_t Domain);
  11.151 -evtchn_port_t
  11.152 -EvtChn_GetXenStorePort(WDFDEVICE Device);
  11.153 -PVOID
  11.154 -EvtChn_GetXenStoreRingAddr(WDFDEVICE Device);
  11.155  
  11.156  VOID
  11.157 -GntTbl_Init(WDFDEVICE Device);
  11.158 +GntTbl_Init(PXENPCI_DEVICE_DATA xpdd);
  11.159 +
  11.160  grant_ref_t
  11.161 -GntTbl_GrantAccess(WDFDEVICE Device, domid_t domid, uint32_t, int readonly, grant_ref_t ref);
  11.162 +GntTbl_GrantAccess(PVOID Context, domid_t domid, uint32_t, int readonly, grant_ref_t ref);
  11.163  BOOLEAN
  11.164 -GntTbl_EndAccess(WDFDEVICE Device, grant_ref_t ref, BOOLEAN keepref);
  11.165 +GntTbl_EndAccess(PVOID Context, grant_ref_t ref, BOOLEAN keepref);
  11.166  VOID
  11.167 -GntTbl_PutRef(WDFDEVICE Device, grant_ref_t ref);
  11.168 +GntTbl_PutRef(PVOID Context, grant_ref_t ref);
  11.169  grant_ref_t
  11.170 -GntTbl_GetRef(WDFDEVICE Device);
  11.171 +GntTbl_GetRef(PVOID Context);
  11.172  
  11.173  #endif
    12.1 --- a/xenpci/xenpci.inx	Mon Apr 28 23:07:28 2008 +1000
    12.2 +++ b/xenpci/xenpci.inx	Fri May 02 20:54:46 2008 +1000
    12.3 @@ -7,7 +7,6 @@ Provider=%XenGplPv%
    12.4  [DestinationDirs]
    12.5  DefaultDestDir = 12
    12.6  ClassInstall32_CopyFiles=11
    12.7 -CoInstaller_CopyFiles = 11
    12.8  
    12.9  [ControlFlags]
   12.10  ExcludeFromSelect=*
   12.11 @@ -32,7 +31,6 @@ xenhide.sys
   12.12  [SourceDisksFiles]
   12.13  xenpci.sys=1
   12.14  xenhide.sys=1
   12.15 -WdfCoinstaller$KMDFCOINSTALLERVERSION$.dll=1,,
   12.16  
   12.17  [SourceDisksNames.x86]
   12.18  1 = %DISK_NAME%,,,\i386
   12.19 @@ -59,26 +57,10 @@ StartType      = 0
   12.20  ErrorControl   = 1
   12.21  LoadOrderGroup = Boot Bus Extender
   12.22  ServiceBinary  = %12%\xenhide.sys
   12.23 -AddReg         = XenHide_Service_AddReg
   12.24 -
   12.25 -[XenHide_Service_AddReg]
   12.26 -HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318},LowerFilters,0x00010008,XenHide
   12.27 -
   12.28 -[XenPCI_Inst.NT.CoInstallers]
   12.29 -AddReg=CoInstaller_AddReg
   12.30 -CopyFiles=CoInstaller_CopyFiles
   12.31 +;AddReg         = XenHide_Service_AddReg
   12.32  
   12.33 -[CoInstaller_CopyFiles]
   12.34 -WdfCoinstaller$KMDFCOINSTALLERVERSION$.dll,,,2
   12.35 -
   12.36 -[CoInstaller_AddReg]
   12.37 -HKR,,CoInstallers32,0x00010000, "WdfCoinstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"
   12.38 -
   12.39 -[XenPCI_Inst.NT.Wdf]
   12.40 -KmdfService = xenpci, xenpci_wdfsect
   12.41 -
   12.42 -[xenpci_wdfsect]
   12.43 -KmdfLibraryVersion = $KMDFVERSION$
   12.44 +;[XenHide_Service_AddReg]
   12.45 +;HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318},LowerFilters,0x00010008,XenHide
   12.46  
   12.47  [Strings]
   12.48  XenGplPv = "Xen GPL PV Driver Developers"