ReactOS  0.4.15-dev-3165-gdf6fff7
fdo.c File Reference
#include "pci.h"
#include <debug.h>
Include dependency graph for fdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS NTAPI ForwardIrpAndWaitCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS NTAPI ForwardIrpAndWait (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS FdoLocateChildDevice (PPCI_DEVICE *Device, PFDO_DEVICE_EXTENSION DeviceExtension, PCI_SLOT_NUMBER SlotNumber, PPCI_COMMON_CONFIG PciConfig)
 
static NTSTATUS FdoEnumerateDevices (PDEVICE_OBJECT DeviceObject)
 
static NTSTATUS FdoQueryBusRelations (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS FdoStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS FdoPnpControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS FdoPowerControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Variables

static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file fdo.c.

Function Documentation

◆ FdoEnumerateDevices()

static NTSTATUS FdoEnumerateDevices ( PDEVICE_OBJECT  DeviceObject)
static

Definition at line 94 of file fdo.c.

96 {
97  PFDO_DEVICE_EXTENSION DeviceExtension;
98  PCI_COMMON_CONFIG PciConfig;
102  ULONG FunctionNumber;
103  ULONG Size;
105 
106  DPRINT("Called\n");
107 
108  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
109 
110  DeviceExtension->DeviceListCount = 0;
111 
112  /* Enumerate devices on the PCI bus */
113  SlotNumber.u.AsULONG = 0;
115  {
116  SlotNumber.u.bits.DeviceNumber = DeviceNumber;
117  for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
118  {
119  SlotNumber.u.bits.FunctionNumber = FunctionNumber;
120 
121  DPRINT("Bus %1lu Device %2lu Func %1lu\n",
122  DeviceExtension->BusNumber,
123  DeviceNumber,
124  FunctionNumber);
125 
126  RtlZeroMemory(&PciConfig,
127  sizeof(PCI_COMMON_CONFIG));
128 
130  DeviceExtension->BusNumber,
131  SlotNumber.u.AsULONG,
132  &PciConfig,
134  DPRINT("Size %lu\n", Size);
136  {
137  if (FunctionNumber == 0)
138  {
139  break;
140  }
141  else
142  {
143  continue;
144  }
145  }
146 
147  DPRINT("Bus %1lu Device %2lu Func %1lu VenID 0x%04hx DevID 0x%04hx\n",
148  DeviceExtension->BusNumber,
149  DeviceNumber,
150  FunctionNumber,
151  PciConfig.VendorID,
152  PciConfig.DeviceID);
153 
154  if (PciConfig.VendorID == 0 && PciConfig.DeviceID == 0)
155  {
156  DPRINT("Filter out devices with null vendor and device ID\n");
157  continue;
158  }
159 
160  Status = FdoLocateChildDevice(&Device, DeviceExtension, SlotNumber, &PciConfig);
161  if (!NT_SUCCESS(Status))
162  {
164  if (!Device)
165  {
166  /* FIXME: Cleanup resources for already discovered devices */
168  }
169 
171  sizeof(PCI_DEVICE));
172 
173  Device->BusNumber = DeviceExtension->BusNumber;
174 
175  RtlCopyMemory(&Device->SlotNumber,
176  &SlotNumber,
177  sizeof(PCI_SLOT_NUMBER));
178 
179  RtlCopyMemory(&Device->PciConfig,
180  &PciConfig,
181  sizeof(PCI_COMMON_CONFIG));
182 
184  &DeviceExtension->DeviceListHead,
185  &Device->ListEntry,
186  &DeviceExtension->DeviceListLock);
187  }
188 
189  DeviceExtension->DeviceListCount++;
190 
191  /* Skip to next device if the current one is not a multifunction device */
192  if ((FunctionNumber == 0) &&
193  ((PciConfig.HeaderType & 0x80) == 0))
194  {
195  break;
196  }
197  }
198  }
199 
200  DPRINT("Done\n");
201 
202  return STATUS_SUCCESS;
203 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
ULONG DeviceListCount
Definition: pci.h:91
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Definition: pci.h:9
KSPIN_LOCK DeviceListLock
Definition: pci.h:93
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define PCI_MAX_DEVICES
Definition: iotypes.h:3598
#define for
Definition: utility.h:88
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG BusNumber
Definition: pci.h:85
#define TAG_PCI
Definition: pci.h:7
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
LIST_ENTRY DeviceListHead
Definition: pci.h:89
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3599
unsigned int ULONG
Definition: retypes.h:1
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
static NTSTATUS FdoLocateChildDevice(PPCI_DEVICE *Device, PFDO_DEVICE_EXTENSION DeviceExtension, PCI_SLOT_NUMBER SlotNumber, PPCI_COMMON_CONFIG PciConfig)
Definition: fdo.c:58
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
#define DPRINT
Definition: sndvol32.h:71
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3594

Referenced by FdoQueryBusRelations().

◆ FdoLocateChildDevice()

static NTSTATUS FdoLocateChildDevice ( PPCI_DEVICE Device,
PFDO_DEVICE_EXTENSION  DeviceExtension,
PCI_SLOT_NUMBER  SlotNumber,
PPCI_COMMON_CONFIG  PciConfig 
)
static

Definition at line 58 of file fdo.c.

63 {
64  PLIST_ENTRY CurrentEntry;
65  PPCI_DEVICE CurrentDevice;
66 
67  DPRINT("Called\n");
68 
69  CurrentEntry = DeviceExtension->DeviceListHead.Flink;
70  while (CurrentEntry != &DeviceExtension->DeviceListHead)
71  {
72  CurrentDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
73 
74  /* If both vendor ID and device ID match, it is the same device */
75  if ((PciConfig->VendorID == CurrentDevice->PciConfig.VendorID) &&
76  (PciConfig->DeviceID == CurrentDevice->PciConfig.DeviceID) &&
77  (SlotNumber.u.AsULONG == CurrentDevice->SlotNumber.u.AsULONG))
78  {
79  *Device = CurrentDevice;
80  DPRINT("Done\n");
81  return STATUS_SUCCESS;
82  }
83 
84  CurrentEntry = CurrentEntry->Flink;
85  }
86 
87  *Device = NULL;
88  DPRINT("Done\n");
89  return STATUS_UNSUCCESSFUL;
90 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
Definition: pci.h:9
union _PCI_SLOT_NUMBER::@3772 u
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
LIST_ENTRY DeviceListHead
Definition: pci.h:89
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PCI_COMMON_CONFIG PciConfig
Definition: pci.h:20

Referenced by FdoEnumerateDevices().

◆ FdoPnpControl()

NTSTATUS FdoPnpControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 468 of file fdo.c.

479 {
480  PFDO_DEVICE_EXTENSION DeviceExtension;
482  NTSTATUS Status = Irp->IoStatus.Status;
483 
484  DPRINT("Called\n");
485 
486  DeviceExtension = DeviceObject->DeviceExtension;
487 
489  switch (IrpSp->MinorFunction)
490  {
491 #if 0
494  break;
495 
498  break;
499 
502  break;
503 
506  break;
507 #endif
509  if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
510  break;
511 
513  Irp->IoStatus.Status = Status;
515  return Status;
516 #if 0
519  break;
520 
523  break;
524 #endif
525  case IRP_MN_START_DEVICE:
526  DPRINT("IRP_MN_START_DEVICE received\n");
528  if (NT_SUCCESS(Status))
530 
531  Irp->IoStatus.Status = Status;
533  return Status;
534 
536  /* We don't support stopping yet */
538  Irp->IoStatus.Status = Status;
540  return Status;
541 
542  case IRP_MN_STOP_DEVICE:
543  /* We can't fail this one so we fail the QUERY_STOP request that precedes it */
544  break;
545 #if 0
548  break;
549 #endif
550 
552  break;
553 
555  /* Detach the device object from the device stack */
556  IoDetachDevice(DeviceExtension->Ldo);
557 
558  /* Delete the device object */
560 
561  /* Return success */
563  break;
564 
567  /* Don't print the warning, too much noise */
568  break;
569 
570  default:
571  DPRINT1("Unknown PNP minor function 0x%x\n", IrpSp->MinorFunction);
572  break;
573  }
574 
575  Irp->IoStatus.Status = Status;
577  Status = IoCallDriver(DeviceExtension->Ldo, Irp);
578 
579  DPRINT("Leaving. Status 0x%lx\n", Status);
580 
581  return Status;
582 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_REMOVE_DEVICE
static NTSTATUS FdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:392
NTSTATUS NTAPI ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:32
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
PDEVICE_OBJECT Ldo
Definition: pci.h:95
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MN_QUERY_STOP_DEVICE
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MN_START_DEVICE
static NTSTATUS FdoQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:207
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_CANCEL_STOP_DEVICE
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_CAPABILITIES

Referenced by PciPnpControl().

◆ FdoPowerControl()

NTSTATUS FdoPowerControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 586 of file fdo.c.

597 {
598  PFDO_DEVICE_EXTENSION DeviceExtension;
600 
601  DPRINT("Called\n");
602 
603  DeviceExtension = DeviceObject->DeviceExtension;
604 
607  Status = PoCallDriver(DeviceExtension->Ldo, Irp);
608 
609  DPRINT("Leaving. Status 0x%X\n", Status);
610 
611  return Status;
612 }
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT Ldo
Definition: pci.h:95
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define DPRINT
Definition: sndvol32.h:71

Referenced by PciPowerControl().

◆ FdoQueryBusRelations()

static NTSTATUS FdoQueryBusRelations ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 207 of file fdo.c.

211 {
212  PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
213  PFDO_DEVICE_EXTENSION DeviceExtension;
214  PDEVICE_RELATIONS Relations;
215  PLIST_ENTRY CurrentEntry;
218  BOOLEAN ErrorOccurred;
219  NTSTATUS ErrorStatus;
220  ULONG Size;
221  ULONG i;
222 
224 
225  DPRINT("Called\n");
226 
227  ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
228 
230 
231  ErrorOccurred = FALSE;
232 
234 
235  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
236 
237  if (Irp->IoStatus.Information)
238  {
239  /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
240  structure so we must merge this structure with our own */
241  DPRINT1("FIXME: leaking old bus relations\n");
242  }
243 
244  Size = sizeof(DEVICE_RELATIONS) +
245  sizeof(Relations->Objects) * (DeviceExtension->DeviceListCount - 1);
247  if (!Relations)
249 
250  Relations->Count = DeviceExtension->DeviceListCount;
251 
252  i = 0;
253  CurrentEntry = DeviceExtension->DeviceListHead.Flink;
254  while (CurrentEntry != &DeviceExtension->DeviceListHead)
255  {
256  Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
257 
258  PdoDeviceExtension = NULL;
259 
260  if (!Device->Pdo)
261  {
262  /* Create a physical device object for the
263  device as it does not already have one */
264  Status = IoCreateDevice(DeviceObject->DriverObject,
265  sizeof(PDO_DEVICE_EXTENSION),
266  NULL,
269  FALSE,
270  &Device->Pdo);
271  if (!NT_SUCCESS(Status))
272  {
273  DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
274  ErrorStatus = Status;
275  ErrorOccurred = TRUE;
276  break;
277  }
278 
279  Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
280 
281  //Device->Pdo->Flags |= DO_POWER_PAGABLE;
282 
283  PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension;
284 
285  RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
286 
287  PdoDeviceExtension->Common.IsFDO = FALSE;
288 
289  PdoDeviceExtension->Common.DeviceObject = Device->Pdo;
290 
291  PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
292 
293  PdoDeviceExtension->Fdo = DeviceObject;
294 
295  PdoDeviceExtension->PciDevice = Device;
296 
297  /* Add Device ID string */
298  Status = PciCreateDeviceIDString(&PdoDeviceExtension->DeviceID, Device);
299  if (!NT_SUCCESS(Status))
300  {
301  ErrorStatus = Status;
302  ErrorOccurred = TRUE;
303  break;
304  }
305 
306  DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceID.Buffer);
307 
308  /* Add Instance ID string */
309  Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceID, Device);
310  if (!NT_SUCCESS(Status))
311  {
312  ErrorStatus = Status;
313  ErrorOccurred = TRUE;
314  break;
315  }
316 
317  /* Add Hardware IDs string */
318  Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs, Device);
319  if (!NT_SUCCESS(Status))
320  {
321  ErrorStatus = Status;
322  ErrorOccurred = TRUE;
323  break;
324  }
325 
326  /* Add Compatible IDs string */
327  Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIDs, Device);
328  if (!NT_SUCCESS(Status))
329  {
330  ErrorStatus = Status;
331  ErrorOccurred = TRUE;
332  break;
333  }
334 
335  /* Add device description string */
337  if (!NT_SUCCESS(Status))
338  {
339  ErrorStatus = Status;
340  ErrorOccurred = TRUE;
341  break;
342  }
343 
344  /* Add device location string */
346  if (!NT_SUCCESS(Status))
347  {
348  ErrorStatus = Status;
349  ErrorOccurred = TRUE;
350  break;
351  }
352  }
353 
354  /* Reference the physical device object. The PnP manager
355  will dereference it again when it is no longer needed */
357 
358  Relations->Objects[i] = Device->Pdo;
359 
360  i++;
361 
362  CurrentEntry = CurrentEntry->Flink;
363  }
364 
365  if (ErrorOccurred)
366  {
367  /* FIXME: Cleanup all new PDOs created in this call. Please give me SEH!!! ;-) */
368  /* FIXME: Should IoAttachDeviceToDeviceStack() be undone? */
369  if (PdoDeviceExtension)
370  {
371  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceID);
372  RtlFreeUnicodeString(&PdoDeviceExtension->InstanceID);
373  RtlFreeUnicodeString(&PdoDeviceExtension->HardwareIDs);
374  RtlFreeUnicodeString(&PdoDeviceExtension->CompatibleIDs);
375  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceDescription);
376  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceLocation);
377  }
378 
379  ExFreePoolWithTag(Relations, TAG_PCI);
380  return ErrorStatus;
381  }
382 
383  Irp->IoStatus.Information = (ULONG_PTR)Relations;
384 
385  DPRINT("Done\n");
386 
387  return Status;
388 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
ULONG DeviceListCount
Definition: pci.h:91
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
NTSTATUS PciCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription, PPCI_DEVICE Device)
Definition: pci.c:378
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PDEVICE_OBJECT Fdo
Definition: pci.h:58
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PPCI_DEVICE PciDevice
Definition: pci.h:60
static NTSTATUS PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs)
Definition: fdo.c:291
Definition: pci.h:9
if(dx==0 &&dy==0)
Definition: linetemp.h:174
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PDEVICE_OBJECT DeviceObject
Definition: kstypes.h:153
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:110
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
unsigned char BOOLEAN
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:56
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UNICODE_STRING DeviceLocation
Definition: pci.h:72
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UNICODE_STRING HardwareIDs
Definition: pci.h:66
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UNICODE_STRING DeviceDescription
Definition: pci.h:70
static NTSTATUS FdoEnumerateDevices(PDEVICE_OBJECT DeviceObject)
Definition: fdo.c:94
#define TAG_PCI
Definition: pci.h:7
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
LIST_ENTRY DeviceListHead
Definition: pci.h:89
struct _DEVICE_RELATIONS DEVICE_RELATIONS
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static NTSTATUS PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs)
Definition: fdo.c:269
static NTSTATUS PciCreateInstanceIDString(PUNICODE_STRING InstanceID, ULONG PeripheralNumber)
Definition: fdo.c:313
NTSTATUS PciCreateDeviceIDString(PUNICODE_STRING DeviceID, PPCI_DEVICE Device)
Definition: pci.c:232
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
UNICODE_STRING InstanceID
Definition: pci.h:64
NTSTATUS PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device)
Definition: pci.c:646
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
UNICODE_STRING DeviceID
Definition: pci.h:62
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
UNICODE_STRING CompatibleIDs
Definition: pci.h:68
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by FdoPnpControl().

◆ FdoStartDevice()

static NTSTATUS FdoStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 392 of file fdo.c.

395 {
396  PFDO_DEVICE_EXTENSION DeviceExtension;
398  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
399  ULONG FoundBusNumber = FALSE;
400  ULONG i;
401 
402  DPRINT("Called\n");
403 
404  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
405 
406  AllocatedResources = IoGetCurrentIrpStackLocation(Irp)->Parameters.StartDevice.AllocatedResources;
407  if (!AllocatedResources)
408  {
409  DPRINT("No allocated resources sent to driver\n");
411  }
412 
413  if (AllocatedResources->Count < 1)
414  {
415  DPRINT("Not enough allocated resources sent to driver\n");
417  }
418 
419  if (AllocatedResources->List[0].PartialResourceList.Version != 1 ||
420  AllocatedResources->List[0].PartialResourceList.Revision != 1)
422 
423  ASSERT(DeviceExtension->State == dsStopped);
424 
425  /* By default, use the bus number in the resource list header */
426  DeviceExtension->BusNumber = AllocatedResources->List[0].BusNumber;
427 
428  for (i = 0; i < AllocatedResources->List[0].PartialResourceList.Count; i++)
429  {
430  ResourceDescriptor = &AllocatedResources->List[0].PartialResourceList.PartialDescriptors[i];
431  switch (ResourceDescriptor->Type)
432  {
434  if (FoundBusNumber || ResourceDescriptor->u.BusNumber.Length < 1)
436 
437  /* Use this one instead */
438  ASSERT(AllocatedResources->List[0].BusNumber == ResourceDescriptor->u.BusNumber.Start);
439  DeviceExtension->BusNumber = ResourceDescriptor->u.BusNumber.Start;
440  DPRINT("Found bus number resource: %lu\n", DeviceExtension->BusNumber);
441  FoundBusNumber = TRUE;
442  break;
443 
444  default:
445  DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
446  }
447  }
448 
449  InitializeListHead(&DeviceExtension->DeviceListHead);
450  KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
451  DeviceExtension->DeviceListCount = 0;
452  DeviceExtension->State = dsStarted;
453 
456  &DeviceExtension->ListEntry,
458 
459  Irp->IoStatus.Information = 0;
460 
461  return STATUS_SUCCESS;
462 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
ULONG DeviceListCount
Definition: pci.h:91
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4640
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LIST_ENTRY ListEntry
Definition: pci.h:83
KSPIN_LOCK DeviceListLock
Definition: pci.h:93
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376 u
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@384 BusNumber
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
#define ASSERT(a)
Definition: mode.c:44
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
KSPIN_LOCK BusListLock
Definition: pci.h:105
PCI_DEVICE_STATE State
Definition: pci.h:87
ULONG BusNumber
Definition: pci.h:85
LIST_ENTRY BusListHead
Definition: pci.h:103
LIST_ENTRY DeviceListHead
Definition: pci.h:89
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

Referenced by FdoPnpControl().

◆ ForwardIrpAndWait()

NTSTATUS NTAPI ForwardIrpAndWait ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 32 of file fdo.c.

35 {
36  KEVENT Event;
38  PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Ldo;
39  ASSERT(LowerDevice);
40 
43 
45 
46  Status = IoCallDriver(LowerDevice, Irp);
47  if (Status == STATUS_PENDING)
48  {
50  if (NT_SUCCESS(Status))
51  Status = Irp->IoStatus.Status;
52  }
53 
54  return Status;
55 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2868
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
Definition: fdo.c:17
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

Referenced by FdcFdoPnp(), FdoPnp(), FdoPnpControl(), PciIdeXFdoPnpDispatch(), PortFdoStartDevice(), SerenumFdoPnp(), and SermousePnp().

◆ ForwardIrpAndWaitCompletion()

static NTSTATUS NTAPI ForwardIrpAndWaitCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)
static

Definition at line 20 of file fdo.c.

24 {
26  if (Irp->PendingReturned)
29 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Variable Documentation

◆ ForwardIrpAndWaitCompletion

IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
static

Definition at line 17 of file fdo.c.

Referenced by ForwardIrpAndWait().