2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013-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 ARM specific kernel interface header
|
2015-12-04 10:09:39 -05:00
|
|
|
*
|
2016-12-23 07:32:56 -05:00
|
|
|
* This header contains the ARM specific kernel interface. It is
|
|
|
|
* included by the kernel interface architecture-abstraction header
|
|
|
|
* (include/arc/cpu.h)
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
#ifndef _ARM_ARCH__H_
|
|
|
|
#define _ARM_ARCH__H_
|
|
|
|
|
2017-02-10 15:31:26 -06:00
|
|
|
/* Add include for DTS generated information */
|
|
|
|
#include <generated_dts_board.h>
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-10-23 16:20:25 -04:00
|
|
|
/* ARM GPRs are often designated by two different names */
|
2017-04-21 10:55:34 -05:00
|
|
|
#define sys_define_gpr_with_alias(name1, name2) union { u32_t name1, name2; }
|
2015-10-23 16:20:25 -04:00
|
|
|
|
2015-10-04 09:34:11 -04:00
|
|
|
/* APIs need to support non-byte addressable architectures */
|
2015-06-01 13:39:43 -04:00
|
|
|
|
|
|
|
#define OCTET_TO_SIZEOFUNIT(X) (X)
|
|
|
|
#define SIZEOFUNIT_TO_OCTET(X) (X)
|
|
|
|
|
2015-06-17 11:16:57 -04:00
|
|
|
#ifdef CONFIG_CPU_CORTEX_M
|
2015-08-20 16:46:11 -04:00
|
|
|
#include <arch/arm/cortex_m/exc.h>
|
|
|
|
#include <arch/arm/cortex_m/irq.h>
|
|
|
|
#include <arch/arm/cortex_m/error.h>
|
|
|
|
#include <arch/arm/cortex_m/misc.h>
|
|
|
|
#include <arch/arm/cortex_m/memory_map.h>
|
|
|
|
#include <arch/arm/cortex_m/asm_inline.h>
|
2015-09-18 15:57:27 -04:00
|
|
|
#include <arch/arm/cortex_m/addr_types.h>
|
2016-01-29 16:23:38 -05:00
|
|
|
#include <arch/arm/cortex_m/sys_io.h>
|
2016-03-08 13:13:02 -08:00
|
|
|
#include <arch/arm/cortex_m/nmi.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif
|
2017-06-27 09:02:47 +02:00
|
|
|
#if defined(CONFIG_MPU_STACK_GUARD)
|
|
|
|
#define STACK_ALIGN 32
|
2017-08-01 16:48:46 -05:00
|
|
|
#else /* CONFIG_MPU_STACK_GUARD */
|
|
|
|
#define STACK_ALIGN 4
|
|
|
|
#endif
|
2017-06-27 09:02:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Declare a toplevel thread stack memory region
|
|
|
|
*
|
|
|
|
* This declares a region of memory suitable for use as a thread's stack.
|
|
|
|
*
|
|
|
|
* This is the generic, historical definition. Align to STACK_ALIGN and put in
|
|
|
|
* 'noinit' section so that it isn't zeroed at boot
|
|
|
|
*
|
|
|
|
* The declared symbol will always be a character array which can be passed to
|
|
|
|
* k_thread_create, but should otherwise not be manipulated.
|
|
|
|
*
|
|
|
|
* It is legal to precede this definition with the 'static' keyword.
|
|
|
|
*
|
|
|
|
* It is NOT legal to take the sizeof(sym) and pass that to the stackSize
|
|
|
|
* parameter of k_thread_create(), it may not be the same as the
|
|
|
|
* 'size' parameter. Use K_THREAD_STACK_SIZEOF() instead.
|
|
|
|
*
|
|
|
|
* @param sym Thread stack symbol name
|
|
|
|
* @param size Size of the stack memory region
|
|
|
|
*/
|
|
|
|
#define _ARCH_THREAD_STACK_DEFINE(sym, size) \
|
|
|
|
char __noinit __aligned(STACK_ALIGN) sym[size+STACK_ALIGN]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Declare a toplevel array of thread stack memory regions
|
|
|
|
*
|
|
|
|
* Create an array of equally sized stacks. See K_THREAD_STACK_DEFINE
|
|
|
|
* definition for additional details and constraints.
|
|
|
|
*
|
|
|
|
* This is the generic, historical definition. Align to STACK_ALIGN and put in
|
|
|
|
* 'noinit' section so that it isn't zeroed at boot
|
|
|
|
*
|
|
|
|
* @param sym Thread stack symbol name
|
|
|
|
* @param nmemb Number of stacks to declare
|
|
|
|
* @param size Size of the stack memory region
|
|
|
|
*/
|
|
|
|
#define _ARCH_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size) \
|
|
|
|
char __noinit __aligned(STACK_ALIGN) sym[nmemb][size+STACK_ALIGN]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Declare an embedded stack memory region
|
|
|
|
*
|
|
|
|
* Used for stacks embedded within other data structures. Use is highly
|
|
|
|
* discouraged but in some cases necessary. For memory protection scenarios,
|
|
|
|
* it is very important that any RAM preceding this member not be writable
|
|
|
|
* by threads else a stack overflow will lead to silent corruption. In other
|
|
|
|
* words, the containing data structure should live in RAM owned by the kernel.
|
|
|
|
*
|
|
|
|
* @param sym Thread stack symbol name
|
|
|
|
* @param size Size of the stack memory region
|
|
|
|
*/
|
|
|
|
#define _ARCH_THREAD_STACK_MEMBER(sym, size) \
|
|
|
|
char __aligned(STACK_ALIGN) sym[size+STACK_ALIGN]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Return the size in bytes of a stack memory region
|
|
|
|
*
|
|
|
|
* Convenience macro for passing the desired stack size to k_thread_create()
|
|
|
|
* since the underlying implementation may actually create something larger
|
|
|
|
* (for instance a guard area).
|
|
|
|
*
|
|
|
|
* The value returned here is guaranteed to match the 'size' parameter
|
|
|
|
* passed to K_THREAD_STACK_DEFINE and related macros.
|
|
|
|
*
|
|
|
|
* @param sym Stack memory symbol
|
|
|
|
* @return Size of the stack
|
|
|
|
*/
|
|
|
|
#define _ARCH_THREAD_STACK_SIZEOF(sym) (sizeof(sym) - STACK_ALIGN)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get a pointer to the physical stack buffer
|
|
|
|
*
|
|
|
|
* Convenience macro to get at the real underlying stack buffer used by
|
|
|
|
* the CPU. Guaranteed to be a character pointer of size K_THREAD_STACK_SIZEOF.
|
|
|
|
* This is really only intended for diagnostic tools which want to examine
|
|
|
|
* stack memory contents.
|
|
|
|
*
|
|
|
|
* @param sym Declared stack symbol name
|
|
|
|
* @return The buffer itself, a char *
|
|
|
|
*/
|
|
|
|
#define _ARCH_THREAD_STACK_BUFFER(sym) (sym + STACK_ALIGN)
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _ARM_ARCH__H_ */
|