正文描述:《动态加载模块并执行指南》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、动态加载模块并执行指南1文件我们将所有编译好的模块放在服务器上(譬如:102.168.0.204上的/modules/atm目录下)配置vxworks的nfs,使之创建nfs文件系统/modules并连接到服务器上参见相关文档2VxWorks镜像裁减保证需要增加如下组件:Developmenttools/loade/targetloaderDevelopmenttools/loade/targetunloaderDevelopmenttools/symboltable/symboltableDevelopmenttools/symbolt
2、able/initializesymboltableNetworks/networkingprotocols/networkfilesystems/NFSclient1提供使用的函数wriLoadandRun1)wriLoadandRun的原形voidwriLoadandRun(char*filename,char*funcname){intfd;SYM_TYPE*pType;FUNCPTRfuncp;MODULE_IDmoduleId;charfn[100];hostAdd("Host","102.168.0.204");/*mount
3、thenfs(Networksfilesystem)atthelocale*/if(nfsMount(SERVERNAME,SERVERPATH,MOUNTENODE)==ERROR){logMsg("nfsMounterror:0x%x",errnoGet());}/*gettheabsolutepathofthefilename*/sprintf(fn,"%s/%s.out",MOUNTENODE,filename);fd=open(fn,O_RDONLY,0);if(fd==ERROR){logMsg("openerrno:0x
4、%x",errnoGet());}/*loadthemoduleinthesystemsymboltable*/if((moduleId=loadModule(fd,LOAD_ALL_SYMBOLS
5、LOAD_COMMON_MATCH_ALL))==NULL){logMsg("loadModuleerrno:0x%x",errnoGet());close(fd);return;}/*closethefile*/close(fd);/*unmountthenfsthatmountpreviously*/if(nfsUnmount(M
6、OUNTENODE)==ERROR){logMsg("nfsUnmounterror:0x%x",errnoGet());}/*findtheentryfunction*/if(symFindByName(sysSymTbl,funcname,(char**)&funcp,pType)==ERROR){logMsg("sysFindByNameerrno=%x",errnoGet());}taskSpawn(funcname,100,0,10000,(FUNCPTR)funcp,0,0,0,0,0,0,0,0,0,0);retur
7、n;}1如何使用wriLoadandRun建议在usrAppInit.c添加如下代码:在usrAppInit()加入voidusrAppInit(void){#ifdefUSER_APPL_INITUSER_APPL_INIT;/*forbackwardscompatibility*/wriLoadandRun(char*filename,char*funcname);#endif/*addapplicationspecificcodehere*/}
显示全部收起