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

📄 pnacfg.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的操作系统pSOS。包括全部源码
💻 C
字号:
/***********************************************************************//*                                                                     *//*   MODULE:  pnacfg.c   1.10                                                *//*   DATE:    14:32:37 - 98/12/29                                                *//*   PURPOSE: pNA+ configuration file                                  *//*                                                                     *//*---------------------------------------------------------------------*//*                                                                     *//*           Copyright 1991 - 1995, Integrated Systems, Inc.           *//*                      ALL RIGHTS RESERVED                            *//*                                                                     *//*   Permission is hereby granted to licensees of Integrated Systems,  *//*   Inc. products to use or abstract this computer program for the    *//*   sole purpose of implementing a product based on Integrated        *//*   Systems, Inc. products.   No other rights to reproduce, use,      *//*   or disseminate this computer program, whether in part or in       *//*   whole, are granted.                                               *//*                                                                     *//*   Integrated Systems, Inc. makes no representation or warranties    *//*   with respect to the performance of this computer program, and     *//*   specifically disclaims any responsibility for any damages,        *//*   special or consequential, connected with the use of this program. *//*                                                                     *//*---------------------------------------------------------------------*//*                                                                     *//*   This code in this module controls the configuration of the        *//*   pNA componet.  Many configurations are possible, based on         *//*   these inputs:                                                     *//*     * Options selected in "sys_conf.h"                              *//*     * The capabilities of the board-support package being used,     *//*       as defined in "bsp.h"                                         *//*     * Answers given to questions in the startup configuration       *//*       dialog, if it is enabled                                      *//*                                                                     *//***********************************************************************/#if defined(__cplusplus)extern "C" {#endif#include "sys_conf.h"#include "stdio.h"/*---------------------------------------------------------------------*//* The following symbols should be defined in sys_conf.h.  However,    *//* the sys_conf.h files in some of the older sample applications do    *//* not contain these definitions.  In order to maintain compatibility, *//* they are set to default values here if they have not been defined   *//* defined in sys_conf.h.  It is preferable that these symbols be      *//* defined in sys_conf.h, and you should note that these "default"     *//* definitions will probably be removed from this file in future       *//* versions of pSOSystem!                                              *//*---------------------------------------------------------------------*/#ifndef SE_MAX_PNA_NC_BUFS#define SE_MAX_PNA_NC_BUFS 4#endif#ifndef NC_MBLKS#define NC_MBLKS 300#endif#ifndef NC_NSOCKETS#define NC_NSOCKETS  8#endif#ifndef NC_NDESCS#define NC_NDESCS 4#endif#include "bsp.h"#include <bspfuncs.h>#include <configs.h>#include <pna.h>#include <sysvars.h>extern void pna(void);extern void sig_handler (); /*---------------------------------------------------------------------*//* pNA+ component configuration table.  The definitions for this is    *//* contained in <configs.h>.                                           *//*---------------------------------------------------------------------*/pNA_CT PnaCfg;struct pna_bufcfg pna_bufcfg[SE_MAX_PNA_NC_BUFS +1];struct ni_init PnaIft[NC_NNI + 1];#if (SC_PX || SC_PRPC)    pNA_SCT PnaSubCfg;#endif#define PNA_DATA_SIZE 0x5000UCHAR *SetUpNI(UCHAR *);extern struct SD_parms SysVars;extern const char MemErrMsg[];#define ADD_BUFFS(nn)  \    if (i>=SE_MAX_PNA_NC_BUFS) { 			\        SysInitFail("SE_MAX_PNA_NC_BUFS too small");    \    } else {						\        pna_bufcfg[i].pna_nbuffers = NC_BUFS_##nn; 	\        pna_bufcfg[i].pna_bsize    = nn; 		\        i++; 						\    }/***********************************************************************//* PnaSetup: Setup pNA+ component                                       *//*                                                                     *//*      INPUTS: FreeMemPtr pointer to free memory area that can be     *//*              used to allocate memory for this componet.             *//*                                                                     *//*              NodeCfg pointer to the systems node configuration      *//*              table. This will be used to set the pnact              *//*              element in the table.                                  *//*                                                                     *//*     RETURNS: The new FreeMemPtr is returned.                        *//*                                                                     *//***********************************************************************/UCHAR *PnaSetup(UCHAR *FreeMemPtr,  NODE_CT *NodeCfg){unsigned long i=0;/*---------------------------------------------------------------------*//* Build the pNA configuration tables                                  *//*---------------------------------------------------------------------*/PnaCfg.nc_pna = pna;#if (SC_PROBE_DEBUG)    /*-----------------------------------------------------------------*/    /* If the pROBE remote debugger module is configured (and pNA too) */    /* assume they will need a pNA data area.  Even if they configure  */    /* pROBE standalone mode in the startup dialog, they can use the   */    /* FL RBUG ON command to go into remote debug mode before pSOS is  */    /* initialized.  Thus we *must* set aside a pNA data area.         */    /*-----------------------------------------------------------------*/    #if !(NC_DATA && NC_DATASIZE)        PnaCfg.nc_data = FreeMemPtr;        PnaCfg.nc_datasize = PNA_DATA_SIZE;        while(i<PNA_DATA_SIZE)            FreeMemPtr[i++] = 0;        FreeMemPtr = FreeMemPtr + PNA_DATA_SIZE;        #if SC_RAM_SIZE            if (FreeMemPtr >              (UCHAR *)(SC_RAM_SIZE + BSP_RAM_BASE))                SysInitFail(MemErrMsg);        #else            if (FreeMemPtr > (UCHAR *)(RamSize() + BSP_RAM_BASE))                SysInitFail(MemErrMsg);        #endif    #endif#endif#if NC_BUFS_0    ADD_BUFFS(0);#endif    #if NC_BUFS_32    ADD_BUFFS(32);#endif#if NC_BUFS_64    ADD_BUFFS(64);#endif#if NC_BUFS_128    ADD_BUFFS(128);#endif#if NC_BUFS_256    ADD_BUFFS(256);#endif#if NC_BUFS_512    ADD_BUFFS(512);#endif#if NC_BUFS_1024    ADD_BUFFS(1024);#endif#if NC_BUFS_2048    ADD_BUFFS(2048);#endif#if NC_BUFS_4096    ADD_BUFFS(4096);#endif#if NC_BUFS_8192    ADD_BUFFS(8192);#endif#if NC_BUFS_16384    ADD_BUFFS(16384);#endifpna_bufcfg[i].pna_nbuffers = 0;pna_bufcfg[i].pna_bsize = 0;    #if (NC_DATA && NC_DATASIZE)    PnaCfg.nc_data = NC_DATA;    PnaCfg.nc_datasize = NC_DATASIZE;#endifPnaCfg.nc_nni = NC_NNI;PnaCfg.nc_ini = PnaIft;PnaCfg.nc_nroute = NC_NROUTE;PnaCfg.nc_defgn = htonl((ULONG) (SysVars.DefGtwyIP));PnaCfg.nc_narp = NC_NARP;PnaCfg.nc_defuid = NC_DEFUID;PnaCfg.nc_defgid = NC_DEFGID;PnaCfg.nc_hostname = NC_HOSTNAME;PnaCfg.nc_nhentry = NC_NHENTRY;#ifdef NC_DAEMSSTKPnaCfg.pnad_sysstk = NC_DAEMSSTK;#elsePnaCfg.pnad_sysstk = KC_ROOTSSTK;#endif#ifdef NC_DAEMUSTKPnaCfg.pnad_usrstk = NC_DAEMUSTK;#elsePnaCfg.pnad_usrstk = KC_ROOTUSTK;#endif#ifdef NC_DAEMMODEPnaCfg.pnad_mode   = NC_DAEMMODE;#elsePnaCfg.pnad_mode   = KC_ROOTMODE;#endif#if (SC_PX || SC_PRPC)    PnaCfg.nc_sct = &PnaSubCfg;#endifPnaCfg.nc_mblks = NC_MBLKS;PnaCfg.nc_bcfg = pna_bufcfg;PnaCfg.nc_nsockets = NC_NSOCKETS;PnaCfg.nc_ndescs = NC_NDESCS;/*---------------------------------------------------------------------*//* Added for New pNA+ MULTICASTING.                                    *//*---------------------------------------------------------------------*/#ifdef NC_NMCSOCS    PnaCfg.nc_nmc_socs = NC_NMCSOCS;#else    PnaCfg.nc_nmc_socs = 0;#endif#ifdef NC_NMCMEMB    PnaCfg.nc_nmc_memb = NC_NMCMEMB;#else    PnaCfg.nc_nmc_memb = 0;#endif/*---------------------------------------------------------------------*//* Added for New pNA+ Network NODE ID.                                 *//*---------------------------------------------------------------------*/#ifdef NC_NNODEID    PnaCfg.nc_nnode_id = NC_NNODEID;#else    PnaCfg.nc_nnode_id = 0;#endif/*---------------------------------------------------------------------*//* Added Signal handler                                                *//*---------------------------------------------------------------------*/#if NC_SIGNALPnaCfg.nc_signal = sig_handler;#endifNodeCfg->pnact = &PnaCfg;/*---------------------------------------------------------------------*//* Build the pNA initial interface table                               *//*---------------------------------------------------------------------*/FreeMemPtr = SetUpNI(FreeMemPtr);return (FreeMemPtr);}/***********************************************************************//* InstallNi: Installs a Ni driver                                     *//*                                                                     *//*      INPUTS:                                                        *//*              int (*entry)();        address of NI entry point       *//*              int ipadd;             IP address                      *//*              int mtu;               maximum transmission length     *//*              int hwalen;            length of hardware address      *//*              int flags;             intErface flags                 *//*              int subnetaddr;        subnet mask                     *//*              int dstipaddr;         destination ip address          *//*                                                                     *//*     RETURNS: Void                                                   *//*                                                                     *//***********************************************************************/void InstallNi(int (*entry)(),                 int ipadd,                 int mtu,                 int hwalen,                 int flags,                 int subnetaddr,                 int dstipaddr){int indx;struct ni_init *ni_ptr;/*---------------------------------------------------------------------*//* Advance ni_ptr to the first empty spot in the NI table, and ensure  *//* that the table is not already full.                                 *//*---------------------------------------------------------------------*/ni_ptr = PnaIft;indx = 0;while (ni_ptr->entry != (int (*)())0)    {    ni_ptr++;    indx++;    }if (indx >= NC_NNI)     SysInitFail("Number of network interfaces > NC_NNI");/*---------------------------------------------------------------------*//* Found an empty slot.  Fill in the values for interface being        *//* installed.                                                          *//*---------------------------------------------------------------------*/ni_ptr->entry = (int (*)())entry;ni_ptr->ipadd = htonl((ULONG)ipadd);ni_ptr->mtu = mtu;ni_ptr->hwalen = hwalen;ni_ptr->flags = flags;ni_ptr->subnetaddr = htonl((ULONG)subnetaddr);/*ni_ptr->dstipaddr = dstipaddr; JRC which is it?*/ni_ptr->dstipaddr = htonl((ULONG)dstipaddr);ni_ptr->reserved[0] = 0;}#if defined(__cplusplus)}#endif

⌨️ 快捷键说明

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