| 1 | /* | 
| 2 | Copyright (c) 2012, Broadcom Europe Ltd | 
| 3 | All rights reserved. | 
| 4 |  | 
| 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. | 
| 15 |  | 
| 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. | 
| 26 | */ | 
| 27 |  | 
| 28 | /*============================================================================= | 
| 29 | VideoCore OS Abstraction Layer - public header file | 
| 30 | =============================================================================*/ | 
| 31 |  | 
| 32 | #ifndef VCOS_EVENT_FLAGS_H | 
| 33 | #define VCOS_EVENT_FLAGS_H | 
| 34 |  | 
| 35 |  | 
| 36 | #ifdef __cplusplus | 
| 37 | extern "C"  { | 
| 38 | #endif | 
| 39 |  | 
| 40 | #include "interface/vcos/vcos_types.h" | 
| 41 | #include "vcos.h" | 
| 42 |  | 
| 43 | #define VCOS_EVENT_FLAGS_SUSPEND    VCOS_SUSPEND | 
| 44 | #define VCOS_EVENT_FLAGS_NO_SUSPEND VCOS_NO_SUSPEND | 
| 45 | typedef VCOS_OPTION VCOS_EVENTGROUP_OPERATION_T; | 
| 46 |  | 
| 47 | /** | 
| 48 |  * \file vcos_event_flags.h | 
| 49 |  * | 
| 50 |  * Defines event flags API. | 
| 51 |  * | 
| 52 |  * Similar to Nucleus event groups. | 
| 53 |  * | 
| 54 |  * These have the same semantics as Nucleus event groups and ThreadX event | 
| 55 |  * flags. As such, they are quite complex internally; if speed is important | 
| 56 |  * they might not be your best choice. | 
| 57 |  * | 
| 58 |  */ | 
| 59 |  | 
| 60 | /** | 
| 61 |  * Create an event flags instance. | 
| 62 |  * | 
| 63 |  * @param flags   Pointer to event flags instance, filled in on return. | 
| 64 |  * @param name    Name for the event flags, used for debug. | 
| 65 |  * | 
| 66 |  * @return VCOS_SUCCESS if succeeded. | 
| 67 |  */ | 
| 68 |  | 
| 69 | VCOS_INLINE_DECL | 
| 70 | VCOS_STATUS_T vcos_event_flags_create(VCOS_EVENT_FLAGS_T *flags, const char *name); | 
| 71 |  | 
| 72 | /** | 
| 73 |   * Set some events. | 
| 74 |   * | 
| 75 |   * @param flags   Instance to set flags on | 
| 76 |   * @param events  Bitmask of the flags to actually set | 
| 77 |   * @param op      How the flags should be set. VCOS_OR will OR in the flags; VCOS_AND | 
| 78 |   *                will AND them in, possibly clearing existing flags. | 
| 79 |   */ | 
| 80 | VCOS_INLINE_DECL | 
| 81 | void vcos_event_flags_set(VCOS_EVENT_FLAGS_T *flags, | 
| 82 |                           VCOS_UNSIGNED events, | 
| 83 |                           VCOS_OPTION op); | 
| 84 |  | 
| 85 | /** | 
| 86 |  * Retrieve some events. | 
| 87 |  * | 
| 88 |  * Waits until the specified events have been set. | 
| 89 |  * | 
| 90 |  * @param flags            Instance to wait on | 
| 91 |  * @param requested_events The bitmask to wait for | 
| 92 |  * @param op               VCOS_OR - get any; VCOS_AND - get all. | 
| 93 |  * @param ms_suspend       How long to wait, in milliseconds | 
| 94 |  * @param retrieved_events the events actually retrieved. | 
| 95 |  * | 
| 96 |  * @return VCOS_SUCCESS if events were retrieved. VCOS_EAGAIN if the | 
| 97 |  * timeout expired. | 
| 98 |  */ | 
| 99 | VCOS_INLINE_DECL | 
| 100 | VCOS_STATUS_T vcos_event_flags_get(VCOS_EVENT_FLAGS_T *flags, | 
| 101 |                                                      VCOS_UNSIGNED requested_events, | 
| 102 |                                                      VCOS_OPTION op, | 
| 103 |                                                      VCOS_UNSIGNED ms_suspend, | 
| 104 |                                                      VCOS_UNSIGNED *retrieved_events); | 
| 105 |  | 
| 106 |  | 
| 107 | /** | 
| 108 |  * Delete an event flags instance. | 
| 109 |  */ | 
| 110 | VCOS_INLINE_DECL | 
| 111 | void vcos_event_flags_delete(VCOS_EVENT_FLAGS_T *); | 
| 112 |  | 
| 113 | #ifdef __cplusplus | 
| 114 | } | 
| 115 | #endif | 
| 116 |  | 
| 117 | #endif | 
| 118 |  | 
| 119 |  |