mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 00:58:16 +00:00
Better handling of errors/special cases
svn path=/trunk/; revision=22095
This commit is contained in:
parent
10052376c0
commit
57ae379676
|
@ -76,7 +76,26 @@ GreenDispatch(
|
|||
{
|
||||
DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
|
||||
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;
|
||||
|
|
|
@ -105,6 +105,7 @@ typedef struct _GREEN_DRIVER_EXTENSION
|
|||
ULONG SampleRate;
|
||||
|
||||
PDEVICE_OBJECT GreenMainDO;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
} GREEN_DRIVER_EXTENSION, *PGREEN_DRIVER_EXTENSION;
|
||||
|
||||
/************************************ createclose.c */
|
||||
|
|
|
@ -38,9 +38,9 @@ ServiceType = 1
|
|||
StartType = 1
|
||||
ErrorControl = 0
|
||||
ServiceBinary = %12%\green.sys
|
||||
LoadOrderGroup = Video Init
|
||||
LoadOrderGroup = Extended base
|
||||
Description = %GREEN.DriverDesc%
|
||||
Dependencies = blue
|
||||
Dependencies = blue, serial
|
||||
|
||||
[Green_AddReg.NT]
|
||||
HKLM,"SYSTEM\CurrentControlSet\Services\green\Parameters","AttachedDevice",0x00000000,"\Device\Serial1"
|
||||
|
|
|
@ -26,7 +26,8 @@ CreateGreenFdo(
|
|||
|
||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
Status = IoCreateDevice(
|
||||
DriverObject,
|
||||
sizeof(GREEN_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_TERMSRV,
|
||||
|
@ -43,7 +44,7 @@ CreateGreenFdo(
|
|||
RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
|
||||
DeviceExtension->Common.Type = GreenFDO;
|
||||
DriverExtension->GreenMainDO->Flags |= DO_POWER_PAGABLE;
|
||||
IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
|
||||
DriverExtension->LowerDevice = IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
|
||||
|
||||
/* Initialize serial port */
|
||||
InitializeObjectAttributes(&ObjectAttributes, &DriverExtension->AttachedDeviceName, OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||
|
@ -119,10 +120,18 @@ cleanup:
|
|||
{
|
||||
if (DeviceExtension && DeviceExtension->Serial)
|
||||
ObDereferenceObject(DeviceExtension->Serial);
|
||||
if (DriverExtension && DriverExtension->GreenMainDO)
|
||||
if (DriverExtension)
|
||||
{
|
||||
IoDeleteDevice(DriverExtension->GreenMainDO);
|
||||
DriverExtension->GreenMainDO = NULL;
|
||||
if (DriverExtension->LowerDevice)
|
||||
{
|
||||
IoDetachDevice(DriverExtension->LowerDevice);
|
||||
DriverExtension->LowerDevice = NULL;
|
||||
}
|
||||
if (DriverExtension->GreenMainDO)
|
||||
{
|
||||
IoDeleteDevice(DriverExtension->GreenMainDO);
|
||||
DriverExtension->GreenMainDO = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Status;
|
||||
|
@ -219,39 +228,45 @@ GreenQueryBusRelations(
|
|||
DeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
/* Create PDOs for keyboard and screen */
|
||||
Status = IoCreateDevice(
|
||||
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))
|
||||
if (DeviceExtension->KeyboardPdo == NULL)
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
||||
goto cleanup;
|
||||
Status = IoCreateDevice(
|
||||
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(
|
||||
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))
|
||||
if (DeviceExtension->ScreenPdo == NULL)
|
||||
{
|
||||
DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
|
||||
goto cleanup;
|
||||
Status = IoCreateDevice(
|
||||
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 */
|
||||
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
|
||||
|
|
Loading…
Reference in a new issue