1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
|
/******************************************************************************
TORNADO AMC modules Software Development Kit (SDK). Rev 3A.
TI SYS/BIOS RTOS abstraction layer for TORNADO AMC embedded controllers.
(C) MicroLAB Systems, 2014-2015
File: This file contains TI SYS/BIOS RTOS abstraction layer definitions
----- for TORNADO AMC embedded controllers, which is used for various
low-level drivers (LLD) and libraries that the application use.
Revision history:
-----------------
rev.1A - 2014, initial release for TORNADO-A6678 board
rev.2A - 2015, totally redesigned SDK;
rev.3A - 2016, added support for TORNADO-A6678/FMC board rev.1A;
******************************************************************************/
/**
* @file TA66XX_OSAL.h
*
* @brief RTOS abstraction layer definitions
*
* This file contains TI SYS/BIOS RTOS abstraction layer (OSAL) definitions for
* TORNADO AMC embedded controllers, which is used for various
* low-level drivers (LLD) and libraries that the application use.
*
*/
#ifndef __TA66XX_OSAL_H__ // check for this file has been already included
#define __TA66XX_OSAL_H__ 1
#ifdef __cplusplus
extern "C" {
#endif
//=============================================================================
//------------ Definitions ----------------------------------------------------
//=============================================================================
/** @addtogroup TA66XX_OSAL_GENERAL OS abstraction layer (OSAL) general definitions
* @{
*/
// Hardware semaphore defs
#define TA66XX_OSAL_CPPI_HW_SEM 1 /**< CPPI LLD hardware semaphore */
#define TA66XX_OSAL_QMSS_HW_SEM 2 /**< QMSS LLD hardware semaphore */
#define TA66XX_OSAL_SRIO_HW_SEM 3 /**< SRIO LLD hardware semaphore */
#define TA66XX_OSAL_SPI_HW_SEM 4 /**< SPI driver hardware semaphore */
/** Macro to define high-priority QMSS queue for accumulator (depends on DSP event ID and core number) */
#define TA66XX_OSAL_set_qmss_queue_acc(eventid, core) (704 + (eventid - 48) * 8 + core)
// Interrupts and event IDs used by NIMU library (DSP core 0 is assumed to be used)
#define TA66XX_OSAL_ETHERNET_AMC_EVENTID 48 /**< Ethernet AMC port event - used by NIMU library */
#define TA66XX_OSAL_ETHERNET_AMC_INTERRUPT 7 /**< Ethernet AMC port interrupt - used by NIMU library */
/** QMSS queue for AMC Ethernet port accumulator (depends on TA66XX_OSAL_ETHERNET_AMC_EVENTID) */
#define TA66XX_OSAL_ETHERNET_AMC_QMSS_QUEUE_ACC TA66XX_OSAL_set_qmss_queue_acc(TA66XX_OSAL_ETHERNET_AMC_EVENTID, 0)
#define TA66XX_OSAL_ETHERNET_PHY_EVENTID 49 /**< Ethernet PHY port event - used by NIMU library */
#define TA66XX_OSAL_ETHERNET_PHY_INTERRUPT 8 /**< Ethernet PHY port interrupt - used by NIMU library */
/** QMSS queue for PHY Ethernet port accumulator (depends on TA66XX_OSAL_ETHERNET_PHY_EVENTID) */
#define TA66XX_OSAL_ETHERNET_PHY_QMSS_QUEUE_ACC TA66XX_OSAL_set_qmss_queue_acc(TA66XX_OSAL_ETHERNET_PHY_EVENTID, 0)
// Interrupts and event IDs used by SRIO (DSP core 0 is assumed to be used)
#define TA66XX_OSAL_SRIO_MESSAGES_EVENTID 50 /**< SRIO event ID used by messages (Type 9 and Type 11) */
#define TA66XX_OSAL_SRIO_INTERRUPT 9 /**< SRIO interrupt */
/** QMSS queue for SRIO accumulator (depends on TA66XX_OSAL_SRIO_MESSAGES_EVENTID) */
#define TA66XX_OSAL_SRIO_QMSS_QUEUE_ACC TA66XX_OSAL_set_qmss_queue_acc(TA66XX_OSAL_SRIO_MESSAGES_EVENTID, 0)
#define TA66XX_OSAL_SRIO_DIO_EVENTID 20 /**< SRIO event ID used by DirectIO (INTDST(n + 16), n - core number) */
/** @}*/
//=============================================================================
//=============================================================================
//------------ Global variables -----------------------------------------------
//=============================================================================
extern uint32_t qmssMallocCounter;
extern uint32_t qmssFreeCounter;
extern uint32_t cppiMallocCounter;
extern uint32_t cppiFreeCounter;
extern uint32_t srioMallocCounter;
extern uint32_t srioFreeCounter;
extern uint32_t srioDataBufferMallocCounter;
extern uint32_t srioDataBufferFreeCounter;
//=============================================================================
//=============================================================================
//============ T-AMC controllers OSAL functions declarations ==================
//=============================================================================
/** @addtogroup TA66XX_OSAL_FUNCTIONS TORNADO AMC OSAL functions
* @{
*/
//=============================================================================
//============ QMSS LLD OSAL functions ========================================
//=============================================================================
/*------------ Osal_qmssBeginMemAccess() function ------------------------*//**
* @brief Function is used to indicate that a block of memory is about to be
* accessed
*
* If the memory block is cached then this indicates that the application
* would need to ensure that the cache is updated with the data from the actual
* memory
*
* @param[in] ptr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_qmssBeginMemAccess(void *ptr, uint32_t size);
/*------------ Osal_qmssEndMemAccess() function --------------------------*//**
* @brief Function is used to indicate that the block of memory has finished
* being accessed
*
* If the memory block is cached then the application would need to ensure that
* the contents of the cache are updated immediately to the actual memory.
*
* @param[in] ptr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_qmssEndMemAccess(void *ptr, uint32_t size);
/*------------ Osal_qmssMalloc() function --------------------------------*//**
* @brief Function implements the memory allocation library function
*
* This function allocates a memory block of a given size specified by input
* parameter 'num_bytes'.
*
* @param[in] num_bytes - number of bytes to be allocated
*
* @return Allocated block address
*
-----------------------------------------------------------------------------*/
Ptr Osal_qmssMalloc(uint32_t num_bytes);
/*------------ Osal_qmssFree() function ----------------------------------*//**
* @brief Function implements the memory free library function
*
* This function frees up memory allocated using Osal_qmssMalloc()
* function call.
*
* @param[in] dataPtr - pointer to the memory block to be cleaned up
* @param[in] num_bytes - size of the memory block to be cleaned up in bytes
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_qmssFree(Ptr dataPtr, uint32_t num_bytes);
/*------------ Osal_qmssCsEnter() function -------------------------------*//**
* @brief Function is used to enter a critical section
*
* Function protects against access from multiple cores and access from
* multiple threads on single core
*
* @return Handle used to lock critical section
*
-----------------------------------------------------------------------------*/
void *Osal_qmssCsEnter(void);
/*------------ Osal_qmssCsExit() function --------------------------------*//**
* @brief Function is used to exit a critical section protected using
* Osal_qmssCsEnter() API.
*
* @param[in] CsHandle - handle for unlocking critical section
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_qmssCsExit(void *CsHandle);
//=============================================================================
//=============================================================================
//============ CPPI LLD OSAL functions ========================================
//=============================================================================
/*------------ Osal_cppiBeginMemAccess() function ------------------------*//**
* @brief Function is used to indicate that a block of memory is about to be
* accessed
*
* If the memory block is cached then this indicates that the application
* would need to ensure that the cache is updated with the data from the actual
* memory
*
* @param[in] ptr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_cppiBeginMemAccess(void *ptr, uint32_t size);
/*------------ Osal_cppiEndMemAccess() function --------------------------*//**
* @brief Function is used to indicate that the block of memory has finished
* being accessed
*
* If the memory block is cached then the application would need to ensure that
* the contents of the cache are updated immediately to the actual memory.
*
* @param[in] ptr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_cppiEndMemAccess(void *ptr, uint32_t size);
/*------------ Osal_cppiMalloc() function --------------------------------*//**
* @brief Function implements the memory allocation library function
*
* This function allocates a memory block of a given size specified by input
* parameter 'num_bytes'.
*
* @param[in] num_bytes - number of bytes to be allocated
*
* @return Allocated block address
*
-----------------------------------------------------------------------------*/
Ptr Osal_cppiMalloc(uint32_t num_bytes);
/*------------ Osal_cppiFree() function ----------------------------------*//**
* @brief Function implements the memory free library function
*
* This function frees up memory allocated using Osal_cppiMalloc()
* function call.
*
* @param[in] dataPtr - pointer to the memory block to be cleaned up
* @param[in] num_bytes - size of the memory block to be cleaned up in bytes
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_cppiFree(Ptr dataPtr, uint32_t num_bytes);
/*------------ Osal_cppiCsEnter() function -------------------------------*//**
* @brief Function is used to enter a critical section
*
* Function protects against access from multiple cores and access from
* multiple threads on single core
*
* @return Handle used to lock critical section
*
-----------------------------------------------------------------------------*/
void *Osal_cppiCsEnter(void);
/*------------ Osal_cppiCsExit() function --------------------------------*//**
* @brief Function is used to exit a critical section protected using
* Osal_cppiCsEnter() API.
*
* @param[in] CsHandle - handle for unlocking critical section
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_cppiCsExit(void *CsHandle);
//=============================================================================
#ifdef __TA66XX_FUNCTIONS_INCLUDE_SRIO__
//=============================================================================
//============ SRIO LLD OSAL functions ========================================
//=============================================================================
/*------------ Osal_srioBeginMemAccess() function ------------------------*//**
* @brief Function is used to indicate that a block of memory is about to be
* accessed
*
* If the memory block is cached then this indicates that the application
* would need to ensure that the cache is updated with the data from the actual
* memory
*
* @param[in] ptr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioBeginMemAccess(void *ptr, uint32_t size);
/*------------ Osal_srioEndMemAccess() function --------------------------*//**
* @brief Function is used to indicate that the block of memory has finished
* being accessed
*
* If the memory block is cached then the application would need to ensure that
* the contents of the cache are updated immediately to the actual memory.
*
* @param[in] ptr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioEndMemAccess(void *ptr, uint32_t size);
/*------------ Osal_srioBeginDescriptorAccess() function -----------------*//**
* @brief Function is invoked by the SRIO LLD to indicate that a descriptor is
* being accessed.
*
* @param[in] drvHandle - driver instance for which descriptor is being
* accessed
* @param[in] ptr - pointer to the descriptor being accessed
* @param[in] descSize - size of the descriptor (valid only for driver managed
* configuration)
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioBeginDescriptorAccess(Srio_DrvHandle drvHandle, void *ptr, uint32_t descSize);
/*------------ Osal_srioEndDescriptorAccess() function -------------------*//**
* @brief Function is invoked by the SRIO LLD to indicate that a descriptor is
* finished being accessed.
*
* @param[in] drvHandle - driver instance for which descriptor is being
* accessed
* @param[in] ptr - pointer to the descriptor being accessed
* @param[in] descSize - size of the descriptor (valid only for driver managed
* configuration)
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioEndDescriptorAccess(Srio_DrvHandle drvHandle, void *ptr, uint32_t descSize);
/*------------ Osal_srioMalloc() function --------------------------------*//**
* @brief Function implements the memory allocation library function
*
* This function allocates a memory block of a given size specified by input
* parameter 'num_bytes'.
*
* @param[in] num_bytes - number of bytes to be allocated
*
* @return Allocated block address
*
-----------------------------------------------------------------------------*/
Ptr Osal_srioMalloc(uint32_t num_bytes);
/*------------ Osal_srioFree() function ----------------------------------*//**
* @brief Function implements the memory free library function
*
* This function frees up memory allocated using Osal_srioMalloc()
* function call.
*
* @param[in] dataPtr - pointer to the memory block to be cleaned up
* @param[in] num_bytes - size of the memory block to be cleaned up in bytes
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioFree(Ptr dataPtr, uint32_t num_bytes);
/*------------ Osal_dataBufferInitMemory() function ----------------------*//**
* @brief Function is used to allocate a block of memory for all the data
* buffer operations. This function is called by the application.
*
* @param[in] dataBufferSize - size of each data buffer
*
* @return Error code
*
-----------------------------------------------------------------------------*/
int32_t Osal_dataBufferInitMemory(uint32_t dataBufferSize);
/*------------ Osal_srioDataBufferMalloc() function ----------------------*//**
* @brief Function is used to allocate a data buffer of the specified size.
* Data buffers should always be allocated from the global address space.
*
* @param[in] numBytes - number of bytes to be allocated
*
* @return Allocated block address
*
-----------------------------------------------------------------------------*/
void *Osal_srioDataBufferMalloc(uint32_t numBytes);
/*------------ Osal_srioDataBufferFree() function ------------------------*//**
* @brief Function is used to clean up a previously allocated data buffer
* block. All data buffers are in the global address space.
*
* @param[in] ptr - pointer to the memory block to be cleaned up
* @param[in] numBytes - size of the memory block to be cleaned up in bytes
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioDataBufferFree(void *ptr, uint32_t numBytes);
/*------------ Osal_srioLog() function -----------------------------------*//**
* @brief Function is used to log the messages from SRIO LLD on the console.
*
* @param[in] fmt - formatted string
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioLog(String fmt, ... );
/*------------ Osal_srioCreateSem() function -----------------------------*//**
* @brief Function is used to create a critical section.
*
* @return Semaphore handle created
*
-----------------------------------------------------------------------------*/
void *Osal_srioCreateSem(void);
/*------------ Osal_srioDeleteSem() function -----------------------------*//**
* @brief Function is used to delete a critical section.
*
* @param[in] semHandle - semaphore handle to be deleted
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioDeleteSem(void *semHandle);
/*------------ Osal_srioPendSem() function -------------------------------*//**
* @brief Function is used to pend on a semaphore
*
* @param[in] semHandle - semaphore handle on which the API will pend
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioPendSem(void *semHandle);
/*------------ Osal_srioPostSem() function -------------------------------*//**
* @brief Function is used to post a semaphore
*
* @param[in] semHandle - semaphore handle which will be posted
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioPostSem(void *semHandle);
/*------------ Osal_srioEnterMultipleCoreCriticalSection() function ------*//**
* @brief Function is used to protect the driver shared resources across
* multiple cores.
*
* @return Handle used to lock critical section
*
-----------------------------------------------------------------------------*/
void *Osal_srioEnterMultipleCoreCriticalSection(void);
/*------------ Osal_srioExitMultipleCoreCriticalSection() function -------*//**
* @brief Function is called to end the critical section which was protecting
* shared resources from access across multiple cores.
*
* @param[in] critSectHandle - handle for unlocking critical section
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioExitMultipleCoreCriticalSection(void *critSectHandle);
/*------------ Osal_srioEnterSingleCoreCriticalSection() function --------*//**
* @brief Function is used to provide critical section to prevent access of
* shared resources from single core and multiple threads.
*
* @param[in] drvHandle - driver handle which needs critical section to
* protect its resources
*
* @return Handle used to lock critical section
*
-----------------------------------------------------------------------------*/
void *Osal_srioEnterSingleCoreCriticalSection(Srio_DrvHandle drvHandle);
/*------------ Osal_srioExitSingleCoreCriticalSection() function ---------*//**
* @brief Function is called to end the critical section access of shared
* resources from single cores.
*
* @param[in] drvHandle - driver handle which needs critical section to
* protect its resources
* @param[in] critSectHandle - critical handle retreived by
* Osal_srioEnterSingleCoreCriticalSection() function call
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_srioExitSingleCoreCriticalSection(Srio_DrvHandle drvHandle, void *critSectHandle);
//=============================================================================
#endif /* __TA66XX_FUNCTIONS_INCLUDE_SRIO__ */
//=============================================================================
//============ NIMU LLD OSAL functions ========================================
//=============================================================================
/*------------ Osal_nimuMalloc() function --------------------------------*//**
* @brief Function implements the memory allocate function for the NIMU
* library.
*
* This function allocates a memory block of a given size specified by input
* parameter 'num_bytes'.
*
* @param[in] num_bytes - number of bytes to be allocated
* @param[in] alignment - alignment of allocated memory block in bytes
*
* @return Allocated block address
*
-----------------------------------------------------------------------------*/
Ptr Osal_nimuMalloc(uint32_t num_bytes, uint32_t alignment);
/*------------ Osal_nimuFree() function ----------------------------------*//**
* @brief Function implements the memory free function for the NIMU library.
*
* This function frees up memory allocated using Osal_nimuMalloc()
* function call.
*
* @param[in] dataPtr - pointer to the memory block to be cleaned up
* @param[in] num_bytes - size of the memory block to be cleaned up in bytes
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_nimuFree(Ptr dataPtr, uint32_t num_bytes);
//=============================================================================
//=============================================================================
//============ PASS LLD OSAL functions ========================================
//=============================================================================
/*------------ Osal_paBeginMemAccess() function --------------------------*//**
* @brief Function is used to indicate that a block of memory is about to be
* accessed
*
* If the memory block is cached then this indicates that the application
* would need to ensure that the cache is updated with the data from the actual
* memory
*
* @param[in] addr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_paBeginMemAccess(Ptr addr, uint32_t size);
/*------------ Osal_paEndMemAccess() function ----------------------------*//**
* @brief Function is used to indicate that the block of memory has finished
* being accessed
*
* If the memory block is cached then the application would need to ensure that
* the contents of the cache are updated immediately to the actual memory.
*
* @param[in] addr - address of memory block
* @param[in] size - size of memory block
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_paEndMemAccess(Ptr addr, uint32_t size);
/*------------ Osal_paMtCsEnter() function -------------------------------*//**
* @brief Function is used to enter a critical section
*
* Function protects against access from multiple cores and access from
* multiple threads on single core
*
* @param[out] key - pointer to a variable to receive a handle for unlocking
* critical section
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_paMtCsEnter(uint32_t *key);
/*------------ Osal_paMtCsExit() function --------------------------------*//**
* @brief Function is used to exit a critical section protected using
* Osal_paMtCsEnter() API.
*
* @param[in] key - handle for unlocking critical section
*
* @return None
*
-----------------------------------------------------------------------------*/
void Osal_paMtCsExit(uint32_t key);
/** @}*/
//=============================================================================
#ifdef __cplusplus
}
#endif
//=============================================================================
#endif /* __TA66XX_OSAL_H__ */
|