Commit 0962114f authored by Daniel Leung's avatar Daniel Leung Committed by Anas Nashif
Browse files

riscv: implements arch_thread_priv_stack_space_get



This implements arch_thread_priv_stack_space_get() so this can
be used to figure out how much privileged stack space is used.

Signed-off-by: default avatarDaniel Leung <daniel.leung@intel.com>
parent bb313355
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ config RISCV
	select SCHED_IPI_SUPPORTED if SMP
	select ARCH_HAS_DIRECTED_IPIS
	select BARRIER_OPERATIONS_BUILTIN
	select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
	imply XIP
	help
	  RISCV architecture
+12 −0
Original line number Diff line number Diff line
@@ -195,6 +195,18 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
	CODE_UNREACHABLE;
}

int arch_thread_priv_stack_space_get(const struct k_thread *thread, size_t *stack_size,
				     size_t *unused_ptr)
{
	if ((thread->base.user_options & K_USER) != K_USER) {
		return -EINVAL;
	}

	*stack_size = Z_STACK_PTR_ALIGN(K_KERNEL_STACK_RESERVED + CONFIG_PRIVILEGED_STACK_SIZE);

	return z_stack_space_get((void *)thread->arch.priv_stack_start, *stack_size, unused_ptr);
}

#endif /* CONFIG_USERSPACE */

#ifndef CONFIG_MULTITHREADING