📄 muxloadl.c
字号:
/* usrAppInit.c - stub application initialization routine */
/* Copyright 1984-1998 Wind River Systems, Inc. */
/*
modification history
--------------------
01a,02jun98,ms written
*/
/*
DESCRIPTION
Initialize user application code.
*/
/******************************************************************************
*
* usrAppInit - initialize the users application
*/
#include "vxWorks.h"
#include "end.h"
#include "usrConfig.h" /* general configuration header */
STATUS myadc(int ghandle);
STATUS RxTest () ;
STATUS usrEndint();
void myt();
void usrAppInit (void)
{
#ifdef USER_APPL_INIT
USER_APPL_INIT; /* for backwards compatibility */
#endif
/*
if(taskSpawn("myt",91,0x100,2000,(FUNCPTR)myt,0,0,0,0,0,0,0,0,0,0)==ERROR)
printf ("Spawn myadc ERROE! \n");
*/
usrEndint();
RxTest () ;
/* add application specific code here */
}
#define DEC_LOAD_STRING "" /* created in sys<device>End.c */
IMPORT END_OBJ* dec21x40EndLoad (char*, void*);
STATUS RxTest ()
{
unsigned int lTemp;
END_OBJ *lendObj;
int st;
char buff[16];
char *ip="192.168.0.77";
int inst=0;
/* load an instance of the driver */
lendObj = muxDevLoad (inst, dec21x40EndLoad,DEC_LOAD_STRING,TRUE,0,FALSE);
if (lendObj == NULL) {
printf ("Not configured lan %d\n", inst);
return -1;
}
lTemp = muxDevStart (lendObj);
if (lTemp == ERROR) {
printf ("muxLoad RAMiX did not work lan %d\n", inst);
return ERROR;
}
st = ipAttach (inst, "dc");
if( st != 0){
printf("ipAttach failed with status %d\n", st);
return ERROR;
}
sprintf(buff, "dc%d", inst);
if( ip == 0){
printf("Default to 192.168.0.76\n");
st = ifAddrSet (buff, "192.168.0.76");
}
else{
printf("Set to %s\n", ip);
st = ifAddrSet (buff, ip);
}
printf("Address set %s.\n", st < 0 ? "failed" : "OK");
if (st < 0)
printf("This is probably because you have tried to set the address of\n"
"the interface to be on the same subnet as another interface.\n");
return 0;
}
extern int ipEtherResolvRtn (FUNCPTR, struct mbuf *, struct sockaddr *,
struct ifnet *, struct rtentry *, char *);
STATUS usrEndint()
{
int count=1;
void * pCookie = NULL;
/* Add our default address resolution functions. */
#ifdef INCLUDE_NT_ULIP
muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, ntResolv);
#else
muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, ipEtherResolvRtn);
#endif
pCookie =
muxDevLoad (count, dec21x40EndLoad,DEC_LOAD_STRING,TRUE,0,FALSE);
if (pCookie == NULL)
{
printf("muxDevLoad failed for device entry %d!\n", count);
}
else
{
if (muxDevStart(pCookie) == ERROR)
{
printf("muxDevStart failed for device entry %d!\n", count);
}
#ifdef END_POLL_STATS_ROUTINE_HOOK
endPollStatsInit (pCookie, END_POLL_STATS_ROUTINE_HOOK);
#endif /* END_POLL_STATS_ROUTINE_HOOK */
}
return (OK);
}
# define DEFAULT_BOOT_LINE \
"dc(0,0)host:vxWorks h=192.168.0.158 e=192.168.0.76 u=765 pw=765"
void myend()
{
char *params;
BOOT_PARAMS *pBoot = DEFAULT_BOOT_LINE;
char prot=0;
void *pBuff;
prot = ((pBoot->flags)>>3) & 3;
if ( prot == 0 ) /* use tftp to get image */
{
pBoot->flags = 0x80;
}
else
{
pBoot->flags = 0x0;
}
params = malloc(1024);
if (params == NULL)
{
printf("\r\nMemory malloc error for bootline.\r\n");
}
bootStructToString(params, (BOOT_PARAMS *)DEFAULT_BOOT_LINE);
/*usrBootLineInit (sysStartType);*/ /* crack the bootline */
usrNetInit (params); /* initialize network support */
ifMaskSet ("dc0", 0xfffffff0);
pBuff = malloc(sizeof(BOOT_PARAMS));
memcpy(pBuff, DEFAULT_BOOT_LINE, sizeof(BOOT_PARAMS));
pBoot = (BOOT_PARAMS *)pBuff;
strcpy(pBoot->bootDev, "dc");
pBoot->unitNum = 1;
strcpy(pBoot->ead, "192.168.0.176:fffffff0");
strcpy(pBoot->had, "192.168.0.158");
bootStructToString(params, (BOOT_PARAMS *)pBoot);
usrNetInit (params); /* initialize network support */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -