Skip to content

Commit c6141c4

Browse files
ibirnbaumcarlescufi
authored andcommitted
arch: arm: core: aarch32: enable ARMv7-R/Cortex-R code for ARMv7-A/Cortex-A
Modify #ifdefs so that any code that is compiled if CONFIG_ARMV7_R is set is also compiled if CONFIG_ARMV7_A is set. Modify #ifdefs so that any code that is compiled if CONFIG_CPU_CORTEX_R is set is also compiled if CONFIG_CPU_AARCH32_CORTEX_A is set. Modify source dir inclusion in CMakeLists.txt accordingly. Brief file descriptions have been updated to include Cortex-A whereever only Cortex-M and Cortex-R were mentioned so far. Signed-off-by: Immo Birnbaum <[email protected]>
1 parent 70c403c commit c6141c4

File tree

13 files changed

+42
-34
lines changed

13 files changed

+42
-34
lines changed

arch/arm/core/aarch32/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ add_subdirectory_ifdef(CONFIG_ARM_MPU mpu)
3030
add_subdirectory_ifdef(CONFIG_ARM_AARCH32_MMU mmu)
3131

3232
add_subdirectory_ifdef(CONFIG_CPU_CORTEX_R cortex_a_r)
33+
add_subdirectory_ifdef(CONFIG_CPU_AARCH32_CORTEX_A cortex_a_r)
3334

3435
zephyr_linker_sources(ROM_START SORT_KEY 0x0vectors vector_table.ld)

arch/arm/core/aarch32/cpu_idle.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* @file
9-
* @brief ARM Cortex-M and Cortex-R power management
9+
* @brief ARM Cortex-A, Cortex-M and Cortex-R power management
1010
*
1111
*/
1212

@@ -135,7 +135,8 @@ SECTION_FUNC(TEXT, arch_cpu_atomic_idle)
135135
/* r0: interrupt mask from caller */
136136

137137
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) \
138-
|| defined(CONFIG_ARMV7_R)
138+
|| defined(CONFIG_ARMV7_R) \
139+
|| defined(CONFIG_ARMV7_A)
139140
/* No BASEPRI, call wfe directly
140141
* (SEVONPEND is set in z_arm_cpu_idle_init())
141142
*/

arch/arm/core/aarch32/irq_manage.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* @file
9-
* @brief ARM Cortex-M and Cortex-R interrupt management
9+
* @brief ARM Cortex-A, Cortex-M and Cortex-R interrupt management
1010
*
1111
*
1212
* Interrupt management: enabling/disabling and dynamic ISR
@@ -18,7 +18,8 @@
1818
#include <arch/cpu.h>
1919
#if defined(CONFIG_CPU_CORTEX_M)
2020
#include <arch/arm/aarch32/cortex_m/cmsis.h>
21-
#elif defined(CONFIG_CPU_CORTEX_A) || defined(CONFIG_CPU_CORTEX_R)
21+
#elif defined(CONFIG_CPU_AARCH32_CORTEX_A) \
22+
|| defined(CONFIG_CPU_CORTEX_R)
2223
#include <drivers/interrupt_controller/gic.h>
2324
#endif
2425
#include <sys/__assert.h>
@@ -92,7 +93,8 @@ void z_arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
9293
NVIC_SetPriority((IRQn_Type)irq, prio);
9394
}
9495

95-
#elif defined(CONFIG_CPU_CORTEX_A) || defined(CONFIG_CPU_CORTEX_R)
96+
#elif defined(CONFIG_CPU_AARCH32_CORTEX_A) \
97+
|| defined(CONFIG_CPU_CORTEX_R)
9698
/*
9799
* For Cortex-A and Cortex-R cores, the default interrupt controller is the ARM
98100
* Generic Interrupt Controller (GIC) and therefore the architecture interrupt
@@ -162,7 +164,8 @@ void z_irq_spurious(const void *unused)
162164
void _arch_isr_direct_pm(void)
163165
{
164166
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) \
165-
|| defined(CONFIG_ARMV7_R)
167+
|| defined(CONFIG_ARMV7_R) \
168+
|| defined(CONFIG_ARMV7_A)
166169
unsigned int key;
167170

168171
/* irq_lock() does what we wan for this CPU */
@@ -185,7 +188,8 @@ void _arch_isr_direct_pm(void)
185188
}
186189

187190
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) \
188-
|| defined(CONFIG_ARMV7_R)
191+
|| defined(CONFIG_ARMV7_R) \
192+
|| defined(CONFIG_ARMV7_A)
189193
irq_unlock(key);
190194
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
191195
__asm__ volatile("cpsie i" : : : "memory");

arch/arm/core/aarch32/isr_wrapper.S

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/**
99
* @file
10-
* @brief ARM Cortex-M and Cortex-R wrapper for ISRs with parameter
10+
* @brief ARM Cortex-A, Cortex-M and Cortex-R wrapper for ISRs with parameter
1111
*
1212
* Wrapper installed in vector table for handling dynamic interrupts that accept
1313
* a parameter.
@@ -48,7 +48,7 @@ SECTION_FUNC(TEXT, _isr_wrapper)
4848

4949
#if defined(CONFIG_CPU_CORTEX_M)
5050
push {r0,lr} /* r0, lr are now the first items on the stack */
51-
#elif defined(CONFIG_CPU_CORTEX_R)
51+
#elif defined(CONFIG_CPU_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
5252

5353
#if defined(CONFIG_USERSPACE)
5454
/* See comment below about svc stack usage */
@@ -164,7 +164,7 @@ _idle_state_cleared:
164164
/* clear kernel idle state */
165165
strne r1, [r2, #_kernel_offset_to_idle]
166166
blne z_pm_save_idle_exit
167-
#elif defined(CONFIG_ARMV7_R)
167+
#elif defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
168168
beq _idle_state_cleared
169169
movs r1, #0
170170
/* clear kernel idle state */
@@ -191,7 +191,7 @@ _idle_state_cleared:
191191
sub r0, r0, #16 /* get IRQ number */
192192
lsl r0, r0, #3 /* table is 8-byte wide */
193193
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
194-
#elif defined(CONFIG_CPU_CORTEX_R)
194+
#elif defined(CONFIG_CPU_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
195195
/* Get active IRQ number from the interrupt controller */
196196
#if !defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)
197197
bl arm_gic_get_active
@@ -233,7 +233,7 @@ _idle_state_cleared:
233233
ldm r1!,{r0,r3} /* arg in r0, ISR in r3 */
234234
blx r3 /* call ISR */
235235

236-
#if defined(CONFIG_CPU_CORTEX_R)
236+
#if defined(CONFIG_CPU_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
237237
spurious_continue:
238238
/* Signal end-of-interrupt */
239239
pop {r0, r1}
@@ -242,7 +242,7 @@ spurious_continue:
242242
#else
243243
bl z_soc_irq_eoi
244244
#endif /* !CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
245-
#endif /* CONFIG_CPU_CORTEX_R */
245+
#endif /* CONFIG_CPU_CORTEX_R || CONFIG_CPU_AARCH32_CORTEX_A */
246246

247247
#ifdef CONFIG_TRACING_ISR
248248
bl sys_trace_isr_exit
@@ -253,7 +253,7 @@ spurious_continue:
253253
mov lr, r3
254254
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
255255
pop {r0, lr}
256-
#elif defined(CONFIG_ARMV7_R)
256+
#elif defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
257257
/*
258258
* r0 and lr_irq were saved on the process stack since a swap could
259259
* happen. exc_exit will handle getting those values back

arch/arm/core/aarch32/prep_c.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <kernel_internal.h>
2121
#include <linker/linker-defs.h>
2222

23-
#if defined(CONFIG_ARMV7_R)
23+
#if defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
2424
#include <aarch32/cortex_a_r/stack.h>
2525
#endif
2626

@@ -166,6 +166,7 @@ static inline void z_arm_floating_point_init(void)
166166
#endif /* CONFIG_CPU_HAS_FPU */
167167

168168
extern FUNC_NORETURN void z_cstart(void);
169+
169170
/**
170171
*
171172
* @brief Prepare to and run C code
@@ -182,7 +183,7 @@ void z_arm_prep_c(void)
182183
#endif
183184
z_bss_zero();
184185
z_data_copy();
185-
#if defined(CONFIG_ARMV7_R) && defined(CONFIG_INIT_STACKS)
186+
#if ((defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)) && defined(CONFIG_INIT_STACKS))
186187
z_arm_init_stacks();
187188
#endif
188189
z_arm_interrupt_init();

arch/arm/core/aarch32/swap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int arch_swap(unsigned int key)
4242

4343
/* clear mask or enable all irqs to take a pendsv */
4444
irq_unlock(0);
45-
#elif defined(CONFIG_CPU_CORTEX_R)
45+
#elif defined(CONFIG_CPU_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
4646
z_arm_cortex_r_svc();
4747
irq_unlock(key);
4848
#endif

arch/arm/core/aarch32/swap_helper.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @brief Thread context switching for ARM Cortex-M and Cortex-R
1212
*
1313
* This module implements the routines necessary for thread context switching
14-
* on ARM Cortex-M and Cortex-R CPUs.
14+
* on ARM Cortex-A, Cortex-M and Cortex-R CPUs.
1515
*/
1616

1717
#include <toolchain.h>
@@ -120,7 +120,7 @@ out_fp_endif:
120120
* regardless of whether the thread has an active FP context.
121121
*/
122122
#endif /* CONFIG_FPU_SHARING */
123-
#elif defined(CONFIG_ARMV7_R)
123+
#elif defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
124124
/* Store rest of process context */
125125
cps #MODE_SYS
126126
stm r0, {r4-r11, sp}
@@ -136,7 +136,7 @@ out_fp_endif:
136136
movs.n r0, #_EXC_IRQ_DEFAULT_PRIO
137137
msr BASEPRI_MAX, r0
138138
isb /* Make the effect of disabling interrupts be realized immediately */
139-
#elif defined(CONFIG_ARMV7_R)
139+
#elif defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
140140
/*
141141
* Interrupts are still disabled from arch_swap so empty clause
142142
* here to avoid the preprocessor error below
@@ -344,7 +344,7 @@ in_fp_endif:
344344
/* load callee-saved + psp from thread */
345345
add r0, r2, #_thread_offset_to_callee_saved
346346
ldmia r0, {v1-v8, ip}
347-
#elif defined(CONFIG_ARMV7_R)
347+
#elif defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
348348
_thread_irq_disabled:
349349
/* load _kernel into r1 and current k_thread into r2 */
350350
ldr r1, =_kernel
@@ -603,7 +603,7 @@ valid_syscall_id:
603603
bx lr
604604
#endif /* CONFIG_USERSPACE */
605605

606-
#elif defined(CONFIG_ARMV7_R)
606+
#elif defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
607607

608608
/**
609609
*

arch/arm/core/aarch32/thread.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
/**
88
* @file
9-
* @brief New thread creation for ARM Cortex-M and Cortex-R
9+
* @brief New thread creation for ARM Cortex-A, Cortex-M and Cortex-R
1010
*
11-
* Core thread related primitives for the ARM Cortex-M and Cortex-R
12-
* processor architecture.
11+
* Core thread related primitives for the ARM Cortex-A, Cortex-M and
12+
* Cortex-R processor architecture.
1313
*/
1414

1515
#include <kernel.h>
@@ -562,7 +562,8 @@ void arch_switch_to_main_thread(struct k_thread *main_thread, char *stack_ptr,
562562

563563
"movs r1, #0\n\t"
564564
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) \
565-
|| defined(CONFIG_ARMV7_R)
565+
|| defined(CONFIG_ARMV7_R) \
566+
|| defined(CONFIG_ARMV7_A)
566567
"cpsie i\n\t" /* __enable_irq() */
567568
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
568569
"cpsie if\n\t" /* __enable_irq(); __enable_fault_irq() */

arch/arm/include/aarch32/cortex_a_r/stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern void z_arm_init_stacks(void);
3030
*
3131
* @brief Setup interrupt stack
3232
*
33-
* On Cortex-R, the interrupt stack is set up by reset.S
33+
* On Cortex-A and Cortex-R, the interrupt stack is set up by reset.S
3434
*
3535
* @return N/A
3636
*/

arch/arm/include/kernel_arch_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#if defined(CONFIG_CPU_CORTEX_M)
2828
#include <aarch32/cortex_m/stack.h>
2929
#include <aarch32/cortex_m/exc.h>
30-
#elif defined(CONFIG_CPU_CORTEX_R)
30+
#elif defined(CONFIG_CPU_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
3131
#include <aarch32/cortex_a_r/stack.h>
3232
#include <aarch32/cortex_a_r/exc.h>
3333
#endif

0 commit comments

Comments
 (0)