]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - linux/include/GateHWSpinlock.h
b809227ebebc95c8d7eca1744b8632f3cbfacfc6
[ipc/ipcdev.git] / linux / include / GateHWSpinlock.h
1 /*
2  * Copyright (c) 2008-2014, Texas Instruments Incorporated
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
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  *  ======== GateHWSpinlock.h ========
34  */
36 #ifndef GATEHWSPINLOCK_H_0xF416
37 #define GATEHWSPINLOCK_H_0xF416
39 /* Utilities & Osal headers */
40 #include <ti/ipc/Std.h>
42 #include <ti/ipc/GateMP.h>
44 #if defined (__cplusplus)
45 extern "C" {
46 #endif
48 /*!
49  *  @def    GateHWSpinlock_MODULEID
50  *  @brief  Unique module ID.
51  */
52 #define GateHWSpinlock_MODULEID               (0xc43d)
54 /* =============================================================================
55  * Module Success and Failure codes
56  * =============================================================================
57  */
58 /*!
59  *  @def    GateHWSpinlock_E_INVALIDARG
60  *  @brief  Argument passed to a function is invalid.
61  */
62 #define GateHWSpinlock_E_INVALIDARG       -1
64 /*!
65  *  @def    GateHWSpinlock_E_MEMORY
66  *  @brief  Memory allocation failed.
67  */
68 #define GateHWSpinlock_E_MEMORY           -2
70 /*!
71  *  @def    GateHWSpinlock_E_BUSY
72  *  @brief  the name is already registered or not.
73  */
74 #define GateHWSpinlock_E_BUSY             -3
76 /*!
77  *  @def    GateHWSpinlock_E_FAIL
78  *  @brief  Generic failure.
79  */
80 #define GateHWSpinlock_E_FAIL             -4
82 /*!
83  *  @def    GateHWSpinlock_E_NOTFOUND
84  *  @brief  name not found in the nameserver.
85  */
86 #define GateHWSpinlock_E_NOTFOUND         -5
88 /*!
89  *  @def    GateHWSpinlock_E_INVALIDSTATE
90  *  @brief  Module is not initialized.
91  */
92 #define GateHWSpinlock_E_INVALIDSTATE     -6
94 /*!
95  *  @def    GateHWSpinlock_E_NOTONWER
96  *  @brief  Instance is not created on this processor.
97  */
98 #define GateHWSpinlock_E_NOTONWER         -7
100 /*!
101  *  @def    GateHWSpinlock_E_REMOTEACTIVE
102  *  @brief  Remote opener of the instance has not closed the instance.
103  */
104 #define GateHWSpinlock_E_REMOTEACTIVE     -8
106 /*!
107  *  @def    GateHWSpinlock_E_INUSE
108  *  @brief  Indicates that the instance is in use..
109  */
110 #define GateHWSpinlock_E_INUSE            -9
112 /*!
113  *  @def    GateHWSpinlock_E_OSFAILURE
114  *  @brief  Failure in OS call.
115  */
116 #define GateHWSpinlock_E_OSFAILURE        -10
118 /*!
119  *  @def    GateHWSpinlock_E_VERSION
120  *  @brief  Version mismatch error.
121  */
122 #define GateHWSpinlock_E_VERSION          -11
124 /*!
125  *  @def    GateHWSpinlock_S_SUCCESS
126  *  @brief  Operation successful.
127  */
128 #define GateHWSpinlock_S_SUCCESS            0
130 /*!
131  *  @def    GateHWSpinlock_S_ALREADYSETUP
132  *  @brief  The GATEHWSPINLOCK module has already been setup in this process.
133  */
134 #define GateHWSpinlock_S_ALREADYSETUP     1
136 /* =============================================================================
137  * Macros
138  * =============================================================================
139  */
140 /*! @brief Forward declaration of structure defining object for the
141  *                 GateHWSpinlock. */
142 typedef struct GateHWSpinlock_Object GateHWSpinlock_Object;
144 /*!
145  *  @brief  Handle for the GateHWSpinlock.
146  */
147 typedef struct GateHWSpinlock_Object * GateHWSpinlock_Handle;
149 /* Q_BLOCKING */
150 #define GateHWSem_Q_BLOCKING   (1)
152 /* Q_PREEMPTING */
153 #define GateHWSem_Q_PREEMPTING (2)
156 /* =============================================================================
157  * Structures & Enums
158  * =============================================================================
159  */
161 /*!
162  *  @brief  Structure defining config parameters for the GateHWSpinlock module.
163  */
164 typedef struct GateHWSpinlock_Config {
165     UInt32               baseAddr;
166     /* Device-specific base address for HW Semaphore subsystem in HOST OS
167      * address space, this is updated in Ipc module */
168     UInt32               size;
169     /* Device-specific size for HW Semaphore subsystem */
170     UInt32               offset;
171     /* Device-specific size for HW Semaphore subsystem */
172 } GateHWSpinlock_Config;
174 /*!
175  *  @brief  Structure defining config parameters for the GateHWSpinlock
176  *          instances.
177  */
178 typedef struct GateHWSpinlock_Params {
179     Bits32 resourceId;
180     Bool   openFlag;
181     UInt16 regionId;
182     Ptr    sharedAddr;
183 } GateHWSpinlock_Params;
186 typedef enum GateHWSpinlock_LocalProtect {
187         GateHWSpinlock_LocalProtect_NONE      = 0,
188         GateHWSpinlock_LocalProtect_INTERRUPT = 1,
189         GateHWSpinlock_LocalProtect_TASKLET   = 2,
190         GateHWSpinlock_LocalProtect_THREAD    = 3,
191         GateHWSpinlock_LocalProtect_PROCESS   = 4
192 } GateHWSpinlock_LocalProtect;
194 /* =============================================================================
195  * APIs
196  * =============================================================================
197  */
198 /* Function to get the default configuration for the GateHWSpinlock module. */
199 Void
200 GateHWSpinlock_getConfig (GateHWSpinlock_Config * cfgParams);
202 /* Function to setup the GateHWSpinlock module. */
203 Int
204 GateHWSpinlock_setup (const GateHWSpinlock_Config * config);
206 /* Function to destroy the GateHWSpinlock module */
207 Int
208 GateHWSpinlock_destroy (Void);
210 /* Initialize parameter structure */
211 Void GateHWSpinlock_Params_init(GateHWSpinlock_Params *params);
213 /* Function to start GateHWSpinlock module */
214 Int32 GateHWSpinlock_start(Void);
216 /* Funciton to stop GateHWSpinlock module */
217 Int GateHWSpinlock_stop(Void);
219 /* Function to create an instance of GateHWSpinlock */
220 GateHWSpinlock_Handle
221 GateHWSpinlock_create (      GateHWSpinlock_LocalProtect localProtect,
222                        const GateHWSpinlock_Params *     params);
224 /* Function to delete an instance of GateHWSpinlock */
225 Int
226 GateHWSpinlock_delete (GateHWSpinlock_Handle * handlePtr);
228 /* Function to delete all instances of GateHWSpinlock */
229 Int
230 GateHWSpinlock_deleteAll (Void);
232 /* Function to enter the GateHWSpinlock instance */
233 IArg
234 GateHWSpinlock_enter  (GateHWSpinlock_Handle handle);
236 /* Function to leave the GateHWSpinlock instance */
237 Int
238 GateHWSpinlock_leave  (GateHWSpinlock_Handle handle, IArg   key);
240 /*!
241  *  @brief      Function to return the number of instances configured in the
242  *              module.
243  *
244  *  @return     Number of instances configured.
245  */
246 UInt32 GateHWSpinlock_getNumInstances (Void);
248 /*!
249  *  @brief      Function to initialize the locks
250  *              module.
251  *
252  */
253 Void GateHWSpinlock_locksinit(Void);
255 /* This is exported from daemon/GateHWSpinlockCfg_<PLATFORM>.c */
256 extern GateHWSpinlock_Config _GateHWSpinlock_cfgParams;
258 /* Internal variable to enable/disable tracing throughout GateHWSpinlock */
259 extern Bool _GateHWSpinlock_verbose;
261 #if defined (__cplusplus)
263 #endif /* defined (__cplusplus) */
266 #endif /* GATEHWSPINLOCK_H_0xF416 */