mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:43:04 +00:00
Better handling of errors/special cases
svn path=/trunk/; revision=22095
This commit is contained in:
parent
10052376c0
commit
57ae379676
4 changed files with 71 additions and 36 deletions
|
@ -76,7 +76,26 @@ GreenDispatch(
|
||||||
{
|
{
|
||||||
DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
|
DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
|
||||||
MajorFunction, DeviceType);
|
MajorFunction, DeviceType);
|
||||||
ASSERT(FALSE);
|
switch (DeviceType)
|
||||||
|
{
|
||||||
|
case KeyboardFDO:
|
||||||
|
case ScreenFDO:
|
||||||
|
{
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
|
||||||
|
}
|
||||||
|
case GreenFDO:
|
||||||
|
{
|
||||||
|
PDRIVER_OBJECT DriverObject;
|
||||||
|
PGREEN_DRIVER_EXTENSION DriverExtension;
|
||||||
|
DriverObject = DeviceObject->DriverObject;
|
||||||
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DriverExtension->LowerDevice, Irp);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Information = Information;
|
Irp->IoStatus.Information = Information;
|
||||||
|
|
|
@ -105,6 +105,7 @@ typedef struct _GREEN_DRIVER_EXTENSION
|
||||||
ULONG SampleRate;
|
ULONG SampleRate;
|
||||||
|
|
||||||
PDEVICE_OBJECT GreenMainDO;
|
PDEVICE_OBJECT GreenMainDO;
|
||||||
|
PDEVICE_OBJECT LowerDevice;
|
||||||
} GREEN_DRIVER_EXTENSION, *PGREEN_DRIVER_EXTENSION;
|
} GREEN_DRIVER_EXTENSION, *PGREEN_DRIVER_EXTENSION;
|
||||||
|
|
||||||
/************************************ createclose.c */
|
/************************************ createclose.c */
|
||||||
|
|
|
@ -38,9 +38,9 @@ ServiceType = 1
|
||||||
StartType = 1
|
StartType = 1
|
||||||
ErrorControl = 0
|
ErrorControl = 0
|
||||||
ServiceBinary = %12%\green.sys
|
ServiceBinary = %12%\green.sys
|
||||||
LoadOrderGroup = Video Init
|
LoadOrderGroup = Extended base
|
||||||
Description = %GREEN.DriverDesc%
|
Description = %GREEN.DriverDesc%
|
||||||
Dependencies = blue
|
Dependencies = blue, serial
|
||||||
|
|
||||||
[Green_AddReg.NT]
|
[Green_AddReg.NT]
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\green\Parameters","AttachedDevice",0x00000000,"\Device\Serial1"
|
HKLM,"SYSTEM\CurrentControlSet\Services\green\Parameters","AttachedDevice",0x00000000,"\Device\Serial1"
|
||||||
|
|
|
@ -26,7 +26,8 @@ CreateGreenFdo(
|
||||||
|
|
||||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
|
|
||||||
Status = IoCreateDevice(DriverObject,
|
Status = IoCreateDevice(
|
||||||
|
DriverObject,
|
||||||
sizeof(GREEN_DEVICE_EXTENSION),
|
sizeof(GREEN_DEVICE_EXTENSION),
|
||||||
NULL,
|
NULL,
|
||||||
FILE_DEVICE_TERMSRV,
|
FILE_DEVICE_TERMSRV,
|
||||||
|
@ -43,7 +44,7 @@ CreateGreenFdo(
|
||||||
RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
|
RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
|
||||||
DeviceExtension->Common.Type = GreenFDO;
|
DeviceExtension->Common.Type = GreenFDO;
|
||||||
DriverExtension->GreenMainDO->Flags |= DO_POWER_PAGABLE;
|
DriverExtension->GreenMainDO->Flags |= DO_POWER_PAGABLE;
|
||||||
IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
|
DriverExtension->LowerDevice = IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
|
||||||
|
|
||||||
/* Initialize serial port */
|
/* Initialize serial port */
|
||||||
InitializeObjectAttributes(&ObjectAttributes, &DriverExtension->AttachedDeviceName, OBJ_KERNEL_HANDLE, NULL, NULL);
|
InitializeObjectAttributes(&ObjectAttributes, &DriverExtension->AttachedDeviceName, OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||||
|
@ -119,10 +120,18 @@ cleanup:
|
||||||
{
|
{
|
||||||
if (DeviceExtension && DeviceExtension->Serial)
|
if (DeviceExtension && DeviceExtension->Serial)
|
||||||
ObDereferenceObject(DeviceExtension->Serial);
|
ObDereferenceObject(DeviceExtension->Serial);
|
||||||
if (DriverExtension && DriverExtension->GreenMainDO)
|
if (DriverExtension)
|
||||||
{
|
{
|
||||||
IoDeleteDevice(DriverExtension->GreenMainDO);
|
if (DriverExtension->LowerDevice)
|
||||||
DriverExtension->GreenMainDO = NULL;
|
{
|
||||||
|
IoDetachDevice(DriverExtension->LowerDevice);
|
||||||
|
DriverExtension->LowerDevice = NULL;
|
||||||
|
}
|
||||||
|
if (DriverExtension->GreenMainDO)
|
||||||
|
{
|
||||||
|
IoDeleteDevice(DriverExtension->GreenMainDO);
|
||||||
|
DriverExtension->GreenMainDO = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -219,39 +228,45 @@ GreenQueryBusRelations(
|
||||||
DeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
/* Create PDOs for keyboard and screen */
|
/* Create PDOs for keyboard and screen */
|
||||||
Status = IoCreateDevice(
|
if (DeviceExtension->KeyboardPdo == NULL)
|
||||||
DeviceObject->DriverObject,
|
|
||||||
sizeof(COMMON_DEVICE_EXTENSION),
|
|
||||||
NULL,
|
|
||||||
FILE_DEVICE_KEYBOARD,
|
|
||||||
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
|
|
||||||
FALSE,
|
|
||||||
&DeviceExtension->KeyboardPdo);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
Status = IoCreateDevice(
|
||||||
goto cleanup;
|
DeviceObject->DriverObject,
|
||||||
|
sizeof(COMMON_DEVICE_EXTENSION),
|
||||||
|
NULL,
|
||||||
|
FILE_DEVICE_KEYBOARD,
|
||||||
|
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
|
||||||
|
FALSE,
|
||||||
|
&DeviceExtension->KeyboardPdo);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
((PCOMMON_DEVICE_EXTENSION)DeviceExtension->KeyboardPdo->DeviceExtension)->Type = KeyboardPDO;
|
||||||
|
DeviceExtension->KeyboardPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
|
||||||
|
DeviceExtension->KeyboardPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
}
|
}
|
||||||
((PCOMMON_DEVICE_EXTENSION)DeviceExtension->KeyboardPdo->DeviceExtension)->Type = KeyboardPDO;
|
|
||||||
DeviceExtension->KeyboardPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
|
|
||||||
DeviceExtension->KeyboardPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
|
||||||
|
|
||||||
Status = IoCreateDevice(
|
if (DeviceExtension->ScreenPdo == NULL)
|
||||||
DeviceObject->DriverObject,
|
|
||||||
sizeof(COMMON_DEVICE_EXTENSION),
|
|
||||||
NULL,
|
|
||||||
FILE_DEVICE_SCREEN,
|
|
||||||
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
|
|
||||||
FALSE,
|
|
||||||
&DeviceExtension->ScreenPdo);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
Status = IoCreateDevice(
|
||||||
goto cleanup;
|
DeviceObject->DriverObject,
|
||||||
|
sizeof(COMMON_DEVICE_EXTENSION),
|
||||||
|
NULL,
|
||||||
|
FILE_DEVICE_SCREEN,
|
||||||
|
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
|
||||||
|
FALSE,
|
||||||
|
&DeviceExtension->ScreenPdo);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
((PCOMMON_DEVICE_EXTENSION)DeviceExtension->ScreenPdo->DeviceExtension)->Type = ScreenPDO;
|
||||||
|
DeviceExtension->ScreenPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
|
||||||
|
DeviceExtension->ScreenPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
}
|
}
|
||||||
((PCOMMON_DEVICE_EXTENSION)DeviceExtension->ScreenPdo->DeviceExtension)->Type = ScreenPDO;
|
|
||||||
DeviceExtension->ScreenPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
|
|
||||||
DeviceExtension->ScreenPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
|
||||||
|
|
||||||
/* Allocate return structure */
|
/* Allocate return structure */
|
||||||
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
|
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue