⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smsc100fd.h

📁 smsc公司的网络芯片smsc100fd的wince源码。
💻 H
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/****************************************************************
 *																*
 * SMSC100FD Ethernet Driver for Windows CE.					*
 *																*
 ****************************************************************/
#ifndef	_SMSC100FD_H_
#define	_SMSC100FD_H_
//
// The Version of NDIS that the driver is compatible with
//
#define SMSC100FD_NDIS_MAJOR_VERSION 4
#define SMSC100FD_NDIS_MINOR_VERSION 0

//
// Windows CE debug zones
//
#if DBG
#define ZONE_ERROR_BIT		0
#define ZONE_WARN_BIT		1
#define ZONE_FUNCTION_BIT	2
#define ZONE_INIT_BIT		3
#define ZONE_INTR_BIT		4
#define ZONE_RCV_BIT		5
#define ZONE_XMIT_BIT		6
#define ZONE_LINK_BIT		7

#define ZONE_ERROR_MASK		(1 << ZONE_ERROR_BIT)
#define ZONE_WARN_MASK		(1 << ZONE_WARN_BIT)
#define ZONE_FUNCTION_MASK	(1 << ZONE_FUNCTION_BIT)
#define ZONE_INIT_MASK		(1 << ZONE_INIT_BIT)
#define ZONE_INTR_MASK		(1 << ZONE_INTR_BIT)
#define ZONE_RCV_MASK		(1 << ZONE_RCV_BIT)
#define ZONE_XMIT_MASK		(1 << ZONE_XMIT_BIT)
#define ZONE_LINK_MASK		(1 << ZONE_LINK_BIT)

#define ZONE_ERROR		DEBUGZONE(ZONE_ERROR_BIT)
#define ZONE_WARN		DEBUGZONE(ZONE_WARN_BIT)
#define ZONE_FUNCTION	DEBUGZONE(ZONE_FUNCTION_BIT)
#define ZONE_INIT		DEBUGZONE(ZONE_INIT_BIT)
#define ZONE_INTR		DEBUGZONE(ZONE_INTR_BIT)
#define ZONE_RCV		DEBUGZONE(ZONE_RCV_BIT)
#define ZONE_XMIT		DEBUGZONE(ZONE_XMIT_BIT)
#define ZONE_LINK		DEBUGZONE(ZONE_LINK_BIT)
#endif

//
// Interrupt request for SMSC100FD
//
//#define SMSC100FDIrq (SYSINTR_ETHER - SYSINTR_FIRMWARE)

//
// Size of the ethernet header
//
#define ETHER_HEADER_SIZE 14

//
// Read and Write word macros for accessing the SMSC100FD Registers
//
//#define ReadWord(wOffset) (*((UINT16 volatile *)((pAdapter->pVirtualRegisterBase) + (wOffset))))
//#define ReadDWord(wOffset) (*((UINT volatile *)((pAdapter->pVirtualRegisterBase) + (wOffset))))
//#define WriteWord(wOffset, Value) (*((UINT16 volatile *)((pAdapter->pVirtualRegisterBase) + (wOffset))) = (Value))

//
// Size of the ethernet address
//
#define ETHER_LENGTH_OF_ADDRESS 6

//
// Maximum number of bytes in a packet
//
#define MAX_PACKET 1518
//
// Number of bytes allowed in a lookahead (max)
//
#define MAX_LOOKAHEAD (MAX_PACKET - ETHER_HEADER_SIZE)

//
// Valid value ranges for the InterruptNumber.
//
#define MAX_IRQ (SYSINTR_MAXIMUM - SYSINTR_FIRMWARE)

//
// Default value for maximum number of multicast addrersses
//
#define DEFAULT_MULTICASTLISTMAX 8

//
// Maximum amount of time to wait for MMU
//
#define MMU_WAIT_LOOP	1000000

//
// Configuration strings
//
#define INTERRUPT			NDIS_STRING_CONST("InterruptNumber")

//
// This structure contains information about the driver
// itself. There is only one of these.
//
typedef struct _DRIVER_BLOCK
	{
    //
    // NDIS wrapper information.
    //
    NDIS_HANDLE NdisWrapperHandle;      // returned from NdisInitializeWrapper
    //
    // Adapters registered for this Miniport driver.
    //
    struct _SMSC100FD_ADAPTER *AdapterQueue;
	} DRIVER_BLOCK, *PDRIVER_BLOCK;

//
// This structure contains all the information about a single
// adapter that this driver is controlling.
//
typedef struct _SMSC100FD_ADAPTER
	{
    //
    // This is the handle given by the wrapper for calling NDIS functions.
    //
    NDIS_HANDLE hMiniportAdapterHandle;
    //
    // used by DriverBlock->AdapterQueue
    //
    struct _SMSC100FD_ADAPTER *NextAdapter;
	//
	// The Virtual address of the SMSC100FD registers
	//
	PBYTE pVirtualRegisterBase;
	//
	// Address MultiPlier
	//
	UINT uMultiplier;
    //
    // Interrupt object.
    //
    NDIS_MINIPORT_INTERRUPT Interrupt;
    //
    // Interrupt number this adapter is using.
    //
    UCHAR ucInterruptNumber;
	//
	// 
	ULONG ulIoBaseAddress;
    //
    // The Ethernet address currently in use.
    //
    UCHAR ucStationAddress[ETHER_LENGTH_OF_ADDRESS];
	//
	// The current packet filter in use.
	//
	ULONG ulPacketFilter;

	//
	// Statistics used by Set/QueryInformation.
	//
	ULONG ulFramesXmitGood;               // Good Frames Transmitted
	ULONG ulFramesRcvGood;                // Good Frames Received
	ULONG ulFramesXmitBad;                // Bad Frames Transmitted
	ULONG ulFramesXmitOneCollision;       // Frames Transmitted with one collision
	ULONG ulFramesXmitManyCollisions;     // Frames Transmitted with > 1 collision
	ULONG ulFrameAlignmentErrors;         // FAE errors counted
	ULONG ulCrcErrors;                    // CRC errors counted
	ULONG ulMissedPackets;                // Missed packets counted
	//
	// Images of card registers, to be restored after a reset.
	//
	UCHAR ucNicMulticastRegs[8];	// Contents of multicast registers
	USHORT usNicReceiveConfig;		// Contents of the RCR
	USHORT usNicTransmitConfig;		// Contents of the TCR
	USHORT usNicInterruptMask;		// Contents of the IMR
	//
	// The lookahead buffer size in use.
	//
	ULONG ulMaxLookAhead;
	//
	// Lookahead buffer
	//
	USHORT usLookahead[((MAX_LOOKAHEAD + ETHER_HEADER_SIZE + 1) / sizeof (USHORT))];
	//
	// List of multicast addresses in use.
	//
	UCHAR ucAddresses[DEFAULT_MULTICASTLISTMAX][ETHER_LENGTH_OF_ADDRESS];
	} SMSC100FD_ADAPTER, *PSMSC100FD_ADAPTER;

//
// Structure describing Registry values
//
typedef struct _REG_VALUE_DESCR {
    LPWSTR val_name;
    DWORD  val_type;
    PBYTE  val_data;
	} REG_VALUE_DESCR, *PREG_VALUE_DESCR;
//
#define IOADDRESS  NDIS_STRING_CONST("IoBaseAddress")
#define INTERRUPT  NDIS_STRING_CONST("InterruptNumber")
#define IOMULTIPLIER  NDIS_STRING_CONST("IoMultiplier")
#define BUS_TYPE  NDIS_STRING_CONST("BusType")

//
// Forward References
//
BOOL AddKeyValues (LPWSTR KeyName, PREG_VALUE_DESCR Vals);
LPWSTR Install_Driver (LPWSTR lpPnpId, LPWSTR lpRegPath, DWORD  cRegPathSize);

VOID CardBlockInterrupts (IN PSMSC100FD_ADAPTER Adapter);
VOID CardUnblockInterrupts (IN PSMSC100FD_ADAPTER Adapter);
VOID CardStop (IN PSMSC100FD_ADAPTER pAdapter);
VOID CardReadEthernetAddress (IN PSMSC100FD_ADAPTER pAdapter);
VOID CardStart (IN PSMSC100FD_ADAPTER pAdapter);
VOID CardFillMulticastRegs (IN PSMSC100FD_ADAPTER pAdapter);
VOID CardGetMulticastBit(IN UCHAR ucAddress[ETHER_LENGTH_OF_ADDRESS], OUT PUCHAR pByte, OUT PUCHAR pValue);

BOOLEAN CardReset (IN PSMSC100FD_ADAPTER pAdapter);
BOOLEAN CardInitialize (IN PSMSC100FD_ADAPTER pAdapter);
BOOLEAN CardSetup (IN PSMSC100FD_ADAPTER pAdapter);
ULONG CardComputeCrc (IN PUCHAR pBuffer, IN UINT uiLength);

BOOLEAN SyncCardSetAllMulticast (IN PVOID pSynchronizeContext);
BOOLEAN SyncCardCopyMulticastRegs (IN PVOID pSynchronizeContext);
BOOLEAN SyncCardSetReceiveConfig (IN PVOID pSynchronizeContext);

VOID Smsc100FdIsr (OUT PBOOLEAN pbInterruptRecognized, OUT PBOOLEAN pbQueueDpc, IN PVOID pContext);
VOID Smsc100FdHandleInterrupt (IN NDIS_HANDLE hMiniportAdapterContext);
VOID Smsc100FdEnableInterrupt (IN NDIS_HANDLE MiniportAdapterContext);
VOID Smsc100FdDisableInterrupt (IN NDIS_HANDLE MiniportAdapterContext);
VOID Smsc100FdHalt (IN NDIS_HANDLE MiniportAdapterContext);
VOID Smsc100FdShutdown (IN NDIS_HANDLE MiniportAdapterContext);

NDIS_STATUS Smsc100FdInitialize (OUT PNDIS_STATUS OpenErrorStatus, OUT PUINT puiSelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, IN UINT uiMediumArraySize, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE ConfigurationHandle);
NDIS_STATUS Smsc100FdRegisterAdapter (IN PSMSC100FD_ADAPTER pAdapter, IN NDIS_HANDLE ConfigurationHandle, IN BOOLEAN bConfigError, IN ULONG ulConfigErrorValue);
NDIS_STATUS Smsc100FdReset (OUT PBOOLEAN pbAddressingReset, IN NDIS_HANDLE MiniportAdapterContext);
NDIS_STATUS Smsc100FdQueryInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID pInformationBuffer, IN ULONG ulInformationBufferLength, OUT PULONG pulBytesWritten, OUT PULONG pulBytesNeeded);
NDIS_STATUS Smsc100FdSend (IN NDIS_HANDLE hMiniportAdapterContext, IN PNDIS_PACKET pPacket, IN UINT uiFlags);

NDIS_STATUS DispatchSetPacketFilter (IN PSMSC100FD_ADAPTER pAdapter);
NDIS_STATUS DispatchSetMulticastAddressList (IN PSMSC100FD_ADAPTER pAdapter);

VOID Smsc100FdWritePhy (IN PSMSC100FD_ADAPTER pAdapter, USHORT usPhyRegister, USHORT usPhyData);
USHORT Smsc100FdReadPhy (IN PSMSC100FD_ADAPTER pAdapter, USHORT usPhyRegister);
#endif	// _SMSC100FD_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -