I have an image project that builds the kernel that I want. I also
have a DKM project to build the application that I want. Now I'd like
to combine the two so when my system boots it automatically starts my
application.
I think I just need to call the application from usrAppInit, however,
how do I link the DKM's .out into the kernel? Do I need to build a
library first? etc.
Can someone describe the steps or point me to some documentation?
Many Thanks.
John.
Maybe you don't need to statically link your application with your
VxWorks image. If you can copy the application's .out file to the
same file system on which you store the VxWorks image then you could
code usrAppInit() to use loadModuleAt() to load the application in
memory, symFindByName() to find the application's entry point, and
finally call that entry point.
--
========================================================================
Michael Kesti | "And like, one and one don't make
| two, one and one make one."
mrkesti at hotmail dot com | - The Who, Bargain
Michael,
Thanks that's an interesting solution. I'll have to give it a try.
I found information on other ways to do this but had limited success:
1. Add the path to the .out file as a value to the EXTRA_MODULES
macro.
Unfortunately when I rebuilt my kernel I got linking errors; 'multiple
definition of _ctors and _dtors'
Didn't try to solve this one.
2. Use a boot script to load the module. I ran into the problem of
Relocation value does not fit in 24 bits (I'm on a PowerPC with 128MB
of ram)
The normal fix of using the -mlongcall flag with the compiler didn't
work.
I haven't tried other fixes which basically fool the system to think
there's less memory when loading the module.
3. Combine the kernel image project and DKM project into one big
kernel image project so the application is already built into the
kernel.
This is what I did. I don't like having one big project but it works.
HTH anyone else asking this same question.
Hi,
have you tried this in the usrAppInit.c?
The problem is that the entry point of your application cannot be
resolved when the VxWorks image is loading. So write a function to
resolve the entry point of your application after loading it. That
way, there will be no unresolved identifiers when the VxWorks image is
loading, and then when the image starts executing in usrAppInit.c,
your function will cause a jump to the entry point of your
application. We have the following functions defined in usrAppInit.c.
Below, "myEntryPointSymbol" will depend on how your linker puts
together the symbols. (For example, if one were creating the app with
RoseRealTime and Tornado2.02, the symbol "_rtsMain" is generated for
the entry point rtsMain() ). Generally, as it might be in your case,
is it "_main"???
cheers.
LOCAL STATUS loadApplicationModule ( char *fileName ){
int fd = open(fileName, O_RDONLY, 0);.
MODULE_ID moduleId;
printErr("loading application module %s...", fileName);
if( fd != ERROR ){
moduleId = loadModule(fd, LOAD_ALL_SYMBOLS);
close(fd);
} else {
printErr("file open error %08X\n", errno);
}
if( moduleId != NULL){
FUNCPTR startfunction;
SYM_TYPE symtype;
STATUS rc;
printErr("search entry point in module %08X...\n", moduleId );
rc = symFindByName( sysSymTbl, "myEntryPointSymbol", (char **)
&startfunction, &symtype);
if ( rc == OK ){
printErr("starting at %p %d\n", startfunction, symtype);
startfunction("myApp", "-oblisten 35518", "-URTS_DEBUG=quit");
} else {
printErr("entry point not found error %08X\n", errno);
}
} else {
printErr("module load error %08X\n", errno);
}
return (OK);
}
void start_myApplication(){
taskSpawn(
"myApplication",
TASK_PRIORITY,
TASK_OPTIONS,
TASK_STACKSIZE,
loadApplicationModule,
(int) "myOutFileNameWithPath",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
Hi,
just a correction:
the rtsMain takes the parameters as below:
startfunction("myApp", "-oblisten 35518", "-URTS_DEBUG=quit");
In general it should be be
startfunction(param1, param2, ...);
cheers