ReactOS 0.4.15-dev-7681-g776c3a3
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 19 of file hdaudbus.cpp.

22{
23 return ExAllocatePoolZero(PoolType, NumberOfBytes, TAG_HDA);
24}
#define TAG_HDA
Definition: hdaudbus.h:15
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

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_Pnp
Definition: hdaudbus.cpp:11
DRIVER_DISPATCH HDA_SystemControl
Definition: hdaudbus.cpp:12
DRIVER_ADD_DEVICE HDA_AddDevice
Definition: hdaudbus.cpp:14
DRIVER_DISPATCH HDA_Power
Definition: hdaudbus.cpp:13
DRIVER_UNLOAD HDA_Unload
Definition: hdaudbus.cpp:15
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER

◆ FreeItem()

VOID FreeItem ( __drv_freesMem(Mem) PVOID  Item)

Definition at line 27 of file hdaudbus.cpp.

29{
31}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ WDFCOLLECTION _In_ WDFOBJECT Item

◆ HDA_AddDevice()

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

Definition at line 264 of file hdaudbus.cpp.

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

◆ HDA_FdoPnp()

NTSTATUS HDA_FdoPnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 34 of file hdaudbus.cpp.

37{
39 PIO_STACK_LOCATION IoStack;
40 PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
41 ULONG CodecIndex, AFGIndex;
42 PHDA_CODEC_ENTRY CodecEntry;
43 PHDA_PDO_DEVICE_EXTENSION ChildDeviceExtension;
44
45 FDODeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
47
48 switch (IoStack->MinorFunction)
49 {
52 Irp->IoStatus.Status = Status;
54 return Status;
58 for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
59 {
60 CodecEntry = FDODeviceExtension->Codecs[CodecIndex];
61
63 for (AFGIndex = 0; AFGIndex < CodecEntry->AudioGroupCount; AFGIndex++)
64 {
65 ChildDeviceExtension = static_cast<PHDA_PDO_DEVICE_EXTENSION>(CodecEntry->AudioGroups[AFGIndex]->ChildPDO->DeviceExtension);
66 ChildDeviceExtension->ReportedMissing = TRUE;
67 }
68 }
69 Irp->IoStatus.Status = STATUS_SUCCESS;
70 break;
73 Irp->IoStatus.Status = STATUS_SUCCESS;
74 break;
76 /* handle bus device relations */
77 if (IoStack->Parameters.QueryDeviceRelations.Type == BusRelations)
78 {
80 Irp->IoStatus.Status = Status;
81 if (!NT_SUCCESS(Status))
82 {
84 return Status;
85 }
86 }
87 break;
88 }
89
91 return IoCallDriver(FDODeviceExtension->LowerDevice, Irp);
92}
_In_ PIRP Irp
Definition: csq.h:116
#define HDA_MAX_AUDIO_GROUPS
Definition: driver.h:40
NTSTATUS NTAPI HDA_FDOStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.cpp:579
NTSTATUS NTAPI HDA_FDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: fdo.cpp:693
NTSTATUS NTAPI HDA_FDOQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.cpp:761
#define ASSERT(a)
Definition: mode.c:44
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCompleteRequest
Definition: irp.c:1240
#define IoCallDriver
Definition: irp.c:1225
PDEVICE_OBJECT ChildPDO
Definition: hdaudbus.h:39
PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS]
Definition: hdaudbus.h:58
ULONG AudioGroupCount
Definition: hdaudbus.h:59
PVOID DeviceExtension
Definition: env_spec_w32.h:418
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
uint32_t ULONG
Definition: typedefs.h:59
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
@ BusRelations
Definition: iotypes.h:2152
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by HDA_Pnp().

◆ HDA_PdoPnp()

NTSTATUS HDA_PdoPnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 95 of file hdaudbus.cpp.

98{
100 PIO_STACK_LOCATION IoStack;
101 PDEVICE_RELATIONS DeviceRelation;
102
104
105 switch (IoStack->MinorFunction)
106 {
108 /* no op for pdo */
110 break;
113 break;
117 break;
119 /* query bus information */
121 break;
123 /* query pnp state */
125 break;
127 if (IoStack->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation)
128 {
129 /* handle target device relations */
130 ASSERT(Irp->IoStatus.Information == 0);
131
132 /* allocate device relation */
133 DeviceRelation = (PDEVICE_RELATIONS)AllocateItem(PagedPool, sizeof(DEVICE_RELATIONS));
134 if (DeviceRelation)
135 {
136 DeviceRelation->Count = 1;
137 DeviceRelation->Objects[0] = DeviceObject;
138
139 /* reference self */
141
142 /* store result */
143 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation;
144
145 /* done */
147 }
148 else
149 {
150 /* no memory */
152 }
153 }
154 else
155 {
156 Status = Irp->IoStatus.Status;
157 }
158 break;
160 /* query capabilities */
162 break;
164 /* no op */
166 break;
168 /* no op */
170 break;
171 case IRP_MN_QUERY_ID:
173 break;
176 break;
179 break;
180 default:
181 /* get default status */
182 Status = Irp->IoStatus.Status;
183 break;
184 }
185
186 Irp->IoStatus.Status = Status;
188
189 return Status;
190}
NTSTATUS HDA_PDOHandleQueryInterface(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define ULONG_PTR
Definition: config.h:101
#define PagedPool
Definition: env_spec_w32.h:308
PVOID AllocateItem(_In_ POOL_TYPE PoolType, _In_ SIZE_T NumberOfBytes)
Definition: hdaudbus.cpp:19
NTSTATUS HDA_PDOHandleQueryDeviceText(IN PIRP Irp)
Definition: pdo.cpp:154
NTSTATUS HDA_PDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject)
Definition: pdo.cpp:11
NTSTATUS HDA_PDOQueryBusDeviceCapabilities(IN PIRP Irp)
Definition: pdo.cpp:199
NTSTATUS HDA_PDOQueryBusDevicePnpState(IN PIRP Irp)
Definition: pdo.cpp:227
NTSTATUS HDA_PDOQueryBusInformation(IN PIRP Irp)
Definition: pdo.cpp:33
NTSTATUS NTAPI HDA_PDOQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.cpp:62
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
@ TargetDeviceRelation
Definition: iotypes.h:2156
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_ID
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_QUERY_BUS_INFORMATION
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by HDA_Pnp().

◆ HDA_Pnp()

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

Definition at line 194 of file hdaudbus.cpp.

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

◆ HDA_Power()

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

Definition at line 238 of file hdaudbus.cpp.

241{
243 PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
244
245 FDODeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
246
247 if (FDODeviceExtension->IsFDO)
248 {
251 return PoCallDriver(FDODeviceExtension->LowerDevice, Irp);
252 }
253 else
254 {
255 Status = Irp->IoStatus.Status;
258 return Status;
259 }
260}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758

◆ HDA_SystemControl()

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

Definition at line 214 of file hdaudbus.cpp.

217{
219 PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
220
221 FDODeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
222
223 if (FDODeviceExtension->IsFDO)
224 {
226 return IoCallDriver(FDODeviceExtension->LowerDevice, Irp);
227 }
228 else
229 {
230 Status = Irp->IoStatus.Status;
232 return Status;
233 }
234}

◆ HDA_Unload()

VOID NTAPI HDA_Unload ( _In_ PDRIVER_OBJECT  DriverObject)

Definition at line 297 of file hdaudbus.cpp.

299{
300}

Variable Documentation

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 16 of file hdaudbus.cpp.

◆ HDA_AddDevice

DRIVER_ADD_DEVICE HDA_AddDevice

Definition at line 14 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_Pnp

DRIVER_DISPATCH HDA_Pnp

Definition at line 11 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_Power

DRIVER_DISPATCH HDA_Power

Definition at line 13 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_SystemControl

DRIVER_DISPATCH HDA_SystemControl

Definition at line 12 of file hdaudbus.cpp.

Referenced by DriverEntry().

◆ HDA_Unload

DRIVER_UNLOAD HDA_Unload

Definition at line 15 of file hdaudbus.cpp.

Referenced by DriverEntry().