ReactOS 0.4.17-dev-1196-gb6224c3
usage.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for usage.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI PciUpdateDeviceUsage (_Inout_ PPCI_POWER_STATE PowerState, _In_ PIO_STACK_LOCATION IoStackLocation)
 Counts a paging, hibernation or dump file arriving on or leaving a device.
 
NTSTATUS NTAPI PciSendDeviceUsageToParent (_In_ PPCI_FDO_EXTENSION ParentFdoExtension, _In_ PIO_STACK_LOCATION IoStackLocation)
 Sends a device usage notification to the top of the stack of a parent bus.
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file usage.c.

Function Documentation

◆ PciSendDeviceUsageToParent()

NTSTATUS NTAPI PciSendDeviceUsageToParent ( _In_ PPCI_FDO_EXTENSION  ParentFdoExtension,
_In_ PIO_STACK_LOCATION  IoStackLocation 
)

Sends a device usage notification to the top of the stack of a parent bus.

Parameters
[in]ParentFdoExtensionThe FDO extension of the bus the function is on.
[in]IoStackLocationThe stack location of the notification the function received.
Returns
The status the parent stack completed the notification with.

Definition at line 94 of file usage.c.

97{
98 PDEVICE_OBJECT TopDevice;
99 PIO_STACK_LOCATION NextStack;
103 PIRP Irp;
104
105 PAGED_CODE();
106
107 TopDevice = IoGetAttachedDeviceReference(ParentFdoExtension->PhysicalDeviceObject);
108
111 TopDevice,
112 NULL,
113 0,
114 NULL,
115 &Event,
116 &IoStatus);
117 if (!Irp)
118 {
119 ObDereferenceObject(TopDevice);
121 }
122
123 /* A PnP IRP nobody handles must come back as not supported */
124 Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
125 Irp->IoStatus.Information = 0;
126
127 NextStack = IoGetNextIrpStackLocation(Irp);
130
131 Status = IoCallDriver(TopDevice, Irp);
132 if (Status == STATUS_PENDING)
133 {
135 Status = IoStatus.Status;
136 }
137
138 ObDereferenceObject(TopDevice);
139 return Status;
140}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:24
_In_ PIRP Irp
Definition: kse.h:79
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define KernelMode
Definition: asm.h:38
@ SynchronizationEvent
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1416
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1101
#define IoCallDriver
Definition: irp.c:1257
struct _IO_STACK_LOCATION::@5020::@5053 UsageNotification
union _IO_STACK_LOCATION::@1814 Parameters
#define STATUS_PENDING
Definition: telnetd.h:14
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIO_STACK_LOCATION IoStackLocation
Definition: usbdlib.h:292
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2702
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
@ Executive
Definition: ketypes.h:467
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by PciPdoIrpDeviceUsageNotification().

◆ PciUpdateDeviceUsage()

NTSTATUS NTAPI PciUpdateDeviceUsage ( _Inout_ PPCI_POWER_STATE  PowerState,
_In_ PIO_STACK_LOCATION  IoStackLocation 
)

Counts a paging, hibernation or dump file arriving on or leaving a device.

Parameters
[in,out]PowerStateThe power state of the extension that holds the counts.
[in]IoStackLocationThe stack location of the device usage notification.
Returns
STATUS_SUCCESS for a usage the driver accepts, STATUS_NOT_SUPPORTED otherwise.

Definition at line 35 of file usage.c.

38{
40
41 PAGED_CODE();
42
44 {
46 Count = &PowerState->Paging;
47 break;
48
50 Count = &PowerState->Hibernate;
51 break;
52
54 Count = &PowerState->CrashDump;
55 break;
56
57 /* Accepted, but nothing is held back for the boot device */
59 return STATUS_SUCCESS;
60
61 default:
63 }
64
65 /* Several files can share a device, so these are counts and not flags */
67 {
69 }
70 else
71 {
72 ASSERT(*Count > 0);
74 }
75
76 return STATUS_SUCCESS;
77}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define ASSERT(a)
Definition: mode.c:44
int Count
Definition: noreturn.cpp:7
#define STATUS_SUCCESS
Definition: shellext.h:65
int32_t * PLONG
Definition: typedefs.h:58
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3040
@ DeviceUsageTypeHibernation
Definition: iotypes.h:1171
@ DeviceUsageTypeBoot
Definition: iotypes.h:1173
@ DeviceUsageTypeDumpFile
Definition: iotypes.h:1172
@ DeviceUsageTypePaging
Definition: iotypes.h:1170

Referenced by PciFdoIrpDeviceUsageNotification(), and PciPdoIrpDeviceUsageNotification().