PDK API Guide for AM64x
osal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2018, 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 
38 /* @} */
39 
55 #ifndef ti_OSAL__include
56 #define ti_OSAL__include
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 #include <ti/osal/HwiP.h>
63 #include <ti/osal/MuxIntcP.h>
64 #include <ti/osal/SemaphoreP.h>
65 #include <ti/osal/CacheP.h>
66 #include <ti/osal/TimerP.h>
67 #include <ti/osal/RegisterIntr.h>
68 #include <ti/osal/Queue.h>
69 #include <ti/osal/CycleprofilerP.h>
70 #include <ti/osal/DebugP.h>
71 #ifdef _TMS320C6X
72 #include <ti/osal/EventCombinerP.h>
73 #endif
74 
80 /*********************************************************************
81  * @def osal_OK
82  * OSAL operation successful
83  *********************************************************************/
84 #define osal_OK (0)
85 
86 /*********************************************************************
87  * @def osal_FAILURE
88  * OSAL operation failed
89  *********************************************************************/
90 #define osal_FAILURE (-(int32_t)(1))
91 
92 /*********************************************************************
93  * @def osal_UNSUPPORTED
94  * OSAL operation is not supported
95  *********************************************************************/
96 #define osal_UNSUPPORTED (-(int32_t)(2))
97 
98 /*********************************************************************
99  * @def osal_NOMEM
100  * OSAL operation is not successful due to internal osal static memory
101  * is full. Application would need to create additional memory blocks
102  * during startup by calling @ref Osal_setHwAttrs API to set the additional
103  * memory blocks for semaphoreP and hwiP
104  *********************************************************************/
105 #define osal_NOMEM (-(int32_t)(3))
106 /* @} */
107 
108 /*********************************************************************
109  * @def OSAL_NONOS_SEMAPHOREP_SIZE_BYTES
110  * Semaphorep handle size for non-os use case
111  * Application can use this size to provide a secondary extended
112  * memory block for semaphore creation when all the memory (internal to osal)
113  * are utilized
114  *
115  *********************************************************************/
116 #define OSAL_NONOS_SEMAPHOREP_SIZE_BYTES ((uint32_t) 48U)
117 
118 /*********************************************************************
119  * @def OSAL_NONOS_HWI_SIZE_BYTES
120  * HwiP handle size for non-os use case
121  * Application can use this size to provide a secondary extended
122  * memory block for hwip creation when all the memory (internal to osal)
123  * are utilized
124  *********************************************************************/
125 #define OSAL_NONOS_HWIP_SIZE_BYTES ((uint32_t) 48U)
126 
127 /*********************************************************************
128  * @def OSAL_TIRTOS_SEMAPHOREP_SIZE_BYTES
129  * Semaphorep handle size for non-os use case
130  * Application can use this size to provide a secondary extended
131  * memory block for semaphore creation when all the memory (internal to osal)
132  * are utilized
133  *
134  *********************************************************************/
135 #define OSAL_TIRTOS_SEMAPHOREP_SIZE_BYTES ((uint32_t) 96U)
136 
137 /*********************************************************************
138  * @def OSAL_TIRTOS_HWI_SIZE_BYTES
139  * HwiP handle size for non-os use case
140  * Application can use this size to provide a secondary extended
141  * memory block for hwip creation when all the memory (internal to osal)
142  * are utilized
143  *********************************************************************/
144 #define OSAL_TIRTOS_HWIP_SIZE_BYTES (96U)
145 
150 typedef struct Osal_StaticMemoryStatus
151 {
152  uint32_t peakSemObjs;
153  uint32_t numMaxSemObjs;
154  uint32_t numFreeSemObjs;
156  uint32_t peakTimerObjs;
157  uint32_t numMaxTimerObjs;
158  uint32_t numFreeTimerObjs;
160  uint32_t peakHwiObjs;
161  uint32_t numMaxHwiObjs;
162  uint32_t numFreeHwiObjs;
164 
169 typedef enum Osal_ThreadType_e {
175 
176 /* Internal function for assert */
177 extern void Osal_DebugP_assert(int32_t expression, const char *file, int32_t line);
187 /* in real code use TI's version of OSAL_Assert (which is also fatal for OSAL_Assert(1)*/
188 #define OSAL_Assert(expression) (Osal_DebugP_assert((int32_t)((expression)?1:0),\
189  __FILE__, __LINE__))
190 
198 
211 extern int32_t Osal_delay(uint32_t nTicks);
212 
217 typedef enum {
221 
226 typedef struct Osal_memRange_s {
227  uintptr_t base;
228  uint32_t size;
229 } Osal_memRange;
230 
235 typedef struct Osal_HwAttrs_s
236 {
238  int32_t cpuFreqKHz;
240  int32_t extClkKHz;
241 #if defined(gnu_targets_arm_A15F)
242 
243  uint32_t a15TargetProcMask;
244 #endif
245 #ifdef _TMS320C6X
246 
247  int32_t ECM_intNum[4];
248 #endif
249 
263 } Osal_HwAttrs;
264 
273 #define OSAL_HWATTR_SET_EXT_CLK (0x00000001U)
274 
278 #define OSAL_HWATTR_SET_ECM_INT (0x00000002U)
279 
283 #define OSAL_HWATTR_SET_HWACCESS_TYPE (0x00000004U)
284 
288 #define OSAL_HWATTR_SET_OSALDELAY_TIMER_BASE (0x00000008U)
289 
293 #define OSAL_HWATTR_SET_SEMP_EXT_BASE (0x00000010U)
294 
298 #define OSAL_HWATTR_SET_HWIP_EXT_BASE (0x00000020U)
299 
303 #define OSAL_HWATTR_SET_CPU_FREQ (0x00000040U)
304 
308 #define OSAL_HWATTR_SET_TARG_PROC_LIST (0x00000080)
309 /* @} */
310 
311 
329 extern int32_t Osal_setHwAttrs(uint32_t ctrlBitMap, const Osal_HwAttrs *hwAttrs);
330 
338 extern int32_t Osal_getHwAttrs(Osal_HwAttrs *hwAttrs);
339 
347 extern int32_t Osal_getStaticMemStatus(Osal_StaticMemStatus *pMemStat);
348 
354 extern int32_t Osal_getCoreId(void);
355 
360 
391 #define OSAL_COMPILE_TIME_SIZE_CHECK(x,y) \
392  do { \
393  struct { \
394  uint8_t NegativeSizeIfPostulateFalse[(y) + 1U - (x)]; \
395  } PostulateCheck; \
396  } \
397  while ((bool)false)
398 
399 #ifdef __cplusplus
400 }
401 #endif
402 
403 #endif /* ti_OSAL__include */
404 /* @} */
Cycle profiler module to measure CPU cycles for the RTOS Porting Interface.
Osal_HwAccessType
Osal hw access type.
Definition: osal.h:217
Event Combiner routines for the RTOS Porting Interface.
Interrupt register routines.
Osal_memRange extHwiPBlock
Definition: osal.h:262
uint32_t peakTimerObjs
Definition: osal.h:156
int32_t Osal_getCoreId(void)
Function to get the core ID of the running Core.
Osal hw attributes structure.
Definition: osal.h:235
Osal_ThreadType Osal_getThreadType(void)
Function to get the current thread type.
Osal_HwAccessType hwAccessType
Definition: osal.h:250
Cache Handling routines for the RTOS Porting Interface.
Definition: osal.h:170
Definition: osal.h:171
Definition: osal.h:219
Definition: osal.h:172
uintptr_t base
Definition: osal.h:227
uint32_t numMaxSemObjs
Definition: osal.h:153
Definition: osal.h:173
Queue Handling routines for RTOS.
int32_t cpuFreqKHz
Definition: osal.h:238
Osal_memRange extSemaphorePBlock
Definition: osal.h:260
uint32_t numMaxTimerObjs
Definition: osal.h:157
Interrupt Controller Mux module for the RTOS Porting Interface.
uintptr_t osalDelayTimerBaseAddr
Definition: osal.h:258
uint32_t numFreeSemObjs
Definition: osal.h:154
uint32_t peakHwiObjs
Definition: osal.h:160
Semaphore module for the RTOS Porting Interface.
This structure holds static memory status parameters of OSAL library.
Definition: osal.h:150
void Osal_DebugP_assert(int32_t expression, const char *file, int32_t line)
int32_t Osal_delay(uint32_t nTicks)
Function to delay/sleep the specified number of ticks.
int32_t extClkKHz
Definition: osal.h:240
uint32_t numFreeHwiObjs
Definition: osal.h:162
Osal_ThreadType
This enum defines the multiple thread types used under OSAL library.
Definition: osal.h:169
Definition: osal.h:218
uint32_t numFreeTimerObjs
Definition: osal.h:158
uint32_t numMaxHwiObjs
Definition: osal.h:161
Osal_HwAttrs gOsal_HwAttrs
external references for Osal Hw Attribute structure
Osal memory address range.
Definition: osal.h:226
uint32_t size
Definition: osal.h:228
int32_t Osal_getStaticMemStatus(Osal_StaticMemStatus *pMemStat)
Function to get the static memory usage of OSAL library.
int32_t Osal_setHwAttrs(uint32_t ctrlBitMap, const Osal_HwAttrs *hwAttrs)
Function to set the Hw Attributes.
uint32_t peakSemObjs
Definition: osal.h:152
int32_t Osal_getHwAttrs(Osal_HwAttrs *hwAttrs)
Function to get the Hw Attributes.
Hardware Interrupt module for the RTOS Porting Interface.
Timer interface for the RTOS Porting Interface.