ReactOS 0.4.17-dev-1196-gb6224c3
usage.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/usage.c
5 * PURPOSE: Bus/Device Usage Reporting
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <pci.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* GLOBALS ********************************************************************/
17
18/* FUNCTIONS ******************************************************************/
19
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}
78
95 _In_ PPCI_FDO_EXTENSION ParentFdoExtension,
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}
141
142/* EOF */
#define PAGED_CODE()
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
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
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.
Definition: usage.c:94
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.
Definition: usage.c:35
#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
#define ASSERT(a)
Definition: mode.c:44
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define KernelMode
Definition: asm.h:38
#define _Inout_
Definition: no_sal2.h:162
#define _In_
Definition: no_sal2.h:158
int Count
Definition: noreturn.cpp:7
@ 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
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _IO_STACK_LOCATION::@5020::@5053 UsageNotification
union _IO_STACK_LOCATION::@1814 Parameters
#define STATUS_PENDING
Definition: telnetd.h:14
#define NTAPI
Definition: typedefs.h:36
int32_t * PLONG
Definition: typedefs.h:58
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIO_STACK_LOCATION IoStackLocation
Definition: usbdlib.h:292
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3040
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2702
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
@ DeviceUsageTypeHibernation
Definition: iotypes.h:1171
@ DeviceUsageTypeBoot
Definition: iotypes.h:1173
@ DeviceUsageTypeDumpFile
Definition: iotypes.h:1172
@ DeviceUsageTypePaging
Definition: iotypes.h:1170
@ Executive
Definition: ketypes.h:467
#define ObDereferenceObject
Definition: obfuncs.h:203