26 static UNICODE_STRING ServiceKeyRegistryPath;
61 ntStatus = STATUS_SUCCESS;
67 DBG_ASSERT(ServiceKeyRegistryPath.Buffer == 0);
71 ServiceKeyRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool,
76 if (ServiceKeyRegistryPath.Buffer)
78 ServiceKeyRegistryPath.MaximumLength =
79 ServiceKeyRegistryPath.Length = RegistryPath->Length;
81 RtlCopyUnicodeString(&ServiceKeyRegistryPath, RegistryPath);
88 ServiceKeyRegistryPath.MaximumLength =
89 ServiceKeyRegistryPath.Length = 0;
95 if (ServiceKeyRegistryPath.Length != 0 && ServiceKeyRegistryPath.Buffer != NULL)
103 if (NT_SUCCESS(ntStatus))
107 ULONG iecCable = IEC_CABLETYPE_AUTO;
133 Pdx->ParallelPortLock = iecCable ? TRUE : FALSE;
178 Pdx->CableInitTimer = 5;
180 DBG_IRQL( <= DISPATCH_LEVEL);
181 IoStartTimer(Pdx->Fdo);
205 CompleteIOCTL(PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
211 UNREFERENCED_PARAMETER(Context);
216 DBG_IRQL( <= DISPATCH_LEVEL);
219 FUNC_LEAVE_NTSTATUS_CONST(STATUS_MORE_PROCESSING_REQUIRED);
242 InitializeCableTimerRoutine(PDEVICE_OBJECT Fdo, PVOID Context)
244 PDEVICE_EXTENSION pdx = Context;
249 DBG_IRQL( == DISPATCH_LEVEL);
251 if (pdx->CableInitTimer > 0 && --pdx->CableInitTimer == 0)
256 PIO_STACK_LOCATION irpSp;
261 DBG_IRQL( <= DISPATCH_LEVEL );
262 irp = IoAllocateIrp(Fdo->StackSize, FALSE);
265 ntStatus = STATUS_INSUFFICIENT_RESOURCES;
269 DBG_IRQL( <= DISPATCH_LEVEL );
270 irpSp = IoGetNextIrpStackLocation(irp);
272 irpSp->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
274 irpSp->Parameters.DeviceIoControl.InputBufferLength = 0;
275 irpSp->Parameters.DeviceIoControl.OutputBufferLength = 0;
276 irpSp->FileObject = NULL;
278 DBG_IRQL( <= DISPATCH_LEVEL );
279 IoSetCompletionRoutine(irp, CompleteIOCTL, pdx, TRUE, TRUE, TRUE);
281 DBG_IRQL( <= DISPATCH_LEVEL );
282 ntStatus = IoCallDriver(Fdo, irp);
286 if (!NT_SUCCESS(ntStatus))
332 Driverobject->MajorFunction[IRP_MJ_CLEANUP] =
cbm_cleanup;
338 FUNC_LEAVE_NTSTATUS_CONST(STATUS_SUCCESS);
360 if (ServiceKeyRegistryPath.Buffer)
362 ExFreePool(ServiceKeyRegistryPath.Buffer);
363 DBGDO(ServiceKeyRegistryPath.Buffer = NULL;
364 ServiceKeyRegistryPath.MaximumLength = ServiceKeyRegistryPath.Length = 0);
403 IN PCWSTR ParallelPortName)
405 PDEVICE_EXTENSION pdx;
406 UNICODE_STRING parallelPortName;
413 pdx = Fdo->DeviceExtension;
417 RtlZeroMemory(pdx,
sizeof(*pdx));
421 pdx->DeviceName.Buffer = DeviceName->Buffer;
422 pdx->DeviceName.Length = DeviceName->Length;
423 pdx->DeviceName.MaximumLength = DeviceName->MaximumLength;
437 Fdo->Flags |= DO_BUFFERED_IO;
442 parallelPortName.Buffer = (PWSTR) ParallelPortName;
443 parallelPortName.Length = (USHORT) wcslen(ParallelPortName) *
sizeof(WCHAR);
444 parallelPortName.MaximumLength = parallelPortName.Length;
461 DBG_IRQL( == PASSIVE_LEVEL);
462 IoInitializeTimer(pdx->Fdo, InitializeCableTimerRoutine, pdx);
468 if (!NT_SUCCESS(ntStatus))
471 LogErrorString(Fdo, CBM_START_FAILED, L
"initialization of the parallel port.", NULL);
476 if (NT_SUCCESS(ntStatus))
486 if (NT_SUCCESS(ntStatus))
491 FUNC_LEAVE_NTSTATUS(ntStatus);
#define LogErrorString(_Fdo_, _UniqueErrorValue_, _String1_, _String2_)
VOID QueueInit(PQUEUE Queue, PCBMDRIVER_STARTIO DriverStartIo)
Initialize a QUEUE object.
NTSTATUS cbm_start_thread(IN PDEVICE_EXTENSION Pdx)
Start the worker thread.
VOID DriverCommonUninit(VOID)
Undo what DriverCommonInit() has done.
VOID DriverUnload(IN PDRIVER_OBJECT DriverObject)
Unload routine of the driver.
NTSTATUS cbmiec_global_init(IN PHANDLE HKey)
Initialization for libiec which are global in nature.
NTSTATUS cbm_readwrite(IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
Services reads from or writes to the driver.
VOID cbmiec_set_cabletype(IN PDEVICE_EXTENSION Pdx, IN IEC_CABLETYPE CableType)
Set the type of the IEC cable.
NTSTATUS cbm_registry_close(IN HANDLE HandleKey)
Close a registry key.
Definitions for the libiec library.
NTSTATUS AddDeviceCommonInit(IN PDEVICE_OBJECT Fdo, IN PUNICODE_STRING DeviceName, IN PCWSTR ParallelPortName)
Initialize device object, common to WDM and NT4 driver.
NTSTATUS cbm_createopenclose(IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
Services IRPs containing the IRP_MJ_CREATE or IRP_MJ_CLOSE I/O function code.
NTSTATUS cbm_registry_read_ulong(IN HANDLE HandleKey, IN PCWSTR KeyName, OUT PULONG Value)
Read a ULONG value out of a registry key.
NTSTATUS cbm_cleanup(IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
Services IRPs containing the IRP_MJ_CLEANUP I/O function code.
NTSTATUS cbm_devicecontrol(IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
Services IOCTLs.
VOID cbm_init_registry(IN PUNICODE_STRING RegistryPath, IN PDEVICE_EXTENSION Pdx)
Initialize from registry.
#define CBMCTRL_UPDATE
IOCTL for updating settings of the driver.
NTSTATUS cbm_startio(IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
Execute an IRP.
ULONG CbmGetNumberProcessors(VOID)
Get the number of processors in the system.
Definitions for the opencbm driver.
NTSTATUS ParPortInit(PUNICODE_STRING ParallelPortName, PDEVICE_EXTENSION Pdx)
Initialize the knowledge on a parallel port.
VOID cbm_initialize_cable_deferred(IN PDEVICE_EXTENSION Pdx)
Initialize the cable.
#define LogErrorOnly(_Fdo_, _UniqueErrorValue_)
NTSTATUS cbm_registry_open_for_read(OUT PHANDLE HandleKey, IN PUNICODE_STRING Path)
Open a registry path for reading.
NTSTATUS DriverCommonInit(IN PDRIVER_OBJECT Driverobject, IN PUNICODE_STRING RegistryPath)
Perform driver initialization, common to WDM and NT4 driver.