Pascal,

Incredible. This is exactly what I need.

Thanks!!!

Craig


On 12/2/05, Pascal A. Brisset <pascal.brisset@wanadoo.fr> wrote:
Craig Casey writes:
> need, but I'd have to figure out some way to be able to program C from
> within the FIQ.

I wrote this small stub which saves registers, sets up a stack,
then calls a regular C function.  Consider it a quick-and-dirty
solution; the proper way is to link a .S file as you suggest.

Note that r8-r14 are shadowed in FIQ mode.

-- Pascal

| void fiq_handler(void) {
|         static struct pt_regs fiq_saved_regs;
|         static unsigned char fiq_stack[256];
|         __asm__ volatile (
|                 "@ Save OSCR asap for profiling                   \n\
|                 mov r9,     #0xf2000000                           \n\
|                 eor r9, r9, #0x00a00000                           \n\
|                 ldr r9, [r9, #0x10]                               \n\
|                 @ Save registers                                  \n\
|                 ldr r8, %0                                        \n\
|                 stmia r8, {r0-r3,lr}                              \n\
|                 @ Invoke the regular IRQ handler                  \n\
|                 ldr sp, %1                                        \n\
|                 @ Can't use a relative branch-and-link since this \n\
|                 @ handler will be relocated to fiq_vector.        \n\
|                 @ bl mpwm_irq_handler                             \n\
|                 mov lr, pc                                        \n\
|                 ldr pc, %2                                        \n\
|                 @ Restore registers and return                    \n\
|                 ldr r8, %0                                        \n\
|                 ldmia r8, {r0-r3,lr}                              \n\
|                 subs pc, lr, #4"
|                 :
|                 : "im"(&fiq_saved_regs.ARM_r0), "im"(&fiq_stack[256]),
|                   "im"(irq_handler));
| }
| void fiq_handler_end(void) { }

| static unsigned long *const fiq_vector = (unsigned long*)0xffff001c;
| memcpy(fiq_vector, fiq_handler+12, fiq_handler_end-fiq_handler-12);
| flush_icache_range((long)fiq_vector,
|                    (long)fiq_vector+fiq_handler_end-fiq_handler-12);



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users