ReactOS  0.4.15-dev-2155-g06f57e1
hdaudbus.cpp File Reference
#include "hdaudbus.h"
Include dependency graph for hdaudbus.cpp:

Go to the source code of this file.

Functions

PVOID AllocateItem (_In_ POOL_TYPE PoolType, _In_ SIZE_T NumberOfBytes)
 
VOID FreeItem (__drv_freesMem(Mem) PVOID Item)
 
NTSTATUS HDA_FdoPnp (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS HDA_PdoPnp (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI HDA_Pnp (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI HDA_SystemControl (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI HDA_Power (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI HDA_AddDevice (_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PhysicalDeviceObject)
 
VOID NTAPI HDA_Unload (_In_ PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPathName)
 

Variables

DRIVER_DISPATCH HDA_Pnp
 
DRIVER_DISPATCH HDA_SystemControl
 
DRIVER_DISPATCH HDA_Power
 
DRIVER_ADD_DEVICE HDA_AddDevice
 
DRIVER_UNLOAD HDA_Unload
 
DRIVER_INITIALIZE DriverEntry
 

Function Documentation

◆ AllocateItem()

PVOID AllocateItem ( _In_ POOL_TYPE  PoolType,
_In_ SIZE_T  NumberOfBytes 
)

Definition at line 18 of file hdaudbus.cpp.

21 {
23  if (!Item)
24  return Item;
25 
27  return Item;
28 }
#define TAG_HDA
Definition: hdaudbus.h:11
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1035
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by HDA_PdoPnp().

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPathName 
)

Definition at line 307 of file hdaudbus.cpp.

310 {
311  DriverObject->DriverUnload = HDA_Unload;
312  DriverObject->DriverExtension->AddDevice = HDA_AddDevice;
313  DriverObject->MajorFunction[IRP_MJ_POWER] = HDA_Power;
315  DriverObject->MajorFunction[IRP_MJ_PNP] = HDA_Pnp;
316 
317  return STATUS_SUCCESS;
318 }
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
DRIVER_DISPATCH HDA_Power
Definition: hdaudbus.cpp:12
DRIVER_DISPATCH HDA_Pnp
Definition: hdaudbus.cpp:10
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_POWER
#define IRP_MJ_SYSTEM_CONTROL
DRIVER_ADD_DEVICE HDA_AddDevice
Definition: hdaudbus.cpp:13
DRIVER_UNLOAD HDA_Unload
Definition: hdaudbus.cpp:14
#define STATUS_SUCCESS
Definition: shellext.h:65
DRIVER_DISPATCH HDA_SystemControl
Definition: hdaudbus.cpp:11

◆ FreeItem()

VOID FreeItem ( __drv_freesMem(Mem) PVOID  Item)

Definition at line 31 of file hdaudbus.cpp.

33 {
35 }
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ HDA_AddDevice()

NTSTATUS NTAPI HDA_AddDevice ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 265 of file hdaudbus.cpp.

268 {
270  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
272 
273  /* create device object */
275  if (!NT_SUCCESS(Status))
276  {
277  /* failed */
278  return Status;
279  }
280 
281  /* get device extension*/
282  DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
283 
284  /* init device extension*/
285  DeviceExtension->IsFDO = TRUE;
288  RtlZeroMemory(DeviceExtension->Codecs, sizeof(PHDA_CODEC_ENTRY) * (HDA_MAX_CODECS + 1));
289 
290  /* set device flags */
291  DeviceObject->Flags |= DO_POWER_PAGABLE;
292 
293  return Status;
294 }
FORCEINLINE VOID IoInitializeDpcRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIO_DPC_ROUTINE DpcRoutine)
Definition: iofuncs.h:2836
#define DO_POWER_PAGABLE
IO_DPC_ROUTINE HDA_DpcForIsr
Definition: hdaudbus.h:122
#define TRUE
Definition: types.h:120
struct HDA_FDO_DEVICE_EXTENSION * PHDA_FDO_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS+1]
Definition: hdaudbus.h:82
#define FALSE
Definition: types.h:117
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PDEVICE_OBJECT LowerDevice
Definition: hdaudbus.h:68
Definition: hdaudbus.h:45
#define HDA_MAX_CODECS
Definition: driver.h:41
#define NULL
Definition: types.h:112
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
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:148

◆ HDA_FdoPnp()

NTSTATUS HDA_FdoPnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 38 of file hdaudbus.cpp.

41 {
43  PIO_STACK_LOCATION IoStack;
44  PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
45  ULONG CodecIndex, AFGIndex;
46  PHDA_CODEC_ENTRY CodecEntry;
47  PHDA_PDO_DEVICE_EXTENSION ChildDeviceExtension;
48 
49  FDODeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
51 
52  switch (IoStack->MinorFunction)
53  {
56  Irp->IoStatus.Status = Status;
58  return Status;
62  for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
63  {
64  CodecEntry = FDODeviceExtension->Codecs[CodecIndex];
65 
67  for (AFGIndex = 0; AFGIndex < CodecEntry->AudioGroupCount; AFGIndex++)
68  {
69  ChildDeviceExtension = static_cast<PHDA_PDO_DEVICE_EXTENSION>(CodecEntry->AudioGroups[AFGIndex]->ChildPDO->DeviceExtension);
70  ChildDeviceExtension->ReportedMissing = TRUE;
71  }
72  }
73  Irp->IoStatus.Status = STATUS_SUCCESS;
74  break;
77  Irp->IoStatus.Status = STATUS_SUCCESS;
78  break;
80  /* handle bus device relations */
81  if (IoStack->Parameters.QueryDeviceRelations.Type == BusRelations)
82  {
84  Irp->IoStatus.Status = Status;
85  if (!NT_SUCCESS(Status))
86  {
88  return Status;
89  }
90  }
91  break;
92  }
93 
95  return IoCallDriver(FDODeviceExtension->LowerDevice, Irp);
96 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define HDA_MAX_AUDIO_GROUPS
Definition: driver.h:40
#define IRP_MN_REMOVE_DEVICE
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI HDA_FDOStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.cpp:578
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS NTAPI HDA_FDOQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.cpp:760
PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS+1]
Definition: hdaudbus.h:82
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
ULONG AudioGroupCount
Definition: hdaudbus.h:60
PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS]
Definition: hdaudbus.h:59
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MN_START_DEVICE
PDEVICE_OBJECT LowerDevice
Definition: hdaudbus.h:68
Definition: hdaudbus.h:45
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define HDA_MAX_CODECS
Definition: driver.h:41
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
PDEVICE_OBJECT ChildPDO
Definition: hdaudbus.h:40
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124
NTSTATUS NTAPI HDA_FDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: fdo.cpp:692

Referenced by HDA_Pnp().

◆ HDA_PdoPnp()

NTSTATUS HDA_PdoPnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 99 of file hdaudbus.cpp.

102 {
104  PIO_STACK_LOCATION IoStack;
105  PDEVICE_RELATIONS DeviceRelation;
106 
108 
109  switch (IoStack->MinorFunction)
110  {
111  case IRP_MN_START_DEVICE:
112  /* no op for pdo */
114  break;
117  break;
121  break;
123  /* query bus information */
125  break;
127  /* query pnp state */
129  break;
131  if (IoStack->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation)
132  {
133  /* handle target device relations */
134  ASSERT(IoStack->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation);
135  ASSERT(Irp->IoStatus.Information == 0);
136 
137  /* allocate device relation */
138  DeviceRelation = (PDEVICE_RELATIONS)AllocateItem(PagedPool, sizeof(DEVICE_RELATIONS));
139  if (DeviceRelation)
140  {
141  DeviceRelation->Count = 1;
142  DeviceRelation->Objects[0] = DeviceObject;
143 
144  /* reference self */
146 
147  /* store result */
148  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation;
149 
150  /* done */
152  }
153  else
154  {
155  /* no memory */
157  }
158  }
159  break;
161  /* query capabilities */
163  break;
165  /* no op */
167  break;
169  /* no op */
171  break;
172  case IRP_MN_QUERY_ID:
174  break;
177  break;
180  break;
181  default:
182  /* get default status */
183  Status = Irp->IoStatus.Status;
184  break;
185  }
186 
187  Irp->IoStatus.Status = Status;
189 
190  return Status;
191 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MN_QUERY_ID
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2160
LONG NTSTATUS
Definition: precomp.h:26
PVOID AllocateItem(_In_ POOL_TYPE PoolType, _In_ SIZE_T NumberOfBytes)
Definition: hdaudbus.cpp:18
NTSTATUS HDA_PDOQueryBusDevicePnpState(IN PIRP Irp)
Definition: pdo.cpp:227
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS HDA_PDOQueryBusInformation(IN PIRP Irp)
Definition: pdo.cpp:33
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
NTSTATUS HDA_PDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject)
Definition: pdo.cpp:11
NTSTATUS HDA_PDOQueryBusDeviceCapabilities(IN PIRP Irp)
Definition: pdo.cpp:199
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_QUERY_BUS_INFORMATION
NTSTATUS HDA_PDOHandleQueryInterface(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define ObReferenceObject
Definition: obfuncs.h:204
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ULONG_PTR
Definition: config.h:101
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124
#define IRP_MN_QUERY_PNP_DEVICE_STATE
NTSTATUS HDA_PDOHandleQueryDeviceText(IN PIRP Irp)
Definition: pdo.cpp:154
#define IRP_MN_QUERY_CAPABILITIES
NTSTATUS NTAPI HDA_PDOQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.cpp:62

Referenced by HDA_Pnp().

◆ HDA_Pnp()

NTSTATUS NTAPI HDA_Pnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 195 of file hdaudbus.cpp.

198 {
199  PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
200 
201  FDODeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
202 
203  if (FDODeviceExtension->IsFDO)
204  {
205  return HDA_FdoPnp(DeviceObject, Irp);
206  }
207  else
208  {
209  return HDA_PdoPnp(DeviceObject, Irp);
210  }
211 }
NTSTATUS HDA_FdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: hdaudbus.cpp:38
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS HDA_PdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: hdaudbus.cpp:99

◆ HDA_Power()

NTSTATUS NTAPI HDA_Power ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 239 of file hdaudbus.cpp.

242 {
244  PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
245 
246  FDODeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
247 
248  if (FDODeviceExtension->IsFDO)
249  {
252  return PoCallDriver(FDODeviceExtension->LowerDevice, Irp);
253  }
254  else
255  {
256  Status = Irp->IoStatus.Status;
259  return Status;
260  }
261 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT LowerDevice
Definition: hdaudbus.h:68
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ HDA_SystemControl()

NTSTATUS NTAPI HDA_SystemControl ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 215 of file hdaudbus.cpp.

218 {
220  PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
221 
222  FDODeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
223 
224  if (FDODeviceExtension->IsFDO)
225  {
227  return IoCallDriver(FDODeviceExtension->LowerDevice, Irp);
228  }
229  else
230  {
231  Status = Irp->IoStatus.Status;
233  return Status;
234  }
235 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT LowerDevice
Definition: hdaudbus.h:68
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ HDA_Unload()

VOID NTAPI HDA_Unload ( _In_ PDRIVER_OBJECT  DriverObject)

Definition at line 298 of file hdaudbus.cpp.

300 {
301 }

Variable Documentation

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 15 of file hdaudbus.cpp.

◆ HDA_AddDevice

DRIVER_ADD_DEVICE HDA_AddDevice

Definition at line 13 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_Pnp

DRIVER_DISPATCH HDA_Pnp

Definition at line 10 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_Power

DRIVER_DISPATCH HDA_Power

Definition at line 12 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_SystemControl

DRIVER_DISPATCH HDA_SystemControl

Definition at line 11 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_Unload

DRIVER_UNLOAD HDA_Unload

Definition at line 14 of file hdaudbus.cpp.

Referenced by DriverEntry().