]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - test/k2h/armv7/linux/rm_linux_osal.c
Updated documentation to point to UG for instructions on running ARM+DSP test
[keystone-rtos/rm-lld.git] / test / k2h / armv7 / linux / rm_linux_osal.c
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-2013, 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 /**********************************************************************
58  *************************** OSAL Functions **************************
59  **********************************************************************/
61 /* FUNCTION PURPOSE: Allocates memory
62  ***********************************************************************
63  * DESCRIPTION: The function is used to allocate a memory block of the
64  *              specified size.
65  */
66 void *Osal_rmMalloc (uint32_t num_bytes)
67 {
68     /* Increment the allocation counter. */
69     rmMallocCounter++;
71         /* Allocate memory. */
72         return calloc(1, num_bytes);
73 }
75 /* FUNCTION PURPOSE: Frees memory
76  ***********************************************************************
77  * DESCRIPTION: The function is used to free a memory block of the
78  *              specified size.
79  */ 
80 void Osal_rmFree (void *ptr, uint32_t size)
81 {
82     /* Increment the free counter. */
83     rmFreeCounter++;
84         free(ptr);
85 }
87 /* FUNCTION PURPOSE: Critical section enter
88  ***********************************************************************
89  * DESCRIPTION: The function is used to enter a critical section.
90  *              Function protects against 
91  *      
92  *              access from multiple cores 
93  *              and 
94  *              access from multiple threads on single core
95  */  
96 void *Osal_rmCsEnter(void)
97 {
98     return NULL;
99 }
101 /* FUNCTION PURPOSE: Critical section exit
102  ***********************************************************************
103  * DESCRIPTION: The function is used to exit a critical section 
104  *              protected using Osal_cppiCsEnter() API.
105  */  
106 void Osal_rmCsExit(void *CsHandle)
111 /* FUNCTION PURPOSE: Cache invalidate
112  ***********************************************************************
113  * DESCRIPTION: The function is used to indicate that a block of memory is 
114  *              about to be accessed. If the memory block is cached then this 
115  *              indicates that the application would need to ensure that the 
116  *              cache is updated with the data from the actual memory.
117  */  
118 void Osal_rmBeginMemAccess(void *ptr, uint32_t size)
120     return;
123 /* FUNCTION PURPOSE: Cache writeback
124  ***********************************************************************
125  * DESCRIPTION: The function is used to indicate that the block of memory has 
126  *              finished being accessed. If the memory block is cached then the 
127  *              application would need to ensure that the contents of the cache 
128  *              are updated immediately to the actual memory. 
129  */  
130 void Osal_rmEndMemAccess(void *ptr, uint32_t size)
132     return;
135 /* FUNCTION PURPOSE: Creates a task blocking object
136  ***********************************************************************
137  * DESCRIPTION: The function is used to create a task blocking object
138  *              capable of blocking the task a RM instance is running
139  *              within
140  */
141 void *Osal_rmTaskBlockCreate(void)
143     return(NULL);
146 /* FUNCTION PURPOSE: Blocks a RM instance
147  ***********************************************************************
148  * DESCRIPTION: The function is used to block a task whose context a
149  *              RM instance is running within.
150  */
151 void Osal_rmTaskBlock(void *handle)
156 /* FUNCTION PURPOSE: unBlocks a RM instance
157  ***********************************************************************
158  * DESCRIPTION: The function is used to unblock a task whose context a
159  *              RM instance is running within.
160  */
161 void Osal_rmTaskUnblock(void *handle)
166 /* FUNCTION PURPOSE: Deletes a task blocking object
167  ***********************************************************************
168  * DESCRIPTION: The function is used to delete a task blocking object
169  *              provided to a RM instance
170  */
171 void Osal_rmTaskBlockDelete(void *handle)
176 /* FUNCTION PURPOSE: Prints a variable list
177  ***********************************************************************
178  * DESCRIPTION: The function is used to print a string to the console
179  */
180 void Osal_rmLog (char *fmt, ... )
182     va_list ap;
183     
184     va_start(ap, fmt);
185     vprintf(fmt, ap);
186     va_end(ap);