📄 device.h
字号:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1998 Microsoft Corporation
Module Name:
device.h
Abstract:
This file contains the IrDA Serial IR device object data types for
maintaining device state, synchronization, send and recv buffers.
This is provided as a sample to platform writers and is expected
to be able to be used without modification on most (if not all)
hardware platforms.
Functions:
Notes:
--*/
#ifndef _IR_DEVICE_H_
#define _IR_DEVICE_H_
//
// RX_BUFFER - Maintain NDIS receive packets and buffers to indicate
// receive data to the protocol.
//
typedef struct _RX_BUFFER
{
LIST_ENTRY Linkage;
PNDIS_PACKET pPacket;
DWORD cbData;
DWORD cbBuffer;
LPBYTE pbBuffer;
} RX_BUFFER, *PRX_BUFFER;
//
// RX_PROCESS_STATE - States for receive finite state machine.
//
typedef enum _RCV_PROCESS_STATE
{
RX_STATE_READY = 0,
RX_STATE_BOF,
RX_STATE_IN_ESC,
RX_STATE_RX,
RX_STATE_SHUTDOWN
} RX_PROCESS_STATE;
//
// IR_DEVICE - Maintain IR device specific information for each adapter.
//
typedef struct _IR_DEVICE
{
//
// Spinlock to serialize access to this device. Need to get spin lock
// when doing the following operations:
// 1) Setting speed of dongle.
// 2) Changing fMediaBusy flag.
// 3) Changing dwCommMask and calling SetCommMask.
// 4) Modifying send queue.
// 5) Modifying recv queues.
// 6) Changing fMinTATRequired flag.
//
NDIS_SPIN_LOCK slDevice;
//
// Handle which the NDIS wrapper associates with this adapter.
//
NDIS_HANDLE hNdisAdapter;
//
// Use the thread handles to ensure threads are indeed shutdown.
//
HANDLE hRxThread;
HANDLE hTxThread;
//
// Handle to serial object, serial port #, and serial object device
// control block structure. CommMask to gather errors...
//
HANDLE hSerial;
DWORD dwCommMask;
DWORD dwPort;
DCB Dcb;
//
// Dongle interface and capabilities. fIntIR is TRUE if we are using
// an internal IR transceiver.
//
IR_TRANSCEIVER_TYPE tTransceiver;
BOOL fIntIR;
DONGLE_INTERFACE IDongle;
DONGLE_CAPS capsDongle;
//
// This is a combination of speed mask:
// 1) dongle caps.
// 2) from registry - if registy key not present - ALL_SLOW_IR_SPEEDS.
// 3) from UART - GetCommProperties.
//
DWORD dwSupportedSpeedsMask;
//
// Current baud rate. This is pointer into the v_rgSupportedBaudRates
// array indicating the current baud rate.
//
const BAUDRATE_INFO *pCurrBaud;
//
// Maintain statistical debug info.
//
DWORD cPacketsRx;
DWORD cPacketsRxDropped;
DWORD cPacketsRxOverflow;
DWORD cPacketsTx;
DWORD cPacketsTxDropped;
#ifdef DEBUG
// Statistical info for media busy.
// Cleared in set media busy - valid in query media busy.
DWORD cMediaBusyRxErrs;
DWORD cMediaBusyRxBytes;
#endif // DEBUG
//
// Media busy. The protocol will call NdisRequest (SetInformation) to
// set the media busy flag to FALSE. The miniport will set the flag
// to TRUE when either a receive error (overrun, ...) occurs or bytes are
// received.
//
BOOL fMediaBusy;
//
// Buffers and sync event for sending data.
//
HANDLE hSendEvent;
LPBYTE pSendBuf;
DWORD cbSendBuf;
PNDIS_PACKET pSendHead;
PNDIS_PACKET pSendTail;
PNDIS_PACKET pSendActive;
//
// TAT:
// Indicate whether a time delay - minimum turn around time (TAT) - is
// required. A TAT delay is required after receiving the last byte
// of a frame from another station and before sending the first byte
// of our frame.
// This variable is initially set to TRUE. After a send occurs, this
// var is set to FALSE, when data is received, set to TRUE.
//
BOOL fMinTATRequired;
//
// Packets, buffers, etc. for receiving data.
//
// Protocol can retain ownership of up to 8 NDIS packets, and
// we can be receiving a packet while the protocol owns 8.
#define NUM_RX_BUFFERS 9
NDIS_HANDLE hRxPacketPool;
NDIS_HANDLE hRxBufferPool;
LIST_ENTRY RxBufFree;
LIST_ENTRY RxBufPending;
//
// Buffers, counts, index and state for reading from serial.
//
// Buffer and allocated size of buffer.
LPBYTE lpRxBuf;
DWORD cbRxBuf;
// Number of valid bytes in lpRxBuf.
DWORD cbRxNumBytes;
// Index to next byte to read.
DWORD iRxCurrByte;
// Maintain state of receive frame.
RX_PROCESS_STATE RxState;
} IR_DEVICE, *PIR_DEVICE;
#endif // _IR_DEVICE_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -