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

📄 smnetlib.c

📁 Tornado 2.0.2 source code!vxworks的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* smNetLib.c - VxWorks interface to the shared memory network (backplane) driver *//* Copyright 1984-1992 Wind River Systems, Inc. *//*modification history--------------------01r,15may95,vin  fixed parameter to build_cluster().01q,30sep93,rrr  Added missing 01p modhist.01p,30sep93,rrr  Fixed smNetIntr from using an uninialized variable if                 intType==SM_INT_BUS.01o,21nov92,jdi  documentation cleanup.01n,13oct92,jcf  added a hack to protect from bus error during attach.01m,20oct92,pme  made smNetInit return ERROR instead of disabling data cache		 if cache coherent buffer cannot be allocated.01l,09sep92,gae  doc tweaks.01k,31jul92,dnw  Changed to new cacheLib.01j,27jul92,elh  Moved smNetShow to smNetShow.c01i,26jul92,gae  fixed number of parameters to logMsg().01h,24jul92,elh  added caching, ripple effect of moving heartbeat.01g,15jun92,elh  changed parameter to smNetInetGet.01f,02jun92,elh  the tree shuffle		  -changed includes to have absolute path from h/01e,27may92,elh  Incorperated the changes caused from restructuring the		 shared memory libraries.01d,17may92,elh  renamed from smVxLib to smNetLib01c,01may92,elh	 added mask, if_resolve hook and smNetAddrResolve.01b,12apr92,elh  added support for sequential addressing.01a,17nov90,elh  written.*//*DESCRIPTIONThis library implements the VxWorks-specific portions of the shared memorynetwork interface driver.  It provides the interface between VxWorks andthe network driver modules (e.g., how the OS initializes and attachesthe driver, interrupt handling, etc.), as well as VxWorks-dependentsystem calls.  There are three user-callable routines:  smNetInit(), smNetAttach(), and smNetInetGet().The backplane master initializes the backplane shared memory and networkstructures by first calling smNetInit().  Once the backplane has beeninitialized, all processors can be attached to the shared memory network viathe smNetAttach() routine.  Both smNetInit() and smNetAttach() are calledautomatically in usrConfig.c when backplane parameters are specified in theboot line.The smNetInetGet() routine gets the Internet address associated with abackplane interface.INTERNALThis file corresponds to the smNetLib for SunOS.  If a change is madeto either file, ensure that both are updated if appropriate. Refer to if_sm.c for more information about the layering of backplane modules.INCLUDE FILES: smPktLib.h, smUtilLib.hSEE ALSO: ifLib, if_sm,.pG "Network"*//* includes */#include "vxWorks.h"#include "net/if.h"#include "netinet/if_ether.h"#include "net/mbuf.h"#include "arpLib.h"#include "wdLib.h"#include "sysLib.h"#include "iv.h"#include "vxLib.h"#include "taskLib.h"#include "stdlib.h"#include "intLib.h"#include "stdio.h"#include "logLib.h"#include "netLib.h"#include "cacheLib.h"#include "drv/netif/if_sm.h"#include "drv/netif/smNetLib.h"#include "smPktLib.h"#include "smUtilLib.h"/* globals */int	smNetVerbose		= FALSE;		/* debug aide */int 	smNetMaxBytesDefault 	= DEFAULT_PKT_SIZE;	/* packet size */int	smNetLoanNum		= 0;			/* buffers to loan */SM_SOFTC * sm_softc [NSM]	= { NULL };		/* soft_c structures *//* forward declarations */LOCAL STATUS    smNetAddrResolve (struct ifnet * pIf, struct in_addr * pIpDest,				 u_char * pHwDest, int * usetrailers);LOCAL void	smNetIntr (int intType);LOCAL void	smNetPulse (SM_PKT_MEM_HDR * pSmPktHdr);/* externs */IMPORT		if_dettach ();/********************************************************************************* smNetInit - initialize the shared memory network driver** This routine is called once by the backplane master.  It sets up and * initializes the shared memory region of the shared memory network and * starts the shared memory heartbeat.  ** The <pAnchor> parameter is the local memory address by which the master* CPU accesses the shared memory anchor.  <pMem> contains either the local* address of shared memory or the value NONE (-1), which implies that shared* memory is to be allocated dynamically.  <memSize> is the size, in bytes,* of the shared memory region.** The <tasType> parameter specifies the test-and-set operation to be used to* obtain exclusive access to the shared data structures.  It is preferable* to use a genuine test-and-set instruction, if the hardware permits it.  In* this case, <tasType> should be SM_TAS_HARD.  If any of the CPUs on the* backplane network do not support the test-and-set instruction, <tasType>* should be SM_TAS_SOFT.** The <maxCpus> parameter specifies the maximum number of CPUs that may* use the shared memory region.** The <maxPktBytes> parameter specifies the size, in bytes, of the data* buffer in shared memory packets.  This is the largest amount of data* that may be sent in a single packet.  If this value is not an exact* multiple of 4 bytes, it will be rounded up to the next multiple of 4.** The <startAddr> parameter is only applicable if sequential addressing is* desired.  If <startAddr> is non-zero, it specifies the starting address to* use for sequential addressing on the backplane.  If <startAddr> is zero,* sequential addressing is disabled.** RETURNS: OK, or ERROR if the shared memory network cannot be initialized.*/STATUS smNetInit    (    SM_ANCHOR *	pAnchor,		/* local addr of anchor */    char *	pMem,			/* local addr of shared memory */    int		memSize,		/* size of shared memory */    BOOL	tasType,		/* TRUE = hardware supports TAS */    int		cpuMax,			/* max numbers of cpus */    int		maxPktBytes, 		/* size of data packets */    u_long	startAddr 		/* beginning address */    )    {    SM_PKT_MEM_HDR *	pSmPktHdr;		/* packet header */    WDOG_ID		beatWd;    BOOL		malloced = FALSE;	/* malloced memory here! */    /* validate parameters */    if ((pAnchor == NULL) || (pMem == NULL))	{	logMsg ("smNetInit: invalid %s\n", (pAnchor == NULL) ?		(int) "pAnchor" : (int) "pMem", 0, 0, 0, 0, 0);	return (ERROR);	}    if (sysProcNumGet () != SM_MASTER)	{	logMsg ("smNetInit:called by cpu [%d] non-master\n", sysProcNumGet(),		0, 0, 0, 0, 0);	return (ERROR);	}    maxPktBytes = (maxPktBytes == 0) ?  smNetMaxBytesDefault : maxPktBytes;    if ((startAddr != 0) && (smNetVerbose))	logMsg ("smNetInit:sequential addressing activated (0x%x) \n", 		startAddr, 0, 0, 0, 0, 0);    if (pMem == (char *) NONE) 		/* allocate the shared memory */	{	if (!CACHE_DMA_IS_WRITE_COHERENT () || !CACHE_DMA_IS_READ_COHERENT ())	    {	    logMsg ("smNetInit - cache coherent buffer not available. Giving up. \n", 0, 0, 0, 0, 0, 0);	    return (ERROR);	    }    	if ((pMem = (char *) cacheDmaMalloc (memSize)) == NULL)    	    return (ERROR);    	malloced = TRUE;        }    else	{    	if (pMem == (char *) pAnchor)	    {	    pMem    +=  sizeof (SM_ANCHOR);	    memSize -=  sizeof (SM_ANCHOR);	    }	}    if (smNetVerbose)	logMsg ("smNetInit: anchor:[0x%x] memory:[0x%x] size:%d \n",		(int) pAnchor, (int) pMem, memSize, 0, 0, 0);    /* set up shared memory region */    if ((smPktSetup (pAnchor, pMem, memSize, tasType, cpuMax,		     maxPktBytes + SIZEOF_ETHERHEADER) == OK) && 	((beatWd = wdCreate ()) != NULL))	{        pSmPktHdr = SM_OFFSET_TO_LOCAL (ntohl (pAnchor->smPktHeader),				        (int) pAnchor, SM_PKT_MEM_HDR *);    	pSmPktHdr->reserved1 = htonl (startAddr);	pSmPktHdr->reserved2 = (int) beatWd;        smNetPulse (pSmPktHdr); 		/* start heartbeat */	return (OK);	}    if (malloced)	(void) free (pMem);    return (ERROR);    }/********************************************************************************* smNetAttach - attach the shared memory network interface** This routine attaches the shared memory interface to the network.  It is* called once by each CPU on the shared memory network.  The <unit> parameter* specifies the backplane unit number.** The <pAnchor> parameter is the local address by which the local CPU may* access the shared memory anchor.** The <maxInputPkts> parameter specifies the maximum number of incoming* shared memory packets which may be queued to this CPU at one time.** The <intType>, <intArg1>, <intArg2>, and <intArg3> parameters allow a* CPU to announce the method by which it is to be notified of input packets* which have been queued to it.** RETURNS: OK, or ERROR if the shared memory interface cannot be attached.*/STATUS smNetAttach    (    int			unit,			/* interface unit number */    SM_ANCHOR *		pAnchor,		/* addr of anchor */    int			maxInputPkts,		/* max queued packets */    int			intType,		/* interrupt method */    int			intArg1,		/* interrupt argument #1 */    int			intArg2,		/* interrupt argument #2 */

⌨️ 快捷键说明

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