include: arm64: Refine the mem alignment macros

Add a new macro MEM_DOMAIN_ALIGN_AND_SIZE for mmu and mpu mem
alignment.
MEM_DOMAIN_ALIGN_AND_SIZE is
  - CONFIG_MMU_PAGE_SIZE, when mmu is enabled.
  - CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE when mpu enabled.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
This commit is contained in:
Jaxson Han 2021-07-20 16:32:13 +08:00 committed by Christopher Friedt
commit ac0c0a61d5
4 changed files with 18 additions and 4 deletions

View file

@ -8,8 +8,19 @@
#if defined(CONFIG_ARM_MMU)
#include <arch/arm64/arm_mmu.h>
/*
* When mmu enabled, some section addresses need to be aligned with
* page size which is CONFIG_MMU_PAGE_SIZE
*/
#define MEM_DOMAIN_ALIGN_AND_SIZE CONFIG_MMU_PAGE_SIZE
#elif defined(CONFIG_ARM_MPU)
#include <arch/arm64/cortex_r/arm_mpu.h>
/*
* When mpu enabled, some section addresses need to be aligned with
* mpu region min align size which is
* CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
*/
#define MEM_DOMAIN_ALIGN_AND_SIZE CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
#endif
#ifndef _ASMLANGUAGE

View file

@ -49,7 +49,7 @@ struct z_arm64_fp_context {
};
struct _thread_arch {
#ifdef CONFIG_USERSPACE
#if defined(CONFIG_USERSPACE) && defined(CONFIG_ARM_MMU)
struct arm_mmu_ptables *ptables;
#endif
#ifdef CONFIG_FPU_SHARING

View file

@ -7,11 +7,13 @@
#ifndef ZEPHYR_INCLUDE_ARCH_ARM64_THREAD_STACK_H_
#define ZEPHYR_INCLUDE_ARCH_ARM64_THREAD_STACK_H_
#define ARCH_STACK_PTR_ALIGN 16
#if CONFIG_USERSPACE
#define Z_ARM64_STACK_BASE_ALIGN CONFIG_MMU_PAGE_SIZE
#define Z_ARM64_STACK_SIZE_ALIGN CONFIG_MMU_PAGE_SIZE
#include <arch/arm64/mm.h>
#define Z_ARM64_STACK_BASE_ALIGN MEM_DOMAIN_ALIGN_AND_SIZE
#define Z_ARM64_STACK_SIZE_ALIGN MEM_DOMAIN_ALIGN_AND_SIZE
#else
#define Z_ARM64_STACK_BASE_ALIGN ARCH_STACK_PTR_ALIGN
#define Z_ARM64_STACK_SIZE_ALIGN ARCH_STACK_PTR_ALIGN