win-pvdrivers

changeset 266:b88529df8b60 wdm

More wdm updates
author James Harper <james.harper@bendigoit.com.au>
date Wed May 07 10:47:03 2008 +1000 (2008-05-07)
parents aef4bd71120b
children f157f82e0293
files xenpci/sources xenpci/xenpci_fdo.c xenpci/xenpci_pdo.c xenvbd/xenvbd.c xenvbd/xenvbd.inx
line diff
     1.1 --- a/xenpci/sources	Mon May 05 23:00:05 2008 +1000
     1.2 +++ b/xenpci/sources	Wed May 07 10:47:03 2008 +1000
     1.3 @@ -5,5 +5,6 @@ TARGETNAME=xenpci
     1.4  TARGETTYPE=DRIVER
     1.5  INF_NAME=$(TARGETNAME)
     1.6  MISCFILES=..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf
     1.7 +TARGETLIBS=$(TARGETLIBS) $(DDK_LIB_PATH)\wdmsec.lib
     1.8  AMD64_SOURCES=hypercall.asm
     1.9  SOURCES=xenpci.c xenpci_fdo.c xenpci_pdo.c evtchn.c gnttbl.c xenbus.c
    1.10 \ No newline at end of file
     2.1 --- a/xenpci/xenpci_fdo.c	Mon May 05 23:00:05 2008 +1000
     2.2 +++ b/xenpci/xenpci_fdo.c	Wed May 07 10:47:03 2008 +1000
     2.3 @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fi
     2.4  */
     2.5  
     2.6  #include "xenpci.h"
     2.7 +#include <wdmsec.h>
     2.8  #include <stdlib.h>
     2.9  
    2.10  #define SYSRQ_PATH "control/sysrq"
    2.11 @@ -290,8 +291,6 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    2.12  
    2.13    status = XenPci_SendAndWaitForIrp(device_object, irp);
    2.14  
    2.15 -  /* I think we want to start a work item here to do this... */
    2.16 -
    2.17    res_list = &stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList;
    2.18    
    2.19    for (i = 0; i < res_list->Count; i++)
    2.20 @@ -300,6 +299,7 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    2.21      switch (res_descriptor->Type)
    2.22      {
    2.23      case CmResourceTypeInterrupt:
    2.24 +      KdPrint((__DRIVER_NAME "     irq_number = %d\n", res_descriptor->u.Interrupt.Vector));
    2.25        xpdd->irq_number = res_descriptor->u.Interrupt.Vector;
    2.26        memcpy(&InterruptRaw, res_descriptor, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
    2.27        break;
    2.28 @@ -321,9 +321,10 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    2.29        xpdd->platform_mmio_alloc = 0;
    2.30        break;
    2.31      case CmResourceTypeInterrupt:
    2.32 -	  xpdd->irq_level = (KIRQL)res_descriptor->u.Interrupt.Level;
    2.33 -	  xpdd->irq_vector = res_descriptor->u.Interrupt.Vector;
    2.34 -	  xpdd->irq_affinity = res_descriptor->u.Interrupt.Affinity;
    2.35 +      KdPrint((__DRIVER_NAME "     irq_vector = %d\n", res_descriptor->u.Interrupt.Vector));
    2.36 +	    xpdd->irq_level = (KIRQL)res_descriptor->u.Interrupt.Level;
    2.37 +  	  xpdd->irq_vector = res_descriptor->u.Interrupt.Vector;
    2.38 +	    xpdd->irq_affinity = res_descriptor->u.Interrupt.Affinity;
    2.39        memcpy(&InterruptTranslated, res_descriptor, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
    2.40        break;
    2.41      case CmResourceTypeDevicePrivate:
    2.42 @@ -542,7 +543,16 @@ XenPci_Pnp_QueryBusRelationsCallback(PDE
    2.43          KdPrint((__DRIVER_NAME "     New device %s\n", Types[i]));
    2.44          child = ExAllocatePoolWithTag(NonPagedPool, sizeof(XEN_CHILD), XENPCI_POOL_TAG);
    2.45          child->state = CHILD_STATE_ADDED;
    2.46 -        status = IoCreateDevice(xpdd->common.fdo->DriverObject, sizeof(XENPCI_PDO_DEVICE_DATA), NULL, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &pdo);
    2.47 +        status = IoCreateDeviceSecure(
    2.48 +          xpdd->common.fdo->DriverObject,
    2.49 +          sizeof(XENPCI_PDO_DEVICE_DATA),
    2.50 +          NULL,
    2.51 +          FILE_DEVICE_UNKNOWN,
    2.52 +          FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
    2.53 +          FALSE,
    2.54 +          &SDDL_DEVOBJ_SYS_ALL_ADM_ALL,
    2.55 +          (LPCGUID)&GUID_XENPCI_DEVCLASS,
    2.56 +          &pdo);
    2.57          if (!NT_SUCCESS(status))
    2.58            KdPrint((__DRIVER_NAME "     IoCreateDevice status = %08X\n", status));
    2.59          child->context = (PXENPCI_PDO_DEVICE_DATA)pdo->DeviceExtension;
    2.60 @@ -615,7 +625,7 @@ XenPci_Pnp_FilterResourceRequirementsCal
    2.61    ULONG irl;
    2.62    ULONG ird;
    2.63      
    2.64 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.65 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (status = %08X)\n", irp->IoStatus.Status));
    2.66    
    2.67    irrl = (PIO_RESOURCE_REQUIREMENTS_LIST)irp->IoStatus.Information;
    2.68    for (irl = 0; irl < irrl->AlternativeLists; irl++)
    2.69 @@ -635,7 +645,7 @@ XenPci_Pnp_FilterResourceRequirementsCal
    2.70  
    2.71    return;
    2.72  }
    2.73 - 
    2.74 +
    2.75  static NTSTATUS
    2.76  XenPci_Pnp_FilterResourceRequirements(PDEVICE_OBJECT device_object, PIRP irp)
    2.77  {
     3.1 --- a/xenpci/xenpci_pdo.c	Mon May 05 23:00:05 2008 +1000
     3.2 +++ b/xenpci/xenpci_pdo.c	Wed May 07 10:47:03 2008 +1000
     3.3 @@ -38,6 +38,48 @@ XenPci_Power_Pdo(PDEVICE_OBJECT device_o
     3.4  }
     3.5  
     3.6  static NTSTATUS
     3.7 +XenPci_Pnp_StartDevice(PDEVICE_OBJECT device_object, PIRP irp)
     3.8 +{
     3.9 +  PIO_STACK_LOCATION stack;
    3.10 +  PCM_PARTIAL_RESOURCE_LIST res_list;
    3.11 +  PCM_PARTIAL_RESOURCE_DESCRIPTOR res_descriptor;
    3.12 +  ULONG i;
    3.13 +
    3.14 +  UNREFERENCED_PARAMETER(device_object);
    3.15 +
    3.16 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.17 +
    3.18 +  stack = IoGetCurrentIrpStackLocation(irp);
    3.19 +
    3.20 +  res_list = &stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList;
    3.21 +  for (i = 0; i < res_list->Count; i++)
    3.22 +  {
    3.23 +    res_descriptor = &res_list->PartialDescriptors[i];
    3.24 +    switch (res_descriptor->Type)
    3.25 +    {
    3.26 +    case CmResourceTypeInterrupt:
    3.27 +      KdPrint((__DRIVER_NAME "     irq_number = %d\n", res_descriptor->u.Interrupt.Vector));
    3.28 +      break;
    3.29 +    }
    3.30 +  }
    3.31 +
    3.32 +  res_list = &stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList;
    3.33 +  for (i = 0; i < res_list->Count; i++)
    3.34 +  {
    3.35 +    res_descriptor = &res_list->PartialDescriptors[i];
    3.36 +    switch (res_descriptor->Type) {
    3.37 +    case CmResourceTypeInterrupt:
    3.38 +      KdPrint((__DRIVER_NAME "     irq_vector = %d\n", res_descriptor->u.Interrupt.Vector));
    3.39 +      break;
    3.40 +    }
    3.41 +  }
    3.42 +  
    3.43 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    3.44 +
    3.45 +  return STATUS_SUCCESS;
    3.46 +}
    3.47 +
    3.48 +static NTSTATUS
    3.49  XenPci_QueryResourceRequirements(PDEVICE_OBJECT device_object, PIRP irp)
    3.50  {
    3.51    PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
    3.52 @@ -47,7 +89,7 @@ XenPci_QueryResourceRequirements(PDEVICE
    3.53    
    3.54    length = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List) +
    3.55      FIELD_OFFSET(IO_RESOURCE_LIST, Descriptors) +
    3.56 -    sizeof(IO_RESOURCE_DESCRIPTOR) * 2;
    3.57 +    sizeof(IO_RESOURCE_DESCRIPTOR) * 3;
    3.58    irrl = ExAllocatePoolWithTag(PagedPool,
    3.59      length,
    3.60      XENPCI_POOL_TAG);
    3.61 @@ -59,7 +101,7 @@ XenPci_QueryResourceRequirements(PDEVICE
    3.62    irrl->AlternativeLists = 1;
    3.63    irrl->List[0].Version = 1;
    3.64    irrl->List[0].Revision = 1;
    3.65 -  irrl->List[0].Count = 2;
    3.66 +  irrl->List[0].Count = 3;
    3.67  
    3.68    ird = &irrl->List[0].Descriptors[0];
    3.69    ird->Option = 0;
    3.70 @@ -67,13 +109,29 @@ XenPci_QueryResourceRequirements(PDEVICE
    3.71    ird->ShareDisposition = CmResourceShareDeviceExclusive;
    3.72    ird->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
    3.73    ird->u.Interrupt.MinimumVector = 1;
    3.74 -  ird->u.Interrupt.MaximumVector = 63;
    3.75 +  ird->u.Interrupt.MaximumVector = 6;
    3.76  
    3.77    ird = &irrl->List[0].Descriptors[1];
    3.78 +  ird->Option = IO_RESOURCE_ALTERNATIVE;
    3.79 +  ird->Type = CmResourceTypeInterrupt;
    3.80 +  ird->ShareDisposition = CmResourceShareDeviceExclusive;
    3.81 +  ird->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
    3.82 +  ird->u.Interrupt.MinimumVector = 8;
    3.83 +  ird->u.Interrupt.MaximumVector = 14;
    3.84 +
    3.85 +  //irq 7 = 0x93
    3.86 +  //irq 11 = 0x81
    3.87 +  //irq ? = 0x52 mouse
    3.88 +  //irq ? = 0xb3 keybouard
    3.89 +  //irq ? = 0x72 atapi
    3.90 +  //irq ? = 0x92 atappi
    3.91 +  //irq 28 = 0x83 xen - 0x183
    3.92 +  
    3.93 +  ird = &irrl->List[0].Descriptors[2];
    3.94    ird->Option = 0;
    3.95    ird->Type = CmResourceTypeMemory;
    3.96    ird->ShareDisposition = CmResourceShareShared;
    3.97 -  ird->Flags = CM_RESOURCE_MEMORY_READ_WRITE|CM_RESOURCE_MEMORY_PREFETCHABLE|CM_RESOURCE_MEMORY_CACHEABLE;
    3.98 +  ird->Flags = CM_RESOURCE_MEMORY_READ_WRITE; //|CM_RESOURCE_MEMORY_PREFETCHABLE|CM_RESOURCE_MEMORY_CACHEABLE;
    3.99    ird->u.Memory.Length = PAGE_SIZE;
   3.100    ird->u.Memory.Alignment = PAGE_SIZE;
   3.101    ird->u.Memory.MinimumAddress.QuadPart = xppdd->mmio_phys.QuadPart;
   3.102 @@ -143,6 +201,7 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
   3.103    unsigned int i;
   3.104    PPNP_BUS_INFORMATION pbi;
   3.105    PCM_RESOURCE_LIST crl;
   3.106 +KIRQL old_irql;
   3.107  
   3.108    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   3.109  
   3.110 @@ -152,7 +211,7 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
   3.111    {
   3.112    case IRP_MN_START_DEVICE:
   3.113      KdPrint((__DRIVER_NAME "     IRP_MN_START_DEVICE (status = %08x)\n", irp->IoStatus.Status));
   3.114 -    status = STATUS_SUCCESS;
   3.115 +    status = XenPci_Pnp_StartDevice(device_object, irp);
   3.116      break;
   3.117      
   3.118    case IRP_MN_QUERY_STOP_DEVICE:
   3.119 @@ -287,12 +346,12 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
   3.120      
   3.121    case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
   3.122      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_RESOURCE_REQUIREMENTS (status = %08x)\n", irp->IoStatus.Status));
   3.123 -    status = irp->IoStatus.Status; //XenPci_QueryResourceRequirements(device_object, irp);
   3.124 +    status = XenPci_QueryResourceRequirements(device_object, irp);
   3.125      break;
   3.126  
   3.127    case IRP_MN_QUERY_CAPABILITIES:
   3.128      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_CAPABILITIES (status = %08x)\n", irp->IoStatus.Status));
   3.129 -    status = irp->IoStatus.Status; //XenPci_Pnp_QueryCapabilities(device_object, irp);
   3.130 +    status = XenPci_Pnp_QueryCapabilities(device_object, irp);
   3.131      break;
   3.132  
   3.133    case IRP_MN_QUERY_BUS_INFORMATION:
   3.134 @@ -336,6 +395,22 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
   3.135        status = XenPci_Pnp_QueryTargetRelations(device_object, irp);
   3.136        break;  
   3.137      default:
   3.138 +KeRaiseIrql(7, &old_irql);
   3.139 +KdPrint((__DRIVER_NAME "     int 0x81 (xenvbd) (from xenpci)"));
   3.140 +__asm {
   3.141 +  int 0x81
   3.142 +};
   3.143 +KeLowerIrql(old_irql);
   3.144 +
   3.145 +KeRaiseIrql(7, &old_irql);
   3.146 +KdPrint((__DRIVER_NAME "     int 0x81 (xenvbd) (from xenpci)"));
   3.147 +__asm {
   3.148 +  cli
   3.149 +  int 0x81
   3.150 +  sti
   3.151 +};
   3.152 +KeLowerIrql(old_irql);
   3.153 +    
   3.154        status = irp->IoStatus.Status;
   3.155        break;
   3.156      }
     4.1 --- a/xenvbd/xenvbd.c	Mon May 05 23:00:05 2008 +1000
     4.2 +++ b/xenvbd/xenvbd.c	Wed May 07 10:47:03 2008 +1000
     4.3 @@ -111,11 +111,11 @@ XenVbd_Interrupt(PKINTERRUPT Interrupt, 
     4.4  
     4.5    UNREFERENCED_PARAMETER(Interrupt);
     4.6  
     4.7 -//  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
     4.8 +  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
     4.9  
    4.10    TargetData->PendingInterrupt = TRUE;
    4.11  
    4.12 -//  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    4.13 +  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    4.14  
    4.15    return TRUE;
    4.16  }
    4.17 @@ -144,8 +144,9 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
    4.18    PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)TargetData->DeviceData;
    4.19    int more_to_do = TRUE;
    4.20  
    4.21 -//  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
    4.22 +  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
    4.23  
    4.24 +#if 0
    4.25    while (more_to_do)
    4.26    {
    4.27      rp = TargetData->Ring.sring->rsp_prod;
    4.28 @@ -230,7 +231,9 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
    4.29      }
    4.30    }
    4.31  
    4.32 -//  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
    4.33 +#endif
    4.34 +
    4.35 +  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
    4.36  }
    4.37  
    4.38  static BOOLEAN
    4.39 @@ -988,12 +991,14 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
    4.40    unsigned int i;
    4.41    int notify;
    4.42  
    4.43 +  KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
    4.44 +
    4.45 +__asm { int 0x91 };
    4.46  Srb->SrbStatus = SRB_STATUS_NO_DEVICE;
    4.47  ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
    4.48  ScsiPortNotification(NextRequest, DeviceExtension, NULL);
    4.49  
    4.50  #if 0
    4.51 -//  KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
    4.52  //  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    4.53  
    4.54    // If we haven't enumerated all the devices yet then just defer the request
    4.55 @@ -1303,9 +1308,9 @@ ScsiPortNotification(NextRequest, Device
    4.56      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
    4.57      break;
    4.58    }
    4.59 +#endif
    4.60  
    4.61 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    4.62 -#endif
    4.63 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    4.64    return TRUE;
    4.65  }
    4.66  
    4.67 @@ -1345,12 +1350,49 @@ XenVbd_HwScsiAdapterControl(PVOID Device
    4.68  {
    4.69    SCSI_ADAPTER_CONTROL_STATUS Status = ScsiAdapterControlSuccess;
    4.70    PSCSI_SUPPORTED_CONTROL_TYPE_LIST SupportedControlTypeList;
    4.71 +  KIRQL OldIrql;
    4.72  
    4.73    UNREFERENCED_PARAMETER(DeviceExtension);
    4.74  
    4.75    KdPrint((__DRIVER_NAME " --> HwScsiAdapterControl\n"));
    4.76    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    4.77  
    4.78 +  //KdBreakPoint();
    4.79 +
    4.80 +  KdPrint((__DRIVER_NAME "     int 0x81 (xenvbd)"));
    4.81 +  __asm {
    4.82 +    cli
    4.83 +    int 0x81
    4.84 +    sti
    4.85 +  };
    4.86 +  
    4.87 +  KeRaiseIrql(7, &OldIrql);
    4.88 +  KdPrint((__DRIVER_NAME "     int 0x81 (xenvbd)"));
    4.89 +  __asm {
    4.90 +    int 0x81
    4.91 +  };
    4.92 +  KeLowerIrql(OldIrql);
    4.93 +
    4.94 +  KeRaiseIrql(7, &OldIrql);
    4.95 +  KdPrint((__DRIVER_NAME "     int 0x81 (xenvbd)"));
    4.96 +  __asm {
    4.97 +    cli
    4.98 +    int 0x81
    4.99 +    sti
   4.100 +  };
   4.101 +  KeLowerIrql(OldIrql);
   4.102 +
   4.103 +  /*
   4.104 +  KdPrint((__DRIVER_NAME "     int 0x07"));
   4.105 +  __asm { int 0x07 };
   4.106 +
   4.107 +  KdPrint((__DRIVER_NAME "     int 0x37"));
   4.108 +  __asm { int 0x37 };
   4.109 +  */
   4.110 +  
   4.111 +//  KdPrint((__DRIVER_NAME "     int 0x83 (xenpci)"));
   4.112 +//  __asm { int 0x83 };
   4.113 +
   4.114    switch (ControlType)
   4.115    {
   4.116    case ScsiQuerySupportedControlTypes:
     5.1 --- a/xenvbd/xenvbd.inx	Mon May 05 23:00:05 2008 +1000
     5.2 +++ b/xenvbd/xenvbd.inx	Wed May 07 10:47:03 2008 +1000
     5.3 @@ -34,7 +34,7 @@ AddService=XenVbd,2,XenVbd_Service, XenV
     5.4  [XenVbd_Service]
     5.5  DisplayName    = %XenVbd.SVCDESC%                            
     5.6  ServiceType    = 1
     5.7 -StartType      = 0
     5.8 +StartType      = 3
     5.9  ErrorControl   = 1
    5.10  LoadOrderGroup = System Bus Extender
    5.11  ServiceBinary  = %12%\xenvbd.sys