Skip to content

Commit e4b924f

Browse files
committed
Move assembly instructions to portASM file
1 parent e4d3814 commit e4b924f

File tree

2 files changed

+79
-31
lines changed

2 files changed

+79
-31
lines changed

portable/GCC/ARM_CRx_No_GIC/portASM.S

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
.text
3030
.arm
3131

32-
.set SYS_MODE, 0x1f
33-
.set SVC_MODE, 0x13
34-
.set IRQ_MODE, 0x12
32+
.set SYS_MODE, 0x1f
33+
.set SVC_MODE, 0x13
34+
.set IRQ_MODE, 0x12
35+
.set CPSR_I_BIT, 0x80
3536

3637
/* Variables and functions. */
3738
.extern pxCurrentTCB
@@ -47,6 +48,10 @@
4748
.global vPortRestoreTaskContext
4849
.global vPortInitialiseFPSCR
4950
.global ulReadAPSR
51+
.global vPortYield
52+
.global vPortEnableInterrupts
53+
.global vPortDisableInterrupts
54+
.global ulPortSetInterruptMaskFromISR
5055

5156
/*-----------------------------------------------------------*/
5257

@@ -142,6 +147,8 @@ FreeRTOS_SVC_Handler:
142147
/*-----------------------------------------------------------*/
143148

144149
/*
150+
* void vPortRestoreTaskContext( void );
151+
*
145152
* vPortRestoreTaskContext is used to start the scheduler.
146153
*/
147154
.align 4
@@ -154,6 +161,8 @@ vPortRestoreTaskContext:
154161
/*-----------------------------------------------------------*/
155162

156163
/*
164+
* void vPortInitialiseFPSCR( void );
165+
*
157166
* vPortInitialiseFPSCR is used to initialize the FPSCR register.
158167
*/
159168
.align 4
@@ -166,13 +175,66 @@ vPortInitialiseFPSCR:
166175
/*-----------------------------------------------------------*/
167176

168177
/*
178+
* uint32_t ulReadAPSR( void );
179+
*
169180
* ulReadAPSR is used to read the value of APSR context.
170181
*/
171182
.align 4
172183
.type ulReadAPSR, %function
173184
ulReadAPSR:
174185
MRS R0, APSR
175-
BX LR
186+
BX LR
187+
188+
/*-----------------------------------------------------------*/
189+
190+
/*
191+
* void vPortYield( void );
192+
*/
193+
.align 4
194+
.type vPortYield, %function
195+
vPortYield:
196+
SVC 0
197+
ISB
198+
BX LR
199+
200+
/*-----------------------------------------------------------*/
201+
202+
/*
203+
* void vPortEnableInterrupts( void );
204+
*/
205+
.align 4
206+
.type vPortEnableInterrupts, %function
207+
vPortEnableInterrupts:
208+
CPSIE I
209+
BX LR
210+
211+
/*-----------------------------------------------------------*/
212+
213+
/*
214+
* void vPortDisableInterrupts( void );
215+
*/
216+
.align 4
217+
.type vPortDisableInterrupts, %function
218+
vPortDisableInterrupts:
219+
CPSID I
220+
DSB
221+
ISB
222+
BX LR
223+
224+
/*-----------------------------------------------------------*/
225+
226+
/*
227+
* uint32_t ulPortSetInterruptMaskFromISR( void );
228+
*/
229+
.align 4
230+
.type ulPortSetInterruptMaskFromISR, %function
231+
ulPortSetInterruptMaskFromISR:
232+
MRS R0, CPSR
233+
AND R0, R0, #CPSR_I_BIT
234+
CPSID I
235+
DSB
236+
ISB
237+
BX LR
176238

177239
/*-----------------------------------------------------------*/
178240

portable/GCC/ARM_CRx_No_GIC/portmacro.h

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ typedef uint32_t TickType_t;
8888
}
8989

9090
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
91-
#define portYIELD() \
92-
__asm volatile ( "SWI 0 \n" \
93-
"ISB " ::: "memory" );
91+
92+
void vPortYield( void );
93+
94+
#define portYIELD() vPortYield();
9495

9596
/*-----------------------------------------------------------*/
9697

@@ -100,36 +101,21 @@ typedef uint32_t TickType_t;
100101

101102
extern void vPortEnterCritical( void );
102103
extern void vPortExitCritical( void );
103-
extern uint32_t ulPortSetInterruptMask( void );
104-
extern void vPortClearInterruptMask( uint32_t ulNewMaskValue );
105-
extern void vPortInstallFreeRTOSVectorTable( void );
104+
extern void vPortEnableInterrupts( void );
105+
extern void vPortDisableInterrupts( void );
106+
extern uint32_t ulPortSetInterruptMaskFromISR( void );
106107

107108
/* The I bit within the CPSR. */
108109
#define portINTERRUPT_ENABLE_BIT ( 1 << 7 )
109110

110111
/* In the absence of a priority mask register, these functions and macros
111112
* globally enable and disable interrupts. */
112-
#define portENTER_CRITICAL() vPortEnterCritical();
113-
#define portEXIT_CRITICAL() vPortExitCritical();
114-
#define portENABLE_INTERRUPTS() __asm volatile ( "CPSIE i \n" ::: "memory" );
115-
#define portDISABLE_INTERRUPTS() \
116-
__asm volatile ( "CPSID i \n" \
117-
"DSB \n" \
118-
"ISB " ::: "memory" );
119-
120-
__attribute__( ( always_inline ) ) static __inline uint32_t portINLINE_SET_INTERRUPT_MASK_FROM_ISR( void )
121-
{
122-
volatile uint32_t ulCPSR;
123-
124-
__asm volatile ( "MRS %0, CPSR" : "=r" ( ulCPSR )::"memory" );
125-
126-
ulCPSR &= portINTERRUPT_ENABLE_BIT;
127-
portDISABLE_INTERRUPTS();
128-
return ulCPSR;
129-
}
130-
131-
#define portSET_INTERRUPT_MASK_FROM_ISR() portINLINE_SET_INTERRUPT_MASK_FROM_ISR()
132-
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) do { if( x == 0 ) portENABLE_INTERRUPTS( ); } while( 0 )
113+
#define portENTER_CRITICAL() vPortEnterCritical();
114+
#define portEXIT_CRITICAL() vPortExitCritical();
115+
#define portENABLE_INTERRUPTS() vPortEnableInterrupts();
116+
#define portDISABLE_INTERRUPTS() vPortDisableInterrupts();
117+
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMaskFromISR();
118+
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) do { if( x == 0 ) portENABLE_INTERRUPTS(); } while( 0 )
133119

134120
/*-----------------------------------------------------------*/
135121

0 commit comments

Comments
 (0)