Zephyr Project API  3.3.0
A Scalable Open Source RTOS
mem_protect.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/kernel.h>
8#include <zephyr/ztest.h>
10#include <string.h>
11#include <stdlib.h>
12
13/* Flag needed to figure out if the fault was expected or not. */
14extern volatile bool valid_fault;
15
16static inline void set_fault_valid(bool valid)
17{
18 valid_fault = valid;
19 /* Put a barrier here, such that no instructions get ordered by the
20 * compiler before we set valid_fault. This can happen with expansion
21 * of inline syscall invocation functions.
22 */
23 compiler_barrier();
24}
25
26/* For inherit.c */
27#define INHERIT_STACK_SIZE CONFIG_MAIN_STACK_SIZE
28#define SEMAPHORE_MAX_COUNT (10)
29#define SEMAPHORE_INIT_COUNT (0)
30#define SYNC_SEM_MAX_COUNT (1)
31#define SYNC_SEM_INIT_COUNT (0)
32#define MSG_Q_SIZE (10)
33#define MSG_Q_MAX_NUM_MSGS (10)
34#define MSG_Q_ALIGN (2)
35#define PRIORITY 5
36#define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
37#define BLK_SIZE_MIN 16
38#define BLK_SIZE_MAX 64
39#define BLK_NUM_MIN 8
40#define BLK_NUM_MAX 2
41#define BLK_ALIGN BLK_SIZE_MIN
42#define SEM_INIT_VAL (0U)
43#define SEM_MAX_VAL (1U)
44
45/* For mem_domain.c */
46#define MEM_DOMAIN_STACK_SIZE CONFIG_MAIN_STACK_SIZE
47#define MEM_PARTITION_INIT_NUM (1)
48#define BLK_SIZE_MIN_MD 8
49#define BLK_SIZE_MAX_MD 16
50#define BLK_NUM_MAX_MD 4
51#define BLK_ALIGN_MD BLK_SIZE_MIN_MD
52#define DESC_SIZE sizeof(struct sys_mem_pool_block)
53#define STACK_SIZE_MD (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
54#define PRIORITY_MD 5
55
56#if defined(CONFIG_X86)
57#define MEM_REGION_ALLOC (4096)
58#elif defined(CONFIG_ARC)
59#define MEM_REGION_ALLOC (Z_ARC_MPU_ALIGN)
60#elif defined(CONFIG_ARM64)
61#define MEM_REGION_ALLOC (4096)
62#elif defined(CONFIG_ARM)
63#define MEM_REGION_ALLOC (Z_THREAD_MIN_STACK_ALIGN)
64#elif defined(CONFIG_RISCV)
65#define MEM_REGION_ALLOC (4)
66#else
67#error "Test suite not compatible for the given architecture"
68#endif
69#define MEM_DOMAIN_ALIGNMENT __aligned(MEM_REGION_ALLOC)
70
71/* for kobject.c */
72#define KOBJECT_STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
73
74
75
76#if (defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || \
77 (defined(CONFIG_RISCV) && defined(CONFIG_64BIT)))
78#define TEST_HEAP_SIZE (2 << CONFIG_MAX_THREAD_BYTES) * 1024
79#define MAX_OBJ 512
80#else
81#define TEST_HEAP_SIZE (2 << CONFIG_MAX_THREAD_BYTES) * 256
82#define MAX_OBJ 256
83#endif
84
85#ifndef _TEST_SYSCALLS_H_
86#define _TEST_SYSCALLS_H_
87
88__syscall struct k_heap *ret_resource_pool_ptr(void);
89
90#include <syscalls/mem_protect.h>
91
92#endif /* _TEST_SYSCALLS_H_ */
Public kernel APIs.
static void set_fault_valid(bool valid)
Definition: mem_protect.h:16
volatile bool valid_fault
Definition: common.c:9
struct k_heap * ret_resource_pool_ptr(void)
Definition: kernel.h:5135
Zephyr Testsuite.