blob: 2df35327fe1abc2f5f4d616ec25e7303d0a9f06e [file] [log] [blame]
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +00001/*
Gyorgy Szing40a7af02019-02-06 14:19:47 +01002 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __OS_WRAPPER_H__
9#define __OS_WRAPPER_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include <stdint.h>
16
17#define OS_WRAPPER_ERROR 0xFFFFFFFF
18
19/* prototype for the thread entry function */
20typedef void (*os_wrapper_thread_func) (void *argument);
21
22/**
23 * \brief Creates a new semaphore
24 *
25 * \param[in] max_count Highest count of the semaphore
26 * \param[in] initial_count Starting count of the semaphore
27 * \param[in] name Name of the semaphore
28 *
29 * \return Returns ID of the semaphore created, or OS_WRAPPER_ERROR in case of
30 * error
31 */
32uint32_t os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count,
33 const char *name);
34
35/**
36 * \brief Acquires the semaphore
37 *
38 * \param[in] semaphore_id Semaphore ID
39 * \param[in] timeout Timeout value
40 *
41 * \return 0 in case of successful acquision, or OS_WRAPPER_ERROR in case of
42 * error
43 */
44uint32_t os_wrapper_semaphore_acquire(uint32_t semaphore_id, uint32_t timeout);
45
46/**
47 * \brief Releases the semaphore
48 *
49 * \param[in] semaphore_id Semaphore ID
50 *
51 * \return 0 in case of successful release, or OS_WRAPPER_ERROR in case of error
52 */
53uint32_t os_wrapper_semaphore_release(uint32_t semaphore_id);
54
55/**
56 * \brief Deletes the semaphore
57 *
58 * \param[in] semaphore_id Semaphore ID
59 *
60 * \return 0 in case of successful release, or OS_WRAPPER_ERROR in case of error
61 */
Gyorgy Szing40a7af02019-02-06 14:19:47 +010062uint32_t os_wrapper_semaphore_delete(uint32_t semaphore_id);
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +000063
64/**
65 * \brief Creates a new thread
66 *
67 * \param[in] name Name of the thread
68 * \param[in] stack_size Size of stack to be allocated for this thread
69 * \param[in] func Pointer to the function invoked by thread
Jamie Fox96dfe7b2018-02-05 14:27:51 +000070 * \param[in] arg Argument to pass to the function invoked by thread
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +000071 * \param[in] priority Initial thread priority
72 *
73 * \return Returns thread ID, or OS_WRAPPER_ERROR in case of error
74 */
75uint32_t os_wrapper_new_thread(const char *name, uint32_t stack_size,
Jamie Fox96dfe7b2018-02-05 14:27:51 +000076 os_wrapper_thread_func func, void *arg,
77 uint32_t priority);
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +000078/**
79 * \brief Gets current thread ID
80 *
81 * \return Returns thread ID, or OS_WRAPPER_ERROR in case of error
82 */
83uint32_t os_wrapper_get_thread_id(void);
84
85/**
86 * \brief Gets thread priority
87 *
88 * \param[in] id Thread ID
89 *
90 * \return Returns thread priority value, or OS_WRAPPER_ERROR in case of error
91 */
92uint32_t os_wrapper_get_thread_priority(uint32_t id);
93
94/**
Jamie Fox440cd892018-02-26 15:43:23 +000095 * \brief Waits for the thread to terminate
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +000096 *
97 * \param[in] id Thread ID
98 *
Jamie Fox440cd892018-02-26 15:43:23 +000099 * \return 0 in case of successful join or OS_WRAPPER_ERROR in case of error.
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +0000100 */
Jamie Fox440cd892018-02-26 15:43:23 +0000101uint32_t os_wrapper_join_thread(uint32_t id);
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +0000102
103#ifdef __cplusplus
104}
105#endif
106
107#endif /* __OS_WRAPPER_H__ */