سؤال

I'm working on a ARM Cortex-A9 based system running software that uses nested interrupts; however, the method for implementing nested interrupts seems to be flawed as floating-point values and operations can get corrupted.

To mitigate this I'm trying to save the states of the floating-point registers when entering an interrupting routine. The method I'm trying for FPSCR is this:

asm ("VMRS %0, FPSCR " : "=r" ( savedReg)); //Save

asm ("VMSR FPSCR, %0 " : "=r" ( savedReg)); //Restore

The read seems to work but not the write, it causes the A9 to reboot.

Is it possible to access the FPSCR in this way? What other method is recomended?

هل كانت مفيدة؟

المحلول

You are writing an undefined value to FPSCR and savedReg. You want:

asm volatile ("VMSR FPSCR, %0 " : : "r" ( savedReg)); //Restore

Also there is no guarantee that the floating point operations stay between the inline assembler (though volatile and "memory" may help), use standalone assembler.

نصائح أخرى

As far as known to me, modifying the coprocessors is allowed only in the supervisor mode.

I use a linux kernel module to run assembly code to give user mode access to interesting coprocessor registers on load. This is only useful for experiments/diagnostics, obviously not in shipping code.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top