ReactOS  0.4.15-dev-5640-g0dde428
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 FdoLocateChildDevice (PPCI_DEVICE *Device, PFDO_DEVICE_EXTENSION DeviceExtension, PCI_SLOT_NUMBER SlotNumber, PPCI_COMMON_CONFIG PciConfig)
 
static BOOLEAN PciIsDebuggingDevice (_In_ ULONG Bus, _In_ PCI_SLOT_NUMBER SlotNumber)
 
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)
 

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 78 of file fdo.c.

80 {
81  PFDO_DEVICE_EXTENSION DeviceExtension;
82  PCI_COMMON_CONFIG PciConfig;
86  ULONG FunctionNumber;
87  ULONG Size;
89 
90  DPRINT("Called\n");
91 
92  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
93 
94  DeviceExtension->DeviceListCount = 0;
95 
96  /* Enumerate devices on the PCI bus */
97  SlotNumber.u.AsULONG = 0;
99  {
100  SlotNumber.u.bits.DeviceNumber = DeviceNumber;
101  for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
102  {
103  SlotNumber.u.bits.FunctionNumber = FunctionNumber;
104 
105  DPRINT("Bus %1lu Device %2lu Func %1lu\n",
106  DeviceExtension->BusNumber,
107  DeviceNumber,
108  FunctionNumber);
109 
110  RtlZeroMemory(&PciConfig,
111  sizeof(PCI_COMMON_CONFIG));
112 
114  DeviceExtension->BusNumber,
115  SlotNumber.u.AsULONG,
116  &PciConfig,
118  DPRINT("Size %lu\n", Size);
119  if (Size != PCI_COMMON_HDR_LENGTH ||
120  PciConfig.VendorID == PCI_INVALID_VENDORID ||
121  PciConfig.VendorID == 0)
122  {
123  if (FunctionNumber == 0)
124  {
125  break;
126  }
127  else
128  {
129  continue;
130  }
131  }
132 
133  DPRINT("Bus %1lu Device %2lu Func %1lu VenID 0x%04hx DevID 0x%04hx\n",
134  DeviceExtension->BusNumber,
135  DeviceNumber,
136  FunctionNumber,
137  PciConfig.VendorID,
138  PciConfig.DeviceID);
139 
140  Status = FdoLocateChildDevice(&Device, DeviceExtension, SlotNumber, &PciConfig);
141  if (!NT_SUCCESS(Status))
142  {
144  if (!Device)
145  {
146  /* FIXME: Cleanup resources for already discovered devices */
148  }
149 
151  sizeof(PCI_DEVICE));
152 
153  Device->BusNumber = DeviceExtension->BusNumber;
154 
155  if (PciIsDebuggingDevice(DeviceExtension->BusNumber, SlotNumber))
156  {
157  Device->IsDebuggingDevice = TRUE;
158 
159  /*
160  * ReactOS-specific: apply a hack
161  * to prevent driver installation for the debugging device.
162  * NOTE: Nothing to do for IEEE 1394 devices; NT5.1 and NT5.2
163  * support IEEE 1394 debugging.
164  *
165  * FIXME: We should set the device problem code
166  * CM_PROB_USED_BY_DEBUGGER instead.
167  */
168  if (PciConfig.BaseClass != PCI_CLASS_SERIAL_BUS_CTLR ||
169  PciConfig.SubClass != PCI_SUBCLASS_SB_IEEE1394)
170  {
171  PciConfig.VendorID = 0xDEAD;
172  PciConfig.DeviceID = 0xBEEF;
173  }
174  }
175 
176  RtlCopyMemory(&Device->SlotNumber,
177  &SlotNumber,
178  sizeof(PCI_SLOT_NUMBER));
179 
180  RtlCopyMemory(&Device->PciConfig,
181  &PciConfig,
182  sizeof(PCI_COMMON_CONFIG));
183 
185  &DeviceExtension->DeviceListHead,
186  &Device->ListEntry,
187  &DeviceExtension->DeviceListLock);
188  }
189 
190  DeviceExtension->DeviceListCount++;
191 
192  /* Skip to next device if the current one is not a multifunction device */
193  if ((FunctionNumber == 0) &&
194  ((PciConfig.HeaderType & 0x80) == 0))
195  {
196  break;
197  }
198  }
199  }
200 
201  DPRINT("Done\n");
202 
203  return STATUS_SUCCESS;
204 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
ULONG DeviceListCount
Definition: pci.h:94
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_CLASS_SERIAL_BUS_CTLR
Definition: iotypes.h:4115
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
KSPIN_LOCK DeviceListLock
Definition: pci.h:96
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
Status
Definition: gdiplustypes.h:24
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601
#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:88
#define TAG_PCI
Definition: pci.h:8
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
LIST_ENTRY DeviceListHead
Definition: pci.h:92
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3599
#define PCI_SUBCLASS_SB_IEEE1394
Definition: iotypes.h:4204
static BOOLEAN PciIsDebuggingDevice(_In_ ULONG Bus, _In_ PCI_SLOT_NUMBER SlotNumber)
Definition: fdo.c:54
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:18
_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 18 of file fdo.c.

23 {
24  PLIST_ENTRY CurrentEntry;
25  PPCI_DEVICE CurrentDevice;
26 
27  DPRINT("Called\n");
28 
29  CurrentEntry = DeviceExtension->DeviceListHead.Flink;
30  while (CurrentEntry != &DeviceExtension->DeviceListHead)
31  {
32  CurrentDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
33 
34  /* If both vendor ID and device ID match, it is the same device */
35  if ((PciConfig->VendorID == CurrentDevice->PciConfig.VendorID) &&
36  (PciConfig->DeviceID == CurrentDevice->PciConfig.DeviceID) &&
37  (SlotNumber.u.AsULONG == CurrentDevice->SlotNumber.u.AsULONG))
38  {
39  *Device = CurrentDevice;
40  DPRINT("Done\n");
41  return STATUS_SUCCESS;
42  }
43 
44  CurrentEntry = CurrentEntry->Flink;
45  }
46 
47  *Device = NULL;
48  DPRINT("Done\n");
49  return STATUS_UNSUCCESSFUL;
50 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
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
union _PCI_SLOT_NUMBER::@3819 u
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
LIST_ENTRY DeviceListHead
Definition: pci.h:92
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:19
#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:21

Referenced by FdoEnumerateDevices().

◆ FdoPnpControl()

NTSTATUS FdoPnpControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 469 of file fdo.c.

480 {
481  PFDO_DEVICE_EXTENSION DeviceExtension;
483  NTSTATUS Status = Irp->IoStatus.Status;
484 
485  DPRINT("Called\n");
486 
487  DeviceExtension = DeviceObject->DeviceExtension;
488 
490  switch (IrpSp->MinorFunction)
491  {
492 #if 0
495  break;
496 
499  break;
500 
503  break;
504 
507  break;
508 #endif
510  if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
511  break;
512 
514  Irp->IoStatus.Status = Status;
516  return Status;
517 #if 0
520  break;
521 
524  break;
525 #endif
526  case IRP_MN_START_DEVICE:
527  DPRINT("IRP_MN_START_DEVICE received\n");
529 
530  if (IoForwardIrpSynchronously(DeviceExtension->Ldo, Irp))
531  {
532  Status = Irp->IoStatus.Status;
533  if (NT_SUCCESS(Status))
534  {
536  }
537  }
538 
539  Irp->IoStatus.Status = Status;
541  return Status;
542 
544  /* We don't support stopping yet */
546  Irp->IoStatus.Status = Status;
548  return Status;
549 
550  case IRP_MN_STOP_DEVICE:
551  /* We can't fail this one so we fail the QUERY_STOP request that precedes it */
552  break;
553 #if 0
556  break;
557 #endif
558 
560  break;
561 
563  /* Detach the device object from the device stack */
564  IoDetachDevice(DeviceExtension->Ldo);
565 
566  /* Delete the device object */
568 
569  /* Return success */
571  break;
572 
575  /* Don't print the warning, too much noise */
576  break;
577 
578  default:
579  DPRINT1("Unknown PNP minor function 0x%x\n", IrpSp->MinorFunction);
580  break;
581  }
582 
583  Irp->IoStatus.Status = Status;
585  Status = IoCallDriver(DeviceExtension->Ldo, Irp);
586 
587  DPRINT("Leaving. Status 0x%lx\n", Status);
588 
589  return Status;
590 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_REMOVE_DEVICE
static NTSTATUS FdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:393
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
PDEVICE_OBJECT Ldo
Definition: pci.h:98
_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:208
#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
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
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IRP_MN_QUERY_CAPABILITIES

Referenced by PciPnpControl().

◆ FdoPowerControl()

NTSTATUS FdoPowerControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 594 of file fdo.c.

605 {
606  PFDO_DEVICE_EXTENSION DeviceExtension;
608 
609  DPRINT("Called\n");
610 
611  DeviceExtension = DeviceObject->DeviceExtension;
612 
615  Status = PoCallDriver(DeviceExtension->Ldo, Irp);
616 
617  DPRINT("Leaving. Status 0x%X\n", Status);
618 
619  return Status;
620 }
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT Ldo
Definition: pci.h:98
_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 208 of file fdo.c.

212 {
213  PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
214  PFDO_DEVICE_EXTENSION DeviceExtension;
215  PDEVICE_RELATIONS Relations;
216  PLIST_ENTRY CurrentEntry;
219  BOOLEAN ErrorOccurred;
220  NTSTATUS ErrorStatus;
221  ULONG Size;
222  ULONG i;
223 
225 
226  DPRINT("Called\n");
227 
228  ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
229 
231 
232  ErrorOccurred = FALSE;
233 
235 
236  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
237 
238  if (Irp->IoStatus.Information)
239  {
240  /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
241  structure so we must merge this structure with our own */
242  DPRINT1("FIXME: leaking old bus relations\n");
243  }
244 
245  Size = sizeof(DEVICE_RELATIONS) +
246  sizeof(Relations->Objects) * (DeviceExtension->DeviceListCount - 1);
248  if (!Relations)
250 
251  Relations->Count = DeviceExtension->DeviceListCount;
252 
253  i = 0;
254  CurrentEntry = DeviceExtension->DeviceListHead.Flink;
255  while (CurrentEntry != &DeviceExtension->DeviceListHead)
256  {
257  Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
258 
259  PdoDeviceExtension = NULL;
260 
261  if (!Device->Pdo)
262  {
263  /* Create a physical device object for the
264  device as it does not already have one */
265  Status = IoCreateDevice(DeviceObject->DriverObject,
266  sizeof(PDO_DEVICE_EXTENSION),
267  NULL,
270  FALSE,
271  &Device->Pdo);
272  if (!NT_SUCCESS(Status))
273  {
274  DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
275  ErrorStatus = Status;
276  ErrorOccurred = TRUE;
277  break;
278  }
279 
280  Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
281 
282  //Device->Pdo->Flags |= DO_POWER_PAGABLE;
283 
284  PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension;
285 
286  RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
287 
288  PdoDeviceExtension->Common.IsFDO = FALSE;
289 
290  PdoDeviceExtension->Common.DeviceObject = Device->Pdo;
291 
292  PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
293 
294  PdoDeviceExtension->Fdo = DeviceObject;
295 
296  PdoDeviceExtension->PciDevice = Device;
297 
298  /* Add Device ID string */
299  Status = PciCreateDeviceIDString(&PdoDeviceExtension->DeviceID, Device);
300  if (!NT_SUCCESS(Status))
301  {
302  ErrorStatus = Status;
303  ErrorOccurred = TRUE;
304  break;
305  }
306 
307  DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceID.Buffer);
308 
309  /* Add Instance ID string */
310  Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceID, Device);
311  if (!NT_SUCCESS(Status))
312  {
313  ErrorStatus = Status;
314  ErrorOccurred = TRUE;
315  break;
316  }
317 
318  /* Add Hardware IDs string */
319  Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs, Device);
320  if (!NT_SUCCESS(Status))
321  {
322  ErrorStatus = Status;
323  ErrorOccurred = TRUE;
324  break;
325  }
326 
327  /* Add Compatible IDs string */
328  Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIDs, Device);
329  if (!NT_SUCCESS(Status))
330  {
331  ErrorStatus = Status;
332  ErrorOccurred = TRUE;
333  break;
334  }
335 
336  /* Add device description string */
338  if (!NT_SUCCESS(Status))
339  {
340  ErrorStatus = Status;
341  ErrorOccurred = TRUE;
342  break;
343  }
344 
345  /* Add device location string */
347  if (!NT_SUCCESS(Status))
348  {
349  ErrorStatus = Status;
350  ErrorOccurred = TRUE;
351  break;
352  }
353  }
354 
355  /* Reference the physical device object. The PnP manager
356  will dereference it again when it is no longer needed */
358 
359  Relations->Objects[i] = Device->Pdo;
360 
361  i++;
362 
363  CurrentEntry = CurrentEntry->Flink;
364  }
365 
366  if (ErrorOccurred)
367  {
368  /* FIXME: Cleanup all new PDOs created in this call. Please give me SEH!!! ;-) */
369  /* FIXME: Should IoAttachDeviceToDeviceStack() be undone? */
370  if (PdoDeviceExtension)
371  {
372  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceID);
373  RtlFreeUnicodeString(&PdoDeviceExtension->InstanceID);
374  RtlFreeUnicodeString(&PdoDeviceExtension->HardwareIDs);
375  RtlFreeUnicodeString(&PdoDeviceExtension->CompatibleIDs);
376  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceDescription);
377  RtlFreeUnicodeString(&PdoDeviceExtension->DeviceLocation);
378  }
379 
380  ExFreePoolWithTag(Relations, TAG_PCI);
381  return ErrorStatus;
382  }
383 
384  Irp->IoStatus.Information = (ULONG_PTR)Relations;
385 
386  DPRINT("Done\n");
387 
388  return Status;
389 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
ULONG DeviceListCount
Definition: pci.h:94
#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:430
#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:61
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PPCI_DEVICE PciDevice
Definition: pci.h:63
static NTSTATUS PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs)
Definition: fdo.c:246
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:59
#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:75
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UNICODE_STRING HardwareIDs
Definition: pci.h:69
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UNICODE_STRING DeviceDescription
Definition: pci.h:73
static NTSTATUS FdoEnumerateDevices(PDEVICE_OBJECT DeviceObject)
Definition: fdo.c:78
#define TAG_PCI
Definition: pci.h:8
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
LIST_ENTRY DeviceListHead
Definition: pci.h:92
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:224
static NTSTATUS PciCreateInstanceIDString(PUNICODE_STRING InstanceID, ULONG PeripheralNumber)
Definition: fdo.c:268
NTSTATUS PciCreateDeviceIDString(PUNICODE_STRING DeviceID, PPCI_DEVICE Device)
Definition: pci.c:284
UNICODE_STRING InstanceID
Definition: pci.h:67
NTSTATUS PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device)
Definition: pci.c:698
#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:65
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
UNICODE_STRING CompatibleIDs
Definition: pci.h:71
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137

Referenced by FdoPnpControl().

◆ FdoStartDevice()

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

Definition at line 393 of file fdo.c.

396 {
397  PFDO_DEVICE_EXTENSION DeviceExtension;
399  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
400  ULONG FoundBusNumber = FALSE;
401  ULONG i;
402 
403  DPRINT("Called\n");
404 
405  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
406 
407  AllocatedResources = IoGetCurrentIrpStackLocation(Irp)->Parameters.StartDevice.AllocatedResources;
408  if (!AllocatedResources)
409  {
410  DPRINT("No allocated resources sent to driver\n");
412  }
413 
414  if (AllocatedResources->Count < 1)
415  {
416  DPRINT("Not enough allocated resources sent to driver\n");
418  }
419 
420  if (AllocatedResources->List[0].PartialResourceList.Version != 1 ||
421  AllocatedResources->List[0].PartialResourceList.Revision != 1)
423 
424  ASSERT(DeviceExtension->State == dsStopped);
425 
426  /* By default, use the bus number in the resource list header */
427  DeviceExtension->BusNumber = AllocatedResources->List[0].BusNumber;
428 
429  for (i = 0; i < AllocatedResources->List[0].PartialResourceList.Count; i++)
430  {
431  ResourceDescriptor = &AllocatedResources->List[0].PartialResourceList.PartialDescriptors[i];
432  switch (ResourceDescriptor->Type)
433  {
435  if (FoundBusNumber || ResourceDescriptor->u.BusNumber.Length < 1)
437 
438  /* Use this one instead */
439  ASSERT(AllocatedResources->List[0].BusNumber == ResourceDescriptor->u.BusNumber.Start);
440  DeviceExtension->BusNumber = ResourceDescriptor->u.BusNumber.Start;
441  DPRINT("Found bus number resource: %lu\n", DeviceExtension->BusNumber);
442  FoundBusNumber = TRUE;
443  break;
444 
445  default:
446  DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
447  }
448  }
449 
450  InitializeListHead(&DeviceExtension->DeviceListHead);
451  KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
452  DeviceExtension->DeviceListCount = 0;
453  DeviceExtension->State = dsStarted;
454 
457  &DeviceExtension->ListEntry,
459 
460  Irp->IoStatus.Information = 0;
461 
462  return STATUS_SUCCESS;
463 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
ULONG DeviceListCount
Definition: pci.h:94
#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:86
KSPIN_LOCK DeviceListLock
Definition: pci.h:96
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:240
#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:108
PCI_DEVICE_STATE State
Definition: pci.h:90
ULONG BusNumber
Definition: pci.h:88
LIST_ENTRY BusListHead
Definition: pci.h:106
LIST_ENTRY DeviceListHead
Definition: pci.h:92
__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
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@389 BusNumber
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
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381 u
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

Referenced by FdoPnpControl().

◆ PciIsDebuggingDevice()

static BOOLEAN PciIsDebuggingDevice ( _In_ ULONG  Bus,
_In_ PCI_SLOT_NUMBER  SlotNumber 
)
static

Definition at line 54 of file fdo.c.

57 {
58  ULONG i;
59 
60  if (!HasDebuggingDevice)
61  return FALSE;
62 
63  for (i = 0; i < RTL_NUMBER_OF(PciDebuggingDevice); ++i)
64  {
65  if (PciDebuggingDevice[i].InUse &&
66  PciDebuggingDevice[i].BusNumber == Bus &&
67  PciDebuggingDevice[i].DeviceNumber == SlotNumber.u.bits.DeviceNumber &&
68  PciDebuggingDevice[i].FunctionNumber == SlotNumber.u.bits.FunctionNumber)
69  {
70  return TRUE;
71  }
72  }
73 
74  return FALSE;
75 }
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
BOOLEAN HasDebuggingDevice
Definition: pci.c:32
PCI_TYPE1_CFG_CYCLE_BITS PciDebuggingDevice[2]
Definition: pci.c:33
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 RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
unsigned int ULONG
Definition: retypes.h:1
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229

Referenced by FdoEnumerateDevices().