OpenCBM
Functions
lockunlock.c File Reference

Functions for locking und unlocking the driver onto the parallel port. More...

#include <wdm.h>
#include "cbm_driver.h"
#include "iec.h"
#include "version.h"

Go to the source code of this file.

Functions

NTSTATUS cbm_lock_parport (IN PDEVICE_EXTENSION Pdx)
 Lock the parallel port for the driver. More...
 
NTSTATUS cbm_unlock_parport (IN PDEVICE_EXTENSION Pdx)
 Unlock the parallel port for the driver. More...
 
NTSTATUS cbm_lock (IN PDEVICE_EXTENSION Pdx)
 Lock the parallel port for the driver. More...
 
NTSTATUS cbm_unlock (IN PDEVICE_EXTENSION Pdx)
 Unlock the parallel port for the driver. More...
 

Detailed Description

Functions for locking und unlocking the driver onto the parallel port.



Author
Spiro Trikaliotis

Definition in file lockunlock.c.

Function Documentation

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
PdxPointer 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 179 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
PdxPointer 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 39 of file lockunlock.c.

References cbm_init_registry(), 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_execute_devicecontrol().

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
PdxPointer 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 208 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
PdxPointer 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 128 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(), cbm_execute_createopen(), and DriverUnload().