Author: fireball
Date: Tue Jun 30 17:42:42 2009
New Revision: 41713
URL:
http://svn.reactos.org/svn/reactos?rev=41713&view=rev
Log:
- Rewrite VideoPort and Win32k (Eng) event functions to:
* Use a documented ENG_EVENT structure (thus be compatible with Windows videoprt/win32k)
instead of a stupid (PKEVENT) casting everywhere through EngEvent or VideoPort event
functions;
* Implement additional checks for user mapped events in EngDeleteEvent and
EngWaitForSingleObject;
* Implement EngReadStateEvent and EngClearEvent.
* Provide a better, readable code which matches kernelstyle coding guidelines;
* Remove (stub out) totally incorrect and buggy map user events support;
- Compile videoprt with ms-extensions flag enabled.
Added:
trunk/reactos/subsystems/win32/win32k/eng/engevent.c (with props)
trunk/reactos/subsystems/win32/win32k/include/engevent.h (with props)
Removed:
trunk/reactos/subsystems/win32/win32k/eng/event.c
Modified:
trunk/reactos/drivers/video/videoprt/event.c
trunk/reactos/drivers/video/videoprt/videoprt.h
trunk/reactos/drivers/video/videoprt/videoprt.rbuild
trunk/reactos/subsystems/win32/win32k/include/win32k.h
trunk/reactos/subsystems/win32/win32k/stubs/stubs.c
trunk/reactos/subsystems/win32/win32k/win32k.rbuild
Modified: trunk/reactos/drivers/video/videoprt/event.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/eve…
==============================================================================
--- trunk/reactos/drivers/video/videoprt/event.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/video/videoprt/event.c [iso-8859-1] Tue Jun 30 17:42:42 2009
@@ -35,22 +35,30 @@
IN PVOID Unused,
OUT PEVENT *Event)
{
- EVENT_TYPE Type;
+ PVIDEO_PORT_EVENT VpEvent;
+ EVENT_TYPE Type = SynchronizationEvent;
- (*Event) = ExAllocatePoolWithTag(
+ /* Allocate storage for the event structure */
+ VpEvent = ExAllocatePoolWithTag(
NonPagedPool,
- sizeof(KEVENT),
+ sizeof(VIDEO_PORT_EVENT),
TAG_VIDEO_PORT);
- if ((*Event) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ /* Fail if not enough memory */
+ if (!VpEvent) return ERROR_NOT_ENOUGH_MEMORY;
+ /* Initialize the event structure */
+ RtlZeroMemory(VpEvent, sizeof(VIDEO_PORT_EVENT));
+ VpEvent->pKEvent = &VpEvent->Event;
+
+ /* Determine the event type */
if (EventFlag & NOTIFICATION_EVENT)
Type = NotificationEvent;
- else
- Type = SynchronizationEvent;
- KeInitializeEvent((PKEVENT)*Event, Type, EventFlag & INITIAL_EVENT_SIGNALED);
+ /* Initialize kernel event */
+ KeInitializeEvent(VpEvent->pKEvent, Type, EventFlag & INITIAL_EVENT_SIGNALED);
+
+ /* Indicate success */
return NO_ERROR;
}
@@ -63,7 +71,10 @@
IN PVOID HwDeviceExtension,
IN PEVENT Event)
{
+ /* Free storage */
ExFreePool(Event);
+
+ /* Indicate success */
return NO_ERROR;
}
@@ -76,7 +87,7 @@
IN PVOID HwDeviceExtension,
IN PEVENT Event)
{
- return KeSetEvent((PKEVENT)Event, IO_NO_INCREMENT, FALSE);
+ return KeSetEvent(Event->pKEvent, IO_NO_INCREMENT, FALSE);
}
/*
@@ -88,7 +99,7 @@
IN PVOID HwDeviceExtension,
IN PEVENT Event)
{
- KeClearEvent((PKEVENT)Event);
+ KeClearEvent(Event->pKEvent);
}
/*
Modified: trunk/reactos/drivers/video/videoprt/videoprt.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/vid…
==============================================================================
--- trunk/reactos/drivers/video/videoprt/videoprt.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/video/videoprt/videoprt.h [iso-8859-1] Tue Jun 30 17:42:42 2009
@@ -104,6 +104,15 @@
VIDEO_PORT_DEVICE_EXTENSION, \
MiniPortDeviceExtension)
+typedef struct _VIDEO_PORT_EVENT
+{
+ /* Public part */
+ ENG_EVENT;
+
+ /* Private part */
+ KEVENT Event;
+} VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT;
+
/* agp.c */
NTSTATUS
Modified: trunk/reactos/drivers/video/videoprt/videoprt.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/vid…
==============================================================================
--- trunk/reactos/drivers/video/videoprt/videoprt.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/video/videoprt/videoprt.rbuild [iso-8859-1] Tue Jun 30 17:42:42
2009
@@ -5,6 +5,7 @@
<include base="videoprt">.</include>
<include base="ntoskrnl">include</include>
<define name="_VIDEOPORT_" />
+ <compilerflag compilerset="gcc">-fms-extensions</compilerflag>
<library>ntoskrnl</library>
<library>hal</library>
<pch>videoprt.h</pch>
Added: trunk/reactos/subsystems/win32/win32k/eng/engevent.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/engevent.c (added)
+++ trunk/reactos/subsystems/win32/win32k/eng/engevent.c [iso-8859-1] Tue Jun 30 17:42:42
2009
@@ -1,0 +1,159 @@
+/*
+ * PROJECT: ReactOS Win32K
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/eng/engevent.c
+ * PURPOSE: Event Support Routines
+ * PROGRAMMERS: Aleksey Bragin <aleksey(a)reactos.org>
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <w32k.h>
+#define NDEBUG
+#include <debug.h>
+
+#define TAG_ENG TAG('E', 'n', 'g', ' ')
+
+/* PUBLIC FUNCTIONS **********************************************************/
+
+BOOL
+APIENTRY
+EngCreateEvent(OUT PEVENT* Event)
+{
+ PENG_EVENT EngEvent;
+
+ /* Allocate memory for the event structure */
+ EngEvent = EngAllocMem(FL_NONPAGED_MEMORY | FL_ZERO_MEMORY,
+ sizeof(ENG_EVENT),
+ TAG_ENG);
+
+ /* Check if we are out of memory */
+ if (!EngEvent)
+ {
+ /* We are, fail */
+ return FALSE;
+ }
+
+ /* Set KEVENT pointer */
+ EngEvent->pKEvent = &EngEvent->KEvent;
+
+ /* Initialize the kernel event */
+ KeInitializeEvent(EngEvent->pKEvent,
+ SynchronizationEvent,
+ FALSE);
+
+ /* Pass pointer to our structure to the caller */
+ *Event = EngEvent;
+
+ DPRINT("EngCreateEvent() created %p\n", EngEvent);
+
+ /* Return success */
+ return TRUE;
+}
+
+BOOL
+APIENTRY
+EngDeleteEvent(IN PEVENT Event)
+{
+ DPRINT("EngDeleteEvent(%p)\n", Event);
+
+ /* Check if it's a usermapped event */
+ if (Event->fFlags & ENG_EVENT_USERMAPPED)
+ {
+ /* Disallow deletion of usermapped events */
+ DPRINT1("Driver attempted to delete a usermapped event!\n");
+ return FALSE;
+ }
+
+ /* Free the allocated memory */
+ EngFreeMem(Event);
+
+ /* Return success */
+ return TRUE;
+}
+
+VOID
+APIENTRY
+EngClearEvent(IN PEVENT Event)
+{
+ /* Clear the event */
+ KeClearEvent(Event->pKEvent);
+}
+
+LONG
+APIENTRY
+EngSetEvent(IN PEVENT Event)
+{
+ /* Set the event */
+ return KeSetEvent(Event->pKEvent,
+ IO_NO_INCREMENT,
+ FALSE);
+}
+
+LONG
+APIENTRY
+EngReadStateEvent(IN PEVENT Event)
+{
+ /* Read the event state */
+ return KeReadStateEvent(Event->pKEvent);
+}
+
+PEVENT
+APIENTRY
+EngMapEvent(IN HDEV hDev,
+ IN HANDLE hUserObject,
+ IN PVOID Reserved1,
+ IN PVOID Reserved2,
+ IN PVOID Reserved3)
+{
+ DPRINT("EngMapEvent(%x %x %p %p %p)\n", hDev, hUserObject, Reserved1,
Reserved2, Reserved3);
+ UNIMPLEMENTED;
+ return NULL;
+}
+
+BOOL
+APIENTRY
+EngUnmapEvent(IN PEVENT Event)
+{
+ DPRINT("EngUnmapEvent(%p)\n", Event);
+ UNIMPLEMENTED;
+ return FALSE;
+}
+
+BOOL
+APIENTRY
+EngWaitForSingleObject(IN PEVENT Event,
+ IN PLARGE_INTEGER TimeOut)
+{
+ NTSTATUS Status;
+
+ DPRINT("EngWaitForSingleObject(%p %I64d)\n", Event, TimeOut->QuadPart);
+
+ /* Validate parameters */
+ if (!Event) return FALSE;
+
+ /* Check if it's a usermapped event and fail in that case */
+ if (Event->fFlags & ENG_EVENT_USERMAPPED)
+ {
+ /* Disallow deletion of usermapped events */
+ DPRINT1("Driver attempted to wait on a usermapped event!\n");
+ return FALSE;
+ }
+
+ /* Wait for the event */
+ Status = KeWaitForSingleObject(Event->pKEvent,
+ Executive,
+ KernelMode,
+ FALSE,
+ TimeOut);
+
+ /* Check if there is a failure or a timeout */
+ if (!NT_SUCCESS(Status))
+ {
+ /* Return failure */
+ return FALSE;
+ }
+
+ /* Return success */
+ return TRUE;
+}
Propchange: trunk/reactos/subsystems/win32/win32k/eng/engevent.c
------------------------------------------------------------------------------
svn:eol-style = native
Removed: trunk/reactos/subsystems/win32/win32k/eng/event.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/event.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/event.c (removed)
@@ -1,105 +1,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Win32k event functions
- * FILE: subsys/win32k/eng/event.c
- * PROGRAMER: Jason Filby
- * REVISION HISTORY:
- * 2/10/1999: Created
- */
-
-#include <w32k.h>
-
-#define NDEBUG
-#include <debug.h>
-
-BOOL
-APIENTRY
-EngCreateEvent ( OUT PEVENT *Event )
-{
- (*Event) = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_DFSM);
- if ((*Event) == NULL)
- {
- return FALSE;
- }
- KeInitializeEvent((PKEVENT)(*Event), SynchronizationEvent, FALSE);
- return TRUE;
-}
-
-BOOL
-APIENTRY
-EngDeleteEvent ( IN PEVENT Event)
-{
- ExFreePoolWithTag(Event, TAG_DFSM);
- return TRUE;
-}
-
-PEVENT
-APIENTRY
-EngMapEvent(IN HDEV Dev,
- IN HANDLE UserObject,
- IN PVOID Reserved1,
- IN PVOID Reserved2,
- IN PVOID Reserved3)
-{
- NTSTATUS Status;
- PKEVENT Event;
-
- Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_DFSM);
- if (!Event) return NULL;
-
- Status = ObReferenceObjectByHandle(UserObject,
- EVENT_MODIFY_STATE,
- ExEventObjectType,
- KernelMode,
- (PVOID*)&Event,
- NULL);
- if (!NT_SUCCESS(Status))
- {
- ExFreePoolWithTag(Event, TAG_DFSM);
- return NULL;
- }
- else
- KePulseEvent(Event, EVENT_INCREMENT, FALSE);
-
- if (Reserved1) Reserved1 = Event;
-
- return (PEVENT)Event;
-}
-
-LONG
-APIENTRY
-EngSetEvent ( IN PEVENT Event )
-{
- return KeSetEvent((PKEVENT)Event, IO_NO_INCREMENT, FALSE);
-}
-
-BOOL
-APIENTRY
-EngUnmapEvent ( IN PEVENT Event )
-{
- ObDereferenceObject((PVOID)Event);
- ExFreePoolWithTag(Event, TAG_DFSM);
- return TRUE;
-}
-
-BOOL
-APIENTRY
-EngWaitForSingleObject (IN PEVENT Event,
- IN PLARGE_INTEGER TimeOut)
-{
- NTSTATUS Status;
-
- if (!Event) return FALSE;
-
- Status = KeWaitForSingleObject(Event,
- Executive,
- KernelMode,
- FALSE,
- TimeOut);
- if (!NT_SUCCESS(Status))
- {
- return FALSE;
- }
- return TRUE;
-}
Added: trunk/reactos/subsystems/win32/win32k/include/engevent.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/engevent.h (added)
+++ trunk/reactos/subsystems/win32/win32k/include/engevent.h [iso-8859-1] Tue Jun 30
17:42:42 2009
@@ -1,0 +1,16 @@
+#ifndef __WIN32K_ENGEVENT_H
+#define __WIN32K_ENGEVENT_H
+
+#define ENG_EVENT_USERMAPPED 1
+
+typedef struct _ENG_EVENT
+{
+ /* Public part */
+ PVOID pKEvent;
+ ULONG fFlags;
+
+ /* Private part */
+ KEVENT KEvent;
+} ENG_EVENT, *PENG_EVENT;
+
+#endif
Propchange: trunk/reactos/subsystems/win32/win32k/include/engevent.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/subsystems/win32/win32k/include/win32k.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/win32k.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/win32k.h [iso-8859-1] Tue Jun 30
17:42:42 2009
@@ -76,6 +76,7 @@
#include <include/misc.h>
#include <include/gdifloat.h>
#include <include/engobjects.h>
+#include <include/engevent.h>
#include <dib/dib.h>
#endif /* __WIN32K_H */
Modified: trunk/reactos/subsystems/win32/win32k/stubs/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/st…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/stubs/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/stubs/stubs.c [iso-8859-1] Tue Jun 30 17:42:42
2009
@@ -794,18 +794,6 @@
{
UNIMPLEMENTED;
return NULL;
-}
-
-/*
- * @unimplemented
- */
-VOID
-APIENTRY
-EngClearEvent(
- IN PEVENT Event)
-{
- /* Forward to the kernel */
- KeClearEvent((PKEVENT)Event);
}
/*
@@ -923,17 +911,6 @@
FileTime.QuadPart = 0;
UNIMPLEMENTED;
return FileTime;
-}
-
-/*
- * @unimplemented
- */
-LONG APIENTRY
-EngReadStateEvent(
- IN PEVENT Event)
-{
- UNIMPLEMENTED;
- return 0;
}
/*
Modified: trunk/reactos/subsystems/win32/win32k/win32k.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/wi…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] Tue Jun 30 17:42:42
2009
@@ -48,13 +48,13 @@
<file>alphablend.c</file>
<file>bitblt.c</file>
<file>engbrush.c</file>
+ <file>engevent.c</file>
<file>clip.c</file>
<file>copybits.c</file>
<file>debug.c</file>
<file>device.c</file>
<file>driverobj.c</file>
<file>error.c</file>
- <file>event.c</file>
<file>float.c</file>
<if property="ARCH" value="i386">
<directory name="i386">