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

#include "AT91UsbSounCardDevice.h"

#pragma hdrstop("AT91UsbSounCard.pch")

extern KTrace t;// Global driver trace object

GUID AT91UsbSounCardDevice_Guid = AT91UsbSounCardDevice_CLASS_GUID;

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

KPnpDevice(Pdo, &AT91UsbSounCardDevice_Guid){

t << "Entering AT91UsbSou

nCardDevice::AT91UsbSounCardDevice (constructor)\n";

if ( ! NT_SUCCESS(m_ConstructorStatus) )// Check constructor status

{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

);// Initialize each Pipe object

SetLowerDevice(&m_Lower);// Inform the base class of the lower edge device object

SetPnpPolicy();// Initialize the PnP Policy settings to the "standard" policy

SetPowerPolicy();// Initialize the Power Policy settings to the "standard" policy}

AT91UsbSounCardDevice::~AT91UsbSounCardDevice()

{t << "Entering AT91UsbSounCardDevice::~AT91UsbSounCardDevice() (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 AT91UsbSounCardDevice::DefaultPnp(KIrp I){

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

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

I.ForceReuseOfCurrentStackLocationInCalldown();

return m_Lower.PnpCall(this, I);}

NTSTATUS AT91UsbSounCardDevice::DefaultPower(KIrp I) {

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

I.IndicatePowerIrpProcessed();

I.CopyParametersDown();

return m_Lower.PnpPowerCall(this, I);}

NTSTATUS AT91UsbSounCardDevice::SystemControl(KIrp I){

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

I.ForceReuseOfCurrentStackLocationInCalldown();

return m_Lower.PnpCall(this, I);}

NTSTATUS AT91UsbSounCardDevice::OnStartDevice(KIrp I){

t << "Entering AT91UsbSounCardDevice::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}

NTSTATUS AT91UsbSounCardDevice::OnStopDevice(KIrp I){

NTSTATUS status = STATUS_SUCCESS;

t << "Entering AT91UsbSounCardDevice::OnStopDevice\n";

m_Lower.DeActivateConfiguration();

return status;

UNREFERENCED_PARAMETER(I);}

NTSTATUS AT91UsbSounCardDevice::OnRemoveDevice(KIrp I){

t << "Entering AT91UsbSounCardDevice::OnRemoveDevice\n";

m_Lower.ReleaseResources();

return STATUS_SUCCESS;

UNREFERENCED_PARAMETER(I);}

NTSTATUS AT91UsbSounCardDevice::OnDevicePowerUp(KIrp I){

NTSTATUS status = STATUS_SUCCESS;

t << "Entering AT91UsbSounCardDevice::OnDevicePowerUp\n";

return status;

UNREFERENCED_PARAMETER(I);}

NTSTATUS AT91UsbSounCardDevice::OnDeviceSleep(KIrp I){

NTSTATUS status = STATUS_SUCCESS;

t << "Entering AT91UsbSounCardDevice::OnDeviceSleep\n";

return status;

UNREFERENCED_PARAMETER(I);}

NTSTATUS AT91UsbSounCardDevice::Create(KIrp I){

NTSTATUS status;

t << "Entering AT91UsbSounCardDevice::Create, " << I << EOL;

status = I.PnpComplete(this, STATUS_SUCCESS, IO_NO_INCREMENT);

t << "AT91UsbSounCardDevice::Create Status " << (ULONG)status << EOL;

return status;}

NTSTATUS AT91UsbSounCardDevice::Close(KIrp I){

NTSTATUS status;

t << "Entering AT91UsbSounCardDevice::Close, " << I << EOL;

status = I.PnpComplete(this, STATUS_SUCCESS, IO_NO_INCREMENT);

t << "AT91UsbSounCardDevice::Close Status " << (ULONG)status << EOL;

return status;}

NTSTATUS AT91UsbSounCardDevice::CleanUp(KIrp I){

t << "Entering CleanUp, " << I << EOL;

return I.PnpComplete(this, STATUS_SUCCESS);}

NTSTATUS AT91UsbSounCardDevice::Read(KIrp I){

t << "Entering AT91UsbSounCardDevice::Read, " << I << EOL;

if (FALSE)// If (Request is invalid)

{I.Information() = 0;// Invalid parameter in the Read request

return I.PnpComplete(this, STATUS_INVALID_PARAMETER);}

if (I.ReadSize() == 0)// Always ok to read 0 elements.

{I.Information() = 0;

return I.PnpComplete(this, STATUS_SUCCESS);}

NTSTATUS status = STATUS_SUCCESS;

KMemory Mem(I.Mdl());// Declare a memory object

PUCHAR pBuffer = (PUCHAR) Mem.VirtualAddress();// Use the memory object to create a pointer to the caller's buffer

Страница:  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 - рефераты, курсовые и дипломные работы