// Device. cpp
# Include "other. H"
# Ifdef _ cplusplus
Extern "C "{
# Endif
Int initdevice (char * Arg );
# Ifdef _ cplusplus
}
# Endif
Int initdevice (char * Arg)
{
Printf ("% s \ n", ARG );
}
Use the following command to generate the. Out file:
Chmod.exe A + RX device. Out
Int dynloadout ()
{
Char szdeviceoutpath [128] = "/ata0a/APP/device. Out ";
For (Int J = 0; j <3; j ++)
{
Int fdx = open (szdeviceoutpath, o_rdonly, 0644 );
If (fdx = Error)
{
Printf ("openfile error: % s \ n", szdeviceoutpath );
Taskdelay (1000 );
Continue;
}
Else
{
Module_id modid = loadmodule (fdx, load_all_symbols );
Close (fdx );
If (modid = 0)
{
Printf ("loadmodule error \ n ");
Return 1;
}
Break;
}
}
Printf ("loadmodule OK \ n ");
Extern symtab_id syssymtbl;
Funcptr deviceentry = 0;
Sym_type type;
Status stus = symfindbyname (syssymtbl, "initdevice", (char **) & deviceentry, & type );
If (stus = Error)
{
Printf ("symfindbyname error \ n ");
Return 1;
}
Else
{
Printf ("deviceentry = 0x % x, type = % d \ n", (INT) deviceentry, (INT) type );
Char szpara [128] = "have a test! "
(* Deviceentry) (szpara );
}
}