A little observation on the function calls over PTP:
PTP_CHDK_CallFunction in ptp.c just plunges into the foreign code like this:
ptp.param1=((int(*)(int,int,int,int,int,int,int,int,int,int))buf[0])(buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7],buf[8],buf[9],buf[10])
This will work with the functions that nicely return with "BX LR" or similar, but will likely crash at the often encountered MOV PC,LR, failing to return to thumb. Also, vararg functions cannot be called this way.
There used to be reyalp's call_vararg_func(), which could be used here like this:
ptp.param1 = call_vararg_func(buf[0], &buf[1], 4); // limit to 4 args, to save some hassle,
but I don't find it in the current trunk.
Has it changed, or is there a better way?
Edit 1: damn arm asm...
Edit 2: thanks, reyalp