1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: Parallel Port Function Driver 4 * PURPOSE: Parport driver loading/unloading 5 */ 6 7 #include "parport.h" 8 9 static DRIVER_UNLOAD DriverUnload; 10 static DRIVER_DISPATCH DispatchCreate; 11 static DRIVER_DISPATCH DispatchClose; 12 static DRIVER_DISPATCH DispatchCleanup; 13 static DRIVER_DISPATCH DispatchPnp; 14 static DRIVER_DISPATCH DispatchPower; 15 DRIVER_INITIALIZE DriverEntry; 16 17 18 /* FUNCTIONS ****************************************************************/ 19 20 static 21 VOID 22 NTAPI 23 DriverUnload(IN PDRIVER_OBJECT DriverObject) 24 { 25 DPRINT("Parport DriverUnload\n"); 26 } 27 28 29 static 30 NTSTATUS 31 NTAPI 32 DispatchCreate(IN PDEVICE_OBJECT DeviceObject, 33 IN PIRP Irp) 34 { 35 if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) 36 return FdoCreate(DeviceObject, Irp); 37 else 38 return PdoCreate(DeviceObject, Irp); 39 } 40 41 42 static 43 NTSTATUS 44 NTAPI 45 DispatchClose(IN PDEVICE_OBJECT DeviceObject, 46 IN PIRP Irp) 47 { 48 if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) 49 return FdoClose(DeviceObject, Irp); 50 else 51 return PdoClose(DeviceObject, Irp); 52 } 53 54 55 static 56 NTSTATUS 57 NTAPI 58 DispatchCleanup(IN PDEVICE_OBJECT DeviceObject, 59 IN PIRP Irp) 60 { 61 if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) 62 return FdoCleanup(DeviceObject, Irp); 63 else 64 return PdoCleanup(DeviceObject, Irp); 65 } 66 67 68 static 69 NTSTATUS 70 NTAPI 71 DispatchRead(IN PDEVICE_OBJECT DeviceObject, 72 IN PIRP Irp) 73 { 74 if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) 75 return FdoRead(DeviceObject, Irp); 76 else 77 return PdoRead(DeviceObject, Irp); 78 } 79 80 81 static 82 NTSTATUS 83 NTAPI 84 DispatchWrite(IN PDEVICE_OBJECT DeviceObject, 85 IN PIRP Irp) 86 { 87 if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) 88 return FdoWrite(DeviceObject, Irp); 89 else 90 return PdoWrite(DeviceObject, Irp); 91 } 92 93 94 static 95 NTSTATUS 96 NTAPI 97 DispatchPnp(IN PDEVICE_OBJECT DeviceObject, 98 IN PIRP Irp) 99 { 100 if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) 101 return FdoPnp(DeviceObject, Irp); 102 else 103 return PdoPnp(DeviceObject, Irp); 104 } 105 106 107 static 108 NTSTATUS 109 NTAPI 110 DispatchPower(IN PDEVICE_OBJECT DeviceObject, 111 IN PIRP Irp) 112 { 113 if (((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.IsFDO) 114 return FdoPower(DeviceObject, Irp); 115 else 116 return PdoPower(DeviceObject, Irp); 117 } 118 119 120 NTSTATUS 121 NTAPI 122 DriverEntry(IN PDRIVER_OBJECT DriverObject, 123 IN PUNICODE_STRING RegPath) 124 { 125 ULONG i; 126 127 DPRINT("Parport DriverEntry\n"); 128 129 DriverObject->DriverUnload = DriverUnload; 130 DriverObject->DriverExtension->AddDevice = AddDevice; 131 132 for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) 133 DriverObject->MajorFunction[i] = ForwardIrpAndForget; 134 135 DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate; 136 DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose; 137 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup; 138 DriverObject->MajorFunction[IRP_MJ_READ] = DispatchRead; 139 DriverObject->MajorFunction[IRP_MJ_WRITE] = DispatchWrite; 140 // DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl; 141 // DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = DispatchQueryInformation; 142 DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp; 143 DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower; 144 145 return STATUS_SUCCESS; 146 } 147