1 /* 2 * Copyright (c) 2022 Huawei Technologies SASU 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include <zephyr/app_memory/app_memdomain.h> 10 11 #define MAX_NB_THREADS 50 12 13 #define APP_STACKSIZE 1024 14 15 struct k_app_thread { 16 struct k_thread thread; 17 struct k_mem_domain domain; 18 void *stack; 19 struct k_mem_partition *partition; 20 }; 21 22 struct k_app_thread app_threads[MAX_NB_THREADS]; 23 24 /* Generate threads data structures */ 25 #define DEFINE_THREADS_HELPER(nb) \ 26 K_THREAD_STACK_DEFINE(app_##nb##_stack, APP_STACKSIZE); \ 27 K_APPMEM_PARTITION_DEFINE(app_##nb##_partition); \ 28 K_APP_DMEM(app_##nb##_partition) int dummy##nb; /* Need data in each partition */ 29 30 #define DEFINE_THREADS_HELPER_10(nb0, nb1, nb2, nb3, nb4, nb5, nb6, nb7, nb8, nb9) \ 31 DEFINE_THREADS_HELPER(nb0) \ 32 DEFINE_THREADS_HELPER(nb1) \ 33 DEFINE_THREADS_HELPER(nb2) \ 34 DEFINE_THREADS_HELPER(nb3) \ 35 DEFINE_THREADS_HELPER(nb4) \ 36 DEFINE_THREADS_HELPER(nb5) \ 37 DEFINE_THREADS_HELPER(nb6) \ 38 DEFINE_THREADS_HELPER(nb7) \ 39 DEFINE_THREADS_HELPER(nb8) \ 40 DEFINE_THREADS_HELPER(nb9) 41 42 DEFINE_THREADS_HELPER_10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 43 DEFINE_THREADS_HELPER_10(11, 12, 13, 14, 15, 16, 17, 18, 19, 20) 44 DEFINE_THREADS_HELPER_10(21, 22, 23, 24, 25, 26, 27, 28, 29, 30) 45 DEFINE_THREADS_HELPER_10(31, 32, 33, 34, 35, 36, 37, 38, 39, 40) 46 DEFINE_THREADS_HELPER_10(41, 42, 43, 44, 45, 46, 47, 48, 49, 50) 47 48 void *app_thread_stacks[MAX_NB_THREADS] = { 49 app_1_stack, app_2_stack, app_3_stack, app_4_stack, app_5_stack, 50 app_6_stack, app_7_stack, app_8_stack, app_9_stack, app_10_stack, 51 app_11_stack, app_12_stack, app_13_stack, app_14_stack, app_15_stack, 52 app_16_stack, app_17_stack, app_18_stack, app_19_stack, app_20_stack, 53 app_21_stack, app_22_stack, app_23_stack, app_24_stack, app_25_stack, 54 app_26_stack, app_27_stack, app_28_stack, app_29_stack, app_30_stack, 55 app_31_stack, app_32_stack, app_33_stack, app_34_stack, app_35_stack, 56 app_36_stack, app_37_stack, app_38_stack, app_39_stack, app_40_stack, 57 app_41_stack, app_42_stack, app_43_stack, app_44_stack, app_45_stack, 58 app_46_stack, app_47_stack, app_48_stack, app_49_stack, app_50_stack 59 }; 60 61 struct k_mem_partition *app_partitions[MAX_NB_THREADS] = { 62 &app_1_partition, &app_2_partition, &app_3_partition, &app_4_partition, 63 &app_5_partition, &app_6_partition, &app_7_partition, &app_8_partition, 64 &app_9_partition, &app_10_partition, 65 &app_11_partition, &app_12_partition, &app_13_partition, &app_14_partition, 66 &app_15_partition, &app_16_partition, &app_17_partition, &app_18_partition, 67 &app_19_partition, &app_20_partition, 68 &app_21_partition, &app_22_partition, &app_23_partition, &app_24_partition, 69 &app_25_partition, &app_26_partition, &app_27_partition, &app_28_partition, 70 &app_29_partition, &app_30_partition, 71 &app_31_partition, &app_32_partition, &app_33_partition, &app_34_partition, 72 &app_35_partition, &app_36_partition, &app_37_partition, &app_38_partition, 73 &app_39_partition, &app_40_partition, 74 &app_41_partition, &app_42_partition, &app_43_partition, &app_44_partition, 75 &app_45_partition, &app_46_partition, &app_47_partition, &app_48_partition, 76 &app_49_partition, &app_50_partition 77 }; 78 79 struct k_mem_domain app_domains[MAX_NB_THREADS]; 80