📄 bufferqueue.h
字号:
/*+++ *******************************************************************\
*
* Copyright and Disclaimer:
*
* ---------------------------------------------------------------
* This software is provided "AS IS" without warranty of any kind,
* either expressed or implied, including but not limited to the
* implied warranties of noninfringement, merchantability and/or
* fitness for a particular purpose.
* ---------------------------------------------------------------
*
* Copyright (c) 2008 Conexant Systems, Inc.
* All rights reserved.
*
\******************************************************************* ---*/
#ifndef _BUFFER_QUEUE_H_
#define _BUFFER_QUEUE_H_
extern "C"
{
#include <wdm.h>
#include <usb.h>
#include <usbdlib.h>
#include <usbdrivr.h>
}
#include <windef.h>
#include "CUSBINTF.H"
class DataTransfer;
typedef struct _BUFFER_ENTRY
{
LIST_ENTRY list_entry;
PBYTE p_buffer;
PIRP p_irp;
PURB p_urb;
DWORD bytes_completed;
READ_CONTEXT read_context;
DataTransfer* p_data_transfer;
DWORD buffer_id;
BOOLEAN buffer_in_list;
}BUFFER_ENTRY, *PBUFFER_ENTRY;
class BufferQueue
{
public:
BufferQueue();
VOID waitForBuffers(DWORD wait_time);
PBUFFER_ENTRY getBuffer();
VOID addBuffer(PBUFFER_ENTRY p_buffer);
VOID cancelWaits();
protected:
KIRQL lock();
VOID unlock(KIRQL irql);
private:
KSPIN_LOCK _spin_lock;
LIST_ENTRY _list_head;
DWORD _count;
KEVENT _list_full_event;
};
/////////////////////////////////////////////////////////////////////////////////////////
//BufferQueue::lock
//
// Lock the list's spin lock in preparation for touching the list
inline KIRQL BufferQueue::lock()
{
KIRQL irql;
KeAcquireSpinLock (&_spin_lock, &irql);
return irql;
}
/////////////////////////////////////////////////////////////////////////////////////////
//BufferQueue::unLock
//
// UnLock the list's spin lock after touching the list
inline VOID BufferQueue::unlock(KIRQL irql)
{
KeReleaseSpinLock (&_spin_lock, irql);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -