ReactOS 0.4.17-dev-769-g1500a35
controller.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for controller.c:

Go to the source code of this file.

Functions

VOID NTAPI IoAllocateController (IN PCONTROLLER_OBJECT ControllerObject, IN PDEVICE_OBJECT DeviceObject, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
 
PCONTROLLER_OBJECT NTAPI IoCreateController (IN ULONG Size)
 
VOID NTAPI IoDeleteController (IN PCONTROLLER_OBJECT ControllerObject)
 
VOID NTAPI IoFreeController (IN PCONTROLLER_OBJECT ControllerObject)
 

Variables

POBJECT_TYPE IoControllerObjectType
 

Function Documentation

◆ IoAllocateController()

VOID NTAPI IoAllocateController ( IN PCONTROLLER_OBJECT  ControllerObject,
IN PDEVICE_OBJECT  DeviceObject,
IN PDRIVER_CONTROL  ExecutionRoutine,
IN PVOID  Context 
)

Definition at line 25 of file controller.c.

29{
32
33 /* Initialize the Wait Context Block */
34 DeviceObject->Queue.Wcb.DeviceContext = Context;
35 DeviceObject->Queue.Wcb.DeviceRoutine = ExecutionRoutine;
36
37 /* Insert the Device Queue */
38 if (!KeInsertDeviceQueue(&ControllerObject->DeviceWaitQueue,
39 &DeviceObject->Queue.Wcb.WaitQueueEntry))
40 {
41 /* Call the execution routine */
43 DeviceObject->CurrentIrp,
44 NULL,
45 Context);
46
47 /* Free the controller if this was requested */
48 if (Result == DeallocateObject) IoFreeController(ControllerObject);
49 }
50}
VOID NTAPI IoFreeController(IN PCONTROLLER_OBJECT ControllerObject)
Definition: controller.c:128
BOOLEAN NTAPI KeInsertDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry)
Definition: devqueue.c:41
#define NULL
Definition: types.h:112
#define ASSERT_IRQL_EQUAL(x)
Definition: debug.h:43
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_In_ PVOID Context
Definition: storport.h:2269
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_In_ PDEVICE_OBJECT _In_ ULONG _In_ PDRIVER_CONTROL ExecutionRoutine
Definition: iofuncs.h:1399
enum _IO_ALLOCATION_ACTION IO_ALLOCATION_ACTION
@ DeallocateObject
Definition: iotypes.h:203

Referenced by AtaReqDispatchRequest().

◆ IoCreateController()

PCONTROLLER_OBJECT NTAPI IoCreateController ( IN ULONG  Size)

Definition at line 57 of file controller.c.

58{
59 PCONTROLLER_OBJECT Controller;
63 PAGED_CODE();
64
65 /* Initialize an empty OBA */
67 NULL,
69 NULL,
70 NULL);
71
72 /* Honor the internal I/O System case (in)sensitivity */
74
75 /* Create the Object */
80 NULL,
81 sizeof(CONTROLLER_OBJECT) + Size,
82 0,
83 0,
84 (PVOID*)&Controller);
85 if (!NT_SUCCESS(Status)) return NULL;
86
87 /* Insert it */
88 Status = ObInsertObject(Controller,
89 NULL,
91 1,
92 (PVOID*)&Controller,
93 &Handle);
94 if (!NT_SUCCESS(Status)) return NULL;
95
96 /* Close the dummy handle */
98
99 /* Zero the Object and set its data */
100 RtlZeroMemory(Controller, sizeof(CONTROLLER_OBJECT) + Size);
101 Controller->Type = IO_TYPE_CONTROLLER;
102 Controller->Size = sizeof(CONTROLLER_OBJECT) + (CSHORT)Size;
103 Controller->ControllerExtension = (Controller + 1);
104
105 /* Initialize its Queue */
107
108 /* Return Controller */
109 return Controller;
110}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
POBJECT_TYPE IoControllerObjectType
Definition: controller.c:16
VOID NTAPI KeInitializeDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
Definition: devqueue.c:22
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:24
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
#define KernelMode
Definition: asm.h:38
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
ULONG IopCaseInsensitive
Definition: iomgr.c:38
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3406
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2957
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:1040
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
KDEVICE_QUEUE DeviceWaitQueue
Definition: iotypes.h:4467
PVOID ControllerExtension
Definition: iotypes.h:4466
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
short CSHORT
Definition: umtypes.h:127
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
struct _CONTROLLER_OBJECT CONTROLLER_OBJECT
#define IO_TYPE_CONTROLLER

Referenced by PciIdeGetControllerProperties().

◆ IoDeleteController()

VOID NTAPI IoDeleteController ( IN PCONTROLLER_OBJECT  ControllerObject)

Definition at line 117 of file controller.c.

118{
119 /* Just Dereference it */
120 ObDereferenceObject(ControllerObject);
121}
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by PciIdeXFdoFreeResources().

◆ IoFreeController()

VOID NTAPI IoFreeController ( IN PCONTROLLER_OBJECT  ControllerObject)

Definition at line 128 of file controller.c.

129{
133
134 /* Remove the Queue */
135 QueueEntry = KeRemoveDeviceQueue(&ControllerObject->DeviceWaitQueue);
136 if (QueueEntry)
137 {
138 /* Get the Device Object */
141 Queue.Wcb.WaitQueueEntry);
142
143 /* Call the routine */
144 Result = DeviceObject->Queue.Wcb.DeviceRoutine(DeviceObject,
145 DeviceObject->CurrentIrp,
146 NULL,
148 Queue.Wcb.DeviceContext);
149 /* Free the controller if this was requested */
150 if (Result == DeallocateObject) IoFreeController(ControllerObject);
151 }
152}
PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
Definition: devqueue.c:153
_In_ PREQUEST_QUEUE_ENTRY QueueEntry
Definition: scsi.c:1054
Definition: ketypes.h:646
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231

Referenced by AtaReqCompleteRequest(), IoAllocateController(), and IoFreeController().

Variable Documentation

◆ IoControllerObjectType

POBJECT_TYPE IoControllerObjectType

Definition at line 16 of file controller.c.

Referenced by IoCreateController(), and IopCreateObjectTypes().