ReactOS  0.4.14-dev-57-g333b8f1
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 
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  Status = FdoLocateChildDevice(&Device, DeviceExtension, SlotNumber, &PciConfig);
155  if (!NT_SUCCESS(Status))
156  {
158  if (!Device)
159  {
160  /* FIXME: Cleanup resources for already discovered devices */
162  }
163 
165  sizeof(PCI_DEVICE));
166 
167  Device->BusNumber = DeviceExtension->BusNumber;
168 
169  RtlCopyMemory(&Device->SlotNumber,
170  &SlotNumber,
171  sizeof(PCI_SLOT_NUMBER));
172 
173  RtlCopyMemory(&Device->PciConfig,
174  &PciConfig,
175  sizeof(PCI_COMMON_CONFIG));
176 
178  &DeviceExtension->DeviceListHead,
179  &Device->ListEntry,
180  &DeviceExtension->DeviceListLock);
181  }
182 
183  DeviceExtension->DeviceListCount++;
184 
185  /* Skip to next device if the current one is not a multifunction device */
186  if ((FunctionNumber == 0) &&
187  ((PciConfig.HeaderType & 0x80) == 0))
188  {
189  break;
190  }
191  }
192  }
193 
194  DPRINT("Done\n");
195 
196  return STATUS_SUCCESS;
197 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG DeviceListCount
Definition: pci.h:90
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
LONG NTSTATUS
Definition: precomp.h:26
Definition: pci.h:8
KSPIN_LOCK DeviceListLock
Definition: pci.h:92
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PCI_MAX_DEVICES
Definition: iotypes.h:3242
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define for
Definition: utility.h:88
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG BusNumber
Definition: pci.h:84
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
#define TAG_PCI
Definition: pci.h:6
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
LIST_ENTRY DeviceListHead
Definition: pci.h:88
Status
Definition: gdiplustypes.h:24
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3243
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
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:1036
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3238

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_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
Definition: pci.h:8
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
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:119
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
union _PCI_SLOT_NUMBER::@3636 u
Definition: typedefs.h:117
LIST_ENTRY DeviceListHead
Definition: pci.h:88
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:17
return STATUS_SUCCESS
Definition: btrfs.c:2966
PCI_COMMON_CONFIG PciConfig
Definition: pci.h:19

Referenced by FdoEnumerateDevices().

◆ FdoPnpControl()

NTSTATUS FdoPnpControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 462 of file fdo.c.

473 {
474  PFDO_DEVICE_EXTENSION DeviceExtension;
476  NTSTATUS Status = Irp->IoStatus.Status;
477 
478  DPRINT("Called\n");
479 
480  DeviceExtension = DeviceObject->DeviceExtension;
481 
483  switch (IrpSp->MinorFunction)
484  {
485 #if 0
488  break;
489 
492  break;
493 
496  break;
497 
500  break;
501 #endif
503  if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
504  break;
505 
507  Irp->IoStatus.Status = Status;
509  return Status;
510 #if 0
513  break;
514 
517  break;
518 #endif
519  case IRP_MN_START_DEVICE:
520  DPRINT("IRP_MN_START_DEVICE received\n");
522  if (NT_SUCCESS(Status))
524 
525  Irp->IoStatus.Status = Status;
527  return Status;
528 
530  /* We don't support stopping yet */
532  Irp->IoStatus.Status = Status;
534  return Status;
535 
536  case IRP_MN_STOP_DEVICE:
537  /* We can't fail this one so we fail the QUERY_STOP request that precedes it */
538  break;
539 #if 0
542  break;
543 #endif
544 
546  break;
547 
549  /* Detach the device object from the device stack */
550  IoDetachDevice(DeviceExtension->Ldo);
551 
552  /* Delete the device object */
554 
555  /* Return success */
557  break;
558 
561  /* Don't print the warning, too much noise */
562  break;
563 
564  default:
565  DPRINT1("Unknown PNP minor function 0x%x\n", IrpSp->MinorFunction);
566  break;
567  }
568 
569  Irp->IoStatus.Status = Status;
571  Status = IoCallDriver(DeviceExtension->Ldo, Irp);
572 
573  DPRINT("Leaving. Status 0x%lx\n", Status);
574 
575  return Status;
576 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_REMOVE_DEVICE
static NTSTATUS FdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:386
NTSTATUS NTAPI ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:32
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
#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:94
#define IRP_MN_QUERY_REMOVE_DEVICE
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IRP_MN_QUERY_STOP_DEVICE
#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:201
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
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:566
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
#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 580 of file fdo.c.

591 {
592  PFDO_DEVICE_EXTENSION DeviceExtension;
594 
595  DPRINT("Called\n");
596 
597  DeviceExtension = DeviceObject->DeviceExtension;
598 
601  Status = PoCallDriver(DeviceExtension->Ldo, Irp);
602 
603  DPRINT("Leaving. Status 0x%X\n", Status);
604 
605  return Status;
606 }
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT Ldo
Definition: pci.h:94
PVOID DeviceExtension
Definition: env_spec_w32.h:418
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by PciPowerControl().

◆ FdoQueryBusRelations()

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

Definition at line 201 of file fdo.c.

205 {
206  PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
207  PFDO_DEVICE_EXTENSION DeviceExtension;
208  PDEVICE_RELATIONS Relations;
209  PLIST_ENTRY CurrentEntry;
212  BOOLEAN ErrorOccurred;
213  NTSTATUS ErrorStatus;
214  ULONG Size;
215  ULONG i;
216 
218 
219  DPRINT("Called\n");
220 
221  ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
222 
224 
225  ErrorOccurred = FALSE;
226 
228 
230 
231  if (Irp->IoStatus.Information)
232  {
233  /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
234  structure so we must merge this structure with our own */
235  DPRINT1("FIXME: leaking old bus relations\n");
236  }
237 
238  Size = sizeof(DEVICE_RELATIONS) +
239  sizeof(Relations->Objects) * (DeviceExtension->DeviceListCount - 1);
241  if (!Relations)
243 
244  Relations->Count = DeviceExtension->DeviceListCount;
245 
246  i = 0;
247  CurrentEntry = DeviceExtension->DeviceListHead.Flink;
248  while (CurrentEntry != &DeviceExtension->DeviceListHead)
249  {
250  Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
251 
252  PdoDeviceExtension = NULL;
253 
254  if (!Device->Pdo)
255  {
256  /* Create a physical device object for the
257  device as it does not already have one */
258  Status = IoCreateDevice(DeviceObject->DriverObject,
259  sizeof(PDO_DEVICE_EXTENSION),
260  NULL,
263  FALSE,
264  &Device->Pdo);
265  if (!NT_SUCCESS(Status))
266  {
267  DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
268  ErrorStatus = Status;
269  ErrorOccurred = TRUE;
270  break;
271  }
272 
273  Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
274 
275  //Device->Pdo->Flags |= DO_POWER_PAGABLE;
276 
277  PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension;
278 
279  RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
280 
281  PdoDeviceExtension->Common.IsFDO = FALSE;
282 
283  PdoDeviceExtension->Common.DeviceObject = Device->Pdo;
284 
285  PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
286 
287  PdoDeviceExtension->Fdo = DeviceObject;
288 
289  PdoDeviceExtension->PciDevice = Device;
290 
291  /* Add Device ID string */
292  Status = PciCreateDeviceIDString(&PdoDeviceExtension->DeviceID, Device);
293  if (!NT_SUCCESS(Status))
294  {
295  ErrorStatus = Status;
296  ErrorOccurred = TRUE;
297  break;
298  }
299 
300  DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceID.Buffer);
301 
302  /* Add Instance ID string */
303  Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceID, Device);
304  if (!NT_SUCCESS(Status))
305  {
306  ErrorStatus = Status;
307  ErrorOccurred = TRUE;
308  break;
309  }
310 
311  /* Add Hardware IDs string */
312  Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs, Device);
313  if (!NT_SUCCESS(Status))
314  {
315  ErrorStatus = Status;
316  ErrorOccurred = TRUE;
317  break;
318  }
319 
320  /* Add Compatible IDs string */
321  Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIDs, Device);
322  if (!NT_SUCCESS(Status))
323  {
324  ErrorStatus = Status;
325  ErrorOccurred = TRUE;
326  break;
327  }
328 
329  /* Add device description string */
331  if (!NT_SUCCESS(Status))
332  {
333  ErrorStatus = Status;
334  ErrorOccurred = TRUE;
335  break;
336  }
337 
338  /* Add device location string */
340  if (!NT_SUCCESS(Status))
341  {
342  ErrorStatus = Status;
343  ErrorOccurred = TRUE;
344  break;
345  }
346  }
347 
348  /* Reference the physical device object. The PnP manager
349  will dereference it again when it is no longer needed */
351 
352  Relations->Objects[i] = Device->Pdo;
353 
354  i++;
355 
356  CurrentEntry = CurrentEntry->Flink;
357  }
358 
359  if (ErrorOccurred)
360  {
361  /* FIXME: Cleanup all new PDOs created in this call. Please give me SEH!!! ;-) */
362  /* FIXME: Should IoAttachDeviceToDeviceStack() be undone? */
363  if (PdoDeviceExtension)
364  {
365  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceID);
366  RtlFreeUnicodeString(&PdoDeviceExtension->InstanceID);
367  RtlFreeUnicodeString(&PdoDeviceExtension->HardwareIDs);
368  RtlFreeUnicodeString(&PdoDeviceExtension->CompatibleIDs);
369  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceDescription);
370  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceLocation);
371  }
372 
373  ExFreePoolWithTag(Relations, TAG_PCI);
374  return ErrorStatus;
375  }
376 
377  Irp->IoStatus.Information = (ULONG_PTR)Relations;
378 
379  DPRINT("Done\n");
380 
381  return Status;
382 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define TRUE
Definition: types.h:120
ULONG DeviceListCount
Definition: pci.h:90
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PDEVICE_OBJECT Fdo
Definition: pci.h:57
NTSTATUS PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device)
Definition: pci.c:655
PPCI_DEVICE PciDevice
Definition: pci.h:59
Definition: pci.h:8
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PDEVICE_OBJECT DeviceObject
Definition: kstypes.h:153
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 FILE_DEVICE_CONTROLLER
Definition: winioctl.h:109
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:55
void DPRINT(...)
Definition: polytest.cpp:61
static NTSTATUS PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs)
Definition: fdo.c:291
#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
static NTSTATUS PciCreateInstanceIDString(PUNICODE_STRING InstanceID, ULONG PeripheralNumber)
Definition: fdo.c:313
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
UNICODE_STRING DeviceLocation
Definition: pci.h:71
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UNICODE_STRING HardwareIDs
Definition: pci.h:65
NTSTATUS PciCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription, PPCI_DEVICE Device)
Definition: pci.c:387
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UNICODE_STRING DeviceDescription
Definition: pci.h:69
static NTSTATUS FdoEnumerateDevices(PDEVICE_OBJECT DeviceObject)
Definition: fdo.c:94
#define TAG_PCI
Definition: pci.h:6
Definition: typedefs.h:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
LIST_ENTRY DeviceListHead
Definition: pci.h:88
Status
Definition: gdiplustypes.h:24
NTSTATUS PciCreateDeviceIDString(PUNICODE_STRING DeviceID, PPCI_DEVICE Device)
Definition: pci.c:241
static NTSTATUS PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs)
Definition: fdo.c:269
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _DEVICE_RELATIONS DEVICE_RELATIONS
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
UNICODE_STRING InstanceID
Definition: pci.h:63
#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:261
#define ULONG_PTR
Definition: config.h:101
UNICODE_STRING DeviceID
Definition: pci.h:61
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2966
UNICODE_STRING CompatibleIDs
Definition: pci.h:67

Referenced by FdoPnpControl().

◆ FdoStartDevice()

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

Definition at line 386 of file fdo.c.

389 {
390  PFDO_DEVICE_EXTENSION DeviceExtension;
392  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
393  ULONG FoundBusNumber = FALSE;
394  ULONG i;
395 
396  DPRINT("Called\n");
397 
399 
400  AllocatedResources = IoGetCurrentIrpStackLocation(Irp)->Parameters.StartDevice.AllocatedResources;
401  if (!AllocatedResources)
402  {
403  DPRINT("No allocated resources sent to driver\n");
405  }
406 
407  if (AllocatedResources->Count < 1)
408  {
409  DPRINT("Not enough allocated resources sent to driver\n");
411  }
412 
413  if (AllocatedResources->List[0].PartialResourceList.Version != 1 ||
414  AllocatedResources->List[0].PartialResourceList.Revision != 1)
416 
417  ASSERT(DeviceExtension->State == dsStopped);
418 
419  /* By default, use the bus number in the resource list header */
420  DeviceExtension->BusNumber = AllocatedResources->List[0].BusNumber;
421 
422  for (i = 0; i < AllocatedResources->List[0].PartialResourceList.Count; i++)
423  {
424  ResourceDescriptor = &AllocatedResources->List[0].PartialResourceList.PartialDescriptors[i];
425  switch (ResourceDescriptor->Type)
426  {
428  if (FoundBusNumber || ResourceDescriptor->u.BusNumber.Length != 1)
430 
431  /* Use this one instead */
432  ASSERT(AllocatedResources->List[0].BusNumber == ResourceDescriptor->u.BusNumber.Start);
433  DeviceExtension->BusNumber = ResourceDescriptor->u.BusNumber.Start;
434  DPRINT("Found bus number resource: %lu\n", DeviceExtension->BusNumber);
435  FoundBusNumber = TRUE;
436  break;
437 
438  default:
439  DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
440  }
441  }
442 
443  InitializeListHead(&DeviceExtension->DeviceListHead);
444  KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
445  DeviceExtension->DeviceListCount = 0;
446  DeviceExtension->State = dsStarted;
447 
450  &DeviceExtension->ListEntry,
452 
453  Irp->IoStatus.Information = 0;
454 
455  return STATUS_SUCCESS;
456 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:311
#define TRUE
Definition: types.h:120
ULONG DeviceListCount
Definition: pci.h:90
#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
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
LIST_ENTRY ListEntry
Definition: pci.h:82
KSPIN_LOCK DeviceListLock
Definition: pci.h:92
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
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
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371 u
void DPRINT(...)
Definition: polytest.cpp:61
KSPIN_LOCK BusListLock
Definition: pci.h:104
PCI_DEVICE_STATE State
Definition: pci.h:86
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG BusNumber
Definition: pci.h:84
LIST_ENTRY BusListHead
Definition: pci.h:102
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
LIST_ENTRY DeviceListHead
Definition: pci.h:88
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371::@379 BusNumber
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966

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;
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
_In_ PIRP Irp
Definition: csq.h:116
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:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
Definition: fdo.c:17
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

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

◆ 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:63
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define IO_NO_INCREMENT
Definition: iotypes.h:566

Variable Documentation

◆ ForwardIrpAndWaitCompletion

IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
static

Definition at line 17 of file fdo.c.

Referenced by ForwardIrpAndWait().