Lines Matching +full:max +full:- +full:read +full:- +full:sz
2 * Copyright (c) 2010-2014 Wind River Systems, Inc.
4 * SPDX-License-Identifier: Apache-2.0
85 arch_current_thread()->custom_data = value; in z_impl_k_thread_custom_data_set()
98 return arch_current_thread()->custom_data; in z_impl_k_thread_custom_data_get()
126 return thread->base.prio; in z_impl_k_thread_priority_get()
145 strncpy(thread->name, str, CONFIG_THREAD_MAX_NAME_LEN - 1); in z_impl_k_thread_name_set()
146 thread->name[CONFIG_THREAD_MAX_NAME_LEN - 1] = '\0'; in z_impl_k_thread_name_set()
159 SYS_PORT_TRACING_OBJ_FUNC(k_thread, name_set, thread, -ENOSYS); in z_impl_k_thread_name_set()
161 return -ENOSYS; in z_impl_k_thread_name_set()
173 return -EINVAL; in z_vrfy_k_thread_name_set()
177 /* In theory we could copy directly into thread->name, but in z_vrfy_k_thread_name_set()
182 return -EFAULT; in z_vrfy_k_thread_name_set()
187 return -ENOSYS; in z_vrfy_k_thread_name_set()
196 return (const char *)thread->name; in k_thread_name_get()
206 strncpy(buf, thread->name, size); in z_impl_k_thread_name_copy()
212 return -ENOSYS; in z_impl_k_thread_name_copy()
230 uint8_t thread_state = thread_id->base.thread_state; in k_thread_state_str()
231 #define SS_ENT(s) { Z_STATE_STR_##s, _THREAD_##s, sizeof(Z_STATE_STR_##s) - 1 } in k_thread_state_str()
252 buf_size--; /* Reserve 1 byte for end-of-string character */ in k_thread_state_str()
267 off += copy_bytes(buf + off, buf_size - off, in k_thread_state_str()
274 off += copy_bytes(buf + off, buf_size - off, "+", 1); in k_thread_state_str()
294 if ((thread == NULL) || (ko->type != K_OBJ_THREAD) || in z_vrfy_k_thread_name_copy()
295 ((ko->flags & K_OBJ_FLAG_INITIALIZED) == 0)) { in z_vrfy_k_thread_name_copy()
296 return -EINVAL; in z_vrfy_k_thread_name_copy()
299 return -EFAULT; in z_vrfy_k_thread_name_copy()
301 len = strlen(thread->name); in z_vrfy_k_thread_name_copy()
303 return -ENOSPC; in z_vrfy_k_thread_name_copy()
306 return k_usermode_to_copy((void *)buf, thread->name, len + 1); in z_vrfy_k_thread_name_copy()
311 return -ENOSYS; in z_vrfy_k_thread_name_copy()
325 * 2) After servicing a non-nested interrupt
337 if ((arch_current_thread()->base.thread_state & _THREAD_DUMMY) != 0) { in z_check_stack_sentinel()
341 stack = (uint32_t *)arch_current_thread()->stack_info.start; in z_check_stack_sentinel()
394 stack_buf_size = stack_obj_size - K_THREAD_STACK_RESERVED; in setup_thread_stack()
401 stack_buf_size = stack_obj_size - K_KERNEL_STACK_RESERVED; in setup_thread_stack()
419 * K_MEM_MAP_UNINIT is used to mimic the behavior of non-mapped in setup_thread_stack()
443 new_thread->stack_info.mapped.addr = stack_mapped; in setup_thread_stack()
444 new_thread->stack_info.mapped.sz = stack_obj_size; in setup_thread_stack()
479 new_thread->userspace_local_data = in setup_thread_stack()
480 (struct _thread_userspace_local_data *)(stack_ptr - delta); in setup_thread_stack()
494 new_thread->stack_info.start = (uintptr_t)stack_buf_start; in setup_thread_stack()
495 new_thread->stack_info.size = stack_buf_size; in setup_thread_stack()
496 new_thread->stack_info.delta = delta; in setup_thread_stack()
498 stack_ptr -= delta; in setup_thread_stack()
526 &new_thread->base.usage, in z_setup_new_thread()
527 sizeof(new_thread->base.usage)); in z_setup_new_thread()
533 "user thread %p with kernel-only stack %p", in z_setup_new_thread()
537 new_thread->stack_obj = stack; in z_setup_new_thread()
538 new_thread->syscall_frame = NULL; in z_setup_new_thread()
543 z_waitq_init(&new_thread->join_queue); in z_setup_new_thread()
546 z_init_thread_base(&new_thread->base, prio, _THREAD_SLEEPING, options); in z_setup_new_thread()
567 new_thread->init_data = NULL; in z_setup_new_thread()
570 /* switch_handle must be non-null except when inside z_swap() in z_setup_new_thread()
574 __ASSERT(new_thread->switch_handle != NULL, in z_setup_new_thread()
579 new_thread->custom_data = NULL; in z_setup_new_thread()
582 new_thread->no_wake_on_timeout = false; in z_setup_new_thread()
585 new_thread->entry.pEntry = entry; in z_setup_new_thread()
586 new_thread->entry.parameter1 = p1; in z_setup_new_thread()
587 new_thread->entry.parameter2 = p2; in z_setup_new_thread()
588 new_thread->entry.parameter3 = p3; in z_setup_new_thread()
592 new_thread->next_thread = _kernel.threads; in z_setup_new_thread()
598 strncpy(new_thread->name, name, in z_setup_new_thread()
599 CONFIG_THREAD_MAX_NAME_LEN - 1); in z_setup_new_thread()
601 new_thread->name[CONFIG_THREAD_MAX_NAME_LEN - 1] = '\0'; in z_setup_new_thread()
606 new_thread->name[0] = '\0'; in z_setup_new_thread()
611 new_thread->base.cpu_mask = 1; /* must specify only one cpu */ in z_setup_new_thread()
613 new_thread->base.cpu_mask = -1; /* allow all cpus */ in z_setup_new_thread()
619 new_thread->resource_pool = NULL; in z_setup_new_thread()
631 new_thread->base.prio_deadline = 0; in z_setup_new_thread()
633 new_thread->resource_pool = arch_current_thread()->resource_pool; in z_setup_new_thread()
636 z_waitq_init(&new_thread->halt_queue); in z_setup_new_thread()
640 new_thread->base.usage = (struct k_cycle_stats) {}; in z_setup_new_thread()
641 new_thread->base.usage.track_usage = in z_setup_new_thread()
705 /* Testing less-than-or-equal since additional room may have been in z_vrfy_k_thread_create()
709 stack_obj_size = stack_object->data.stack_data->size; in z_vrfy_k_thread_create()
711 stack_obj_size = stack_object->data.stack_size; in z_vrfy_k_thread_create()
714 "stack size %zu is too big, max is %zu", in z_vrfy_k_thread_create()
728 arch_current_thread()->base.prio))); in z_vrfy_k_thread_create()
746 thread_base->pended_on = NULL; in z_init_thread_base()
747 thread_base->user_options = (uint8_t)options; in z_init_thread_base()
748 thread_base->thread_state = (uint8_t)initial_state; in z_init_thread_base()
750 thread_base->prio = priority; in z_init_thread_base()
752 thread_base->sched_locked = 0U; in z_init_thread_base()
755 thread_base->is_idle = 0; in z_init_thread_base()
759 thread_base->slice_ticks = 0; in z_init_thread_base()
760 thread_base->slice_expired = NULL; in z_init_thread_base()
773 arch_current_thread()->base.user_options |= K_USER; in k_thread_user_mode_enter()
776 arch_current_thread()->entry.pEntry = entry; in k_thread_user_mode_enter()
777 arch_current_thread()->entry.parameter1 = p1; in k_thread_user_mode_enter()
778 arch_current_thread()->entry.parameter2 = p2; in k_thread_user_mode_enter()
779 arch_current_thread()->entry.parameter3 = p3; in k_thread_user_mode_enter()
782 __ASSERT(z_stack_is_user_capable(arch_current_thread()->stack_obj), in k_thread_user_mode_enter()
783 "dropping to user mode with kernel-only stack object"); in k_thread_user_mode_enter()
785 memset(arch_current_thread()->userspace_local_data, 0, in k_thread_user_mode_enter()
790 (char *)(arch_current_thread()->stack_info.start + in k_thread_user_mode_enter()
791 arch_current_thread()->stack_info.size)); in k_thread_user_mode_enter()
817 * read unused stack memory. in z_stack_space_get()
828 return -ENOTSUP; in z_stack_space_get()
836 * FIXME: thread->stack_info.start ought to reflect in z_stack_space_get()
840 size -= 4; in z_stack_space_get()
860 if (thread->stack_info.mapped.addr == NULL) { in z_impl_k_thread_stack_space_get()
861 return -EINVAL; in z_impl_k_thread_stack_space_get()
865 return z_stack_space_get((const uint8_t *)thread->stack_info.start, in z_impl_k_thread_stack_space_get()
866 thread->stack_info.size, unused_ptr); in z_impl_k_thread_stack_space_get()
937 (arch_current_thread()->base.thread_state & _THREAD_DUMMY) != 0) in z_thread_mark_switched_out()
949 return -EINVAL; in k_thread_runtime_stats_get()
968 return -EINVAL; in k_thread_runtime_stats_all_get()
981 stats->execution_cycles += tmp_stats.execution_cycles; in k_thread_runtime_stats_all_get()
982 stats->total_cycles += tmp_stats.total_cycles; in k_thread_runtime_stats_all_get()
984 stats->current_cycles += tmp_stats.current_cycles; in k_thread_runtime_stats_all_get()
985 stats->peak_cycles += tmp_stats.peak_cycles; in k_thread_runtime_stats_all_get()
986 stats->average_cycles += tmp_stats.average_cycles; in k_thread_runtime_stats_all_get()
988 stats->idle_cycles += tmp_stats.idle_cycles; in k_thread_runtime_stats_all_get()
998 return -EINVAL; in k_thread_runtime_stats_cpu_get()
1031 * - The thread object may have been overwritten by the time in defer_thread_cleanup()
1048 thread_cleanup_stack_addr = thread->stack_info.mapped.addr; in defer_thread_cleanup()
1049 thread_cleanup_stack_sz = thread->stack_info.mapped.sz; in defer_thread_cleanup()
1051 /* The stack is now considered un-usable. This should prevent any functions in defer_thread_cleanup()
1055 thread->stack_info.mapped.addr = NULL; in defer_thread_cleanup()
1056 thread->stack_info.mapped.sz = 0; in defer_thread_cleanup()
1063 * - The thread object may have been overwritten when this is in do_thread_cleanup()