Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

OsalSemaphore.h

Go to the documentation of this file.
00001 /** 
00002  *  @file   OsalSemaphore.h
00003  *
00004  *  @brief      Kernel utils Semaphore interface definitions.
00005  *
00006  *              This abstracts the Semaphore interface in Kernel code and
00007  *              is implemented using the wait queues. It has interfaces
00008  *              for creating, destroying, waiting and triggering the Semaphores.
00009  *
00010  *
00011  *  @ver        02.00.00.68_beta1
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 #ifndef OSALSEMAPHORE_H_0xF6D6
00056 #define OSALSEMAPHORE_H_0xF6D6
00057 
00058 
00059 /* OSAL and utils */
00060 
00061 
00062 #if defined (__cplusplus)
00063 extern "C" {
00064 #endif
00065 
00066 
00067 /*!
00068  *  @def    OSALSEMAPHORE_MODULEID
00069  *  @brief  Module ID for OsalSemaphore OSAL module.
00070  */
00071 #define OSALSEMAPHORE_MODULEID                 (UInt16) 0xF6D6
00072 
00073 /* =============================================================================
00074  *  All success and failure codes for the module
00075  * =============================================================================
00076  */
00077 /*!
00078 * @def   OSALSEMAPHORE_STATUSCODEBASE
00079 * @brief Stauts code base for MEMORY module.
00080 */
00081 #define OSALSEMAPHORE_STATUSCODEBASE      (OSALSEMAPHORE_MODULEID << 12u)
00082 
00083 /*!
00084 * @def   OSALSEMAPHORE_MAKE_FAILURE
00085 * @brief Convert to failure code.
00086 */
00087 #define OSALSEMAPHORE_MAKE_FAILURE(x)  ((Int) (0x80000000  \
00088                                         + (OSALSEMAPHORE_STATUSCODEBASE +(x))))
00089 /*!
00090 * @def   OSALSEMAPHORE_MAKE_SUCCESS
00091 * @brief Convert to success code.
00092 */
00093 #define OSALSEMAPHORE_MAKE_SUCCESS(x)      (OSALSEMAPHORE_STATUSCODEBASE + (x))
00094 
00095 /*!
00096 * @def   OSALSEMAPHORE_E_MEMORY
00097 * @brief Indicates OsalSemaphore alloc/free failure.
00098 */
00099 #define OSALSEMAPHORE_E_MEMORY             OSALSEMAPHORE_MAKE_FAILURE(1)
00100 
00101 /*!
00102 * @def   OSALSEMAPHORE_E_INVALIDARG
00103 * @brief Invalid argument provided
00104 */
00105 #define OSALSEMAPHORE_E_INVALIDARG         OSALSEMAPHORE_MAKE_FAILURE(2)
00106 
00107 /*!
00108 * @def   OSALSEMAPHORE_E_FAIL
00109 * @brief Generic failure
00110 */
00111 #define OSALSEMAPHORE_E_FAIL               OSALSEMAPHORE_MAKE_FAILURE(3)
00112 
00113 /*!
00114 * @def   OSALSEMAPHORE_E_TIMEOUT
00115 * @brief A timeout occurred
00116 */
00117 #define OSALSEMAPHORE_E_TIMEOUT            OSALSEMAPHORE_MAKE_FAILURE(4)
00118 
00119 /*!
00120  *  @def    OSALSEMAPHORE_E_HANDLE
00121  *  @brief  Invalid handle provided
00122  */
00123 #define OSALSEMAPHORE_E_HANDLE             OSALSEMAPHORE_MAKE_FAILURE(5)
00124 
00125 /*!
00126  *  @def    OSALSEMAPHORE_E_WAITNONE
00127  *  @brief  WAIT_NONE timeout value was provided, but semaphore was not
00128  *          available.
00129  */
00130 #define OSALSEMAPHORE_E_WAITNONE           OSALSEMAPHORE_MAKE_FAILURE(6)
00131 
00132 /*!
00133 * @def   OSALSEMAPHORE_SUCCESS
00134 * @brief Operation successfully completed
00135 */
00136 #define OSALSEMAPHORE_SUCCESS              OSALSEMAPHORE_MAKE_SUCCESS(0)
00137 
00138 
00139 /* =============================================================================
00140  *  Macros and types
00141  * =============================================================================
00142  */
00143 /*!
00144  *  @def    OSALSEMAPHORE_WAIT_FOREVER
00145  *  @brief  Indicates forever wait for APIs that can wait.
00146  */
00147 #define OSALSEMAPHORE_WAIT_FOREVER           (~((UInt32) 0u))
00148 
00149 /*!
00150  *  @def    OSALSEMAPHORE_WAIT_NONE
00151  *  @brief  Indicates zero wait for APIs that can wait.
00152  */
00153 #define OSALSEMAPHORE_WAIT_NONE               ((UInt32) 0u)
00154 
00155 /*!
00156  *  @def    OSALSEMAPHORE_TYPE_VALUE
00157  *  @brief  Returns the value of semaphore type (binary/counting)
00158  */
00159 #define OSALSEMAPHORE_TYPE_VALUE(type)        (type & 0x0000FFFF)
00160 
00161 /*!
00162  *  @def    OSALSEMAPHORE_INTTYPE_VALUE
00163  *  @brief  Returns the value of semaphore interruptability type
00164  */
00165 #define OSALSEMAPHORE_INTTYPE_VALUE(type)     (type & 0xFFFF0000)
00166 
00167 /*!
00168  *  @brief  Declaration for the OsalSemaphore object handle.
00169  *          Definition of OsalSemaphore_Object is not exposed.
00170  */
00171 typedef struct OsalSemaphore_Object * OsalSemaphore_Handle;
00172 
00173 /*!
00174  *  @brief   Enumerates the types of semaphores
00175  */
00176 typedef enum {
00177     OsalSemaphore_Type_Binary          = 0x00000000,
00178     /*!< Binary semaphore */
00179     OsalSemaphore_Type_Counting        = 0x00000001,
00180     /*!< Counting semaphore */
00181     OsalSemaphore_Type_EndValue        = 0x00000002
00182     /*!< End delimiter indicating start of invalid values for this enum */
00183 } OsalSemaphore_Type;
00184 
00185 /*!
00186  *  @brief   Enumerates the interruptible/non-interruptible types.
00187  */
00188 typedef enum {
00189     OsalSemaphore_IntType_Interruptible    = 0x00000000,
00190     /*!< Waits on this mutex are interruptible */
00191     OsalSemaphore_IntType_Noninterruptible = 0x00010000,
00192     /*!< Waits on this mutex are non-interruptible */
00193     OsalSemaphore_IntType_EndValue         = 0x00020000
00194     /*!< End delimiter indicating start of invalid values for this enum */
00195 } OsalSemaphore_IntType;
00196 
00197 
00198 /* =============================================================================
00199  *  APIs
00200  * =============================================================================
00201  */
00202 /* Creates the semaphore object. */
00203 OsalSemaphore_Handle OsalSemaphore_create (UInt32 semType);
00204 
00205 /* Deletes the semaphore object */
00206 Int OsalSemaphore_delete (OsalSemaphore_Handle * semHandle);
00207 
00208 /* Wait on the said Semaphore in the kernel thread context */
00209 Int OsalSemaphore_pend (OsalSemaphore_Handle semHandle, UInt32 timeout);
00210 
00211 /* Signal the semaphore and make it available for other threads. */
00212 Int OsalSemaphore_post (OsalSemaphore_Handle semHandle);
00213 
00214 
00215 #if defined (__cplusplus)
00216 }
00217 #endif /* defined (__cplusplus) */
00218 
00219 #endif /* ifndef OSALSEMAPHORE_H_0xF6D6 */

Generated on Mon Mar 14 11:59:45 2011 for Syslink by  doxygen 1.4.4