ReactOS  0.4.14-dev-342-gdc047f9
pdo.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for pdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 C_ASSERT (FIELD_OFFSET(PCI_FDO_EXTENSION, DeviceState)==FIELD_OFFSET(PCI_PDO_EXTENSION, DeviceState))
 
 C_ASSERT (FIELD_OFFSET(PCI_FDO_EXTENSION, TentativeNextState)==FIELD_OFFSET(PCI_PDO_EXTENSION, TentativeNextState))
 
 C_ASSERT (FIELD_OFFSET(PCI_FDO_EXTENSION, List)==FIELD_OFFSET(PCI_PDO_EXTENSION, Next))
 
NTSTATUS NTAPI PciPdoWaitWake (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoSetPowerState (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryPower (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpStartDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpCancelRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpCancelStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryInterface (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryDeviceRelations (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryCapabilities (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryResources (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryResourceRequirements (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryDeviceText (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryId (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryBusInformation (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpReadConfig (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpWriteConfig (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryDeviceState (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpDeviceUsageNotification (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpSurpriseRemoval (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryLegacyBusInformation (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoCreate (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_SLOT_NUMBER Slot, OUT PDEVICE_OBJECT *PdoDeviceObject)
 

Variables

LONG PciPdoSequenceNumber
 
PCI_MN_DISPATCH_TABLE PciPdoDispatchPowerTable []
 
PCI_MN_DISPATCH_TABLE PciPdoDispatchPnpTable []
 
PCI_MJ_DISPATCH_TABLE PciPdoDispatchTable
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file pdo.c.

Function Documentation

◆ C_ASSERT() [1/3]

C_ASSERT ( FIELD_OFFSET(PCI_FDO_EXTENSION, DeviceState)  = =FIELD_OFFSET(PCI_PDO_EXTENSION, DeviceState))

◆ C_ASSERT() [2/3]

C_ASSERT ( FIELD_OFFSET(PCI_FDO_EXTENSION, TentativeNextState)  = =FIELD_OFFSET(PCI_PDO_EXTENSION, TentativeNextState))

◆ C_ASSERT() [3/3]

◆ PciPdoCreate()

NTSTATUS NTAPI PciPdoCreate ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_SLOT_NUMBER  Slot,
OUT PDEVICE_OBJECT PdoDeviceObject 
)

Definition at line 530 of file pdo.c.

533 {
534  WCHAR DeviceName[32];
535  UNICODE_STRING DeviceString;
539  ULONG SequenceNumber;
540  PAGED_CODE();
541 
542  /* Pick an atomically unique sequence number for this device */
543  SequenceNumber = InterlockedIncrement(&PciPdoSequenceNumber);
544 
545  /* Create the standard PCI device name for a PDO */
546  swprintf(DeviceName, L"\\Device\\NTPNP_PCI%04d", SequenceNumber);
547  RtlInitUnicodeString(&DeviceString, DeviceName);
548 
549  /* Create the actual device now */
550  Status = IoCreateDevice(DeviceExtension->FunctionalDeviceObject->DriverObject,
551  sizeof(PCI_PDO_EXTENSION),
552  &DeviceString,
554  0,
555  0,
556  &DeviceObject);
558 
559  /* Get the extension for it */
561  DPRINT1("PCI: New PDO (b=0x%x, d=0x%x, f=0x%x) @ %p, ext @ %p\n",
562  DeviceExtension->BaseBus,
563  Slot.u.bits.DeviceNumber,
564  Slot.u.bits.FunctionNumber,
565  DeviceObject,
567 
568  /* Configure the extension */
569  PdoExtension->ExtensionType = PciPdoExtensionType;
570  PdoExtension->IrpDispatchTable = &PciPdoDispatchTable;
571  PdoExtension->PhysicalDeviceObject = DeviceObject;
572  PdoExtension->Slot = Slot;
573  PdoExtension->PowerState.CurrentSystemState = PowerDeviceD0;
574  PdoExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
575  PdoExtension->ParentFdoExtension = DeviceExtension;
576 
577  /* Initialize the lock for arbiters and other interfaces */
579 
580  /* Initialize the state machine */
582 
583  /* Add the PDO to the parent's list */
584  PdoExtension->Next = NULL;
585  PciInsertEntryAtTail((PSINGLE_LIST_ENTRY)&DeviceExtension->ChildPdoList,
587  &DeviceExtension->ChildListLock);
588 
589  /* And finally return it to the caller */
591  return STATUS_SUCCESS;
592 }
VOID NTAPI PciInsertEntryAtTail(IN PSINGLE_LIST_ENTRY ListHead, IN PPCI_FDO_EXTENSION DeviceExtension, IN PKEVENT Lock)
Definition: utils.c:400
#define TRUE
Definition: types.h:120
Definition: ntbasedef.h:635
LONG NTSTATUS
Definition: precomp.h:26
LONG PciPdoSequenceNumber
Definition: pdo.c:18
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT _In_ PUSB_PORT_PATH _Out_ PUSB_CD_ERROR_INFORMATION _In_ USHORT _In_ PDEVICE_OBJECT PdoDeviceObject
Definition: hubbusif.h:89
WCHAR DeviceName[]
Definition: adapter.cpp:21
struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
#define PAGED_CODE()
Definition: video.h:57
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
PCI_MJ_DISPATCH_TABLE PciPdoDispatchTable
Definition: pdo.c:63
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf(buf, format,...)
Definition: sprintf.c:56
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
VOID NTAPI PciInitializeState(IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: state.c:88
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InterlockedIncrement
Definition: armddk.h:53
#define DPRINT1
Definition: precomp.h:8
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:147

Referenced by PciScanBus().

◆ PciPdoIrpCancelRemoveDevice()

NTSTATUS NTAPI PciPdoIrpCancelRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 248 of file pdo.c.

251 {
253  UNREFERENCED_PARAMETER(IoStackLocation);
254  UNREFERENCED_PARAMETER(DeviceExtension);
255 
257  return STATUS_NOT_SUPPORTED;
258 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpCancelStopDevice()

NTSTATUS NTAPI PciPdoIrpCancelStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 290 of file pdo.c.

293 {
295  UNREFERENCED_PARAMETER(IoStackLocation);
296  UNREFERENCED_PARAMETER(DeviceExtension);
297 
299  return STATUS_NOT_SUPPORTED;
300 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpDeviceUsageNotification()

NTSTATUS NTAPI PciPdoIrpDeviceUsageNotification ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 488 of file pdo.c.

491 {
493  UNREFERENCED_PARAMETER(IoStackLocation);
494  UNREFERENCED_PARAMETER(DeviceExtension);
495 
497  return STATUS_NOT_SUPPORTED;
498 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpQueryBusInformation()

NTSTATUS NTAPI PciPdoIrpQueryBusInformation ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 430 of file pdo.c.

433 {
434  PAGED_CODE();
435 
436  UNREFERENCED_PARAMETER(IoStackLocation);
437 
438  /* Call the worker function */
439  return PciQueryBusInformation(DeviceExtension,
441  IoStatus.Information);
442 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI PciQueryBusInformation(IN PPCI_PDO_EXTENSION PdoExtension, IN PPNP_BUS_INFORMATION *Buffer)
Definition: utils.c:1316

◆ PciPdoIrpQueryCapabilities()

NTSTATUS NTAPI PciPdoIrpQueryCapabilities ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 352 of file pdo.c.

355 {
356  PAGED_CODE();
357 
359 
360  /* Call the worker function */
361  return PciQueryCapabilities(DeviceExtension,
362  IoStackLocation->
363  Parameters.DeviceCapabilities.Capabilities);
364 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI PciQueryCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_CAPABILITIES DeviceCapability)
Definition: utils.c:1727
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872

◆ PciPdoIrpQueryDeviceRelations()

NTSTATUS NTAPI PciPdoIrpQueryDeviceRelations ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 318 of file pdo.c.

321 {
323  PAGED_CODE();
324 
325  /* Are ejection relations being queried? */
326  if (IoStackLocation->Parameters.QueryDeviceRelations.Type == EjectionRelations)
327  {
328  /* Call the worker function */
329  Status = PciQueryEjectionRelations(DeviceExtension,
331  IoStatus.Information);
332  }
333  else if (IoStackLocation->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation)
334  {
335  /* The only other relation supported is the target device relation */
336  Status = PciQueryTargetDeviceRelations(DeviceExtension,
338  IoStatus.Information);
339  }
340  else
341  {
342  /* All other relations are unsupported */
344  }
345 
346  /* Return either the result of the worker function, or unsupported status */
347  return Status;
348 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI PciQueryEjectionRelations(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:538
NTSTATUS NTAPI PciQueryTargetDeviceRelations(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:511
Status
Definition: gdiplustypes.h:24
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpQueryDeviceState()

NTSTATUS NTAPI PciPdoIrpQueryDeviceState ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 474 of file pdo.c.

477 {
479  UNREFERENCED_PARAMETER(IoStackLocation);
480  UNREFERENCED_PARAMETER(DeviceExtension);
481 
483  return STATUS_NOT_SUPPORTED;
484 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PciPdoIrpQueryDeviceText()

NTSTATUS NTAPI PciPdoIrpQueryDeviceText ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 399 of file pdo.c.

402 {
403  PAGED_CODE();
404 
405  /* Call the worker function */
406  return PciQueryDeviceText(DeviceExtension,
407  IoStackLocation->
408  Parameters.QueryDeviceText.DeviceTextType,
409  IoStackLocation->
410  Parameters.QueryDeviceText.LocaleId,
411  (PWCHAR*)&Irp->IoStatus.Information);
412 }
_In_ PIRP Irp
Definition: csq.h:116
uint16_t * PWCHAR
Definition: typedefs.h:54
#define PAGED_CODE()
Definition: video.h:57
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
NTSTATUS NTAPI PciQueryDeviceText(IN PPCI_PDO_EXTENSION PdoExtension, IN DEVICE_TEXT_TYPE QueryType, IN ULONG Locale, OUT PWCHAR *Buffer)
Definition: id.c:394

◆ PciPdoIrpQueryId()

NTSTATUS NTAPI PciPdoIrpQueryId ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 416 of file pdo.c.

419 {
420  PAGED_CODE();
421 
422  /* Call the worker function */
423  return PciQueryId(DeviceExtension,
424  IoStackLocation->Parameters.QueryId.IdType,
425  (PWCHAR*)&Irp->IoStatus.Information);
426 }
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI PciQueryId(IN PPCI_PDO_EXTENSION DeviceExtension, IN BUS_QUERY_ID_TYPE QueryType, OUT PWCHAR *Buffer)
Definition: id.c:200
uint16_t * PWCHAR
Definition: typedefs.h:54
#define PAGED_CODE()
Definition: video.h:57

◆ PciPdoIrpQueryInterface()

NTSTATUS NTAPI PciPdoIrpQueryInterface ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 304 of file pdo.c.

307 {
309  UNREFERENCED_PARAMETER(IoStackLocation);
310  UNREFERENCED_PARAMETER(DeviceExtension);
311 
313  return STATUS_NOT_SUPPORTED;
314 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpQueryLegacyBusInformation()

NTSTATUS NTAPI PciPdoIrpQueryLegacyBusInformation ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 516 of file pdo.c.

519 {
521  UNREFERENCED_PARAMETER(IoStackLocation);
522  UNREFERENCED_PARAMETER(DeviceExtension);
523 
525  return STATUS_NOT_SUPPORTED;
526 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpQueryPower()

NTSTATUS NTAPI PciPdoIrpQueryPower ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 107 of file pdo.c.

110 {
112  UNREFERENCED_PARAMETER(IoStackLocation);
113  UNREFERENCED_PARAMETER(DeviceExtension);
114 
116  return STATUS_NOT_SUPPORTED;
117 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpQueryRemoveDevice()

NTSTATUS NTAPI PciPdoIrpQueryRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 220 of file pdo.c.

223 {
225  UNREFERENCED_PARAMETER(IoStackLocation);
226  UNREFERENCED_PARAMETER(DeviceExtension);
227 
229  return STATUS_NOT_SUPPORTED;
230 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PciPdoIrpQueryResourceRequirements()

NTSTATUS NTAPI PciPdoIrpQueryResourceRequirements ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 383 of file pdo.c.

386 {
387  PAGED_CODE();
388 
389  UNREFERENCED_PARAMETER(IoStackLocation);
390 
391  /* Call the worker function */
392  return PciQueryRequirements(DeviceExtension,
394  IoStatus.Information);
395 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSTATUS NTAPI PciQueryRequirements(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList)
Definition: enum.c:583
#define PAGED_CODE()
Definition: video.h:57

◆ PciPdoIrpQueryResources()

NTSTATUS NTAPI PciPdoIrpQueryResources ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 368 of file pdo.c.

371 {
372  PAGED_CODE();
373 
374  UNREFERENCED_PARAMETER(IoStackLocation);
375 
376  /* Call the worker function */
377  return PciQueryResources(DeviceExtension,
378  (PCM_RESOURCE_LIST*)&Irp->IoStatus.Information);
379 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSTATUS NTAPI PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension, OUT PCM_RESOURCE_LIST *Buffer)
Definition: enum.c:354
#define PAGED_CODE()
Definition: video.h:57

◆ PciPdoIrpQueryStopDevice()

NTSTATUS NTAPI PciPdoIrpQueryStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 276 of file pdo.c.

279 {
281  UNREFERENCED_PARAMETER(IoStackLocation);
282  UNREFERENCED_PARAMETER(DeviceExtension);
283 
285  return STATUS_NOT_SUPPORTED;
286 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpReadConfig()

NTSTATUS NTAPI PciPdoIrpReadConfig ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 446 of file pdo.c.

449 {
451  UNREFERENCED_PARAMETER(IoStackLocation);
452  UNREFERENCED_PARAMETER(DeviceExtension);
453 
455  return STATUS_NOT_SUPPORTED;
456 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpRemoveDevice()

NTSTATUS NTAPI PciPdoIrpRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 234 of file pdo.c.

237 {
239  UNREFERENCED_PARAMETER(IoStackLocation);
240  UNREFERENCED_PARAMETER(DeviceExtension);
241 
243  return STATUS_NOT_SUPPORTED;
244 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpStartDevice()

NTSTATUS NTAPI PciPdoIrpStartDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 121 of file pdo.c.

124 {
126  BOOLEAN Changed, DoReset;
128  PAGED_CODE();
129 
131 
132  DoReset = FALSE;
133 
134  /* Begin entering the start phase */
135  Status = PciBeginStateTransition((PVOID)DeviceExtension, PciStarted);
136  if (!NT_SUCCESS(Status)) return Status;
137 
138  /* Check if this is a VGA device */
139  if (((DeviceExtension->BaseClass == PCI_CLASS_PRE_20) &&
140  (DeviceExtension->SubClass == PCI_SUBCLASS_PRE_20_VGA)) ||
141  ((DeviceExtension->BaseClass == PCI_CLASS_DISPLAY_CTLR) &&
142  (DeviceExtension->SubClass == PCI_SUBCLASS_VID_VGA_CTLR)))
143  {
144  /* Always force it on */
145  DeviceExtension->CommandEnables |= (PCI_ENABLE_IO_SPACE |
147  }
148 
149  /* Check if native IDE is enabled and it owns the I/O ports */
150  if (DeviceExtension->IoSpaceUnderNativeIdeControl)
151  {
152  /* Then don't allow I/O access */
153  DeviceExtension->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
154  }
155 
156  /* Always enable bus mastering */
157  DeviceExtension->CommandEnables |= PCI_ENABLE_BUS_MASTER;
158 
159  /* Check if the OS assigned resources differ from the PCI configuration */
160  Changed = PciComputeNewCurrentSettings(DeviceExtension,
161  IoStackLocation->Parameters.
162  StartDevice.AllocatedResources);
163  if (Changed)
164  {
165  /* Remember this for later */
166  DeviceExtension->MovedDevice = TRUE;
167  }
168  else
169  {
170  /* All good */
171  DPRINT1("PCI - START not changing resource settings.\n");
172  }
173 
174  /* Check if the device was sleeping */
175  if (DeviceExtension->PowerState.CurrentDeviceState != PowerDeviceD0)
176  {
177  /* Power it up */
178  Status = PciSetPowerManagedDevicePowerState(DeviceExtension,
180  FALSE);
181  if (!NT_SUCCESS(Status))
182  {
183  /* Powerup fail, fail the request */
184  PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
186  }
187 
188  /* Tell the power manager that the device is powered up */
190  PoSetPowerState(DeviceExtension->PhysicalDeviceObject,
192  PowerState);
193 
194  /* Update internal state */
195  DeviceExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
196 
197  /* This device's resources and decodes will need to be reset */
198  DoReset = TRUE;
199  }
200 
201  /* Update resource information now that the device is powered up and active */
202  Status = PciSetResources(DeviceExtension, DoReset, TRUE);
203  if (!NT_SUCCESS(Status))
204  {
205  /* That failed, so cancel the transition */
206  PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
207  }
208  else
209  {
210  /* Fully commit, as the device is now started up and ready to go */
211  PciCommitStateTransition((PVOID)DeviceExtension, PciStarted);
212  }
213 
214  /* Return the result of the start request */
215  return Status;
216 }
VOID NTAPI PciCommitStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:181
BOOLEAN NTAPI PciComputeNewCurrentSettings(IN PPCI_PDO_EXTENSION PdoExtension, IN PCM_RESOURCE_LIST ResourceList)
Definition: enum.c:55
#define TRUE
Definition: types.h:120
_In_ UCHAR _In_ POWER_STATE PowerState
Definition: pofuncs.h:42
#define PCI_ENABLE_IO_SPACE
Definition: iotypes.h:3260
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI PciSetPowerManagedDevicePowerState(IN PPCI_PDO_EXTENSION DeviceExtension, IN DEVICE_POWER_STATE DeviceState, IN BOOLEAN IrpSet)
Definition: power.c:121
NTSTATUS NTAPI PciSetResources(IN PPCI_PDO_EXTENSION PdoExtension, IN BOOLEAN DoReset, IN BOOLEAN SomethingSomethingDarkSide)
Definition: enum.c:2155
NTSTATUS NTAPI PciCancelStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE StateNotEntered)
Definition: state.c:145
unsigned char BOOLEAN
#define PCI_SUBCLASS_VID_VGA_CTLR
Definition: iotypes.h:3788
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PCI_ENABLE_BUS_MASTER
Definition: iotypes.h:3262
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
static BOOL StartDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, IN BOOL bEnable, IN DWORD HardwareProfile OPTIONAL, OUT BOOL *bNeedReboot OPTIONAL)
Definition: wizard.c:142
#define PCI_CLASS_DISPLAY_CTLR
Definition: iotypes.h:3750
NTSTATUS NTAPI PciBeginStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:97
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
#define PCI_ENABLE_MEMORY_SPACE
Definition: iotypes.h:3261
#define PCI_SUBCLASS_PRE_20_VGA
Definition: iotypes.h:3769
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
Definition: power.c:597
#define STATUS_DEVICE_POWER_FAILURE
Definition: ntstatus.h:380
#define PCI_CLASS_PRE_20
Definition: iotypes.h:3747

◆ PciPdoIrpStopDevice()

NTSTATUS NTAPI PciPdoIrpStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 262 of file pdo.c.

265 {
267  UNREFERENCED_PARAMETER(IoStackLocation);
268  UNREFERENCED_PARAMETER(DeviceExtension);
269 
271  return STATUS_NOT_SUPPORTED;
272 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpSurpriseRemoval()

NTSTATUS NTAPI PciPdoIrpSurpriseRemoval ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 502 of file pdo.c.

505 {
507  UNREFERENCED_PARAMETER(IoStackLocation);
508  UNREFERENCED_PARAMETER(DeviceExtension);
509 
511  return STATUS_NOT_SUPPORTED;
512 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoIrpWriteConfig()

NTSTATUS NTAPI PciPdoIrpWriteConfig ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 460 of file pdo.c.

463 {
465  UNREFERENCED_PARAMETER(IoStackLocation);
466  UNREFERENCED_PARAMETER(DeviceExtension);
467 
469  return STATUS_NOT_SUPPORTED;
470 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciPdoSetPowerState()

NTSTATUS NTAPI PciPdoSetPowerState ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 93 of file pdo.c.

96 {
98  UNREFERENCED_PARAMETER(IoStackLocation);
99  UNREFERENCED_PARAMETER(DeviceExtension);
100 
102  return STATUS_NOT_SUPPORTED;
103 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PciPdoWaitWake()

NTSTATUS NTAPI PciPdoWaitWake ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 79 of file pdo.c.

82 {
84  UNREFERENCED_PARAMETER(IoStackLocation);
85  UNREFERENCED_PARAMETER(DeviceExtension);
86 
88  return STATUS_NOT_SUPPORTED;
89 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

Variable Documentation

◆ PciPdoDispatchPnpTable

PCI_MN_DISPATCH_TABLE PciPdoDispatchPnpTable[]
Initial value:
=
{
}
NTSTATUS NTAPI PciPdoIrpQueryRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:220
NTSTATUS NTAPI PciPdoIrpWriteConfig(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:460
NTSTATUS NTAPI PciPdoIrpQueryDeviceRelations(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:318
NTSTATUS NTAPI PciPdoIrpCancelRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:248
NTSTATUS NTAPI PciPdoIrpQueryDeviceState(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:474
NTSTATUS NTAPI PciPdoIrpQueryInterface(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:304
NTSTATUS NTAPI PciPdoIrpQueryLegacyBusInformation(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:516
NTSTATUS NTAPI PciPdoIrpQueryResourceRequirements(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:383
NTSTATUS NTAPI PciPdoIrpCancelStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:290
NTSTATUS NTAPI PciPdoIrpRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:234
NTSTATUS NTAPI PciPdoIrpDeviceUsageNotification(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:488
NTSTATUS NTAPI PciPdoIrpQueryId(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:416
NTSTATUS NTAPI PciPdoIrpQueryResources(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:368
NTSTATUS NTAPI PciPdoIrpQueryStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:276
NTSTATUS NTAPI PciPdoIrpSurpriseRemoval(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:502
NTSTATUS NTAPI PciPdoIrpStartDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:121
NTSTATUS NTAPI PciPdoIrpReadConfig(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:446
NTSTATUS NTAPI PciPdoIrpQueryDeviceText(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:399
NTSTATUS NTAPI PciPdoIrpStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:262
NTSTATUS NTAPI PciPdoIrpQueryBusInformation(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:430
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:323
NTSTATUS NTAPI PciPdoIrpQueryCapabilities(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:352
NTSTATUS NTAPI PciIrpNotSupported(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:261

Definition at line 33 of file pdo.c.

◆ PciPdoDispatchPowerTable

PCI_MN_DISPATCH_TABLE PciPdoDispatchPowerTable[]
Initial value:
=
{
}
NTSTATUS NTAPI PciPdoIrpQueryPower(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:107
NTSTATUS NTAPI PciPdoWaitWake(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:79
NTSTATUS NTAPI PciPdoSetPowerState(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:93
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:323
NTSTATUS NTAPI PciIrpNotSupported(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:261

Definition at line 24 of file pdo.c.

◆ PciPdoDispatchTable

PCI_MJ_DISPATCH_TABLE PciPdoDispatchTable
Initial value:
=
{
}
#define IRP_MN_QUERY_POWER
#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION
Definition: iotypes.h:4071
PCI_MN_DISPATCH_TABLE PciPdoDispatchPnpTable[]
Definition: pdo.c:33
PCI_MN_DISPATCH_TABLE PciPdoDispatchPowerTable[]
Definition: pdo.c:24
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:323
NTSTATUS NTAPI PciIrpNotSupported(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:261
NTSTATUS NTAPI PciIrpInvalidDeviceRequest(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:277

Definition at line 63 of file pdo.c.

Referenced by PciPdoCreate().

◆ PciPdoSequenceNumber

LONG PciPdoSequenceNumber

Definition at line 18 of file pdo.c.

Referenced by PciPdoCreate().