Skip to content

Commit d6fff2a

Browse files
committed
Add ulReadValueAPSR API
1 parent 886d1fd commit d6fff2a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

portable/GCC/ARM_CRx_No_GIC/port.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@
8383
/*-----------------------------------------------------------*/
8484

8585
/*
86-
* Starts the first task executing. This function is necessarily written in
86+
* Starts the first task executing. These functions are necessarily written in
8787
* assembly code so is implemented in portASM.s.
8888
*/
8989
extern void vPortRestoreTaskContext( void );
90+
extern void vPortInitialiseFPSCR( void );
91+
extern uint32_t ulReadValueAPSR( void );
9092

9193
/*
9294
* Used to catch tasks that attempt to return from their implementing function.
@@ -218,7 +220,7 @@ BaseType_t xPortStartScheduler( void )
218220

219221
/* Only continue if the CPU is not in User mode. The CPU must be in a
220222
* Privileged mode for the scheduler to start. */
221-
__asm volatile ( "MRS %0, APSR" : "=r" ( ulAPSR )::"memory" );
223+
ulAPSR = ulReadValueAPSR();
222224

223225
ulAPSR &= portAPSR_MODE_BITS_MASK;
224226
configASSERT( ulAPSR != portAPSR_USER_MODE );
@@ -312,14 +314,11 @@ void FreeRTOS_Tick_Handler( void )
312314

313315
void vPortTaskUsesFPU( void )
314316
{
315-
//uint32_t ulInitialFPSCR = 0;
316-
317317
/* A task is registering the fact that it needs an FPU context. Set the
318318
* FPU flag (which is saved as part of the task context). */
319319
ulPortTaskHasFPUContext = pdTRUE;
320320

321321
/* Initialise the floating point status register. */
322322
vPortInitialiseFPSCR();
323-
/*__asm volatile ( "FMXR FPSCR, %0" ::"r" ( ulInitialFPSCR ) : "memory" );*/
324323
}
325324
/*-----------------------------------------------------------*/

portable/GCC/ARM_CRx_No_GIC/portASM.S

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
.global FreeRTOS_SVC_Handler
4949
.global vPortRestoreTaskContext
5050
.global vPortInitialiseFPSCR
51+
.global ulReadValueAPSR
5152

5253

5354
.macro portSAVE_CONTEXT
@@ -162,6 +163,15 @@ vPortInitialiseFPSCR:
162163
FMXR FPSCR, R0
163164
BX LR
164165

166+
/******************************************************************************
167+
* ulReadValueAPSR is used to read the value of APSR context.
168+
*****************************************************************************/
169+
.align 4
170+
.type ulReadValueAPSR, %function
171+
ulReadValueAPSR:
172+
MRS R0, APSR
173+
BX LR
174+
165175
.align 4
166176
.type FreeRTOS_IRQ_Handler, %function
167177
FreeRTOS_IRQ_Handler:

0 commit comments

Comments
 (0)