ReactOS  0.4.15-dev-3291-gea4c1a0
pci.c File Reference
#include "pci.h"
#include <stdio.h>
#include <debug.h>
Include dependency graph for pci.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS NTAPI PciDispatchDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PciAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
static NTSTATUS NTAPI PciPowerControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PciPnpControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI PciUnload (IN PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
NTSTATUS PciCreateDeviceIDString (PUNICODE_STRING DeviceID, PPCI_DEVICE Device)
 
NTSTATUS PciCreateInstanceIDString (PUNICODE_STRING InstanceID, PPCI_DEVICE Device)
 
NTSTATUS PciCreateHardwareIDsString (PUNICODE_STRING HardwareIDs, PPCI_DEVICE Device)
 
NTSTATUS PciCreateCompatibleIDsString (PUNICODE_STRING CompatibleIDs, PPCI_DEVICE Device)
 
NTSTATUS PciCreateDeviceDescriptionString (PUNICODE_STRING DeviceDescription, PPCI_DEVICE Device)
 
NTSTATUS PciCreateDeviceLocationString (PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device)
 
NTSTATUS PciDuplicateUnicodeString (IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
 

Variables

static DRIVER_DISPATCH PciDispatchDeviceControl
 
static DRIVER_ADD_DEVICE PciAddDevice
 
static DRIVER_DISPATCH PciPowerControl
 
static DRIVER_DISPATCH PciPnpControl
 
PPCI_DRIVER_EXTENSION DriverExtension = NULL
 
DRIVER_UNLOAD PciUnload
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file pci.c.

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 200 of file pci.c.

203 {
205 
207  DPRINT("Peripheral Component Interconnect Bus Driver\n");
208 
210  DriverObject->MajorFunction[IRP_MJ_PNP] = PciPnpControl;
211  DriverObject->MajorFunction[IRP_MJ_POWER] = PciPowerControl;
212  DriverObject->DriverExtension->AddDevice = PciAddDevice;
213  DriverObject->DriverUnload = PciUnload;
214 
216  DriverObject,
217  sizeof(PCI_DRIVER_EXTENSION),
219  if (!NT_SUCCESS(Status))
220  return Status;
221 
223 
226 
227  return STATUS_SUCCESS;
228 }
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1799
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
static DRIVER_DISPATCH PciPnpControl
Definition: pci.c:26
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KSPIN_LOCK BusListLock
Definition: pci.h:105
#define IRP_MJ_POWER
LIST_ENTRY BusListHead
Definition: pci.h:103
static DRIVER_DISPATCH PciPowerControl
Definition: pci.c:23
static DRIVER_ADD_DEVICE PciAddDevice
Definition: pci.c:20
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
static DRIVER_DISPATCH PciDispatchDeviceControl
Definition: pci.c:17
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
DRIVER_UNLOAD PciUnload
Definition: pci.c:186
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

◆ PciAddDevice()

static NTSTATUS NTAPI PciAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)
static

Definition at line 141 of file pci.c.

144 {
145  PFDO_DEVICE_EXTENSION DeviceExtension;
148 
149  DPRINT("Called\n");
150  if (PhysicalDeviceObject == NULL)
151  return STATUS_SUCCESS;
152 
154  sizeof(FDO_DEVICE_EXTENSION),
155  NULL,
158  TRUE,
159  &Fdo);
160  if (!NT_SUCCESS(Status))
161  {
162  DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
163  return Status;
164  }
165 
166  DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
167 
168  RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
169 
170  DeviceExtension->Common.IsFDO = TRUE;
171 
172  DeviceExtension->Ldo = IoAttachDeviceToDeviceStack(Fdo,
174 
175  DeviceExtension->State = dsStopped;
176 
177  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
178 
179  //Fdo->Flags |= DO_POWER_PAGABLE;
180 
181  DPRINT("Done AddDevice\n");
182 
183  return STATUS_SUCCESS;
184 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
PDEVICE_OBJECT Ldo
Definition: pci.h:95
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCI_DEVICE_STATE State
Definition: pci.h:87
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:81
#define NULL
Definition: types.h:112
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 FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:148

◆ PciCreateCompatibleIDsString()

NTSTATUS PciCreateCompatibleIDsString ( PUNICODE_STRING  CompatibleIDs,
PPCI_DEVICE  Device 
)

Definition at line 314 of file pci.c.

316 {
317  WCHAR Buffer[256];
318  UNICODE_STRING BufferU;
319  ULONG Index;
320 
321  Index = 0;
322  Index += swprintf(&Buffer[Index],
323  L"PCI\\VEN_%04X&DEV_%04X&REV_%02X",
324  Device->PciConfig.VendorID,
325  Device->PciConfig.DeviceID,
326  Device->PciConfig.RevisionID);
327  Index++;
328 
329  Index += swprintf(&Buffer[Index],
330  L"PCI\\VEN_%04X&DEV_%04X",
331  Device->PciConfig.VendorID,
332  Device->PciConfig.DeviceID);
333  Index++;
334 
335  Index += swprintf(&Buffer[Index],
336  L"PCI\\VEN_%04X&CC_%02X%02X%02X",
337  Device->PciConfig.VendorID,
338  Device->PciConfig.BaseClass,
339  Device->PciConfig.SubClass,
340  Device->PciConfig.ProgIf);
341  Index++;
342 
343  Index += swprintf(&Buffer[Index],
344  L"PCI\\VEN_%04X&CC_%02X%02X",
345  Device->PciConfig.VendorID,
346  Device->PciConfig.BaseClass,
347  Device->PciConfig.SubClass);
348  Index++;
349 
350  Index += swprintf(&Buffer[Index],
351  L"PCI\\VEN_%04X",
352  Device->PciConfig.VendorID);
353  Index++;
354 
355  Index += swprintf(&Buffer[Index],
356  L"PCI\\CC_%02X%02X%02X",
357  Device->PciConfig.BaseClass,
358  Device->PciConfig.SubClass,
359  Device->PciConfig.ProgIf);
360  Index++;
361 
362  Index += swprintf(&Buffer[Index],
363  L"PCI\\CC_%02X%02X",
364  Device->PciConfig.BaseClass,
365  Device->PciConfig.SubClass);
366  Index++;
367 
369 
370  BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR);
371  BufferU.Buffer = Buffer;
372 
373  return PciDuplicateUnicodeString(0, &BufferU, CompatibleIDs);
374 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
NTSTATUS PciDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: pci.c:661
#define swprintf
Definition: precomp.h:40
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1

◆ PciCreateDeviceDescriptionString()

NTSTATUS PciCreateDeviceDescriptionString ( PUNICODE_STRING  DeviceDescription,
PPCI_DEVICE  Device 
)

Definition at line 378 of file pci.c.

380 {
382 
383  switch (Device->PciConfig.BaseClass)
384  {
385  case PCI_CLASS_PRE_20:
386  switch (Device->PciConfig.SubClass)
387  {
389  Description = L"VGA device";
390  break;
391 
392  default:
394  Description = L"PCI device";
395  break;
396  }
397  break;
398 
400  switch (Device->PciConfig.SubClass)
401  {
403  Description = L"SCSI controller";
404  break;
405 
407  Description = L"IDE controller";
408  break;
409 
411  Description = L"Floppy disk controller";
412  break;
413 
415  Description = L"IPI controller";
416  break;
417 
419  Description = L"RAID controller";
420  break;
421 
422  default:
423  Description = L"Mass storage controller";
424  break;
425  }
426  break;
427 
429  switch (Device->PciConfig.SubClass)
430  {
432  Description = L"Ethernet controller";
433  break;
434 
436  Description = L"Token-Ring controller";
437  break;
438 
440  Description = L"FDDI controller";
441  break;
442 
444  Description = L"ATM controller";
445  break;
446 
447  default:
448  Description = L"Network controller";
449  break;
450  }
451  break;
452 
454  switch (Device->PciConfig.SubClass)
455  {
457  Description = L"VGA display controller";
458  break;
459 
461  Description = L"XGA display controller";
462  break;
463 
465  Description = L"Multimedia display controller";
466  break;
467 
468  default:
469  Description = L"Other display controller";
470  break;
471  }
472  break;
473 
475  switch (Device->PciConfig.SubClass)
476  {
478  Description = L"Multimedia video device";
479  break;
480 
482  Description = L"Multimedia audio device";
483  break;
484 
486  Description = L"Multimedia telephony device";
487  break;
488 
489  default:
490  Description = L"Other multimedia device";
491  break;
492  }
493  break;
494 
496  switch (Device->PciConfig.SubClass)
497  {
499  Description = L"PCI Memory";
500  break;
501 
503  Description = L"PCI Flash Memory";
504  break;
505 
506  default:
507  Description = L"Other memory controller";
508  break;
509  }
510  break;
511 
513  switch (Device->PciConfig.SubClass)
514  {
516  Description = L"PCI-Host bridge";
517  break;
518 
519  case PCI_SUBCLASS_BR_ISA:
520  Description = L"PCI-ISA bridge";
521  break;
522 
524  Description = L"PCI-EISA bridge";
525  break;
526 
527  case PCI_SUBCLASS_BR_MCA:
528  Description = L"PCI-Micro Channel bridge";
529  break;
530 
532  Description = L"PCI-PCI bridge";
533  break;
534 
536  Description = L"PCI-PCMCIA bridge";
537  break;
538 
540  Description = L"PCI-NUBUS bridge";
541  break;
542 
544  Description = L"PCI-CARDBUS bridge";
545  break;
546 
547  default:
548  Description = L"Other bridge device";
549  break;
550  }
551  break;
552 
554  switch (Device->PciConfig.SubClass)
555  {
556 
557  default:
558  Description = L"Communication device";
559  break;
560  }
561  break;
562 
564  switch (Device->PciConfig.SubClass)
565  {
566 
567  default:
568  Description = L"System device";
569  break;
570  }
571  break;
572 
573  case PCI_CLASS_INPUT_DEV:
574  switch (Device->PciConfig.SubClass)
575  {
576 
577  default:
578  Description = L"Input device";
579  break;
580  }
581  break;
582 
584  switch (Device->PciConfig.SubClass)
585  {
586 
587  default:
588  Description = L"Docking station";
589  break;
590  }
591  break;
592 
593  case PCI_CLASS_PROCESSOR:
594  switch (Device->PciConfig.SubClass)
595  {
596 
597  default:
598  Description = L"Processor";
599  break;
600  }
601  break;
602 
604  switch (Device->PciConfig.SubClass)
605  {
607  Description = L"FireWire controller";
608  break;
609 
611  Description = L"ACCESS bus controller";
612  break;
613 
614  case PCI_SUBCLASS_SB_SSA:
615  Description = L"SSA controller";
616  break;
617 
618  case PCI_SUBCLASS_SB_USB:
619  Description = L"USB controller";
620  break;
621 
623  Description = L"Fibre Channel controller";
624  break;
625 
627  Description = L"SMBus controller";
628  break;
629 
630  default:
631  Description = L"Other serial bus controller";
632  break;
633  }
634  break;
635 
636  default:
637  Description = L"Other PCI Device";
638  break;
639  }
640 
642 }
#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR
Definition: iotypes.h:4137
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define PCI_SUBCLASS_NET_ETHERNET_CTLR
Definition: iotypes.h:4136
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_CLASS_SERIAL_BUS_CTLR
Definition: iotypes.h:4115
#define PCI_SUBCLASS_VID_3D_CTLR
Definition: iotypes.h:4146
#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR
Definition: iotypes.h:4128
#define PCI_SUBCLASS_SB_USB
Definition: iotypes.h:4207
#define PCI_SUBCLASS_MEM_RAM
Definition: iotypes.h:4156
#define PCI_CLASS_MULTIMEDIA_DEV
Definition: iotypes.h:4107
static const WCHAR Description[]
Definition: oid.c:1266
#define PCI_SUBCLASS_MEM_FLASH
Definition: iotypes.h:4157
#define PCI_SUBCLASS_PRE_20_NON_VGA
Definition: iotypes.h:4124
#define PCI_SUBCLASS_MM_TELEPHONY_DEV
Definition: iotypes.h:4152
#define PCI_SUBCLASS_MM_AUDIO_DEV
Definition: iotypes.h:4151
#define PCI_SUBCLASS_SB_FIBRE_CHANNEL
Definition: iotypes.h:4208
#define PCI_SUBCLASS_SB_SMBUS
Definition: iotypes.h:4209
#define PCI_SUBCLASS_BR_CARDBUS
Definition: iotypes.h:4168
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:430
#define PCI_SUBCLASS_NET_ATM_CTLR
Definition: iotypes.h:4139
#define PCI_SUBCLASS_MSC_FLOPPY_CTLR
Definition: iotypes.h:4130
#define PCI_SUBCLASS_MSC_IPI_CTLR
Definition: iotypes.h:4131
#define PCI_SUBCLASS_MSC_RAID_CTLR
Definition: iotypes.h:4132
#define PCI_SUBCLASS_NET_FDDI_CTLR
Definition: iotypes.h:4138
#define PCI_SUBCLASS_VID_VGA_CTLR
Definition: iotypes.h:4144
#define PCI_SUBCLASS_BR_MCA
Definition: iotypes.h:4164
#define PCI_CLASS_DISPLAY_CTLR
Definition: iotypes.h:4106
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const WCHAR L[]
Definition: oid.c:1250
#define PCI_SUBCLASS_BR_PCMCIA
Definition: iotypes.h:4166
#define PCI_CLASS_MEMORY_CTLR
Definition: iotypes.h:4108
#define PCI_SUBCLASS_BR_PCI_TO_PCI
Definition: iotypes.h:4165
#define PCI_SUBCLASS_MSC_IDE_CTLR
Definition: iotypes.h:4129
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define PCI_CLASS_SIMPLE_COMMS_CTLR
Definition: iotypes.h:4110
#define PCI_SUBCLASS_SB_SSA
Definition: iotypes.h:4206
#define PCI_CLASS_NETWORK_CTLR
Definition: iotypes.h:4105
#define PCI_SUBCLASS_MM_VIDEO_DEV
Definition: iotypes.h:4150
#define PCI_SUBCLASS_VID_XGA_CTLR
Definition: iotypes.h:4145
#define PCI_SUBCLASS_SB_IEEE1394
Definition: iotypes.h:4204
#define PCI_CLASS_INPUT_DEV
Definition: iotypes.h:4112
#define PCI_SUBCLASS_BR_NUBUS
Definition: iotypes.h:4167
#define PCI_SUBCLASS_PRE_20_VGA
Definition: iotypes.h:4125
#define PCI_CLASS_DOCKING_STATION
Definition: iotypes.h:4113
#define PCI_SUBCLASS_BR_HOST
Definition: iotypes.h:4161
#define PCI_CLASS_PROCESSOR
Definition: iotypes.h:4114
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4109
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PCI_SUBCLASS_BR_ISA
Definition: iotypes.h:4162
#define PCI_SUBCLASS_SB_ACCESS
Definition: iotypes.h:4205
#define PCI_CLASS_BASE_SYSTEM_DEV
Definition: iotypes.h:4111
#define PCI_SUBCLASS_BR_EISA
Definition: iotypes.h:4163
#define PCI_CLASS_MASS_STORAGE_CTLR
Definition: iotypes.h:4104
#define PCI_CLASS_PRE_20
Definition: iotypes.h:4103

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().

◆ PciCreateDeviceIDString()

NTSTATUS PciCreateDeviceIDString ( PUNICODE_STRING  DeviceID,
PPCI_DEVICE  Device 
)

Definition at line 232 of file pci.c.

234 {
235  WCHAR Buffer[256];
236 
238  L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
239  Device->PciConfig.VendorID,
240  Device->PciConfig.DeviceID,
241  (Device->PciConfig.u.type0.SubSystemID << 16) +
242  Device->PciConfig.u.type0.SubVendorID,
243  Device->PciConfig.RevisionID);
244 
246 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define swprintf
Definition: precomp.h:40
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceID
Definition: wdfpdo.h:275
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by FdoQueryBusRelations().

◆ PciCreateDeviceLocationString()

NTSTATUS PciCreateDeviceLocationString ( PUNICODE_STRING  DeviceLocation,
PPCI_DEVICE  Device 
)

Definition at line 646 of file pci.c.

648 {
649  WCHAR Buffer[256];
650 
652  L"PCI-Bus %lu, Device %u, Function %u",
653  Device->BusNumber,
654  Device->SlotNumber.u.bits.DeviceNumber,
655  Device->SlotNumber.u.bits.FunctionNumber);
656 
658 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define swprintf
Definition: precomp.h:40
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING DeviceLocation
Definition: wdfpdo.h:430
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().

◆ PciCreateHardwareIDsString()

NTSTATUS PciCreateHardwareIDsString ( PUNICODE_STRING  HardwareIDs,
PPCI_DEVICE  Device 
)

Definition at line 262 of file pci.c.

264 {
265  WCHAR Buffer[256];
266  UNICODE_STRING BufferU;
267  ULONG Index;
268 
269  Index = 0;
270  Index += swprintf(&Buffer[Index],
271  L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
272  Device->PciConfig.VendorID,
273  Device->PciConfig.DeviceID,
274  (Device->PciConfig.u.type0.SubSystemID << 16) +
275  Device->PciConfig.u.type0.SubVendorID,
276  Device->PciConfig.RevisionID);
277  Index++;
278 
279  Index += swprintf(&Buffer[Index],
280  L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X",
281  Device->PciConfig.VendorID,
282  Device->PciConfig.DeviceID,
283  (Device->PciConfig.u.type0.SubSystemID << 16) +
284  Device->PciConfig.u.type0.SubVendorID);
285  Index++;
286 
287  Index += swprintf(&Buffer[Index],
288  L"PCI\\VEN_%04X&DEV_%04X&CC_%02X%02X%02X",
289  Device->PciConfig.VendorID,
290  Device->PciConfig.DeviceID,
291  Device->PciConfig.BaseClass,
292  Device->PciConfig.SubClass,
293  Device->PciConfig.ProgIf);
294  Index++;
295 
296  Index += swprintf(&Buffer[Index],
297  L"PCI\\VEN_%04X&DEV_%04X&CC_%02X%02X",
298  Device->PciConfig.VendorID,
299  Device->PciConfig.DeviceID,
300  Device->PciConfig.BaseClass,
301  Device->PciConfig.SubClass);
302  Index++;
303 
305 
306  BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR);
307  BufferU.Buffer = Buffer;
308 
309  return PciDuplicateUnicodeString(0, &BufferU, HardwareIDs);
310 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
NTSTATUS PciDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: pci.c:661
#define swprintf
Definition: precomp.h:40
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1

◆ PciCreateInstanceIDString()

NTSTATUS PciCreateInstanceIDString ( PUNICODE_STRING  InstanceID,
PPCI_DEVICE  Device 
)

Definition at line 250 of file pci.c.

252 {
253  WCHAR Buffer[3];
254 
255  swprintf(Buffer, L"%02X", Device->SlotNumber.u.AsULONG & 0xff);
256 
258 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define swprintf
Definition: precomp.h:40
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING InstanceID
Definition: wdfpdo.h:306
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ PciDispatchDeviceControl()

static NTSTATUS NTAPI PciDispatchDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 37 of file pci.c.

40 {
43 
45  DPRINT("Called. IRP is at (0x%p)\n", Irp);
46 
47  Irp->IoStatus.Information = 0;
48 
50  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
51  {
52  default:
53  DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
55  break;
56  }
57 
58  if (Status != STATUS_PENDING)
59  {
60  Irp->IoStatus.Status = Status;
61 
62  DPRINT("Completing IRP at 0x%p\n", Irp);
63 
65  }
66 
67  DPRINT("Leaving. Status 0x%X\n", Status);
68 
69  return Status;
70 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define STATUS_PENDING
Definition: ntstatus.h:82
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

◆ PciDuplicateUnicodeString()

NTSTATUS PciDuplicateUnicodeString ( IN ULONG  Flags,
IN PCUNICODE_STRING  SourceString,
OUT PUNICODE_STRING  DestinationString 
)

Definition at line 661 of file pci.c.

665 {
666  if (SourceString == NULL ||
667  DestinationString == NULL ||
671  Flags >= 4)
672  {
674  }
675 
676  if ((SourceString->Length == 0) &&
679  {
683  }
684  else
685  {
686  USHORT DestMaxLength = SourceString->Length;
687 
689  DestMaxLength += sizeof(UNICODE_NULL);
690 
692  if (DestinationString->Buffer == NULL)
693  return STATUS_NO_MEMORY;
694 
697  DestinationString->MaximumLength = DestMaxLength;
698 
701  }
702 
703  return STATUS_SUCCESS;
704 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
#define TAG_PCI
Definition: pci.h:7
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
unsigned short MaximumLength
Definition: sprintf.c:452

Referenced by PciCreateCompatibleIDsString(), PciCreateHardwareIDsString(), PdoQueryDeviceText(), and PdoQueryId().

◆ PciPnpControl()

static NTSTATUS NTAPI PciPnpControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 75 of file pci.c.

86 {
87  PCOMMON_DEVICE_EXTENSION DeviceExtension;
89 
90  DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
91 
92  DPRINT("IsFDO %u\n", DeviceExtension->IsFDO);
93 
94  if (DeviceExtension->IsFDO)
95  {
97  }
98  else
99  {
101  }
102 
103  return Status;
104 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS PdoPnpControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pdo.c:1500
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
Status
Definition: gdiplustypes.h:24
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
NTSTATUS FdoPnpControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: fdo.c:468
#define DPRINT
Definition: sndvol32.h:71

◆ PciPowerControl()

static NTSTATUS NTAPI PciPowerControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 109 of file pci.c.

120 {
121  PCOMMON_DEVICE_EXTENSION DeviceExtension;
123 
124  DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
125 
126  if (DeviceExtension->IsFDO)
127  {
129  }
130  else
131  {
133  }
134 
135  return Status;
136 }
LONG NTSTATUS
Definition: precomp.h:26
if(dx==0 &&dy==0)
Definition: linetemp.h:174
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS PdoPowerControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pdo.c:1623
Status
Definition: gdiplustypes.h:24
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
NTSTATUS FdoPowerControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: fdo.c:586

◆ PciUnload()

VOID NTAPI PciUnload ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 190 of file pci.c.

192 {
193  /* The driver object extension is destroyed by the I/O manager */
195 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

Variable Documentation

◆ DriverExtension

◆ PciAddDevice

static NTSTATUS NTAPI PciAddDevice
static

Definition at line 20 of file pci.c.

Referenced by DriverEntry().

◆ PciDispatchDeviceControl

static NTSTATUS NTAPI PciDispatchDeviceControl
static

Definition at line 17 of file pci.c.

Referenced by DriverEntry().

◆ PciPnpControl

static NTSTATUS NTAPI PciPnpControl
static

Definition at line 26 of file pci.c.

Referenced by DriverEntry().

◆ PciPowerControl

static NTSTATUS NTAPI PciPowerControl
static

Definition at line 23 of file pci.c.

Referenced by DriverEntry().

◆ PciUnload

DRIVER_UNLOAD PciUnload

Definition at line 186 of file pci.c.

Referenced by DriverEntry().