Fix bugs in lazy FPU register saving
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4427 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
92f566a2c1
commit
f99a779f4f
@ -77,66 +77,29 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
/* Given a uint8_t array of size CONFIG_EXAMPLES_OSTEST_FPUSIZE, this
|
/* Given an array of size CONFIG_EXAMPLES_OSTEST_FPUSIZE, this function will return
|
||||||
* function will return the current FPU registers.
|
* the current FPU registers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void arch_getfpu(FAR uint8_t *fpusave)
|
void arch_getfpu(FAR uint32_t *fpusave)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
uint32_t regs[XCPTCONTEXT_REGS];
|
uint32_t regs[XCPTCONTEXT_REGS];
|
||||||
|
|
||||||
flags = irqsave();
|
flags = irqsave();
|
||||||
up_savefpu(regs);
|
up_savefpu(regs); /* Saves the context of the FPU registers to memory */
|
||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
|
|
||||||
memcpy(fpusave, ®s[REG_S0], (4*SW_FPU_REGS));
|
memcpy(fpusave, ®s[REG_S0], (4*SW_FPU_REGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Given a uint8_t array of size CONFIG_EXAMPLES_OSTEST_FPUSIZE, this
|
/* Given two arrays of size CONFIG_EXAMPLES_OSTEST_FPUSIZE this function
|
||||||
* function will set the current FPU regisers to match the provided
|
* will compare then an return true if they are identical.
|
||||||
* register save set.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void arch_setfpu(FAR const uint8_t *fpusave)
|
bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0;
|
||||||
uint32_t regs[XCPTCONTEXT_REGS];
|
|
||||||
|
|
||||||
memcpy(®s[REG_S0], fpusave, (4*SW_FPU_REGS));
|
|
||||||
|
|
||||||
flags = irqsave();
|
|
||||||
up_restorefpu(regs);
|
|
||||||
irqrestore(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Given a uint8_t array of size CONFIG_EXAMPLES_OSTEST_FPUSIZE and a
|
|
||||||
* seed value, this function will set the FPU registers to a known
|
|
||||||
* values for testing purposes. The contents of the FPU registers
|
|
||||||
* must be uniqe for each sed value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void arch_initfpu(FAR uint8_t *fpusave, int seed)
|
|
||||||
{
|
|
||||||
FAR uint32_t *dest = (FAR uint32_t *)fpusave;
|
|
||||||
uint32_t mask = 0x01010101;
|
|
||||||
uint32_t incr = 0x01010101;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 32; i++)
|
|
||||||
{
|
|
||||||
*dest = (uint32_t)seed ^ mask;
|
|
||||||
mask += incr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Given two uint8_t arrays of size CONFIG_EXAMPLES_OSTEST_FPUSIZE this
|
|
||||||
* function will compare then an return true if they are identical.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool arch_cmpfpu(FAR const uint8_t *fpusave1, FAR const uint8_t *fpusave2)
|
|
||||||
{
|
|
||||||
return memcmp(fpusave1, fpusave2, (4*32)) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_FPU */
|
#endif /* HAVE_FPU */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user