2004-01-19 15:56:53 +00:00
|
|
|
/*
|
|
|
|
* VideoPort driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002, 2003, 2004 ReactOS Team
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-10-27 10:34:16 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2004-01-19 15:56:53 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
2009-10-27 10:34:16 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2004-01-19 15:56:53 +00:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2009-10-27 10:34:16 +00:00
|
|
|
* Lesser General Public License for more details.
|
2004-01-19 15:56:53 +00:00
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-19 15:56:53 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VIDEOPRT_H
|
|
|
|
#define VIDEOPRT_H
|
|
|
|
|
2011-08-17 14:04:33 +00:00
|
|
|
#include <ntifs.h>
|
|
|
|
|
2010-03-03 07:09:09 +00:00
|
|
|
#define __BROKEN__
|
2005-12-01 21:37:19 +00:00
|
|
|
#include <miniport.h>
|
|
|
|
#include <video.h>
|
|
|
|
#include <ntagp.h>
|
2008-11-27 20:05:12 +00:00
|
|
|
#include <dderror.h>
|
|
|
|
#include <windef.h>
|
2011-07-28 16:13:00 +00:00
|
|
|
#include <wdmguid.h>
|
|
|
|
|
[WIN32K][VIDEOPRT] Improve initialization and interfacing with INBV.
CORE-12149
VIDEOPRT:
=========
Improve interfacing with INBV, so as to detect when an external module
acquired INBV display ownership, and whether ownership is being released
later on. (This does NOT rely on hooking!)
For this purpose we improve the IntVideoPortResetDisplayParameters(Ex)
callback that gets registered with an InbvNotifyDisplayOwnershipLost()
call during initialization, and we add a monitoring thread.
The callback is called whenever an external module calls
InbvAcquireDisplayOwnership(), for example the bugcheck code or the KDBG
debugger in SCREEN mode. When this happens, a flag that tells the
monitoring thread to start monitoring INBV is set (ReactOS-specific),
and the display adapters get reset with HwResetHw() (as done on Windows).
Due to the fact that this INBV callback can be called at *ANY* IRQL, we
cannot use dispatcher synchronization mechanisms such as events to tell
the INBV monitoring thread to start its operations, so we need to rely
instead on a flag to be set. And, since INBV doesn't provide with any
proper callback/notification system either, we need to actively monitor
its state by pooling. To reduce the load on the system the monitoring
thread performs 1-second waits between each check for the flag set by
the INBV callback, and during checking the INBV ownership status.
When the INBV ownership is detected to be released by an external module,
the INBV callback is re-registered (this is *MANDATORY* since the
external module has called InbvNotifyDisplayOwnershipLost() with a
different callback parameter!), and then we callout to Win32k for
re-enabling the display.
This has the virtue of correctly resetting the display once the KDBG
debugger in SCREEN mode is being exited, and fixes CORE-12149 .
The following additional fixes were needed:
VIDEOPRT & WIN32K:
==================
Remove the registration with INBV that was previously done in a ReactOS-
specific hacked IRP_MJ_WRITE call; it is now done correctly during the
video device opening done by EngpRegisterGraphicsDevice() in the VIDEOPRT's
IRP_MJ_CREATE handler, as done on Windows.
WIN32K:
=======
- Stub the VideoPortCallout() support, for VIDEOPRT -> WIN32 callbacks.
This function gets registered with VIDEOPRT through an
IOCTL_VIDEO_INIT_WIN32K_CALLBACKS call in EngpRegisterGraphicsDevice().
- Only partially implement the 'VideoFindAdapterCallout' case, that just
re-enables the primary display by refreshing it (using the new function
UserRefreshDisplay()).
VIDEOPRT:
=========
- PVIDEO_WIN32K_CALLOUT is an NTAPI (stdcall) callback.
- In the IntVideoPortResetDisplayParameters(Ex) callback, reset all the
"resettable" adapters registered in the HwResetAdaptersList list.
We thus get rid of the global ResetDisplayParametersDeviceExtension.
- Make the IntVideoPortResetDisplayParameters(Ex) callback slightly more
robust (using SEH) against potential HwResetListEntry list corruption
or invalid DriverExtension->InitializationData.HwResetHw() that would
otherwise trigger a BSOD, and this would be disastrous since that
callback is precisely called when INBV is acquired, typically when the
BSOD code initializes the display for displaying its information...
Extras:
- Validate the IrpStack->MajorFunction in IntVideoPortDispatchDeviceControl()
and implement IRP_MJ_SHUTDOWN handling. Stub out the other IOCTLs that
are handled by VIDEOPRT only (and not by the miniports).
- VIDEOPRT doesn't require IRP_MJ_INTERNAL_DEVICE_CONTROL (unused).
- Implement IOCTL_VIDEO_PREPARE_FOR_EARECOVERY that just resets the
display to standard VGA 80x25 text mode.
2019-11-26 01:49:35 +00:00
|
|
|
/* PSEH for SEH Support */
|
|
|
|
#include <pseh/pseh2.h>
|
2004-01-19 15:56:53 +00:00
|
|
|
|
[WIN32K][VIDEOPRT] Improve initialization and interfacing with INBV.
CORE-12149
VIDEOPRT:
=========
Improve interfacing with INBV, so as to detect when an external module
acquired INBV display ownership, and whether ownership is being released
later on. (This does NOT rely on hooking!)
For this purpose we improve the IntVideoPortResetDisplayParameters(Ex)
callback that gets registered with an InbvNotifyDisplayOwnershipLost()
call during initialization, and we add a monitoring thread.
The callback is called whenever an external module calls
InbvAcquireDisplayOwnership(), for example the bugcheck code or the KDBG
debugger in SCREEN mode. When this happens, a flag that tells the
monitoring thread to start monitoring INBV is set (ReactOS-specific),
and the display adapters get reset with HwResetHw() (as done on Windows).
Due to the fact that this INBV callback can be called at *ANY* IRQL, we
cannot use dispatcher synchronization mechanisms such as events to tell
the INBV monitoring thread to start its operations, so we need to rely
instead on a flag to be set. And, since INBV doesn't provide with any
proper callback/notification system either, we need to actively monitor
its state by pooling. To reduce the load on the system the monitoring
thread performs 1-second waits between each check for the flag set by
the INBV callback, and during checking the INBV ownership status.
When the INBV ownership is detected to be released by an external module,
the INBV callback is re-registered (this is *MANDATORY* since the
external module has called InbvNotifyDisplayOwnershipLost() with a
different callback parameter!), and then we callout to Win32k for
re-enabling the display.
This has the virtue of correctly resetting the display once the KDBG
debugger in SCREEN mode is being exited, and fixes CORE-12149 .
The following additional fixes were needed:
VIDEOPRT & WIN32K:
==================
Remove the registration with INBV that was previously done in a ReactOS-
specific hacked IRP_MJ_WRITE call; it is now done correctly during the
video device opening done by EngpRegisterGraphicsDevice() in the VIDEOPRT's
IRP_MJ_CREATE handler, as done on Windows.
WIN32K:
=======
- Stub the VideoPortCallout() support, for VIDEOPRT -> WIN32 callbacks.
This function gets registered with VIDEOPRT through an
IOCTL_VIDEO_INIT_WIN32K_CALLBACKS call in EngpRegisterGraphicsDevice().
- Only partially implement the 'VideoFindAdapterCallout' case, that just
re-enables the primary display by refreshing it (using the new function
UserRefreshDisplay()).
VIDEOPRT:
=========
- PVIDEO_WIN32K_CALLOUT is an NTAPI (stdcall) callback.
- In the IntVideoPortResetDisplayParameters(Ex) callback, reset all the
"resettable" adapters registered in the HwResetAdaptersList list.
We thus get rid of the global ResetDisplayParametersDeviceExtension.
- Make the IntVideoPortResetDisplayParameters(Ex) callback slightly more
robust (using SEH) against potential HwResetListEntry list corruption
or invalid DriverExtension->InitializationData.HwResetHw() that would
otherwise trigger a BSOD, and this would be disastrous since that
callback is precisely called when INBV is acquired, typically when the
BSOD code initializes the display for displaying its information...
Extras:
- Validate the IrpStack->MajorFunction in IntVideoPortDispatchDeviceControl()
and implement IRP_MJ_SHUTDOWN handling. Stub out the other IOCTLs that
are handled by VIDEOPRT only (and not by the miniports).
- VIDEOPRT doesn't require IRP_MJ_INTERNAL_DEVICE_CONTROL (unused).
- Implement IOCTL_VIDEO_PREPARE_FOR_EARECOVERY that just resets the
display to standard VGA 80x25 text mode.
2019-11-26 01:49:35 +00:00
|
|
|
#define TAG_VIDEO_PORT 'PDIV'
|
|
|
|
#define TAG_VIDEO_PORT_BUFFER '\0mpV'
|
|
|
|
#define TAG_REQUEST_PACKET 'qRpV'
|
|
|
|
|
|
|
|
#define GUID_STRING_LENGTH (38 * sizeof(WCHAR))
|
2013-11-16 18:40:24 +00:00
|
|
|
|
2004-01-19 15:56:53 +00:00
|
|
|
typedef struct _VIDEO_PORT_ADDRESS_MAPPING
|
|
|
|
{
|
|
|
|
LIST_ENTRY List;
|
|
|
|
PVOID MappedAddress;
|
|
|
|
ULONG NumberOfUchars;
|
|
|
|
PHYSICAL_ADDRESS IoAddress;
|
|
|
|
ULONG SystemIoBusNumber;
|
|
|
|
UINT MappingCount;
|
|
|
|
} VIDEO_PORT_ADDRESS_MAPPING, *PVIDEO_PORT_ADDRESS_MAPPING;
|
|
|
|
|
2005-01-07 01:03:34 +00:00
|
|
|
struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING;
|
|
|
|
|
|
|
|
typedef struct _VIDEO_PORT_AGP_MAPPING
|
|
|
|
{
|
|
|
|
ULONG NumberOfPages;
|
|
|
|
PVOID MapHandle;
|
|
|
|
PHYSICAL_ADDRESS PhysicalAddress;
|
|
|
|
} VIDEO_PORT_AGP_MAPPING, *PVIDEO_PORT_AGP_MAPPING;
|
|
|
|
|
|
|
|
typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING
|
|
|
|
{
|
|
|
|
PVIDEO_PORT_AGP_MAPPING AgpMapping;
|
|
|
|
HANDLE ProcessHandle;
|
|
|
|
PVOID MappedAddress;
|
|
|
|
} VIDEO_PORT_AGP_VIRTUAL_MAPPING, *PVIDEO_PORT_AGP_VIRTUAL_MAPPING;
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
typedef struct _VIDEO_PORT_DRIVER_EXTENSION
|
|
|
|
{
|
|
|
|
VIDEO_HW_INITIALIZATION_DATA InitializationData;
|
|
|
|
PVOID HwContext;
|
|
|
|
UNICODE_STRING RegistryPath;
|
|
|
|
} VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
|
|
|
|
|
2012-03-12 03:29:36 +00:00
|
|
|
typedef struct _VIDEO_PORT_COMMON_EXTENSION
|
|
|
|
{
|
|
|
|
BOOLEAN Fdo;
|
|
|
|
} VIDEO_PORT_COMMON_EXTENSION, *PVIDEO_PORT_COMMON_EXTENSION;
|
|
|
|
|
2004-01-19 15:56:53 +00:00
|
|
|
typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
|
|
|
|
{
|
2012-03-12 03:29:36 +00:00
|
|
|
VIDEO_PORT_COMMON_EXTENSION Common;
|
2005-01-07 01:03:34 +00:00
|
|
|
ULONG DeviceNumber;
|
2005-06-03 16:56:27 +00:00
|
|
|
PDRIVER_OBJECT DriverObject;
|
2004-03-19 20:58:32 +00:00
|
|
|
PDEVICE_OBJECT PhysicalDeviceObject;
|
|
|
|
PDEVICE_OBJECT FunctionalDeviceObject;
|
2004-12-19 15:51:51 +00:00
|
|
|
PDEVICE_OBJECT NextDeviceObject;
|
2004-03-19 20:58:32 +00:00
|
|
|
UNICODE_STRING RegistryPath;
|
2013-11-16 18:40:24 +00:00
|
|
|
UNICODE_STRING NewRegistryPath;
|
2004-01-19 15:56:53 +00:00
|
|
|
PKINTERRUPT InterruptObject;
|
|
|
|
KSPIN_LOCK InterruptSpinLock;
|
2005-01-07 01:03:34 +00:00
|
|
|
PCM_RESOURCE_LIST AllocatedResources;
|
2004-01-19 15:56:53 +00:00
|
|
|
ULONG InterruptVector;
|
|
|
|
ULONG InterruptLevel;
|
2005-03-23 21:51:40 +00:00
|
|
|
BOOLEAN InterruptShared;
|
2005-06-03 16:56:27 +00:00
|
|
|
INTERFACE_TYPE AdapterInterfaceType;
|
2004-01-19 15:56:53 +00:00
|
|
|
ULONG SystemIoBusNumber;
|
2004-03-19 20:58:32 +00:00
|
|
|
ULONG SystemIoSlotNumber;
|
|
|
|
LIST_ENTRY AddressMappingListHead;
|
2004-03-06 22:25:22 +00:00
|
|
|
KDPC DpcObject;
|
2004-03-19 20:58:32 +00:00
|
|
|
VIDEO_PORT_DRIVER_EXTENSION *DriverExtension;
|
2004-04-08 09:43:55 +00:00
|
|
|
ULONG DeviceOpened;
|
2005-01-07 01:03:34 +00:00
|
|
|
AGP_BUS_INTERFACE_STANDARD AgpInterface;
|
|
|
|
KMUTEX DeviceLock;
|
2012-03-12 03:29:36 +00:00
|
|
|
LIST_ENTRY DmaAdapterList, ChildDeviceList;
|
[WIN32K][VIDEOPRT] Improve initialization and interfacing with INBV.
CORE-12149
VIDEOPRT:
=========
Improve interfacing with INBV, so as to detect when an external module
acquired INBV display ownership, and whether ownership is being released
later on. (This does NOT rely on hooking!)
For this purpose we improve the IntVideoPortResetDisplayParameters(Ex)
callback that gets registered with an InbvNotifyDisplayOwnershipLost()
call during initialization, and we add a monitoring thread.
The callback is called whenever an external module calls
InbvAcquireDisplayOwnership(), for example the bugcheck code or the KDBG
debugger in SCREEN mode. When this happens, a flag that tells the
monitoring thread to start monitoring INBV is set (ReactOS-specific),
and the display adapters get reset with HwResetHw() (as done on Windows).
Due to the fact that this INBV callback can be called at *ANY* IRQL, we
cannot use dispatcher synchronization mechanisms such as events to tell
the INBV monitoring thread to start its operations, so we need to rely
instead on a flag to be set. And, since INBV doesn't provide with any
proper callback/notification system either, we need to actively monitor
its state by pooling. To reduce the load on the system the monitoring
thread performs 1-second waits between each check for the flag set by
the INBV callback, and during checking the INBV ownership status.
When the INBV ownership is detected to be released by an external module,
the INBV callback is re-registered (this is *MANDATORY* since the
external module has called InbvNotifyDisplayOwnershipLost() with a
different callback parameter!), and then we callout to Win32k for
re-enabling the display.
This has the virtue of correctly resetting the display once the KDBG
debugger in SCREEN mode is being exited, and fixes CORE-12149 .
The following additional fixes were needed:
VIDEOPRT & WIN32K:
==================
Remove the registration with INBV that was previously done in a ReactOS-
specific hacked IRP_MJ_WRITE call; it is now done correctly during the
video device opening done by EngpRegisterGraphicsDevice() in the VIDEOPRT's
IRP_MJ_CREATE handler, as done on Windows.
WIN32K:
=======
- Stub the VideoPortCallout() support, for VIDEOPRT -> WIN32 callbacks.
This function gets registered with VIDEOPRT through an
IOCTL_VIDEO_INIT_WIN32K_CALLBACKS call in EngpRegisterGraphicsDevice().
- Only partially implement the 'VideoFindAdapterCallout' case, that just
re-enables the primary display by refreshing it (using the new function
UserRefreshDisplay()).
VIDEOPRT:
=========
- PVIDEO_WIN32K_CALLOUT is an NTAPI (stdcall) callback.
- In the IntVideoPortResetDisplayParameters(Ex) callback, reset all the
"resettable" adapters registered in the HwResetAdaptersList list.
We thus get rid of the global ResetDisplayParametersDeviceExtension.
- Make the IntVideoPortResetDisplayParameters(Ex) callback slightly more
robust (using SEH) against potential HwResetListEntry list corruption
or invalid DriverExtension->InitializationData.HwResetHw() that would
otherwise trigger a BSOD, and this would be disastrous since that
callback is precisely called when INBV is acquired, typically when the
BSOD code initializes the display for displaying its information...
Extras:
- Validate the IrpStack->MajorFunction in IntVideoPortDispatchDeviceControl()
and implement IRP_MJ_SHUTDOWN handling. Stub out the other IOCTLs that
are handled by VIDEOPRT only (and not by the miniports).
- VIDEOPRT doesn't require IRP_MJ_INTERNAL_DEVICE_CONTROL (unused).
- Implement IOCTL_VIDEO_PREPARE_FOR_EARECOVERY that just resets the
display to standard VGA 80x25 text mode.
2019-11-26 01:49:35 +00:00
|
|
|
LIST_ENTRY HwResetListEntry;
|
2013-11-22 11:36:22 +00:00
|
|
|
ULONG SessionId;
|
2021-07-03 20:59:30 +00:00
|
|
|
USHORT AdapterNumber;
|
|
|
|
USHORT DisplayNumber;
|
|
|
|
ULONG NumberOfSecondaryDisplays;
|
|
|
|
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1];
|
2004-01-19 15:56:53 +00:00
|
|
|
} VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
|
|
|
|
|
2012-03-12 03:29:36 +00:00
|
|
|
typedef struct _VIDEO_PORT_CHILD_EXTENSION
|
|
|
|
{
|
|
|
|
VIDEO_PORT_COMMON_EXTENSION Common;
|
|
|
|
|
|
|
|
ULONG ChildId;
|
|
|
|
VIDEO_CHILD_TYPE ChildType;
|
|
|
|
UCHAR ChildDescriptor[256];
|
|
|
|
|
|
|
|
BOOLEAN EdidValid;
|
|
|
|
|
|
|
|
PDRIVER_OBJECT DriverObject;
|
|
|
|
PDEVICE_OBJECT PhysicalDeviceObject;
|
|
|
|
|
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
|
|
|
|
CHAR ChildDeviceExtension[1];
|
|
|
|
} VIDEO_PORT_CHILD_EXTENSION, *PVIDEO_PORT_CHILD_EXTENSION;
|
|
|
|
|
|
|
|
#define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension) \
|
|
|
|
CONTAINING_RECORD( \
|
|
|
|
MiniportExtension, \
|
|
|
|
VIDEO_PORT_CHILD_EXTENSION, \
|
|
|
|
ChildDeviceExtension)
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \
|
|
|
|
CONTAINING_RECORD( \
|
2012-03-12 03:29:36 +00:00
|
|
|
MiniportExtension, \
|
2004-03-19 20:58:32 +00:00
|
|
|
VIDEO_PORT_DEVICE_EXTENSION, \
|
|
|
|
MiniPortDeviceExtension)
|
|
|
|
|
2009-06-30 13:42:42 +00:00
|
|
|
typedef struct _VIDEO_PORT_EVENT
|
|
|
|
{
|
|
|
|
ENG_EVENT;
|
|
|
|
} VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT;
|
|
|
|
|
2005-01-07 01:03:34 +00:00
|
|
|
/* agp.c */
|
|
|
|
|
2005-12-31 16:01:02 +00:00
|
|
|
NTSTATUS
|
|
|
|
IopInitiatePnpIrp(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIO_STATUS_BLOCK IoStatusBlock,
|
2011-06-25 14:10:19 +00:00
|
|
|
UCHAR MinorFunction,
|
2005-12-31 16:01:02 +00:00
|
|
|
PIO_STACK_LOCATION Stack OPTIONAL);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2005-01-07 01:03:34 +00:00
|
|
|
IntAgpGetInterface(
|
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN OUT PINTERFACE Interface);
|
|
|
|
|
2012-03-12 03:29:36 +00:00
|
|
|
/* child.c */
|
|
|
|
|
|
|
|
NTSTATUS NTAPI
|
|
|
|
IntVideoPortDispatchPdoPnp(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/* dispatch.c */
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortAddDevice(
|
|
|
|
IN PDRIVER_OBJECT DriverObject,
|
|
|
|
IN PDEVICE_OBJECT PhysicalDeviceObject);
|
2004-01-19 15:56:53 +00:00
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortDispatchOpen(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
2004-01-19 15:56:53 +00:00
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortDispatchClose(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
2004-01-19 15:56:53 +00:00
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortDispatchCleanup(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortDispatchDeviceControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortDispatchPnp(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortDispatchPower(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
2004-01-19 15:56:53 +00:00
|
|
|
|
2007-12-20 12:31:39 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
IntVideoPortDispatchSystemControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
VOID NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortUnload(PDRIVER_OBJECT DriverObject);
|
|
|
|
|
|
|
|
/* timer.c */
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
BOOLEAN NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortSetupTimer(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension);
|
|
|
|
|
|
|
|
/* interrupt.c */
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
BOOLEAN NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortSetupInterrupt(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
|
|
|
|
IN PVIDEO_PORT_CONFIG_INFO ConfigInfo);
|
|
|
|
|
2005-01-07 01:03:34 +00:00
|
|
|
/* resource.c */
|
|
|
|
|
2011-10-23 02:45:09 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
IntVideoPortFilterResourceRequirements(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
2021-10-07 19:36:24 +00:00
|
|
|
IN PIO_STACK_LOCATION IrpStack,
|
2011-10-23 02:45:09 +00:00
|
|
|
IN PIRP Irp);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2005-01-07 01:03:34 +00:00
|
|
|
IntVideoPortMapPhysicalMemory(
|
|
|
|
IN HANDLE Process,
|
|
|
|
IN PHYSICAL_ADDRESS PhysicalAddress,
|
|
|
|
IN ULONG SizeInBytes,
|
|
|
|
IN ULONG Protect,
|
|
|
|
IN OUT PVOID *VirtualAddress OPTIONAL);
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/* videoprt.c */
|
|
|
|
|
[WIN32K][VIDEOPRT] Improve initialization and interfacing with INBV.
CORE-12149
VIDEOPRT:
=========
Improve interfacing with INBV, so as to detect when an external module
acquired INBV display ownership, and whether ownership is being released
later on. (This does NOT rely on hooking!)
For this purpose we improve the IntVideoPortResetDisplayParameters(Ex)
callback that gets registered with an InbvNotifyDisplayOwnershipLost()
call during initialization, and we add a monitoring thread.
The callback is called whenever an external module calls
InbvAcquireDisplayOwnership(), for example the bugcheck code or the KDBG
debugger in SCREEN mode. When this happens, a flag that tells the
monitoring thread to start monitoring INBV is set (ReactOS-specific),
and the display adapters get reset with HwResetHw() (as done on Windows).
Due to the fact that this INBV callback can be called at *ANY* IRQL, we
cannot use dispatcher synchronization mechanisms such as events to tell
the INBV monitoring thread to start its operations, so we need to rely
instead on a flag to be set. And, since INBV doesn't provide with any
proper callback/notification system either, we need to actively monitor
its state by pooling. To reduce the load on the system the monitoring
thread performs 1-second waits between each check for the flag set by
the INBV callback, and during checking the INBV ownership status.
When the INBV ownership is detected to be released by an external module,
the INBV callback is re-registered (this is *MANDATORY* since the
external module has called InbvNotifyDisplayOwnershipLost() with a
different callback parameter!), and then we callout to Win32k for
re-enabling the display.
This has the virtue of correctly resetting the display once the KDBG
debugger in SCREEN mode is being exited, and fixes CORE-12149 .
The following additional fixes were needed:
VIDEOPRT & WIN32K:
==================
Remove the registration with INBV that was previously done in a ReactOS-
specific hacked IRP_MJ_WRITE call; it is now done correctly during the
video device opening done by EngpRegisterGraphicsDevice() in the VIDEOPRT's
IRP_MJ_CREATE handler, as done on Windows.
WIN32K:
=======
- Stub the VideoPortCallout() support, for VIDEOPRT -> WIN32 callbacks.
This function gets registered with VIDEOPRT through an
IOCTL_VIDEO_INIT_WIN32K_CALLBACKS call in EngpRegisterGraphicsDevice().
- Only partially implement the 'VideoFindAdapterCallout' case, that just
re-enables the primary display by refreshing it (using the new function
UserRefreshDisplay()).
VIDEOPRT:
=========
- PVIDEO_WIN32K_CALLOUT is an NTAPI (stdcall) callback.
- In the IntVideoPortResetDisplayParameters(Ex) callback, reset all the
"resettable" adapters registered in the HwResetAdaptersList list.
We thus get rid of the global ResetDisplayParametersDeviceExtension.
- Make the IntVideoPortResetDisplayParameters(Ex) callback slightly more
robust (using SEH) against potential HwResetListEntry list corruption
or invalid DriverExtension->InitializationData.HwResetHw() that would
otherwise trigger a BSOD, and this would be disastrous since that
callback is precisely called when INBV is acquired, typically when the
BSOD code initializes the display for displaying its information...
Extras:
- Validate the IrpStack->MajorFunction in IntVideoPortDispatchDeviceControl()
and implement IRP_MJ_SHUTDOWN handling. Stub out the other IOCTLs that
are handled by VIDEOPRT only (and not by the miniports).
- VIDEOPRT doesn't require IRP_MJ_INTERNAL_DEVICE_CONTROL (unused).
- Implement IOCTL_VIDEO_PREPARE_FOR_EARECOVERY that just resets the
display to standard VGA 80x25 text mode.
2019-11-26 01:49:35 +00:00
|
|
|
extern PKPROCESS CsrProcess;
|
2008-05-07 21:51:39 +00:00
|
|
|
extern ULONG VideoPortDeviceNumber;
|
2017-05-18 21:29:24 +00:00
|
|
|
extern KMUTEX VideoPortInt10Mutex;
|
2019-12-03 01:08:34 +00:00
|
|
|
extern KSPIN_LOCK HwResetAdaptersLock;
|
[WIN32K][VIDEOPRT] Improve initialization and interfacing with INBV.
CORE-12149
VIDEOPRT:
=========
Improve interfacing with INBV, so as to detect when an external module
acquired INBV display ownership, and whether ownership is being released
later on. (This does NOT rely on hooking!)
For this purpose we improve the IntVideoPortResetDisplayParameters(Ex)
callback that gets registered with an InbvNotifyDisplayOwnershipLost()
call during initialization, and we add a monitoring thread.
The callback is called whenever an external module calls
InbvAcquireDisplayOwnership(), for example the bugcheck code or the KDBG
debugger in SCREEN mode. When this happens, a flag that tells the
monitoring thread to start monitoring INBV is set (ReactOS-specific),
and the display adapters get reset with HwResetHw() (as done on Windows).
Due to the fact that this INBV callback can be called at *ANY* IRQL, we
cannot use dispatcher synchronization mechanisms such as events to tell
the INBV monitoring thread to start its operations, so we need to rely
instead on a flag to be set. And, since INBV doesn't provide with any
proper callback/notification system either, we need to actively monitor
its state by pooling. To reduce the load on the system the monitoring
thread performs 1-second waits between each check for the flag set by
the INBV callback, and during checking the INBV ownership status.
When the INBV ownership is detected to be released by an external module,
the INBV callback is re-registered (this is *MANDATORY* since the
external module has called InbvNotifyDisplayOwnershipLost() with a
different callback parameter!), and then we callout to Win32k for
re-enabling the display.
This has the virtue of correctly resetting the display once the KDBG
debugger in SCREEN mode is being exited, and fixes CORE-12149 .
The following additional fixes were needed:
VIDEOPRT & WIN32K:
==================
Remove the registration with INBV that was previously done in a ReactOS-
specific hacked IRP_MJ_WRITE call; it is now done correctly during the
video device opening done by EngpRegisterGraphicsDevice() in the VIDEOPRT's
IRP_MJ_CREATE handler, as done on Windows.
WIN32K:
=======
- Stub the VideoPortCallout() support, for VIDEOPRT -> WIN32 callbacks.
This function gets registered with VIDEOPRT through an
IOCTL_VIDEO_INIT_WIN32K_CALLBACKS call in EngpRegisterGraphicsDevice().
- Only partially implement the 'VideoFindAdapterCallout' case, that just
re-enables the primary display by refreshing it (using the new function
UserRefreshDisplay()).
VIDEOPRT:
=========
- PVIDEO_WIN32K_CALLOUT is an NTAPI (stdcall) callback.
- In the IntVideoPortResetDisplayParameters(Ex) callback, reset all the
"resettable" adapters registered in the HwResetAdaptersList list.
We thus get rid of the global ResetDisplayParametersDeviceExtension.
- Make the IntVideoPortResetDisplayParameters(Ex) callback slightly more
robust (using SEH) against potential HwResetListEntry list corruption
or invalid DriverExtension->InitializationData.HwResetHw() that would
otherwise trigger a BSOD, and this would be disastrous since that
callback is precisely called when INBV is acquired, typically when the
BSOD code initializes the display for displaying its information...
Extras:
- Validate the IrpStack->MajorFunction in IntVideoPortDispatchDeviceControl()
and implement IRP_MJ_SHUTDOWN handling. Stub out the other IOCTLs that
are handled by VIDEOPRT only (and not by the miniports).
- VIDEOPRT doesn't require IRP_MJ_INTERNAL_DEVICE_CONTROL (unused).
- Implement IOCTL_VIDEO_PREPARE_FOR_EARECOVERY that just resets the
display to standard VGA 80x25 text mode.
2019-11-26 01:49:35 +00:00
|
|
|
extern LIST_ENTRY HwResetAdaptersList;
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2005-05-08 02:16:32 +00:00
|
|
|
VOID FASTCALL
|
2005-06-14 20:24:02 +00:00
|
|
|
IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2005-05-08 02:16:32 +00:00
|
|
|
VOID FASTCALL
|
2005-06-14 20:24:02 +00:00
|
|
|
IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2005-01-07 01:03:34 +00:00
|
|
|
IntVideoPortCreateAdapterDeviceObject(
|
2020-06-08 20:45:45 +00:00
|
|
|
_In_ PDRIVER_OBJECT DriverObject,
|
|
|
|
_In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
|
|
|
|
_In_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
|
2021-07-03 20:59:30 +00:00
|
|
|
_In_ USHORT AdapterNumber,
|
|
|
|
_In_ USHORT DisplayNumber,
|
2020-06-08 20:45:45 +00:00
|
|
|
_Out_opt_ PDEVICE_OBJECT *DeviceObject);
|
2005-01-07 01:03:34 +00:00
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
NTSTATUS NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortFindAdapter(
|
|
|
|
IN PDRIVER_OBJECT DriverObject,
|
|
|
|
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
|
2005-01-07 01:03:34 +00:00
|
|
|
IN PDEVICE_OBJECT DeviceObject);
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2007-10-01 08:14:24 +00:00
|
|
|
PVOID NTAPI
|
|
|
|
IntVideoPortGetProcAddress(
|
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PUCHAR FunctionName);
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/* int10.c */
|
2004-01-19 15:56:53 +00:00
|
|
|
|
2013-11-16 18:40:24 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IntInitializeVideoAddressSpace(VOID);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
VP_STATUS NTAPI
|
2004-01-19 15:56:53 +00:00
|
|
|
IntInt10AllocateBuffer(
|
|
|
|
IN PVOID Context,
|
|
|
|
OUT PUSHORT Seg,
|
|
|
|
OUT PUSHORT Off,
|
|
|
|
IN OUT PULONG Length);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
VP_STATUS NTAPI
|
2004-01-19 15:56:53 +00:00
|
|
|
IntInt10FreeBuffer(
|
|
|
|
IN PVOID Context,
|
|
|
|
IN USHORT Seg,
|
|
|
|
IN USHORT Off);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
VP_STATUS NTAPI
|
2004-01-19 15:56:53 +00:00
|
|
|
IntInt10ReadMemory(
|
|
|
|
IN PVOID Context,
|
|
|
|
IN USHORT Seg,
|
|
|
|
IN USHORT Off,
|
|
|
|
OUT PVOID Buffer,
|
|
|
|
IN ULONG Length);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
VP_STATUS NTAPI
|
2004-01-19 15:56:53 +00:00
|
|
|
IntInt10WriteMemory(
|
|
|
|
IN PVOID Context,
|
|
|
|
IN USHORT Seg,
|
|
|
|
IN USHORT Off,
|
|
|
|
IN PVOID Buffer,
|
|
|
|
IN ULONG Length);
|
|
|
|
|
2005-08-24 21:29:24 +00:00
|
|
|
VP_STATUS NTAPI
|
2004-01-19 15:56:53 +00:00
|
|
|
IntInt10CallBios(
|
|
|
|
IN PVOID Context,
|
|
|
|
IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
|
|
|
|
|
2013-11-16 18:40:24 +00:00
|
|
|
/* registry.c */
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IntCopyRegistryKey(
|
|
|
|
_In_ HANDLE SourceKeyHandle,
|
|
|
|
_In_ HANDLE DestKeyHandle);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IntCopyRegistryValue(
|
|
|
|
HANDLE SourceKeyHandle,
|
|
|
|
HANDLE DestKeyHandle,
|
|
|
|
PWSTR ValueName);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IntSetupDeviceSettingsKey(
|
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IntCreateNewRegistryPath(
|
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IntCreateRegistryPath(
|
|
|
|
IN PCUNICODE_STRING DriverRegistryPath,
|
2021-05-29 06:29:30 +00:00
|
|
|
IN ULONG DeviceNumber,
|
2013-11-16 18:40:24 +00:00
|
|
|
OUT PUNICODE_STRING DeviceRegistryPath);
|
|
|
|
|
|
|
|
|
2004-01-19 15:56:53 +00:00
|
|
|
#endif /* VIDEOPRT_H */
|