Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vcos.h 6.7KB

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