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