ReactOS  0.4.15-dev-489-g75a0787
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 
13 typedef struct _CTEBLOCK_EVENT
14 {
18 
19 struct _CTE_DELAYED_EVENT;
20 typedef void (*CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context);
21 
22 typedef struct _CTE_DELAYED_EVENT
23 {
30 
31 /* FUNCTIONS *****************************************************************/
32 
33 /*
34  * @implemented
35  */
37 NTAPI
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 
52 VOID
53 NTAPI
55 {
57  KIRQL OldIrql;
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  */
77 VOID
78 NTAPI
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  */
93 NTAPI
95  ULONG Unknown0,
96  ULONG Unknown1,
97  ULONG Unknown2,
100  ULONG Unknown5,
102  )
103 {
104  /* Probably call
105  * IoAllocateErrorLogEntry and
106  * IoWriteErrorLogEntry
107  */
108  return STATUS_NOT_IMPLEMENTED;
109 }
110 
111 
112 /*
113  * @implemented
114  */
115 BOOLEAN
116 NTAPI
118  PVOID Context)
119 {
120  KIRQL OldIrql;
121 
122  /* Acquire the lock */
123  KeAcquireSpinLock(&Event->Lock, &OldIrql);
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  */
146 LONG
147 NTAPI
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 */
#define IN
Definition: typedefs.h:39
#define TRUE
Definition: types.h:120
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:717
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD Unknown3
Definition: conport.c:35
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
struct _CTE_DELAYED_EVENT * PCTE_DELAYED_EVENT
NTSTATUS Status
Definition: events.c:15
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD IN DWORD IN DWORD IN DWORD Unknown6
Definition: conport.c:35
_In_ PVOID Parameter
Definition: ldrtypes.h:241
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
KSPIN_LOCK Lock
Definition: events.c:25
LONG NTAPI CTESignal(PCTEBLOCK_EVENT Block, NTSTATUS Status)
Definition: events.c:148
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
long LONG
Definition: pedump.c:60
PRTL_UNICODE_STRING_BUFFER PULONG PULONG Unknown4
VOID NTAPI InternalWorker(IN PVOID Parameter)
Definition: events.c:54
NTSTATUS NTAPI CTEBlock(PCTEBLOCK_EVENT Block)
Definition: events.c:38
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN Queued
Definition: events.c:24
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WORK_QUEUE_ITEM WorkItem
Definition: events.c:28
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
CTE_WORKER_ROUTINE WorkerRoutine
Definition: events.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
VOID NTAPI CTEInitEvent(PCTE_DELAYED_EVENT Event, CTE_WORKER_ROUTINE Routine)
Definition: events.c:79
Status
Definition: gdiplustypes.h:24
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
void(* CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context)
Definition: events.c:20
KEVENT Event
Definition: events.c:16
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
BOOLEAN NTAPI CTEScheduleEvent(PCTE_DELAYED_EVENT Event, PVOID Context)
Definition: events.c:117
NTSTATUS NTAPI CTELogEvent(ULONG Unknown0, ULONG Unknown1, ULONG Unknown2, ULONG Unknown3, ULONG Unknown4, ULONG Unknown5, ULONG Unknown6)
Definition: events.c:94
struct _CTEBLOCK_EVENT * PCTEBLOCK_EVENT
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:568
struct _CTE_DELAYED_EVENT CTE_DELAYED_EVENT
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD IN DWORD IN DWORD Unknown5
Definition: conport.c:35
struct _CTEBLOCK_EVENT CTEBLOCK_EVENT