Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 1 | /* |
| 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 |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | #include "common.h" |
| 16 | |
| 17 | /* prototype for the thread entry function */ |
| 18 | typedef 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 Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 31 | * \return Returns the thread handle created, or NULL in case of error |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 32 | */ |
Kevin Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 33 | void *os_wrapper_thread_new(const char *name, int32_t stack_size, |
| 34 | os_wrapper_thread_func func, void *arg, |
| 35 | uint32_t priority); |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 36 | /** |
Kevin Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 37 | * \brief Gets current thread handle |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 38 | * |
Kevin Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 39 | * \return Returns the thread handle, or NULL in case of error |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 40 | */ |
Kevin Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 41 | void *os_wrapper_thread_get_handle(void); |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * \brief Gets thread priority |
| 45 | * |
Kevin Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 46 | * \param[in] handle Thread handle |
| 47 | * \param[out] priority The priority of the thread |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 48 | * |
Kevin Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 49 | * \return Returns \ref OS_WRAPPER_SUCCESS on success, or \ref OS_WRAPPER_ERROR |
| 50 | * in case of error |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 51 | */ |
Kevin Peng | 383e840 | 2019-08-05 16:35:44 +0800 | [diff] [blame^] | 52 | uint32_t os_wrapper_thread_get_priority(void *handle, uint32_t *priority); |
Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * \brief Exits the calling thread |
| 56 | */ |
| 57 | void os_wrapper_thread_exit(void); |
| 58 | |
| 59 | #ifdef __cplusplus |
| 60 | } |
| 61 | #endif |
| 62 | |
| 63 | #endif /* __OS_WRAPPER_THREAD_H__ */ |