win-pvdrivers

changeset 261:aef4bd71120b wdm

More updates. Still not working though - won't even look at loading xenvbd!
author James Harper <james.harper@bendigoit.com.au>
date Mon May 05 23:00:05 2008 +1000 (2008-05-05)
parents 952b8aa9c44c
children b88529df8b60
files xenpci/xenpci.h xenpci/xenpci_fdo.c xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/xenpci.h	Mon May 05 00:09:47 2008 +1000
     1.2 +++ b/xenpci/xenpci.h	Mon May 05 23:00:05 2008 +1000
     1.3 @@ -162,6 +162,7 @@ typedef struct {
     1.4  
     1.5  typedef struct {  
     1.6    XENPCI_COMMON common;
     1.7 +  PDEVICE_OBJECT bus_fdo;
     1.8    char path[128];
     1.9    ULONG index;
    1.10    PHYSICAL_ADDRESS mmio_phys;
     2.1 --- a/xenpci/xenpci_fdo.c	Mon May 05 00:09:47 2008 +1000
     2.2 +++ b/xenpci/xenpci_fdo.c	Mon May 05 23:00:05 2008 +1000
     2.3 @@ -549,6 +549,7 @@ XenPci_Pnp_QueryBusRelationsCallback(PDE
     2.4          child->context->common.fdo = NULL;
     2.5          child->context->common.pdo = pdo;
     2.6          child->context->common.lower_do = NULL;
     2.7 +        child->context->bus_fdo = device_object;
     2.8          strcpy(child->context->path, Types[i]);
     2.9          child->context->index = 0;
    2.10          child->context->mmio_phys = XenPci_AllocMMIO(xpdd, PAGE_SIZE);
     3.1 --- a/xenpci/xenpci_pdo.c	Mon May 05 00:09:47 2008 +1000
     3.2 +++ b/xenpci/xenpci_pdo.c	Mon May 05 23:00:05 2008 +1000
     3.3 @@ -72,7 +72,7 @@ XenPci_QueryResourceRequirements(PDEVICE
     3.4    ird = &irrl->List[0].Descriptors[1];
     3.5    ird->Option = 0;
     3.6    ird->Type = CmResourceTypeMemory;
     3.7 -  ird->ShareDisposition = CmResourceShareDeviceExclusive;
     3.8 +  ird->ShareDisposition = CmResourceShareShared;
     3.9    ird->Flags = CM_RESOURCE_MEMORY_READ_WRITE|CM_RESOURCE_MEMORY_PREFETCHABLE|CM_RESOURCE_MEMORY_CACHEABLE;
    3.10    ird->u.Memory.Length = PAGE_SIZE;
    3.11    ird->u.Memory.Alignment = PAGE_SIZE;
    3.12 @@ -83,6 +83,55 @@ XenPci_QueryResourceRequirements(PDEVICE
    3.13    return STATUS_SUCCESS;
    3.14  }
    3.15  
    3.16 +static NTSTATUS
    3.17 +XenPci_Pnp_QueryTargetRelations(PDEVICE_OBJECT device_object, PIRP irp)
    3.18 +{
    3.19 +  PDEVICE_RELATIONS dr;
    3.20 +  PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
    3.21 +  
    3.22 +  dr = (PDEVICE_RELATIONS)ExAllocatePoolWithTag (PagedPool, sizeof(DEVICE_RELATIONS), XENPCI_POOL_TAG);
    3.23 +  dr->Count = 1;
    3.24 +  dr->Objects[0] = xppdd->common.pdo;
    3.25 +  ObReferenceObject(xppdd->common.pdo);
    3.26 +  irp->IoStatus.Information = (ULONG_PTR)dr;
    3.27 +  
    3.28 +  return STATUS_SUCCESS;
    3.29 +}
    3.30 +
    3.31 +static NTSTATUS
    3.32 +XenPci_Pnp_QueryCapabilities(PDEVICE_OBJECT device_object, PIRP irp)
    3.33 +{
    3.34 +  PIO_STACK_LOCATION stack;
    3.35 +  PDEVICE_CAPABILITIES dc;
    3.36 +
    3.37 +  UNREFERENCED_PARAMETER(device_object);
    3.38 +  
    3.39 +  stack = IoGetCurrentIrpStackLocation(irp);
    3.40 +  dc = stack->Parameters.DeviceCapabilities.Capabilities;
    3.41 +  dc->LockSupported = FALSE;
    3.42 +  dc->EjectSupported = FALSE;
    3.43 +  dc->Removable = FALSE;
    3.44 +  dc->DockDevice = FALSE;
    3.45 +  dc->UniqueID = FALSE;
    3.46 +  dc->SilentInstall = FALSE;
    3.47 +  dc->RawDeviceOK = FALSE;
    3.48 +  dc->SurpriseRemovalOK = FALSE;
    3.49 +  dc->HardwareDisabled = FALSE;
    3.50 +  dc->NoDisplayInUI = FALSE;
    3.51 +  dc->DeviceWake = PowerDeviceUnspecified;
    3.52 +  dc->D1Latency = 0;
    3.53 +  dc->D2Latency = 0;
    3.54 +  dc->D3Latency = 0;
    3.55 +  /* we are really supposed to get the DeviceState entries from the parent... */
    3.56 +  dc->DeviceState[PowerSystemWorking] = PowerDeviceD0;
    3.57 +  dc->DeviceState[PowerSystemSleeping1] = PowerDeviceUnspecified;
    3.58 +  dc->DeviceState[PowerSystemSleeping2] = PowerDeviceUnspecified;
    3.59 +  dc->DeviceState[PowerSystemSleeping3] = PowerDeviceUnspecified;
    3.60 +  dc->DeviceState[PowerSystemHibernate] = PowerDeviceD3;
    3.61 +  dc->DeviceState[PowerSystemShutdown] = PowerDeviceD3;
    3.62 +  return STATUS_SUCCESS;
    3.63 +}
    3.64 +
    3.65  NTSTATUS
    3.66  XenPci_Pnp_Pdo(PDEVICE_OBJECT device_object, PIRP irp)
    3.67  {
    3.68 @@ -93,7 +142,6 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
    3.69    WCHAR widebuf[256];
    3.70    unsigned int i;
    3.71    PPNP_BUS_INFORMATION pbi;
    3.72 -  PDEVICE_CAPABILITIES dc;
    3.73    PCM_RESOURCE_LIST crl;
    3.74  
    3.75    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.76 @@ -103,57 +151,52 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
    3.77    switch (stack->MinorFunction)
    3.78    {
    3.79    case IRP_MN_START_DEVICE:
    3.80 -    KdPrint((__DRIVER_NAME "     IRP_MN_START_DEVICE\n"));
    3.81 +    KdPrint((__DRIVER_NAME "     IRP_MN_START_DEVICE (status = %08x)\n", irp->IoStatus.Status));
    3.82      status = STATUS_SUCCESS;
    3.83      break;
    3.84      
    3.85    case IRP_MN_QUERY_STOP_DEVICE:
    3.86 -    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_STOP_DEVICE\n"));
    3.87 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_STOP_DEVICE (status = %08x)\n", irp->IoStatus.Status));
    3.88      status = STATUS_SUCCESS;
    3.89      break;
    3.90  
    3.91    case IRP_MN_STOP_DEVICE:
    3.92 -    KdPrint((__DRIVER_NAME "     IRP_MN_STOP_DEVICE\n"));
    3.93 +    KdPrint((__DRIVER_NAME "     IRP_MN_STOP_DEVICE (status = %08x)\n", irp->IoStatus.Status));
    3.94      status = STATUS_SUCCESS;
    3.95      break;
    3.96  
    3.97    case IRP_MN_CANCEL_STOP_DEVICE:
    3.98 -    KdPrint((__DRIVER_NAME "     IRP_MN_CANCEL_STOP_DEVICE\n"));
    3.99 +    KdPrint((__DRIVER_NAME "     IRP_MN_CANCEL_STOP_DEVICE (status = %08x)\n", irp->IoStatus.Status));
   3.100      status = STATUS_SUCCESS;
   3.101      break;
   3.102  
   3.103    case IRP_MN_QUERY_REMOVE_DEVICE:
   3.104 -    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_REMOVE_DEVICE\n"));
   3.105 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_REMOVE_DEVICE (status = %08x)\n", irp->IoStatus.Status));
   3.106      status = STATUS_SUCCESS;
   3.107      break;
   3.108  
   3.109    case IRP_MN_REMOVE_DEVICE:
   3.110 -    KdPrint((__DRIVER_NAME "     IRP_MN_REMOVE_DEVICE\n"));
   3.111 +    KdPrint((__DRIVER_NAME "     IRP_MN_REMOVE_DEVICE (status = %08x)\n", irp->IoStatus.Status));
   3.112      status = STATUS_SUCCESS;
   3.113      break;
   3.114  
   3.115    case IRP_MN_CANCEL_REMOVE_DEVICE:
   3.116 -    KdPrint((__DRIVER_NAME "     IRP_MN_CANCEL_REMOVE_DEVICE\n"));
   3.117 +    KdPrint((__DRIVER_NAME "     IRP_MN_CANCEL_REMOVE_DEVICE (status = %08x)\n", irp->IoStatus.Status));
   3.118      status = STATUS_SUCCESS;
   3.119      break;
   3.120  
   3.121    case IRP_MN_SURPRISE_REMOVAL:
   3.122 -    KdPrint((__DRIVER_NAME "     IRP_MN_SURPRISE_REMOVAL\n"));
   3.123 +    KdPrint((__DRIVER_NAME "     IRP_MN_SURPRISE_REMOVAL (status = %08x)\n", irp->IoStatus.Status));
   3.124      status = STATUS_SUCCESS;
   3.125      break;
   3.126  
   3.127    case IRP_MN_DEVICE_USAGE_NOTIFICATION:
   3.128 -    KdPrint((__DRIVER_NAME "     IRP_MN_DEVICE_USAGE_NOTIFICATION\n"));
   3.129 +    KdPrint((__DRIVER_NAME "     IRP_MN_DEVICE_USAGE_NOTIFICATION (status = %08x)\n", irp->IoStatus.Status));
   3.130      status = STATUS_SUCCESS;
   3.131      break;
   3.132  
   3.133 -  case IRP_MN_QUERY_DEVICE_RELATIONS:
   3.134 -    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
   3.135 -    status = STATUS_NOT_SUPPORTED;
   3.136 -    break;
   3.137 -
   3.138    case IRP_MN_QUERY_ID:
   3.139 -    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_ID\n"));
   3.140 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_ID (status = %08x)\n", irp->IoStatus.Status));
   3.141      switch (stack->Parameters.QueryId.IdType)
   3.142      {
   3.143      case BusQueryDeviceID: /* REG_SZ */
   3.144 @@ -212,7 +255,7 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
   3.145      break;
   3.146      
   3.147    case IRP_MN_QUERY_DEVICE_TEXT:
   3.148 -    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_TEXT\n"));
   3.149 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_TEXT (status = %08x)\n", irp->IoStatus.Status));
   3.150      switch (stack->Parameters.QueryDeviceText.DeviceTextType)
   3.151      {
   3.152      case DeviceTextDescription:
   3.153 @@ -242,58 +285,66 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
   3.154      }
   3.155      break;
   3.156      
   3.157 -    case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
   3.158 -      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n"));
   3.159 -      status = XenPci_QueryResourceRequirements(device_object, irp);
   3.160 -      break;
   3.161 -
   3.162 -    case IRP_MN_QUERY_CAPABILITIES:
   3.163 -      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_CAPABILITIES\n"));
   3.164 -      dc = stack->Parameters.DeviceCapabilities.Capabilities;
   3.165 -      dc->LockSupported = FALSE;
   3.166 -      dc->EjectSupported = FALSE;
   3.167 -      dc->Removable = FALSE;
   3.168 -      dc->DockDevice = FALSE;
   3.169 -      dc->UniqueID = FALSE;
   3.170 -      dc->SilentInstall = FALSE;
   3.171 -      dc->RawDeviceOK = FALSE;
   3.172 -      dc->SurpriseRemovalOK = FALSE;
   3.173 -      dc->HardwareDisabled = FALSE;
   3.174 -      dc->NoDisplayInUI = FALSE;
   3.175 -      //dc->DeviceWake = PowerDeviceUndefined;
   3.176 -      dc->D1Latency = 0;
   3.177 -      dc->D2Latency = 0;
   3.178 -      dc->D3Latency = 0;
   3.179 -      status = STATUS_SUCCESS;
   3.180 -      break;
   3.181 +  case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
   3.182 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_RESOURCE_REQUIREMENTS (status = %08x)\n", irp->IoStatus.Status));
   3.183 +    status = irp->IoStatus.Status; //XenPci_QueryResourceRequirements(device_object, irp);
   3.184 +    break;
   3.185  
   3.186 -    case IRP_MN_QUERY_BUS_INFORMATION:
   3.187 -      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_BUS_INFORMATION\n"));
   3.188 -      pbi = (PPNP_BUS_INFORMATION)ExAllocatePoolWithTag(PagedPool, sizeof(PNP_BUS_INFORMATION), XENPCI_POOL_TAG);
   3.189 -      pbi->BusTypeGuid = GUID_XENPCI_DEVCLASS;
   3.190 -      pbi->LegacyBusType = Internal;
   3.191 -      pbi->BusNumber = 0;
   3.192 -      irp->IoStatus.Information = (ULONG_PTR)pbi;
   3.193 -      status = STATUS_SUCCESS;
   3.194 -      break;
   3.195 +  case IRP_MN_QUERY_CAPABILITIES:
   3.196 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_CAPABILITIES (status = %08x)\n", irp->IoStatus.Status));
   3.197 +    status = irp->IoStatus.Status; //XenPci_Pnp_QueryCapabilities(device_object, irp);
   3.198 +    break;
   3.199  
   3.200 -    case IRP_MN_QUERY_RESOURCES:
   3.201 -      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_RESOURCES\n"));
   3.202 -      crl = (PCM_RESOURCE_LIST)ExAllocatePoolWithTag(PagedPool, sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR), XENPCI_POOL_TAG);
   3.203 -      crl->Count = 1;
   3.204 -      crl->List[0].InterfaceType = Internal;
   3.205 -      crl->List[0].BusNumber = 0;
   3.206 -      crl->List[0].PartialResourceList.Version = 0;
   3.207 -      crl->List[0].PartialResourceList.Revision = 0;
   3.208 -      crl->List[0].PartialResourceList.Count = 0;
   3.209 -      irp->IoStatus.Information = (ULONG_PTR)crl;
   3.210 -      status = STATUS_SUCCESS;
   3.211 +  case IRP_MN_QUERY_BUS_INFORMATION:
   3.212 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_BUS_INFORMATION (status = %08x)\n", irp->IoStatus.Status));
   3.213 +    pbi = (PPNP_BUS_INFORMATION)ExAllocatePoolWithTag(PagedPool, sizeof(PNP_BUS_INFORMATION), XENPCI_POOL_TAG);
   3.214 +    pbi->BusTypeGuid = GUID_XENPCI_DEVCLASS;
   3.215 +    pbi->LegacyBusType = Internal;
   3.216 +    pbi->BusNumber = 0;
   3.217 +    irp->IoStatus.Information = (ULONG_PTR)pbi;
   3.218 +    status = STATUS_SUCCESS;
   3.219 +    break;
   3.220 +
   3.221 +  case IRP_MN_QUERY_RESOURCES:
   3.222 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_RESOURCES (status = %08x)\n", irp->IoStatus.Status));
   3.223 +    status = irp->IoStatus.Status;
   3.224 +    #if 0
   3.225 +    crl = (PCM_RESOURCE_LIST)ExAllocatePoolWithTag(PagedPool, sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR), XENPCI_POOL_TAG);
   3.226 +    crl->Count = 1;
   3.227 +    crl->List[0].InterfaceType = Internal;
   3.228 +    crl->List[0].BusNumber = 0;
   3.229 +    crl->List[0].PartialResourceList.Version = 0;
   3.230 +    crl->List[0].PartialResourceList.Revision = 0;
   3.231 +    crl->List[0].PartialResourceList.Count = 0;
   3.232 +    irp->IoStatus.Information = (ULONG_PTR)crl;
   3.233 +    status = STATUS_SUCCESS;
   3.234 +    #endif
   3.235 +    break;
   3.236 +    
   3.237 +  case IRP_MN_QUERY_PNP_DEVICE_STATE:
   3.238 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_PNP_DEVICE_STATE (status = %08x)\n", irp->IoStatus.Status));
   3.239 +    irp->IoStatus.Information = 0;
   3.240 +    status = STATUS_SUCCESS;
   3.241 +    break;
   3.242 +  
   3.243 +  case IRP_MN_QUERY_DEVICE_RELATIONS:
   3.244 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS (status = %08x)\n", irp->IoStatus.Status));
   3.245 +    switch (stack->Parameters.QueryDeviceRelations.Type)
   3.246 +    {
   3.247 +    case TargetDeviceRelation:
   3.248 +      KdPrint((__DRIVER_NAME "     BusRelations\n"));
   3.249 +      status = XenPci_Pnp_QueryTargetRelations(device_object, irp);
   3.250 +      break;  
   3.251 +    default:
   3.252 +      status = irp->IoStatus.Status;
   3.253        break;
   3.254 +    }
   3.255 +    break;
   3.256          
   3.257 -    default:
   3.258 -      KdPrint((__DRIVER_NAME "     Unhandled Minor = %d\n", stack->MinorFunction));
   3.259 -      status = STATUS_NOT_SUPPORTED;
   3.260 -      break;
   3.261 +  default:
   3.262 +    KdPrint((__DRIVER_NAME "     Unhandled Minor = %d, Status = %08x\n", stack->MinorFunction, irp->IoStatus.Status));
   3.263 +    status = irp->IoStatus.Status;
   3.264 +    break;
   3.265    }
   3.266  
   3.267    irp->IoStatus.Status = status;