mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 21:06:17 +00:00
[VIDEOPRT]
FORMATTING, no code change. svn path=/trunk/; revision=60962
This commit is contained in:
parent
49a2c38305
commit
3e75f29597
1 changed files with 362 additions and 351 deletions
|
@ -30,60 +30,54 @@ PVIDEO_PORT_DEVICE_EXTENSION ResetDisplayParametersDeviceExtension = NULL;
|
||||||
/*
|
/*
|
||||||
* Reset display to blue screen
|
* Reset display to blue screen
|
||||||
*/
|
*/
|
||||||
|
BOOLEAN
|
||||||
BOOLEAN NTAPI
|
NTAPI
|
||||||
IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
|
IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
|
||||||
{
|
{
|
||||||
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
||||||
|
|
||||||
if (ResetDisplayParametersDeviceExtension == NULL)
|
if (ResetDisplayParametersDeviceExtension == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
DriverExtension = ResetDisplayParametersDeviceExtension->DriverExtension;
|
DriverExtension = ResetDisplayParametersDeviceExtension->DriverExtension;
|
||||||
|
|
||||||
if (DriverExtension->InitializationData.HwResetHw != NULL)
|
if (DriverExtension->InitializationData.HwResetHw != NULL)
|
||||||
{
|
{
|
||||||
if (DriverExtension->InitializationData.HwResetHw(
|
if (DriverExtension->InitializationData.HwResetHw(
|
||||||
&ResetDisplayParametersDeviceExtension->MiniPortDeviceExtension,
|
&ResetDisplayParametersDeviceExtension->MiniPortDeviceExtension,
|
||||||
Columns, Rows))
|
Columns, Rows))
|
||||||
{
|
{
|
||||||
ResetDisplayParametersDeviceExtension = NULL;
|
ResetDisplayParametersDeviceExtension = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetDisplayParametersDeviceExtension = NULL;
|
ResetDisplayParametersDeviceExtension = NULL;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortAddDevice(
|
IntVideoPortAddDevice(
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PDEVICE_OBJECT PhysicalDeviceObject)
|
IN PDEVICE_OBJECT PhysicalDeviceObject)
|
||||||
{
|
{
|
||||||
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/*
|
/* Get the initialization data we saved in VideoPortInitialize. */
|
||||||
* Get the initialization data we saved in VideoPortInitialize.
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
*/
|
|
||||||
|
|
||||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
/* Create adapter device object. */
|
||||||
|
Status = IntVideoPortCreateAdapterDeviceObject(DriverObject,
|
||||||
|
DriverExtension,
|
||||||
|
PhysicalDeviceObject,
|
||||||
|
&DeviceObject);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
VideoPortDeviceNumber++;
|
||||||
|
|
||||||
/*
|
return Status;
|
||||||
* Create adapter device object.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Status = IntVideoPortCreateAdapterDeviceObject(
|
|
||||||
DriverObject,
|
|
||||||
DriverExtension,
|
|
||||||
PhysicalDeviceObject,
|
|
||||||
&DeviceObject);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
VideoPortDeviceNumber++;
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -94,54 +88,53 @@ IntVideoPortAddDevice(
|
||||||
* Run Level
|
* Run Level
|
||||||
* PASSIVE_LEVEL
|
* PASSIVE_LEVEL
|
||||||
*/
|
*/
|
||||||
|
NTSTATUS
|
||||||
NTSTATUS NTAPI
|
NTAPI
|
||||||
IntVideoPortDispatchOpen(
|
IntVideoPortDispatchOpen(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
||||||
|
|
||||||
TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
|
TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
|
||||||
|
|
||||||
if (CsrssInitialized == FALSE)
|
if (CsrssInitialized == FALSE)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We know the first open call will be from the CSRSS process
|
* We know the first open call will be from the CSRSS process
|
||||||
* to let us know its handle.
|
* to let us know its handle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INFO_(VIDEOPRT, "Referencing CSRSS\n");
|
INFO_(VIDEOPRT, "Referencing CSRSS\n");
|
||||||
Csrss = (PKPROCESS)PsGetCurrentProcess();
|
Csrss = (PKPROCESS)PsGetCurrentProcess();
|
||||||
INFO_(VIDEOPRT, "Csrss %p\n", Csrss);
|
INFO_(VIDEOPRT, "Csrss %p\n", Csrss);
|
||||||
|
|
||||||
CsrssInitialized = TRUE;
|
CsrssInitialized = TRUE;
|
||||||
|
|
||||||
Irp->IoStatus.Information = FILE_OPENED;
|
Irp->IoStatus.Information = FILE_OPENED;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
DriverExtension = DeviceExtension->DriverExtension;
|
DriverExtension = DeviceExtension->DriverExtension;
|
||||||
|
|
||||||
if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
|
if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
|
Irp->IoStatus.Information = FILE_OPENED;
|
||||||
}
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
else
|
|
||||||
{
|
|
||||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Information = FILE_OPENED;
|
return STATUS_SUCCESS;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -152,30 +145,30 @@ IntVideoPortDispatchOpen(
|
||||||
* Run Level
|
* Run Level
|
||||||
* PASSIVE_LEVEL
|
* PASSIVE_LEVEL
|
||||||
*/
|
*/
|
||||||
|
NTSTATUS
|
||||||
NTSTATUS NTAPI
|
NTAPI
|
||||||
IntVideoPortDispatchClose(
|
IntVideoPortDispatchClose(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
|
TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
|
||||||
|
|
||||||
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
if (DeviceExtension->DeviceOpened >= 1 &&
|
if ((DeviceExtension->DeviceOpened >= 1) &&
|
||||||
InterlockedDecrement((PLONG)&DeviceExtension->DeviceOpened) == 0)
|
(InterlockedDecrement((PLONG)&DeviceExtension->DeviceOpened) == 0))
|
||||||
{
|
{
|
||||||
ResetDisplayParametersDeviceExtension = NULL;
|
ResetDisplayParametersDeviceExtension = NULL;
|
||||||
InbvNotifyDisplayOwnershipLost(NULL);
|
InbvNotifyDisplayOwnershipLost(NULL);
|
||||||
ResetDisplayParametersDeviceExtension = DeviceExtension;
|
ResetDisplayParametersDeviceExtension = DeviceExtension;
|
||||||
IntVideoPortResetDisplayParameters(80, 50);
|
IntVideoPortResetDisplayParameters(80, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -186,73 +179,86 @@ IntVideoPortDispatchClose(
|
||||||
* Run Level
|
* Run Level
|
||||||
* PASSIVE_LEVEL
|
* PASSIVE_LEVEL
|
||||||
*/
|
*/
|
||||||
|
NTSTATUS
|
||||||
NTSTATUS NTAPI
|
NTAPI
|
||||||
IntVideoPortDispatchDeviceControl(
|
IntVideoPortDispatchDeviceControl(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpStack;
|
PIO_STACK_LOCATION IrpStack;
|
||||||
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
PVIDEO_REQUEST_PACKET vrp;
|
PVIDEO_REQUEST_PACKET vrp;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
|
TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
|
||||||
|
|
||||||
IrpStack = IoGetCurrentIrpStackLocation(Irp);
|
IrpStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
DeviceExtension = DeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
DriverExtension = DeviceExtension->DriverExtension;
|
DriverExtension = DeviceExtension->DriverExtension;
|
||||||
|
|
||||||
/* Translate the IRP to a VRP */
|
/* Translate the IRP to a VRP */
|
||||||
vrp = ExAllocatePoolWithTag(NonPagedPool,
|
vrp = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
sizeof(VIDEO_REQUEST_PACKET),
|
sizeof(VIDEO_REQUEST_PACKET),
|
||||||
TAG_REQUEST_PACKET);
|
TAG_REQUEST_PACKET);
|
||||||
if (NULL == vrp)
|
if (vrp == NULL)
|
||||||
{
|
{
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
vrp->StatusBlock = (PSTATUS_BLOCK)&(Irp->IoStatus);
|
vrp->StatusBlock = (PSTATUS_BLOCK) & (Irp->IoStatus);
|
||||||
vrp->IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
|
vrp->IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
|
||||||
|
|
||||||
INFO_(VIDEOPRT, "- IoControlCode: %x\n", vrp->IoControlCode);
|
INFO_(VIDEOPRT, "- IoControlCode: %x\n", vrp->IoControlCode);
|
||||||
|
|
||||||
/* We're assuming METHOD_BUFFERED */
|
/* We're assuming METHOD_BUFFERED */
|
||||||
vrp->InputBuffer = Irp->AssociatedIrp.SystemBuffer;
|
vrp->InputBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||||
vrp->InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
|
vrp->InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
|
||||||
vrp->OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
|
vrp->OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||||
vrp->OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
|
vrp->OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
|
||||||
|
|
||||||
/* Call the Miniport Driver with the VRP */
|
/* Call the Miniport Driver with the VRP */
|
||||||
DriverExtension->InitializationData.HwStartIO(
|
DriverExtension->InitializationData.HwStartIO(
|
||||||
&DeviceExtension->MiniPortDeviceExtension,
|
&DeviceExtension->MiniPortDeviceExtension,
|
||||||
vrp);
|
vrp);
|
||||||
|
|
||||||
/* Free the VRP */
|
/* Free the VRP */
|
||||||
ExFreePoolWithTag(vrp, TAG_REQUEST_PACKET);
|
ExFreePoolWithTag(vrp, TAG_REQUEST_PACKET);
|
||||||
|
|
||||||
INFO_(VIDEOPRT, "- Returned status: %x\n", Irp->IoStatus.Status);
|
INFO_(VIDEOPRT, "- Returned status: %x\n", Irp->IoStatus.Status);
|
||||||
|
|
||||||
if (Irp->IoStatus.Status != STATUS_SUCCESS)
|
if (Irp->IoStatus.Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Map from win32 error codes to NT status values. */
|
switch (Irp->IoStatus.Status)
|
||||||
switch (Irp->IoStatus.Status)
|
{
|
||||||
{
|
case ERROR_NOT_ENOUGH_MEMORY:
|
||||||
case ERROR_NOT_ENOUGH_MEMORY: Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; break;
|
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
case ERROR_MORE_DATA: Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW; break;
|
break;
|
||||||
case ERROR_INVALID_FUNCTION: Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; break;
|
case ERROR_MORE_DATA:
|
||||||
case ERROR_INVALID_PARAMETER: Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; break;
|
Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
|
||||||
case ERROR_INSUFFICIENT_BUFFER: Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; break;
|
break;
|
||||||
case ERROR_DEV_NOT_EXIST: Irp->IoStatus.Status = STATUS_DEVICE_DOES_NOT_EXIST; break;
|
case ERROR_INVALID_FUNCTION:
|
||||||
case ERROR_IO_PENDING: Irp->IoStatus.Status = STATUS_PENDING; break;
|
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
break;
|
||||||
}
|
case ERROR_INVALID_PARAMETER:
|
||||||
|
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||||
|
break;
|
||||||
|
case ERROR_INSUFFICIENT_BUFFER:
|
||||||
|
Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
|
||||||
|
break;
|
||||||
|
case ERROR_DEV_NOT_EXIST:
|
||||||
|
Irp->IoStatus.Status = STATUS_DEVICE_DOES_NOT_EXIST;
|
||||||
|
break;
|
||||||
|
case ERROR_IO_PENDING:
|
||||||
|
Irp->IoStatus.Status = STATUS_PENDING;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -273,127 +279,119 @@ IntVideoPortDispatchDeviceControl(
|
||||||
* PASSIVE_LEVEL
|
* PASSIVE_LEVEL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortDispatchWrite(
|
IntVideoPortDispatchWrite(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION piosStack = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION piosStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
NTSTATUS nErrCode;
|
NTSTATUS nErrCode;
|
||||||
|
|
||||||
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Storing the device extension pointer in a static variable is an
|
* Storing the device extension pointer in a static variable is an
|
||||||
* ugly hack. Unfortunately, we need it in IntVideoPortResetDisplayParameters
|
* ugly hack. Unfortunately, we need it in IntVideoPortResetDisplayParameters
|
||||||
* and InbvNotifyDisplayOwnershipLost doesn't allow us to pass a userdata
|
* and InbvNotifyDisplayOwnershipLost doesn't allow us to pass a userdata
|
||||||
* parameter. On the bright side, the DISPLAY device is opened
|
* parameter. On the bright side, the DISPLAY device is opened
|
||||||
* exclusively, so there can be only one device extension active at
|
* exclusively, so there can be only one device extension active at
|
||||||
* any point in time.
|
* any point in time.
|
||||||
*
|
*
|
||||||
* FIXME: We should process all opened display devices in
|
* FIXME: We should process all opened display devices in
|
||||||
* IntVideoPortResetDisplayParameters.
|
* IntVideoPortResetDisplayParameters.
|
||||||
*/
|
*/
|
||||||
|
ResetDisplayParametersDeviceExtension = DeviceExtension;
|
||||||
|
InbvNotifyDisplayOwnershipLost(IntVideoPortResetDisplayParameters);
|
||||||
|
|
||||||
ResetDisplayParametersDeviceExtension = DeviceExtension;
|
nErrCode = STATUS_SUCCESS;
|
||||||
InbvNotifyDisplayOwnershipLost(IntVideoPortResetDisplayParameters);
|
Irp->IoStatus.Information = piosStack->Parameters.Write.Length;
|
||||||
|
Irp->IoStatus.Status = nErrCode;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
nErrCode = STATUS_SUCCESS;
|
return nErrCode;
|
||||||
Irp->IoStatus.Information = piosStack->Parameters.Write.Length;
|
|
||||||
Irp->IoStatus.Status = nErrCode;
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
|
|
||||||
return nErrCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortPnPStartDevice(
|
IntVideoPortPnPStartDevice(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
PCM_RESOURCE_LIST AllocatedResources;
|
PCM_RESOURCE_LIST AllocatedResources;
|
||||||
|
|
||||||
/*
|
/* Get the initialization data we saved in VideoPortInitialize.*/
|
||||||
* Get the initialization data we saved in VideoPortInitialize.
|
DriverObject = DeviceObject->DriverObject;
|
||||||
*/
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
|
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
DriverObject = DeviceObject->DriverObject;
|
/* Store some resources in the DeviceExtension. */
|
||||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
|
||||||
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
if (AllocatedResources != NULL)
|
||||||
|
{
|
||||||
|
CM_FULL_RESOURCE_DESCRIPTOR *FullList;
|
||||||
|
CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor;
|
||||||
|
ULONG ResourceCount;
|
||||||
|
ULONG ResourceListSize;
|
||||||
|
|
||||||
/*
|
/* Save the resource list */
|
||||||
* Store some resources in the DeviceExtension.
|
ResourceCount = AllocatedResources->List[0].PartialResourceList.Count;
|
||||||
*/
|
ResourceListSize =
|
||||||
|
FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
|
||||||
|
PartialDescriptors[ResourceCount]);
|
||||||
|
DeviceExtension->AllocatedResources = ExAllocatePool(PagedPool, ResourceListSize);
|
||||||
|
if (DeviceExtension->AllocatedResources == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
|
RtlCopyMemory(DeviceExtension->AllocatedResources,
|
||||||
if (AllocatedResources != NULL)
|
AllocatedResources,
|
||||||
{
|
ResourceListSize);
|
||||||
CM_FULL_RESOURCE_DESCRIPTOR *FullList;
|
|
||||||
CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor;
|
|
||||||
ULONG ResourceCount;
|
|
||||||
ULONG ResourceListSize;
|
|
||||||
|
|
||||||
/* Save the resource list */
|
/* Get the interrupt level/vector - needed by HwFindAdapter sometimes */
|
||||||
ResourceCount = AllocatedResources->List[0].PartialResourceList.Count;
|
for (FullList = AllocatedResources->List;
|
||||||
ResourceListSize =
|
FullList < AllocatedResources->List + AllocatedResources->Count;
|
||||||
FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
|
FullList++)
|
||||||
PartialDescriptors[ResourceCount]);
|
{
|
||||||
DeviceExtension->AllocatedResources = ExAllocatePool(PagedPool, ResourceListSize);
|
INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
|
||||||
if (DeviceExtension->AllocatedResources == NULL)
|
FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
|
||||||
{
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlCopyMemory(DeviceExtension->AllocatedResources,
|
/* FIXME: Is this ASSERT ok for resources from the PNP manager? */
|
||||||
AllocatedResources,
|
ASSERT(FullList->InterfaceType == PCIBus);
|
||||||
ResourceListSize);
|
ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
|
||||||
|
ASSERT(1 == FullList->PartialResourceList.Version);
|
||||||
/* Get the interrupt level/vector - needed by HwFindAdapter sometimes */
|
ASSERT(1 == FullList->PartialResourceList.Revision);
|
||||||
for (FullList = AllocatedResources->List;
|
for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
|
||||||
FullList < AllocatedResources->List + AllocatedResources->Count;
|
Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
|
||||||
FullList++)
|
Descriptor++)
|
||||||
{
|
|
||||||
INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
|
|
||||||
FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
|
|
||||||
|
|
||||||
/* FIXME: Is this ASSERT ok for resources from the PNP manager? */
|
|
||||||
ASSERT(FullList->InterfaceType == PCIBus);
|
|
||||||
ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
|
|
||||||
ASSERT(1 == FullList->PartialResourceList.Version);
|
|
||||||
ASSERT(1 == FullList->PartialResourceList.Revision);
|
|
||||||
for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
|
|
||||||
Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
|
|
||||||
Descriptor++)
|
|
||||||
{
|
|
||||||
if (Descriptor->Type == CmResourceTypeInterrupt)
|
|
||||||
{
|
{
|
||||||
DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
|
if (Descriptor->Type == CmResourceTypeInterrupt)
|
||||||
DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
|
{
|
||||||
if (Descriptor->ShareDisposition == CmResourceShareShared)
|
DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
|
||||||
DeviceExtension->InterruptShared = TRUE;
|
DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
|
||||||
else
|
if (Descriptor->ShareDisposition == CmResourceShareShared)
|
||||||
DeviceExtension->InterruptShared = FALSE;
|
DeviceExtension->InterruptShared = TRUE;
|
||||||
|
else
|
||||||
|
DeviceExtension->InterruptShared = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
INFO_(VIDEOPRT, "Interrupt level: 0x%x Interrupt Vector: 0x%x\n",
|
INFO_(VIDEOPRT, "Interrupt level: 0x%x Interrupt Vector: 0x%x\n",
|
||||||
DeviceExtension->InterruptLevel,
|
DeviceExtension->InterruptLevel,
|
||||||
DeviceExtension->InterruptVector);
|
DeviceExtension->InterruptVector);
|
||||||
|
|
||||||
/*
|
/* Create adapter device object. */
|
||||||
* Create adapter device object.
|
return IntVideoPortFindAdapter(DriverObject,
|
||||||
*/
|
DriverExtension,
|
||||||
|
DeviceObject);
|
||||||
return IntVideoPortFindAdapter(
|
|
||||||
DriverObject,
|
|
||||||
DriverExtension,
|
|
||||||
DeviceObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -404,12 +402,12 @@ IntVideoPortForwardIrpAndWaitCompletionRoutine(
|
||||||
PIRP Irp,
|
PIRP Irp,
|
||||||
PVOID Context)
|
PVOID Context)
|
||||||
{
|
{
|
||||||
PKEVENT Event = Context;
|
PKEVENT Event = Context;
|
||||||
|
|
||||||
if (Irp->PendingReturned)
|
if (Irp->PendingReturned)
|
||||||
KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
|
||||||
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -434,7 +432,8 @@ IntVideoPortQueryBusRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return Irp->IoStatus.Status;
|
return Irp->IoStatus.Status;
|
||||||
|
|
||||||
DeviceRelations = ExAllocatePool(PagedPool, sizeof(DEVICE_RELATIONS) + ((i - 1) * sizeof(PVOID)));
|
DeviceRelations = ExAllocatePool(PagedPool,
|
||||||
|
sizeof(DEVICE_RELATIONS) + ((i - 1) * sizeof(PVOID)));
|
||||||
if (!DeviceRelations) return STATUS_NO_MEMORY;
|
if (!DeviceRelations) return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
DeviceRelations->Count = i;
|
DeviceRelations->Count = i;
|
||||||
|
@ -463,101 +462,109 @@ NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IntVideoPortForwardIrpAndWait(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
IntVideoPortForwardIrpAndWait(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
{
|
{
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension =
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension =
|
||||||
(PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
(PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||||
IoSetCompletionRoutine(Irp, IntVideoPortForwardIrpAndWaitCompletionRoutine,
|
IoSetCompletionRoutine(Irp,
|
||||||
&Event, TRUE, TRUE, TRUE);
|
IntVideoPortForwardIrpAndWaitCompletionRoutine,
|
||||||
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
&Event,
|
||||||
if (Status == STATUS_PENDING)
|
TRUE,
|
||||||
{
|
TRUE,
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
TRUE);
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
return Status;
|
if (Status == STATUS_PENDING)
|
||||||
|
{
|
||||||
|
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortDispatchFdoPnp(
|
IntVideoPortDispatchFdoPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpSp;
|
PIO_STACK_LOCATION IrpSp;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction)
|
switch (IrpSp->MinorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
||||||
if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
||||||
Status = IntVideoPortPnPStartDevice(DeviceObject, Irp);
|
Status = IntVideoPortPnPStartDevice(DeviceObject, Irp);
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
||||||
Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
||||||
if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
||||||
Status = IntVideoPortFilterResourceRequirements(DeviceObject, Irp);
|
Status = IntVideoPortFilterResourceRequirements(DeviceObject, Irp);
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
||||||
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
||||||
{
|
{
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Status = IntVideoPortQueryBusRelations(DeviceObject, Irp);
|
Status = IntVideoPortQueryBusRelations(DeviceObject, Irp);
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_REMOVE_DEVICE:
|
case IRP_MN_REMOVE_DEVICE:
|
||||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||||
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||||
case IRP_MN_SURPRISE_REMOVAL:
|
case IRP_MN_SURPRISE_REMOVAL:
|
||||||
|
|
||||||
case IRP_MN_STOP_DEVICE:
|
case IRP_MN_STOP_DEVICE:
|
||||||
Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
||||||
if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
Irp->IoStatus.Status = Status;
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IRP_MN_QUERY_STOP_DEVICE:
|
||||||
|
case IRP_MN_CANCEL_STOP_DEVICE:
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_STOP_DEVICE:
|
default:
|
||||||
case IRP_MN_CANCEL_STOP_DEVICE:
|
Status = Irp->IoStatus.Status;
|
||||||
Status = STATUS_SUCCESS;
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
break;
|
||||||
Irp->IoStatus.Information = 0;
|
}
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
return Status;
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortDispatchPnp(
|
IntVideoPortDispatchPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
|
@ -570,40 +577,44 @@ IntVideoPortDispatchPnp(
|
||||||
return IntVideoPortDispatchPdoPnp(DeviceObject, Irp);
|
return IntVideoPortDispatchPdoPnp(DeviceObject, Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortDispatchCleanup(
|
IntVideoPortDispatchCleanup(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
DeviceExtension = DeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
|
RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortDispatchPower(
|
IntVideoPortDispatchPower(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
IntVideoPortDispatchSystemControl(
|
IntVideoPortDispatchSystemControl(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID NTAPI
|
VOID
|
||||||
|
NTAPI
|
||||||
IntVideoPortUnload(PDRIVER_OBJECT DriverObject)
|
IntVideoPortUnload(PDRIVER_OBJECT DriverObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue