mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[VIDEOPRT] Refactor device map key creation
This commit is contained in:
parent
c3da00c42c
commit
066337dc84
2 changed files with 77 additions and 43 deletions
|
@ -347,9 +347,10 @@ IntVideoPortAddDevice(
|
||||||
DriverExtension,
|
DriverExtension,
|
||||||
PhysicalDeviceObject,
|
PhysicalDeviceObject,
|
||||||
&DeviceObject);
|
&DeviceObject);
|
||||||
if (NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
VideoPortDeviceNumber++;
|
{
|
||||||
|
ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject() failed with status 0x%lx\n", Status);
|
||||||
|
}
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ BOOLEAN VpBaseVideo = FALSE;
|
||||||
BOOLEAN VpNoVesa = FALSE;
|
BOOLEAN VpNoVesa = FALSE;
|
||||||
|
|
||||||
PKPROCESS CsrProcess = NULL;
|
PKPROCESS CsrProcess = NULL;
|
||||||
ULONG VideoPortDeviceNumber = 0;
|
static ULONG VideoPortMaxObjectNumber = -1;
|
||||||
KMUTEX VideoPortInt10Mutex;
|
KMUTEX VideoPortInt10Mutex;
|
||||||
KSPIN_LOCK HwResetAdaptersLock;
|
KSPIN_LOCK HwResetAdaptersLock;
|
||||||
RTL_STATIC_LIST_HEAD(HwResetAdaptersList);
|
RTL_STATIC_LIST_HEAD(HwResetAdaptersList);
|
||||||
|
@ -53,6 +53,64 @@ DriverEntry(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
NTSTATUS
|
||||||
|
IntVideoPortAddDeviceMapLink(
|
||||||
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
|
||||||
|
{
|
||||||
|
WCHAR DeviceBuffer[20];
|
||||||
|
UNICODE_STRING DeviceName;
|
||||||
|
WCHAR SymlinkBuffer[20];
|
||||||
|
UNICODE_STRING SymlinkName;
|
||||||
|
ULONG DeviceNumber;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Create a unicode device name. */
|
||||||
|
DeviceNumber = DeviceExtension->DeviceNumber;
|
||||||
|
swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
|
||||||
|
|
||||||
|
/* Add entry to DEVICEMAP\VIDEO key in registry. */
|
||||||
|
Status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP,
|
||||||
|
L"VIDEO",
|
||||||
|
DeviceBuffer,
|
||||||
|
REG_SZ,
|
||||||
|
DeviceExtension->RegistryPath.Buffer,
|
||||||
|
DeviceExtension->RegistryPath.Length + sizeof(UNICODE_NULL));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR_(VIDEOPRT, "Failed to create DEViCEMAP registry entry: 0x%X\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP,
|
||||||
|
L"VIDEO",
|
||||||
|
L"MaxObjectNumber",
|
||||||
|
REG_DWORD,
|
||||||
|
&VideoPortMaxObjectNumber,
|
||||||
|
sizeof(VideoPortMaxObjectNumber));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR_(VIDEOPRT, "Failed to write MaxObjectNumber: 0x%X\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create symbolic link "\??\DISPLAYx" */
|
||||||
|
swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
|
||||||
|
RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
|
||||||
|
RtlInitUnicodeString(&DeviceName, DeviceBuffer);
|
||||||
|
Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR_(VIDEOPRT, "Failed to write MaxObjectNumber: 0x%X\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update MaxObjectNumber */
|
||||||
|
VideoPortMaxObjectNumber = DeviceNumber;
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
NTAPI
|
NTAPI
|
||||||
IntVideoPortImageDirectoryEntryToData(
|
IntVideoPortImageDirectoryEntryToData(
|
||||||
|
@ -114,8 +172,8 @@ IntVideoPortCreateAdapterDeviceObject(
|
||||||
* Find the first free device number that can be used for video device
|
* Find the first free device number that can be used for video device
|
||||||
* object names and symlinks.
|
* object names and symlinks.
|
||||||
*/
|
*/
|
||||||
DeviceNumber = VideoPortDeviceNumber;
|
DeviceNumber = VideoPortMaxObjectNumber + 1;
|
||||||
if (DeviceNumber == 0xFFFFFFFF)
|
if (DeviceNumber == (ULONG)-1)
|
||||||
{
|
{
|
||||||
WARN_(VIDEOPRT, "Can't find free device number\n");
|
WARN_(VIDEOPRT, "Can't find free device number\n");
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
@ -247,6 +305,17 @@ IntVideoPortCreateAdapterDeviceObject(
|
||||||
|
|
||||||
/* Remove the initailizing flag */
|
/* Remove the initailizing flag */
|
||||||
(*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
|
(*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
|
|
||||||
|
/* Set up the VIDEO/DEVICEMAP registry keys */
|
||||||
|
Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
|
||||||
|
IoDeleteDevice(*DeviceObject);
|
||||||
|
*DeviceObject = NULL;
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,21 +327,14 @@ IntVideoPortFindAdapter(
|
||||||
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
|
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
|
||||||
IN PDEVICE_OBJECT DeviceObject)
|
IN PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
WCHAR DeviceVideoBuffer[20];
|
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
VIDEO_PORT_CONFIG_INFO ConfigInfo;
|
VIDEO_PORT_CONFIG_INFO ConfigInfo;
|
||||||
SYSTEM_BASIC_INFORMATION SystemBasicInfo;
|
SYSTEM_BASIC_INFORMATION SystemBasicInfo;
|
||||||
UCHAR Again = FALSE;
|
UCHAR Again = FALSE;
|
||||||
WCHAR DeviceBuffer[20];
|
|
||||||
UNICODE_STRING DeviceName;
|
|
||||||
WCHAR SymlinkBuffer[20];
|
|
||||||
UNICODE_STRING SymlinkName;
|
|
||||||
BOOL LegacyDetection = FALSE;
|
BOOL LegacyDetection = FALSE;
|
||||||
ULONG DeviceNumber;
|
|
||||||
|
|
||||||
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
DeviceNumber = DeviceExtension->DeviceNumber;
|
|
||||||
|
|
||||||
/* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
|
/* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
|
||||||
RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
|
RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
|
||||||
|
@ -371,33 +433,6 @@ IntVideoPortFindAdapter(
|
||||||
* such as creating symlinks or setting up interrupts and timer.
|
* such as creating symlinks or setting up interrupts and timer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Create a unicode device name. */
|
|
||||||
swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
|
|
||||||
RtlInitUnicodeString(&DeviceName, DeviceBuffer);
|
|
||||||
|
|
||||||
/* Create symbolic link "\??\DISPLAYx" */
|
|
||||||
swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
|
|
||||||
RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
|
|
||||||
IoCreateSymbolicLink(&SymlinkName, &DeviceName);
|
|
||||||
|
|
||||||
/* Add entry to DEVICEMAP\VIDEO key in registry. */
|
|
||||||
swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber);
|
|
||||||
RtlWriteRegistryValue(
|
|
||||||
RTL_REGISTRY_DEVICEMAP,
|
|
||||||
L"VIDEO",
|
|
||||||
DeviceVideoBuffer,
|
|
||||||
REG_SZ,
|
|
||||||
DeviceExtension->RegistryPath.Buffer,
|
|
||||||
DeviceExtension->RegistryPath.Length + sizeof(UNICODE_NULL));
|
|
||||||
|
|
||||||
RtlWriteRegistryValue(
|
|
||||||
RTL_REGISTRY_DEVICEMAP,
|
|
||||||
L"VIDEO",
|
|
||||||
L"MaxObjectNumber",
|
|
||||||
REG_DWORD,
|
|
||||||
&DeviceNumber,
|
|
||||||
sizeof(DeviceNumber));
|
|
||||||
|
|
||||||
/* FIXME: Allocate hardware resources for device. */
|
/* FIXME: Allocate hardware resources for device. */
|
||||||
|
|
||||||
/* Allocate interrupt for device. */
|
/* Allocate interrupt for device. */
|
||||||
|
@ -771,9 +806,7 @@ VideoPortInitialize(
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IntVideoPortFindAdapter(DriverObject, DriverExtension, DeviceObject);
|
Status = IntVideoPortFindAdapter(DriverObject, DriverExtension, DeviceObject);
|
||||||
if (NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
VideoPortDeviceNumber++;
|
|
||||||
else
|
|
||||||
ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status);
|
ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
|
Loading…
Reference in a new issue