ReactOS 0.4.15-dev-8235-gcd88a97
events.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS TDI driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/network/tdi/cte/events.c
5 * PURPOSE: CTE events support
6 * PROGRAMMERS: Oleg Baikalow (obaikalow@gmail.com)
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include "precomp.h"
12
13typedef struct _CTEBLOCK_EVENT
14{
18
21
22typedef struct _CTE_DELAYED_EVENT
23{
30
31/* FUNCTIONS *****************************************************************/
32
33/*
34 * @implemented
35 */
39{
41
42 /* Perform the wait */
44
45 /* Update event status if wait was not successful */
46 if (!NT_SUCCESS(Status)) Block->Status = Status;
47
48 return Block->Status;
49}
50
51
52VOID
55{
58
59 /* Acquire the lock */
61
62 /* Make sure it is queued */
63 ASSERT(Event->Queued);
64 Event->Queued = FALSE;
65
66 /* Release the lock */
68
69 /* Call the real worker routine */
70 (*Event->WorkerRoutine)(Event, Event->Context);
71}
72
73
74/*
75 * @implemented
76 */
77VOID
80 CTE_WORKER_ROUTINE Routine)
81{
82 /* Init the structure, lock and a work item */
83 Event->Queued = FALSE;
85 Event->WorkerRoutine = Routine;
87}
88
89/*
90 * @unimplemented
91 */
95 ULONG Unknown0,
96 ULONG Unknown1,
97 ULONG Unknown2,
102 )
103{
104 /* Probably call
105 * IoAllocateErrorLogEntry and
106 * IoWriteErrorLogEntry
107 */
109}
110
111
112/*
113 * @implemented
114 */
116NTAPI
119{
121
122 /* Acquire the lock */
124
125 /* Make sure it is queued */
126 if (!Event->Queued)
127 {
128 /* Mark it as queued and set optional context pointer */
129 Event->Queued = TRUE;
130 Event->Context = Context;
131
132 /* Actually queue it */
134 }
135
136 /* Release the lock */
138
139 return TRUE;
140}
141
142
143/*
144 * @implemented
145 */
146LONG
147NTAPI
149{
150 /* Set status right away */
151 Block->Status = Status;
152
153 /* Set the event */
154 return KeSetEvent(&Block->Event, IO_NO_INCREMENT, FALSE);
155}
156
157/* EOF */
unsigned char BOOLEAN
PRTL_UNICODE_STRING_BUFFER PULONG PULONG Unknown4
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD IN DWORD IN DWORD IN DWORD Unknown6
Definition: conport.c:40
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD IN DWORD IN DWORD Unknown5
Definition: conport.c:39
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD Unknown3
Definition: conport.c:37
#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
NTSTATUS NTAPI CTELogEvent(ULONG Unknown0, ULONG Unknown1, ULONG Unknown2, ULONG Unknown3, ULONG Unknown4, ULONG Unknown5, ULONG Unknown6)
Definition: events.c:94
struct _CTE_DELAYED_EVENT * PCTE_DELAYED_EVENT
BOOLEAN NTAPI CTEScheduleEvent(PCTE_DELAYED_EVENT Event, PVOID Context)
Definition: events.c:117
void(* CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context)
Definition: events.c:20
struct _CTEBLOCK_EVENT CTEBLOCK_EVENT
LONG NTAPI CTESignal(PCTEBLOCK_EVENT Block, NTSTATUS Status)
Definition: events.c:148
struct _CTEBLOCK_EVENT * PCTEBLOCK_EVENT
VOID NTAPI CTEInitEvent(PCTE_DELAYED_EVENT Event, CTE_WORKER_ROUTINE Routine)
Definition: events.c:79
VOID NTAPI InternalWorker(IN PVOID Parameter)
Definition: events.c:54
struct _CTE_DELAYED_EVENT CTE_DELAYED_EVENT
NTSTATUS NTAPI CTEBlock(PCTEBLOCK_EVENT Block)
Definition: events.c:38
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
#define KernelMode
Definition: asm.h:34
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
long LONG
Definition: pedump.c:60
KEVENT Event
Definition: events.c:16
NTSTATUS Status
Definition: events.c:15
BOOLEAN Queued
Definition: events.c:24
KSPIN_LOCK Lock
Definition: events.c:25
CTE_WORKER_ROUTINE WorkerRoutine
Definition: events.c:26
WORK_QUEUE_ITEM WorkItem
Definition: events.c:28
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:723
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
@ CriticalWorkQueue
Definition: extypes.h:189
#define IO_NO_INCREMENT
Definition: iotypes.h:598
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ UserRequest
Definition: ketypes.h:421
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336