Skip to content

Commit 2aff843

Browse files
committed
arch: arm: Separate common kernel_arch_func code
This commit separates kernel_arch_func.h into two header file, 'cortex_a_r/kernel_arch_func.h' and 'cortex_m/kernel_arch_func.h', it also removes some functions which is empty. Signed-off-by: Huifeng Zhang <[email protected]>
1 parent 67e8f39 commit 2aff843

File tree

6 files changed

+163
-118
lines changed

6 files changed

+163
-118
lines changed

arch/arm/core/cortex_a_r/cpu_idle.S

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
_ASM_FILE_PROLOGUE
2121

22-
GTEXT(z_arm_cpu_idle_init)
2322
GTEXT(arch_cpu_idle)
2423
GTEXT(arch_cpu_atomic_idle)
2524

@@ -50,21 +49,6 @@ _skip_\@:
5049
#endif /* CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK */
5150
.endm
5251

53-
/**
54-
*
55-
* @brief Initialization of CPU idle
56-
*
57-
* Only called by arch_kernel_init(). Sets SEVONPEND bit once for the system's
58-
* duration.
59-
*
60-
* C function prototype:
61-
*
62-
* void z_arm_cpu_idle_init(void);
63-
*/
64-
65-
SECTION_FUNC(TEXT, z_arm_cpu_idle_init)
66-
bx lr
67-
6852
SECTION_FUNC(TEXT, arch_cpu_idle)
6953
#ifdef CONFIG_TRACING
7054
push {r0, lr}
@@ -97,15 +81,9 @@ SECTION_FUNC(TEXT, arch_cpu_atomic_idle)
9781
*/
9882
cpsid i
9983

100-
/*
101-
* No need to set SEVONPEND, it's set once in z_arm_cpu_idle_init()
102-
* and never touched again.
103-
*/
104-
10584
/* r0: interrupt mask from caller */
10685

10786
/* No BASEPRI, call wfe directly
108-
* (SEVONPEND is set in z_arm_cpu_idle_init())
10987
*/
11088
_sleep_if_allowed wfe
11189

arch/arm/include/cortex_a_r/exc.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,6 @@ static ALWAYS_INLINE bool z_arm_preempted_thread_in_user_mode(const z_arch_esf_t
5454
}
5555
#endif
5656

57-
/**
58-
* @brief Setup system exceptions
59-
*
60-
* Enable fault exceptions.
61-
*
62-
*/
63-
static ALWAYS_INLINE void z_arm_exc_setup(void)
64-
{
65-
}
66-
67-
/**
68-
* @brief Clear Fault exceptions
69-
*
70-
* Clear out exceptions for Mem, Bus, Usage and Hard Faults
71-
*
72-
*/
73-
static ALWAYS_INLINE void z_arm_clear_faults(void)
74-
{
75-
}
76-
7757
extern void z_arm_cortex_r_svc(void);
7858

7959
#ifdef __cplusplus
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2019 Carlo Caione <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/**
7+
* @file
8+
* @brief Private kernel definitions (ARM)
9+
*
10+
* This file contains private kernel function definitions and various
11+
* other definitions for the 32-bit ARM Cortex-A/R processor architecture
12+
* family.
13+
*
14+
* This file is also included by assembly language files which must #define
15+
* _ASMLANGUAGE before including this header file. Note that kernel
16+
* assembly source files obtains structure offset values via "absolute symbols"
17+
* in the offsets.o module.
18+
*/
19+
20+
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_A_R_KERNEL_ARCH_FUNC_H_
21+
#define ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_A_R_KERNEL_ARCH_FUNC_H_
22+
23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
27+
#ifndef _ASMLANGUAGE
28+
#ifdef CONFIG_ARM_MPU
29+
extern void z_arm_configure_static_mpu_regions(void);
30+
extern int z_arm_mpu_init(void);
31+
#endif /* CONFIG_ARM_MPU */
32+
#ifdef CONFIG_ARM_AARCH32_MMU
33+
extern int z_arm_mmu_init(void);
34+
#endif /* CONFIG_ARM_AARCH32_MMU */
35+
36+
static ALWAYS_INLINE void arch_kernel_init(void)
37+
{
38+
#if defined(CONFIG_ARM_MPU)
39+
z_arm_mpu_init();
40+
/* Configure static memory map. This will program MPU regions,
41+
* to set up access permissions for fixed memory sections, such
42+
* as Application Memory or No-Cacheable SRAM area.
43+
*
44+
* This function is invoked once, upon system initialization.
45+
*/
46+
z_arm_configure_static_mpu_regions();
47+
#endif /* CONFIG_ARM_MPU */
48+
#if defined(CONFIG_ARM_AARCH32_MMU)
49+
z_arm_mmu_init();
50+
#endif /* CONFIG_ARM_AARCH32_MMU */
51+
}
52+
53+
static ALWAYS_INLINE void
54+
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
55+
{
56+
thread->arch.swap_return_value = value;
57+
}
58+
59+
extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
60+
void *p1, void *p2, void *p3,
61+
uint32_t stack_end,
62+
uint32_t stack_start);
63+
64+
extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
65+
66+
#endif /* _ASMLANGUAGE */
67+
68+
#ifdef __cplusplus
69+
}
70+
#endif
71+
72+
#endif /* ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_A_R_KERNEL_ARCH_FUNC_H_ */

arch/arm/include/cortex_a_r/stack.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ extern "C" {
2626

2727
extern void z_arm_init_stacks(void);
2828

29-
/**
30-
*
31-
* @brief Setup interrupt stack
32-
*
33-
* On Cortex-A and Cortex-R, the interrupt stack is set up by reset.S
34-
*
35-
*/
36-
static ALWAYS_INLINE void z_arm_interrupt_stack_setup(void)
37-
{
38-
}
39-
4029
#endif /* _ASMLANGUAGE */
4130

4231
#ifdef __cplusplus
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2019 Carlo Caione <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/**
7+
* @file
8+
* @brief Private kernel definitions (ARM)
9+
*
10+
* This file contains private kernel function definitions and various
11+
* other definitions for the 32-bit ARM Cortex-M processor architecture
12+
* family.
13+
*
14+
* This file is also included by assembly language files which must #define
15+
* _ASMLANGUAGE before including this header file. Note that kernel
16+
* assembly source files obtains structure offset values via "absolute symbols"
17+
* in the offsets.o module.
18+
*/
19+
20+
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_
21+
#define ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_
22+
23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
27+
#ifndef _ASMLANGUAGE
28+
extern void z_arm_fault_init(void);
29+
extern void z_arm_cpu_idle_init(void);
30+
#ifdef CONFIG_ARM_MPU
31+
extern void z_arm_configure_static_mpu_regions(void);
32+
extern void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread);
33+
extern int z_arm_mpu_init(void);
34+
#endif /* CONFIG_ARM_MPU */
35+
#ifdef CONFIG_ARM_AARCH32_MMU
36+
extern int z_arm_mmu_init(void);
37+
#endif /* CONFIG_ARM_AARCH32_MMU */
38+
39+
static ALWAYS_INLINE void arch_kernel_init(void)
40+
{
41+
z_arm_interrupt_stack_setup();
42+
z_arm_exc_setup();
43+
z_arm_fault_init();
44+
z_arm_cpu_idle_init();
45+
z_arm_clear_faults();
46+
#if defined(CONFIG_ARM_MPU)
47+
z_arm_mpu_init();
48+
/* Configure static memory map. This will program MPU regions,
49+
* to set up access permissions for fixed memory sections, such
50+
* as Application Memory or No-Cacheable SRAM area.
51+
*
52+
* This function is invoked once, upon system initialization.
53+
*/
54+
z_arm_configure_static_mpu_regions();
55+
#endif /* CONFIG_ARM_MPU */
56+
}
57+
58+
static ALWAYS_INLINE void
59+
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
60+
{
61+
thread->arch.swap_return_value = value;
62+
}
63+
64+
#if !defined(CONFIG_MULTITHREADING)
65+
extern FUNC_NORETURN void z_arm_switch_to_main_no_multithreading(
66+
k_thread_entry_t main_func,
67+
void *p1, void *p2, void *p3);
68+
69+
#define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \
70+
z_arm_switch_to_main_no_multithreading
71+
72+
#endif /* !CONFIG_MULTITHREADING */
73+
74+
extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
75+
void *p1, void *p2, void *p3,
76+
uint32_t stack_end,
77+
uint32_t stack_start);
78+
79+
extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
80+
81+
#endif /* _ASMLANGUAGE */
82+
83+
#ifdef __cplusplus
84+
}
85+
#endif
86+
87+
#endif /* ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_ */

arch/arm/include/kernel_arch_func.h

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,10 @@
2222

2323
#include <kernel_arch_data.h>
2424

25-
#ifdef __cplusplus
26-
extern "C" {
27-
#endif
28-
29-
#ifndef _ASMLANGUAGE
30-
extern void z_arm_fault_init(void);
31-
extern void z_arm_cpu_idle_init(void);
32-
#ifdef CONFIG_ARM_MPU
33-
extern void z_arm_configure_static_mpu_regions(void);
34-
extern void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread);
35-
extern int z_arm_mpu_init(void);
36-
#endif /* CONFIG_ARM_MPU */
37-
#ifdef CONFIG_ARM_AARCH32_MMU
38-
extern int z_arm_mmu_init(void);
39-
#endif /* CONFIG_ARM_AARCH32_MMU */
40-
41-
static ALWAYS_INLINE void arch_kernel_init(void)
42-
{
43-
z_arm_interrupt_stack_setup();
44-
z_arm_exc_setup();
45-
z_arm_fault_init();
46-
z_arm_cpu_idle_init();
47-
z_arm_clear_faults();
48-
#if defined(CONFIG_ARM_MPU)
49-
z_arm_mpu_init();
50-
/* Configure static memory map. This will program MPU regions,
51-
* to set up access permissions for fixed memory sections, such
52-
* as Application Memory or No-Cacheable SRAM area.
53-
*
54-
* This function is invoked once, upon system initialization.
55-
*/
56-
z_arm_configure_static_mpu_regions();
57-
#endif /* CONFIG_ARM_MPU */
58-
#if defined(CONFIG_ARM_AARCH32_MMU)
59-
z_arm_mmu_init();
60-
#endif /* CONFIG_ARM_AARCH32_MMU */
61-
}
62-
63-
static ALWAYS_INLINE void
64-
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
65-
{
66-
thread->arch.swap_return_value = value;
67-
}
68-
69-
#if !defined(CONFIG_MULTITHREADING) && defined(CONFIG_CPU_CORTEX_M)
70-
extern FUNC_NORETURN void z_arm_switch_to_main_no_multithreading(
71-
k_thread_entry_t main_func,
72-
void *p1, void *p2, void *p3);
73-
74-
#define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \
75-
z_arm_switch_to_main_no_multithreading
76-
77-
#endif /* !CONFIG_MULTITHREADING && CONFIG_CPU_CORTEX_M */
78-
79-
extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
80-
void *p1, void *p2, void *p3,
81-
uint32_t stack_end,
82-
uint32_t stack_start);
83-
84-
extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
85-
86-
#endif /* _ASMLANGUAGE */
87-
88-
#ifdef __cplusplus
89-
}
25+
#if defined(CONFIG_CPU_CORTEX_M)
26+
#include <cortex_m/kernel_arch_func.h>
27+
#else
28+
#include <cortex_a_r/kernel_arch_func.h>
9029
#endif
9130

9231
#endif /* ZEPHYR_ARCH_ARM_INCLUDE_KERNEL_ARCH_FUNC_H_ */

0 commit comments

Comments
 (0)