AM263x MCU+ SDK  10.00.00
enet_osal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
39 #ifndef ENET_OSAL_H_
40 #define ENET_OSAL_H_
41 
42 /* ========================================================================== */
43 /* Include Files */
44 /* ========================================================================== */
45 
46 #include <stdint.h>
47 #include <stdbool.h>
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /* ========================================================================== */
54 /* Macros */
55 /* ========================================================================== */
56 
57 /* None */
58 
59 /* ========================================================================== */
60 /* Structures and Enums */
61 /* ========================================================================== */
68 typedef enum
69 {
88 
94 typedef uintptr_t (*EnetOsal_DisableAllIntr)(void);
95 
101 typedef void (*EnetOsal_RestoreAllIntr)(uintptr_t cookie);
102 
108 typedef void (*EnetOsal_RestoreIntr)(uint32_t coreIntrNum);
109 
115 typedef void (*EnetOsal_DisableIntr)(uint32_t coreIntrNum);
116 
122 typedef void (*EnetOsal_Isr)(uintptr_t arg);
123 
136 typedef void *(*EnetOsal_RegisterIntr)(EnetOsal_Isr isrFxn,
137  uint32_t coreIntrNum,
138  uint32_t intrPriority,
139  uint32_t triggerType,
140  void *arg);
141 
147 typedef void (*EnetOsal_UnregisterIntr)(void *hHwi);
148 
155 typedef void *(*EnetOsal_CreateMutex)(void);
156 
162 typedef void (*EnetOsal_DeleteMutex)(void *hMutex);
163 
169 typedef void (*EnetOsal_LockMutex)(void *hMutex);
170 
176 typedef void (*EnetOsal_UnlockMutex)(void *hMutex);
177 
183 typedef bool (*EnetOsal_IsCacheCoherent)(void);
184 
191 typedef void (*EnetOsal_CacheInv)(const void *addr,
192  int32_t size);
193 
200 typedef void (*EnetOsal_CacheWb)(const void *addr,
201  int32_t size);
202 
209 typedef void (*EnetOsal_CacheWbInv)(const void *addr,
210  int32_t size);
211 
217 typedef uint32_t (*EnetOsal_TimerRead)(void);
218 
222 typedef struct EnetOsal_Cfg_s
223 {
226 
229 
232 
235 
238 
241 
244 
247 
250 
253 
256 
259 
262 
265 
268 } EnetOsal_Cfg;
269 
270 /* ========================================================================== */
271 /* Global Variables Declarations */
272 /* ========================================================================== */
273 
274 /* None */
275 
276 /* ========================================================================== */
277 /* Function Declarations */
278 /* ========================================================================== */
279 
288 void EnetOsal_init(const EnetOsal_Cfg *cfg);
289 
296 void EnetOsal_deinit(void);
297 
303 uintptr_t EnetOsal_disableAllIntr(void);
304 
310 void EnetOsal_restoreAllIntr(uintptr_t cookie);
311 
324  uint32_t coreIntrNum,
325  uint32_t intrPriority,
326  uint32_t intrTrigType,
327  void *arg);
328 
334 void EnetOsal_unregisterIntr(void *hHwi);
335 
341 void EnetOsal_enableIntr(uint32_t coreIntrNum);
342 
348 void EnetOsal_disableIntr(uint32_t coreIntrNum);
349 
356 
362 void EnetOsal_deleteMutex(void *hMutex);
363 
369 void EnetOsal_lockMutex(void *hMutex);
370 
376 void EnetOsal_unlockMutex(void *hMutex);
377 
386 void EnetOsal_cacheInv(const void *addr,
387  int32_t size);
388 
397 void EnetOsal_cacheWb(const void *addr,
398  int32_t size);
399 
408 void EnetOsal_cacheWbInv(const void *addr,
409  int32_t size);
410 
419 uint32_t EnetOsal_timerGetDiff(uint32_t startTime);
420 
426 uint32_t EnetOsal_timerRead(void);
427 
428 /* ========================================================================== */
429 /* Deprecated Function Declarations */
430 /* ========================================================================== */
431 
432 /* None */
433 
434 #ifdef __cplusplus
435 }
436 #endif
437 
438 #endif /* ENET_OSAL_H_ */
EnetOsal_Cfg::timerRead
EnetOsal_TimerRead timerRead
Definition: enet_osal.h:267
EnetOsal_CacheWb
void(* EnetOsal_CacheWb)(const void *addr, int32_t size)
Enet OSAL cache writeback function prototype.
Definition: enet_osal.h:200
EnetOsal_Cfg::restoreIntr
EnetOsal_RestoreIntr restoreIntr
Definition: enet_osal.h:234
EnetOsal_Cfg::restoreAllIntr
EnetOsal_RestoreAllIntr restoreAllIntr
Definition: enet_osal.h:228
EnetOsal_DisableAllIntr
uintptr_t(* EnetOsal_DisableAllIntr)(void)
Enet OSAL intr disable function prototype.
Definition: enet_osal.h:94
EnetOsal_RestoreAllIntr
void(* EnetOsal_RestoreAllIntr)(uintptr_t cookie)
Enet OSAL intr restore function prototype.
Definition: enet_osal.h:101
EnetOsal_timerGetDiff
uint32_t EnetOsal_timerGetDiff(uint32_t startTime)
Get the time difference with respect to timestamp.
EnetOsal_timerRead
uint32_t EnetOsal_timerRead(void)
Read current timer value.
ENETOSAL_ARM_GIC_TRIG_TYPE_HIGH_LEVEL
@ ENETOSAL_ARM_GIC_TRIG_TYPE_HIGH_LEVEL
Definition: enet_osal.h:76
EnetOsal_RegisterIntr
void *(* EnetOsal_RegisterIntr)(EnetOsal_Isr isrFxn, uint32_t coreIntrNum, uint32_t intrPriority, uint32_t triggerType, void *arg)
Enet OSAL ISR register function prototype.
Definition: enet_osal.h:136
EnetOsal_Cfg::unlockMutex
EnetOsal_UnlockMutex unlockMutex
Definition: enet_osal.h:252
EnetOsal_Cfg::disableAllIntr
EnetOsal_DisableAllIntr disableAllIntr
Definition: enet_osal.h:225
EnetOsal_RestoreIntr
void(* EnetOsal_RestoreIntr)(uint32_t coreIntrNum)
Enet OSAL intr restore function prototype.
Definition: enet_osal.h:108
EnetOsal_LockMutex
void(* EnetOsal_LockMutex)(void *hMutex)
Enet OSAL mutex lock function prototype.
Definition: enet_osal.h:169
EnetOsal_cacheWbInv
void EnetOsal_cacheWbInv(const void *addr, int32_t size)
Write-back and invalidate cache.
EnetOsal_disableIntr
void EnetOsal_disableIntr(uint32_t coreIntrNum)
Disable interrupt.
EnetOsal_cacheWb
void EnetOsal_cacheWb(const void *addr, int32_t size)
Write-back cache.
EnetOsal_Cfg::cacheWbInv
EnetOsal_CacheWbInv cacheWbInv
Definition: enet_osal.h:264
ENETOSAL_ARM_GIC_TRIG_TYPE_EDGE
@ ENETOSAL_ARM_GIC_TRIG_TYPE_EDGE
Definition: enet_osal.h:73
EnetOsal_CacheWbInv
void(* EnetOsal_CacheWbInv)(const void *addr, int32_t size)
Enet OSAL cache writeback invalidate function prototype.
Definition: enet_osal.h:209
ENETOSAL_ARM_GIC_TRIG_TYPE_FALLING_EDGE
@ ENETOSAL_ARM_GIC_TRIG_TYPE_FALLING_EDGE
Definition: enet_osal.h:85
EnetOsal_TimerRead
uint32_t(* EnetOsal_TimerRead)(void)
Enet OSAL timer read function prototype.
Definition: enet_osal.h:217
EnetOsal_Cfg::deleteMutex
EnetOsal_DeleteMutex deleteMutex
Definition: enet_osal.h:246
EnetOsal_Cfg
Enet OSAL configuration paramters.
Definition: enet_osal.h:223
EnetOsal_registerIntr
void * EnetOsal_registerIntr(EnetOsal_Isr isrFxn, uint32_t coreIntrNum, uint32_t intrPriority, uint32_t intrTrigType, void *arg)
Register an ISR for an interrupt.
EnetOsal_deleteMutex
void EnetOsal_deleteMutex(void *hMutex)
Delete a mutex.
EnetOsal_unlockMutex
void EnetOsal_unlockMutex(void *hMutex)
Unlock a mutex.
EnetOsal_Cfg::createMutex
EnetOsal_CreateMutex createMutex
Definition: enet_osal.h:243
EnetOsal_cacheInv
void EnetOsal_cacheInv(const void *addr, int32_t size)
Invalidate cache.
EnetOsal_init
void EnetOsal_init(const EnetOsal_Cfg *cfg)
Initialize OSAL with provided configuration.
EnetOsal_Cfg::unregisterIntr
EnetOsal_UnregisterIntr unregisterIntr
Definition: enet_osal.h:240
EnetOsal_deinit
void EnetOsal_deinit(void)
Deinitialize OSAL.
ENETOSAL_ARM_GIC_TRIG_TYPE_RISING_EDGE
@ ENETOSAL_ARM_GIC_TRIG_TYPE_RISING_EDGE
Definition: enet_osal.h:82
EnetOsal_IsCacheCoherent
bool(* EnetOsal_IsCacheCoherent)(void)
Enet OSAL cache coherency check function prototype.
Definition: enet_osal.h:183
EnetOsal_Cfg::disableIntr
EnetOsal_DisableIntr disableIntr
Definition: enet_osal.h:231
EnetOsal_CreateMutex
void *(* EnetOsal_CreateMutex)(void)
Enet OSAL mutex create function prototype to protect critical section.
Definition: enet_osal.h:155
ENETOSAL_ARM_GIC_TRIG_TYPE_LEVEL
@ ENETOSAL_ARM_GIC_TRIG_TYPE_LEVEL
Definition: enet_osal.h:70
EnetOsal_UnregisterIntr
void(* EnetOsal_UnregisterIntr)(void *hHwi)
Enet OSAL ISR unregister function prototype.
Definition: enet_osal.h:147
EnetOSAL_armGicTrigType_t
EnetOSAL_armGicTrigType_t
Enumerates the types different trigger types. Please refer to Section 4.3.13 Interrupt Configuration ...
Definition: enet_osal.h:69
EnetOsal_UnlockMutex
void(* EnetOsal_UnlockMutex)(void *hMutex)
Enet OSAL mutex lock function prototype.
Definition: enet_osal.h:176
EnetOsal_Cfg::lockMutex
EnetOsal_LockMutex lockMutex
Definition: enet_osal.h:249
EnetOsal_Cfg::cacheInv
EnetOsal_CacheInv cacheInv
Definition: enet_osal.h:258
EnetOsal_disableAllIntr
uintptr_t EnetOsal_disableAllIntr(void)
Enet OSAL intr disable function prototype.
EnetOsal_lockMutex
void EnetOsal_lockMutex(void *hMutex)
Lock a mutex.
EnetOsal_enableIntr
void EnetOsal_enableIntr(uint32_t coreIntrNum)
Enable interrupt.
EnetOsal_unregisterIntr
void EnetOsal_unregisterIntr(void *hHwi)
Unregister an interrupt.
EnetOsal_Isr
void(* EnetOsal_Isr)(uintptr_t arg)
Enet OSAL ISR callback function prototype.
Definition: enet_osal.h:122
EnetOsal_Cfg::isCacheCoherent
EnetOsal_IsCacheCoherent isCacheCoherent
Definition: enet_osal.h:255
EnetOsal_DeleteMutex
void(* EnetOsal_DeleteMutex)(void *hMutex)
Enet OSAL mutex delete function prototype.
Definition: enet_osal.h:162
EnetOsal_restoreAllIntr
void EnetOsal_restoreAllIntr(uintptr_t cookie)
Enet OSAL intr restore function prototype.
EnetOsal_CacheInv
void(* EnetOsal_CacheInv)(const void *addr, int32_t size)
Enet OSAL cache invalidate function prototype.
Definition: enet_osal.h:191
EnetOsal_Cfg::cacheWb
EnetOsal_CacheWb cacheWb
Definition: enet_osal.h:261
EnetOsal_Cfg::registerIntr
EnetOsal_RegisterIntr registerIntr
Definition: enet_osal.h:237
EnetOsal_createMutex
void * EnetOsal_createMutex(void)
Create a mutex.
EnetOsal_DisableIntr
void(* EnetOsal_DisableIntr)(uint32_t coreIntrNum)
Enet OSAL intr disable function prototype.
Definition: enet_osal.h:115
ENETOSAL_ARM_GIC_TRIG_TYPE_LOW_LEVEL
@ ENETOSAL_ARM_GIC_TRIG_TYPE_LOW_LEVEL
Definition: enet_osal.h:79