Комбинированное звуковое USB-устройство с функциями автономного MP3-плеера и поддержкой Bluetooth

if (bBreakOnEntry) DbgBreakPoint();// If requested, break into debugger

#endif

LoadRegistryParameters(Params);// Load driver data members from the registry}

m_Unit = 0;

return STATUS_SUCCESS;}

void AT91UsbMassStorage::LoadRegistryParameters(KRegistryKey &Params){

m_bBreakOnEntry = FALSE;

Params.QueryValue(L"BreakOnEntry", &m_bBreakOnEntry);

t &l

t;< "m_bBreakOnEntry loaded from registry, resulting value: [" << m_bBreakOnEntry << "]\n";}

// End INIT section

#pragma code_seg()

NTSTATUS AT91UsbMassStorage::AddDevice(PDEVICE_OBJECT Pdo){

t << "AddDevice called\n";

AT91UsbMassStorageDevice * pDevice = new (

static_cast<PCWSTR>(KUnitizedName(L"AT91UsbMassStorageDevice", m_Unit)),

FILE_DEVICE_UNKNOWN,

NULL,

0,

DO_DIRECT_IO)

AT91UsbMassStorageDevice(Pdo, m_Unit);

if (pDevice == NULL){

t << "Error creating device AT91UsbMassStorageDevice"

<< (ULONG) m_Unit << EOL;

return STATUS_INSUFFICIENT_RESOURCES;}

NTSTATUS status = pDevice->ConstructorStatus();

if ( !NT_SUCCESS(status) ){

t << "Error constructing device AT91UsbMassStorageDevice"

<< (ULONG) m_Unit << " status " << (ULONG) status << EOL;

delete pDevice;}

else{m_Unit++;}

return status;}

AT91UsbMassStorage.h

// AT91UsbMassStorage.h // Generated by DriverWizard version DriverStudio 2.0.0 (Build 526)

// Requires Compuware's DriverWorks classes

#ifndef AT91UsbMassStorage_h

#define AT91UsbMassStorage_h

#define EOL "\n"

extern Trace t; // Global driver trace object

class AT91UsbMassStorage : public KDriver{

SAFE_DESTRUCTORS

public:

virtual NTSTATUS DriverEntry(PUNICODE_STRING RegistryPath);

virtual NTSTATUS AddDevice(PDEVICE_OBJECT Pdo);

void LoadRegistryParameters(KRegistryKey &Params);

int m_Unit;

// The following data members are loaded from the registry during DriverEntry

ULONG m_bBreakOnEntry;};

#endif // AT91UsbMassStorage_h

AT91UsbMassStorageDevice.cpp

// AT91UsbMassStorageDevice.cpp // Implementation of AT91UsbMassStorageDevice device class

// Generated by DriverWizard version DriverStudio 2.0.0 (Build 526)

// Requires Compuware's DriverWorks classes

#pragma warning(disable:4065) // Allow switch statement with no cases

#include <vdw.h>

#include <kusb.h>

#include " \AT91UsbMassStorageDeviceinterface.h"

#include "AT91UsbMassStorage.h"

#include "AT91UsbMassStorageDevice.h"

#pragma hdrstop("AT91UsbMassStorage.pch")

extern KTrace t; // Global driver trace object

GUID AT91UsbMassStorageDevice_Guid = AT91UsbMassStorageDevice_CLASS_GUID;

AT91UsbMassStorageDevice::AT91UsbMassStorageDevice(PDEVICE_OBJECT Pdo, ULONG Unit) :

KPnpDevice(Pdo, &AT91UsbMassStorageDevice_Guid){

t << "Entering AT91UsbMassStorageDevice::AT91UsbMassStorageDevice (constructor)\n";

// Check constructor status

if ( ! NT_SUCCESS(m_ConstructorStatus) ){return;}

m_Unit = Unit;// Remember our unit number

m_Lower.Initialize(this, Pdo);// Initialize the lower device

m_Interface.Initialize(

m_Lower, //KUsbLowerDevice

0, //InterfaceNumber

1, //ConfigurationValue

0 //Initial Interface Alternate Setting);

SetLowerDevice(&m_Lower);

SetPnpPolicy();}

AT91UsbMassStorageDevice::~AT91UsbMassStorageDevice()

{t << "Entering AT91UsbMassStorageDevice::~AT91UsbMassStorageDevice() (destructor)\n";}

char *PNPMinorFunctionName(ULONG mn){

static char* minors[] = {

"IRP_MN_START_DEVICE",

"IRP_MN_QUERY_REMOVE_DEVICE",

"IRP_MN_REMOVE_DEVICE",

"IRP_MN_CANCEL_REMOVE_DEVICE",

"IRP_MN_STOP_DEVICE",

"IRP_MN_QUERY_STOP_DEVICE",

"IRP_MN_CANCEL_STOP_DEVICE",

"IRP_MN_QUERY_DEVICE_RELATIONS",

"IRP_MN_QUERY_INTERFACE",

"IRP_MN_QUERY_CAPABILITIES",

"IRP_MN_QUERY_RESOURCES",

"IRP_MN_QUERY_RESOURCE_REQUIREMENTS",

"IRP_MN_QUERY_DEVICE_TEXT",

"IRP_MN_FILTER_RESOURCE_REQUIREMENTS",

"<unknown minor function>",

"IRP_MN_READ_CONFIG",

"IRP_MN_WRITE_CONFIG",

"IRP_MN_EJECT",

"IRP_MN_SET_LOCK",

"IRP_MN_QUERY_ID",

"IRP_MN_QUERY_PNP_DEVICE_STATE",

"IRP_MN_QUERY_BUS_INFORMATION",

"IRP_MN_DEVICE_USAGE_NOTIFICATION",

"IRP_MN_SURPRISE_REMOVAL"};

if (mn > IRP_MN_SURPRISE_REMOVAL)return "<unknown minor function>";

else return minors[mn];}

NTSTATUS AT91UsbMassStorageDevice::DefaultPnp(KIrp I){

t << "Entering AT91UsbMassStorageDevice::DefaultPnp with IRP minor function="

<< PNPMinorFunctionName(I.MinorFunction()) << EOL;

I.ForceReuseOfCurrentStackLocationInCalldown();

return m_Lower.PnpCall(this, I);}

NTSTATUS AT91UsbMassStorageDevice::DefaultPower(KIrp I){

t << "Entering AT91UsbMassStorageDevice::DefaultPower\n";

I.IndicatePowerIrpProcessed();

I.CopyParametersDown();

return m_Lower.PnpPowerCall(this, I);}

NTSTATUS AT91UsbMassStorageDevice::SystemControl(KIrp I){

t << "Entering AT91UsbMassStorageDevice::SystemControl\n";

I.ForceReuseOfCurrentStackLocationInCalldown();

return m_Lower.PnpCall(this, I);}

NTSTATUS AT91UsbMassStorageDevice::OnStartDevice(KIrp I){

t << "Entering AT91UsbMassStorageDevice::OnStartDevice\n";

NTSTATUS status = STATUS_UNSUCCESSFUL;

AC_STATUS acStatus = AC_SUCCESS;

I.Information() = 0;

acStatus = m_Lower.ActivateConfiguration(1);// ConfigurationValue 1 (the first configuration)

switch (acStatus){

case AC_SUCCESS:t << "USB Configuration OK\n";

status = STATUS_SUCCESS;break;

case AC_COULD_NOT_LOCATE_INTERFACE:t << "Could not locate interface\n";break;

case AC_COULD_NOT_PRECONFIGURE_INTERFACE:

t << "Could not get configuration descriptor\n";break;

case AC_CONFIGURATION_REQUEST_FAILED:

t << "Board did not accept configuration URB\n";break;

case AC_FAILED_TO_INITIALIZE_INTERFACE_OBJECT:

t << "Failed to initialize interface object\n";break;

case AC_FAILED_TO_GET_DESCRIPTOR:t << "Failed to get device descriptor\n";break;

case AC_FAILED_TO_OPEN_PIPE_OBJECT:status = STATUS_SUCCESS;

t << "Failed to open pipe object\n";break;

default:t << "Unexpected error activating USB configuration\n";break;}

return status; // base class completes the IRP}

Страница:  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15 
 16  17  18  19  20  21  22  23  24  25 


Другие рефераты на тему «Программирование, компьютеры и кибернетика»:

Поиск рефератов

Последние рефераты раздела

Copyright © 2010-2024 - www.refsru.com - рефераты, курсовые и дипломные работы