00001 00012 /* 00013 * ============================================================================ 00014 * 00015 * Copyright (c) 2008-2009, Texas Instruments Incorporated 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions 00019 * are met: 00020 * 00021 * * Redistributions of source code must retain the above copyright 00022 * notice, this list of conditions and the following disclaimer. 00023 * 00024 * * Redistributions in binary form must reproduce the above copyright 00025 * notice, this list of conditions and the following disclaimer in the 00026 * documentation and/or other materials provided with the distribution. 00027 * 00028 * * Neither the name of Texas Instruments Incorporated nor the names of 00029 * its contributors may be used to endorse or promote products derived 00030 * from this software without specific prior written permission. 00031 * 00032 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00033 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00034 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00035 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00036 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00037 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00038 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00039 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00040 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00041 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00042 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00043 * Contact information for paper mail: 00044 * Texas Instruments 00045 * Post Office Box 655303 00046 * Dallas, Texas 75265 00047 * Contact information: 00048 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm? 00049 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact 00050 * ============================================================================ 00051 * 00052 */ 00053 00054 00055 00056 #ifndef OSALSEMAPHORE_H_0xF6D6 00057 #define OSALSEMAPHORE_H_0xF6D6 00058 00059 00060 /* OSAL and utils */ 00061 00062 00063 #if defined (__cplusplus) 00064 extern "C" { 00065 #endif 00066 00067 00072 #define OSALSEMAPHORE_MODULEID (UInt16) 0xF6D6 00073 00074 /* ============================================================================= 00075 * All success and failure codes for the module 00076 * ============================================================================= 00077 */ 00082 #define OSALSEMAPHORE_STATUSCODEBASE (OSALSEMAPHORE_MODULEID << 12u) 00083 00088 #define OSALSEMAPHORE_MAKE_FAILURE(x) ((Int) (0x80000000 \ 00089 + (OSALSEMAPHORE_STATUSCODEBASE +(x)))) 00090 00094 #define OSALSEMAPHORE_MAKE_SUCCESS(x) (OSALSEMAPHORE_STATUSCODEBASE + (x)) 00095 00100 #define OSALSEMAPHORE_E_MEMORY OSALSEMAPHORE_MAKE_FAILURE(1) 00101 00106 #define OSALSEMAPHORE_E_INVALIDARG OSALSEMAPHORE_MAKE_FAILURE(2) 00107 00112 #define OSALSEMAPHORE_E_FAIL OSALSEMAPHORE_MAKE_FAILURE(3) 00113 00118 #define OSALSEMAPHORE_E_TIMEOUT OSALSEMAPHORE_MAKE_FAILURE(4) 00119 00124 #define OSALSEMAPHORE_E_HANDLE OSALSEMAPHORE_MAKE_FAILURE(5) 00125 00131 #define OSALSEMAPHORE_E_WAITNONE OSALSEMAPHORE_MAKE_FAILURE(6) 00132 00137 #define OSALSEMAPHORE_SUCCESS OSALSEMAPHORE_MAKE_SUCCESS(0) 00138 00139 00140 /* ============================================================================= 00141 * Macros and types 00142 * ============================================================================= 00143 */ 00148 #define OSALSEMAPHORE_WAIT_FOREVER (~((UInt32) 0u)) 00149 00154 #define OSALSEMAPHORE_WAIT_NONE ((UInt32) 0u) 00155 00160 #define OSALSEMAPHORE_TYPE_VALUE(type) (type & 0x0000FFFF) 00161 00166 #define OSALSEMAPHORE_INTTYPE_VALUE(type) (type & 0xFFFF0000) 00167 00172 typedef struct OsalSemaphore_Object * OsalSemaphore_Handle; 00173 00177 typedef enum { 00178 OsalSemaphore_Type_Binary = 0x00000000, 00180 OsalSemaphore_Type_Counting = 0x00000001, 00182 OsalSemaphore_Type_EndValue = 0x00000002 00184 } OsalSemaphore_Type; 00185 00189 typedef enum { 00190 OsalSemaphore_IntType_Interruptible = 0x00000000, 00192 OsalSemaphore_IntType_Noninterruptible = 0x00010000, 00194 OsalSemaphore_IntType_EndValue = 0x00020000 00196 } OsalSemaphore_IntType; 00197 00198 00199 /* ============================================================================= 00200 * APIs 00201 * ============================================================================= 00202 */ 00203 /* Creates the semaphore object. */ 00204 OsalSemaphore_Handle OsalSemaphore_create (UInt32 semType); 00205 00206 /* Deletes the semaphore object */ 00207 Int OsalSemaphore_delete (OsalSemaphore_Handle * semHandle); 00208 00209 /* Wait on the said Semaphore in the kernel thread context */ 00210 Int OsalSemaphore_pend (OsalSemaphore_Handle semHandle, UInt32 timeout); 00211 00212 /* Signal the semaphore and make it available for other threads. */ 00213 Int OsalSemaphore_post (OsalSemaphore_Handle semHandle); 00214 00215 00216 #if defined (__cplusplus) 00217 } 00218 #endif /* defined (__cplusplus) */ 00219 00220 #endif /* ifndef OSALSEMAPHORE_H_0xF6D6 */