TIOVX User Guide

Detailed Description

APIs for memory mapping on host and target.

Data Structures

struct  tivx_shared_mem_ptr_t
 Structure describing a shared memory pointer. More...
 
struct  tivx_mem_stats
 Structure describing a memory stats pointer. More...
 

Enumerations

enum  tivx_mem_heap_region_e {
  TIVX_MEM_EXTERNAL,
  TIVX_MEM_INTERNAL_L3,
  TIVX_MEM_INTERNAL_L2,
  TIVX_MEM_INTERNAL_L1,
  TIVX_MEM_EXTERNAL_SCRATCH,
  TIVX_MEM_EXTERNAL_PERSISTENT_NON_CACHEABLE,
  TIVX_MEM_EXTERNAL_SCRATCH_NON_CACHEABLE,
  TIVX_MEM_EXTERNAL_CACHEABLE_WT
}
 Enum that list all possible memory regions from which allocations are possible. More...
 
enum  tivx_memory_type_e { TIVX_MEMORY_TYPE_DMA = VX_ENUM_BASE(VX_ID_TI, VX_ENUM_MEMORY_TYPE) + 0x0 }
 An enumeration of TI extension memory import types. More...
 

Functions

vx_status tivxMemBufferAlloc (tivx_shared_mem_ptr_t *mem_ptr, uint32_t size, vx_enum mem_heap_region)
 Allocates memory of given size in the shared memory carveout region used by OpenVX data buffers. More...
 
vx_status tivxMemBufferFree (tivx_shared_mem_ptr_t *mem_ptr, uint32_t size)
 Free buffer from shared memory. More...
 
vx_status tivxMemBufferMap (void *host_ptr, uint32_t size, vx_enum mem_type, vx_enum maptype)
 Map an allocated buffer address. More...
 
vx_status tivxMemBufferUnmap (void *host_ptr, uint32_t size, vx_enum mem_type, vx_enum maptype)
 UnMap a buffer address. More...
 
uint64_t tivxMemHost2SharedPtr (uint64_t host_ptr, vx_enum mem_heap_region)
 Convert Host pointer to shared pointer. More...
 
void * tivxMemShared2TargetPtr (const tivx_shared_mem_ptr_t *shared_ptr)
 Convert shared pointer to target pointer. More...
 
uint64_t tivxMemShared2PhysPtr (uint64_t shared_ptr, vx_enum mem_heap_region)
 Convert shared pointer to system physical memory location This is mainly used for configuring physical address to HW. More...
 
void * tivxMemAlloc (vx_uint32 size, vx_enum mem_heap_region)
 Allocates memory of given size in the shared memory carveout region used by OpenVX data buffers. More...
 
vx_status tivxMemFree (void *ptr, vx_uint32 size, vx_enum mem_heap_region)
 Frees already allocated memory. More...
 
void tivxMemStats (tivx_mem_stats *stats, vx_enum mem_type)
 Get memory segment information. More...
 
int32_t tivxMemResetScratchHeap (vx_enum mem_heap_region)
 Reset scratch memory. More...
 
vx_status tivxMemTranslateVirtAddr (const void *virtAddr, uint64_t *fd, void **phyAddr)
 Translates a given virtual address to a file descriptor and a physical address. The following conditions regarding 'virt_addr' must be TRUE: More...
 
vx_bool tivxMemCompareFd (uint64_t dmaBufFd1, uint64_t dmaBufFd2, uint32_t size1, uint32_t size2)
 Compares two given FD's and returns a boolean based on whether they are the same or not. More...
 
vx_status tivxMemTranslateFd (uint64_t dmaBufFd, uint32_t size, void **virtAddr, void **phyAddr)
 Translates a given file descriptor to a virtual and physical address. The following conditions regarding 'fd' must be TRUE: More...
 
void tivxEnableL1DandL2CacheWb (void)
 For J784S4, the C7X cache coherency model is different than other Jacinto SoC's. While other SoC's C7X cache was coherent, the J784S4 C7X requires cache operations to be performed on the buffers when using them within the OpenVX shared region. This API allows the entire L1D and L2 cache to be written back for J784S4.
 

Enumeration Type Documentation

◆ tivx_mem_heap_region_e

Enum that list all possible memory regions from which allocations are possible.

Enumerator
TIVX_MEM_EXTERNAL 

External memory.

Typically large in size and can be used by kernels. as well as applications.

TIVX_MEM_INTERNAL_L3 

Internal memory at L3 level.

Typically visible to all CPUs, limited in size. Typically used by kernels and in very rare cases by applications.

TIVX_MEM_INTERNAL_L2 

Internal memory at L2 level.

Typically local to CPU, very limited in size. Typically used by kernels.

This is used as scratch memory by kernels, i.e memory contents are not preserved across kernel function calls

tivxMemAlloc() API will linearly allocate from this memory segment. After each allocation an internal offset will be incremented.

tivxMemFree() resets this offset to zero. i.e tivxMemAlloc() and tivxMemFree() are not heap like memory alloc and free functions.

NOT to be used by applications.

TIVX_MEM_INTERNAL_L1 

Internal memory at L1 level.

Typically local to CPU, very limited in size. Typically used by kernels.

This is used as scratch memory by kernels, i.e memory contents are not preserved across kernel function calls

tivxMemAlloc() API will linearly allocate from this memory segment. After each allocation an internal offset will be incremented.

tivxMemFree() resets this offset to zero. i.e tivxMemAlloc() and tivxMemFree() are not heap like memory alloc and free functions.

NOT to be used by applications.

TIVX_MEM_EXTERNAL_SCRATCH 

External scratch memory.

Typically large in size and can be used by kernels. as well as applications. Must be reset and allocated each time it is used.

TIVX_MEM_EXTERNAL_PERSISTENT_NON_CACHEABLE 

External persistent non cacheable memory.

Typically large in size and can be used by kernels. as well as applications. Must be reset and allocated each time it is used.

TIVX_MEM_EXTERNAL_SCRATCH_NON_CACHEABLE 

External scratch non cacheable memory.

Typically large in size and can be used by kernels. as well as applications. Must be reset and allocated each time it is used.

TIVX_MEM_EXTERNAL_CACHEABLE_WT 

External cacheable memory with write through policy.

Typically used when only one core needs to RW the memory, and a DMA needs to read what was written. In this case, time is saved by avoiding a cache write back operation before triggering a DMA read of the memory.

Definition at line 86 of file tivx_mem.h.

◆ tivx_memory_type_e

An enumeration of TI extension memory import types.

Enumerator
TIVX_MEMORY_TYPE_DMA 

Memory type when a DMA will access the memory rather than the HOST.

Definition at line 178 of file tivx_mem.h.

Function Documentation

◆ tivxMemBufferAlloc()

vx_status tivxMemBufferAlloc ( tivx_shared_mem_ptr_t mem_ptr,
uint32_t  size,
vx_enum  mem_heap_region 
)

Allocates memory of given size in the shared memory carveout region used by OpenVX data buffers.

Parameters
[out]mem_ptrAllocated memory pointer
[in]sizeSize of memory to allocate in bytes
[in]mem_heap_regionMemory region to which this allocation belongs, see tivx_mem_heap_region_e

◆ tivxMemBufferFree()

vx_status tivxMemBufferFree ( tivx_shared_mem_ptr_t mem_ptr,
uint32_t  size 
)

Free buffer from shared memory.

Parameters
[in,out]mem_ptrAllocated memory pointer
[in]sizeSize of memory allocated in bytes

◆ tivxMemBufferMap()

vx_status tivxMemBufferMap ( void *  host_ptr,
uint32_t  size,
vx_enum  mem_type,
vx_enum  maptype 
)

Map an allocated buffer address.

This is to ensure the memory pointed by the buffer is accessible to the caller and brought to a coherent state wrt caller by performing a cache invalidate when necessary.

Parameters
[in]host_ptrBuffer memory to map
[in]sizeSize of memory to map in units of bytes
[in]mem_typeMemory type to which this pointer belongs, see vx_memory_type_e and tivx_memory_type_e
[in]maptypeMapping type as defined by vx_accessor_e

◆ tivxMemBufferUnmap()

vx_status tivxMemBufferUnmap ( void *  host_ptr,
uint32_t  size,
vx_enum  mem_type,
vx_enum  maptype 
)

UnMap a buffer address.

This is to ensure the memory pointed by the buffer pointer is made coherent with other possible readers of this buffer

Performs a cache writeback of host_ptr when maptype is VX_WRITE_ONLY or VX_READ_AND_WRITE and the CPU is not cache coherent.

Parameters
[in]host_ptrBuffer memory to unmap
[in]sizeSize of memory to unmap in units of bytes
[in]mem_typeMemory type to which this pointer belongs, see vx_memory_type_e and tivx_memory_type_e
[in]maptypeMapping type as defined by vx_accessor_e

◆ tivxMemHost2SharedPtr()

uint64_t tivxMemHost2SharedPtr ( uint64_t  host_ptr,
vx_enum  mem_heap_region 
)

Convert Host pointer to shared pointer.

Parameters
[in]host_ptrHost memory pointer
[in]mem_heap_regionMemory region to which this pointer belongs, see tivx_mem_heap_region_e
Returns
Converted shared memory pointer

◆ tivxMemShared2TargetPtr()

void* tivxMemShared2TargetPtr ( const tivx_shared_mem_ptr_t shared_ptr)

Convert shared pointer to target pointer.

Parameters
[in]shared_ptrShared memory pointer
Returns
Converted shared memory pointer

◆ tivxMemShared2PhysPtr()

uint64_t tivxMemShared2PhysPtr ( uint64_t  shared_ptr,
vx_enum  mem_heap_region 
)

Convert shared pointer to system physical memory location This is mainly used for configuring physical address to HW.

Parameters
[in]shared_ptrHost memory pointer
[in]mem_heap_regionMemory region to which this pointer belongs, see tivx_mem_heap_region_e
Returns
Converted Physical memory pointer

◆ tivxMemAlloc()

void* tivxMemAlloc ( vx_uint32  size,
vx_enum  mem_heap_region 
)

Allocates memory of given size in the shared memory carveout region used by OpenVX data buffers.

Parameters
[in]sizesize of the memory to be allocated
[in]mem_heap_regionmemory heap region
Returns
Pointer to the allocated memory

◆ tivxMemFree()

vx_status tivxMemFree ( void *  ptr,
vx_uint32  size,
vx_enum  mem_heap_region 
)

Frees already allocated memory.

Parameters
[in]ptrPointer to the memory
[in]sizesize of the memory to be freed
[in]mem_heap_regionMemory segment ID

◆ tivxMemStats()

void tivxMemStats ( tivx_mem_stats stats,
vx_enum  mem_type 
)

Get memory segment information.

Parameters
[out]statsMemory segment information
[in]mem_typeMemory type

◆ tivxMemResetScratchHeap()

int32_t tivxMemResetScratchHeap ( vx_enum  mem_heap_region)

Reset scratch memory.

Parameters
[in]mem_heap_regionMemory segment ID
Returns
0 on success else failure

◆ tivxMemTranslateVirtAddr()

vx_status tivxMemTranslateVirtAddr ( const void *  virtAddr,
uint64_t *  fd,
void **  phyAddr 
)

Translates a given virtual address to a file descriptor and a physical address. The following conditions regarding 'virt_addr' must be TRUE:

  • allocated using appMemAlloc()/tivxMemAlloc() on ARM
  • memory block is contiguous
Parameters
virt_addr[in] Virtual address to translate.
fd[out] File descriptor corresponding to 'virt_addr'.
phys_addr[out] Physical address corresponding to 'virt_addr'.
Returns
- VX_SUCCESS, and the content of 'fd' and 'phys_addr' will be valid
  • VX_FAILURE, and the content of 'fd' and 'phys_addr' will be undefined

◆ tivxMemCompareFd()

vx_bool tivxMemCompareFd ( uint64_t  dmaBufFd1,
uint64_t  dmaBufFd2,
uint32_t  size1,
uint32_t  size2 
)

Compares two given FD's and returns a boolean based on whether they are the same or not.

Parameters
dmaBufFd1[in] First file descriptor corresponding to compare.
dmaBufFd2[in] Second file descriptor corresponding to compare.
size1[in] Size of the first descriptor.
size2[in] Size of the second descriptor.
Returns
- vx_true_e, if dmaBufFd1 and dmaBufFd2 are the same
  • vx_false_e, if dmaBufFd1 and dmaBufFd2 are the different

◆ tivxMemTranslateFd()

vx_status tivxMemTranslateFd ( uint64_t  dmaBufFd,
uint32_t  size,
void **  virtAddr,
void **  phyAddr 
)

Translates a given file descriptor to a virtual and physical address. The following conditions regarding 'fd' must be TRUE:

  • allocated using appMemAlloc()/tivxMemAlloc()
  • memory block is contiguous
Parameters
dmaBufFd[in] File descriptor to translate.
size[in] Size of the memory block corresponding to 'dmaBufFd' in bytes.
virt_addr[out] File descriptor corresponding to 'dmaBufFd'.
phys_addr[out] Physical address corresponding to 'dmaBufFd'.
Returns
- VX_SUCCESS and the content of 'virt_addr' and 'phys_addr' will be valid
  • VX_FAILURE, and the content of 'virt_addr' and 'phys_addr' will be undefined