Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

arch_cbm_driver.h File Reference

Windows-specific definitions for the opencbm driver. More...

#include "config.h"
#include <parallel.h>
#include "cbmioctl.h"
#include "memtags.h"
#include "util.h"
#include "queue.h"
#include "cbmlog.h"

Go to the source code of this file.

Defines

#define DVRH_USE_PARPORT_ECP_ADDR   1
#define DBG_PROGNAME   "CBM4WIN.SYS"
#define CBMDEVICENAME   L"\\DosDevices\\opencbm"

Typedefs

typedef _ARCH_DEVICE_EXTENSION ARCH_DEVICE_EXTENSION
typedef PVOID PENUMERATE

Functions

VOID DriverUnload (IN PDRIVER_OBJECT DriverObject)
 Unload routine of the driver.
NTSTATUS DriverCommonInit (IN PDRIVER_OBJECT Driverobject, IN PUNICODE_STRING RegistryPath)
 Perform driver initialization, common to WDM and NT4 driver.
VOID DriverCommonUninit (VOID)
 Undo what DriverCommonInit() has done.
NTSTATUS AddDeviceCommonInit (IN PDEVICE_OBJECT Fdo, IN PUNICODE_STRING DeviceName, IN PCWSTR ParallelPortName)
 Initialize device object, common to WDM and NT4 driver.
NTSTATUS cbm_install (IN PDEVICE_EXTENSION Pdx, OUT PCBMT_I_INSTALL_OUT ReturnBuffer, IN OUT PULONG ReturnLength)
 Complete driver installation.
NTSTATUS cbm_lock (IN PDEVICE_EXTENSION Pdx)
 Lock the parallel port for the driver.
NTSTATUS cbm_unlock (IN PDEVICE_EXTENSION Pdx)
 Unlock the parallel port for the driver.
NTSTATUS cbm_lock_parport (IN PDEVICE_EXTENSION Pdx)
 Lock the parallel port for the driver.
NTSTATUS cbm_unlock_parport (IN PDEVICE_EXTENSION Pdx)
 Unlock the parallel port for the driver.
VOID cbm_init_registry (IN PUNICODE_STRING RegistryPath, IN PDEVICE_EXTENSION Pdx)
 Initialize from registry.
NTSTATUS cbm_startio (IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
 Execute an IRP.
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_readwrite (IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
 Services reads from or writes to the driver.
NTSTATUS cbm_execute_readwrite (IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
 Executes reads from or writes to the driver.
NTSTATUS cbm_execute_createopen (IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
 Execute IRPs containing the IRP_MJ_CREATEOPEN I/O function code.
NTSTATUS cbm_cleanup (IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
 Services IRPs containing the IRP_MJ_CLEANUP I/O function code.
NTSTATUS cbm_execute_close (IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
 Execute IRPs containing the IRP_MJ_CLOSE I/O function code.
NTSTATUS cbm_devicecontrol (IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
 Services IOCTLs.
NTSTATUS cbm_execute_devicecontrol (IN PDEVICE_EXTENSION Pdx, IN PIRP Irp)
 Executes IOCTLs.
BOOLEAN cbm_isr (IN PKINTERRUPT Interrupt, IN PVOID Pdx)
 Interrupt Service Routine (ISR).
VOID cbm_thread (IN PVOID Context)
 The thread function.
NTSTATUS cbm_start_thread (IN PDEVICE_EXTENSION Pdx)
 Start the worker thread.
VOID cbm_stop_thread (IN PDEVICE_EXTENSION Pdx)
 Stop the worker thread.
NTSTATUS ParPortEnumerateOpen (PENUMERATE *EnumStruct)
 Start enumeration of the parallel port drivers.
NTSTATUS ParPortEnumerate (PENUMERATE EnumStruct, PCWSTR *DriverName)
 Get next enumerated parallel port driver.
VOID ParPortEnumerateClose (PENUMERATE EnumStruct)
 Stop enumeration of the parallel port drivers.
NTSTATUS ParPortInit (PUNICODE_STRING ParallelPortName, PDEVICE_EXTENSION Pdx)
 Initialize the knowledge on a parallel port.
NTSTATUS ParPortDeinit (PDEVICE_EXTENSION Pdx)
 Undoes anything ParPortInit has done.
NTSTATUS ParPortAllocate (PDEVICE_EXTENSION Pdx)
 Allocate a parallel port for using it.
NTSTATUS ParPortFree (PDEVICE_EXTENSION Pdx)
 Free a parallel port after using it.
NTSTATUS ParPortSetMode (PDEVICE_EXTENSION Pdx)
 Set the operational mode of the parallel port.
NTSTATUS ParPortUnsetMode (PDEVICE_EXTENSION Pdx)
 Unset the operational mode of the parallel port.
NTSTATUS ParPortSetModeWdm (PDEVICE_EXTENSION Pdx)
 Set the operational mode of the parallel port, WDM Version.
NTSTATUS ParPortUnsetModeWdm (PDEVICE_EXTENSION Pdx)
 Unset the operational mode of the parallel port, WDM Version.
NTSTATUS ParPortAllocInterrupt (PDEVICE_EXTENSION Pdx, PKSERVICE_ROUTINE Isr)
 Allocate an interrupt routine for a parallel port.
NTSTATUS ParPortFreeInterrupt (PDEVICE_EXTENSION Pdx)
 Free an interrupt routine for a parallel port after using it.
NTSTATUS ParPortAllowInterruptIoctl (PDEVICE_EXTENSION Pdx)
 Set registry key such that we can get the interrupt of a parallel port.
NTSTATUS cbm_registry_open_for_read (OUT PHANDLE HandleKey, IN PUNICODE_STRING Path)
 Open a registry path for reading.
NTSTATUS cbm_registry_open_hardwarekey (OUT PHANDLE HandleKey, OUT PDEVICE_OBJECT *Pdo, IN PDEVICE_EXTENSION Pdx)
 Open the hardware key for another driver.
NTSTATUS cbm_registry_close (IN HANDLE HandleKey)
 Close a registry key.
NTSTATUS cbm_registry_close_hardwarekey (IN HANDLE HandleKey, IN PDEVICE_OBJECT Pdo)
 Close a hardware registry key.
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_registry_write_ulong (IN HANDLE HandleKey, IN PCWSTR KeyName, IN ULONG Value)
 Write a ULONG value out of a registry key.
NTSTATUS CbmOpenDeviceRegistryKey (IN PDEVICE_OBJECT a, IN ULONG b, IN ACCESS_MASK c, OUT PHANDLE d)
 Stub for a function.
ULONG CbmGetCurrentProcessorNumber (VOID)
 Wrapper for KeGetCurrentProcessorNumber().
ULONG CbmGetNumberProcessors (VOID)
VOID CLI (VOID)
 Stop interrupts with CLI assembler command.
VOID STI (VOID)
 Restart interrupts with STI assembler command.


Detailed Description

Windows-specific definitions for the opencbm driver.

**************************************************************

Author:
Spiro Trikaliotis
Version:
Id
arch_cbm_driver.h,v 1.10 2006/03/10 18:26:51 trikalio Exp


Definition in file arch_cbm_driver.h.


Define Documentation

#define CBMDEVICENAME   L"\\DosDevices\\opencbm"
 

The name if the driver. This name gets a number appended, starting with 0.

Definition at line 39 of file arch_cbm_driver.h.

Referenced by AddDevice().

#define DBG_PROGNAME   "CBM4WIN.SYS"
 

Name of the executable to be debugged

Definition at line 30 of file arch_cbm_driver.h.

#define DVRH_USE_PARPORT_ECP_ADDR   1
 

make sure that ECR_OFFSET and the like use 0x02, and not 0x0402 in parallel.h

Definition at line 25 of file arch_cbm_driver.h.


Typedef Documentation

typedef struct _ARCH_DEVICE_EXTENSION ARCH_DEVICE_EXTENSION
 

The device extension for the device

typedef struct ENUMERATE_WDM * PENUMERATE
 

opaque enumeration structure.

Definition at line 204 of file arch_cbm_driver.h.


Function Documentation

NTSTATUS AddDeviceCommonInit IN PDEVICE_OBJECT  Fdo,
IN PUNICODE_STRING  DeviceName,
IN PCWSTR  ParallelPortName
 

Initialize device object, common to WDM and NT4 driver.

This function initializes the device object, as done in AddDevice() of a WDM driver, or in DriverEntry() for an NT4 driver.

Parameters:
Fdo Pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver.
DeviceName Pointer to the name of the device.
ParallelPortName Pointer to the name of the parallel port driver which this device will use.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
This function performs the following steps:
1. Initialize the Pdx
2. Initialize the Queue inside of the Pdx
3. Initialize the operating mode of the Fdo (Buffered, Direct, Neither)
4. Get the information from the parallel port
5. Start the Worker Thread
6. Log either success or failure

Definition at line 277 of file libcommon/init.c.

References cbm_start_thread(), cbm_startio(), DBG_ERROR, DBG_PREFIX, FUNC_ENTER, LogErrorOnly, LogErrorString, ParPortInit(), and QueueInit().

Referenced by AddDevice().

NTSTATUS cbm_cleanup IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp
 

Services IRPs containing the IRP_MJ_CLEANUP I/O function code.

Services IRPs containing the IRP_MJ_CREATE I/O function code.

Parameters:
Fdo Pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
The driver's DriverEntry routine has stored this routine's address in DriverObject->MajorFunction[IRP_MJ_CLEANUP].

Definition at line 45 of file cleanup.c.

References FUNC_ENTER, QueueCleanup(), and QueueCompleteIrp().

Referenced by DriverCommonInit().

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.

Services IRPs containing the IRP_MJ_CREATE or IRP_MJ_CLOSE I/O function code.

Parameters:
Fdo Pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.
The driver's DriverEntry routine has stored this routine's address in DriverObject->MajorFunction[IRP_MJ_CREATE] and DriverObject->MajorFunction[IRP_MJ_CLOSE].

Generally, all Dispatch routines execute in an arbitrary thread context at IRQL PASSIVE_LEVEL, but there are exceptions.

Definition at line 48 of file libcommon/openclose.c.

References DBG_ERROR, DBG_IRPPATH_COMPLETE, DBG_IRPPATH_PROCESS, DBG_PREFIX, FUNC_ENTER, PERF_EVENT_CLOSE_QUEUE, PERF_EVENT_OPEN_QUEUE, QueueCompleteIrp(), and QueueStartPacket().

Referenced by DriverCommonInit().

NTSTATUS cbm_devicecontrol IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp
 

Services IOCTLs.

Services IRPs containing the IRP_MJ_DEVICE_CONTROL I/O function code.

Parameters:
Fdo Pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values:
STATUS_SUCCESS - Success.
STATUS_PENDING - Request pending.
STATUS_BUFFER_TOO_SMALL - Buffer too small.
STATUS_INVALID_PARAMETER - Invalid io control request.
The driver's DriverEntry routine stored this routine's address in DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL].

Generally, all Dispatch routines execute in an arbitrary thread context at IRQL PASSIVE_LEVEL, but there are exceptions.

Definition at line 115 of file ioctl.c.

References CBMCTRL_CLEAR_EOI, CBMCTRL_CLOSE, CBMCTRL_GET_EOI, CBMCTRL_I_INSTALL, CBMCTRL_IEC_POLL, CBMCTRL_IEC_RELEASE, CBMCTRL_IEC_SET, CBMCTRL_IEC_SETRELEASE, CBMCTRL_IEC_WAIT, CBMCTRL_LISTEN, CBMCTRL_OPEN, CBMCTRL_PARBURST_READ, CBMCTRL_PARBURST_READ_TRACK, CBMCTRL_PARBURST_WRITE, CBMCTRL_PARBURST_WRITE_TRACK, CBMCTRL_PARPORT_LOCK, CBMCTRL_PARPORT_UNLOCK, CBMCTRL_PP_READ, CBMCTRL_PP_WRITE, CBMCTRL_RESET, CBMCTRL_TALK, CBMCTRL_UNLISTEN, CBMCTRL_UNTALK, CBMCTRL_UPDATE, DBG_ERROR, DBG_IRPPATH_PROCESS, DBG_PREFIX, FUNC_ENTER, PERF_EVENT_IOCTL_QUEUE, QueueCompleteIrp(), and QueueStartPacket().

Referenced by DriverCommonInit().

NTSTATUS cbm_execute_close IN PDEVICE_EXTENSION  Pdx,
IN PIRP  Irp
 

Execute IRPs containing the IRP_MJ_CLOSE I/O function code.

Executes IRPs containing the IRP_MJ_CLOSE I/O function code.

Parameters:
Pdx Pointer to a DEVICE_EXTENSION structure.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.

Definition at line 167 of file libcommon/openclose.c.

References cbm_unlock_parport(), DBG_ASSERT, DBG_IRPPATH_COMPLETE, DBG_IRPPATH_PROCESS, FUNC_ENTER, PERF_EVENT_CLOSE_EXECUTE, and QueueCompleteIrp().

Referenced by cbm_startio().

NTSTATUS cbm_execute_createopen IN PDEVICE_EXTENSION  Pdx,
IN PIRP  Irp
 

Execute IRPs containing the IRP_MJ_CREATEOPEN I/O function code.

Executes IRPs containing the IRP_MJ_CREATEOPEN I/O function code.

Parameters:
Pdx Pointer to a DEVICE_EXTENSION structure.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.

Definition at line 118 of file libcommon/openclose.c.

References cbm_lock_parport(), DBG_ASSERT, DBG_IRPPATH_COMPLETE, DBG_IRPPATH_EXECUTE, FUNC_ENTER, PERF_EVENT_OPEN_EXECUTE, and QueueCompleteIrp().

Referenced by cbm_startio().

NTSTATUS cbm_execute_devicecontrol IN PDEVICE_EXTENSION  Pdx,
IN PIRP  Irp
 

Executes IOCTLs.

Executes IRPs containing the IRP_MJ_DEVICE_CONTROL I/O function code.

Parameters:
Pdx Pointer to the DEVICE_EXTENSION structure.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values:
STATUS_SUCCESS - Success.
STATUS_BUFFER_TOO_SMALL - Buffer too small.
This function does not perform any validity checks on the input and output buffer! This should already been done in cbm_devicecontrol.

Definition at line 342 of file ioctl.c.

References cbm_init_registry(), cbm_install(), cbm_lock(), cbm_unlock(), CBMCTRL_CLEAR_EOI, CBMCTRL_CLOSE, CBMCTRL_GET_EOI, CBMCTRL_I_INSTALL, CBMCTRL_IEC_POLL, CBMCTRL_IEC_RELEASE, CBMCTRL_IEC_SET, CBMCTRL_IEC_SETRELEASE, CBMCTRL_IEC_WAIT, CBMCTRL_LISTEN, CBMCTRL_OPEN, CBMCTRL_PARBURST_READ, CBMCTRL_PARBURST_READ_TRACK, CBMCTRL_PARBURST_WRITE, CBMCTRL_PARBURST_WRITE_TRACK, CBMCTRL_PARPORT_LOCK, CBMCTRL_PARPORT_UNLOCK, CBMCTRL_PP_READ, CBMCTRL_PP_WRITE, CBMCTRL_RESET, CBMCTRL_TALK, CBMCTRL_UNLISTEN, CBMCTRL_UNTALK, CBMCTRL_UPDATE, cbmiec_clear_eoi(), cbmiec_close(), cbmiec_get_eoi(), cbmiec_iec_poll(), cbmiec_iec_release(), cbmiec_iec_set(), cbmiec_iec_setrelease(), cbmiec_iec_wait(), cbmiec_listen(), cbmiec_open(), cbmiec_pp_read(), cbmiec_pp_write(), cbmiec_reset(), cbmiec_talk(), cbmiec_unlisten(), cbmiec_untalk(), DBG_ASSERT, DBG_ERROR, DBG_IRPPATH_COMPLETE, DBG_IRPPATH_EXECUTE, DBG_PREFIX, FUNC_ENTER, INPUTVALUE, OUTPUTVALUE, PERF_EVENT_IOCTL_EXECUTE, and QueueCompleteIrp().

Referenced by cbm_startio().

NTSTATUS cbm_execute_readwrite IN PDEVICE_EXTENSION  Pdx,
IN PIRP  Irp
 

Executes reads from or writes to the driver.

Services reads from or writes to the driver

Parameters:
Pdx Pointer to the DEVICE_EXTENSION structure.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
This function does not perform any validity checks on the input and output buffer! This should already been done in cbm_readwrite.

Todo:
Remove this, is this does not make sense.

Definition at line 179 of file readwrite.c.

References cbmiec_raw_read(), cbmiec_raw_write(), DBG_ASSERT, DBG_ERROR, DBG_IRPPATH_EXECUTE, DBG_PREFIX, FUNC_ENTER, PERF_EVENT_READ_EXECUTE, PERF_EVENT_WRITE_EXECUTE, and QueueCompleteIrp().

Referenced by cbm_startio().

VOID cbm_init_registry IN PUNICODE_STRING  RegistryPath,
IN PDEVICE_EXTENSION  Pdx
 

Initialize from registry.

This function initializes some driver settings from the appropriate registry keys.

Parameters:
RegistryPath Pointer to a UNICODE_STRING containing the name of the registry path from which to get the information. If this is NULL, this function uses the same registry path that was given the last time this function was called.
Pdx Pointer to the device extension of the device to be updated.
The RegistryPath parameter can be NULL, but this is only allowed on a second or subsequent call.

Pdx can be NULL, too. If it is NULL, no device-specific data is read at all.

If RegistryPath is not NULL, some memory is allocated. This has to be freed by calling DriverCommonUninit().

Definition at line 56 of file libcommon/init.c.

References cbm_lock_parport(), cbm_registry_close(), cbm_registry_open_for_read(), cbm_registry_read_ulong(), cbmiec_global_init(), cbmiec_set_cabletype(), DBG_ASSERT, FUNC_ENTER, FUNC_LEAVE, and MTAG_SERVKEY.

Referenced by AddDevice(), cbm_execute_devicecontrol(), and DriverCommonInit().

NTSTATUS cbm_install IN PDEVICE_EXTENSION  Pdx,
OUT PCBMT_I_INSTALL_OUT  ReturnBuffer,
IN OUT PULONG  ReturnLength
 

Complete driver installation.

This function performs anything that is needed for completing the driver installation.

Parameters:
Pdx Pointer to the device extension.
ReturnBuffer Pointer to a buffer which will contain the result.
ReturnLength Pointer to a ULONG which contains the length of the ReturnBuffer on entry, and which will contain the length of the written ReturnBuffer on exit.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.
If ReturnLength is smaller then the length of CBMT_I_INSTALL_OUT, then only the the first settings are copied there. This way, a caller can get information even if newer versions have more informations to give.

Definition at line 52 of file install.c.

References CBM_I_DRIVER_INSTALL_0M_NO_INTERRUPT, CBMT_I_INSTALL_OUT_MAKE_VERSION, CBMT_I_INSTALL_OUT_MAKE_VERSION_EX, FUNC_ENTER, and ParPortAllowInterruptIoctl().

Referenced by cbm_execute_devicecontrol().

BOOLEAN cbm_isr IN PKINTERRUPT  Interrupt,
IN PVOID  Pdx
 

Interrupt Service Routine (ISR).

This is the Interrupt Service Routine for the parallel port.

Parameters:
Interrupt,: Pointer to the interrupt object.
Pdx,: The device extension
Returns:
If we are responsible for this interrupt, we return TRUE. If not, we return FALSE and let Windows try other ISRs (if there are any).

Definition at line 39 of file isr.c.

References cbmiec_interrupt().

Referenced by cbm_lock_parport().

NTSTATUS cbm_lock IN PDEVICE_EXTENSION  Pdx  ) 
 

Lock the parallel port for the driver.

This function locks the driver onto the parallel port. This way, no other program or driver can allocate the parallel port and interfere with the communication.

Parameters:
Pdx Pointer to the device extension.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.
Remarks:
A call to cbm_lock() is undone with a call to cbm_unlock().
Note that it is *not* necessary to call this function (or cbm_unlock()) when all communication is done with the handle to opencbm open (that is, between cbm_driver_open() and cbm_driver_close(). You only need this function to pin the driver to the port even when cbm_driver_close() is to be executed (for example, because the program terminates).

Definition at line 174 of file lockunlock.c.

References DBG_PREFIX, DBG_PRINT, and FUNC_ENTER.

NTSTATUS cbm_lock_parport IN PDEVICE_EXTENSION  Pdx  ) 
 

Lock the parallel port for the driver.

This function locks the driver onto the parallel port, so we can use the port afterwards.

Parameters:
Pdx Pointer to the device extension.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.
Todo:
As we will try to cope without interrupt, do not handle it as an open failure if we do not succeed!

Definition at line 40 of file lockunlock.c.

References cbm_isr(), cbmiec_init(), cbmiec_release_bus(), DBG_ASSERT, DBG_PREFIX, DBG_PRINT, FUNC_ENTER, ParPortAllocate(), ParPortAllocInterrupt(), ParPortFree(), ParPortFreeInterrupt(), ParPortSetMode(), and ParPortUnsetMode().

Referenced by cbm_execute_createopen(), and cbm_init_registry().

NTSTATUS cbm_readwrite IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp
 

Services reads from or writes to the driver.

Services reads from or writes to the driver

Parameters:
Fdo Pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.
Irp Pointer to an IRP structure that describes the requested I/O operation.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
The driver's DriverEntry routine stored this routine's address in DriverObject->MajorFunction[IRP_MJ_READ] and DriverObject->MajorFunction[IRP_MJ_WRITE].

Generally, all Dispatch routines execute in an arbitrary thread context at IRQL PASSIVE_LEVEL, but there are exceptions.

Definition at line 85 of file readwrite.c.

References DBG_ASSERT, DBG_IRPPATH_PROCESS, FUNC_ENTER, PERF_EVENT_READ_QUEUE, PERF_EVENT_WRITE_QUEUE, QueueCompleteIrp(), and QueueStartPacket().

Referenced by DriverCommonInit().

NTSTATUS cbm_registry_close IN HANDLE  HandleKey  ) 
 

Close a registry key.

This function closes a registry key.

Parameters:
HandleKey The HANDLE of the registry path.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
If the registry key was obtained with a call to cbm_registry_open_hardwarekey(), you must *not* use this function, but use cbm_registry_close_hardwarekey() instead.

Definition at line 231 of file util-reg.c.

References FUNC_ENTER.

Referenced by cbm_init_registry(), and cbm_registry_close_hardwarekey().

NTSTATUS cbm_registry_close_hardwarekey IN HANDLE  HandleKey,
IN PDEVICE_OBJECT  Pdo
 

Close a hardware registry key.

This function closes a registry key pointing to a hardware registry key.

Parameters:
HandleKey The HANDLE of the registry path.
Pdo Pointer to the DEVICE_OBJECT for which we found the hardware key.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

Definition at line 261 of file util-reg.c.

References cbm_registry_close(), and FUNC_ENTER.

Referenced by ParPortAllowInterruptIoctl().

NTSTATUS cbm_registry_open_for_read OUT PHANDLE  HandleKey,
IN PUNICODE_STRING  Path
 

Open a registry path for reading.

This function opens a registry key ("path"). This way, its entries can be read afterwards.

Parameters:
HandleKey Pointer to a HANDLE which will contain the handle to the registry key ("path") on exit
Path Pointer to a UNICODE_STRING which points to the registry key to be opened.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
A call to this function must be balanced with a call to cbm_registry_close().

Todo:
| OBJ_KERNEL_HANDLE

Definition at line 44 of file util-reg.c.

References DBG_PREFIX, FUNC_ENTER, and FUNC_PARAM.

Referenced by cbm_init_registry().

NTSTATUS cbm_registry_open_hardwarekey OUT PHANDLE  HandleKey,
OUT PDEVICE_OBJECT *  Pdo,
IN PDEVICE_EXTENSION  Pdx
 

Open the hardware key for another driver.

This function opens a the "hardware" registry key for the parallel port driver.

Parameters:
HandleKey Pointer to a HANDLE which will contain the handle to the registry key ("path") on exit
Pdo Pointer to the DEVICE_OBJECT for which we found the hardware key.
Pdx The PDX of the driver which is calling this function
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
A call to this function must be balanced with a call to cbm_registry_close_hardwarekey().

Thanks to Doron Holan [MS] for pointing out how to do it (MsgId:<O6weQL8qEHA.3428@TK2MSFTNGP11.phx.gbl> on microsoft.public.development.device.drivers, http://groups.google.com/groups?selm=O6weQL8qEHA.3428%40TK2MSFTNGP11.phx.gbl

Definition at line 96 of file util-reg.c.

References CbmOpenDeviceRegistryKey(), DBG_ASSERT, and FUNC_ENTER.

Referenced by ParPortAllowInterruptIoctl().

NTSTATUS cbm_registry_read_ulong IN HANDLE  HandleKey,
IN PCWSTR  KeyName,
OUT PULONG  Value
 

Read a ULONG value out of a registry key.

This function reads a ULONG value out of the registry.

Parameters:
HandleKey The HANDLE of the registry path.
KeyName A null-terminated wide char string which contains the name of the value to be read.
Value Pointer to a memory location which will hold the return value.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
If the value cannot be read, the return value in *Value will not be changed.

Definition at line 300 of file util-reg.c.

References DBG_PREFIX, FUNC_ENTER, and FUNC_PARAM.

Referenced by cbm_init_registry(), and ParPortAllowInterruptIoctl().

NTSTATUS cbm_registry_write_ulong IN HANDLE  HandleKey,
IN PCWSTR  KeyName,
IN ULONG  Value
 

Write a ULONG value out of a registry key.

This function writes a ULONG value to the registry.

Parameters:
HandleKey The HANDLE of the registry path.
KeyName A null-terminated wide char string which contains the name of the value to be read.
Value The value to be written to that memory entry.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

Definition at line 357 of file util-reg.c.

References DBG_PREFIX, FUNC_ENTER, and FUNC_PARAM.

Referenced by ParPortAllowInterruptIoctl().

NTSTATUS cbm_start_thread IN PDEVICE_EXTENSION  Pdx  ) 
 

Start the worker thread.

This function start the worker thread.

Parameters:
Pdx Pointer to a DEVICE_EXTENSION structure.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.
Todo:
Replace Pdx->QuitThread with a event for quitting

Definition at line 35 of file thread.c.

References cbm_thread(), DBG_ASSERT, DBG_ERROR, DBG_PREFIX, FUNC_ENTER, LogErrorString, and PERF_EVENT_THREAD_START_SCHED.

Referenced by AddDeviceCommonInit().

NTSTATUS cbm_startio IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp
 

Execute an IRP.

This function executes an IRP. Normally, it is called from as StartIo() routine from the QUEUE, but it can be called directly (for example, if FastStart is selected).

Parameters:
Fdo,: Pointer to the DEVICE_OBJECT of the FDO.
Irp,: Pointer to the IRP to be executed.
Returns:
If everything works as expected, this function returns STATUS_SUCCESS. If not, it returns an appropriate error value.

Definition at line 40 of file startio.c.

References cbm_execute_close(), cbm_execute_createopen(), cbm_execute_devicecontrol(), cbm_execute_readwrite(), DBG_ASSERT, DBG_ERROR, DBG_PREFIX, FUNC_ENTER, and PERF_EVENT_STARTIO.

Referenced by AddDeviceCommonInit().

VOID cbm_stop_thread IN PDEVICE_EXTENSION  Pdx  ) 
 

Stop the worker thread.

This function stops the worker thread.

Parameters:
Pdx Pointer to a DEVICE_EXTENSION structure.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

Definition at line 118 of file thread.c.

References DBG_ASSERT, FUNC_ENTER, FUNC_LEAVE, PERF_EVENT_THREAD_STOP_SCHED, and QueueSignal().

Referenced by DriverUnload().

VOID cbm_thread IN PVOID  Context  ) 
 

The thread function.

This function is the function of the thread itself. It polls the QUEUE and executed the IRPs which are on it.

Parameters:
Context Pointer to the thread context. This is a PDX in reality.

Definition at line 166 of file thread.c.

References FUNC_ENTER, FUNC_LEAVE, PERF_EVENT_THREAD_POLL, PERF_EVENT_THREAD_START_EXEC, PERF_EVENT_THREAD_STOP_EXEC, and QueuePoll().

Referenced by cbm_start_thread().

NTSTATUS cbm_unlock IN PDEVICE_EXTENSION  Pdx  ) 
 

Unlock the parallel port for the driver.

This function unlocks the driver from the parallel port. This way, other programs and drivers can allocate the parallel port and do their own communication with whatever device they use.

Parameters:
Pdx Pointer to the device extension.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.
Remarks:
Look at cbm_lock() for an explanation of this function.

Definition at line 203 of file lockunlock.c.

References DBG_PREFIX, DBG_PRINT, and FUNC_ENTER.

NTSTATUS cbm_unlock_parport IN PDEVICE_EXTENSION  Pdx  ) 
 

Unlock the parallel port for the driver.

This function unlocks the driver from the parallel port after the port has been used.

Parameters:
Pdx Pointer to the device extension.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.

Definition at line 123 of file lockunlock.c.

References cbmiec_release_bus(), DBG_ASSERT, DBG_PREFIX, DBG_PRINT, FUNC_ENTER, ParPortFree(), ParPortFreeInterrupt(), and ParPortUnsetMode().

Referenced by cbm_execute_close(), and DriverUnload().

ULONG CbmGetCurrentProcessorNumber VOID   ) 
 

Wrapper for KeGetCurrentProcessorNumber().

See KeGetCurrentProcessorNumber()

This function is needed as KeGetCurrentProcessorNumber() is only defined in NTDDK.H, not in WDM.H. Anyway, for debugging purposes, we need to access it from anywhere..

Definition at line 32 of file processor.c.

NTSTATUS CbmOpenDeviceRegistryKey IN PDEVICE_OBJECT  a,
IN ULONG  b,
IN ACCESS_MASK  c,
OUT PHANDLE  d
 

Stub for a function.

This function is not available on NT4, and it is not needed there, but it is needed for WDM. Because of this, we define it here for cbm4wdm.sys, so that the driver works in either case.

Definition at line 304 of file nt4/PortEnum.c.

References FUNC_ENTER.

Referenced by cbm_registry_open_hardwarekey().

VOID CLI VOID   ) 
 

Stop interrupts with CLI assembler command.

This function stops interrupts on the current CPU by executing a CLI assembler command.

Definition at line 29 of file amd64/clisti.c.

Referenced by cbmiec_block_irq().

NTSTATUS DriverCommonInit IN PDRIVER_OBJECT  Driverobject,
IN PUNICODE_STRING  RegistryPath
 

Perform driver initialization, common to WDM and NT4 driver.

This function is called from the DriverEntry() of either the WDM or the NT4 driver.

Parameters:
Driverobject Pointer to the DRIVER_OBJECT structure given to DriverEntry().
RegistryPath Pointer to a UNICODE_STRING containing the name of the registry path from which to get the information.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.

Definition at line 191 of file libcommon/init.c.

References cbm_cleanup(), cbm_createopenclose(), cbm_devicecontrol(), cbm_init_registry(), cbm_readwrite(), DriverUnload(), FUNC_ENTER, and PERF_INIT.

Referenced by DriverEntry().

VOID DriverCommonUninit VOID   ) 
 

Undo what DriverCommonInit() has done.

This function is called from the DriverUnload() of either the WDM or the NT4 driver.

This function frees memory allocated by cbm_init_registry().

Definition at line 224 of file libcommon/init.c.

References DBGDO, FUNC_ENTER, FUNC_LEAVE, and PERF_SAVE.

Referenced by DriverUnload().

VOID DriverUnload IN PDRIVER_OBJECT  DriverObject  ) 
 

Unload routine of the driver.

DriverUnload performs any operations that are necessary before the system unloads the driver.

Parameters:
DriverObject Caller-supplied pointer to a DRIVER_OBJECT structure. This is the driver's driver object.
A driver's Unload routine executes in a system thread context at IRQL PASSIVE_LEVEL. The driver's DriverEntry routine must store the Unload routine's address in DriverObject->DriverUnload. (If no routine is supplied, this pointer must be NULL.)

Definition at line 179 of file nt4/LoadUnload.c.

References cbm_stop_thread(), cbm_unlock_parport(), DBG_ASSERT, DriverCommonUninit(), FUNC_ENTER, FUNC_LEAVE, and ParPortDeinit().

Referenced by DriverCommonInit().

NTSTATUS ParPortAllocate PDEVICE_EXTENSION  Pdx  ) 
 

Allocate a parallel port for using it.

This function allocates a parallel port, preventing other drivers from accessing it.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
This function has to be balanced with a corresponding ParPortFree() This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 158 of file PortAccess.c.

References DBG_ASSERT, and FUNC_ENTER.

Referenced by cbm_lock_parport().

NTSTATUS ParPortAllocInterrupt PDEVICE_EXTENSION  Pdx,
PKSERVICE_ROUTINE  Isr
 

Allocate an interrupt routine for a parallel port.

This function allocates an interrupt service routine for a parallel port.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
Isr Pointer to the interrupt service routine (ISR) which the caller wants to be installed.
This function has to be balanced with a corresponding ParPortFreeInterrupt()

The parallel port has to be already allocated!

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 618 of file PortAccess.c.

References DBG_ASSERT, DBG_PREFIX, DBG_WARN, FUNC_ENTER, and LogErrorOnly.

Referenced by cbm_lock_parport().

NTSTATUS ParPortAllowInterruptIoctl PDEVICE_EXTENSION  Pdx  ) 
 

Set registry key such that we can get the interrupt of a parallel port.

This function sets some specific registry key which allows us to allocate an interrupt service routine for a parallel port. Without this key, allocating the interrupt is forbidden for Win 2000, XP, and above.

This is not true for NT4.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
This function must be run at IRQL == PASSIVE_LEVEL.

Warning:
This function cannot be used on NT4! In fact, it is unnecessary there.

Definition at line 719 of file PortAccess.c.

References cbm_registry_close_hardwarekey(), cbm_registry_open_hardwarekey(), cbm_registry_read_ulong(), cbm_registry_write_ulong(), DBG_ASSERT, and FUNC_ENTER.

Referenced by cbm_install().

NTSTATUS ParPortDeinit PDEVICE_EXTENSION  Pdx  ) 
 

Undoes anything ParPortInit has done.

This function undoes anything ParPortInit() has done.

Parameters:
Pdx Device extension which will be initialized with the needed knowledge on the parallel port.
This function should be called as part of the unloading process of the driver

One of the purposes of this function is to allow the parallel port driver to be unloaded from memory (via calling ObDereferenceObject()).

This function must be run at IRQL <= DISPATCH_LEVEL.

Definition at line 340 of file PortAccess.c.

References FUNC_ENTER.

Referenced by DriverUnload().

NTSTATUS ParPortEnumerate PENUMERATE  EnumStruct,
PCWSTR *  DriverName
 

Get next enumerated parallel port driver.

This function starts the enumeration process of the parallel port drivers

Parameters:
EnumStruct Pointer to a ENUMERATE structure. This is internal storage for these functions.
DriverName; Pointer to a storage area which will contain the next driver implementing this interface.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.
For enumerating, a caller has to do the following:

Definition at line 197 of file nt4/PortEnum.c.

References DBG_ASSERT, and FUNC_ENTER.

Referenced by DriverEntry().

VOID ParPortEnumerateClose PENUMERATE  EnumStruct  ) 
 

Stop enumeration of the parallel port drivers.

This function stops the enumeration process of the parallel port drivers

Parameters:
EnumStruct Pointer to a ENUMERATE structure, which contains the last enumerated driver
For enumerating, a caller has to do the following:

Definition at line 265 of file nt4/PortEnum.c.

References DBG_ASSERT, DBGDO, FUNC_ENTER, and FUNC_LEAVE.

Referenced by DriverEntry(), and ParPortEnumerateOpen().

NTSTATUS ParPortEnumerateOpen PENUMERATE EnumStruct  ) 
 

Start enumeration of the parallel port drivers.

This function starts the enumeration process of the parallel port drivers

Parameters:
EnumStruct Pointer to a pointer to hold an ENUMERATE structure. This is internal storage for these functions, and it is allocated by this function.
Returns:
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.
For enumerating, a caller has to do the following:

Definition at line 75 of file nt4/PortEnum.c.

References FUNC_ENTER, and MTAG_SENUMERATE.

Referenced by DriverEntry().

NTSTATUS ParPortFree PDEVICE_EXTENSION  Pdx  ) 
 

Free a parallel port after using it.

This function frees a previously allocated parallel port.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
If the parallel port has not been already allocated, this function just returns.

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 196 of file PortAccess.c.

References DBG_ASSERT, and FUNC_ENTER.

Referenced by cbm_lock_parport(), and cbm_unlock_parport().

NTSTATUS ParPortFreeInterrupt PDEVICE_EXTENSION  Pdx  ) 
 

Free an interrupt routine for a parallel port after using it.

This function frees a previously allocated parallel port.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
If the parallel port interrupt has not been already allocated, this function just returns.

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 670 of file PortAccess.c.

References DBG_ASSERT, and FUNC_ENTER.

Referenced by cbm_lock_parport(), and cbm_unlock_parport().

NTSTATUS ParPortInit PUNICODE_STRING  ParallelPortName,
PDEVICE_EXTENSION  Pdx
 

Initialize the knowledge on a parallel port.

This function gets some knowledge on a parallel port, and stores this info into the given DEVICE_EXTENSION.

Parameters:
ParallelPortName UNICODE_STRING which holds the name of the parallel port driver
Pdx Device extension which will be initialized with the needed knowledge on the parallel port.
This function should be called before any other parallel port function is called. Usually, it is done in the driver's AddDevice (WDM) or DriverEntry (WKM, WDM) function.

One of the purposes of this function is to make sure the parallel port driver is not unloaded from memory (via IoGetDeviceObjectPointer()).

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 254 of file PortAccess.c.

References DBG_ASSERT, DBG_PPORT, DBG_PREFIX, DBG_WARN, FUNC_ENTER, MTAG_PPINFO, and _DEVICE_EXTENSION::ParPortPortAddress.

Referenced by AddDeviceCommonInit().

NTSTATUS ParPortSetMode PDEVICE_EXTENSION  Pdx  ) 
 

Set the operational mode of the parallel port.

This function sets the operational mode of the parallel port.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
This function has to be balanced with a corresponding ParPortUnsetMode()

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 520 of file PortAccessNt4.c.

References cbmiec_udelay(), FUNC_ENTER, ParPortSetModeNt4(), and ParPortSetModeWdm().

Referenced by cbm_lock_parport().

NTSTATUS ParPortSetModeWdm PDEVICE_EXTENSION  Pdx  ) 
 

Set the operational mode of the parallel port, WDM Version.

This function sets the operational mode of the parallel port.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
This function has to be balanced with a corresponding ParPortUnsetModeWdm()

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 456 of file PortAccess.c.

References DBG_PPORT, DBG_PREFIX, DebugNtStatus(), FUNC_ENTER, and ParPortUnsetMode().

Referenced by ParPortSetMode().

NTSTATUS ParPortUnsetMode PDEVICE_EXTENSION  Pdx  ) 
 

Unset the operational mode of the parallel port.

This function unsets the operational mode of the parallel port.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
This function mustn't be called without a prior call to ParPortSetMode()

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 556 of file PortAccessNt4.c.

References FUNC_ENTER, and ParPortUnsetModeWdm().

Referenced by cbm_lock_parport(), cbm_unlock_parport(), and ParPortSetModeWdm().

NTSTATUS ParPortUnsetModeWdm PDEVICE_EXTENSION  Pdx  ) 
 

Unset the operational mode of the parallel port, WDM Version.

This function unsets the operational mode of the parallel port.

Parameters:
Pdx Pointer to a device extension which contains the DEVICE_OBJECT of the parallel port driver.
This function mustn't be called without a prior call to ParPortSetModeWdm()

This function must be run at IRQL == PASSIVE_LEVEL.

Definition at line 539 of file PortAccess.c.

References DBG_PPORT, DBG_PREFIX, DebugNtStatus(), and FUNC_ENTER.

Referenced by ParPortUnsetMode().

VOID STI VOID   ) 
 

Restart interrupts with STI assembler command.

This function stops interrupts on the current CPU by executing a STI assembler command.

Definition at line 39 of file amd64/clisti.c.

Referenced by cbmiec_release_irq().


Generated on Sun Apr 30 18:46:02 2006 for opencbm by  doxygen 1.4.2