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

PortAccess.c File Reference

Functions for communicating with the parallel port driver. More...

#include <initguid.h>
#include <wdm.h>
#include "cbm_driver.h"

Go to the source code of this file.

Defines

#define DBG_PPORT_VERBOSE(_yy, _xxx, _type)   DBG_PPORT((DBG_PREFIX " --- " #_xxx " = " _type, PnpInfo->_xxx))

Functions

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 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 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.


Detailed Description

Functions for communicating with the parallel port driver.

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

Author:
Spiro Trikaliotis
Version:
Id
PortAccess.c,v 1.28 2006/02/24 12:01:19 trikalio Exp


Definition in file PortAccess.c.


Define Documentation

#define DBG_PPORT_VERBOSE _yy,
_xxx,
_type   )     DBG_PPORT((DBG_PREFIX " --- " #_xxx " = " _type, PnpInfo->_xxx))
 

Verbose output of parallel port parameters

Definition at line 370 of file PortAccess.c.


Function Documentation

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 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 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 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().


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