2 Copyright (c) 2012, Broadcom Europe Ltd
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 /*=============================================================================
29 VideoCore OS Abstraction Layer - public header file
30 =============================================================================*/
33 * \mainpage OS Abstraction Layer
35 * \section intro Introduction
37 * This abstraction layer is here to allow the underlying OS to be easily changed (e.g. from
38 * Nucleus to ThreadX) and to aid in porting host applications to new targets.
40 * \subsection error Error handling
42 * Wherever possible, VCOS functions assert internally and return void. The only exceptions
43 * are creation functions (which might fail due to lack of resources) and functions that
44 * might timeout or fail due to lack of space. Errors that might be reported by the underlying
45 * OS API (e.g. invalid mutex) are treated as a programming error, and are merely asserted on.
47 * \section thread_synch Threads and synchronisation
49 * \subsection thread Threads
51 * The thread API is somewhat different to that found in Nucleus. In particular, threads
52 * cannot just be destroyed at arbitrary times and nor can they merely exit. This is so
53 * that the same API can be implemented across all interesting platforms without too much
54 * difficulty. See vcos_thread.h for details. Thread attributes are configured via
55 * the VCOS_THREAD_ATTR_T structure, found in vcos_thread_attr.h.
57 * \subsection sema Semaphores
59 * Counted semaphores (c.f. Nucleus NU_SEMAPHORE) are created with VCOS_SEMAPHORE_T.
60 * Under ThreadX on VideoCore, semaphores are implemented using VideoCore spinlocks, and
61 * so are quite a lot faster than ordinary ThreadX semaphores. See vcos_semaphore.h.
63 * \subsection mtx Mutexes
65 * Mutexes are used for locking. Attempts to take a mutex twice, or to unlock it
66 * in a different thread to the one in which it was locked should be expected to fail.
67 * Mutexes are not re-entrant (see vcos_reentrant_mutex.h for a slightly slower
70 * \subsection evflags Event flags
72 * Event flags (the ThreadX name - also known as event groups under Nucleus) provide
73 * 32 flags which can be waited on by multiple clients, and signalled by multiple clients.
74 * A timeout can be specified. See vcos_event_flags.h. An alternative to this is the
75 * VCOS_EVENT_T (see vcos_event.h) which is akin to the Win32 auto-reset event, or a
76 * saturating counted semaphore.
78 * \subsection event Events
80 * A VCOS_EVENT_T is a bit like a saturating semaphore. No matter how many times it
81 * is signalled, the waiter will only wake up once. See vcos_event.h. You might think this
82 * is useful if you suspect that the cost of reading the semaphore count (perhaps via a
83 * system call) is expensive on your platform.
85 * \subsection tls Thread local storage
87 * Thread local storage is supported using vcos_tls.h. This is emulated on Nucleus
90 * \section int Interrupts
92 * The legacy LISR/HISR scheme found in Nucleus is supported via the legacy ISR API,
93 * which is also supported on ThreadX. New code should avoid this, and old code should
94 * be migrated away from it, since it is slow. See vcos_legacy_isr.h.
96 * Registering an interrupt handler, and disabling/restoring interrupts, is handled
97 * using the functions in vcos_isr.h.
104 * This is the top level header file. Clients include this. It pulls in the platform-specific
105 * header file (vcos_platform.h) together with header files defining the expected APIs, such
106 * as vcos_mutex.h, vcos_semaphore.h, etc. It is also possible to include these header files
114 #include "interface/vcos/vcos_assert.h"
115 #include "vcos_types.h"
117 #if defined(__unix__) && !defined(__ANDROID__)
118 #include "interface/vcos/pthreads/vcos_platform.h"
120 #include "vcos_platform.h"
124 #include "interface/vcos/vcos_init.h"
127 #ifndef VCOS_SEMAPHORE_H
128 #include "interface/vcos/vcos_semaphore.h"
131 #ifndef VCOS_THREAD_H
132 #include "interface/vcos/vcos_thread.h"
136 #include "interface/vcos/vcos_mutex.h"
140 #include "interface/vcos/vcos_mem.h"
143 #ifndef VCOS_LOGGING_H
144 #include "interface/vcos/vcos_logging.h"
147 #ifndef VCOS_STRING_H
148 #include "interface/vcos/vcos_string.h"
152 #include "interface/vcos/vcos_event.h"
155 #ifndef VCOS_THREAD_ATTR_H
156 #include "interface/vcos/vcos_thread_attr.h"
160 #include "interface/vcos/vcos_tls.h"
163 #ifndef VCOS_REENTRANT_MUTEX_H
164 #include "interface/vcos/vcos_reentrant_mutex.h"
167 #ifndef VCOS_NAMED_SEMAPHORE_H
168 #include "interface/vcos/vcos_named_semaphore.h"
171 #ifndef VCOS_QUICKSLOW_MUTEX_H
172 #include "interface/vcos/vcos_quickslow_mutex.h"
175 /* Headers with predicates */
177 #if VCOS_HAVE_EVENT_FLAGS
178 #include "interface/vcos/vcos_event_flags.h"
182 #include "interface/vcos/vcos_queue.h"
185 #if VCOS_HAVE_LEGACY_ISR
186 #include "interface/vcos/vcos_legacy_isr.h"
190 #include "interface/vcos/vcos_timer.h"
193 #if VCOS_HAVE_MEMPOOL
194 #include "interface/vcos/vcos_mempool.h"
198 #include "interface/vcos/vcos_isr.h"
201 #if VCOS_HAVE_ATOMIC_FLAGS
202 #include "interface/vcos/vcos_atomic_flags.h"
206 #include "interface/vcos/vcos_once.h"
209 #if VCOS_HAVE_BLOCK_POOL
210 #include "interface/vcos/vcos_blockpool.h"
214 #include "interface/vcos/vcos_file.h"
218 #include "interface/vcos/vcos_cfg.h"
222 #include "interface/vcos/vcos_cmd.h"