9b94b489291a2f3a077ebb3aab99d841039c20e7
1 /**
2 * @file rm_linux_osal.c
3 *
4 * @brief
5 * This is the OS abstraction layer used by the Resource Manager in Linux.
6 *
7 * \par
8 * ============================================================================
9 * @n (C) Copyright 2012-2014, Texas Instruments, Inc.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the
21 * distribution.
22 *
23 * Neither the name of Texas Instruments Incorporated nor the names of
24 * its contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 * \par
40 */
42 /* Standard Includes */
43 #include <stdint.h>
44 #include <stdarg.h>
45 #include <stdlib.h>
47 /**********************************************************************
48 ****************************** Defines *******************************
49 **********************************************************************/
51 /**********************************************************************
52 ************************** Global Variables **************************
53 **********************************************************************/
54 uint32_t rmMallocCounter = 0;
55 uint32_t rmFreeCounter = 0;
57 int32_t rmByteAlloc = 0;
58 int32_t rmByteFree = 0;
60 /**********************************************************************
61 *************************** OSAL Functions **************************
62 **********************************************************************/
64 /* FUNCTION PURPOSE: Allocates memory
65 ***********************************************************************
66 * DESCRIPTION: The function is used to allocate a memory block of the
67 * specified size.
68 */
69 void *Osal_rmMalloc (uint32_t num_bytes)
70 {
71 /* Increment the allocation counter. */
72 rmMallocCounter++;
73 rmByteAlloc += num_bytes;
75 /* Allocate memory. */
76 return calloc(1, num_bytes);
77 }
79 /* FUNCTION PURPOSE: Frees memory
80 ***********************************************************************
81 * DESCRIPTION: The function is used to free a memory block of the
82 * specified size.
83 */
84 void Osal_rmFree (void *ptr, uint32_t size)
85 {
86 /* Increment the free counter. */
87 rmFreeCounter++;
88 rmByteFree += size;
89 free(ptr);
90 }
92 /* FUNCTION PURPOSE: Critical section enter
93 ***********************************************************************
94 * DESCRIPTION: The function is used to enter a critical section.
95 * Function protects against
96 *
97 * access from multiple cores
98 * and
99 * access from multiple threads on single core
100 */
101 void *Osal_rmCsEnter(void)
102 {
103 return NULL;
104 }
106 /* FUNCTION PURPOSE: Critical section exit
107 ***********************************************************************
108 * DESCRIPTION: The function is used to exit a critical section
109 * protected using Osal_cppiCsEnter() API.
110 */
111 void Osal_rmCsExit(void *CsHandle)
112 {
114 }
116 /* FUNCTION PURPOSE: Multi-threaded critical section enter
117 ***********************************************************************
118 * DESCRIPTION: The function is used to enter a multi-threaded critical
119 * section. Function protects against
120 *
121 * access from multiple threads on single core
122 */
123 void *Osal_rmMtCsEnter(void *mtSemObj)
124 {
125 return NULL;
126 }
128 /* FUNCTION PURPOSE: Multi-threaded critical section exit
129 ***********************************************************************
130 * DESCRIPTION: The function is used to exit a multi-threaded critical
131 * section protected using Osal_rmMtCsEnter() API.
132 */
133 void Osal_rmMtCsExit(void *mtSemObj, void *CsHandle)
134 {
135 }
137 /* FUNCTION PURPOSE: Cache invalidate
138 ***********************************************************************
139 * DESCRIPTION: The function is used to indicate that a block of memory is
140 * about to be accessed. If the memory block is cached then this
141 * indicates that the application would need to ensure that the
142 * cache is updated with the data from the actual memory.
143 */
144 void Osal_rmBeginMemAccess(void *ptr, uint32_t size)
145 {
146 return;
147 }
149 /* FUNCTION PURPOSE: Cache writeback
150 ***********************************************************************
151 * DESCRIPTION: The function is used to indicate that the block of memory has
152 * finished being accessed. If the memory block is cached then the
153 * application would need to ensure that the contents of the cache
154 * are updated immediately to the actual memory.
155 */
156 void Osal_rmEndMemAccess(void *ptr, uint32_t size)
157 {
158 return;
159 }
161 /* FUNCTION PURPOSE: Creates a task blocking object
162 ***********************************************************************
163 * DESCRIPTION: The function is used to create a task blocking object
164 * capable of blocking the task a RM instance is running
165 * within
166 */
167 void *Osal_rmTaskBlockCreate(void)
168 {
169 return(NULL);
170 }
172 /* FUNCTION PURPOSE: Blocks a RM instance
173 ***********************************************************************
174 * DESCRIPTION: The function is used to block a task whose context a
175 * RM instance is running within.
176 */
177 void Osal_rmTaskBlock(void *handle)
178 {
180 }
182 /* FUNCTION PURPOSE: unBlocks a RM instance
183 ***********************************************************************
184 * DESCRIPTION: The function is used to unblock a task whose context a
185 * RM instance is running within.
186 */
187 void Osal_rmTaskUnblock(void *handle)
188 {
190 }
192 /* FUNCTION PURPOSE: Deletes a task blocking object
193 ***********************************************************************
194 * DESCRIPTION: The function is used to delete a task blocking object
195 * provided to a RM instance
196 */
197 void Osal_rmTaskBlockDelete(void *handle)
198 {
200 }
202 /* FUNCTION PURPOSE: Prints a variable list
203 ***********************************************************************
204 * DESCRIPTION: The function is used to print a string to the console
205 */
206 void Osal_rmLog (char *fmt, ... )
207 {
208 va_list ap;
210 va_start(ap, fmt);
211 vprintf(fmt, ap);
212 va_end(ap);
213 }