ReactOS 0.4.16-dev-197-g92996da
event.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Video Port Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: win32ss/drivers/videoprt/event.c
5 * PURPOSE: Event Support Routines
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "videoprt.h"
12#include "../../gdi/eng/engevent.h"
13
14#define NDEBUG
15#include <debug.h>
16
17/* PUBLIC FUNCTIONS ***********************************************************/
18
19/*
20 * @implemented
21 */
25 _In_ PVOID HwDeviceExtension,
26 _In_ ULONG EventFlag,
28 _Out_ PEVENT* pEvent)
29{
31 PVIDEO_PORT_EVENT EngEvent;
32
33 /* Allocate memory for the event structure */
35 sizeof(VIDEO_PORT_EVENT) + sizeof(KEVENT),
37 if (EngEvent)
38 {
39 /* Zero flags */
40 EngEvent->fFlags = 0;
41
42 /* Set KEVENT pointer */
43 EngEvent->pKEvent = EngEvent + 1;
44
45 /* Initialize the kernel event */
46 KeInitializeEvent(EngEvent->pKEvent,
47 (EventFlag & EVENT_TYPE_MASK) ?
49 EventFlag & INITIAL_EVENT_STATE_MASK);
50
51 /* Pass pointer to our structure to the caller */
52 *pEvent = (PEVENT)EngEvent;
53 DPRINT("VideoPortCreateEvent() created %p\n", EngEvent);
54 }
55 else
56 {
57 /* Out of memory */
58 DPRINT("VideoPortCreateEvent() failed\n");
60 }
61
62 /* Return result */
63 return Result;
64}
65
66/*
67 * @implemented
68 */
72 _In_ PVOID HwDeviceExtension,
74{
75 /* Handle error cases */
76 if (!Event) return ERROR_INVALID_PARAMETER;
78 if (!Event->pKEvent) return ERROR_INVALID_PARAMETER;
79
80 /* Free storage */
82
83 /* Indicate success */
84 return NO_ERROR;
85}
86
87/*
88 * @implemented
89 */
90LONG
93 _In_ PVOID HwDeviceExtension,
95{
97 return KeSetEvent(Event->pKEvent, IO_NO_INCREMENT, FALSE);
98}
99
100/*
101 * @implemented
102 */
103VOID
104NTAPI
106 _In_ PVOID HwDeviceExtension,
108{
109 ASSERT(Event);
110 KeClearEvent(Event->pKEvent);
111}
112
113/*
114 * @implemented
115 */
116LONG
117NTAPI
119 _In_ PVOID HwDeviceExtension,
121{
122 ASSERT(Event);
123 return KeReadStateEvent(Event->pKEvent);
124}
125
126/*
127 * @implemented
128 */
130NTAPI
132 _In_ PVOID HwDeviceExtension,
135{
136 PVIDEO_PORT_EVENT EngEvent = Event;
138
139 /* Handle error cases */
140 if (!EngEvent) return ERROR_INVALID_PARAMETER;
141 if (!EngEvent->pKEvent) return ERROR_INVALID_PARAMETER;
142 if (EngEvent->fFlags & ENG_EVENT_USERMAPPED) return ERROR_INVALID_PARAMETER;
143
144 /* Do the actual wait */
145 Status = KeWaitForSingleObject(EngEvent->pKEvent,
146 Executive,
148 FALSE,
149 Timeout);
150 if (Status == STATUS_TIMEOUT)
151 {
152 /* Convert to wait timeout, otherwise NT_SUCCESS would return NO_ERROR */
153 return WAIT_TIMEOUT;
154 }
155 else if (NT_SUCCESS(Status))
156 {
157 /* All other success codes are Win32 success */
158 return NO_ERROR;
159 }
160
161 /* Otherwise, return default Win32 failure */
163}
164
165/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_TIMEOUT
Definition: d3dkmdt.h:49
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
@ ENG_EVENT_USERMAPPED
Definition: engevent.h:8
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define NonPagedPool
Definition: env_spec_w32.h:307
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
LONG NTAPI KeReadStateEvent(IN PKEVENT Event)
Definition: eventobj.c:120
Status
Definition: gdiplustypes.h:25
#define Unused(x)
Definition: atlwin.h:28
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define KernelMode
Definition: asm.h:34
struct _ENG_EVENT * PEVENT
Definition: ntddvdeo.h:618
@ NotificationEvent
@ SynchronizationEvent
long LONG
Definition: pedump.c:60
static ULONG Timeout
Definition: ping.c:61
#define INITIAL_EVENT_STATE_MASK
Definition: video.h:111
LONG VP_STATUS
Definition: video.h:153
#define EVENT_TYPE_MASK
Definition: video.h:107
#define DPRINT
Definition: sndvol32.h:73
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
VP_STATUS NTAPI VideoPortWaitForSingleObject(_In_ PVOID HwDeviceExtension, _In_ PVOID Event, _In_opt_ PLARGE_INTEGER Timeout)
Definition: event.c:131
LONG NTAPI VideoPortSetEvent(_In_ PVOID HwDeviceExtension, _In_ PEVENT Event)
Definition: event.c:92
VOID NTAPI VideoPortClearEvent(_In_ PVOID HwDeviceExtension, _In_ PEVENT Event)
Definition: event.c:105
VP_STATUS NTAPI VideoPortDeleteEvent(_In_ PVOID HwDeviceExtension, _In_ PEVENT Event)
Definition: event.c:71
VP_STATUS NTAPI VideoPortCreateEvent(_In_ PVOID HwDeviceExtension, _In_ ULONG EventFlag, _In_ PVOID Unused, _Out_ PEVENT *pEvent)
Definition: event.c:24
LONG NTAPI VideoPortReadStateEvent(_In_ PVOID HwDeviceExtension, _In_ PEVENT Event)
Definition: event.c:118
_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
#define IO_NO_INCREMENT
Definition: iotypes.h:598
@ Executive
Definition: ketypes.h:415