Data Structures | Macros | Functions
cpsw_utils.h File Reference

CPSW utility API to make TR, get TR descriptor memory requirement. More...

#include <stdarg.h>
#include <ti/drv/cpsw/include/cpsw_cfg.h>
#include <ti/drv/cpsw/include/cpsw_dma_pktutils.h>
#include <ti/drv/cpsw/soc/cpsw_soc.h>

Data Structures

struct  CpswUtils_Prms
 CPSW utils parameters. More...
 

Macros

#define container_of(ptr, type, member)
 Macro to get container structure from one of its members' addresses. More...
 
#define CPSW_UTILS_ARRAYSIZE(x)   (sizeof(x) / sizeof(x[0]))
 Macro to get the size of an array.
 
#define CPSW_UTILS_GETARRAYINDEX(member, array)   (member - &array[0])
 Get the index of the given element within an array.
 
#define CPSW_UTILS_ARRAYISMEMBER(member, array)
 Macro to determine if a member is part of an array. More...
 
#define CPSW_UTILS_COMPILETIME_ASSERT(condition)
 Compile-time assertion. More...
 
#define CPSW_UTILS_DIV_ROUNDUP(val, div)   (((val) + (div) - 1) / (div))
 Macro to perform round-up division.
 
#define CPSW_UTILS_ROUNDUP(val, div)   (CPSW_UTILS_DIV_ROUNDUP((val), (div)) * (div))
 Macro to round up a value.
 
#define CPSW_UTILS_ROUNDDOWN(val, div)   (((val) / (div)) * (div))
 Macro round down a value.
 
#define CPSW_UTILS_MK_ONES(c_ebit, c_sbit)   (((1U << (((c_ebit) - (c_sbit)) + 1U)) - 1U) << (c_sbit))
 Generates a pattern of ones between end bit and start bit M_ONES(7,4) will give 0x000000F0.
 
#define CPSW_UTILS_MK_MASK(c_ebit, c_sbit)   (~(CPSW_UTILS_MK_ONES((c_ebit), (c_sbit))))
 Generates a pattern of zeros between end bit and start bit M_MASK(7,4) will give 0xFFFFFF0F.
 
#define CPSW_UTILS_VAL_BOUND(val, c_ebit, c_sbit)   ((CPSW_UTILS_MK_ONES((c_ebit), (c_sbit)) >> (c_sbit)) & (val))
 Bounds the value before writing to register M_VAL_BOUND(0x1F, 7, 4) will remove the extra bit resulting in 0xF.
 
#define CPSW_UTILS_CACHELINE_SIZE   (UDMA_CACHELINE_ALIGNMENT)
 CPSW Ring Acc memory alignment.
 
#define CPSW_UTILS_ALIGN(x, y)   (((x + (y - 1)) / y) * y)
 Align a value by performing a round-up operation.
 
#define CPSW_UTILS_IS_ALIGNED(addr, alignSize)   (((uintptr_t)addr & (alignSize - 1U)) == 0U)
 Macro to determine if an address is aligned to a given size.
 
#define CPSW_UTILS_ARRAY_COPY(dst, src)
 Macro to copy arrays. They must be of the same size. More...
 

Functions

void CpswUtils_printf (const char *format,...)
 Prints to shared memory and CCS console. More...
 
void CpswUtils_trace (const char *format, va_list vaArgPtr)
 Logs trace info. More...
 
void CpswUtils_init (CpswUtils_Prms *pUtilsPrms)
 Initialize utils module. More...
 
void CpswUtils_deInit (void)
 De-initialize utils module.
 
uint32_t CpswUtils_min (uint32_t num1, uint32_t num2)
 Returns minimum of two numbers. More...
 
uint32_t CpswUtils_max (uint32_t num1, uint32_t num2)
 Returns minimum of two numbers. More...
 
void CpswUtils_delay (uint32_t delayVal)
 Busy loop for a given amount of time. More...
 
void * CpswUtils_registerIntr (CpswOsal_IsrFxn isrFxn, uint32_t coreIntrNum, uint32_t intrPriority, void *arg)
 Register an ISR for an interrupt. More...
 
void CpswUtils_unRegisterIntr (void *hwiHandle)
 Unregister an interrupt. More...
 
void CpswUtils_enableIntr (uint32_t coreIntrNum)
 Enable interrupt. More...
 
void CpswUtils_disableIntr (uint32_t coreIntrNum)
 Disable interrupt. More...
 
void * CpswUtils_mutexCreate (void)
 Create a mutex. More...
 
void CpswUtils_mutexDelete (void *mutexHandle)
 Delete a mutex. More...
 
void CpswUtils_mutexLock (void *mutexHandle)
 Lock a mutex. More...
 
void CpswUtils_mutexUnlock (void *mutexHandle)
 Unlock a mutex. More...
 
uint64_t CpswUtils_virtToPhyFxn (const void *virtAddr, void *appData)
 Convert a virtual address to physical address. More...
 
void * CpswUtils_phyToVirtFxn (uint64_t phyAddr, void *appData)
 Convert a physical address to virtual address. More...
 
int32_t CpswUtils_timerInit (void)
 Initialize a timer. More...
 
int32_t CpswUtils_timerDeInit (void)
 De-initialize a timer. More...
 
uint32_t CpswUtils_timerRead (void)
 Read timer value. More...
 
uint32_t CpswOsal_timerGetDiff (uint32_t startTime)
 Get time different between a starting and current time. More...
 
uint32_t CpswUtils_getIpFeatureBitMap (Cpsw_Type cpswType)
 Returns CPSW IP featureBitmap. More...
 
const CpswSoc_CpswIpInfo * CpswUtils_getIpInfo (Cpsw_Type cpswType)
 Get CPSW IP information. More...
 
uint32_t CpswUtils_getIpErrataBitMap (Cpsw_Type cpswType)
 Returns CPSW IP errataBitmap. More...
 

Detailed Description

CPSW utility API to make TR, get TR descriptor memory requirement.

Macro Definition Documentation

#define container_of (   ptr,
  type,
  member 
)
Value:
({ \
const typeof(((type *)0)->member) * __mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); \
})

Macro to get container structure from one of its members' addresses.

#define CPSW_UTILS_ARRAY_COPY (   dst,
  src 
)
Value:
do \
{ \
/* dst argument of macro should be array and not pointer.*/ \
CPSW_UTILS_COMPILETIME_ASSERT(sizeof(dst) != sizeof(uintptr_t)); \
memcpy(dst, src, (CPSW_UTILS_ARRAYSIZE(dst) * sizeof(dst[0]))); \
} while (0)
#define CPSW_UTILS_ARRAYSIZE(x)
Macro to get the size of an array.
Definition: cpsw_utils.h:67
#define CPSW_UTILS_COMPILETIME_ASSERT(condition)
Compile-time assertion.
Definition: cpsw_utils.h:79

Macro to copy arrays. They must be of the same size.

#define CPSW_UTILS_ARRAYISMEMBER (   member,
  array 
)
Value:
(((((uint32)member - (uint32) & array[0]) % sizeof(array[0])) == 0) \
&& (member >= &array[0]) \
&& (CPSW_UTILS_GETARRAYINDEX(member, array) < CPSW_UTILS_ARRAYSIZE(array)))
#define CPSW_UTILS_ARRAYSIZE(x)
Macro to get the size of an array.
Definition: cpsw_utils.h:67
#define CPSW_UTILS_GETARRAYINDEX(member, array)
Get the index of the given element within an array.
Definition: cpsw_utils.h:70

Macro to determine if a member is part of an array.

#define CPSW_UTILS_COMPILETIME_ASSERT (   condition)
Value:
do { \
typedef char ErrorCheck[((condition) == TRUE) ? 1 : -1]; \
ErrorCheck a = {0}; \
a[0U] = a[0U]; \
} while (0)

Compile-time assertion.

Function Documentation

uint32_t CpswOsal_timerGetDiff ( uint32_t  startTime)

Get time different between a starting and current time.

Returns
Time difference in timer's units
void CpswUtils_delay ( uint32_t  delayVal)

Busy loop for a given amount of time.

Parameters
delayVal[IN] Delay time
void CpswUtils_disableIntr ( uint32_t  coreIntrNum)

Disable interrupt.

Parameters
coreIntrNum[IN] Interrupt number
void CpswUtils_enableIntr ( uint32_t  coreIntrNum)

Enable interrupt.

Parameters
coreIntrNum[IN] Interrupt number
uint32_t CpswUtils_getIpErrataBitMap ( Cpsw_Type  cpswType)

Returns CPSW IP errataBitmap.

Returns CPSW IP errataBitmap info from SOC for the given CPSW type

Parameters
cpswType[IN] CPSW instance type. Refer to Cpsw_Type
Returns
errataBitmap [OUT] IP errata bitmap for given CPSW type
uint32_t CpswUtils_getIpFeatureBitMap ( Cpsw_Type  cpswType)

Returns CPSW IP featureBitmap.

Returns CPSW IP featureBitmap info from SOC for the given CPSW type

Parameters
cpswType[IN] CPSW instance type. Refer to Cpsw_Type
Returns
ipFeatureMap [OUT] IP feature bitmap for given CPSW type
const CpswSoc_CpswIpInfo* CpswUtils_getIpInfo ( Cpsw_Type  cpswType)

Get CPSW IP information.

Returns CPSW IP information structure for the given CPSW type in the SoC.

Parameters
cpswType[IN] CPSW instance type. Refer to Cpsw_Type
Returns
ipInfoPtr [OUT] Pointer to #CpswSoc_CpswIpInfo structure
void CpswUtils_init ( CpswUtils_Prms pUtilsPrms)

Initialize utils module.

Utils module initialization function. Should be only called from the CPSW top level module.

Parameters
pUtilsPrms[IN] Pointer to the initialization parameters
uint32_t CpswUtils_max ( uint32_t  num1,
uint32_t  num2 
)

Returns minimum of two numbers.

Parameters
num1[IN] First number
num2[IN] Second number
Returns
Maximum number
uint32_t CpswUtils_min ( uint32_t  num1,
uint32_t  num2 
)

Returns minimum of two numbers.

Parameters
num1[IN] First number
num2[IN] Second number
Returns
Minimum number
void* CpswUtils_mutexCreate ( void  )

Create a mutex.

Returns
Mutex handle pointer
void CpswUtils_mutexDelete ( void *  mutexHandle)

Delete a mutex.

Parameters
mutexHandle[IN] Mutex handle pointer
void CpswUtils_mutexLock ( void *  mutexHandle)

Lock a mutex.

Parameters
mutexHandle[IN] Mutex handle pointer
void CpswUtils_mutexUnlock ( void *  mutexHandle)

Unlock a mutex.

Parameters
mutexHandle[IN] Mutex handle pointer
void* CpswUtils_phyToVirtFxn ( uint64_t  phyAddr,
void *  appData 
)

Convert a physical address to virtual address.

Parameters
phyAddr[IN] Physical address
appData[IN] Auxiliary data
Returns
Virtual address
void CpswUtils_printf ( const char *  format,
  ... 
)

Prints to shared memory and CCS console.

This function prints the provided formatted string to shared memory and CCS console.

Parameters
format[IN] Formatted string followed by variable arguments
void* CpswUtils_registerIntr ( CpswOsal_IsrFxn  isrFxn,
uint32_t  coreIntrNum,
uint32_t  intrPriority,
void *  arg 
)

Register an ISR for an interrupt.

Parameters
isrFxn[IN] Interrupt service routine
coreIntrNum[IN] Interrupt number
intrPriority[IN] Interrupt priority
arg[IN] Argument to ISR function
Returns
Interrupt handle pointer
int32_t CpswUtils_timerDeInit ( void  )

De-initialize a timer.

Returns
Cpsw_ErrorCodes
int32_t CpswUtils_timerInit ( void  )

Initialize a timer.

Returns
Cpsw_ErrorCodes
uint32_t CpswUtils_timerRead ( void  )

Read timer value.

Returns
Timer's current value
void CpswUtils_trace ( const char *  format,
va_list  vaArgPtr 
)

Logs trace info.

This function logs the provided formatted string to the provided trace callback function.

Parameters
format[IN] Formatted string
vaArgPtr[IN] Variadic argument list
void CpswUtils_unRegisterIntr ( void *  hwiHandle)

Unregister an interrupt.

Parameters
hwiHandle[IN] Interrupt handle pointer
uint64_t CpswUtils_virtToPhyFxn ( const void *  virtAddr,
void *  appData 
)

Convert a virtual address to physical address.

Parameters
virtAddr[IN] Virtual address
appData[IN] Auxiliary data
Returns
Physical address

Copyright 2020, Texas Instruments Incorporated