blob: 8386bd593e1471a0dd458cb6a3b6be90b77f3628 [file] [log] [blame]
Kevin Peng477fa942019-07-29 10:55:17 +08001/*
2 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __OS_WRAPPER_THREAD_H__
9#define __OS_WRAPPER_THREAD_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include "common.h"
16
17/* prototype for the thread entry function */
18typedef void (*os_wrapper_thread_func) (void *argument);
19
20/**
21 * \brief Creates a new thread
22 *
23 * \param[in] name Name of the thread
24 * \param[in] stack_size Size of stack to be allocated for this thread. It can
25 * be \ref OS_WRAPPER_DEFAULT_STACK_SIZE to use the
26 * default value provided by the underlying RTOS
27 * \param[in] func Pointer to the function invoked by thread
28 * \param[in] arg Argument to pass to the function invoked by thread
29 * \param[in] priority Initial thread priority
30 *
Kevin Peng383e8402019-08-05 16:35:44 +080031 * \return Returns the thread handle created, or NULL in case of error
Kevin Peng477fa942019-07-29 10:55:17 +080032 */
Kevin Peng383e8402019-08-05 16:35:44 +080033void *os_wrapper_thread_new(const char *name, int32_t stack_size,
34 os_wrapper_thread_func func, void *arg,
35 uint32_t priority);
Kevin Peng477fa942019-07-29 10:55:17 +080036/**
Kevin Peng383e8402019-08-05 16:35:44 +080037 * \brief Gets current thread handle
Kevin Peng477fa942019-07-29 10:55:17 +080038 *
Kevin Peng383e8402019-08-05 16:35:44 +080039 * \return Returns the thread handle, or NULL in case of error
Kevin Peng477fa942019-07-29 10:55:17 +080040 */
Kevin Peng383e8402019-08-05 16:35:44 +080041void *os_wrapper_thread_get_handle(void);
Kevin Peng477fa942019-07-29 10:55:17 +080042
43/**
44 * \brief Gets thread priority
45 *
Kevin Peng383e8402019-08-05 16:35:44 +080046 * \param[in] handle Thread handle
47 * \param[out] priority The priority of the thread
Kevin Peng477fa942019-07-29 10:55:17 +080048 *
Kevin Peng383e8402019-08-05 16:35:44 +080049 * \return Returns \ref OS_WRAPPER_SUCCESS on success, or \ref OS_WRAPPER_ERROR
50 * in case of error
Kevin Peng477fa942019-07-29 10:55:17 +080051 */
Kevin Peng383e8402019-08-05 16:35:44 +080052uint32_t os_wrapper_thread_get_priority(void *handle, uint32_t *priority);
Kevin Peng477fa942019-07-29 10:55:17 +080053
54/**
55 * \brief Exits the calling thread
56 */
57void os_wrapper_thread_exit(void);
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif /* __OS_WRAPPER_THREAD_H__ */