ReactOS 0.4.15-dev-7670-g69b08be
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() [2/3]

◆ C_ASSERT() [3/3]

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

◆ 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 */
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 */
560 PdoExtension = (PPCI_PDO_EXTENSION)DeviceObject->DeviceExtension;
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,
566 DeviceObject->DeviceExtension);
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}
#define PAGED_CODE()
#define InterlockedIncrement
Definition: armddk.h:53
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
PCI_MJ_DISPATCH_TABLE PciPdoDispatchTable
Definition: pdo.c:63
LONG PciPdoSequenceNumber
Definition: pdo.c:18
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf
Definition: precomp.h:40
VOID NTAPI PciInsertEntryAtTail(IN PSINGLE_LIST_ENTRY ListHead, IN PPCI_FDO_EXTENSION DeviceExtension, IN PKEVENT Lock)
Definition: utils.c:400
struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
VOID NTAPI PciInitializeState(IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: state.c:88
@ PciPdoExtensionType
Definition: pci.h:94
@ PdoExtension
Definition: precomp.h:49
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
_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:95
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
@ SynchronizationEvent
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
@ PowerDeviceD0
Definition: ntpoapi.h:49
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:148
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ntbasedef.h:628
uint32_t ULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
__wchar_t WCHAR
Definition: xmlstorage.h:180

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
258}
_In_ PIRP Irp
Definition: csq.h:116
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423

◆ 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
300}

◆ 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
498}

◆ 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}
NTSTATUS NTAPI PciQueryBusInformation(IN PPCI_PDO_EXTENSION PdoExtension, IN PPNP_BUS_INFORMATION *Buffer)
Definition: utils.c:1316
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159

◆ 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}
NTSTATUS NTAPI PciQueryCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_CAPABILITIES DeviceCapability)
Definition: utils.c:1727
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

◆ 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}
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
@ EjectionRelations
Definition: iotypes.h:2153
@ TargetDeviceRelation
Definition: iotypes.h:2156

◆ 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
484}
#define UNIMPLEMENTED
Definition: debug.h:115

◆ 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}
NTSTATUS NTAPI PciQueryDeviceText(IN PPCI_PDO_EXTENSION PdoExtension, IN DEVICE_TEXT_TYPE QueryType, IN ULONG Locale, OUT PWCHAR *Buffer)
Definition: id.c:394
uint16_t * PWCHAR
Definition: typedefs.h:56

◆ 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}
NTSTATUS NTAPI PciQueryId(IN PPCI_PDO_EXTENSION DeviceExtension, IN BUS_QUERY_ID_TYPE QueryType, OUT PWCHAR *Buffer)
Definition: id.c:200

◆ 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
314}

◆ 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
526}

◆ 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
117}

◆ 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
230}

◆ 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}
NTSTATUS NTAPI PciQueryRequirements(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList)
Definition: enum.c:583

◆ 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}
NTSTATUS NTAPI PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension, OUT PCM_RESOURCE_LIST *Buffer)
Definition: enum.c:354

◆ 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
286}

◆ 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
456}

◆ 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
244}

◆ 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 */
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 */
189 PowerState.DeviceState = PowerDeviceD0;
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}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI PciSetResources(IN PPCI_PDO_EXTENSION PdoExtension, IN BOOLEAN DoReset, IN BOOLEAN SomethingSomethingDarkSide)
Definition: enum.c:2155
BOOLEAN NTAPI PciComputeNewCurrentSettings(IN PPCI_PDO_EXTENSION PdoExtension, IN PCM_RESOURCE_LIST ResourceList)
Definition: enum.c:55
@ PciStarted
Definition: pci.h:130
NTSTATUS NTAPI PciCancelStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:145
NTSTATUS NTAPI PciBeginStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:97
NTSTATUS NTAPI PciSetPowerManagedDevicePowerState(IN PPCI_PDO_EXTENSION DeviceExtension, IN DEVICE_POWER_STATE DeviceState, IN BOOLEAN IrpSet)
Definition: power.c:121
VOID NTAPI PciCommitStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:181
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:173
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
Definition: power.c:729
@ DevicePowerState
Definition: ntpoapi.h:63
#define STATUS_DEVICE_POWER_FAILURE
Definition: ntstatus.h:394
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3034
#define PCI_ENABLE_BUS_MASTER
Definition: iotypes.h:3618
#define PCI_ENABLE_IO_SPACE
Definition: iotypes.h:3616
#define PCI_ENABLE_MEMORY_SPACE
Definition: iotypes.h:3617
#define PCI_CLASS_PRE_20
Definition: iotypes.h:4103
#define PCI_SUBCLASS_VID_VGA_CTLR
Definition: iotypes.h:4144
#define PCI_SUBCLASS_PRE_20_VGA
Definition: iotypes.h:4125
#define PCI_CLASS_DISPLAY_CTLR
Definition: iotypes.h:4106

◆ 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
272}

◆ 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
512}

◆ 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
470}

◆ 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
103}

◆ 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
89}

Variable Documentation

◆ PciPdoDispatchPnpTable

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

Definition at line 33 of file pdo.c.

◆ PciPdoDispatchPowerTable

PCI_MN_DISPATCH_TABLE PciPdoDispatchPowerTable[]
Initial value:
=
{
}
NTSTATUS NTAPI PciPdoSetPowerState(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
Definition: pdo.c:93
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
@ IRP_DISPATCH
Definition: pci.h:146

Definition at line 24 of file pdo.c.

◆ PciPdoDispatchTable

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

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().