blob: 931cb96fd9f3974eff7cf42adf2343df6201eb74 [file] [log] [blame]
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +00001/*
Jamie Fox440cd892018-02-26 15:43:23 +00002 * Copyright (c) 2017-2018, 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 */
62uint32_t os_wrapper_semaphore_delete(uint32_t sema);
63
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
70 * \param[in] priority Initial thread priority
71 *
72 * \return Returns thread ID, or OS_WRAPPER_ERROR in case of error
73 */
74uint32_t os_wrapper_new_thread(const char *name, uint32_t stack_size,
75 os_wrapper_thread_func func, uint32_t priority);
76/**
77 * \brief Gets current thread ID
78 *
79 * \return Returns thread ID, or OS_WRAPPER_ERROR in case of error
80 */
81uint32_t os_wrapper_get_thread_id(void);
82
83/**
84 * \brief Gets thread priority
85 *
86 * \param[in] id Thread ID
87 *
88 * \return Returns thread priority value, or OS_WRAPPER_ERROR in case of error
89 */
90uint32_t os_wrapper_get_thread_priority(uint32_t id);
91
92/**
Jamie Fox440cd892018-02-26 15:43:23 +000093 * \brief Waits for the thread to terminate
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +000094 *
95 * \param[in] id Thread ID
96 *
Jamie Fox440cd892018-02-26 15:43:23 +000097 * \return 0 in case of successful join or OS_WRAPPER_ERROR in case of error.
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +000098 */
Jamie Fox440cd892018-02-26 15:43:23 +000099uint32_t os_wrapper_join_thread(uint32_t id);
Marc Moreno Berengueffd3c462017-11-29 16:09:52 +0000100
101#ifdef __cplusplus
102}
103#endif
104
105#endif /* __OS_WRAPPER_H__ */