mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:03:12 +00:00
- 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. svn path=/trunk/; revision=41713
This commit is contained in:
parent
615a35bf83
commit
e468760dd8
9 changed files with 208 additions and 139 deletions
|
@ -35,22 +35,30 @@ VideoPortCreateEvent(
|
||||||
IN PVOID Unused,
|
IN PVOID Unused,
|
||||||
OUT PEVENT *Event)
|
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,
|
NonPagedPool,
|
||||||
sizeof(KEVENT),
|
sizeof(VIDEO_PORT_EVENT),
|
||||||
TAG_VIDEO_PORT);
|
TAG_VIDEO_PORT);
|
||||||
|
|
||||||
if ((*Event) == NULL)
|
/* Fail if not enough memory */
|
||||||
return ERROR_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)
|
if (EventFlag & NOTIFICATION_EVENT)
|
||||||
Type = NotificationEvent;
|
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;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +71,10 @@ VideoPortDeleteEvent(
|
||||||
IN PVOID HwDeviceExtension,
|
IN PVOID HwDeviceExtension,
|
||||||
IN PEVENT Event)
|
IN PEVENT Event)
|
||||||
{
|
{
|
||||||
|
/* Free storage */
|
||||||
ExFreePool(Event);
|
ExFreePool(Event);
|
||||||
|
|
||||||
|
/* Indicate success */
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +87,7 @@ VideoPortSetEvent(
|
||||||
IN PVOID HwDeviceExtension,
|
IN PVOID HwDeviceExtension,
|
||||||
IN PEVENT Event)
|
IN PEVENT Event)
|
||||||
{
|
{
|
||||||
return KeSetEvent((PKEVENT)Event, IO_NO_INCREMENT, FALSE);
|
return KeSetEvent(Event->pKEvent, IO_NO_INCREMENT, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,7 +99,7 @@ VideoPortClearEvent(
|
||||||
IN PVOID HwDeviceExtension,
|
IN PVOID HwDeviceExtension,
|
||||||
IN PEVENT Event)
|
IN PEVENT Event)
|
||||||
{
|
{
|
||||||
KeClearEvent((PKEVENT)Event);
|
KeClearEvent(Event->pKEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -104,6 +104,15 @@ typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
|
||||||
VIDEO_PORT_DEVICE_EXTENSION, \
|
VIDEO_PORT_DEVICE_EXTENSION, \
|
||||||
MiniPortDeviceExtension)
|
MiniPortDeviceExtension)
|
||||||
|
|
||||||
|
typedef struct _VIDEO_PORT_EVENT
|
||||||
|
{
|
||||||
|
/* Public part */
|
||||||
|
ENG_EVENT;
|
||||||
|
|
||||||
|
/* Private part */
|
||||||
|
KEVENT Event;
|
||||||
|
} VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT;
|
||||||
|
|
||||||
/* agp.c */
|
/* agp.c */
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<include base="videoprt">.</include>
|
<include base="videoprt">.</include>
|
||||||
<include base="ntoskrnl">include</include>
|
<include base="ntoskrnl">include</include>
|
||||||
<define name="_VIDEOPORT_" />
|
<define name="_VIDEOPORT_" />
|
||||||
|
<compilerflag compilerset="gcc">-fms-extensions</compilerflag>
|
||||||
<library>ntoskrnl</library>
|
<library>ntoskrnl</library>
|
||||||
<library>hal</library>
|
<library>hal</library>
|
||||||
<pch>videoprt.h</pch>
|
<pch>videoprt.h</pch>
|
||||||
|
|
159
reactos/subsystems/win32/win32k/eng/engevent.c
Normal file
159
reactos/subsystems/win32/win32k/eng/engevent.c
Normal file
|
@ -0,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@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;
|
||||||
|
}
|
|
@ -1,105 +0,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;
|
|
||||||
}
|
|
16
reactos/subsystems/win32/win32k/include/engevent.h
Normal file
16
reactos/subsystems/win32/win32k/include/engevent.h
Normal file
|
@ -0,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
|
|
@ -76,6 +76,7 @@
|
||||||
#include <include/misc.h>
|
#include <include/misc.h>
|
||||||
#include <include/gdifloat.h>
|
#include <include/gdifloat.h>
|
||||||
#include <include/engobjects.h>
|
#include <include/engobjects.h>
|
||||||
|
#include <include/engevent.h>
|
||||||
#include <dib/dib.h>
|
#include <dib/dib.h>
|
||||||
|
|
||||||
#endif /* __WIN32K_H */
|
#endif /* __WIN32K_H */
|
||||||
|
|
|
@ -796,18 +796,6 @@ BRUSHOBJ_hGetColorTransform(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
VOID
|
|
||||||
APIENTRY
|
|
||||||
EngClearEvent(
|
|
||||||
IN PEVENT Event)
|
|
||||||
{
|
|
||||||
/* Forward to the kernel */
|
|
||||||
KeClearEvent((PKEVENT)Event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
@ -925,17 +913,6 @@ EngQueryFileTimeStamp(IN LPWSTR FileName)
|
||||||
return FileTime;
|
return FileTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
LONG APIENTRY
|
|
||||||
EngReadStateEvent(
|
|
||||||
IN PEVENT Event)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,13 +48,13 @@
|
||||||
<file>alphablend.c</file>
|
<file>alphablend.c</file>
|
||||||
<file>bitblt.c</file>
|
<file>bitblt.c</file>
|
||||||
<file>engbrush.c</file>
|
<file>engbrush.c</file>
|
||||||
|
<file>engevent.c</file>
|
||||||
<file>clip.c</file>
|
<file>clip.c</file>
|
||||||
<file>copybits.c</file>
|
<file>copybits.c</file>
|
||||||
<file>debug.c</file>
|
<file>debug.c</file>
|
||||||
<file>device.c</file>
|
<file>device.c</file>
|
||||||
<file>driverobj.c</file>
|
<file>driverobj.c</file>
|
||||||
<file>error.c</file>
|
<file>error.c</file>
|
||||||
<file>event.c</file>
|
|
||||||
<file>float.c</file>
|
<file>float.c</file>
|
||||||
<if property="ARCH" value="i386">
|
<if property="ARCH" value="i386">
|
||||||
<directory name="i386">
|
<directory name="i386">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue