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

📄 cf_ifc.h

📁 Windows CE 6.0 BSP for VOIP sample phone. Intel PXA270 platform.
💻 H
📖 第 1 页 / 共 4 页
字号:
	//-------------------------------------------------------------------------------
    //    	Signal end of packet to device and indicate interrupt for card
	//-------------------------------------------------------------------------------
	cf_TxEndPacket ( pCf );

    return IX_STATUS_SUCCESS;
}

//************************************************************************************
//* Function: 		cf_KickstartRX
//*	Description:	Fire off bogus int to start up RX in firmware
//*
//* Returns			void
//* Date:			05/19/2003
//************************************************************************************
__inline void cf_KickstartRX
(
    PCF_OBJECT pCf
)
{
	//-------------------------------------------------------------------------------
	// Set the CFMACREG_HCR_HS_RxUpLdOvr bit in the host status register.
	//-------------------------------------------------------------------------------
	cf_UshortRegSetBits(pCf, CFMACREG_HCR_HOST_STATUS,    CFMACREG_HCR_HS_RxUpLdOvr );

	//-------------------------------------------------------------------------------
	// Set the CFMACREG_HCR_CIC_RxUpLdOvr bit in the interrupt cause register.
	//		This triggers an interrupt in the card FW.
	//-------------------------------------------------------------------------------
	cf_UshortRegSetBits(pCf, CFMACREG_HCR_CARD_INT_CAUSE, CFMACREG_HCR_CIC_RxUpLdOvr );
  		
}

//*************************************************************************
//* Function: 		cf_RxStartPacket
//*	Description:	Verifies packet is available and then reads and returns packet
//*						length.
//* Returns			IX_STATUS_DEVICE_BUSY if device busy, IX_STATUS_SUCCESS otherwise
//* Date:			04/08/2003
//*************************************************************************
__inline IX_STATUS cf_RxStartPacket(PCF_OBJECT pCf, USHORT *rxPacketLength )
{
	//-------------------------------------------------------------------------------
	// Debug assertions from specifciation.
	//-------------------------------------------------------------------------------
	ASSERT( pCf != NULL );
	ASSERT(!pCf -> bRxPacketOpen );
	ASSERT( pCf -> ulSignatureTop == CF_Signature );
	ASSERT( pCf -> ulSignatureBottom == CF_Signature );
	ASSERT( pCf -> ulMrvDrvVirtualIoBase != 0 );
	
	//-------------------------------------------------------------------------------
	// First check if there is data available. If not then return status indicationg so.
	//-------------------------------------------------------------------------------
	if ( !IX_SUCCESS(cf_IsRxUploadReady(pCf)) )
	{
		DBGPRINT(DBG_ERROR,("cf_RxStartPacket: ERROR: Device has no data waiting\n"));
		return IX_STATUS_NO_DATA;
	}

	//-------------------------------------------------------------------------------
       //      Read the receive packet length: This tells device we are getting ready to read
       //			the current packet.
	//-------------------------------------------------------------------------------
    NdisRawReadPortUshort(
  		 pCf -> ulMrvDrvVirtualIoBase + CFMACREG_CCR_IO_READ_LEN,
	         rxPacketLength );

#if DBG             // PJG: optimize - this data is only used in debug build.
	pCf -> bRxPacketOpen = TRUE;						// indicate rx packet is open.
	pCf -> ulRxPacketSize = *rxPacketLength;			// and remember the length.
#endif	
       DBGPRINT(DBG_HWIF,("cf_RxStartPacket: Will transfer %d bytes\n",*rxPacketLength));
	
	return IX_STATUS_SUCCESS;
}

//************************************************************************************
//* Function: 		cf_RxBlock
//*	Description:	Receives a block of data from the device.
//* Returns			void
//* Date:			04/08/2003
//************************************************************************************
__inline void cf_RxBlock
	(
		PCF_OBJECT pCf, 								// Pointer to our interface object.
		UCHAR *packetBuf, 								// Pointer to packet to transmit.
		USHORT packetSizeBytes 							// size in bytes of current packet.
	)
{
	int ii;
	PUSHORT packetPtr = (PUSHORT)packetBuf;							// Word pointer to our packet.
	USHORT packetSizeWords = packetSizeBytes / sizeof(USHORT);		//  get the whole number of words.
	USHORT leftOverByte = packetSizeBytes % sizeof(USHORT);			// see if we divide evenly.

	//-------------------------------------------------------------------------------
	// Debug assertions from specifciation.
	//-------------------------------------------------------------------------------
	ASSERT( pCf != NULL );
	ASSERT( pCf -> ulSignatureTop == CF_Signature );
	ASSERT( pCf -> ulSignatureBottom == CF_Signature );
	ASSERT( pCf -> bRxPacketOpen);
	ASSERT( pCf -> ulMrvDrvVirtualIoBase != 0);
	ASSERT( packetSizeBytes != 0 );

    //-------------------------------------------------------------------------------
   	//      Download packet from the device.
	//-------------------------------------------------------------------------------
   	for( ii = 0; ii < (int)packetSizeWords; ii++ )
    {
   	    NdisRawReadPortUshort(
  		    pCf -> ulMrvDrvVirtualIoBase + CFMACREG_HCR_IO_READ_PORT,
   	        packetPtr);
       	packetPtr++;
    }

	//-------------------------------------------------------------------------------
   	//      If cmd was not even number of bytes write the leftover byte to the device.
    //-------------------------------------------------------------------------------
   	if ( leftOverByte )
    {
   		NdisRawReadPortUchar(
   			pCf -> ulMrvDrvVirtualIoBase + CFMACREG_HCR_IO_READ_PORT,
	        ((UCHAR *)packetPtr));
   	}

   	pCf -> ulRxPacketByteCount += packetSizeBytes;		// accumulate the total bytes.
    DBGPRINT(DBG_HWIF,("cf_RxBlock: Transfered %d bytes\n",packetSizeBytes));
   	
}	

//*************************************************************************
//* Function: 		cf_RxEndPacket
//*	Description:	Ends download of current packet by setting the host status
//*					 RxUpLdOver bit and and setting the card interrupt cause fo RxUpLdOver
//*					 so card can generate internal interrupt.
//* NOTE:			This routine can be called at anytime on an open packet to either
//*						end a packet whose data has been read, or to discard packet 
//*						data without actually reading in any or all of the receive packet.
//* Returns			void
//* Date:			04/10/2003
//*************************************************************************
__inline void cf_RxEndPacket(PCF_OBJECT pCf )
{
    static ULONG rxPacketCnt = 0;
	//-------------------------------------------------------------------------------
	// Debug assertions from specifciation.
	//-------------------------------------------------------------------------------
	ASSERT( pCf != NULL );
	ASSERT( pCf -> ulSignatureTop == CF_Signature );
	ASSERT( pCf -> ulSignatureBottom == CF_Signature );
//	ASSERT( pCf -> bRxPacketOpen);                      // not legitmate assert we have to call this to acknowlege false ints from devcie.
	ASSERT( pCf -> ulMrvDrvVirtualIoBase != 0);

    rxPacketCnt++;
#if 0
	if ( pCf->ulRxPacketByteCount != pCf->ulRxPacketSize )
	{
		DBGPRINT(DBG_WARNING,(" cf_RxEndPacket: WARNING - packet ended with wrong size: size %d, read %d \n", pCf->ulRxPacketSize, pCf->ulRxPacketByteCount));
	}
#endif
    DBGPRINT(DBG_HWIF,("cf_RxEndPacket: Packet %d Transfered %d bytes\n",
                rxPacketCnt,pCf->ulRxPacketByteCount));

	//-------------------------------------------------------------------------------
	// Set the CFMACREG_HCR_HS_RxUpLdOvr bit in the host status register.
	//-------------------------------------------------------------------------------
	cf_UshortRegSetBits(pCf, CFMACREG_HCR_HOST_STATUS,    CFMACREG_HCR_HS_RxUpLdOvr );

	//-------------------------------------------------------------------------------
	// Set the CFMACREG_HCR_CIC_TxDnLdOvr bit in the interrupt cause register.
	//		This triggers an interrupt in the card FW.
	//-------------------------------------------------------------------------------
	cf_UshortRegSetBits(pCf, CFMACREG_HCR_CARD_INT_CAUSE, CFMACREG_HCR_CIC_RxUpLdOvr );

#if DBG     // PJG: optimize - this data only used in debug build.
	pCf -> bRxPacketOpen = FALSE;					// packet no longer open.
	pCf -> ulRxPacketSize  = 0;						// reset current packet size.
	pCf -> ulRxPacketByteCount = 0;					// reset the byte count.
#endif	
}

//************************************************************************************
//* Function: 		cf_TxUpdateSeq
//*	Description:	Ends transmit of current packet to the device.
//*						Block is ended by setting the download complete bit in the
//*						host status register and by signaling a download complete
//*						interrupt cause to the device in the card interrupt cause
//*						register.
//* Returns			void
//* Date:			04/08/2003
//************************************************************************************
__inline void cf_TxUpdateSeq
	(
		PCF_OBJECT pCf, 					// Pointer to our interface object.
		USHORT	   seqNum
	)
{
    NdisRawWritePortUshort
    	(pCf -> ulMrvDrvVirtualIoBase + CFMACREG_CCR_TX_FRAME_SEQ_NUM,seqNum);
}

//************************************************************************************
//* Function: 		cf_UpdateInterrupt
//*	Description:	return the status of the interrupt indicated by the supplied
//*                 mask and mask that interrupt if set.
//* Returns			USHORT mask of current interrupt
//* Date:			04/08/2003
//************************************************************************************
__inline USHORT cf_UpdateInterrupt
(
	    PMRVDRV_ADAPTER Adapter,
	    USHORT	   intrMask
)
{
    USHORT usRegValue;

    // get current interrupt flags
    NdisRawReadPortUshort(
	    Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
		&usRegValue);
	// mask all but the one we are concerned with
    usRegValue &= intrMask; 

    // clear interrupt if it is pending.
	NdisRawWritePortUshort(
	Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,usRegValue );

    // return state of this interrupt
	return usRegValue;
}

//************************************************************************************
//* Function: 		HexDump
//*	Description:	Debug helper routine for HEX dumps of data buffers..
//* Returns			void
//* Date:			05/20/2003
//************************************************************************************
///#if DBG
extern ULONG DebugLevel;
// set line length to your pleasure.  23 is the size of repeating data in MS Pings.
#define HD_LINE_LENGTH 		23
#define MRV_DRV_LINE_LENGTH 	16
static __inline
void HexDump ( UINT dbgLevel, char *msg, PUCHAR buf, int len)
{
	int ii = 0, jj;
 	UCHAR lastBuf[MRV_DRV_LINE_LENGTH];

  //if ( (dbgLevel & DebugLevel) == 0 )
  //{
  //    return;
  // }

  if ( msg ) AllenDBGPRINT(dbgLevel,("%s\n",msg));

  	// new version that prints out correctly in dbgview
  	jj = len / MRV_DRV_LINE_LENGTH;

⌨️ 快捷键说明

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