PDK API Guide for AM65xx
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/TaskP.h>
63 #include <ti/osal/HwiP.h>
64 #include <ti/osal/MuxIntcP.h>
65 #include <ti/osal/SemaphoreP.h>
66 #include <ti/osal/CacheP.h>
67 #include <ti/osal/TimerP.h>
68 #include <ti/osal/RegisterIntr.h>
69 #include <ti/osal/QueueP.h>
70 #include <ti/osal/CycleprofilerP.h>
71 #include <ti/osal/MailboxP.h>
72 #include <ti/osal/MutexP.h>
73 #include <ti/osal/ClockP.h>
74 #include <ti/osal/DebugP.h>
75 #include <ti/osal/HeapP.h>
76 #include <ti/osal/MemoryP.h>
77 #include <ti/osal/EventP.h>
78 #ifdef _TMS320C6X
79 #include <ti/osal/EventCombinerP.h>
80 #endif
81 
87 /*********************************************************************
88  * @def osal_OK
89  * OSAL operation successful
90  *********************************************************************/
91 #define osal_OK (0)
92 
93 /*********************************************************************
94  * @def osal_FAILURE
95  * OSAL operation failed
96  *********************************************************************/
97 #define osal_FAILURE (-(int32_t)(1))
98 
99 /*********************************************************************
100  * @def osal_UNSUPPORTED
101  * OSAL operation is not supported
102  *********************************************************************/
103 #define osal_UNSUPPORTED (-(int32_t)(2))
104 
105 /*********************************************************************
106  * @def osal_NOMEM
107  * OSAL operation is not successful due to internal osal static memory
108  * is full. Application would need to create additional memory blocks
109  * during startup by calling @ref Osal_setHwAttrs API to set the additional
110  * memory blocks for semaphoreP and hwiP
111  *********************************************************************/
112 #define osal_NOMEM (-(int32_t)(3))
113 /* @} */
114 
115 /*********************************************************************
116  * @def osal_WAIT_FOREVER
117  * OSAL timeout wait forever
118  *********************************************************************/
119 #define osal_WAIT_FOREVER (~((uint32_t)0U))
120 
121 /*********************************************************************
122  * @def osal_NO_WAIT
123  * OSAL timeout no wait
124  *********************************************************************/
125 #define osal_NO_WAIT ((uint32_t)0U)
126 
127 /*********************************************************************
128  * @def OSAL_NONOS_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_NONOS_SEMAPHOREP_SIZE_BYTES ((uint32_t) 48U)
136 
137 /*********************************************************************
138  * @def OSAL_NONOS_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_NONOS_HWIP_SIZE_BYTES ((uint32_t) 48U)
145 
146 /*********************************************************************
147  * @def OSAL_TIRTOS_SEMAPHOREP_SIZE_BYTES
148  * Semaphorep handle size for non-os use case
149  * Application can use this size to provide a secondary extended
150  * memory block for semaphore creation when all the memory (internal to osal)
151  * are utilized
152  *
153  *********************************************************************/
154 #define OSAL_TIRTOS_SEMAPHOREP_SIZE_BYTES ((uint32_t) 96U)
155 
156 /*********************************************************************
157  * @def OSAL_TIRTOS_HWI_SIZE_BYTES
158  * HwiP handle size for non-os use case
159  * Application can use this size to provide a secondary extended
160  * memory block for hwip creation when all the memory (internal to osal)
161  * are utilized
162  *********************************************************************/
163 #define OSAL_TIRTOS_HWIP_SIZE_BYTES (96U)
164 
165 /*********************************************************************
166  * @def OSAL_FREERTOS_SEMAPHOREP_SIZE_BYTES
167  * Semaphorep handle size for non-os use case
168  * Application can use this size to provide a secondary extended
169  * memory block for semaphore creation when all the memory (internal to osal)
170  * are utilized
171  *
172  *********************************************************************/
173 #define OSAL_FREERTOS_SEMAPHOREP_SIZE_BYTES ((uint32_t) 96U)
174 
175 /*********************************************************************
176  * @def OSAL_FREERTOS_TASKP_SIZE_BYTES
177  * TaskP handle size for non-os use case
178  * Application can use this size to provide a secondary extended
179  * memory block for semaphore creation when all the memory (internal to osal)
180  * are utilized
181  *
182  *********************************************************************/
183 #define OSAL_FREERTOS_TASKP_SIZE_BYTES ((uint32_t) 128U)
184 
185 /*********************************************************************
186  * @def OSAL_SAFERTOS_SEMAPHOREP_SIZE_BYTES
187  * Semaphorep handle size for non-os use case
188  * Application can use this size to provide a secondary extended
189  * memory block for semaphore creation when all the memory (internal to osal)
190  * are utilized
191  *
192  *********************************************************************/
193 #define OSAL_SAFERTOS_SEMAPHOREP_SIZE_BYTES ((uint32_t) 136U)
194 
195 /*********************************************************************
196  * @def OSAL_SAFERTOS_TASKP_SIZE_BYTES
197  * TaskP handle size for non-os use case
198  * Application can use this size to provide a secondary extended
199  * memory block for semaphore creation when all the memory (internal to osal)
200  * are utilized
201  *
202  *********************************************************************/
203 #define OSAL_SAFERTOS_TASKP_SIZE_BYTES ((uint32_t) 156U)
204 
209 typedef struct Osal_StaticMemoryStatus
210 {
211  uint32_t peakSemObjs;
212  uint32_t numMaxSemObjs;
213  uint32_t numFreeSemObjs;
215  uint32_t peakTimerObjs;
216  uint32_t numMaxTimerObjs;
217  uint32_t numFreeTimerObjs;
219  uint32_t peakHwiObjs;
220  uint32_t numMaxHwiObjs;
221  uint32_t numFreeHwiObjs;
223 
228 typedef enum Osal_ThreadType_e {
234 
235 /* Internal function for assert */
236 extern void Osal_DebugP_assert(int32_t expression, const char *file, int32_t line);
246 /* in real code use TI's version of OSAL_Assert (which is also fatal for OSAL_Assert(1)*/
247 #define OSAL_Assert(expression) (Osal_DebugP_assert((int32_t)((expression)?1:0),\
248  __FILE__, __LINE__))
249 
257 
270 extern int32_t Osal_delay(uint32_t nTicks);
271 
276 typedef enum {
280 
285 typedef struct Osal_memRange_s {
286  uintptr_t base;
287  uint32_t size;
288 } Osal_memRange;
289 
294 typedef struct Osal_HwAttrs_s
295 {
297  int32_t cpuFreqKHz;
299  int32_t extClkKHz;
300 #if defined(gnu_targets_arm_A15F)
301 
302  uint32_t a15TargetProcMask;
303 #endif
304 #ifdef _TMS320C6X
305 
306  int32_t ECM_intNum[4];
307 #endif
308 
322 } Osal_HwAttrs;
323 
332 #define OSAL_HWATTR_SET_EXT_CLK (0x00000001U)
333 
337 #define OSAL_HWATTR_SET_ECM_INT (0x00000002U)
338 
342 #define OSAL_HWATTR_SET_HWACCESS_TYPE (0x00000004U)
343 
347 #define OSAL_HWATTR_SET_OSALDELAY_TIMER_BASE (0x00000008U)
348 
352 #define OSAL_HWATTR_SET_SEMP_EXT_BASE (0x00000010U)
353 
357 #define OSAL_HWATTR_SET_HWIP_EXT_BASE (0x00000020U)
358 
362 #define OSAL_HWATTR_SET_CPU_FREQ (0x00000040U)
363 
367 #define OSAL_HWATTR_SET_TARG_PROC_LIST (0x00000080)
368 /* @} */
369 
370 
388 extern int32_t Osal_setHwAttrs(uint32_t ctrlBitMap, const Osal_HwAttrs *hwAttrs);
389 
397 extern int32_t Osal_getHwAttrs(Osal_HwAttrs *hwAttrs);
398 
406 extern int32_t Osal_getStaticMemStatus(Osal_StaticMemStatus *pMemStat);
407 
413 extern int32_t Osal_getCoreId(void);
414 
419 
450 #define OSAL_COMPILE_TIME_SIZE_CHECK(x,y) \
451  do { \
452  struct { \
453  uint8_t NegativeSizeIfPostulateFalse[(y) + 1U - (x)]; \
454  } PostulateCheck; \
455  } \
456  while ((bool)false)
457 
462 extern void OS_init(void);
463 
468 extern void OS_start(void);
469 
474 extern void OS_stop(void);
475 
476 #ifdef __cplusplus
477 }
478 #endif
479 
480 #endif /* ti_OSAL__include */
481 /* @} */
Cycle profiler module to measure CPU cycles for the RTOS Porting Interface.
Osal_HwAccessType
Osal hw access type.
Definition: osal.h:276
Event Combiner routines for the RTOS Porting Interface.
Interrupt register routines.
Heap management module for the RTOS Porting Interface.
Osal_memRange extHwiPBlock
Definition: osal.h:321
uint32_t peakTimerObjs
Definition: osal.h:215
int32_t Osal_getCoreId(void)
Function to get the core ID of the running Core.
Osal hw attributes structure.
Definition: osal.h:294
Osal_ThreadType Osal_getThreadType(void)
Function to get the current thread type.
Osal_HwAccessType hwAccessType
Definition: osal.h:309
Cache Handling routines for the RTOS Porting Interface.
Definition: osal.h:229
Definition: osal.h:230
void OS_stop(void)
Function to stop OS / scheduler.
Definition: osal.h:278
Definition: osal.h:231
uintptr_t base
Definition: osal.h:286
uint32_t numMaxSemObjs
Definition: osal.h:212
Mailbox module for the RTOS Porting Interface.
Queue Handling routines for RTOS.
Event module for the RTOS Porting Interface.
Definition: osal.h:232
int32_t cpuFreqKHz
Definition: osal.h:297
Mailbox module for the RTOS Porting Interface.
Osal_memRange extSemaphorePBlock
Definition: osal.h:319
uint32_t numMaxTimerObjs
Definition: osal.h:216
Interrupt Controller Mux module for the RTOS Porting Interface.
Memory module for the RTOS Porting Interface.
uintptr_t osalDelayTimerBaseAddr
Definition: osal.h:317
uint32_t numFreeSemObjs
Definition: osal.h:213
uint32_t peakHwiObjs
Definition: osal.h:219
Semaphore module for the RTOS Porting Interface.
This structure holds static memory status parameters of OSAL library.
Definition: osal.h:209
Task module for the RTOS Porting Interface.
void Osal_DebugP_assert(int32_t expression, const char *file, int32_t line)
void OS_init(void)
Function for initializing the OS / scheduler.
int32_t Osal_delay(uint32_t nTicks)
Function to delay/sleep the specified number of ticks.
int32_t extClkKHz
Definition: osal.h:299
uint32_t numFreeHwiObjs
Definition: osal.h:221
Osal_ThreadType
This enum defines the multiple thread types used under OSAL library.
Definition: osal.h:228
Definition: osal.h:277
uint32_t numFreeTimerObjs
Definition: osal.h:217
uint32_t numMaxHwiObjs
Definition: osal.h:220
Osal_HwAttrs gOsal_HwAttrs
external references for Osal Hw Attribute structure
Clock module for the RTOS Porting Interface. This implements the software timer support....
Osal memory address range.
Definition: osal.h:285
uint32_t size
Definition: osal.h:287
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:211
void OS_start(void)
Function to strat OS / scheduler.
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.