OpenCBM
Functions
libcommon/init.c File Reference

Common functions für initialization the WDM and NT4 driver. More...

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

Go to the source code of this file.

Functions

VOID cbm_init_registry (IN PUNICODE_STRING RegistryPath, IN PDEVICE_EXTENSION Pdx)
 Initialize from registry. More...
 
VOID cbm_initialize_cable_deferred (IN PDEVICE_EXTENSION Pdx)
 Initialize the cable. More...
 
NTSTATUS DriverCommonInit (IN PDRIVER_OBJECT Driverobject, IN PUNICODE_STRING RegistryPath)
 Perform driver initialization, common to WDM and NT4 driver. More...
 
VOID DriverCommonUninit (VOID)
 Undo what DriverCommonInit() has done. More...
 
NTSTATUS AddDeviceCommonInit (IN PDEVICE_OBJECT Fdo, IN PUNICODE_STRING DeviceName, IN PCWSTR ParallelPortName)
 Initialize device object, common to WDM and NT4 driver. More...
 

Detailed Description

Common functions für initialization the WDM and NT4 driver.



Author
Spiro Trikaliotis

Definition in file libcommon/init.c.

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
FdoPointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver.
DeviceNamePointer to the name of the device.
ParallelPortNamePointer 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 402 of file libcommon/init.c.

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

Referenced by AddDevice().

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
RegistryPathPointer 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.
PdxPointer 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 55 of file libcommon/init.c.

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

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

VOID cbm_initialize_cable_deferred ( IN PDEVICE_EXTENSION  Pdx)

Initialize the cable.

This function initializes the cable. For this, it makes sure the initialization is started asynchronously.

Parameters
PdxPointer to the DEVICE_EXTENSION (unused).

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

References FUNC_ENTER, and FUNC_LEAVE.

Referenced by AddDeviceCommonInit().

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
DriverobjectPointer to the DRIVER_OBJECT structure given to DriverEntry().
RegistryPathPointer 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 315 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 349 of file libcommon/init.c.

References DBGDO, FUNC_ENTER, FUNC_LEAVE, and PERF_SAVE.

Referenced by DriverUnload().