📄 pnacfg.c
字号:
/***********************************************************************/
/* */
/* MODULE: pnacfg.c 1.10 */
/* PURPOSE: pNA+ configuration file */
/* */
/* 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 */
/* */
/***********************************************************************/
//该文件是从PSOSystem拷贝的,不需做改动
#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 0x5000
UCHAR *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);
#endif
pna_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;
#endif
PnaCfg.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_DAEMSSTK
PnaCfg.pnad_sysstk = NC_DAEMSSTK;
#else
PnaCfg.pnad_sysstk = KC_ROOTSSTK;
#endif
#ifdef NC_DAEMUSTK
PnaCfg.pnad_usrstk = NC_DAEMUSTK;
#else
PnaCfg.pnad_usrstk = KC_ROOTUSTK;
#endif
#ifdef NC_DAEMMODE
PnaCfg.pnad_mode = NC_DAEMMODE;
#else
PnaCfg.pnad_mode = KC_ROOTMODE;
#endif
#if (SC_PX || SC_PRPC)
PnaCfg.nc_sct = &PnaSubCfg;
#endif
PnaCfg.nc_mblks = NC_MBLKS;
PnaCfg.nc_bcfg = pna_bufcfg;
PnaCfg.nc_nsockets = NC_NSOCKETS;
PnaCfg.nc_ndescs = NC_NDESCS;
/*---------------------------------------------------------------------*/
/* Added for New pNA+ MULTICASTING. */
/*---------------------------------------------------------------------*/
#define NC_NMCSOCS 16
#define NC_NMCMEMB 16
#ifdef NC_NMCSOCS
PnaCfg.nc_nmc_socs = NC_NMCSOCS;
// #error "support multicast"
#else
PnaCfg.nc_nmc_socs = 0;
// #error "not support multicast"
#endif
#ifdef NC_NMCMEMB
PnaCfg.nc_nmc_memb = NC_NMCMEMB;
// #error "support multicast2"
#else
PnaCfg.nc_nmc_memb = 0;
// #error "not support multicast2"
#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_SIGNAL
PnaCfg.nc_signal = sig_handler;
#endif
NodeCfg->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;
//printf("pnacfg.c\n");//////////add 6.6
}
#if defined(__cplusplus)
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -