Lines Matching full:domain
24 static bool check_add_partition(struct k_mem_domain *domain, in check_add_partition() argument
64 * in the domain in check_add_partition()
66 for (i = 0; i < domain->num_partitions; i++) { in check_add_partition()
67 struct k_mem_partition *dpart = &domain->partitions[i]; in check_add_partition()
88 int k_mem_domain_init(struct k_mem_domain *domain, uint8_t num_parts, in k_mem_domain_init() argument
94 CHECKIF(domain == NULL) { in k_mem_domain_init()
114 domain->num_partitions = 0U; in k_mem_domain_init()
115 (void)memset(domain->partitions, 0, sizeof(domain->partitions)); in k_mem_domain_init()
116 sys_dlist_init(&domain->mem_domain_q); in k_mem_domain_init()
119 ret = arch_mem_domain_init(domain); in k_mem_domain_init()
122 LOG_ERR("architecture-specific initialization failed for domain %p with %d", in k_mem_domain_init()
123 domain, ret); in k_mem_domain_init()
132 CHECKIF(!check_add_partition(domain, parts[i])) { in k_mem_domain_init()
139 domain->partitions[i] = *parts[i]; in k_mem_domain_init()
140 domain->num_partitions++; in k_mem_domain_init()
142 int ret2 = arch_mem_domain_partition_add(domain, i); in k_mem_domain_init()
159 int k_mem_domain_add_partition(struct k_mem_domain *domain, in k_mem_domain_add_partition() argument
166 CHECKIF(domain == NULL) { in k_mem_domain_add_partition()
171 CHECKIF(!check_add_partition(domain, part)) { in k_mem_domain_add_partition()
181 if (domain->partitions[p_idx].size == 0U) { in k_mem_domain_add_partition()
192 LOG_DBG("add partition base %lx size %zu to domain %p\n", in k_mem_domain_add_partition()
193 part->start, part->size, domain); in k_mem_domain_add_partition()
195 domain->partitions[p_idx].start = part->start; in k_mem_domain_add_partition()
196 domain->partitions[p_idx].size = part->size; in k_mem_domain_add_partition()
197 domain->partitions[p_idx].attr = part->attr; in k_mem_domain_add_partition()
199 domain->num_partitions++; in k_mem_domain_add_partition()
202 ret = arch_mem_domain_partition_add(domain, p_idx); in k_mem_domain_add_partition()
212 int k_mem_domain_remove_partition(struct k_mem_domain *domain, in k_mem_domain_remove_partition() argument
219 CHECKIF((domain == NULL) || (part == NULL)) { in k_mem_domain_remove_partition()
228 if ((domain->partitions[p_idx].start == part->start) && in k_mem_domain_remove_partition()
229 (domain->partitions[p_idx].size == part->size)) { in k_mem_domain_remove_partition()
240 LOG_DBG("remove partition base %lx size %zu from domain %p\n", in k_mem_domain_remove_partition()
241 part->start, part->size, domain); in k_mem_domain_remove_partition()
244 ret = arch_mem_domain_partition_remove(domain, p_idx); in k_mem_domain_remove_partition()
248 domain->partitions[p_idx].size = 0U; in k_mem_domain_remove_partition()
250 domain->num_partitions--; in k_mem_domain_remove_partition()
259 static int add_thread_locked(struct k_mem_domain *domain, in add_thread_locked() argument
264 __ASSERT_NO_MSG(domain != NULL); in add_thread_locked()
267 LOG_DBG("add thread %p to domain %p\n", thread, domain); in add_thread_locked()
268 sys_dlist_append(&domain->mem_domain_q, in add_thread_locked()
270 thread->mem_domain_info.mem_domain = domain; in add_thread_locked()
284 LOG_DBG("remove thread %p from memory domain %p\n", in remove_thread_locked()
301 /* New threads inherit memory domain configuration from parent */ in z_mem_domain_init_thread()
323 int k_mem_domain_add_thread(struct k_mem_domain *domain, k_tid_t thread) in k_mem_domain_add_thread() argument
329 if (thread->mem_domain_info.mem_domain != domain) { in k_mem_domain_add_thread()
333 ret = add_thread_locked(domain, thread); in k_mem_domain_add_thread()
356 __ASSERT(ret == 0, "failed to init default mem domain"); in init_mem_domain_module()