2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
2015-12-04 10:09:39 -05:00
|
|
|
/**
|
|
|
|
* @file
|
2016-12-23 07:32:56 -05:00
|
|
|
* @brief ARC specific kernel interface header
|
2015-12-04 10:09:39 -05:00
|
|
|
*
|
2016-12-23 07:32:56 -05:00
|
|
|
* This header contains the ARC specific kernel interface. It is
|
|
|
|
* included by the kernel interface architecture-abstraction header
|
|
|
|
* include/arch/cpu.h)
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2018-09-14 10:43:44 -07:00
|
|
|
#ifndef ZEPHYR_INCLUDE_ARCH_ARC_ARCH_H_
|
|
|
|
#define ZEPHYR_INCLUDE_ARCH_ARC_ARCH_H_
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2020-01-16 13:29:53 +01:00
|
|
|
#include <devicetree.h>
|
2015-11-24 17:02:50 -06:00
|
|
|
#include <sw_isr_table.h>
|
2019-10-25 00:08:21 +09:00
|
|
|
#include <arch/arc/thread.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifdef CONFIG_CPU_ARCV2
|
2015-05-28 10:56:47 -07:00
|
|
|
#include <arch/arc/v2/exc.h>
|
|
|
|
#include <arch/arc/v2/irq.h>
|
|
|
|
#include <arch/arc/v2/ffs.h>
|
|
|
|
#include <arch/arc/v2/error.h>
|
|
|
|
#include <arch/arc/v2/misc.h>
|
|
|
|
#include <arch/arc/v2/aux_regs.h>
|
|
|
|
#include <arch/arc/v2/arcv2_irq_unit.h>
|
2015-08-25 14:39:56 +03:00
|
|
|
#include <arch/arc/v2/asm_inline.h>
|
2019-06-02 21:44:42 -04:00
|
|
|
#include <arch/common/addr_types.h>
|
2019-06-02 13:07:43 -04:00
|
|
|
#include "v2/sys_io.h"
|
2019-07-24 17:47:29 +08:00
|
|
|
#ifdef CONFIG_ARC_CONNECT
|
|
|
|
#include <arch/arc/v2/arc_connect.h>
|
|
|
|
#endif
|
2019-08-01 12:39:35 +08:00
|
|
|
#ifdef CONFIG_ARC_HAS_SECURE
|
|
|
|
#include <arch/arc/v2/secureshield/arc_secure.h>
|
|
|
|
#endif
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif
|
|
|
|
|
2018-07-19 14:47:59 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-04-19 15:06:31 -07:00
|
|
|
#define ARCH_STACK_PTR_ALIGN 4
|
|
|
|
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
#if defined(CONFIG_MPU_STACK_GUARD) || defined(CONFIG_USERSPACE)
|
2018-02-12 19:42:37 +08:00
|
|
|
#if defined(CONFIG_ARC_CORE_MPU)
|
|
|
|
#if CONFIG_ARC_MPU_VER == 2
|
|
|
|
/*
|
|
|
|
* The minimum MPU region of MPU v2 is 2048 bytes. The
|
|
|
|
* start address of MPU region should be aligned to the
|
|
|
|
* region size
|
|
|
|
*/
|
|
|
|
/* The STACK_GUARD_SIZE is the size of stack guard region */
|
|
|
|
#define STACK_ALIGN 2048
|
|
|
|
#elif CONFIG_ARC_MPU_VER == 3
|
|
|
|
#define STACK_ALIGN 32
|
|
|
|
#else
|
|
|
|
#error "Unsupported MPU version"
|
|
|
|
#endif /* CONFIG_ARC_MPU_VER */
|
|
|
|
|
|
|
|
#else /* CONFIG_ARC_CORE_MPU */
|
|
|
|
#error "Requires to enable MPU"
|
|
|
|
#endif
|
|
|
|
|
2018-05-23 08:23:41 -05:00
|
|
|
#else /* CONFIG_MPU_STACK_GUARD || CONFIG_USERSPACE */
|
2018-02-12 19:42:37 +08:00
|
|
|
#define STACK_ALIGN 4
|
2017-08-15 12:20:42 +08:00
|
|
|
#endif
|
|
|
|
|
2018-02-12 19:42:37 +08:00
|
|
|
#if defined(CONFIG_MPU_STACK_GUARD)
|
|
|
|
#if CONFIG_ARC_MPU_VER == 2
|
|
|
|
#define STACK_GUARD_SIZE 2048
|
|
|
|
#elif CONFIG_ARC_MPU_VER == 3
|
|
|
|
#define STACK_GUARD_SIZE 32
|
|
|
|
#endif
|
|
|
|
#else /* CONFIG_MPU_STACK_GUARD */
|
|
|
|
#define STACK_GUARD_SIZE 0
|
|
|
|
#endif /* CONFIG_MPU_STACK_GUARD */
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
|
|
|
|
2019-04-09 00:12:45 +08:00
|
|
|
#define STACK_SIZE_ALIGN(x) ROUND_UP(x, STACK_ALIGN)
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Calculate power of two ceiling for a buffer size input
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define POW2_CEIL(x) ((1 << (31 - __builtin_clz(x))) < x ? \
|
|
|
|
1 << (31 - __builtin_clz(x) + 1) : \
|
|
|
|
1 << (31 - __builtin_clz(x)))
|
|
|
|
|
|
|
|
|
2019-04-08 01:32:33 +08:00
|
|
|
#if defined(CONFIG_USERSPACE)
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_RESERVED \
|
2019-03-19 10:42:24 -07:00
|
|
|
(STACK_GUARD_SIZE + CONFIG_PRIVILEGED_STACK_SIZE)
|
2019-04-08 01:32:33 +08:00
|
|
|
#else
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_RESERVED (STACK_GUARD_SIZE)
|
2019-04-08 01:32:33 +08:00
|
|
|
#endif
|
2019-03-19 10:42:24 -07:00
|
|
|
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
2019-04-08 01:32:33 +08:00
|
|
|
#if defined(CONFIG_USERSPACE) && CONFIG_ARC_MPU_VER == 2
|
2019-04-09 00:12:45 +08:00
|
|
|
/* MPUv2 requires
|
|
|
|
* - region size must be power of 2 and >= 2048
|
|
|
|
* - region start must be aligned to its size
|
|
|
|
*/
|
|
|
|
#define Z_ARC_MPUV2_SIZE_ALIGN(size) POW2_CEIL(STACK_SIZE_ALIGN(size))
|
|
|
|
/*
|
|
|
|
* user stack and guard are protected using MPU regions, so need to adhere to
|
|
|
|
* MPU start, size alignment
|
|
|
|
*/
|
|
|
|
#define Z_ARC_THREAD_STACK_ALIGN(size) Z_ARC_MPUV2_SIZE_ALIGN(size)
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_LEN(size) \
|
|
|
|
(Z_ARC_MPUV2_SIZE_ALIGN(size) + ARCH_THREAD_STACK_RESERVED)
|
2019-04-08 01:32:33 +08:00
|
|
|
/*
|
2019-04-09 00:12:45 +08:00
|
|
|
* for stack array, each array member should be aligned both in size
|
|
|
|
* and start
|
2019-04-08 01:32:33 +08:00
|
|
|
*/
|
2019-04-09 00:12:45 +08:00
|
|
|
#define Z_ARC_THREAD_STACK_ARRAY_LEN(size) \
|
|
|
|
(Z_ARC_MPUV2_SIZE_ALIGN(size) + \
|
|
|
|
MAX(Z_ARC_MPUV2_SIZE_ALIGN(size), \
|
2019-11-07 12:43:29 -08:00
|
|
|
POW2_CEIL(ARCH_THREAD_STACK_RESERVED)))
|
2019-04-09 00:12:45 +08:00
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* MPUv3, no-mpu and no USERSPACE share the same macro definitions.
|
|
|
|
* For MPU STACK_GUARD kernel stacks do not need a MPU region to protect,
|
2019-06-04 19:24:49 +03:00
|
|
|
* only guard needs to be protected and aligned. For MPUv3, MPU_STACK_GUARD
|
2019-04-09 00:12:45 +08:00
|
|
|
* requires start 32 bytes aligned, also for size which is decided by stack
|
|
|
|
* array and USERSPACE; For MPUv2, MPU_STACK_GUARD requires
|
|
|
|
* start 2048 bytes aligned, also for size which is decided by stack array.
|
|
|
|
*
|
|
|
|
* When no-mpu and no USERSPACE/MPU_STACK_GUARD, everything is 4 bytes
|
|
|
|
* aligned
|
|
|
|
*/
|
|
|
|
#define Z_ARC_THREAD_STACK_ALIGN(size) (STACK_ALIGN)
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_LEN(size) \
|
|
|
|
(STACK_SIZE_ALIGN(size) + ARCH_THREAD_STACK_RESERVED)
|
2019-04-09 00:12:45 +08:00
|
|
|
#define Z_ARC_THREAD_STACK_ARRAY_LEN(size) \
|
2019-11-07 12:43:29 -08:00
|
|
|
ARCH_THREAD_STACK_LEN(size)
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
2019-04-09 00:12:45 +08:00
|
|
|
#endif /* CONFIG_USERSPACE && CONFIG_ARC_MPU_VER == 2 */
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_DEFINE(sym, size) \
|
2020-03-11 06:56:58 -07:00
|
|
|
struct z_thread_stack_element __noinit \
|
2019-04-09 00:12:45 +08:00
|
|
|
__aligned(Z_ARC_THREAD_STACK_ALIGN(size)) \
|
2019-11-07 12:43:29 -08:00
|
|
|
sym[ARCH_THREAD_STACK_LEN(size)]
|
2018-06-27 13:26:20 +05:30
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size) \
|
2020-03-11 06:56:58 -07:00
|
|
|
struct z_thread_stack_element __noinit \
|
2019-04-09 00:12:45 +08:00
|
|
|
__aligned(Z_ARC_THREAD_STACK_ALIGN(size)) \
|
|
|
|
sym[nmemb][Z_ARC_THREAD_STACK_ARRAY_LEN(size)]
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_MEMBER(sym, size) \
|
2020-03-11 06:56:58 -07:00
|
|
|
struct z_thread_stack_element \
|
2019-04-09 00:12:45 +08:00
|
|
|
__aligned(Z_ARC_THREAD_STACK_ALIGN(size)) \
|
2019-11-07 12:43:29 -08:00
|
|
|
sym[ARCH_THREAD_STACK_LEN(size)]
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_SIZEOF(sym) \
|
|
|
|
(sizeof(sym) - ARCH_THREAD_STACK_RESERVED)
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
#define ARCH_THREAD_STACK_BUFFER(sym) \
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
((char *)(sym))
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
#ifdef CONFIG_ARC_MPU
|
|
|
|
#ifndef _ASMLANGUAGE
|
2019-08-12 12:52:11 -05:00
|
|
|
|
|
|
|
/* Legacy case: retain containing extern "C" with C++ */
|
2017-12-20 16:48:45 +08:00
|
|
|
#include <arch/arc/v2/mpu/arc_mpu.h>
|
2015-05-26 10:21:42 -04:00
|
|
|
|
2019-03-05 10:29:16 +08:00
|
|
|
#define K_MEM_PARTITION_P_NA_U_NA AUX_MPU_ATTR_N
|
|
|
|
#define K_MEM_PARTITION_P_RW_U_RW (AUX_MPU_ATTR_UW | AUX_MPU_ATTR_UR | \
|
|
|
|
AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR)
|
|
|
|
#define K_MEM_PARTITION_P_RW_U_RO (AUX_MPU_ATTR_UR | \
|
|
|
|
AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR)
|
|
|
|
#define K_MEM_PARTITION_P_RW_U_NA (AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR)
|
|
|
|
#define K_MEM_PARTITION_P_RO_U_RO (AUX_MPU_ATTR_UR | AUX_MPU_ATTR_KR)
|
|
|
|
#define K_MEM_PARTITION_P_RO_U_NA (AUX_MPU_ATTR_KR)
|
2017-12-20 16:48:45 +08:00
|
|
|
|
|
|
|
/* Execution-allowed attributes */
|
2019-03-05 10:29:16 +08:00
|
|
|
#define K_MEM_PARTITION_P_RWX_U_RWX (AUX_MPU_ATTR_UW | AUX_MPU_ATTR_UR | \
|
|
|
|
AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR | \
|
|
|
|
AUX_MPU_ATTR_KE | AUX_MPU_ATTR_UE)
|
|
|
|
#define K_MEM_PARTITION_P_RWX_U_RX (AUX_MPU_ATTR_UR | \
|
|
|
|
AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR | \
|
|
|
|
AUX_MPU_ATTR_KE | AUX_MPU_ATTR_UE)
|
|
|
|
#define K_MEM_PARTITION_P_RX_U_RX (AUX_MPU_ATTR_UR | \
|
|
|
|
AUX_MPU_ATTR_KR | \
|
|
|
|
AUX_MPU_ATTR_KE | AUX_MPU_ATTR_UE)
|
2017-12-20 16:48:45 +08:00
|
|
|
|
|
|
|
#define K_MEM_PARTITION_IS_WRITABLE(attr) \
|
|
|
|
({ \
|
|
|
|
int __is_writable__; \
|
2019-11-28 16:27:59 +08:00
|
|
|
switch (attr & (AUX_MPU_ATTR_UW | AUX_MPU_ATTR_KW)) { \
|
2019-03-05 10:29:16 +08:00
|
|
|
case (AUX_MPU_ATTR_UW | AUX_MPU_ATTR_KW): \
|
|
|
|
case AUX_MPU_ATTR_UW: \
|
|
|
|
case AUX_MPU_ATTR_KW: \
|
2017-12-20 16:48:45 +08:00
|
|
|
__is_writable__ = 1; \
|
|
|
|
break; \
|
|
|
|
default: \
|
|
|
|
__is_writable__ = 0; \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
__is_writable__; \
|
|
|
|
})
|
|
|
|
#define K_MEM_PARTITION_IS_EXECUTABLE(attr) \
|
2019-03-05 10:29:16 +08:00
|
|
|
((attr) & (AUX_MPU_ATTR_KE | AUX_MPU_ATTR_UE))
|
2017-12-20 16:48:45 +08:00
|
|
|
|
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
|
|
|
#if CONFIG_ARC_MPU_VER == 2
|
|
|
|
#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
|
2020-03-12 17:16:00 +02:00
|
|
|
BUILD_ASSERT(!(((size) & ((size) - 1))) && (size) >= STACK_ALIGN \
|
2017-12-20 16:48:45 +08:00
|
|
|
&& !((u32_t)(start) & ((size) - 1)), \
|
|
|
|
"the size of the partition must be power of 2" \
|
|
|
|
" and greater than or equal to the mpu adddress alignment." \
|
|
|
|
"start address of the partition must align with size.")
|
|
|
|
#elif CONFIG_ARC_MPU_VER == 3
|
|
|
|
#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
|
2020-03-12 17:16:00 +02:00
|
|
|
BUILD_ASSERT((size) % STACK_ALIGN == 0 && (size) >= STACK_ALIGN \
|
2017-12-20 16:48:45 +08:00
|
|
|
&& (u32_t)(start) % STACK_ALIGN == 0, \
|
|
|
|
"the size of the partition must align with 32" \
|
|
|
|
" and greater than or equal to 32." \
|
|
|
|
"start address of the partition must align with 32.")
|
|
|
|
#endif
|
|
|
|
#endif /* CONFIG_ARC_MPU*/
|
|
|
|
|
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
/* Typedef for the k_mem_partition attribute*/
|
|
|
|
typedef u32_t k_mem_partition_attr_t;
|
2018-12-04 17:15:27 -08:00
|
|
|
|
2019-11-07 12:43:29 -08:00
|
|
|
static ALWAYS_INLINE void arch_nop(void)
|
2018-12-04 17:15:27 -08:00
|
|
|
{
|
|
|
|
__asm__ volatile("nop");
|
|
|
|
}
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2018-09-14 10:43:44 -07:00
|
|
|
#endif /* ZEPHYR_INCLUDE_ARCH_ARC_ARCH_H_ */
|