Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
thread_stack.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Carlo Caione <ccaione@baylibre.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_ARCH_ARM64_THREAD_STACK_H_
8#define ZEPHYR_INCLUDE_ARCH_ARM64_THREAD_STACK_H_
9
10#define ARCH_STACK_PTR_ALIGN 16
11
12#if CONFIG_USERSPACE
13#define Z_ARM64_STACK_BASE_ALIGN CONFIG_MMU_PAGE_SIZE
14#define Z_ARM64_STACK_SIZE_ALIGN CONFIG_MMU_PAGE_SIZE
15#else
16#define Z_ARM64_STACK_BASE_ALIGN ARCH_STACK_PTR_ALIGN
17#define Z_ARM64_STACK_SIZE_ALIGN ARCH_STACK_PTR_ALIGN
18#endif
19
20/*
21 * [ see also comments in arch/arm64/core/thread.c ]
22 *
23 * High memory addresses
24 *
25 * +-------------------+ <- thread.stack_info.start + thread.stack_info.size
26 * | TLS |
27 * +-------------------+ <- initial sp (computable with thread.stack_info.delta)
28 * | |
29 * | Used stack |
30 * | |
31 * +...................+ <- thread's current stack pointer
32 * | |
33 * | Unused stack |
34 * | |
35 * +-------------------+ <- thread.stack_info.start
36 * | Privileged stack | } K_(THREAD|KERNEL)_STACK_RESERVED
37 * +-------------------+ <- thread.stack_obj
38 *
39 * Low Memory addresses
40 */
41
42/* thread stack */
43#define ARCH_THREAD_STACK_OBJ_ALIGN(size) Z_ARM64_STACK_BASE_ALIGN
44#define ARCH_THREAD_STACK_SIZE_ADJUST(size) \
45 ROUND_UP((size), Z_ARM64_STACK_SIZE_ALIGN)
46#define ARCH_THREAD_STACK_RESERVED CONFIG_PRIVILEGED_STACK_SIZE
47
48/* kernel stack */
49#define ARCH_KERNEL_STACK_RESERVED 0
50#define ARCH_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
51
52#ifndef _ASMLANGUAGE
53
54struct z_arm64_thread_stack_header {
55 char privilege_stack[CONFIG_PRIVILEGED_STACK_SIZE];
56} __packed __aligned(Z_ARM64_STACK_BASE_ALIGN);
57
58#endif /* _ASMLANGUAGE */
59
60#endif /* ZEPHYR_INCLUDE_ARCH_ARM64_THREAD_STACK_H_ */