1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28/*=============================================================================
29VideoCore OS Abstraction Layer - common postamble code
30=============================================================================*/
31
32/** \file
33 *
34 * Postamble code included by the platform-specific header files
35 */
36
37#define VCOS_THREAD_PRI_DEFAULT VCOS_THREAD_PRI_NORMAL
38
39#if !defined(VCOS_THREAD_PRI_INCREASE)
40#error Which way to thread priorities go?
41#endif
42
43#if VCOS_THREAD_PRI_INCREASE < 0
44/* smaller numbers are higher priority */
45#define VCOS_THREAD_PRI_LESS(x) ((x)<VCOS_THREAD_PRI_MAX?(x)+1:VCOS_THREAD_PRI_MAX)
46#define VCOS_THREAD_PRI_MORE(x) ((x)>VCOS_THREAD_PRI_MIN?(x)-1:VCOS_THREAD_PRI_MIN)
47#else
48/* bigger numbers are lower priority */
49#define VCOS_THREAD_PRI_MORE(x) ((x)<VCOS_THREAD_PRI_MAX?(x)+1:VCOS_THREAD_PRI_MAX)
50#define VCOS_THREAD_PRI_LESS(x) ((x)>VCOS_THREAD_PRI_MIN?(x)-1:VCOS_THREAD_PRI_MIN)
51#endif
52
53/* Convenience for Brits: */
54#define VCOS_APPLICATION_INITIALISE VCOS_APPLICATION_INITIALIZE
55
56/*
57 * Check for constant definitions
58 */
59#ifndef VCOS_TICKS_PER_SECOND
60#error VCOS_TICKS_PER_SECOND not defined
61#endif
62
63#if !defined(VCOS_THREAD_PRI_MIN) || !defined(VCOS_THREAD_PRI_MAX)
64#error Priority range not defined
65#endif
66
67#if !defined(VCOS_THREAD_PRI_HIGHEST) || !defined(VCOS_THREAD_PRI_LOWEST) || !defined(VCOS_THREAD_PRI_NORMAL)
68#error Priority ordering not defined
69#endif
70
71#if !defined(VCOS_CAN_SET_STACK_ADDR)
72#error Can stack addresses be set on this platform? Please set this macro to either 0 or 1.
73#endif
74
75#if (_VCOS_AFFINITY_CPU0|_VCOS_AFFINITY_CPU1) & (~_VCOS_AFFINITY_MASK)
76#error _VCOS_AFFINITY_CPUxxx values are not consistent with _VCOS_AFFINITY_MASK
77#endif
78
79/** Append to the end of a singly-linked queue, O(1). Works with
80 * any structure where list has members 'head' and 'tail' and
81 * item has a 'next' pointer.
82 */
83#define VCOS_QUEUE_APPEND_TAIL(list, item) {\
84 (item)->next = NULL;\
85 if (!(list)->head) {\
86 (list)->head = (list)->tail = (item); \
87 } else {\
88 (list)->tail->next = (item); \
89 (list)->tail = (item); \
90 } \
91}
92
93#ifndef VCOS_HAVE_TIMER
94VCOSPRE_ void VCOSPOST_ vcos_timer_init(void);
95#endif
96
97