ReactOS  0.4.13-dev-479-gec9c8fd
api.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for api.cpp:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI PcGetDeviceProperty (IN PVOID DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
 
ULONGLONG NTAPI PcGetTimeInterval (IN ULONGLONG Since)
 
VOID NTAPI PcIoTimerRoutine (IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
 
NTSTATUS NTAPI PcRegisterIoTimeout (IN PDEVICE_OBJECT pDeviceObject, IN PIO_TIMER_ROUTINE pTimerRoutine, IN PVOID pContext)
 
NTSTATUS NTAPI PcUnregisterIoTimeout (IN PDEVICE_OBJECT pDeviceObject, IN PIO_TIMER_ROUTINE pTimerRoutine, IN PVOID pContext)
 
NTSTATUS NTAPI PcCompletePendingPropertyRequest (IN PPCPROPERTY_REQUEST PropertyRequest, IN NTSTATUS NtStatus)
 
NTSTATUS NTAPI PcDmaMasterDescription (IN PRESOURCELIST ResourceList OPTIONAL, IN BOOLEAN ScatterGather, IN BOOLEAN Dma32BitAddresses, IN BOOLEAN IgnoreCount, IN BOOLEAN Dma64BitAddresses, IN DMA_WIDTH DmaWidth, IN DMA_SPEED DmaSpeed, IN ULONG MaximumLength, IN ULONG DmaPort, OUT PDEVICE_DESCRIPTION DeviceDescription)
 
NTSTATUS NTAPI PcDmaSlaveDescription (IN PRESOURCELIST ResourceList OPTIONAL, IN ULONG DmaIndex, IN BOOLEAN DemandMode, IN BOOLEAN AutoInitialize, IN DMA_SPEED DmaSpeed, IN ULONG MaximumLength, IN ULONG DmaPort, OUT PDEVICE_DESCRIPTION DeviceDescription)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file api.cpp.

Function Documentation

◆ PcCompletePendingPropertyRequest()

NTSTATUS NTAPI PcCompletePendingPropertyRequest ( IN PPCPROPERTY_REQUEST  PropertyRequest,
IN NTSTATUS  NtStatus 
)

Definition at line 188 of file api.cpp.

191 {
192  // sanity checks
194 
195  if (!PropertyRequest || !PropertyRequest->Irp || NtStatus == STATUS_PENDING)
197 
198  // set the final status code
199  PropertyRequest->Irp->IoStatus.Status = NtStatus;
200 
201  // complete the irp
202  IoCompleteRequest(PropertyRequest->Irp, IO_SOUND_INCREMENT);
203 
204  // free the property request
205  FreeItem(PropertyRequest, TAG_PORTCLASS);
206 
207  // return success
208  return STATUS_SUCCESS;
209 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TAG_PORTCLASS
Definition: private.hpp:24
#define IO_SOUND_INCREMENT
Definition: iotypes.h:575
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_PENDING
Definition: ntstatus.h:82
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30

◆ PcDmaMasterDescription()

NTSTATUS NTAPI PcDmaMasterDescription ( IN PRESOURCELIST ResourceList  OPTIONAL,
IN BOOLEAN  ScatterGather,
IN BOOLEAN  Dma32BitAddresses,
IN BOOLEAN  IgnoreCount,
IN BOOLEAN  Dma64BitAddresses,
IN DMA_WIDTH  DmaWidth,
IN DMA_SPEED  DmaSpeed,
IN ULONG  MaximumLength,
IN ULONG  DmaPort,
OUT PDEVICE_DESCRIPTION  DeviceDescription 
)

Definition at line 213 of file api.cpp.

224 {
225 
227 
231  DeviceDescription->Dma32BitAddresses = Dma32BitAddresses;
232  DeviceDescription->IgnoreCount = IgnoreCount;
234  DeviceDescription->DmaWidth = DmaWidth;
235  DeviceDescription->DmaSpeed = DmaSpeed;
237  DeviceDescription->DmaPort = DmaPort;
238 
239  return STATUS_SUCCESS;
240 }
#define TRUE
Definition: types.h:120
DMA_SPEED DmaSpeed
Definition: iotypes.h:2037
BOOLEAN IgnoreCount
Definition: iotypes.h:2030
_In_ BOOLEAN Dma64BitAddresses
Definition: ndis.h:4652
BOOLEAN Dma32BitAddresses
Definition: iotypes.h:2029
BOOLEAN Dma64BitAddresses
Definition: iotypes.h:2032
_Must_inspect_result_ _In_ PDEVICE_DESCRIPTION DeviceDescription
Definition: iofuncs.h:1015
BOOLEAN ScatterGather
Definition: iotypes.h:2026
DMA_WIDTH DmaWidth
Definition: iotypes.h:2036
UnicodeString MaximumLength
Definition: rtlfuncs.h:2982
_In_ struct _IRP _In_ struct _SCATTER_GATHER_LIST * ScatterGather
Definition: iotypes.h:2258
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DEVICE_DESCRIPTION_VERSION1
Definition: iotypes.h:2020
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ PcDmaSlaveDescription()

NTSTATUS NTAPI PcDmaSlaveDescription ( IN PRESOURCELIST ResourceList  OPTIONAL,
IN ULONG  DmaIndex,
IN BOOLEAN  DemandMode,
IN BOOLEAN  AutoInitialize,
IN DMA_SPEED  DmaSpeed,
IN ULONG  MaximumLength,
IN ULONG  DmaPort,
OUT PDEVICE_DESCRIPTION  DeviceDescription 
)

Definition at line 244 of file api.cpp.

253 {
254 
256 
258  DeviceDescription->DemandMode = DemandMode;
259  DeviceDescription->AutoInitialize = AutoInitialize;
260  DeviceDescription->DmaSpeed = DmaSpeed;
262  DeviceDescription->DmaPort = DmaPort;
263 
264  return STATUS_SUCCESS;
265 }
DMA_SPEED DmaSpeed
Definition: iotypes.h:2037
_Must_inspect_result_ _In_ PDEVICE_DESCRIPTION DeviceDescription
Definition: iofuncs.h:1015
BOOLEAN DemandMode
Definition: iotypes.h:2027
UnicodeString MaximumLength
Definition: rtlfuncs.h:2982
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DEVICE_DESCRIPTION_VERSION1
Definition: iotypes.h:2020
return STATUS_SUCCESS
Definition: btrfs.c:2777
BOOLEAN AutoInitialize
Definition: iotypes.h:2028

◆ PcGetDeviceProperty()

NTSTATUS NTAPI PcGetDeviceProperty ( IN PVOID  DeviceObject,
IN DEVICE_REGISTRY_PROPERTY  DeviceProperty,
IN ULONG  BufferLength,
OUT PVOID  PropertyBuffer,
OUT PULONG  ResultLength 
)

Definition at line 19 of file api.cpp.

25 {
26  PPCLASS_DEVICE_EXTENSION DeviceExtension;
27 
29 
30  DeviceExtension = (PPCLASS_DEVICE_EXTENSION)((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
31 
32  return IoGetDeviceProperty(DeviceExtension->PhysicalDeviceObject, DeviceProperty, BufferLength, PropertyBuffer, ResultLength);
33 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
_In_ ULONG BufferLength
Definition: usbdlib.h:225
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4210
PDEVICE_OBJECT PhysicalDeviceObject
Definition: private.hpp:395
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: iofuncs.h:1003

◆ PcGetTimeInterval()

ULONGLONG NTAPI PcGetTimeInterval ( IN ULONGLONG  Since)

Definition at line 37 of file api.cpp.

39 {
40  LARGE_INTEGER CurrentTime;
41 
42  KeQuerySystemTime(&CurrentTime);
43 
44  return (CurrentTime.QuadPart - Since);
45 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by DMusMPUInterruptServiceRoutine(), InitMPU(), and WriteMPU().

◆ PcIoTimerRoutine()

VOID NTAPI PcIoTimerRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PVOID  Context 
)

Definition at line 49 of file api.cpp.

52 {
53  PPCLASS_DEVICE_EXTENSION DeviceExtension;
54  KIRQL OldIrql;
55  PLIST_ENTRY ListEntry;
56  PTIMER_CONTEXT CurContext;
57 
59  return;
60 
62 
63  KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
64 
65  ListEntry = DeviceExtension->TimerList.Flink;
66  while(ListEntry != &DeviceExtension->TimerList)
67  {
68  CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
69 
70  CurContext->pTimerRoutine(DeviceObject, CurContext->Context);
71  ListEntry = ListEntry->Flink;
72  }
73 
74  KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
75 }
PVOID Context
Definition: private.hpp:425
struct TIMER_CONTEXT * PTIMER_CONTEXT
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
PIO_TIMER_ROUTINE pTimerRoutine
Definition: private.hpp:424
UCHAR KIRQL
Definition: env_spec_w32.h:591
PVOID DeviceExtension
Definition: env_spec_w32.h:418
KSPIN_LOCK TimerListLock
Definition: private.hpp:406
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
base of all file and directory entries
Definition: entries.h:82

Referenced by PcAddAdapterDevice().

◆ PcRegisterIoTimeout()

NTSTATUS NTAPI PcRegisterIoTimeout ( IN PDEVICE_OBJECT  pDeviceObject,
IN PIO_TIMER_ROUTINE  pTimerRoutine,
IN PVOID  pContext 
)

Definition at line 79 of file api.cpp.

83 {
85  PTIMER_CONTEXT TimerContext, CurContext;
86  KIRQL OldIrql;
87  PLIST_ENTRY ListEntry;
88  BOOLEAN bFound;
89  PPCLASS_DEVICE_EXTENSION DeviceExtension;
90 
92 
93  if (!pDeviceObject || !pDeviceObject->DeviceExtension)
95 
96  DeviceExtension = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
97 
99  if (!TimerContext)
100  {
101  DPRINT("Failed to allocate memory\n");
103  }
104 
105  KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
106 
107  ListEntry = DeviceExtension->TimerList.Flink;
108  bFound = FALSE;
109  while(ListEntry != &DeviceExtension->TimerList)
110  {
111  CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
112 
113  if (CurContext->Context == pContext && CurContext->pTimerRoutine == pTimerRoutine)
114  {
115  bFound = TRUE;
118  break;
119  }
120  ListEntry = ListEntry->Flink;
121  }
122 
123  if (!bFound)
124  {
125  TimerContext->Context = pContext;
126  TimerContext->pTimerRoutine = pTimerRoutine;
127  InsertTailList(&DeviceExtension->TimerList, &TimerContext->Entry);
128  }
129 
130  KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
131 
132  return Status;
133 }
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PVOID Context
Definition: private.hpp:425
struct TIMER_CONTEXT * PTIMER_CONTEXT
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TAG_PORTCLASS
Definition: private.hpp:24
PIO_TIMER_ROUTINE pTimerRoutine
Definition: private.hpp:424
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
KSPIN_LOCK TimerListLock
Definition: private.hpp:406
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_In_ PLARGE_INTEGER _In_opt_ PTIMER_APC_ROUTINE _In_opt_ PVOID TimerContext
Definition: zwfuncs.h:428
return STATUS_SUCCESS
Definition: btrfs.c:2777
base of all file and directory entries
Definition: entries.h:82

◆ PcUnregisterIoTimeout()

NTSTATUS NTAPI PcUnregisterIoTimeout ( IN PDEVICE_OBJECT  pDeviceObject,
IN PIO_TIMER_ROUTINE  pTimerRoutine,
IN PVOID  pContext 
)

Definition at line 137 of file api.cpp.

141 {
142  PTIMER_CONTEXT CurContext;
143  KIRQL OldIrql;
144  PLIST_ENTRY ListEntry;
145  BOOLEAN bFound;
146  PPCLASS_DEVICE_EXTENSION DeviceExtension;
147 
149 
150  if (!pDeviceObject || !pDeviceObject->DeviceExtension)
152 
153 
154  DeviceExtension = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
155 
156 
157  KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
158 
159  ListEntry = DeviceExtension->TimerList.Flink;
160  bFound = FALSE;
161 
162  while(ListEntry != &DeviceExtension->TimerList)
163  {
164  CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
165 
166  if (CurContext->Context == pContext && CurContext->pTimerRoutine == pTimerRoutine)
167  {
168  bFound = TRUE;
169  RemoveEntryList(&CurContext->Entry);
170  FreeItem(CurContext, TAG_PORTCLASS);
171  break;
172  }
173  ListEntry = ListEntry->Flink;
174  }
175 
176  KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
177 
178  if (bFound)
179  return STATUS_SUCCESS;
180  else
181  return STATUS_NOT_FOUND;
182 }
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
#define TRUE
Definition: types.h:120
PVOID Context
Definition: private.hpp:425
struct TIMER_CONTEXT * PTIMER_CONTEXT
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TAG_PORTCLASS
Definition: private.hpp:24
PIO_TIMER_ROUTINE pTimerRoutine
Definition: private.hpp:424
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
unsigned char BOOLEAN
KSPIN_LOCK TimerListLock
Definition: private.hpp:406
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_NOT_FOUND
Definition: shellext.h:67
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
LIST_ENTRY Entry
Definition: private.hpp:423
return STATUS_SUCCESS
Definition: btrfs.c:2777
base of all file and directory entries
Definition: entries.h:82