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 <Huifeng.Zhang@arm.com>
This commit is contained in:
parent
9ba3d31310
commit
37a6118372
|
@ -19,7 +19,6 @@
|
|||
|
||||
_ASM_FILE_PROLOGUE
|
||||
|
||||
GTEXT(z_arm_cpu_idle_init)
|
||||
GTEXT(arch_cpu_idle)
|
||||
GTEXT(arch_cpu_atomic_idle)
|
||||
|
||||
|
@ -50,21 +49,6 @@ _skip_\@:
|
|||
#endif /* CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK */
|
||||
.endm
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Initialization of CPU idle
|
||||
*
|
||||
* Only called by arch_kernel_init(). Sets SEVONPEND bit once for the system's
|
||||
* duration.
|
||||
*
|
||||
* C function prototype:
|
||||
*
|
||||
* void z_arm_cpu_idle_init(void);
|
||||
*/
|
||||
|
||||
SECTION_FUNC(TEXT, z_arm_cpu_idle_init)
|
||||
bx lr
|
||||
|
||||
SECTION_FUNC(TEXT, arch_cpu_idle)
|
||||
#ifdef CONFIG_TRACING
|
||||
push {r0, lr}
|
||||
|
@ -97,15 +81,9 @@ SECTION_FUNC(TEXT, arch_cpu_atomic_idle)
|
|||
*/
|
||||
cpsid i
|
||||
|
||||
/*
|
||||
* No need to set SEVONPEND, it's set once in z_arm_cpu_idle_init()
|
||||
* and never touched again.
|
||||
*/
|
||||
|
||||
/* r0: interrupt mask from caller */
|
||||
|
||||
/* No BASEPRI, call wfe directly
|
||||
* (SEVONPEND is set in z_arm_cpu_idle_init())
|
||||
*/
|
||||
_sleep_if_allowed wfe
|
||||
|
||||
|
|
|
@ -54,26 +54,6 @@ static ALWAYS_INLINE bool z_arm_preempted_thread_in_user_mode(const z_arch_esf_t
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Setup system exceptions
|
||||
*
|
||||
* Enable fault exceptions.
|
||||
*
|
||||
*/
|
||||
static ALWAYS_INLINE void z_arm_exc_setup(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Fault exceptions
|
||||
*
|
||||
* Clear out exceptions for Mem, Bus, Usage and Hard Faults
|
||||
*
|
||||
*/
|
||||
static ALWAYS_INLINE void z_arm_clear_faults(void)
|
||||
{
|
||||
}
|
||||
|
||||
extern void z_arm_cortex_r_svc(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
72
arch/arm/include/cortex_a_r/kernel_arch_func.h
Normal file
72
arch/arm/include/cortex_a_r/kernel_arch_func.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* @brief Private kernel definitions (ARM)
|
||||
*
|
||||
* This file contains private kernel function definitions and various
|
||||
* other definitions for the 32-bit ARM Cortex-A/R processor architecture
|
||||
* family.
|
||||
*
|
||||
* This file is also included by assembly language files which must #define
|
||||
* _ASMLANGUAGE before including this header file. Note that kernel
|
||||
* assembly source files obtains structure offset values via "absolute symbols"
|
||||
* in the offsets.o module.
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_A_R_KERNEL_ARCH_FUNC_H_
|
||||
#define ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_A_R_KERNEL_ARCH_FUNC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
extern void z_arm_configure_static_mpu_regions(void);
|
||||
extern int z_arm_mpu_init(void);
|
||||
#endif /* CONFIG_ARM_MPU */
|
||||
#ifdef CONFIG_ARM_AARCH32_MMU
|
||||
extern int z_arm_mmu_init(void);
|
||||
#endif /* CONFIG_ARM_AARCH32_MMU */
|
||||
|
||||
static ALWAYS_INLINE void arch_kernel_init(void)
|
||||
{
|
||||
#if defined(CONFIG_ARM_MPU)
|
||||
z_arm_mpu_init();
|
||||
/* Configure static memory map. This will program MPU regions,
|
||||
* to set up access permissions for fixed memory sections, such
|
||||
* as Application Memory or No-Cacheable SRAM area.
|
||||
*
|
||||
* This function is invoked once, upon system initialization.
|
||||
*/
|
||||
z_arm_configure_static_mpu_regions();
|
||||
#endif /* CONFIG_ARM_MPU */
|
||||
#if defined(CONFIG_ARM_AARCH32_MMU)
|
||||
z_arm_mmu_init();
|
||||
#endif /* CONFIG_ARM_AARCH32_MMU */
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void
|
||||
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
|
||||
{
|
||||
thread->arch.swap_return_value = value;
|
||||
}
|
||||
|
||||
extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
|
||||
void *p1, void *p2, void *p3,
|
||||
uint32_t stack_end,
|
||||
uint32_t stack_start);
|
||||
|
||||
extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_A_R_KERNEL_ARCH_FUNC_H_ */
|
|
@ -26,17 +26,6 @@ extern "C" {
|
|||
|
||||
extern void z_arm_init_stacks(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Setup interrupt stack
|
||||
*
|
||||
* On Cortex-A and Cortex-R, the interrupt stack is set up by reset.S
|
||||
*
|
||||
*/
|
||||
static ALWAYS_INLINE void z_arm_interrupt_stack_setup(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
87
arch/arm/include/cortex_m/kernel_arch_func.h
Normal file
87
arch/arm/include/cortex_m/kernel_arch_func.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* @brief Private kernel definitions (ARM)
|
||||
*
|
||||
* This file contains private kernel function definitions and various
|
||||
* other definitions for the 32-bit ARM Cortex-M processor architecture
|
||||
* family.
|
||||
*
|
||||
* This file is also included by assembly language files which must #define
|
||||
* _ASMLANGUAGE before including this header file. Note that kernel
|
||||
* assembly source files obtains structure offset values via "absolute symbols"
|
||||
* in the offsets.o module.
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_
|
||||
#define ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
extern void z_arm_fault_init(void);
|
||||
extern void z_arm_cpu_idle_init(void);
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
extern void z_arm_configure_static_mpu_regions(void);
|
||||
extern void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread);
|
||||
extern int z_arm_mpu_init(void);
|
||||
#endif /* CONFIG_ARM_MPU */
|
||||
#ifdef CONFIG_ARM_AARCH32_MMU
|
||||
extern int z_arm_mmu_init(void);
|
||||
#endif /* CONFIG_ARM_AARCH32_MMU */
|
||||
|
||||
static ALWAYS_INLINE void arch_kernel_init(void)
|
||||
{
|
||||
z_arm_interrupt_stack_setup();
|
||||
z_arm_exc_setup();
|
||||
z_arm_fault_init();
|
||||
z_arm_cpu_idle_init();
|
||||
z_arm_clear_faults();
|
||||
#if defined(CONFIG_ARM_MPU)
|
||||
z_arm_mpu_init();
|
||||
/* Configure static memory map. This will program MPU regions,
|
||||
* to set up access permissions for fixed memory sections, such
|
||||
* as Application Memory or No-Cacheable SRAM area.
|
||||
*
|
||||
* This function is invoked once, upon system initialization.
|
||||
*/
|
||||
z_arm_configure_static_mpu_regions();
|
||||
#endif /* CONFIG_ARM_MPU */
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void
|
||||
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
|
||||
{
|
||||
thread->arch.swap_return_value = value;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_MULTITHREADING)
|
||||
extern FUNC_NORETURN void z_arm_switch_to_main_no_multithreading(
|
||||
k_thread_entry_t main_func,
|
||||
void *p1, void *p2, void *p3);
|
||||
|
||||
#define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \
|
||||
z_arm_switch_to_main_no_multithreading
|
||||
|
||||
#endif /* !CONFIG_MULTITHREADING */
|
||||
|
||||
extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
|
||||
void *p1, void *p2, void *p3,
|
||||
uint32_t stack_end,
|
||||
uint32_t stack_start);
|
||||
|
||||
extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_ */
|
|
@ -22,71 +22,10 @@
|
|||
|
||||
#include <kernel_arch_data.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
extern void z_arm_fault_init(void);
|
||||
extern void z_arm_cpu_idle_init(void);
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
extern void z_arm_configure_static_mpu_regions(void);
|
||||
extern void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread);
|
||||
extern int z_arm_mpu_init(void);
|
||||
#endif /* CONFIG_ARM_MPU */
|
||||
#ifdef CONFIG_ARM_AARCH32_MMU
|
||||
extern int z_arm_mmu_init(void);
|
||||
#endif /* CONFIG_ARM_AARCH32_MMU */
|
||||
|
||||
static ALWAYS_INLINE void arch_kernel_init(void)
|
||||
{
|
||||
z_arm_interrupt_stack_setup();
|
||||
z_arm_exc_setup();
|
||||
z_arm_fault_init();
|
||||
z_arm_cpu_idle_init();
|
||||
z_arm_clear_faults();
|
||||
#if defined(CONFIG_ARM_MPU)
|
||||
z_arm_mpu_init();
|
||||
/* Configure static memory map. This will program MPU regions,
|
||||
* to set up access permissions for fixed memory sections, such
|
||||
* as Application Memory or No-Cacheable SRAM area.
|
||||
*
|
||||
* This function is invoked once, upon system initialization.
|
||||
*/
|
||||
z_arm_configure_static_mpu_regions();
|
||||
#endif /* CONFIG_ARM_MPU */
|
||||
#if defined(CONFIG_ARM_AARCH32_MMU)
|
||||
z_arm_mmu_init();
|
||||
#endif /* CONFIG_ARM_AARCH32_MMU */
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void
|
||||
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
|
||||
{
|
||||
thread->arch.swap_return_value = value;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_MULTITHREADING) && defined(CONFIG_CPU_CORTEX_M)
|
||||
extern FUNC_NORETURN void z_arm_switch_to_main_no_multithreading(
|
||||
k_thread_entry_t main_func,
|
||||
void *p1, void *p2, void *p3);
|
||||
|
||||
#define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \
|
||||
z_arm_switch_to_main_no_multithreading
|
||||
|
||||
#endif /* !CONFIG_MULTITHREADING && CONFIG_CPU_CORTEX_M */
|
||||
|
||||
extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
|
||||
void *p1, void *p2, void *p3,
|
||||
uint32_t stack_end,
|
||||
uint32_t stack_start);
|
||||
|
||||
extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#if defined(CONFIG_CPU_CORTEX_M)
|
||||
#include <cortex_m/kernel_arch_func.h>
|
||||
#else
|
||||
#include <cortex_a_r/kernel_arch_func.h>
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_ARCH_ARM_INCLUDE_KERNEL_ARCH_FUNC_H_ */
|
||||
|
|
Loading…
Reference in a new issue