c41032ddfbd193fc67dab039c28e98f667fd1f20
1 /**
2 * @file rm_osal.h
3 *
4 * @brief
5 * This is the sample OS Adaptation layer which is used by the RM low level
6 * driver. The OSAL layer can be ported in either of the following
7 * manners to a native OS:
8 *
9 * <b> Approach 1: </b>
10 * @n Use Prebuilt Libraries
11 * - Ensure that the provide an implementation of all
12 * Osal_XXX API for their native OS.
13 * - Link the prebuilt libraries with their application.
14 * - Refer to the "example" directory for an example of this
15 * @n <b> Pros: </b>
16 * - Customers can reuse prebuilt TI provided libraries
17 * @n <b> Cons: </b>
18 * - Level of indirection in the API to get to the actual OS call
19 *
20 * <b> Approach 2: </b>
21 * @n Rebuilt Library
22 * - Create a copy of this file and modify it to directly
23 * inline the native OS calls
24 * - Rebuild the RM low level drivver library; ensure that the Include
25 * path points to the directory where the copy of this file
26 * has been provided.
27 * - Please refer to the "test" directory for an example of this
28 * @n <b> Pros: </b>
29 * - Optimizations can be done to remove the level of indirection
30 * @n <b> Cons: </b>
31 * - RM LLD Libraries need to be rebuilt by the customer.
32 *
33 * \par
34 * NOTE:
35 * (C) Copyright 2012 Texas Instruments, Inc.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 *
41 * Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 *
44 * Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the
47 * distribution.
48 *
49 * Neither the name of Texas Instruments Incorporated nor the names of
50 * its contributors may be used to endorse or promote products derived
51 * from this software without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 *
65 * \par
66 */
67 #ifndef __RM_OSAL_H__
68 #define __RM_OSAL_H__
70 /** @addtogroup RM_LLD_OSAL
71 @{ */
73 /**********************************************************************
74 ************************* Extern Declarations ************************
75 **********************************************************************/
77 /* #include <string.h> is here because there used to be
78 * memcpy/memset prototypes here. This #include prevents warnings in
79 * other code that unintentionally worked because of these prototypes
80 */
81 #include <string.h>
83 extern void* Osal_rmMalloc (uint32_t num_bytes);
84 extern void Osal_rmFree (void *ptr, uint32_t size);
85 extern void* Osal_rmCsEnter (void);
86 extern void Osal_rmCsExit (void *CsHandle);
87 extern void* Osal_rmMtCsEnter (void);
88 extern void Osal_rmMtCsExit (void *CsHandle);
89 extern void Osal_rmLog (char *fmt, ... );
90 extern void Osal_rmBeginMemAccess (void *ptr, uint32_t size);
91 extern void Osal_rmEndMemAccess (void *ptr, uint32_t size);
93 /**
94 * @brief The macro is used by the RM LLD to allocate memory of specified
95 * size
96 *
97 * <b> Prototype: </b>
98 * The following is the C prototype for the expected OSAL API.
99 *
100 * @verbatim
101 void* Osal_rmMalloc (uint32_t numBytes)
102 @endverbatim
103 *
104 * <b> Parameter </b>
105 * @n Number of bytes to be allocated
106 *
107 * <b> Return Value </b>
108 * @n Pointer to the allocated block size
109 */
111 #define Rm_osalMalloc Osal_rmMalloc
113 /**
114 * @brief The macro is used by the RM LLD to free a allocated block of
115 * memory
116 *
117 * <b> Prototype: </b>
118 * The following is the C prototype for the expected OSAL API.
119 *
120 * @verbatim
121 void Osal_rmFree (void *ptr, uint32_t size)
122 @endverbatim
123 *
124 * <b> Parameter </b>
125 * @n Pointer to the block of memory to be cleaned up.
126 * @n Size of the allocated memory which is being freed.
127 *
128 * <b> Return Value </b>
129 * @n Not applicable.
130 */
132 #define Rm_osalFree Osal_rmFree
134 /**
135 * @brief The macro is used by the RM LLD to provide critical sections to
136 * protect global and shared variables from
137 *
138 * access from multiple cores
139 * and
140 * access from multiple threads on single core
141 *
142 * <b> Prototype: </b>
143 * The following is the C prototype for the expected OSAL API.
144 *
145 * @verbatim
146 void* Osal_rmCsEnter (void)
147 @endverbatim
148 *
149 * <b> Parameter </b>
150 * @n None.
151 *
152 * <b> Return Value </b>
153 * @n Handle used to lock critical section.
154 */
155 #define Rm_osalCsEnter Osal_rmCsEnter
157 /**
158 * @brief The macro is used by the RM LLD to exit a critical section
159 * protected using Osal_rmCsEnter() API.
160 *
161 * <b> Prototype: </b>
162 * The following is the C prototype for the expected OSAL API.
163 *
164 * @verbatim
165 void Osal_rmCsExit (void *CsHandle)
166 @endverbatim
167 *
168 * <b> Parameter </b>
169 * @n Handle for unlocking critical section.
170 *
171 * <b> Return Value </b>
172 * @n Not applicable.
173 */
174 #define Rm_osalCsExit Osal_rmCsExit
176 /**
177 * @brief The macro is used by the RM LLD to provide critical sections to
178 * protect global and shared variables from
179 *
180 * access from multiple threads on single core
181 *
182 * <b> Prototype: </b>
183 * The following is the C prototype for the expected OSAL API.
184 *
185 * @verbatim
186 void* Osal_rmMtCsEnter (void)
187 @endverbatim
188 *
189 * <b> Parameter </b>
190 * @n None.
191 *
192 * <b> Return Value </b>
193 * @n Handle used to lock critical section.
194 */
195 #define Rm_osalMtCsEnter Osal_rmMtCsEnter
197 /**
198 * @brief The macro is used by the RM LLD to exit a critical section
199 * protected using Osal_rmMtCsEnter() API.
200 *
201 * <b> Prototype: </b>
202 * The following is the C prototype for the expected OSAL API.
203 *
204 * @verbatim
205 void Osal_rmMtCsExit (void *CsHandle)
206 @endverbatim
207 *
208 * <b> Parameter </b>
209 * @n Handle for unlocking critical section.
210 *
211 * <b> Return Value </b>
212 * @n Not applicable.
213 */
214 #define Rm_osalMtCsExit Osal_rmMtCsExit
216 /**
217 * @brief The macro is used by the RM LLD to log various
218 * messages.
219 *
220 * <b> Prototype: </b>
221 * The following is the C prototype for the expected OSAL API.
222 *
223 * @verbatim
224 void Osal_rmLog( char *fmt, ... )
225 @endverbatim
226 *
227 * <b> Parameter </b>
228 * @n printf-style format string
229 *
230 * <b> Return Value </b>
231 * @n Not applicable.
232 */
233 #define Rm_osalLog Osal_rmLog
235 /**
236 * @brief The macro is used by the RM LLD to indicate that a block
237 * of memory is about to be accessed. If the memory block is cached then
238 * this indicates that the application would need to ensure that the cache
239 * is updated with the data from the actual memory.
240 *
241 * <b> Prototype: </b>
242 * The following is the C prototype for the expected OSAL API.
243 *
244 * @verbatim
245 void Osal_rmBeginMemAccess (void *ptr, uint32_t size)
246 @endverbatim
247 *
248 * <b> Parameter </b>
249 * @n Address of memory block.
250 * @n Size of memory block.
251 *
252 * <b> Return Value </b>
253 * @n Not applicable.
254 */
255 #define Rm_osalBeginMemAccess Osal_rmBeginMemAccess
257 /**
258 * @brief The macro is used by the RM LLD to indicate that the block of
259 * memory has finished being accessed. If the memory block is cached then the
260 * application would need to ensure that the contents of the cache are updated
261 * immediately to the actual memory.
262 *
263 * <b> Prototype: </b>
264 * The following is the C prototype for the expected OSAL API.
265 *
266 * @verbatim
267 void Osal_rmEndMemAccess (void *ptr, uint32_t size)
268 @endverbatim
269 *
270 * <b> Parameter </b>
271 * @n Address of memory block.
272 * @n Size of memory block.
273 *
274 * <b> Return Value </b>
275 * @n Not applicable.
276 */
277 #define Rm_osalEndMemAccess Osal_rmEndMemAccess
279 /**
280 @}
281 */
282 #endif /* __RM_OSAL_H__ */