FloatPoint in ISR

Till Straumann strauman at slac.stanford.edu
Mon Apr 25 15:30:24 UTC 2005


Manuel Pedro Coutinho wrote:

>
> Hello again!
>
> I'm now in need of float point operations inside an interuption 
> handler in the pc386 BSP. I've seen that the initial task has to have 
> float point but apparently this isn't enough... All my tasks now have 
> float point attributes but the ISR just blocks after performing the 
> first float point operation.
>
> Can float point operations be done inside an ISR? and if so, can 
> anyone tell me how to allow this? 

An ISR is not operating in any task context - therefore it doesn't 
matter if tasks are FP enabled.

RTEMS has to save the register context before dispatching an ISR and for 
sake of performance
the FP registers are usually *not* saved. In order to detect illegal FP 
usage by ISRs, the FPU
should be disabled during execution of ISRs (I'm more familiar with PPC 
than with the i386 BSP
- a problem with the PPC BSPs I recently discovered was just that the FP 
context was not saved
but the FPU was not disabled either --> corruption by an ISR was hard to 
detect. I suspect the
i386 BSP is better in that regard and possibly disables the FPU prior to 
dispatching to your ISR.)

That said, here's what you have to do if you want to use the FPU from an 
ISR:

ISR {

enable_FPU();
save_caller_saved_FP_registers();

your_fp_routine();

restore_caller_saved_FP_registers();
disable_FPU();
}

Call your 'real' routine as a subroutine from the 'wrapper'
so you only have to save/restore the 'caller-saved' FP registers
(according to the x86 ABI - don't know by heart) any others are
been taken care of by the compiler.

HTH

-- Till

>
>
> Many Thanks
> Manuel Coutinho
>
> _________________________________________________________________
> MSN Busca: fácil, rápido, direto ao ponto.  http://search.msn.com.br
>






More information about the users mailing list