📄 e100bexadap.h
字号:
// E100bexAdap.h: interface for the E100bexAdapter class.
//
//=============================================================================
//
// Compuware Corporation
// NuMega Lab
// 9 Townsend West
// Nashua, NH 03060 USA
//
// Copyright (c) 2000 Compuware Corporation. All Rights Reserved.
// Unpublished - rights reserved under the Copyright laws of the
// United States.
//
//=============================================================================
//
// Portions copied from Microsoft Windows 2000 DDK sample driver containing the
// following copyright
//
/****************************************************************************
** COPYRIGHT (C) 1994-1997 INTEL CORPORATION **
** DEVELOPED FOR MICROSOFT BY INTEL CORP., HILLSBORO, OREGON **
** HTTP://WWW.INTEL.COM/ **
** THIS FILE IS PART OF THE INTEL ETHEREXPRESS PRO/100B(TM) AND **
** ETHEREXPRESS PRO/100+(TM) NDIS 5.0 MINIPORT SAMPLE DRIVER **
****************************************************************************/
#if !defined(AFX_E100BEXADAP_H__8534F9A9_27F5_11D3_8F9E_00C04F7445B7__INCLUDED_)
#define AFX_E100BEXADAP_H__8534F9A9_27F5_11D3_8F9E_00C04F7445B7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Characteristics.h"
//-------------------------------------------------------------------------
// Hardware Receive Frame Descriptor (RFD)
//-------------------------------------------------------------------------
// This struct is declared as a public nested type so that
// KNdisSharedReceiveArea<A> can reference A::HW_RFD
typedef struct _HW_RFD {
CB_HEADER_STRUC RfdCbHeader; // Command Block Header Structure
ULONG RfdRbdPointer; // Receive Buffer Descriptor Addr
USHORT RfdActualCount; // Number Of Bytes Received
USHORT RfdSize; // Number Of Bytes In RFD
ETH_RX_BUFFER_STRUC RfdBuffer; // Data buffer in TCB
static ULONG GetBufferLength() // Required by KNdisSharedReceiveArea
{ return MAXIMUM_ETHERNET_PACKET_SIZE; }
static ULONG GetBufferOffset() // Required by KNdisSharedReceiveArea
{ return FIELD_OFFSET(HW_RFD, RfdBuffer); }
} HW_RFD, *PHW_RFD;
///////////////////////////////////////////////////////////////////////
// E100bexAdapter Originally Generated by wizard
//
// This class defines member methods which are passed control on
// NDIS callbacks.
//
// The instances of the class are created automatically
// by KNDIS framework.
//
class E100bexAdapter : public KNdisMiniAdapter
{
// NDIS handlers are called only by the 'friendly' wrapper class
friend class KNdisWrapper<E100bexAdapter>;
// Hardware access is delegated to 'friendly' E100bexCard class
friend class E100bexCard;
// Construction/Destruction
public:
SAFE_DESTRUCTORS
E100bexAdapter();
protected:
~E100bexAdapter();
// NDIS handlers
protected:
// These methods MUST be implemented:
VOID Halt(void);
NDIS_STATUS Initialize(
IN OUT KNdisMedium& Medium,
IN KNdisConfig& Config
);
NDIS_STATUS Reset(OUT PBOOLEAN AddressingReset);
// sending packets
VOID SendPackets(
IN PPNDIS_PACKET PacketArray,
IN UINT NumberOfPackets
);
// checking for bad things
BOOLEAN CheckForHang(void);
// dealing with INTs
VOID DisableInterrupt(void);
VOID EnableInterrupt(void);
VOID HandleInterrupt(void);
VOID Isr(
OUT PBOOLEAN InterruptRecognized,
OUT PBOOLEAN QueueMiniportHandleInterrupt
);
// reclaiming packets
VOID ReturnPacket(IN PNDIS_PACKET Packet);
// processing shutdown
VOID Shutdown(void);
// asynchronous allocation complete
VOID AllocateComplete(
PVOID VirtualAddress,
PNDIS_PHYSICAL_ADDRESS PhysicalAddress,
ULONG Length,
PVOID Context
);
// OID processing (via OID_MAP)
NDIS_STATUS QueryInformation(
IN NDIS_OID Oid,
IN PVOID InformationBuffer,
IN ULONG InformationBufferLength,
OUT PULONG BytesWritten,
OUT PULONG BytesNeeded
);
NDIS_STATUS SetInformation(
IN NDIS_OID Oid,
IN PVOID InformationBuffer,
IN ULONG InformationBufferLength,
OUT PULONG BytesRead,
OUT PULONG BytesNeeded
);
// Standard OID handlers. This should be included in every adapter class declaration.
#include <KNdisOidDefs.h>
// A list of supported OIDs. Inserted by the wizard
static NDIS_OID sm_OID_GEN_SUPPORTED_LIST[];
// Helper methods
public:
// These methods are callbacks required by KNdisSharedReceiveArea to initialize h/w RFD's
VOID DescriptorInitialize(PHW_RFD pHwDesc, PNDIS_PHYSICAL_ADDRESS pPhysAddr);
VOID DescriptorInvalidate(PHW_RFD pHwDesc);
VOID DescriptorComplete(PHW_RFD pHwDesc, PNDIS_PHYSICAL_ADDRESS pPhysAddr);
VOID DescriptorReclaim(PHW_RFD pHwDesc, PNDIS_PHYSICAL_ADDRESS pPhysAddr);
VOID DescriptorInitializeComplete(void);
VOID DescriptorInitializeStart(void);
PUCHAR AlignSharedMemory(PULONG pLowPhysAddr, ULONG Alignment, KNdisSharedMemory& ShMem);
protected:
// Timer binding and callback function used in reset
KNDIS_DECLARE_TIMERCALLBACK(E100bexAdapter, AsyncResetTimerCallback);
VOID AsyncResetTimerCallback(void);
NDIS_STATUS ParseRegistryParameters(KNdisConfig& Config, ADAPTER_INFO& Ai);
NDIS_STATUS EnableCard(void);
VOID DisableCard(void);
NDIS_STATUS SetupSharedAdapterMemory(void);
VOID DeleteSharedAdapterMemory(void);
VOID SetupTransmitQueues(void);
NDIS_STATUS SetupReceiveQueues(void);
BOOLEAN StartReceiveUnit(void);
BOOLEAN ProcessRXInterrupt(void);
BOOLEAN ProcessTXInterrupt(void);
BOOLEAN TransmitCleanup(void);
VOID DoBogusMulticast(void);
NDIS_STATUS SetupNextSend(KNdisPacket& Packet);
BOOLEAN PrepareForTransmit(KNdisPacket Packet, PD100SwTcb SwTcb);
BOOLEAN AcquireCoalesceBuffer(PD100SwTcb SwTcb);
VOID CopyFromPacketToBuffer(
KNdisPacket Packet,
UINT BytesToCopy,
PCHAR DestBuffer,
KNdisBuffer FirstBuffer,
PUINT BytesCopied
);
VOID DumpHwRfd(HW_RFD* desc);
// Data members
private:
// Card object which we use to manipulate the hardware
E100bexCard * m_pCard;
// Holds the interrupt object for this adapter.
KNdisInterrupt m_Interrupt;
// CSR range accessors
KNdisIoRange m_CSRIoRange;
KNdisMemoryRange m_CSRMemoryRange;
// Holds the timer structure used for Async Resets
KNdisTimer m_Timer;
// Encapsulates shared memory for receive structure
KNdisSharedMemory* m_pRxShMem;
// Encapsulates receive frame descriptors, buffer and packet pools for Rx
typedef KNdisSharedReceiveArea< E100bexAdapter, HW_RFD > E100bexReceiveArea;
// By changing the 2nd template parameter of KNdisSharedReceiveArea<> to
// KNdisRxAreaNoAsync, asynchronous shared memory allocation support is removed.
E100bexReceiveArea* m_pRxArea;
// Spin Lock
KNdisSpinLock m_Lock;
USHORT m_AiThreshold; // 'Threshold', Transmit Threshold
NDIS_MEDIA_STATE m_LinkIsActive;
ETHERNET_ADDRESS m_AiNodeAddress;
// Fields for various D100 specific parameters
UINT m_NumCoalesce; // 'NumCoalese'
UINT m_NumRfd; // 'NumRfd'
UINT m_NumTbdPerTcb; // 'NumTbdPerTcb'
UINT m_NumTbd; // Total number of TBDs
UINT m_RegNumTcb; // number of transmit control blocks the registry says
UINT m_NumTcb; // 'NumTcb' (number of tcb we are actually using (usually RegNumTcb+1))
// Map register variables
UINT m_NumMapRegisters;
UINT m_NextFreeMapReg;
UINT m_OldestUsedMapReg;
// command unit status flags
BOOLEAN m_TransmitIdle;
BOOLEAN m_ResumeWait;
ULONG m_MaxPhysicalMappings;
// Memory for 82557/82558 Control Structures. (note: VOLATILE memory area)
KNdisSharedMemory* m_pCbShMem;
// Transmit memory structures.
PUCHAR m_XmitCached;
UINT m_XmitCachedSize;
PUCHAR m_XmitUnCached;
UINT m_XmitUnCachedSize;
NDIS_PHYSICAL_ADDRESS m_XmitUnCachedPhys;
// Map into a local array to avoid overflow in the Tcb if the virtual
// buffer is made of too many physical buffers. This is a temporary
// scratch area.
NDIS_PHYSICAL_ADDRESS_UNIT m_pUnits[MAX_PHYS_DESC];
// Keep a list of free transmit descriptors.
KList<D100SwTcb> m_TxCBList;
KList<D100SwTcb> m_ActiveChainList;
KList<D100SwTcb> m_CompletedChainList;
// Keep a coalesce buffer list around for those times when there are too many
// physical mappings.
KList<COALESCE> m_CoalesceBufferList;
// Queue of "pending" Tx packets
KNdisPacketList m_TxQueue;
// Needed for multicast address changes during resets
UCHAR m_PrivateMulticastBuffer[MAX_MULTICAST_ADDRESSES][ETH_LENGTH_OF_ADDRESS];
UINT m_NumberOfMcAddresses;
// place to hold the revision id of the d100 chip (read from PCI config)
UCHAR m_AiRevID;
USHORT m_AiSubVendor;
USHORT m_AiSubDevice;
// NDIS_MAC_OPTION_xxx bit set
ULONG m_uMacOptions;
// Statistics. Based on wizard's input only a basic or specific or
// custom stats can be inserted
KNdisStats<ERR_COUNT_STRUC> m_Stats;
// Power Management State
#if KNDIS_PNP_AWARE
KNdisPnpMode<E100bexAdapter> m_Power;
#endif
#if DBG
USHORT m_txsent;
USHORT m_txind;
UINT m_sdebugindex;
#endif
HW_RFD* m_pTempHwDesc;
};
#endif // !defined(AFX_E100BEXADAP_H__8534F9A9_27F5_11D3_8F9E_00C04F7445B7__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -