Author: hpoussin
Date: Mon May 29 01:43:45 2006
New Revision: 22095
URL:
http://svn.reactos.ru/svn/reactos?rev=22095&view=rev
Log:
Better handling of errors/special cases
Modified:
trunk/reactos/drivers/base/green/dispatch.c
trunk/reactos/drivers/base/green/green.h
trunk/reactos/drivers/base/green/green.inf
trunk/reactos/drivers/base/green/pnp.c
Modified: trunk/reactos/drivers/base/green/dispatch.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/base/green/dispatch…
==============================================================================
--- trunk/reactos/drivers/base/green/dispatch.c (original)
+++ trunk/reactos/drivers/base/green/dispatch.c Mon May 29 01:43:45 2006
@@ -76,7 +76,26 @@
{
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;
Modified: trunk/reactos/drivers/base/green/green.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/base/green/green.h?…
==============================================================================
--- trunk/reactos/drivers/base/green/green.h (original)
+++ trunk/reactos/drivers/base/green/green.h Mon May 29 01:43:45 2006
@@ -105,6 +105,7 @@
ULONG SampleRate;
PDEVICE_OBJECT GreenMainDO;
+ PDEVICE_OBJECT LowerDevice;
} GREEN_DRIVER_EXTENSION, *PGREEN_DRIVER_EXTENSION;
/************************************ createclose.c */
Modified: trunk/reactos/drivers/base/green/green.inf
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/base/green/green.in…
==============================================================================
--- trunk/reactos/drivers/base/green/green.inf (original)
+++ trunk/reactos/drivers/base/green/green.inf Mon May 29 01:43:45 2006
@@ -38,9 +38,9 @@
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"
Modified: trunk/reactos/drivers/base/green/pnp.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/base/green/pnp.c?re…
==============================================================================
--- trunk/reactos/drivers/base/green/pnp.c (original)
+++ trunk/reactos/drivers/base/green/pnp.c Mon May 29 01:43:45 2006
@@ -26,7 +26,8 @@
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
- Status = IoCreateDevice(DriverObject,
+ Status = IoCreateDevice(
+ DriverObject,
sizeof(GREEN_DEVICE_EXTENSION),
NULL,
FILE_DEVICE_TERMSRV,
@@ -43,7 +44,7 @@
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 @@
{
if (DeviceExtension && DeviceExtension->Serial)
ObDereferenceObject(DeviceExtension->Serial);
- if (DriverExtension && DriverExtension->GreenMainDO)
- {
- IoDeleteDevice(DriverExtension->GreenMainDO);
- DriverExtension->GreenMainDO = NULL;
+ if (DriverExtension)
+ {
+ if (DriverExtension->LowerDevice)
+ {
+ IoDetachDevice(DriverExtension->LowerDevice);
+ DriverExtension->LowerDevice = NULL;
+ }
+ if (DriverExtension->GreenMainDO)
+ {
+ IoDeleteDevice(DriverExtension->GreenMainDO);
+ DriverExtension->GreenMainDO = NULL;
+ }
}
}
return Status;
@@ -219,39 +228,45 @@
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))
- {
- 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;
-
- 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;
+ if (DeviceExtension->KeyboardPdo == NULL)
+ {
+ 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;
+ }
+
+ if (DeviceExtension->ScreenPdo == NULL)
+ {
+ 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;
+ }
/* Allocate return structure */
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(