Skip to content

Commit b68cdc7

Browse files
committed
arch: microblaze: Thread Creation and Termination
Internal references: FWRIVERHD-4973 Signed-off-by: Alp Sayin <alpsayin@gmail.com>
1 parent f7b2c3c commit b68cdc7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

arch/microblaze/core/thread.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
* Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
9+
10+
#include <zephyr/kernel.h>
11+
12+
void z_thread_entry(k_thread_entry_t thread, void *arg1, void *arg2, void *arg3);
13+
14+
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, char *stack_ptr,
15+
k_thread_entry_t entry, void *arg1, void *arg2, void *arg3)
16+
{
17+
struct __esf *stack_init;
18+
19+
/* Initial stack frame for thread */
20+
stack_init =
21+
(struct __esf *)Z_STACK_PTR_ALIGN(Z_STACK_PTR_TO_FRAME(struct __esf, stack_ptr));
22+
23+
/* Setup the initial stack frame */
24+
stack_init->r5 = (uint32_t)entry;
25+
stack_init->r6 = (uint32_t)arg1;
26+
stack_init->r7 = (uint32_t)arg2;
27+
stack_init->r8 = (uint32_t)arg3;
28+
stack_init->r14 = (uint32_t)z_thread_entry;
29+
30+
/* Initialise the stack to stack_init */
31+
thread->callee_saved.r1 = (uint32_t)stack_init;
32+
/* Threads start with irq_unlocked */
33+
thread->callee_saved.key = 1;
34+
/* and return value set to default */
35+
thread->callee_saved.retval = -EAGAIN;
36+
}
37+
38+
/**
39+
* @brief can be used as a safe stub for thread_abort implementation
40+
*
41+
* @return FUNC_NORETURN
42+
*/
43+
FUNC_NORETURN void arch_thread_sleep_forever(void)
44+
{
45+
k_sleep(K_FOREVER);
46+
CODE_UNREACHABLE;
47+
}

0 commit comments

Comments
 (0)