Zephyr Project API  3.3.0
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
11#define ARCH_STACK_PTR_ALIGN 16
12
13#if CONFIG_USERSPACE
15#define Z_ARM64_STACK_BASE_ALIGN MEM_DOMAIN_ALIGN_AND_SIZE
16#define Z_ARM64_STACK_SIZE_ALIGN MEM_DOMAIN_ALIGN_AND_SIZE
17#else
18#define Z_ARM64_STACK_BASE_ALIGN ARCH_STACK_PTR_ALIGN
19#define Z_ARM64_STACK_SIZE_ALIGN ARCH_STACK_PTR_ALIGN
20#endif
21
22/*
23 * [ see also comments in arch/arm64/core/thread.c ]
24 *
25 * High memory addresses
26 *
27 * +-------------------+ <- thread.stack_info.start + thread.stack_info.size
28 * | TLS |
29 * +-------------------+ <- initial sp (computable with thread.stack_info.delta)
30 * | |
31 * | Used stack |
32 * | |
33 * +...................+ <- thread's current stack pointer
34 * | |
35 * | Unused stack |
36 * | |
37 * +-------------------+ <- thread.stack_info.start
38 * | Privileged stack | } K_(THREAD|KERNEL)_STACK_RESERVED
39 * +-------------------+ <- thread.stack_obj
40 *
41 * Low Memory addresses
42 */
43
44/* thread stack */
45#define ARCH_THREAD_STACK_OBJ_ALIGN(size) Z_ARM64_STACK_BASE_ALIGN
46#define ARCH_THREAD_STACK_SIZE_ADJUST(size) \
47 ROUND_UP((size), Z_ARM64_STACK_SIZE_ALIGN)
48#define ARCH_THREAD_STACK_RESERVED CONFIG_PRIVILEGED_STACK_SIZE
49
50/* kernel stack */
51#define ARCH_KERNEL_STACK_RESERVED 0
52#define ARCH_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
53
54#ifndef _ASMLANGUAGE
55
56struct z_arm64_thread_stack_header {
57 char privilege_stack[CONFIG_PRIVILEGED_STACK_SIZE];
58} __packed __aligned(Z_ARM64_STACK_BASE_ALIGN);
59
60#endif /* _ASMLANGUAGE */
61
62#endif /* ZEPHYR_INCLUDE_ARCH_ARM64_THREAD_STACK_H_ */