// I2cAnalyzerDevice.cpp
//
// Generated by DriverWizard 3.2.0 (Build 2485)
// Requires DDK and DriverWorks
// File created on 7/27/2009
//
// This source file contains the implementation of a subclass of KDevice.
// WDM drivers implement a subclass of KPnpDevice and override member
// functions to handle requests (IRPs) from the system.
//
#include <vdw.h>
#include <kusb.h>
#include <kusbbusintf.h>
#include "I2cAnalyzerDriver.h"
#include "I2cAnalyzerDevice.h"
#include "..\\intrface.h"
#pragma hdrstop("I2cAnalyzer.pch")
// Global driver trace object
// TODO: Use KDebugOnlyTrace if you want trace messages
// to appear only in checked builds. Use KTrace if
// you want trace messages to always appear. Call
// method SetOutputLevel to set the output threshold.
extern KDebugOnlyTrace T;
///////////////////////////////////////////////////////////////////////////////////////////////////
// I2cAnalyzerDevice::I2cAnalyzerDevice
// This is the constructor for the class representing the Functional
// Device Object, or FDO. It is derived from KPnpDevice, which builds
// in automatic dispatching of subfunctions of IRP_MJ_POWER and IRP_MJ_PNP
// to virtual member functions.
// The object being constructed contains a data member (m_Lower) of type
// KPnpLowerDevice. By initializing it, the driver binds the FDO to the
// PDO and creates an interface to the upper edge of the system class driver.
//
// Arguments:
// IN Pdo
// Physical Device Object. This is a pointer to a system
// device object that represents the physical device.
//
// IN Unit
// Unit number to append to the device's base device name
// to distinguish multiple units of this device type.
//
// Return Value:
// none
//
I2cAnalyzerDevice::I2cAnalyzerDevice(PDEVICE_OBJECT Pdo, ULONG Unit) :
KPnpDevice(Pdo, &GUID_DEVINTERFACE_I2CANALYZER)
{
if (!NT_SUCCESS(m_ConstructorStatus))
{
T.Trace(TraceError, __FUNCTION__": Failed to create device I2cAnalyzerDevice"
" unit number %d status %x\n", Unit, m_ConstructorStatus);
ASSERT(FALSE);
return;
}
// Initialize the lower device
m_Lower.Initialize(this, Pdo);
// Initialize the interface object. The wizard generates code
// to support a single interface. You may create and add additional
// interfaces. By default, the wizard uses InterfaceNumber 0 (the
// first interface descriptor), ConfigurationValue 1 (the first
// configuration descriptor), and initial interface alternate
// setting of 0. If your device has multiple interfaces or alternate
// settings for an interface, you can add additional KUsbInterface
// objects or adjust the parameters passed to this function.
m_Interface.Initialize(
m_Lower, //KUsbLowerDevice
0, //InterfaceNumber
1, //ConfigurationValue
0 //Initial Interface Alternate Setting
);
// Initialize each Pipe object
Ep1In.Initialize(m_Lower, 0x81); //16);
Ep1Out.Initialize(m_Lower, 0x01); // 16);
Ep2In.Initialize(m_Lower, 0x82); //, 4096); //64);
Ep3Out.Initialize(m_Lower, 0x03); //, 4096); //64);
#if (_WDM_ && (WDM_MAJORVERSION > 1 ||((WDM_MAJORVERSION == 1) && (WDM_MINORVERSION >= 0x20))))
// Initialize USB direct client access interface
if (STATUS_SUCCESS == m_BusIntf.Initialize(m_Lower.TopOfStack()))
m_fBusIntfAvailable = TRUE;
else
m_fBusIntfAvailable = FALSE;
#endif
// Inform the base class of the lower edge device object
SetLowerDevice(&m_Lower);
// Initialize the PnP Policy settings to the "standard" policy
SetPnpPolicy();
// TODO: Customize the PnP Policy for this device by setting
// flags in m_Policies.
// Initialize the Power Policy settings to the "standard" policy
SetPowerPolicy();
// TODO: Customize the Power Policy for this device by setting
// flags in m_PowerPolicies.
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// I2cAnalyzerDevice::~I2cAnalyzerDevice
// This is the destructor for the class.
//
// Arguments:
// none
//
// Return Value:
// none
//
I2cAnalyzerDevice::~I2cAnalyzerDevice()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// I2cAnalyzerDevice::DefaultPnp
// Default handler for IRP_MJ_PNP.
// This routine just passes the IRP through to the lower device. IRPs
// that correspond to any virtual members of KpnpDevice that handle
// minor functions of IRP_MJ_PNP and that are not overridden get
// passed to this routine.
//
// Arguments:
// IN I
// the plug and play IRP
//
// Return Value:
// NTSTATUS
// Result returned from lower device
//
NTSTATUS I2cAnalyzerDevice::DefaultPnp(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
T << I;
I.ForceReuseOfCurrentStackLocationInCalldown();
NTSTATUS status = m_Lower.PnpCall(this, I);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// I2cAnalyzerDevice::DefaultPower
// Default handler for IRP_MJ_POWER.
// This routine just passes the IRP through to the lower device. IRPs
// that correspond to any virtual members of KpnpDevice that handle
// minor functions of IRP_MJ_POWER and that are not overridden get
// passed to this routine.
//
// Arguments:
// IN I
// the power IRP
//
// Return Value:
// NTSTATUS
// Result returned from lower device
//
NTSTATUS I2cAnalyzerDevice::DefaultPower(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
T << I;
I.IndicatePowerIrpProcessed();
I.CopyParametersDown();
NTSTATUS status = m_Lower.PnpPowerCall(this, I);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// I2cAnalyzerDevice::SystemControl
// Default handler for IRP_MJ_SYSTEM_CONTROL.
// This routine just passes the IRP through to the next device since
// this driver is not a WMI provider.
//
// Arguments:
// IN I
// the system control (WMI) IRP
//
// Return Value:
// NTSTATUS
// Result returned from lower device
//
NTSTATUS I2cAnalyzerDevice::SystemControl(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
T << I;
NTSTATUS status = STATUS_SUCCESS;
I.ForceReuseOfCurrentStackLocationInCalldown();
status = m_Lower.PnpCall(this, I);
T.Trace(TraceInfo, __FUNCTION__"--. IRP %p, STATUS %x\n", I, status);
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// I2cAnalyzerDevice::OnStartDevice
// Handler for IRP_MJ_PNP subfcn IRP_MN_START_DEVICE.
// Initialize the hardware device. Typically, the driver initializes
// physical resources here. Call I.AllocatedResources() for a list
// of the raw resources that the system has assigned to the device,
// or I.TranslatedResources() for the translated resource list.
//
// Arguments:
// IN I
// the start device IRP
//
// Return Value:
// NTSTATUS
//
NTSTATUS I2cAnalyzerDevice::OnStartDevice(KIrp I)
{
T.Trace(TraceInfo, __FUNCTION__"++. IRP %p\n", I);
NTSTATUS status = STATUS_SUCCESS;
I.Information() = 0;
status = STATUS_UNSUCCESSFUL;
AC_STATUS acStatus = AC_SUCCESS;
// By default, the wizard passes a ConfigurationValue of 1 to
// ActivateConfiguration(). This corresponds to the first configuration
// that the device reports in its configuration descriptor. If the device
// supports multiple configurations, pass the appropriate
// ConfigurationValue of the configuration to activate here.
acStatus = m_Lower.ActivateConfiguration(
1 // ConfigurationValue 1 (the first configuration)
评论0