Skip to content

Commit a0a03d7

Browse files
ioannisggalak
authored andcommitted
arch: arm: common Armv8-M support
This PR includes the required changes in order to support conditional compilation for Armv8-M architecture. Two variants of the Armv8-M architecture are defined: - the Armv8-M Baseline (backwards compatible with ARMv6-M), - the Armv8-M Mainline (backwards compatible with ARMv7-M). Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent edbce1c commit a0a03d7

File tree

21 files changed

+197
-115
lines changed

21 files changed

+197
-115
lines changed

arch/arm/core/cortex_m/Kconfig

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,26 @@ config CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP
6565
This option signifies the Cortex-M0 has some mechanisms that can map
6666
the vector table to SRAM
6767

68-
config ARMV6_M
68+
config ARMV6_M_ARMV8_M_BASELINE
6969
bool
7070
# Omit prompt to signify "hidden" option
7171
default n
7272
select ATOMIC_OPERATIONS_C
7373
select ISA_THUMB2
7474
help
75-
This option signifies the use of an ARMv6-M processor implementation.
75+
This option signifies the use of an ARMv6-M processor
76+
implementation, or the use of an ARMv8-M processor
77+
supporting the Baseline implementation.
7678

77-
config ARMV7_M
79+
Notes:
80+
- A Processing Element (PE) without the Main Extension
81+
is also referred to as a Baseline Implementation. A
82+
Baseline implementation has a subset of the instructions,
83+
registers, and features, of a Mainline implementation.
84+
- ARMv6-M compatibility is provided by all ARMv8-M
85+
implementations.
86+
87+
config ARMV7_M_ARMV8_M_MAINLINE
7888
bool
7989
# Omit prompt to signify "hidden" option
8090
default n
@@ -84,40 +94,51 @@ config ARMV7_M
8494
select CPU_CORTEX_M_HAS_VTOR
8595
select CPU_CORTEX_M_HAS_PROGRAMMABLE_FAULT_PRIOS
8696
help
87-
This option signifies the use of an ARMv7-M processor implementation.
97+
This option signifies the use of an ARMv7-M processor
98+
implementation, or the use of an ARMv8-M processor
99+
implementation supporting the Main Extension.
100+
101+
Notes:
102+
- A Processing Element (PE) with the Main Extension is also
103+
referred to as a Mainline Implementation.
104+
- ARMv7-M compatibility requires the Main Extension.
105+
106+
From https://developer.arm.com/products/architecture/m-profile:
107+
The Main Extension provides backwards compatibility
108+
with ARMv7-M.
88109

89110
config CPU_CORTEX_M0
90111
bool
91112
# Omit prompt to signify "hidden" option
92-
select ARMV6_M
113+
select ARMV6_M_ARMV8_M_BASELINE
93114
help
94115
This option signifies the use of a Cortex-M0 CPU
95116

96117
config CPU_CORTEX_M0PLUS
97118
bool
98119
# Omit prompt to signify "hidden" option
99-
select ARMV6_M
120+
select ARMV6_M_ARMV8_M_BASELINE
100121
help
101122
This option signifies the use of a Cortex-M0+ CPU
102123

103124
config CPU_CORTEX_M3
104125
bool
105126
# Omit prompt to signify "hidden" option
106-
select ARMV7_M
127+
select ARMV7_M_ARMV8_M_MAINLINE
107128
help
108129
This option signifies the use of a Cortex-M3 CPU
109130

110131
config CPU_CORTEX_M4
111132
bool
112133
# Omit prompt to signify "hidden" option
113-
select ARMV7_M
134+
select ARMV7_M_ARMV8_M_MAINLINE
114135
help
115136
This option signifies the use of a Cortex-M4 CPU
116137

117138
config CPU_CORTEX_M7
118139
bool
119140
# Omit prompt to signify "hidden" option
120-
select ARMV7_M
141+
select ARMV7_M_ARMV8_M_MAINLINE
121142
default n
122143
help
123144
This option signifies the use of a Cortex-M7 CPU
@@ -177,7 +198,7 @@ config XIP
177198
endmenu
178199

179200
menu "ARM Cortex-M0/M0+/M3/M4/M7 options"
180-
depends on ARMV6_M || ARMV7_M
201+
depends on ARMV6_M_ARMV8_M_BASELINE || ARMV7_M_ARMV8_M_MAINLINE
181202

182203
config GEN_ISR_TABLES
183204
default y

arch/arm/core/cortex_m/reset.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__reset)
5858
SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)
5959

6060
/* lock interrupts: will get unlocked when switch to main task */
61-
#if defined(CONFIG_ARMV6_M)
61+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
6262
cpsid i
63-
#elif defined(CONFIG_ARMV7_M)
63+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
6464
movs.n r0, #_EXC_IRQ_DEFAULT_PRIO
6565
msr BASEPRI, r0
6666
#else
6767
#error Unknown ARM architecture
68-
#endif /* CONFIG_ARMV6_M */
68+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
6969

7070
#ifdef CONFIG_WDOG_INIT
7171
/* board-specific watchdog initialization is necessary */

arch/arm/core/cortex_m/vector_table.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table)
3939
.word __nmi
4040

4141
.word __hard_fault
42-
#if defined(CONFIG_ARMV6_M)
42+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
4343
.word __reserved
4444
.word __reserved
4545
.word __reserved
@@ -49,7 +49,7 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table)
4949
.word __reserved
5050
.word __svc
5151
.word __reserved
52-
#elif defined(CONFIG_ARMV7_M)
52+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
5353
.word __mpu_fault
5454
.word __bus_fault
5555
.word __usage_fault
@@ -61,7 +61,7 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table)
6161
.word __debug_monitor
6262
#else
6363
#error Unknown ARM architecture
64-
#endif /* CONFIG_ARMV6_M */
64+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
6565
.word __reserved
6666
.word __pendsv
6767
#if defined(CONFIG_CORTEX_M_SYSTICK)

arch/arm/core/cortex_m/vector_table.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ GTEXT(_vector_table)
3838
GTEXT(__reset)
3939
GTEXT(__nmi)
4040
GTEXT(__hard_fault)
41-
#if defined(CONFIG_ARMV6_M)
41+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
4242
GTEXT(__svc)
43-
#elif defined(CONFIG_ARMV7_M)
43+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
4444
GTEXT(__mpu_fault)
4545
GTEXT(__bus_fault)
4646
GTEXT(__usage_fault)
4747
GTEXT(__svc)
4848
GTEXT(__debug_monitor)
4949
#else
5050
#error Unknown ARM architecture
51-
#endif /* CONFIG_ARMV6_M */
51+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
5252
GTEXT(__pendsv)
5353
GTEXT(__reserved)
5454

arch/arm/core/cpu_idle.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ SECTION_FUNC(TEXT, k_cpu_idle)
120120
mov lr, r0
121121
#endif
122122

123-
#if defined(CONFIG_ARMV6_M)
123+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
124124
cpsie i
125-
#elif defined(CONFIG_ARMV7_M)
125+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
126126
/* clear BASEPRI so wfi is awakened by incoming interrupts */
127127
eors.n r0, r0
128128
msr BASEPRI, r0
129129
#else
130130
#error Unknown ARM architecture
131-
#endif /* CONFIG_ARMV6_M */
131+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
132132

133133
wfi
134134

@@ -177,7 +177,7 @@ SECTION_FUNC(TEXT, k_cpu_atomic_idle)
177177

178178
/* r0: interrupt mask from caller */
179179

180-
#if defined(CONFIG_ARMV6_M)
180+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
181181
/* No BASEPRI, call wfe directly (SEVONPEND set in _CpuIdleInit()) */
182182
wfe
183183

@@ -186,7 +186,7 @@ SECTION_FUNC(TEXT, k_cpu_atomic_idle)
186186
cpsie i
187187
_irq_disabled:
188188

189-
#elif defined(CONFIG_ARMV7_M)
189+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
190190
/* r1: zero, for setting BASEPRI (needs a register) */
191191
eors.n r1, r1
192192

@@ -199,5 +199,5 @@ _irq_disabled:
199199
cpsie i
200200
#else
201201
#error Unknown ARM architecture
202-
#endif /* CONFIG_ARMV6_M */
202+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
203203
bx lr

arch/arm/core/exc_exit.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, _ExcExit)
9090
#ifdef CONFIG_TIMESLICING
9191
push {lr}
9292
bl _update_time_slice_before_swap
93-
#if defined(CONFIG_ARMV6_M)
93+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
9494
pop {r0}
9595
mov lr, r0
9696
#else
9797
pop {lr}
98-
#endif /* CONFIG_ARMV6_M */
98+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
9999
#endif /* CONFIG_TIMESLICING */
100100

101101
/* context switch required, pend the PendSV exception */
@@ -111,12 +111,12 @@ _EXIT_EXC:
111111
#ifdef CONFIG_STACK_SENTINEL
112112
push {lr}
113113
bl _check_stack_sentinel
114-
#if defined(CONFIG_ARMV6_M)
114+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
115115
pop {r0}
116116
mov lr, r0
117117
#else
118118
pop {lr}
119-
#endif /* CONFIG_ARMV6_M */
119+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
120120
#endif /* CONFIG_STACK_SENTINEL */
121121

122122
bx lr

arch/arm/core/fault.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void _FaultDump(const NANO_ESF *esf, int fault)
5959
k_current_get(),
6060
esf->pc);
6161

62-
#if defined(CONFIG_ARMV6_M)
63-
#elif defined(CONFIG_ARMV7_M)
62+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
63+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
6464
int escalation = 0;
6565

6666
if (3 == fault) { /* hard fault */
@@ -92,7 +92,7 @@ void _FaultDump(const NANO_ESF *esf, int fault)
9292
SCB->CFSR |= SCB_CFSR_USGFAULTSR_Msk;
9393
#else
9494
#error Unknown ARM architecture
95-
#endif /* CONFIG_ARMV6_M */
95+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
9696
}
9797
#endif
9898

@@ -112,8 +112,9 @@ static void _FaultThreadShow(const NANO_ESF *esf)
112112
k_current_get(), esf->pc);
113113
}
114114

115-
#if defined(CONFIG_ARMV6_M)
116-
#elif defined(CONFIG_ARMV7_M)
115+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
116+
/* HardFault is used for all fault conditions on ARMv6-M. */
117+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
117118

118119
/**
119120
*
@@ -240,7 +241,7 @@ static void _DebugMonitor(const NANO_ESF *esf)
240241

241242
#else
242243
#error Unknown ARM architecture
243-
#endif /* CONFIG_ARMV6_M */
244+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
244245

245246
/**
246247
*
@@ -254,9 +255,9 @@ static void _HardFault(const NANO_ESF *esf)
254255
{
255256
PR_EXC("***** HARD FAULT *****\n");
256257

257-
#if defined(CONFIG_ARMV6_M)
258+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
258259
_FaultThreadShow(esf);
259-
#elif defined(CONFIG_ARMV7_M)
260+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
260261
if (SCB->HFSR & SCB_HFSR_VECTTBL_Msk) {
261262
PR_EXC(" Bus fault on vector table read\n");
262263
} else if (SCB->HFSR & SCB_HFSR_FORCED_Msk) {
@@ -271,7 +272,7 @@ static void _HardFault(const NANO_ESF *esf)
271272
}
272273
#else
273274
#error Unknown ARM architecture
274-
#endif /* CONFIG_ARMV6_M */
275+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
275276
}
276277

277278
/**
@@ -316,8 +317,9 @@ static void _FaultDump(const NANO_ESF *esf, int fault)
316317
case 3:
317318
_HardFault(esf);
318319
break;
319-
#if defined(CONFIG_ARMV6_M)
320-
#elif defined(CONFIG_ARMV7_M)
320+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
321+
/* HardFault is used for all fault conditions on ARMv6-M. */
322+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
321323
case 4:
322324
_MpuFault(esf, 0);
323325
break;
@@ -332,7 +334,7 @@ static void _FaultDump(const NANO_ESF *esf, int fault)
332334
break;
333335
#else
334336
#error Unknown ARM architecture
335-
#endif /* CONFIG_ARMV6_M */
337+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
336338
default:
337339
_ReservedException(esf, fault);
338340
break;
@@ -375,10 +377,10 @@ void _Fault(const NANO_ESF *esf)
375377
*/
376378
void _FaultInit(void)
377379
{
378-
#if defined(CONFIG_ARMV6_M)
379-
#elif defined(CONFIG_ARMV7_M)
380+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
381+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
380382
SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk;
381383
#else
382384
#error Unknown ARM architecture
383-
#endif /* CONFIG_ARMV6_M */
385+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
384386
}

arch/arm/core/fault_s.S

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ _ASM_FILE_PROLOGUE
2020
GTEXT(_Fault)
2121

2222
GTEXT(__hard_fault)
23-
#if defined(CONFIG_ARMV6_M)
24-
#elif defined(CONFIG_ARMV7_M)
23+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
24+
/* HardFault is used for all fault conditions on ARMv6-M. */
25+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
2526
GTEXT(__mpu_fault)
2627
GTEXT(__bus_fault)
2728
GTEXT(__usage_fault)
2829
GTEXT(__debug_monitor)
2930
#else
3031
#error Unknown ARM architecture
31-
#endif /* CONFIG_ARMV6_M */
32+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
3233
GTEXT(__reserved)
3334

3435
/**
@@ -55,18 +56,19 @@ GTEXT(__reserved)
5556
*/
5657

5758
SECTION_SUBSEC_FUNC(TEXT,__fault,__hard_fault)
58-
#if defined(CONFIG_ARMV6_M)
59-
#elif defined(CONFIG_ARMV7_M)
59+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
60+
/* HardFault is used for all fault conditions on ARMv6-M. */
61+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
6062
SECTION_SUBSEC_FUNC(TEXT,__fault,__mpu_fault)
6163
SECTION_SUBSEC_FUNC(TEXT,__fault,__bus_fault)
6264
SECTION_SUBSEC_FUNC(TEXT,__fault,__usage_fault)
6365
SECTION_SUBSEC_FUNC(TEXT,__fault,__debug_monitor)
6466
#else
6567
#error Unknown ARM architecture
66-
#endif /* CONFIG_ARMV6_M */
68+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
6769
SECTION_SUBSEC_FUNC(TEXT,__fault,__reserved)
6870

69-
#if defined(CONFIG_ARMV6_M)
71+
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
7072
/* force unlock interrupts */
7173
cpsie i
7274

@@ -83,7 +85,7 @@ _stack_frame_msp:
8385
mrs r0, MSP
8486
_stack_frame_endif:
8587

86-
#elif defined(CONFIG_ARMV7_M)
88+
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
8789
/* force unlock interrupts */
8890
eors.n r0, r0
8991
msr BASEPRI, r0
@@ -102,7 +104,7 @@ _stack_frame_endif:
102104
* frame is on the PSP */
103105
#else
104106
#error Unknown ARM architecture
105-
#endif /* CONFIG_ARMV6_M */
107+
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
106108

107109
push {lr}
108110
bl _Fault

0 commit comments

Comments
 (0)