mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-05-29 00:19:04 -04:00
Address code review suggestions
This commit is contained in:
parent
48acdd2c14
commit
3560308473
|
@ -82,11 +82,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The space on the stack required to hold the FPU registers. */
|
/* The space on the stack required to hold the FPU registers. */
|
||||||
#if ( configFPU_D32 == 1 )
|
#define portFPU_REGISTER_WORDS ( ( 16 * 2 ) + 1 ) /* D0-D15 and FPSCR. */
|
||||||
#define portFPU_REGISTER_WORDS ( ( 32 * 2 ) + 1 ) /* D0-D31 and FPSCR. */
|
|
||||||
#else
|
|
||||||
#define portFPU_REGISTER_WORDS ( ( 16 * 2 ) + 1 ) /* D0-D15 and FPSCR. */
|
|
||||||
#endif
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
/* Save the LR and SPSR onto the system mode stack before switching to
|
/* Save the LR and SPSR onto the system mode stack before switching to
|
||||||
* system mode to save the remaining system mode registers. */
|
* system mode to save the remaining system mode registers. */
|
||||||
SRSDB sp!, #SYS_MODE
|
SRSDB SP!, #SYS_MODE
|
||||||
CPS #SYS_MODE
|
CPS #SYS_MODE
|
||||||
PUSH {R0-R12, R14}
|
PUSH {R0-R12, R14}
|
||||||
|
|
||||||
|
@ -80,9 +80,6 @@
|
||||||
/* Save the floating point context, if any. */
|
/* Save the floating point context, if any. */
|
||||||
VMRSNE R1, FPSCR
|
VMRSNE R1, FPSCR
|
||||||
VPUSHNE {D0-D15}
|
VPUSHNE {D0-D15}
|
||||||
#if configFPU_D32 == 1
|
|
||||||
VPUSHNE {D16-D31}
|
|
||||||
#endif /* configFPU_D32 */
|
|
||||||
PUSHNE {R1}
|
PUSHNE {R1}
|
||||||
|
|
||||||
/* Save ulPortTaskHasFPUContext itself. */
|
/* Save ulPortTaskHasFPUContext itself. */
|
||||||
|
@ -129,7 +126,7 @@
|
||||||
POP {R0-R12, R14}
|
POP {R0-R12, R14}
|
||||||
|
|
||||||
/* Return to the task code, loading CPSR on the way. */
|
/* Return to the task code, loading CPSR on the way. */
|
||||||
RFEIA sp!
|
RFEIA SP!
|
||||||
|
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
@ -291,67 +288,68 @@ svcApplicationCall:
|
||||||
.type FreeRTOS_IRQ_Handler, %function
|
.type FreeRTOS_IRQ_Handler, %function
|
||||||
FreeRTOS_IRQ_Handler:
|
FreeRTOS_IRQ_Handler:
|
||||||
/* Return to the interrupted instruction. */
|
/* Return to the interrupted instruction. */
|
||||||
SUB lr, lr, #4
|
SUB LR, LR, #4
|
||||||
|
|
||||||
/* Push the return address and SPSR. */
|
/* Push the return address and SPSR. */
|
||||||
PUSH {lr}
|
PUSH {LR}
|
||||||
MRS lr, SPSR
|
MRS LR, SPSR
|
||||||
PUSH {lr}
|
PUSH {LR}
|
||||||
|
|
||||||
/* Change to supervisor mode to allow reentry. */
|
/* Change to supervisor mode to allow reentry. */
|
||||||
CPS #SVC_MODE
|
CPS #SVC_MODE
|
||||||
|
|
||||||
/* Push used registers. */
|
/* Push used registers. */
|
||||||
PUSH {r0-r3, r12}
|
PUSH {R0-R3, R12}
|
||||||
|
|
||||||
/* Increment nesting count. r3 holds the address of ulPortInterruptNesting
|
/* Increment nesting count. r3 holds the address of ulPortInterruptNesting
|
||||||
* for future use. r1 holds the original ulPortInterruptNesting value for
|
* for future use. r1 holds the original ulPortInterruptNesting value for
|
||||||
* future use. */
|
* future use. */
|
||||||
LDR r3, =ulPortInterruptNesting
|
LDR R3, =ulPortInterruptNesting
|
||||||
LDR r1, [r3]
|
LDR R1, [R3]
|
||||||
ADD r0, r1, #1
|
ADD R0, R1, #1
|
||||||
STR r0, [r3]
|
STR R0, [R3]
|
||||||
|
|
||||||
/* Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for
|
/* Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for
|
||||||
* future use. */
|
* future use. */
|
||||||
MOV r0, sp
|
MOV R0, SP
|
||||||
AND r2, r0, #4
|
AND R2, R0, #4
|
||||||
SUB sp, sp, r2
|
SUB SP, SP, R2
|
||||||
|
|
||||||
/* Call the interrupt handler. */
|
/* Call the interrupt handler. */
|
||||||
PUSH {r0-r3, lr}
|
PUSH {R0-R3, LR}
|
||||||
BLX vApplicationIRQHandler
|
BLX vApplicationIRQHandler
|
||||||
POP {r0-r3, lr}
|
POP {R0-R3, LR}
|
||||||
ADD sp, sp, r2
|
ADD SP, SP, R2
|
||||||
|
|
||||||
|
/* Disable IRQs incase vApplicationIRQHandler enabled them for re-entry. */
|
||||||
CPSID i
|
CPSID i
|
||||||
DSB
|
DSB
|
||||||
ISB
|
ISB
|
||||||
|
|
||||||
/* Write to the EOI register. */
|
/* Write to the EOI register. */
|
||||||
LDR r0, =ulICCEOIR
|
LDR R0, =ulICCEOIR
|
||||||
LDR r2, [r0]
|
LDR R2, [R0]
|
||||||
STR r0, [r2]
|
STR R0, [R2]
|
||||||
|
|
||||||
/* Restore the old nesting count. */
|
/* Restore the old nesting count. */
|
||||||
STR r1, [r3]
|
STR R1, [R3]
|
||||||
|
|
||||||
/* A context switch is never performed if the nesting count is not 0. */
|
/* A context switch is never performed if the nesting count is not 0. */
|
||||||
CMP r1, #0
|
CMP R1, #0
|
||||||
BNE exit_without_switch
|
BNE exit_without_switch
|
||||||
|
|
||||||
/* Did the interrupt request a context switch? r1 holds the address of
|
/* Did the interrupt request a context switch? r1 holds the address of
|
||||||
* ulPortYieldRequired and r0 the value of ulPortYieldRequired for future
|
* ulPortYieldRequired and r0 the value of ulPortYieldRequired for future
|
||||||
* use. */
|
* use. */
|
||||||
LDR r1, =ulPortYieldRequired
|
LDR R1, =ulPortYieldRequired
|
||||||
LDR r0, [r1]
|
LDR R0, [R1]
|
||||||
CMP r0, #0
|
CMP R0, #0
|
||||||
BNE switch_before_exit
|
BNE switch_before_exit
|
||||||
|
|
||||||
exit_without_switch:
|
exit_without_switch:
|
||||||
/* No context switch. Restore used registers, LR_irq and SPSR before
|
/* No context switch. Restore used registers, LR_irq and SPSR before
|
||||||
* returning. */
|
* returning. */
|
||||||
POP {r0-r3, r12}
|
POP {R0-R3, R12}
|
||||||
CPS #IRQ_MODE
|
CPS #IRQ_MODE
|
||||||
POP {LR}
|
POP {LR}
|
||||||
MSR SPSR_cxsf, LR
|
MSR SPSR_cxsf, LR
|
||||||
|
@ -361,12 +359,12 @@ exit_without_switch:
|
||||||
switch_before_exit:
|
switch_before_exit:
|
||||||
/* A context switch is to be performed. Clear the context switch pending
|
/* A context switch is to be performed. Clear the context switch pending
|
||||||
* flag. */
|
* flag. */
|
||||||
MOV r0, #0
|
MOV R0, #0
|
||||||
STR r0, [r1]
|
STR R0, [R1]
|
||||||
|
|
||||||
/* Restore used registers, LR-irq and SPSR before saving the context
|
/* Restore used registers, LR-irq and SPSR before saving the context
|
||||||
* to the task stack. */
|
* to the task stack. */
|
||||||
POP {r0-r3, r12}
|
POP {R0-R3, R12}
|
||||||
CPS #IRQ_MODE
|
CPS #IRQ_MODE
|
||||||
POP {LR}
|
POP {LR}
|
||||||
MSR SPSR_cxsf, LR
|
MSR SPSR_cxsf, LR
|
||||||
|
|
|
@ -149,8 +149,8 @@ UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
|
||||||
#if ( configUSE_TASK_FPU_SUPPORT != 2 )
|
#if ( configUSE_TASK_FPU_SUPPORT != 2 )
|
||||||
void vPortTaskUsesFPU( void );
|
void vPortTaskUsesFPU( void );
|
||||||
#else
|
#else
|
||||||
/* Each task has an FPU context already, so define this function away to
|
/* Each task has an FPU context already, so define this function as a
|
||||||
* nothing to prevent it from being called accidentally. */
|
*no-op. */
|
||||||
#define vPortTaskUsesFPU()
|
#define vPortTaskUsesFPU()
|
||||||
#endif
|
#endif
|
||||||
#define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
|
#define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
|
||||||
|
|
Loading…
Reference in a new issue