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

📄 ethread.c

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 C
字号:
 /*
 * Copyright 2001, Metro Link, Inc.
 * All Rights Reserved
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Metro Link, Inc. and may
 * contain proprietary, confidential and trade secret information of
 * Metro Link, Inc. and/or its partners.
 *  
 * The contents of this file may not be disclosed to third parties, copied or
 * duplicated in any form, in whole or in part, without the prior written
 * permission of Metro Link, Inc.
 *
 */
/*
* File			:	Ethread.c
*
* Description	:	Ethernet read manager function. Interface between hardware
*                   and upper layers
*					
* 
* Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
* sole discretion 
*/




#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"
#include "ZMessageQ.h"
#include "ZDevice.h"
#include "EtherMgr.h"
#include "common.h"


extern void					ReceiveEthPkt(EMAC_FRAME_t * ) ;
extern RZK_MESSAGEQHANDLE_t rxQueueHandle ;
extern TICK_t				rxBlockTime ;
extern ETH_DEV_STRUCT_t		emac[];





void RxFunc(void)
{
	ETH_PKT_t *				pep;
	ETH_DEV_STRUCT_t	*	ped=&(emac[0]);
	RZK_STATUS_t status ;

	pep = (ETH_PKT_t*)AllocPktBuff() ;
	if( pep )
	{
		/*
		 * ReceivePkt() wants the pointer to a EMACFRAME (ethhdr808.h), but
		 * the rest of IPworks wants a strupt ep. ETH_PKT_t has been arranged
		 * so that it looks like a EMACFRAME with ep_order matching Flags,
		 * and the rest line up properly. This is done to avoid extra buffer
		 * copies.
		 */
   		ReceiveEthPkt((EMAC_FRAME_t *)&pep->ethPktOrder);

		if( pep->ethPktLen )
		{
			pep->ethPktOrder = EPO_NET;

			/* Initialize the packet with the interface number *///Added for interworking of PPP and ethernet Sridhar 02 Aug 04
			pep->ifNum = (UINT8)(ped->pDev->dvminor) ;

			/*
			 * Normally we'd queue the packet, but for now just toss it.
			 */
			/* Send message */

			status = RZKSendToQueue( rxQueueHandle, (RZK_PTR_t)&pep, sizeof(RZK_PTR_t), 0 ) ;
			if( status != RZKERR_SUCCESS )
			{
				FreePktBuff(pep) ;
				/* On error free the memory and return */
			}				

		}
		else
		{
			FreePktBuff(pep) ;
		}
	}
	else
	{
	/* Need to handle this */
	#if DEBUG
		printf( "emac: No Rx buffer avail\n" );
	#endif
	
	}
}




DDF_STATUS_t EmacRead(RZK_DEVICE_CB_t *pDev, ETH_PKT_t **pep, RZK_DEV_BYTES_t len)
{
  
  RZK_PTR_t pktrecvbuff ;
  COUNT_t size = sizeof(RZK_PTR_t) ;  // IAR changed
  RZK_STATUS_t status = EMACDEV_ERR_SUCCESS ;
  
  if( (pDev->devMode & RZKDEV_OPENED) != RZKDEV_OPENED )
  {
          return EMACDEV_ERR_INVALID_OPERATION ;
  }
  
  /* Network interface not supported Yet */
  
  /********************************/
  
  /* Receive the packet pointer */
  status = RZKReceiveFromQueue( rxQueueHandle, (RZK_PTR_t) &pktrecvbuff, &size, rxBlockTime) ;  // IAR changed
  if(status != RZKERR_SUCCESS)
  {
  
//        FreePktBuff((void *)pktrecvbuff) ;	// IAR changed
          return EMACDEV_ERR_KERNEL_ERROR ;
  }
  
  *pep = (ETH_PKT_t *)pktrecvbuff ;
  len = (*pep)->ethPktLen ;
  
  return len ;

}


⌨️ 快捷键说明

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