2 * PROJECT: ReactOS VT100 emulator
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/base/green/dispatch.c
5 * PURPOSE: Dispatch routines
6 * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
16 IN PDEVICE_OBJECT DeviceObject
,
20 GREEN_DEVICE_TYPE DeviceType
;
21 ULONG_PTR Information
;
24 MajorFunction
= IoGetCurrentIrpStackLocation(Irp
)->MajorFunction
;
25 DeviceType
= ((PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
)->Type
;
27 Information
= Irp
->IoStatus
.Information
;
28 Status
= Irp
->IoStatus
.Status
;
30 DPRINT("Dispatching major function 0x%lx, DeviceType %u\n",
31 MajorFunction
, DeviceType
);
33 if (DeviceType
== PassThroughFDO
)
35 IoSkipCurrentIrpStackLocation(Irp
);
36 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
)->LowerDevice
, Irp
);
38 else if (MajorFunction
== IRP_MJ_CREATE
&& (DeviceType
== GreenFDO
|| DeviceType
== KeyboardPDO
|| DeviceType
== ScreenPDO
))
39 return GreenCreate(DeviceObject
, Irp
);
40 else if (MajorFunction
== IRP_MJ_CLOSE
&& (DeviceType
== GreenFDO
|| DeviceType
== KeyboardPDO
|| DeviceType
== ScreenPDO
))
41 return GreenClose(DeviceObject
, Irp
);
42 else if ((MajorFunction
== IRP_MJ_CREATE
|| MajorFunction
== IRP_MJ_CLOSE
|| MajorFunction
== IRP_MJ_CLEANUP
)
43 && (DeviceType
== KeyboardFDO
|| DeviceType
== ScreenFDO
))
45 IoSkipCurrentIrpStackLocation(Irp
);
46 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
)->LowerDevice
, Irp
);
48 else if (MajorFunction
== IRP_MJ_INTERNAL_DEVICE_CONTROL
&& DeviceType
== GreenFDO
)
50 return KeyboardInternalDeviceControl(
51 ((PGREEN_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
)->KeyboardFdo
,
54 else if (MajorFunction
== IRP_MJ_INTERNAL_DEVICE_CONTROL
&& DeviceType
== KeyboardFDO
)
55 return KeyboardInternalDeviceControl(DeviceObject
, Irp
);
56 else if (MajorFunction
== IRP_MJ_DEVICE_CONTROL
&& DeviceType
== GreenFDO
)
58 return ScreenDeviceControl(
59 ((PGREEN_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
)->ScreenFdo
,
62 else if (MajorFunction
== IRP_MJ_DEVICE_CONTROL
&& DeviceType
== ScreenFDO
)
63 return ScreenDeviceControl(DeviceObject
, Irp
);
64 else if (MajorFunction
== IRP_MJ_WRITE
&& DeviceType
== ScreenFDO
)
65 return ScreenWrite(DeviceObject
, Irp
);
66 else if (MajorFunction
== IRP_MJ_PNP
&& (DeviceType
== KeyboardFDO
|| DeviceType
== ScreenFDO
))
68 IoSkipCurrentIrpStackLocation(Irp
);
69 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
)->LowerDevice
, Irp
);
71 else if (MajorFunction
== IRP_MJ_PNP
&& (DeviceType
== GreenFDO
|| DeviceType
== KeyboardPDO
|| DeviceType
== ScreenPDO
))
72 return GreenPnp(DeviceObject
, Irp
);
73 else if (MajorFunction
== IRP_MJ_POWER
&& DeviceType
== GreenFDO
)
74 return GreenPower(DeviceObject
, Irp
);
77 DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
78 MajorFunction
, DeviceType
);
84 IoSkipCurrentIrpStackLocation(Irp
);
85 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
)->LowerDevice
, Irp
);
89 PDRIVER_OBJECT DriverObject
;
90 PGREEN_DRIVER_EXTENSION DriverExtension
;
91 DriverObject
= DeviceObject
->DriverObject
;
92 DriverExtension
= IoGetDriverObjectExtension(DriverObject
, DriverObject
);
93 IoSkipCurrentIrpStackLocation(Irp
);
94 return IoCallDriver(DriverExtension
->LowerDevice
, Irp
);
101 Irp
->IoStatus
.Information
= Information
;
102 Irp
->IoStatus
.Status
= Status
;
103 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);