diff --git a/portable/GCC/ARM_CRx_No_GIC/port.c b/portable/GCC/ARM_CRx_No_GIC/port.c index 42356f3b0..029e4f251 100644 --- a/portable/GCC/ARM_CRx_No_GIC/port.c +++ b/portable/GCC/ARM_CRx_No_GIC/port.c @@ -83,12 +83,12 @@ /*-----------------------------------------------------------*/ /* - * Starts the first task executing. These functions are necessarily written in - * assembly code so is implemented in portASM.s. + * These functions are necessarily written in assembly code, so are implemented + * in portASM.S. */ extern void vPortRestoreTaskContext( void ); extern void vPortInitialiseFPSCR( void ); -extern uint32_t ulReadValueAPSR( void ); +extern uint32_t ulReadAPSR( void ); /* * Used to catch tasks that attempt to return from their implementing function. @@ -220,7 +220,7 @@ BaseType_t xPortStartScheduler( void ) /* Only continue if the CPU is not in User mode. The CPU must be in a * Privileged mode for the scheduler to start. */ - ulAPSR = ulReadValueAPSR(); + ulAPSR = ulReadAPSR(); ulAPSR &= portAPSR_MODE_BITS_MASK; configASSERT( ulAPSR != portAPSR_USER_MODE ); @@ -321,4 +321,4 @@ void vPortTaskUsesFPU( void ) /* Initialise the floating point status register. */ vPortInitialiseFPSCR(); } -/*-----------------------------------------------------------*/ \ No newline at end of file +/*-----------------------------------------------------------*/ diff --git a/portable/GCC/ARM_CRx_No_GIC/portASM.S b/portable/GCC/ARM_CRx_No_GIC/portASM.S index a212c9590..46849c4c8 100644 --- a/portable/GCC/ARM_CRx_No_GIC/portASM.S +++ b/portable/GCC/ARM_CRx_No_GIC/portASM.S @@ -34,8 +34,6 @@ .set IRQ_MODE, 0x12 /* Variables and functions. */ - .extern ulMaxAPIPriorityMask - .extern _freertos_vector_table .extern pxCurrentTCB .extern vTaskSwitchContext .extern vApplicationIRQHandler @@ -48,30 +46,31 @@ .global FreeRTOS_SVC_Handler .global vPortRestoreTaskContext .global vPortInitialiseFPSCR - .global ulReadValueAPSR + .global ulReadAPSR +/*-----------------------------------------------------------*/ .macro portSAVE_CONTEXT /* 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 CPS #SYS_MODE PUSH {R0-R12, R14} /* Push the critical nesting count. */ - LDR R2, ulCriticalNestingConst + LDR R2, =ulCriticalNesting LDR R1, [R2] PUSH {R1} /* Does the task have a floating point context that needs saving? If - ulPortTaskHasFPUContext is 0 then no. */ - LDR R2, ulPortTaskHasFPUContextConst + * ulPortTaskHasFPUContext is 0 then no. */ + LDR R2, =ulPortTaskHasFPUContext LDR R3, [R2] CMP R3, #0 /* Save the floating point context, if any. */ - FMRXNE R1, FPSCR + VMRSNE R1, FPSCR VPUSHNE {D0-D15} #if configFPU_D32 == 1 VPUSHNE {D16-D31} @@ -82,24 +81,24 @@ PUSH {R3} /* Save the stack pointer in the TCB. */ - LDR R0, pxCurrentTCBConst + LDR R0, =pxCurrentTCB LDR R1, [R0] STR SP, [R1] .endm -; /**********************************************************************/ +/*-----------------------------------------------------------*/ .macro portRESTORE_CONTEXT /* Set the SP to point to the stack of the task being restored. */ - LDR R0, pxCurrentTCBConst + LDR R0, =pxCurrentTCB LDR R1, [R0] LDR SP, [R1] /* Is there a floating point context to restore? If the restored - ulPortTaskHasFPUContext is zero then no. */ - LDR R0, ulPortTaskHasFPUContextConst + * ulPortTaskHasFPUContext is zero then no. */ + LDR R0, =ulPortTaskHasFPUContext POP {R1} STR R1, [R0] CMP R1, #0 @@ -113,7 +112,7 @@ VMSRNE FPSCR, R0 /* Restore the critical section nesting depth. */ - LDR R0, ulCriticalNestingConst + LDR R0, =ulCriticalNesting POP {R1} STR R1, [R0] @@ -126,25 +125,25 @@ .endm +/*-----------------------------------------------------------*/ - - -/****************************************************************************** +/* * SVC handler is used to yield. - *****************************************************************************/ + */ .align 4 .type FreeRTOS_SVC_Handler, %function FreeRTOS_SVC_Handler: /* Save the context of the current task and select a new task to run. */ portSAVE_CONTEXT - LDR R0, vTaskSwitchContextConst - BLX R0 + BLX vTaskSwitchContext portRESTORE_CONTEXT -/****************************************************************************** +/*-----------------------------------------------------------*/ + +/* * vPortRestoreTaskContext is used to start the scheduler. - *****************************************************************************/ + */ .align 4 .type vPortRestoreTaskContext, %function vPortRestoreTaskContext: @@ -152,26 +151,31 @@ vPortRestoreTaskContext: CPS #SYS_MODE portRESTORE_CONTEXT +/*-----------------------------------------------------------*/ -/****************************************************************************** - * vPortInitialiseFPSCR is used to initialize the FPSCR context. - *****************************************************************************/ +/* + * vPortInitialiseFPSCR is used to initialize the FPSCR register. + */ .align 4 .type vPortInitialiseFPSCR, %function vPortInitialiseFPSCR: MOV R0, #0 - FMXR FPSCR, R0 + VMSR FPSCR, R0 BX LR -/****************************************************************************** - * ulReadValueAPSR is used to read the value of APSR context. - *****************************************************************************/ +/*-----------------------------------------------------------*/ + +/* + * ulReadAPSR is used to read the value of APSR context. + */ .align 4 -.type ulReadValueAPSR, %function -ulReadValueAPSR: +.type ulReadAPSR, %function +ulReadAPSR: MRS R0, APSR BX LR +/*-----------------------------------------------------------*/ + .align 4 .type FreeRTOS_IRQ_Handler, %function FreeRTOS_IRQ_Handler: @@ -184,29 +188,28 @@ FreeRTOS_IRQ_Handler: PUSH {lr} /* Change to supervisor mode to allow reentry. */ - CPS #0x13 + CPS #SVC_MODE /* Push used registers. */ PUSH {r0-r3, r12} /* Increment nesting count. r3 holds the address of ulPortInterruptNesting - for future use. r1 holds the original ulPortInterruptNesting value for - future use. */ - LDR r3, ulPortInterruptNestingConst + * for future use. r1 holds the original ulPortInterruptNesting value for + * future use. */ + LDR r3, =ulPortInterruptNesting LDR r1, [r3] ADD r0, r1, #1 STR r0, [r3] /* Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for - future use. */ + * future use. */ MOV r0, sp AND r2, r0, #4 SUB sp, sp, r2 /* Call the interrupt handler. */ PUSH {r0-r3, lr} - LDR r1, vApplicationIRQHandlerConst - BLX r1 + BLX vApplicationIRQHandler POP {r0-r3, lr} ADD sp, sp, r2 @@ -215,7 +218,7 @@ FreeRTOS_IRQ_Handler: ISB /* Write to the EOI register. */ - LDR r0, ulICCEOIRConst + LDR r0, =ulICCEOIR LDR r2, [r0] STR r0, [r2] @@ -227,16 +230,16 @@ FreeRTOS_IRQ_Handler: BNE exit_without_switch /* Did the interrupt request a context switch? r1 holds the address of - ulPortYieldRequired and r0 the value of ulPortYieldRequired for future - use. */ - LDR r1, ulPortYieldRequiredConst + * ulPortYieldRequired and r0 the value of ulPortYieldRequired for future + * use. */ + LDR r1, =ulPortYieldRequired LDR r0, [r1] CMP r0, #0 BNE switch_before_exit exit_without_switch: /* No context switch. Restore used registers, LR_irq and SPSR before - returning. */ + * returning. */ POP {r0-r3, r12} CPS #IRQ_MODE POP {LR} @@ -246,12 +249,12 @@ exit_without_switch: switch_before_exit: /* A context switch is to be performed. Clear the context switch pending - flag. */ + * flag. */ MOV r0, #0 STR r0, [r1] /* Restore used registers, LR-irq and SPSR before saving the context - to the task stack. */ + * to the task stack. */ POP {r0-r3, r12} CPS #IRQ_MODE POP {LR} @@ -260,23 +263,15 @@ switch_before_exit: portSAVE_CONTEXT /* Call the function that selects the new task to execute. - vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD - instructions, or 8 byte aligned stack allocated data. LR does not need - saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */ - LDR R0, vTaskSwitchContextConst - BLX R0 + * vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD + * instructions, or 8 byte aligned stack allocated data. LR does not need + * saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */ + BLX vTaskSwitchContext /* Restore the context of, and branch to, the task selected to execute - next. */ + * next. */ portRESTORE_CONTEXT -ulICCEOIRConst: .word ulICCEOIR -pxCurrentTCBConst: .word pxCurrentTCB -ulCriticalNestingConst: .word ulCriticalNesting -ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext -vTaskSwitchContextConst: .word vTaskSwitchContext -vApplicationIRQHandlerConst: .word vApplicationIRQHandler -ulPortInterruptNestingConst: .word ulPortInterruptNesting -ulPortYieldRequiredConst: .word ulPortYieldRequired +/*-----------------------------------------------------------*/ .end diff --git a/portable/GCC/ARM_CRx_No_GIC/portmacro.h b/portable/GCC/ARM_CRx_No_GIC/portmacro.h index 5a9ae265e..74a60df87 100644 --- a/portable/GCC/ARM_CRx_No_GIC/portmacro.h +++ b/portable/GCC/ARM_CRx_No_GIC/portmacro.h @@ -59,7 +59,7 @@ typedef long BaseType_t; typedef unsigned long UBaseType_t; typedef uint32_t TickType_t; -#define portMAX_DELAY ( TickType_t ) 0xffffffffUL +#define portMAX_DELAY ( TickType_t ) 0xffffffffUL /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do * not need to be guarded with a critical section. */ @@ -92,10 +92,11 @@ typedef uint32_t TickType_t; __asm volatile ( "SWI 0 \n" \ "ISB " ::: "memory" ); +/*-----------------------------------------------------------*/ -/*----------------------------------------------------------- -* Critical section control -*----------------------------------------------------------*/ +/* + * Critical section management. + */ extern void vPortEnterCritical( void ); extern void vPortExitCritical( void ); @@ -163,19 +164,15 @@ void vPortTaskUsesFPU( void ); #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 -/* Store/clear the ready priorities in a bit map. */ + /* Store, clear and get the ready priorities in a bit map. */ #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) ) #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ) - -/*-----------------------------------------------------------*/ - - #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __builtin_clz( uxReadyPriorities ) ) + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __builtin_clz( uxReadyPriorities ) ) #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ #define portNOP() __asm volatile ( "NOP" ) -#define portINLINE __inline - +#define portINLINE __inline #define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" ) /* *INDENT-OFF* */